|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 [( }4 D7 G E$ `% \; R% \
#include <linux/init.h>
# X9 m% {: q; y" q( O#include <linux/module.h>4 D" S2 I7 a! E- F) c, I1 i
#include <linux/kernel.h>
2 h2 }, T) n2 ?. \' j6 x- Q#include <linux/types.h>
3 u* \0 A. `& Q$ |/ Q$ ]#include <linux/gpio.h>
3 [; ~# ^! w' a* u9 P z1 G/ z#include <linux/leds.h>& m9 \! Q, e+ f/ H0 J3 j" S
#include <linux/platform_device.h>6 f# H; T- j I2 K0 J/ e; m
V( v) R g( S; i- M$ q$ a0 d#include <asm/mach-types.h>- O+ j& B, a H& Q
#include <asm/mach/arch.h>
3 H8 I) ^9 i( i4 b+ J#include <mach/da8xx.h>
, D- ~# k) [) d- [9 P8 U#include <mach/mux.h>
6 L5 f0 K; H7 b; e7 s7 @. w" t5 X8 S4 }! z( O3 G
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' f o6 R1 ^6 s+ b( y" z9 |) @0 j#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% J- H+ D$ H' J, V+ z @, S
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); B5 N( p. ?: l
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" D& g' a! n Y" O; l
7 w* a/ D. ^* h7 l" w
/* assign the tl som board LED-GPIOs*/
* N. W6 p/ e6 ]0 I0 S5 m% \" estatic const short da850_evm_tl_user_led_pins[] = {
T c* c( J r" J# b /* These pins are definition at <mach/mux.h> file */4 l$ a. i5 N& L7 N9 J; V0 e
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) y0 S( ~/ `# ~: [ -1$ |* ]4 ]9 F+ {' K' ?8 B, `4 E
};
& u: q1 g$ \ {/ h- G% a1 {, P" ~
9 I/ _ K2 H9 j' T' sstatic struct gpio_led da850_evm_tl_leds[] = {$ C" ~' Y q4 [+ D4 _- ~
{
9 r1 M% U$ f* y S4 [ .active_low = 0,0 d/ R3 h4 n: }* }4 A; h! x& @
.gpio = DA850_USER_LED0,9 S0 `3 o! |, f9 T
.name = "user_led0",8 ~+ M M. a- J% X
.default_trigger = "default-on",5 U- H& S9 ^5 f9 T4 [
},
' h! I4 x3 z5 L6 Z& r4 h$ N {
% C4 ~9 v0 V! Y1 n4 K% G .active_low = 0,
# m ]- d: p- i) q! w .gpio = DA850_USER_LED1,
2 U8 e# T% |% P+ B0 @ .name = "user_led1",
1 m, r- t' f/ N% m5 E) l* a" ^ .default_trigger = "default-on",
1 ^( {( F5 w; ]+ Z) g' @ },$ o- Z1 d2 e6 @
{
: N- z4 p. G* \+ y4 ?: d .active_low = 0,
?2 T& l+ Q/ z .gpio = DA850_USER_LED2,: n5 n' H( v, S; ~
.name = "user_led2",
( @) m- m8 ?" }8 b; Q( Q .default_trigger = "default-on",
# i7 o4 ~6 b& X. U! F* H) R },- e' {% o8 j1 m2 }
{
7 L: l6 }' g, L. w( L, j .active_low = 0,
( i: h+ T) J* T1 V0 e7 M .gpio = DA850_USER_LED3,
% _3 `7 b8 |5 E4 M6 b: @- a .name = "user_led3",& |, e5 R% ~$ c9 ?5 _2 L( m1 l/ u2 @
.default_trigger = "default-on",
5 |% M2 p' v* E6 `$ O, g) m. o },
+ L+ @( R3 E' @0 l9 u};
$ y! c$ a" ^1 Z- ]) Q K* y @8 y/ d! G7 s" M' Y% h( t: n3 r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { L7 e8 W0 d6 _; g7 |+ G5 y+ A
.leds = da850_evm_tl_leds,3 ?$ j2 U% C0 j! P$ J d3 ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: j$ g# I4 O3 A F};
/ x3 I+ B. {' L7 _) ?& f
# v! m T8 |- e W* ?static void led_dev_release(struct device *dev)
* n; w, |" }7 r. k{
3 c. e$ i `5 M- e2 q/ i};7 V$ {! z0 G( x! B" U3 w2 e3 U" c
. q3 W8 W; y* R! Hstatic struct platform_device da850_evm_tl_leds_device = {
, a5 c$ Q* C, T* R s .name = "leds-gpio",
' z& t# b3 `; Q5 e .id = 1,* l7 U/ W, s7 @: N8 p# y. S
.dev = {
& O4 B( A, L6 R) F9 l* \0 y8 Q .platform_data = &da850_evm_tl_leds_pdata,
: g l2 D, K- S) @" h3 w* [' I .release = led_dev_release,$ J! W0 I6 s" e( k! V3 x' E: b
}8 ^+ ]) G m# P( z/ ^, O% q. X1 a
};* O2 t/ s7 n# u9 @1 ~' ?/ w
7 G0 E4 T, f) ^) c, }/ P
static int __init led_platform_init(void)
+ U3 g4 M0 Z: i% S" A- j3 t [{
# P: r: b9 c# w. u int ret;
5 j7 q" o4 T: d9 y& p- o" T w( }( j#if 0
" i) S1 X+ e' Q$ \* r: p: |0 z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 y0 x" `" u- S3 i4 |0 \' L if (ret)
N) O' ^) v( j$ _1 n pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 k! r$ X- `6 H, u0 w( v8 p
"%d\n", ret);
: t4 G! [ F8 M# \: F#endif
2 r1 _3 }+ {* R7 {) h' A0 p ret = platform_device_register(&da850_evm_tl_leds_device);& E3 k \% H& E/ m, o
if (ret)5 U* ~2 O; u9 K: U! w
pr_warning("Could not register som GPIO expander LEDS");' u! u4 t2 Z0 F. ^ n+ f
else" A- J0 `* l. E& k
printk(KERN_INFO "LED register sucessful!\n");
4 \2 o" N# ~) B0 b- }' y
( E& B+ E9 i- Z: W1 _1 N) P8 j2 W return ret;
; b4 v5 [; H# ^; w}; a5 [6 E7 A) }4 l- R* j2 w
6 Z! k$ Y/ l, I, Rstatic void __exit led_platform_exit(void)- X1 b) R8 p( i
{. V0 T; B; y4 ~. w; \" N+ J
platform_device_unregister(&da850_evm_tl_leds_device);1 H" y- q* H; n& @
# B2 i9 h3 c6 J* d printk(KERN_INFO "LED unregister!\n");, h: w2 R/ B7 r; \
}
9 q6 P [( {$ \% i# f R% U( S4 m3 T5 q, p. f. |/ j
module_init(led_platform_init);
9 C5 _. k' |. g7 O! _5 @, }: }module_exit(led_platform_exit);' j/ T9 _7 v9 U9 C2 P/ x1 f
$ `6 D5 Y6 m; y/ C' A3 h9 ^3 WMODULE_DESCRIPTION("Led platform driver");; z5 k3 ?" c8 w9 ` A8 x
MODULE_AUTHOR("Tronlong");) l) j+ |( E- W' h8 o# v4 |, y- ]
MODULE_LICENSE("GPL");
0 ]: c _) [* R. |+ w/ ^
2 I( Q/ x. \ l+ _' Q, X! n |
|