|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 S. m' Y- P; H. Q- j8 a5 n/ \#include <linux/init.h>5 U* n& E3 [! v$ p Z& }6 j
#include <linux/module.h>/ }8 \/ a+ M5 x7 I% n8 _
#include <linux/kernel.h>
9 O; |' K# V& G8 Q) Y#include <linux/types.h>
! j2 M! e4 }$ S7 J#include <linux/gpio.h>
# Z! q. ]9 Q; E5 s! w4 M6 Y& ~% r. j; X#include <linux/leds.h>
" P9 \+ F, s( z. _- \' ]0 v' `) v#include <linux/platform_device.h>6 G( k6 q5 F( V0 R+ V, b0 t. z
8 a1 M- O" h4 W7 p& f& }% Z+ `#include <asm/mach-types.h>
3 R3 O5 X. v" z9 q; b+ {#include <asm/mach/arch.h>! {2 d! L1 _7 C( _
#include <mach/da8xx.h>
9 t/ [3 z( x" w, L. J G#include <mach/mux.h>* H" k6 X- n1 f) b1 o& q8 O
) ?. Y8 {; `+ R
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 o9 D/ E7 s% ?6 q2 a4 G, K#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ B; t& u1 B0 L* e2 {, x) W
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 d0 r( d# }0 y) t2 e) \
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% G; T7 t6 x7 v( T( q* S/ h8 P
& D% q8 [. \. _! l: [; D/* assign the tl som board LED-GPIOs*/- o! ^3 y% [0 F, R5 b
static const short da850_evm_tl_user_led_pins[] = {! z) C* l7 C& L( m" } h
/* These pins are definition at <mach/mux.h> file */
3 B; D L" s* t' B: ` DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 H. o0 v" C4 Y/ z- y -1
' k9 N2 ]! O7 s* W8 c& \}; @: C, G4 X9 r4 o9 ~6 T
) a$ r$ N1 M H9 Zstatic struct gpio_led da850_evm_tl_leds[] = {
9 b* w5 n! U( r/ A C5 s, _ {2 H# K: o, f1 q2 ] Q! U
.active_low = 0,
# K0 b/ h6 f4 t .gpio = DA850_USER_LED0,2 s7 }; p& b. s
.name = "user_led0",
6 e5 Q% H- i7 I .default_trigger = "default-on",2 C3 g( w, I; w. d# ^# x+ k
},, D% `( N) x: E+ P- w
{8 _1 p$ n7 H5 ]
.active_low = 0,# f2 o: K8 L" U! a- c7 a
.gpio = DA850_USER_LED1,
7 k F" r/ \$ o5 o5 X: ~9 I .name = "user_led1",
, L2 _/ U, b8 _" Z% g' k .default_trigger = "default-on",
) x6 F% j5 M, P$ i; s5 m },# y) e! _ f7 R, Q; U2 Y7 v
{/ N" M* U! b" y- @1 I
.active_low = 0," z$ I" e |" T% f4 F. f n
.gpio = DA850_USER_LED2,
; ^: H1 K2 @1 z( L! {/ y. W .name = "user_led2",- r7 Y- r8 J: |3 K0 b/ K+ \0 s
.default_trigger = "default-on",7 ]4 F& N$ S. m2 z: ]9 U& f. ?
},' t7 {; S: T$ y8 L( B0 h
{
2 s0 Z1 x4 @ I+ z8 z& \/ c" ]$ W .active_low = 0,* v& T3 R- d5 n' U( u, H& q
.gpio = DA850_USER_LED3,
% {3 i0 U) J" X .name = "user_led3",( J) \" D; @& M z) K9 ?" v
.default_trigger = "default-on",
! x# t' }3 Q8 u9 H },
l, z4 v n+ T+ h/ R};
2 @# \; @- M/ \" V: R$ W3 x
2 Q/ {3 A# p# y/ a; G& l2 Qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ x3 \4 Z: q2 \4 r .leds = da850_evm_tl_leds,
. K$ A3 B+ f3 r- n" U) L2 [ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, V2 z" u V0 c3 y7 h9 |};! s) R8 P- L& p. p
3 ?6 c9 c$ K8 C% M8 c
static void led_dev_release(struct device *dev)+ f* V; \2 p4 @! i/ x9 A1 a/ e
{
) S9 A- s" J6 f( a$ g& ]& s0 M; P2 C- S};9 x3 n) \& \3 F' F
& K+ P. h' F0 G6 Z) T$ Tstatic struct platform_device da850_evm_tl_leds_device = {% ~1 l6 Z& Y/ J, @ a
.name = "leds-gpio",
+ H3 H9 G' |# `5 \- d# b .id = 1,
& k( p1 w; u3 u- t# I- c .dev = {
$ B6 d% }5 n1 @3 e .platform_data = &da850_evm_tl_leds_pdata,
* ?' l& n' m. f8 K$ t* q; Z# O1 w4 _0 \) L .release = led_dev_release,3 z2 Q7 \( k% g# y
}
4 i5 B1 i# E1 Y$ \1 x};" \ n* K6 W* s4 W G; P* a, V5 M
. Q/ {5 C9 y9 }2 ]( T; {9 E
static int __init led_platform_init(void) Q( K. g L, j+ `# O
{/ x, ? n) [! E+ J
int ret;
) n5 I- c1 j$ h5 i5 v#if 08 \* H# l+ o% ?
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" c+ }' c5 P; F
if (ret)' T% Z* D9 u/ r9 x- M
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ `% w+ j4 X4 E6 H P( w/ a) W, _
"%d\n", ret); p4 a, m0 f: z$ E' n7 C5 {- n
#endif
/ H6 L7 R* Z: v! i ret = platform_device_register(&da850_evm_tl_leds_device);' Z- l1 }# f: ~& h% G2 o+ e3 X' z
if (ret)+ y1 o' H# a( s3 ?, d, V
pr_warning("Could not register som GPIO expander LEDS");3 S( L; v0 X! u: E" ]+ M
else. q% \& S2 P5 T
printk(KERN_INFO "LED register sucessful!\n");2 i9 S# T. c( X% T& r% y
. s* l) B7 u, O" w' Y4 k$ \ g0 Q* ] K return ret;
' [1 w# ~# l, F8 I! |4 ~7 Q+ p5 p* e}7 ?- K$ r! ^' ~( T: m
" o6 v/ v- W: i9 i: z3 c& D! Y
static void __exit led_platform_exit(void)0 B; D7 `' U, J+ i$ s4 ^: [" W# _
{. m9 ^% X* T" m% c3 l
platform_device_unregister(&da850_evm_tl_leds_device);
. l! z! _$ a' J/ j
5 T: \4 G( A: f7 y printk(KERN_INFO "LED unregister!\n");
9 n8 q8 ~2 [/ Q6 U}5 I; K* I2 F. S( C( u
" e! K! K3 n; t" Y& X: B
module_init(led_platform_init);% \1 y. c5 y# k* B6 k6 ?1 [" B( c
module_exit(led_platform_exit);
4 c3 Q& n$ V7 Q% v6 R& \' R/ l" G- r7 e
MODULE_DESCRIPTION("Led platform driver");
! ~: r7 ?0 \. AMODULE_AUTHOR("Tronlong");5 H: {6 b/ _- {1 h( g5 Y
MODULE_LICENSE("GPL");
+ G# t2 J" f5 w' z2 K; p$ m
7 y' U$ A( R/ Z" ~9 q5 Y |
|