|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 z) \. O- O# L/ i& M: x, u8 k
#include <linux/init.h>
# i5 P' A4 H6 U( Q9 X#include <linux/module.h>5 I% w! q1 S/ d9 D3 t0 p: K* e
#include <linux/kernel.h>$ P" g/ @0 M" l& n+ |5 O6 K
#include <linux/types.h>4 m( R- y" z U! V' l3 G5 `# ]
#include <linux/gpio.h>) K+ ?* z! R$ P6 _& V- Y1 L, W8 r
#include <linux/leds.h>
1 a7 N5 X! j4 y% l5 q2 d8 X6 A#include <linux/platform_device.h>
/ e0 P" [1 `, c4 G4 @1 t5 E% i% ]$ @
#include <asm/mach-types.h>. V' t* ~5 i% r3 O0 f, A4 c1 H. M
#include <asm/mach/arch.h>
0 [) m6 S+ i. A) ?+ A/ t, Y#include <mach/da8xx.h>" @1 n! p1 l) O% l) { l# j
#include <mach/mux.h>
6 P6 w0 M* ?% p N; X& s3 X: x8 v
& j; w/ P% X) m C" Q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) l; z6 q7 J$ R1 s2 B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* w3 R5 J0 f5 D3 }. E
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 _/ k$ q' r( {- Z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) L3 o, a8 x0 m7 s4 I
- P$ v# i/ A0 g/* assign the tl som board LED-GPIOs*/# i9 E9 b" P1 D1 `3 y& x7 [
static const short da850_evm_tl_user_led_pins[] = {
4 Y# b0 Z9 e1 h# y4 [ /* These pins are definition at <mach/mux.h> file */
6 X8 k) S" ?; m o) p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; ]) p/ Y: h* v: b1 ]
-1
& A$ @2 D) o- V b2 g; t};
2 k5 w( I$ @1 h/ M) O9 W1 c6 J* R, b$ F+ `$ t+ P$ U/ ]/ k
static struct gpio_led da850_evm_tl_leds[] = {
5 W" S7 k, [) R {
1 g4 x M# m0 M4 |* h .active_low = 0,
+ D5 i7 ?$ f3 |" H8 A: m .gpio = DA850_USER_LED0,' N7 y% X- m4 R n$ T
.name = "user_led0",/ E6 S+ W) A( W" }/ l
.default_trigger = "default-on",3 G. D$ V! M+ U: y
},
* p z! y* ]# S1 K0 z+ j e {0 t, z- p, q- M5 N
.active_low = 0,
) b& ^. v, |# q; `0 q .gpio = DA850_USER_LED1,
$ r3 D) u$ }5 G9 x$ O .name = "user_led1",7 b N& ]4 {$ m7 d( `! a! p
.default_trigger = "default-on",
/ f, i. l" f" Z$ \ },
9 |1 l$ V+ l }5 |8 m9 V u) j7 l {
6 d* l& c2 `6 o6 T0 X' w+ [3 @ .active_low = 0,
7 u# G* V' Y* M8 [. m .gpio = DA850_USER_LED2,+ f% d, S# d) F; h
.name = "user_led2",% {* `# O7 O/ M3 Z/ k- ?% b
.default_trigger = "default-on",. W, X, ?) w* c. G- v% y G# P
},
; _' j6 ]& U2 V L. G. R, h2 e {6 b5 a! v# w4 g* i) @0 K/ `! K! ?
.active_low = 0,! m6 m" x! ?3 Z
.gpio = DA850_USER_LED3,6 F( @2 ]& |: U- B
.name = "user_led3",
1 _5 U! G3 S: S# r" {1 h( U .default_trigger = "default-on", ?8 X1 x, s6 C. {; Z7 o" t
},
8 z' ]3 C0 k1 Y; ?% \# {};
{% n, D0 R h" M- G) A% u9 e' ~5 f& ~# m/ C6 @
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ G- M+ \6 u9 \; o6 o$ c: \; @
.leds = da850_evm_tl_leds,
5 r+ V3 F+ _. x% i .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 a/ d$ R3 [2 e4 V) Y: m2 N
};$ k9 ^/ u% Y' ]; n* c8 E! H9 G
* H: \4 r4 J: b1 }2 Ostatic void led_dev_release(struct device *dev)
1 D0 E6 ?, M: A) N; J2 ?3 K{
( Z1 q- W! J1 d0 ^};- R; x$ B# U. g. |" Z! ]
! F& `& x! V2 X# X' o# Ostatic struct platform_device da850_evm_tl_leds_device = {! r5 V1 X6 l. t. B7 Y, o
.name = "leds-gpio",
" ?% n6 }0 ^) T .id = 1,, H; W% e& o4 T7 \8 ]) i
.dev = {) \5 ] D3 \; K
.platform_data = &da850_evm_tl_leds_pdata,9 C9 r( u& L( T$ h! l$ @& K2 [
.release = led_dev_release,/ e2 o7 P1 r6 D b; A& S
}6 M; Y2 v4 J! b; o0 n* x# k5 w( T
};
1 W) O F9 k! z5 ~ q4 l! \' y( z. p
static int __init led_platform_init(void)
' \4 Y+ w6 L) P5 q4 D. p% S{% l1 j( a# r( h6 E! F9 e1 `
int ret;. C. L8 O7 j& M! n
#if 0
2 \1 n* }6 S( U# U ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); M2 u g( F$ a% m7 C3 L
if (ret)2 f _1 l F2 G# B5 n' X
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% Z& K% \1 ~/ B! ^) v3 C "%d\n", ret);: |7 @5 Z; L2 ^( B5 V2 w. B
#endif
% B6 @1 f" u8 ^8 \+ U5 Z @+ k ret = platform_device_register(&da850_evm_tl_leds_device);
) N- t" q; k- U* a' F/ m7 {& ] if (ret)
* w5 L/ E) [ u" l" g! } pr_warning("Could not register som GPIO expander LEDS");
' I ]1 c# L7 `1 W else" }! x G u" v
printk(KERN_INFO "LED register sucessful!\n");
$ V, w0 U4 ?3 O# c0 h O; w3 F+ S* E7 w0 S! G
return ret;: t7 J2 e5 ]& z6 H* s7 e
}7 Z; Q' ^, `- k" |
- A X$ G0 A# K+ @# Z. U4 a
static void __exit led_platform_exit(void)
0 B/ u/ C$ K4 Z* a$ Z( P) Y{" G, \$ A O# X. m- h. _
platform_device_unregister(&da850_evm_tl_leds_device);
5 U5 F% J3 j2 K& d4 m' b g* l' l/ E p
printk(KERN_INFO "LED unregister!\n");% q: { m+ H- }9 h
}
' ?0 x4 k' }$ Q' a- a2 I7 N2 \- U1 _% A" p
module_init(led_platform_init);1 t/ {+ O% R5 w8 @; f" r& g
module_exit(led_platform_exit);) t4 F* }2 G+ d+ k
# Y) }1 [2 G( p6 B1 N+ h
MODULE_DESCRIPTION("Led platform driver");
. p2 f! Q% h. H' j2 [9 L8 ? }MODULE_AUTHOR("Tronlong");3 [3 {% q) q7 {1 C: p" }
MODULE_LICENSE("GPL");. S" a G4 A0 w
% @' Y3 C: N2 W% i4 C7 J" r
|
|