|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 ]+ e+ m% n: k& a6 J$ ]$ x& i2 P8 E5 s
#include <linux/init.h>
, I$ z4 R- c; A4 m3 M6 L2 l#include <linux/module.h>
5 j* H% Q) D; z, ^- `3 o#include <linux/kernel.h>
6 T5 L- O) ?0 d/ ~& b% ]#include <linux/types.h>; z+ X/ E0 u6 r: j$ S) L
#include <linux/gpio.h>
1 G+ m7 `9 {" T0 s8 X: g#include <linux/leds.h>8 K! v, `0 D6 `" z; Y5 o
#include <linux/platform_device.h>
`0 E! ]) q+ t1 r: u7 V
/ t% e; P0 M+ Z" A#include <asm/mach-types.h>
4 W% v% N9 u6 Z; a; Y) i#include <asm/mach/arch.h>9 G4 P( r8 d" {$ @: N
#include <mach/da8xx.h>! j% g. d) q; N6 X" N
#include <mach/mux.h>
" l u' v: A; o, X1 \ d1 M
! q2 q4 Q. s* }/ R" ~4 i#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 A5 k, m- G1 a3 u. w#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- o O& i) _+ t* m H& D#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 R1 }& X+ H8 u# i! S) @: \#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& Z3 j0 A5 S$ q2 X2 i( }
2 m$ o2 F! @) P5 ?
/* assign the tl som board LED-GPIOs*/
1 ~% T) L5 Y) {9 f! S; I, K/ Gstatic const short da850_evm_tl_user_led_pins[] = {7 N$ l3 W8 g3 w4 x; X5 o' X% I7 s
/* These pins are definition at <mach/mux.h> file */' e3 l% U& e9 y' j7 I) }& y' j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ F: A# m$ K( E8 R: \- S. @# c, y; ?) o
-1" A6 | O, Q: n9 P" N) U S5 e
};
% F+ X S5 r* a
9 r2 b1 m9 o: {; U* z0 jstatic struct gpio_led da850_evm_tl_leds[] = {1 S+ e* p$ N9 `- m
{( f4 F( C# s& s4 a- j
.active_low = 0,# R5 U& i; w: V5 y
.gpio = DA850_USER_LED0,. V* f& M1 H1 c9 T
.name = "user_led0",) X5 ~ D* l2 J1 l& m3 W+ G; b" g9 w
.default_trigger = "default-on",
( B# g& A& ?$ o" I9 l* } },* P& @* p3 d" r; ~" Q- B3 W
{0 {9 {- b# _" F# V
.active_low = 0,6 j* H* q. C* o# `/ o
.gpio = DA850_USER_LED1,- L n j) |9 J/ S
.name = "user_led1",) t% v; u0 ^) P- [
.default_trigger = "default-on",
% ~' `) f. N, s1 @6 P },( c1 K6 t" Z( k2 z8 Z8 Q+ [3 R
{, Z( h" P6 V# c8 [3 F
.active_low = 0,0 Q' U$ e. F+ ?7 U6 J! q* W1 D. i
.gpio = DA850_USER_LED2,
/ S+ A; m7 t3 e1 N .name = "user_led2",
# q% U4 l1 p: _" ? .default_trigger = "default-on",8 F& D- x: e& I' N' H& o
},- Q( p5 ~2 d) D5 q9 ]0 m
{0 H' N# J" M9 q
.active_low = 0,( v% L6 V! |2 _5 ]5 O- G
.gpio = DA850_USER_LED3,0 I6 X2 q9 E7 ^, B8 A3 ]
.name = "user_led3",' Q2 L* [* U; u' b8 P& D, ^
.default_trigger = "default-on",6 e) V% r0 z9 z1 q: c
},8 r% y, H1 m5 f# X3 ?
};% }! n" f9 Y* J; v. t
3 t: l, ~; `- q. `- u! g2 c5 c
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* C; p% q1 d. @$ o F
.leds = da850_evm_tl_leds,# m0 P$ U% R* s- E2 a- ^$ \3 S7 m Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
! v% P6 q/ l! D$ k, a, F+ Z};
N7 T+ M* u4 a- d8 @
/ ~2 _" a, G% O/ C, ]static void led_dev_release(struct device *dev)' w% k0 ~+ W( k2 ^1 N- f i
{
: D: `/ l$ g5 w};
- J* g7 t, h" M& p, N+ _7 S9 |3 p9 T l& W& s F
static struct platform_device da850_evm_tl_leds_device = {" @: f3 U& Q- P, ]% t8 Y9 i
.name = "leds-gpio",# h) H$ o! q8 ]/ r2 k* s
.id = 1,
2 I9 p& D u7 l! K; R4 | .dev = {
. g3 F8 u+ H, _+ ]# h) Y/ [" H .platform_data = &da850_evm_tl_leds_pdata,
4 o4 y9 ^- ]8 R& h .release = led_dev_release,, R) j! z/ z/ p$ C9 M
}
2 O6 c1 T% _1 r) k+ }+ _};
; u* q7 n% \- x; I$ t6 [# V! ]* W
2 m; s3 i; G1 F+ P, m4 X Estatic int __init led_platform_init(void), y- G8 u! P4 r e
{: v: d& A2 Q9 E6 D, E
int ret;
0 b" Q! Q; c' Z" I1 ?7 C#if 0: w2 p7 z. U. Q7 ]6 p- M2 l
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 I F4 y8 ^% P. T4 s o: c
if (ret)+ X# I: @- a$ W& D4 C$ U4 G* d
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") P; O( _0 m, M4 a
"%d\n", ret);0 L4 r4 J! Z9 I: F4 i* d2 T8 o
#endif" V3 Q( Q7 ` X$ C
ret = platform_device_register(&da850_evm_tl_leds_device);; R2 C- L \4 ?6 F- I! I
if (ret)# z; R4 w* T$ d" T T
pr_warning("Could not register som GPIO expander LEDS"); L' h" `3 r$ v/ j6 Y* b4 w/ J
else F" S! [& S9 M/ ?
printk(KERN_INFO "LED register sucessful!\n");
8 s2 p7 x( h1 f% _4 o1 S- f( E+ x: i, j
return ret;
) R. ~ Y/ o4 y8 a}, \; G& k& a* K/ p- w2 K6 x
1 {7 H& p1 w8 f. \6 w! `( V, J' x
static void __exit led_platform_exit(void)
+ b! O+ U6 |. Y$ ]$ F& Q0 [" k% Q{6 p( o& Y8 b$ ]5 h2 l H
platform_device_unregister(&da850_evm_tl_leds_device);
+ Z& w! y: x9 u* N0 D$ N7 y& B% M# \+ U
printk(KERN_INFO "LED unregister!\n");
& A. ~' K @9 s7 R& _ n}
5 A4 _: w+ t+ `8 z
! M) I2 m, i7 f! U/ Ymodule_init(led_platform_init);; @3 o0 L; {% \! R; D
module_exit(led_platform_exit);
! M. M) `2 O) J7 a6 V2 L
f, d6 h2 j+ P0 A. KMODULE_DESCRIPTION("Led platform driver");
$ \* f: X6 U/ D$ O& E, f/ TMODULE_AUTHOR("Tronlong");: D& P6 I2 `3 y) ]3 E
MODULE_LICENSE("GPL");) f3 T% Q" \% j% G) t
# K) n: Y/ G! H: p9 Z: j |
|