|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 h% Q# v3 ?( V; }4 S a7 L
#include <linux/init.h>
6 l2 [/ f0 @1 o: j#include <linux/module.h>
& }- q* m8 l4 q" [* s) h7 @1 }#include <linux/kernel.h>, b" o7 L- R2 x" ~
#include <linux/types.h>. n" x0 y# L! a; ^
#include <linux/gpio.h>
6 }' k+ s) D* B& g#include <linux/leds.h>6 c$ j2 D- x" |
#include <linux/platform_device.h>7 y2 ]5 F, B1 `# @6 w9 A; y9 V
3 ?' L& S* r4 p) }
#include <asm/mach-types.h>; c s( A* w H! i3 a# x4 ~
#include <asm/mach/arch.h>
' N7 G& u2 D$ z& b2 _3 {! ~4 P) @#include <mach/da8xx.h>
0 {' X7 r$ w% j# a2 e#include <mach/mux.h>
4 _, L; L3 D1 v9 u. k& P @6 [0 p! ]$ G9 f9 [" `9 o) A
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): j; p$ W2 E5 k- J% q+ y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. v1 r* w/ _5 d. x* i) I4 W( I7 J#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). h4 @% f1 r3 C9 P
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ n Z7 t2 E7 d
+ Y( @( {! g- E7 d/* assign the tl som board LED-GPIOs*/4 m" g8 D! R H: m8 W, X
static const short da850_evm_tl_user_led_pins[] = {+ k+ f) X: |. p9 l
/* These pins are definition at <mach/mux.h> file */ u! T, h" N9 l9 Z S) n
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! r$ L1 z7 g P6 k9 ~: R
-10 k$ t6 k% i2 S1 D% y2 z
};7 r% q$ M4 V: H8 D! ], {
U2 S+ K& Z) P2 b/ u1 Xstatic struct gpio_led da850_evm_tl_leds[] = {+ B8 L9 ]5 ?2 n' |
{6 X% W4 k9 c' C0 a- {
.active_low = 0,2 G# B2 V9 `* }# \
.gpio = DA850_USER_LED0,; u& U [+ c: m2 o, M1 }
.name = "user_led0",
3 q8 k7 Y- ?) }" H- ?6 i .default_trigger = "default-on",
& J0 d8 Z/ q( l# d6 R0 g9 t% X },! P; g7 C! b; w5 ^; I5 q5 J
{" r( m9 f+ Y: p' A H
.active_low = 0,; g9 n& @, w" c2 z
.gpio = DA850_USER_LED1,
" d$ L( B8 B- }! c6 a .name = "user_led1",( W" t8 M% x( f' q+ H+ c- D
.default_trigger = "default-on",( x& w% p; S5 d7 C6 }3 R
},
8 v; v2 w' e1 T& ]3 d! |& A {9 g1 O2 l9 D* T2 v$ [
.active_low = 0,( u" T+ C; V# G5 u1 g
.gpio = DA850_USER_LED2,
) O# W1 j) W; | ` .name = "user_led2",# h; b, q4 V( i4 t$ U3 q' l9 ~: u* s
.default_trigger = "default-on",
( }9 o2 w8 H$ f, p3 d },2 g0 ~: U! E' m
{, Y( s' _& L6 G% ]- \1 W
.active_low = 0,
- x+ V+ i$ A! Q# S$ z- N .gpio = DA850_USER_LED3,. |0 n6 E$ e# d/ z7 Z9 g6 l
.name = "user_led3",9 L6 S' U0 F4 v' v6 F# P
.default_trigger = "default-on",
& _2 Z& W& B" z, u },
- q. s: U* a% D) F7 U$ i& ]% P};
; J r3 T/ M, `- d U6 r2 y- j! ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
B2 w. O5 g6 `' C7 Z. C .leds = da850_evm_tl_leds,
( t* T9 p+ K t0 @' E .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% d/ z3 e. N( _, q8 V- i9 x! u( ]" o
};
3 j* \* @" N8 N% N: t% d
2 Q7 R+ d! ]& r+ M5 Astatic void led_dev_release(struct device *dev)+ i3 K+ q/ b# D6 W, X
{" ^! V8 ^, \+ I. Q Y$ G; R/ T5 T
};
) E. D$ y# h+ o5 K" Q4 }
+ k4 {5 i3 V+ m9 \ v9 [0 o. Astatic struct platform_device da850_evm_tl_leds_device = {
0 R% ?; Z( B: Z7 d3 \. t .name = "leds-gpio",$ k' [7 W: s; B& c
.id = 1,. C. w% p+ ]9 L) C
.dev = { Q4 Y4 y! h% i8 |# }3 b, ~
.platform_data = &da850_evm_tl_leds_pdata,- {* M) A* f% |
.release = led_dev_release,$ S2 p: |" c/ G9 @' ~
}/ h* J7 G* n, I. b- L
};
# ]$ l2 \1 S* c C2 h4 X+ O$ g/ ]( _' l; S" R" P1 T
static int __init led_platform_init(void)
( C ^5 {7 Q: Q* I{6 ]' O; a- O; E0 B3 d! x/ D
int ret;8 x" S, }$ k$ m+ {
#if 06 l, ]' s5 A4 ?& \2 _7 b0 _+ f2 b
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 j7 P3 J9 m8 Y/ N
if (ret)
- O2 ^6 ^0 y. w pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ \- N+ B0 p4 R: O# q1 V1 L8 R n
"%d\n", ret);
: @* p' @2 s7 e- S V#endif
1 e3 t6 z3 x2 T9 W+ q, J ret = platform_device_register(&da850_evm_tl_leds_device);
5 L' T' g- s2 b& x if (ret)# _( O# t; L8 W8 Q& K9 m1 q( Z, d
pr_warning("Could not register som GPIO expander LEDS");( N s$ O' R& M! P
else
/ Y9 B z/ }& W$ y3 P6 L, ]4 f; O printk(KERN_INFO "LED register sucessful!\n");7 L3 }8 J% p4 k x
4 k! A' z' C6 W0 D. G/ i% S
return ret;: v# ~: T& i, Y" k
}% I# X9 o1 \1 S5 C
0 K# v5 R4 \- y8 B8 B# |
static void __exit led_platform_exit(void)" j4 V6 E- |2 G% }9 X
{
! l1 {- z, _1 Q% ^1 V+ P3 V platform_device_unregister(&da850_evm_tl_leds_device);
4 C) ], _; Z( f8 G, c. z- @/ I4 Y n/ l2 c
printk(KERN_INFO "LED unregister!\n");# F. ^* }: q2 k4 q9 B7 n! \
}
) z8 V9 D. d9 {0 X3 C: V( {; ]- Y% }* z0 R! @
module_init(led_platform_init);
' y( j! x$ X8 Tmodule_exit(led_platform_exit); n0 ^+ y( B5 \5 }6 _' g
; p- E' C% x: q1 U# T
MODULE_DESCRIPTION("Led platform driver");
1 {& a) |4 y: _* K+ {MODULE_AUTHOR("Tronlong");
+ h) J8 w. m( @4 l' qMODULE_LICENSE("GPL");- J. ]0 g4 l! A" m; m4 Y; z
) t5 l" W4 \, K |
|