|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" z) p- W- c& ~
#include <linux/init.h>
+ W+ H2 M# a, U1 B3 }4 Z#include <linux/module.h>
+ ?. I6 o2 U2 I$ `#include <linux/kernel.h>
, r: m. c* p2 J. t2 J/ P7 [#include <linux/types.h>6 F, U' G% S+ j3 J6 `/ G
#include <linux/gpio.h>
* b* T+ W* J5 W3 d: A1 i#include <linux/leds.h>/ T {& g# u) G, `5 n3 K
#include <linux/platform_device.h>
+ `8 ~) D0 l/ S/ T
) K6 C' X9 d- n5 q$ ?#include <asm/mach-types.h>
' H& n/ d( \ B7 ^6 l7 Z) H+ Q#include <asm/mach/arch.h>
1 i# I9 U6 ^( B% J, w: R#include <mach/da8xx.h>+ \8 ]& r" ~# U# z: U0 [- O
#include <mach/mux.h>
( p1 S1 ^9 u9 i; g# y" j: \/ F8 d6 \/ O; ^& r+ D: A
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 T) k# @( Z5 K$ u4 o3 l
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. k& s6 \9 c* t1 l- ]' Z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 m1 I3 a1 [: Y+ |
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 R4 l1 {5 ~7 S
2 R1 Z, s4 I1 F; ~/* assign the tl som board LED-GPIOs*/+ J! G1 z" H. Y) [# I
static const short da850_evm_tl_user_led_pins[] = {+ c [3 ?) b h" S7 ]2 X5 v5 T+ ~. B* ?
/* These pins are definition at <mach/mux.h> file */
2 A3 R& `3 s! A DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 I. p! x) F3 u. O( S1 M6 T
-1$ q! _: r- d0 V8 u2 H
};
6 i! {) g f9 X$ q5 c
. m# s9 b2 Y3 kstatic struct gpio_led da850_evm_tl_leds[] = {
6 g4 Y9 }7 s/ E& Q" o. ]5 X2 c4 U! m {* i/ `! l5 t6 L" b4 P
.active_low = 0,. K- i9 M# E# p/ Z
.gpio = DA850_USER_LED0,3 U9 E ~7 G$ Y& U6 T3 x p
.name = "user_led0",$ |: w& A# n1 n m# j( u
.default_trigger = "default-on",9 O- z4 [! N) ^
},
* y' | a' c. k$ O {
1 ?, z- z3 W- N1 k9 }5 f6 i .active_low = 0,
5 O, C5 K/ m! w* H7 L$ w .gpio = DA850_USER_LED1,7 u2 r. C" o0 o
.name = "user_led1",/ u/ V0 I x# H) a5 _# t, m& k
.default_trigger = "default-on",. h& l3 L$ \8 I6 u9 ] @
},
/ I) Y( K' H- Y {
3 g7 ]; ^8 Y6 R8 y4 x .active_low = 0,1 [! d, e5 `. e$ Z; X6 n- N2 Q
.gpio = DA850_USER_LED2,
" k& P( B2 }5 S3 K .name = "user_led2",
3 P* N7 f+ O! Q; _+ d! p .default_trigger = "default-on",' Q$ `3 C8 m j
},, [9 g1 n8 H6 F5 a1 w9 L
{
2 i/ }" F( r; o3 d3 z .active_low = 0,
" B& I% O* }. w$ V( r% ^ .gpio = DA850_USER_LED3,
. Q W0 A/ r( J: ^ .name = "user_led3",6 v* a- z, A; ^3 y) D. A$ N% B
.default_trigger = "default-on",9 Y/ T+ u) |1 @; v3 m% \
},# C, c4 K; W) k+ ~7 x, |
};
_+ p' H- S1 h; F1 h9 T- I, K) u. ]3 `$ D5 C5 @' s
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; }- |/ l2 m5 }5 m3 i, _
.leds = da850_evm_tl_leds,9 h4 Q7 G" H. o+ v3 d; Z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 @" z7 A, U# Q- v/ ~8 A& i};* d6 r! c( E, J ?
/ P7 A7 X% j: G5 k: }! Kstatic void led_dev_release(struct device *dev)* @; j* `. D) ?1 c
{1 d2 L) f: H; R8 W- f8 E
};
& Z9 L6 ~- r- q) ] C+ x! X5 c5 w/ j8 t) O; W! `) R
static struct platform_device da850_evm_tl_leds_device = {
; z- l0 f6 d2 s' o; g9 d' Q5 ~ .name = "leds-gpio",
2 ] l* j! Q6 P) u0 s .id = 1,$ o! t# b% ]4 X# w3 \# q: J- R
.dev = {' r4 M% {3 s: t) {# E, u% n
.platform_data = &da850_evm_tl_leds_pdata,2 L! ]& \1 K3 [2 c7 k+ b3 V
.release = led_dev_release,) h! x" Q8 z& l j" M* R9 d8 G
} i7 C0 C) w' s; f5 u' E
};
6 c9 X9 v) d+ Y C7 U/ G# s
; v* L, {3 q" K3 {5 P2 O* rstatic int __init led_platform_init(void)
' M0 P; V0 |# b7 a2 h) q{3 F+ ^: W! g+ c4 _" ]3 Q. _
int ret;
) }9 ?$ x( x% l5 j#if 0$ O2 P7 Q- M( A5 m4 {* I
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 a' ]& N7 F' A, [+ w
if (ret)+ B* g: E$ _/ x( K
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ T* c% n7 ?0 R& t. h "%d\n", ret);( X- o7 ~, |' K) w/ A+ J, A
#endif
) `) y0 p6 w; ~0 m2 S ret = platform_device_register(&da850_evm_tl_leds_device);
0 f. r7 o; \4 h! o( l" H if (ret)4 q+ h, O( Z# c
pr_warning("Could not register som GPIO expander LEDS");+ `$ u$ J ]& g. n6 t5 n( d
else7 E% `+ x8 a+ j9 h2 }
printk(KERN_INFO "LED register sucessful!\n");
. Z" r- L8 f; z2 p" d% b. S: K9 v* p3 ~2 m% I3 U6 @0 M! j
return ret;0 ^- o3 r/ F U) E
}" k7 g7 x/ l# `3 B, Z$ o! `
* a! Z5 U* M2 u) x
static void __exit led_platform_exit(void)( ]! V" T! k r; |
{9 S+ B% U$ V* ?3 V$ U0 W( E
platform_device_unregister(&da850_evm_tl_leds_device);, F" x6 ?3 o+ o9 e' ~
3 [- P- ^) P$ P4 y) H6 w! i
printk(KERN_INFO "LED unregister!\n");5 Y& \5 w, O `3 @1 L4 u
}
! [, _* V, q" y/ k6 C& I' ^
7 _! p7 E J; f! {module_init(led_platform_init);% j/ ~9 J- C/ |) X$ ~
module_exit(led_platform_exit);
+ x/ t- C9 s5 S; [4 A8 x6 f) [3 v$ f% r0 H! I
MODULE_DESCRIPTION("Led platform driver");
t" h$ a7 {6 U' EMODULE_AUTHOR("Tronlong");
Y' h) u6 Q+ n2 JMODULE_LICENSE("GPL");
. L! X" z: P) _) U' ^9 u% b J8 K/ I6 }3 g- ?
|
|