|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& v& g* T* B6 P% I; c$ J
#include <linux/init.h>
" h1 |: C9 s5 t: V( ]#include <linux/module.h>
9 R" D8 Y; @- P9 `( o: p: ?#include <linux/kernel.h>5 Q4 R1 o2 ~& `' q& W
#include <linux/types.h>
8 L- ?! f. p3 R# m1 Y' F, M#include <linux/gpio.h> @# \9 R7 S Q* G, ]6 n
#include <linux/leds.h>
: H1 c2 M4 x. ]- W& u6 K#include <linux/platform_device.h>' E; x7 [$ n4 [+ P* S
8 z H$ C$ n, J4 D) P#include <asm/mach-types.h>
7 Z) a) {! e3 x" x8 M# M% d7 G7 N5 b, ^#include <asm/mach/arch.h>
# R! b2 k' s' `2 D#include <mach/da8xx.h>8 S6 k" L1 ?# I/ ], F1 j
#include <mach/mux.h>+ F t. w- r0 o
7 M" w E! E% Z9 t/ W( ^/ N#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 [- Y' N* X. E4 Q( t' \8 |& u% p/ V#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 b4 ?; p5 P7 b, H. }
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% z& ]; [- I- H; C6 h: c9 k- }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 d! v& h! j4 U# h0 c
; m5 l/ I4 |: Z
/* assign the tl som board LED-GPIOs*/
! V( B# V2 p! R- q& z' D1 ]static const short da850_evm_tl_user_led_pins[] = {
. w+ V: ]7 q5 C, F! y1 c /* These pins are definition at <mach/mux.h> file */+ @/ l3 ~. ^ f3 m9 h' c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& \' v6 } w# A -1
% K H0 @ t k};
: }% J1 B, }8 p9 x2 H) ~1 V& n, T. O: v- B' x( c
static struct gpio_led da850_evm_tl_leds[] = {7 A% J8 t- G b; \% @
{$ }8 T, X" \! X* W+ o6 I
.active_low = 0,# x; j5 S# D9 v! d& @/ w
.gpio = DA850_USER_LED0,4 g6 ?# i2 E. V8 |4 f9 j# b9 H
.name = "user_led0",
& e7 y) n$ p# W .default_trigger = "default-on",
U; _. M2 S1 o& t( D: Y) B" `0 {& W },1 c Y! Y# a7 Y# z
{
* L- q8 K; q7 O0 {: K* G! z0 W .active_low = 0, o: b5 i2 R+ M8 V& ]4 s
.gpio = DA850_USER_LED1,2 H5 {: m" L( q' g: F
.name = "user_led1",
! K6 e3 D8 z. W& m5 a .default_trigger = "default-on",
8 c; v( `+ z) ^% l" m; r },
/ i* s7 E& D; X3 o! A* f" F {$ Y) S: X- k" N" J6 z" n* P
.active_low = 0,
% c: O4 w0 I' a/ W: B$ n d .gpio = DA850_USER_LED2,
; I* p' d2 P+ S/ B .name = "user_led2",
, G3 D* v$ X- f .default_trigger = "default-on",3 U) k& x5 i% S( J, A
},. B4 r2 |+ V3 @# f3 {; }
{, M, \) [8 E" \7 w; D# S$ O1 C
.active_low = 0,
9 k( l! X) b) O' E- W .gpio = DA850_USER_LED3, e0 k/ O9 T! F2 p: V6 ^
.name = "user_led3",' o. V- F9 {5 `7 P# Z4 f
.default_trigger = "default-on",
+ e7 q$ u) v, K' a( j" [" k/ r: d* C6 j },
. S3 ^, b9 j* ]! K$ ?};
1 x% a, P- [& j! o5 s7 M. E. m; Q4 O$ Q6 I; i( R
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 n4 X1 U, k, Z! z( P
.leds = da850_evm_tl_leds,$ K0 @' c4 |- X$ {: ^5 O, S4 L
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 T6 W0 p/ P' R+ u& P. Y/ Z7 d' r
};
9 ]1 y0 y7 p$ `! Y/ V M
- s% t1 ~$ |0 N3 y0 w$ A% ^) ?static void led_dev_release(struct device *dev)
1 q5 u+ f- c7 w, E6 V1 P; I9 v9 @{6 g* m5 ~% p5 y2 d
};9 e$ _7 v* \/ Y6 M0 u" d: T
1 r# Z1 f |3 `# S
static struct platform_device da850_evm_tl_leds_device = {9 ~7 t6 T4 a: Q0 ^+ ^* [% b: z; n
.name = "leds-gpio",+ ?% S, H2 O0 n2 ~6 t3 k
.id = 1,
0 i2 K. g1 p Y+ o Z" C' r: t .dev = {
- d9 l' x" v# z0 U .platform_data = &da850_evm_tl_leds_pdata,
- q, X3 I6 Z/ N9 g .release = led_dev_release,& G2 p4 N: a+ [2 K. S
}4 }: G% @% u/ p5 s3 T& W; x* u
};
9 ?/ s3 |$ q) f% j% E4 F2 k
$ p9 P! ]% g/ R" h5 l5 Fstatic int __init led_platform_init(void)' K# S9 v1 a! m; z1 G' N
{$ m9 m$ }& N; T; d2 b
int ret;
8 D n) P9 j9 `8 V2 ]#if 0/ k/ z' b( Z( U& r2 I& W/ b; k+ h
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. P! M) L1 v: ^5 P% v1 q
if (ret)5 T2 W) v9 |9 c
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 n# A3 _) p) E! p2 { B% x
"%d\n", ret);
Z& `3 U" B; {, ]3 n. R9 j6 @#endif
% A0 j; O. p% ~8 M4 E ret = platform_device_register(&da850_evm_tl_leds_device);9 ~8 Y) K7 g( r' n9 Y
if (ret)# G/ G3 ?( w g5 ^% b
pr_warning("Could not register som GPIO expander LEDS");' X/ m2 s( {8 U0 |. W
else9 p$ J0 b/ [, P3 E# d
printk(KERN_INFO "LED register sucessful!\n");
) m- B9 N2 c5 Y: f, W5 f" L* u6 _# I8 N1 s; e) m* z9 h
return ret;
) C3 R4 P9 h. N6 \1 n- _/ S}5 b8 F D- B. k. m6 L
9 }6 J& T1 F! ^9 }4 Q$ a( V1 xstatic void __exit led_platform_exit(void)
7 p- c6 W. i. P" V7 B q! ]{1 R# q2 E, W! `2 B! P
platform_device_unregister(&da850_evm_tl_leds_device);
& H" ?- y' ^- W3 n
" z4 ]& v& a! D4 K- A- [ printk(KERN_INFO "LED unregister!\n");' p( J$ ]; ~' N; l( u
}
7 j4 ^$ a! Y6 n, ?+ ?6 E8 u- Q- I+ C2 n( j0 \* D: @3 H5 q8 i$ t) J
module_init(led_platform_init);
3 |+ X" h' [" Umodule_exit(led_platform_exit);4 G9 H; p9 R9 j; s# U
3 M5 }* v: l- |
MODULE_DESCRIPTION("Led platform driver");
4 M' J" H6 `: n. U! D: TMODULE_AUTHOR("Tronlong");
1 x+ K$ b7 o+ E2 dMODULE_LICENSE("GPL");
8 U+ |/ U2 @6 z
; \3 H, r1 \) d4 n/ t v |
|