|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& ~% V* }; Z! {4 o
#include <linux/init.h>
7 {9 v2 ]& [- `' S#include <linux/module.h>, u$ i1 Q( a Q* n$ U5 n
#include <linux/kernel.h>
/ D7 g5 b* l3 K3 p#include <linux/types.h>
% A0 Z# [/ S( T8 H! @$ n; E#include <linux/gpio.h>" O# W% f- @, v8 H
#include <linux/leds.h>. h- } \* r+ T
#include <linux/platform_device.h>: D4 l$ G) X0 }6 n% j) ^/ _5 _
$ ~5 \8 R+ n% U
#include <asm/mach-types.h>8 H) \, a3 d" y1 K2 h
#include <asm/mach/arch.h>/ \* P) D; ~% E+ l
#include <mach/da8xx.h>6 }3 S* r% w2 c4 f/ C
#include <mach/mux.h>
& E/ ]; u$ a' D/ f0 B- y- d `' T/ X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 B0 R3 Q: M- b2 r4 W# D
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ C- @9 T3 |' x+ a7 c4 x+ V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& g6 X( m0 V* {9 G' z. s# ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): s+ Z9 A8 f6 Q- W) O& e, Q
1 }7 K L& l3 Z$ y* S+ a( \/* assign the tl som board LED-GPIOs*/0 T1 n3 u% ]' m1 K w
static const short da850_evm_tl_user_led_pins[] = {5 _& }7 }6 c7 I ~) Q; |
/* These pins are definition at <mach/mux.h> file */5 T, P; ?" q! |" w/ z! ?2 h6 O7 E
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 t& `- a2 _- ~5 F# }, X0 i -1
2 z( S" t2 D/ F( _0 w; G( }};
' q9 p' W J6 o8 T* U! ~4 h9 w2 X! I$ T) F3 j4 o( M# I" q( b+ ?
static struct gpio_led da850_evm_tl_leds[] = {
! p- r, y- g4 J9 H6 ? {
+ m0 o7 W; R+ w( Z6 r .active_low = 0,% u( w( J& X3 S) V% B* ^
.gpio = DA850_USER_LED0,+ W. ^/ y% K) }2 U. D( J. C( X
.name = "user_led0",
9 e, R& E9 o9 `( X( N .default_trigger = "default-on",9 }: d( E+ |5 d! d8 _
},
) t' L" x+ c0 y0 R$ E o2 k {
+ S7 O& T9 l5 s. L# P: ^. E; q5 K .active_low = 0,
, u% i% _( i% G8 P1 i/ p .gpio = DA850_USER_LED1,% _( i2 F6 l! b2 ?& ]* S
.name = "user_led1",
% i. }3 j* ]& I/ U5 P T: |% R .default_trigger = "default-on",
8 t3 Z6 N# H3 \: ^( ?9 n },
4 u; Q2 E. D! i2 i( b: i7 S, J8 ~ {* _) q6 D7 B1 \/ R" F+ \
.active_low = 0,, h. I9 P( a e
.gpio = DA850_USER_LED2,
" f% C4 B i y .name = "user_led2"," y( w8 j1 m; q9 ~4 ]
.default_trigger = "default-on",! O( C! X4 n( S# a0 {
},
9 U) k" p9 Y( M( i" k {' ?$ H: u1 W7 ~, A4 e1 x) r' X
.active_low = 0,
% f! | [8 h9 R+ Y .gpio = DA850_USER_LED3,, ^. P' E+ U& \% d' T/ V# ?
.name = "user_led3",
4 u4 ~; h& k2 g& V .default_trigger = "default-on",
/ b, N: j& d W8 g* s* b/ w },% `" N9 Q, ?- @( x2 _
};
6 y/ h2 J% x( u: R5 B0 v- ?6 ~" m
3 O4 [- O; @9 E; D* _* S+ }8 H% c3 Vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ q( Q3 m* i- W- K
.leds = da850_evm_tl_leds,
' a8 g, @7 m, [1 y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* m, B: n" \& _2 ]) ^# c3 P};
3 v3 o( A K* _
4 C; P0 g w. X8 F1 Y( p5 hstatic void led_dev_release(struct device *dev)
9 n7 x* o- \8 @- r. O{$ f6 c( m5 i: h9 ~ f* H' V/ s
};
1 l4 c, ], b5 j9 b
) a/ ~* q7 L: H7 h. B3 l* Jstatic struct platform_device da850_evm_tl_leds_device = {7 V& k: h( M9 N- F$ N
.name = "leds-gpio",: z+ _( _1 e! S, z- E0 W7 X
.id = 1,$ i' L4 |6 O+ O8 P) G! n: M; |, }
.dev = {" k; W8 n) F& Z( @5 r2 D
.platform_data = &da850_evm_tl_leds_pdata,
6 p4 |' v2 b% O .release = led_dev_release,/ Q% c4 ^. E! q& w- j. H7 x
}
q! n* b7 W7 a9 G0 P0 R};
; x5 P9 m3 [) U
+ @! [6 i# Y* w% K0 ~static int __init led_platform_init(void)
% ~# n9 O# B$ L5 X8 _/ A; A* U$ @{- W0 ]% d, }: x5 j- q
int ret;& R8 Q2 S5 G( G; B: i) a
#if 0: ^ f/ M) Z; {
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 ~% e% C& ^/ R! [' O4 Z6 X
if (ret)
; N) {" R, D+ x/ H pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" ], c6 l5 y }' c "%d\n", ret);* Z7 T/ S$ X6 e! y: {" H
#endif
( U4 T( M ^7 N) S( ? ret = platform_device_register(&da850_evm_tl_leds_device);
- L8 q: X" n$ ~ if (ret)
4 t: f% Q8 ^3 E$ H' j pr_warning("Could not register som GPIO expander LEDS");/ Q- y" r' d6 r( F2 D
else( D: j+ m+ o' a& |
printk(KERN_INFO "LED register sucessful!\n");
, S$ m* ~" k( z: G( T4 l4 h4 v$ L/ J _( `
return ret;
) P# h, X) |) B" e" }& Y+ J}0 c* h& e' C: ]1 A: Q) z+ f
. W7 V- e5 X+ a$ v0 @1 o$ e
static void __exit led_platform_exit(void)- O0 K% s9 V, r8 S3 @8 Z* h4 e
{- F3 w: |' F U( B4 D
platform_device_unregister(&da850_evm_tl_leds_device);
/ C% h- x0 j9 ^ s8 I+ D- S
# N* A, }4 j- a2 o Y: y printk(KERN_INFO "LED unregister!\n");& M% a9 O( B [$ f/ |
}
/ i; Y1 H+ p1 Y, f0 c! a# k+ h2 g$ q" L3 ^* a# V! x. A
module_init(led_platform_init);: }( Y1 T6 [1 Q/ v+ @8 X
module_exit(led_platform_exit);7 B' V4 J0 W/ @$ [* s
9 ]* `9 D$ Z; f' N& F4 n) ]/ rMODULE_DESCRIPTION("Led platform driver");
6 o9 J x6 e$ H) _4 J! ]MODULE_AUTHOR("Tronlong");, k w/ z; M9 @9 l! x1 ]
MODULE_LICENSE("GPL");
8 x+ r2 r% }. K2 V7 ?
/ T p5 b# M* ]/ ~* p7 R) ` |
|