|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 R) n# }& A0 ^ B: ]#include <linux/init.h>
) _$ Y+ U/ o' H$ Z' }#include <linux/module.h>
) {2 A" e. }: C* t& T H4 P#include <linux/kernel.h>( C/ _$ o) i$ Y" Z6 J
#include <linux/types.h>
2 W" ?# S6 M& M, X8 C3 r#include <linux/gpio.h>" \+ k( j* @0 R: x
#include <linux/leds.h>
$ O5 u/ P) T& K+ g0 ^#include <linux/platform_device.h>
/ E0 E; g* {2 N- [0 i4 N5 C* o2 Z5 [& l& K8 o
#include <asm/mach-types.h>1 j8 w& }$ N( V% d( m, ?
#include <asm/mach/arch.h>
0 f0 w% p0 _4 X( g, t6 a#include <mach/da8xx.h>
( b2 D- U8 [( H6 J3 m7 X- _8 t#include <mach/mux.h>
$ t u. l2 t4 k1 m! H8 J
$ \& n, Y4 D! i' ^/ f, j- }% b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* A# p8 q5 i2 @/ m* P
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% A) U; Z# A! n5 ^' \& E5 |% o
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% I& ]& U* f4 i1 S- B) O' G#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! n' e9 e. W+ M
$ X7 _/ r3 ^1 H. r7 S/* assign the tl som board LED-GPIOs*/
- t. {0 k- I' K6 `" Sstatic const short da850_evm_tl_user_led_pins[] = {
- J! u% R+ }/ p' C2 J! Z /* These pins are definition at <mach/mux.h> file */
7 m0 z; O0 S% L5 \! | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& D, l3 {$ p& w
-1
/ I: C, M7 @8 Z4 h0 T};( K: m; B; Z) L2 @6 l6 ]
% L1 E% _$ Z+ ~2 D; K, K0 @5 |static struct gpio_led da850_evm_tl_leds[] = {
& S; Z5 y* D- o6 G" w {- j6 l) K" [+ U7 W3 O5 U# a) I. ^ Q
.active_low = 0,7 x: ^9 S- R7 e( y! a$ O
.gpio = DA850_USER_LED0,
/ N: _& X8 F' M: F' N .name = "user_led0",
' z! M( ~$ K* F .default_trigger = "default-on",
& V2 K8 @1 `1 v" y) b) y2 w },
& h b$ w& G6 p2 P9 q {7 N6 I7 D, V8 W; |6 n) B
.active_low = 0,0 w+ N2 m+ O! }2 [7 F, \
.gpio = DA850_USER_LED1,
1 n( l( G. A) D Q .name = "user_led1",
; w' g" p0 a( d5 v6 S& U+ n, T .default_trigger = "default-on",$ }1 p- Z5 e6 f8 M2 H
},& I' m" q3 ]* u( Z* \9 u" ?
{0 t, p# o: v* V& b a
.active_low = 0,4 v7 M6 k" q5 B2 A4 _9 A
.gpio = DA850_USER_LED2,
4 l- e) M) {; G) j) U, W .name = "user_led2",
1 O* O5 o: H/ T4 u4 k .default_trigger = "default-on",; B& a$ Q, P5 x, [! h% _: {+ e
},
9 P) G( E/ j9 M* f5 A \ d( \ {# t! I2 R8 p- f% Z h
.active_low = 0,: K* x, q8 X5 q6 P1 j0 y ~( s
.gpio = DA850_USER_LED3,
4 p& X2 l! p; _2 m4 W0 i .name = "user_led3",
* v% |( [/ R7 S ^; ` .default_trigger = "default-on",
! h6 b/ \8 b2 x },
! x/ I1 g" U! F) S- u8 x) x0 F};
* r0 r( [7 O* }3 A5 A6 M3 p
* i$ j; t& s, _5 v6 Q, S3 `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' ~0 U3 p5 [' `+ K/ Z .leds = da850_evm_tl_leds,
7 V1 N4 L, N1 t8 M% h .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 ]1 a0 t: z- u' T& ^7 t+ s};
' T" L+ p' u2 V- `. L, T
! _! ?( t5 J9 C/ mstatic void led_dev_release(struct device *dev)5 [, q. a4 G- w3 V/ }1 o, J9 ^
{
4 t5 m, q$ p x; }% P};
9 P3 v `5 n4 ?7 d _ T
" P. J" O/ E; n4 c4 V' Y3 vstatic struct platform_device da850_evm_tl_leds_device = {% [& ` ?4 S# ?4 c3 @9 P
.name = "leds-gpio",
4 h3 c2 O' D. H .id = 1,
. N$ X% X8 u2 |3 ?5 o$ |( B% v4 M .dev = {
8 g# s) j$ e* u( Q5 M2 e x .platform_data = &da850_evm_tl_leds_pdata,+ c3 g) w* \# }& Y1 c' s5 w# C
.release = led_dev_release,
+ Q6 u3 o0 @" G9 t2 J0 D, A: f2 T( K }
$ m! M, H& X$ ]9 R};
# Y& s% S% v) r8 U8 s v( N$ z4 C7 V. f
static int __init led_platform_init(void)) i! `. I+ y1 n* O* F, |
{, S# c% @, }3 K7 ~6 @
int ret;
2 o( F4 U# V+ V4 \, A Q#if 0
F9 W+ x# Z1 O( } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" x7 d2 N1 R8 I2 m6 d+ v
if (ret)# I- w3 x4 q' B {2 X
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- i4 y- I2 e) q/ c! V "%d\n", ret);
2 |+ V+ Q8 ~& b2 J O+ @#endif
4 Q" [+ d* y8 z) w1 c4 { ret = platform_device_register(&da850_evm_tl_leds_device);
% c) c5 O# K( O: ^- c if (ret)$ Y n5 h3 _0 D. ~
pr_warning("Could not register som GPIO expander LEDS");
0 o9 ~7 e/ G% |9 r else: R- q0 X0 D0 q! N1 O
printk(KERN_INFO "LED register sucessful!\n");6 i5 u1 @/ r5 {* s
" m- S$ ?) e5 l" P return ret;
$ v9 G1 }. d- e4 C}" C% O4 V/ W4 p& F
, ~/ v5 F8 r3 o
static void __exit led_platform_exit(void)
) C9 i" q b, [{; j2 _9 [6 C! s2 I) _1 j* ^; M
platform_device_unregister(&da850_evm_tl_leds_device);, Z& [- {2 P7 V/ a/ S/ [
+ H$ `6 \7 P" F; Z printk(KERN_INFO "LED unregister!\n");
' g0 ?$ o5 P" f. A1 C7 b9 G4 @}
/ R/ m! ]' t! z- e. E$ y
' K: u4 y1 m9 l. B% Rmodule_init(led_platform_init);
% {% G2 @; N a0 f6 V4 r) k6 r* Bmodule_exit(led_platform_exit);( l: L9 T- x4 |. v9 f: p
! ~) `3 t5 C0 c! j* x& iMODULE_DESCRIPTION("Led platform driver");! D% n3 O& `, j5 ?: z5 i9 M+ r
MODULE_AUTHOR("Tronlong");
% D4 m( q: R' J y' vMODULE_LICENSE("GPL");' S4 \3 ^* q* y) g5 V" C2 \7 n3 N; l
7 D' M# ~ e; O& J( c( C& I
|
|