|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 C# @* V. ?- \ T9 C) R
#include <linux/init.h>) j9 k4 a6 z' E7 R$ W* @# o+ }
#include <linux/module.h>
) P$ m* t0 Z9 j1 Q) |#include <linux/kernel.h>
' u! N' x9 P c2 m5 I#include <linux/types.h>
% R9 e+ P* m1 O; Z7 ]* C& x) f#include <linux/gpio.h>
4 I, r8 g# B' e" b8 y" m; ^# r#include <linux/leds.h>
/ R. @: [8 N, `0 T: f* }" ]#include <linux/platform_device.h>
: V1 s+ c0 _8 V+ m* i9 M* d
0 s# O+ O- X) D" ^* I J9 M/ {' R#include <asm/mach-types.h>( G3 s! z0 R) c% V
#include <asm/mach/arch.h>
' x/ \3 Q" Q4 C4 i$ U6 y4 h/ e1 q#include <mach/da8xx.h>
Z1 i. C, j8 g1 B. s8 b#include <mach/mux.h>1 [# A) [1 }7 N4 [! G9 i
3 O( n5 q R0 g#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* P/ ]" y7 B! @3 w; I& f
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 V4 ?4 G0 a- m- m/ V* X6 C#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 Y- P9 O( B1 I2 ~
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, s9 j4 ~; q2 f6 V" q% I/ r! n
# l6 o1 ~- B3 O$ @! e9 y/* assign the tl som board LED-GPIOs*/- @) a/ p6 J& ?' o5 p
static const short da850_evm_tl_user_led_pins[] = {: X2 [$ @3 z4 r' _1 C% X- R5 _
/* These pins are definition at <mach/mux.h> file */$ k) H- ?! ^8 A0 a! @+ G: J- H- M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 R, b+ s9 O. ? -1
0 I0 |6 X: N3 \5 A4 A: |9 Q};; D: P% q8 Y3 f8 q: _% g
6 m" B i% J9 P: |/ f! Ystatic struct gpio_led da850_evm_tl_leds[] = {
! m) _ }) p( P6 n. x {, i& h" T/ x* _$ I$ E
.active_low = 0,
s/ q$ Z O5 k% ?- |" i0 h. T .gpio = DA850_USER_LED0,
5 z. }' m/ M. U4 ^6 A6 B .name = "user_led0",& G' X9 l R. p/ ] m% u0 Z, A
.default_trigger = "default-on",
9 ~! G2 g" L3 r, S1 G) A z },
. v# J p& U" T- t" k {" V3 Y, m7 L( n. ^$ Z m9 Y2 Q
.active_low = 0,
# f# c3 r6 X% G( }1 ~" w; ` .gpio = DA850_USER_LED1,
6 [% _- q3 \8 ` F7 D% M* u .name = "user_led1",
' z) u+ v' X L. s. u1 E .default_trigger = "default-on",2 K' ^$ {+ T k2 a) r) h
},/ z0 m' p8 S; h/ S6 }& ?$ t
{
2 b; y2 a# l* N& v .active_low = 0,! z/ m+ R# B0 a+ l+ N* @
.gpio = DA850_USER_LED2,+ V. D4 J5 [$ m, T
.name = "user_led2",
. L/ r9 |0 U+ m: }* E5 Q& U .default_trigger = "default-on",- y" N9 w+ V; B2 l/ A# r h4 T
}," Z! A7 I8 q6 b: }) P
{
" S D; H6 h- d8 m! k) O& v .active_low = 0,
- a y7 x& V0 Y" H2 b5 C .gpio = DA850_USER_LED3,7 b: q+ G; ~% ~0 |, ^' \
.name = "user_led3",) d5 P4 K8 j, A7 d7 H
.default_trigger = "default-on",% ?+ n! _( F# ?9 n7 H+ t) q
},5 _5 ~) W% w4 ~: B) j
};" `* \& e: T4 B/ S/ D) ]
, P5 N1 q# D6 H0 j! k' f- w! f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' W3 x& \1 |# M% ~' u$ Q" g .leds = da850_evm_tl_leds,* b- E, I9 \% @4 v4 \3 R) H9 {
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 H7 ~; J8 w) [8 l
};
$ V9 n& u/ N) L" I9 r
! X! [; k& W, n1 C5 x) Zstatic void led_dev_release(struct device *dev)1 n" t; u9 f J8 `: c, C9 O( W
{
9 m, f+ `1 n2 S: @. M8 E6 F2 L};
8 r8 T1 G! c- l+ p! m- r
9 |+ V4 [* @# s! m1 dstatic struct platform_device da850_evm_tl_leds_device = {7 @% l* P$ j X
.name = "leds-gpio",* Y, G+ X: m0 u$ P! U6 ~9 J
.id = 1,- t3 X& i7 ^% w6 [
.dev = {
0 W+ b9 S! D5 U2 j' P .platform_data = &da850_evm_tl_leds_pdata,
. x" y" { a4 Y( E4 d .release = led_dev_release,2 Q, k9 h7 J7 p: a/ E
}
D! Z' f/ Y" ~, f1 x2 W2 a};
: C6 H! J: Q S3 @" x, f
5 @. N/ C/ e. M* n$ L& Rstatic int __init led_platform_init(void)
' U3 N! X+ V" c- F{) [: v8 j+ g: @. a8 K
int ret;
1 D+ V" o: B* |2 \6 p9 k S! G#if 0 ~. Q8 T, R7 D0 ~% m }% ?7 e
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 @* G+ H" h/ q+ k6 \1 E) ?
if (ret)
9 a6 u! E* }8 H" T# @5 B pr_warning("da850_evm_tl_leds_init : User LED mux failed :": i R0 u; L' ^
"%d\n", ret);7 o7 b; ~7 h$ Q- m9 e N k# _
#endif6 R8 T% r1 \3 h7 o( Z, P& M, r( O% Q! _
ret = platform_device_register(&da850_evm_tl_leds_device);
f9 u, H, m" E" h if (ret)
D2 l5 H/ y. J! M pr_warning("Could not register som GPIO expander LEDS");
, \( }8 J/ t( F1 [/ P5 ] else
9 D: O8 h' D& @; S0 r M printk(KERN_INFO "LED register sucessful!\n");
* o2 S+ h2 X; @; E% j, J+ R) l e( o8 t' ]) W
return ret;0 I6 O) r/ D2 J6 m y8 {5 ]$ Z* J
}
- m4 y9 D: g( m! f1 E. W: |# I9 ~5 V$ w% H
static void __exit led_platform_exit(void)$ U- t1 X! Q( K5 C7 C$ l
{
2 n. c/ F' ^* g, }5 B platform_device_unregister(&da850_evm_tl_leds_device);/ L) R! E! j9 t# z/ p
$ [' X7 ?3 ~4 c% Q" j$ Z$ e printk(KERN_INFO "LED unregister!\n");& x6 ^' \! t) s* U- {8 `5 W
}, R( e. d! r, e3 a; ?. y
; H. y* n# i# m" ]. Z
module_init(led_platform_init);
4 N2 ~! w' |( E" tmodule_exit(led_platform_exit);
8 S; _8 D5 O0 m/ z# H& N7 n& O3 Z9 Y m3 l- y# n4 c, ]3 P
MODULE_DESCRIPTION("Led platform driver");1 W2 c/ o) P/ ~5 c; C
MODULE_AUTHOR("Tronlong");* K5 ?- L0 ~& B7 p. A% k
MODULE_LICENSE("GPL");# ^# u! t+ _1 Z# ~
y9 ]: b9 x, A+ |' W |
|