|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" t8 |. Z _7 p
#include <linux/init.h>: {% P& c N8 C8 u+ M
#include <linux/module.h> K5 u4 P8 ~5 B5 C. j! {
#include <linux/kernel.h>' A: O$ C2 R2 L- b, C F
#include <linux/types.h>! q: Q: O4 |: B: ?. y. w9 k4 z
#include <linux/gpio.h>) b! B$ y! U. ?$ C5 g$ _6 c
#include <linux/leds.h>1 H# [' k7 t- y! }$ \
#include <linux/platform_device.h>7 f6 _- p0 h- G( q! m7 G, }
1 Q) o( s4 [$ R1 g+ D8 }* [1 |7 ^#include <asm/mach-types.h>
. B9 u0 d! E# a% T) g2 S9 D#include <asm/mach/arch.h>
0 a" l) m: Q: N. K/ b. o#include <mach/da8xx.h>8 |5 v7 A# k5 c! D3 P$ c# \
#include <mach/mux.h>: j" w. Q( O `" }& C2 u1 t
- I% k* D" y( v: }5 t
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 P. q* B- ~' x3 r1 o: j: q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 d" \. x- M* f2 N8 v
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' Q( i |# s$ E, O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- T, R6 u* ^4 }, ^# g( _& Y! D2 H h: g) F- z: ]
/* assign the tl som board LED-GPIOs*/
$ E) ]& R' H0 j/ c0 l9 m: P3 Bstatic const short da850_evm_tl_user_led_pins[] = {# p0 O* n! j2 L7 V) j4 B
/* These pins are definition at <mach/mux.h> file */
: y8 b5 H9 L' O DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 }1 p% ~0 E, }1 l8 ], p8 g4 g; A9 V
-1
$ p) |& x5 N, \: \& Y};' \. t# f0 f) q" @. O. Z2 y0 \* ^
! C, C' F7 V7 c, R% j$ b7 tstatic struct gpio_led da850_evm_tl_leds[] = {
2 h* p$ x k- z; \, V {
7 E/ q/ }' r" Y7 a% N8 r# F: ~/ X .active_low = 0,
; ^. G C! c# g; Y3 v( g: @! J .gpio = DA850_USER_LED0,( K1 z7 J& L8 o- @
.name = "user_led0",
4 d7 O7 t7 K6 r% a4 I1 \ .default_trigger = "default-on",
/ k) Y5 h: E3 @8 F/ t },
- h S/ q( h |- d3 U# T8 D {6 p t* l2 f# |3 l: b7 D. k
.active_low = 0,) \/ I5 f% l2 c3 S& z/ g
.gpio = DA850_USER_LED1,( O+ e: N# J; L' E' n+ B
.name = "user_led1",
* F- A! T1 M% p- f% @ .default_trigger = "default-on",! t+ }7 v0 K- E% H; {" N
},
( G, y0 D0 Z: e! O/ U6 L) L {
: Q0 i* D1 j3 k( ^" v .active_low = 0,7 V- Y' X! V$ z7 Q
.gpio = DA850_USER_LED2,
$ }; J. u1 Y. O- w2 V: e .name = "user_led2",+ q/ F; C" M! q
.default_trigger = "default-on",
5 s! e A, K$ C },
/ ?- N# P; S9 }7 r% o/ P: ~ {* p" r o" k5 y+ f
.active_low = 0,
& M5 f8 r" F0 `0 |5 i) k: e .gpio = DA850_USER_LED3,) t e) E1 h* V7 f+ S/ P; N
.name = "user_led3",
( Z+ b, A. x! X& U, K7 {. x; C9 O .default_trigger = "default-on",
3 ]1 z+ I5 |1 }) } },. D" o0 b% B. e9 j1 B$ n/ b3 U/ L- z
};7 K1 t- p, T+ [# h* ?7 y4 u" b( d
- F- S. l9 c" Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. H1 H( i8 C% h* L0 S .leds = da850_evm_tl_leds,- Y2 K9 y P6 _0 T# P
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),# _$ k+ o& B+ d1 Q+ J
};
0 ^, E) J9 G' [6 y0 ^2 o
) a: n" r; k' M( bstatic void led_dev_release(struct device *dev)
3 v! o' K: `8 L8 o6 L- c, m{8 @' N. q5 C( l) I" I
};
$ [$ \& z; j" I3 q6 n$ P
7 C# H; c: R: M0 {. c; H; dstatic struct platform_device da850_evm_tl_leds_device = {1 G- d' N7 Z5 J# i8 c0 e
.name = "leds-gpio",
% V5 g8 b6 W; b* N6 o j .id = 1,
7 j3 d9 B- X" |9 J% a' t- n .dev = {" \* U9 C( O: n& G
.platform_data = &da850_evm_tl_leds_pdata,
% k, q4 j _5 v .release = led_dev_release,
2 [$ f* ?& D4 B5 f; ] }
( A) G: @( i/ H0 i};7 v$ X% V( e1 l: ^- U
% z" J: V. H- q0 N! E) O7 Fstatic int __init led_platform_init(void)
" F8 |8 _! y* W q1 ?# }9 F{
. ^1 t9 t0 Q; F" e' c4 A# } int ret;
4 G' I' ~2 n6 ^; L0 {# ~8 I1 k2 v#if 0
6 n6 W8 c! ~% [; Q8 O ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* K. I& P$ K {; U- P( A+ X if (ret)
) |) L: z" b# A5 W5 Q! } pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 w* r: }% N2 a- k. r
"%d\n", ret);% A0 h- ?' t- d4 ?+ L% {% C
#endif
0 b0 r" x) {, }7 X ret = platform_device_register(&da850_evm_tl_leds_device);8 x. E4 ]4 Z- E, L9 S$ e; k
if (ret)9 R9 ?9 F! l/ B8 v
pr_warning("Could not register som GPIO expander LEDS");
' [, d6 l) n+ v' b& k, Z3 w else& V; C: s5 c6 ]- E9 g
printk(KERN_INFO "LED register sucessful!\n");
5 [. N9 |, l M* `% ^9 y; v5 N3 V6 A* y
return ret;
$ b/ u4 O# q3 L3 e# U* F0 F}
; s8 J- S. ]) q1 M
' U/ B# u( s7 Q7 H0 E8 tstatic void __exit led_platform_exit(void)
+ ~$ M3 X6 }: p5 f' F' S& X{; s& i( B% Y0 e# G- A1 c
platform_device_unregister(&da850_evm_tl_leds_device);
* `- G! @5 ^9 L0 E4 u: [# t% F* ?# m6 _
printk(KERN_INFO "LED unregister!\n");. R- o: m; v" f, P# P0 ` ^7 A
}" p4 z! c3 v' s) b: p; ?, \
7 S7 y9 K& k6 umodule_init(led_platform_init);1 G6 x8 j4 W! Q( K m4 j( H2 t
module_exit(led_platform_exit);
; b9 @5 g$ A3 P' L
0 C; b8 V9 a/ ~; P' y+ p; u) zMODULE_DESCRIPTION("Led platform driver");
/ l1 } J+ Q: w4 a& I0 j7 P0 WMODULE_AUTHOR("Tronlong");& _% T* T; t6 A- {! I% G/ C [& a" w
MODULE_LICENSE("GPL");0 W9 V" D0 H% h" i, O
! ]% O8 I* t' O
|
|