|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( `6 W8 }; }" p5 f
#include <linux/init.h>
2 k+ p- Y1 Q- T#include <linux/module.h>
f2 ?% i- i9 b5 p1 u# k#include <linux/kernel.h>
9 c2 ]' {4 F& n#include <linux/types.h>/ Z0 X' r- X: L4 Y) n
#include <linux/gpio.h>7 V4 `* F2 R2 p8 Z8 y! K
#include <linux/leds.h>
5 k- u: v m* X" b u#include <linux/platform_device.h>$ s4 g8 N9 {% F {; E( W
: u% O1 E$ N* M+ v. F5 H7 ?" r
#include <asm/mach-types.h>
) r0 n5 g0 p% C# I#include <asm/mach/arch.h>
( I2 ~6 K2 i9 }#include <mach/da8xx.h>
) R: `* t! V4 V3 K& s; F#include <mach/mux.h>( @* J/ y; |9 ^4 f% h
7 _. Z: j3 h- i
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 }# {3 ]/ y& _, c- y5 C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' e) ]) Q' l8 m/ C. V! d5 ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# T% E: d$ m9 ^+ y. T' o- S
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! u R% g9 O* o8 Q D# _. A
, T9 P* E" {' W8 x2 l$ m/* assign the tl som board LED-GPIOs*/
1 D4 h) y! F$ Z& T4 Astatic const short da850_evm_tl_user_led_pins[] = {; Q7 K# p' _1 M
/* These pins are definition at <mach/mux.h> file */8 I+ F4 R, \6 c3 N: k, n# w
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# t8 w* C# r& @. m$ @& \# d1 { -14 T1 Z7 Q) E' a+ J$ F
};
* D! `' T: ^) s. ~
" I5 y |3 K1 j1 p/ C3 g9 ~static struct gpio_led da850_evm_tl_leds[] = {
4 C4 s8 y/ Q2 b. _! E' a3 g {
/ Q u$ {9 v& ~2 T/ G( k& \, ^ .active_low = 0,
1 J2 x, d8 q* y& } .gpio = DA850_USER_LED0,
1 s0 n$ ?& B2 L, r& d1 s# V .name = "user_led0",& G5 E0 ]. @: U" U* m6 @5 ?2 \
.default_trigger = "default-on",# I0 h+ Q- e# L( X0 K
},
& P) d% D5 t$ { {
( E0 |! J2 C7 L J7 d .active_low = 0,
9 `* o( m% I1 v9 X .gpio = DA850_USER_LED1,
, p% F4 n$ o# Q2 s9 @+ P9 W .name = "user_led1",7 t' l4 |- g2 u5 T" q& s3 {
.default_trigger = "default-on",
- l$ j- M& q" a q, h; C, u },
. C0 i5 H. m) P$ l4 d% t {
4 R: }8 O. a+ A6 I6 p$ [) ^ .active_low = 0,
$ I# u. V. R; U .gpio = DA850_USER_LED2,+ e2 r9 `" y% g
.name = "user_led2",
+ @& h5 Z. |2 Y% g( F S6 j .default_trigger = "default-on",
, c' I' S! E7 Z- W },+ X$ _0 a$ M# B- }
{: d4 K) X9 j' T
.active_low = 0," u) I: `" c( i4 Y7 j7 R7 o
.gpio = DA850_USER_LED3,
6 S7 P0 Y( f5 f j8 F, S .name = "user_led3",
7 A1 `; d# `7 r8 }- K" W .default_trigger = "default-on",3 Z, R. u9 E" t
},
5 O2 m/ K6 @4 t: H% F- x. Z};
! n, T, M/ }8 k8 J, `% L* z% E6 D7 H! x' j5 d% I; P
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 K4 z& R; Y0 ^2 F
.leds = da850_evm_tl_leds,& H* G7 f* M3 I4 @2 B
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 M! ^6 W% h: B6 W! U9 H! A};& e3 r! q6 Q+ z( c$ ? R4 {2 `, B
- d o1 C5 A' x) L% d) {8 v& Qstatic void led_dev_release(struct device *dev)" y8 L% p8 \: t2 v3 y. A
{
$ \' Y/ P, }* g* @( _1 F};: B: N' P6 \. M2 t) u8 M
1 j" @8 ^ k$ n% ?0 P/ j W4 zstatic struct platform_device da850_evm_tl_leds_device = {3 U2 l3 ^5 |, y
.name = "leds-gpio",
6 }) a" a, R5 X N( v8 [! ~9 |) |8 u .id = 1,' S s( x4 Q) x- N# g
.dev = {* r1 t& m4 p9 D. v, |
.platform_data = &da850_evm_tl_leds_pdata,
- q& G E+ G$ @3 K6 a8 V/ R .release = led_dev_release,2 v( _1 r1 g7 G, [$ \3 H
}, S h1 I1 E0 v) s
};
, H* c. ]) l5 e" R; ?& W4 i5 O- T8 t4 g
static int __init led_platform_init(void)6 H4 _; B& ?5 W
{( |" }" [" W* p, I
int ret;
1 Q! y# z& \) @( P; K#if 0
; U) G* U5 K7 { ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" R+ f1 G! D4 c. {! B1 d. ]- X
if (ret)7 T+ a+ q' l% K+ {: q" a: v; h; i
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 S- }9 ~7 S5 m
"%d\n", ret);% B' D5 Y/ ]4 Y. ~2 J& d
#endif( N i3 ~: N, J( c& @
ret = platform_device_register(&da850_evm_tl_leds_device);! \% e: L( B$ w: K
if (ret)
, I5 s5 I" M# A( F. q- o6 w) @7 h pr_warning("Could not register som GPIO expander LEDS");
; @3 L, h( N# ~ s else
3 T3 ?) G! y! U5 }8 N2 D( S' | printk(KERN_INFO "LED register sucessful!\n");
9 E. O1 d% z3 |! n) ?
) y8 S+ d; }6 h. ]$ y return ret;
5 |; b9 n# j. E3 r+ J ]# g}
- }3 I( i( h$ f( {+ M& W& x0 u
) I, {( q8 b+ q+ _9 Wstatic void __exit led_platform_exit(void)
# ~( l6 F" _, P# Z{
5 d; {8 e! |) S' k. Q3 U* K( H. ` platform_device_unregister(&da850_evm_tl_leds_device); F9 F6 C7 V, Y' O0 X5 J
+ l6 y7 T* j, O0 y printk(KERN_INFO "LED unregister!\n");
0 U$ h/ N# |0 b7 R4 _}2 M' [- y+ m# Z7 ?
6 C/ _ B/ i# Z$ }7 y( e
module_init(led_platform_init);* _# g6 t+ m; k/ D
module_exit(led_platform_exit);4 z2 h8 a; o X) W2 h
7 c9 _- }. y- v+ DMODULE_DESCRIPTION("Led platform driver");, S2 L3 _, I! A5 \0 P4 N" @( e/ D
MODULE_AUTHOR("Tronlong");
! y- J" B) b: o2 ^MODULE_LICENSE("GPL");' {/ ~, A! Y0 ]; ~
U1 c5 ~: Y I) K$ M* A; T6 J d
|
|