|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- K" o- P/ s7 _# g$ y- k: z
#include <linux/init.h>9 P4 }0 X+ o2 i2 R/ K6 x
#include <linux/module.h>
4 y$ q1 ?& S# O/ j% D2 R0 }4 N6 l- v#include <linux/kernel.h>
' n# ^' X5 C3 C8 d" N#include <linux/types.h>
- A/ C% S) ]: @. m/ P( X: V3 m#include <linux/gpio.h>
$ x* m$ Z7 c& }) `$ Z/ _8 N5 I#include <linux/leds.h>
- h( D' n' u0 i6 b, _5 M% k#include <linux/platform_device.h>
- y _6 }7 g2 A0 @) ^* s' }6 h: C3 X. i) S. ?
#include <asm/mach-types.h>( p/ l! Y9 s% [% S
#include <asm/mach/arch.h>7 E# `2 y9 D+ g. |( G/ s1 z
#include <mach/da8xx.h>3 W0 \! b$ \, ~0 G- @5 ?* Z
#include <mach/mux.h>$ ?- L8 m/ k9 F* a9 ?5 _ [- R$ A3 n" U
! @- N% c7 ~+ H$ s# A: i$ u% e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% j+ ]9 n% D* b8 c9 r' D' v#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! Q8 r1 O* L2 b6 S5 I#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; b9 t( ]7 v* j- x- h/ z5 D3 M9 W#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 f3 R4 }5 g6 n. ~/ `3 {- ~
/ O% j0 o) E3 i! ]0 g( m/ s/* assign the tl som board LED-GPIOs*/
, ]5 u. `4 S1 G9 j7 }& Gstatic const short da850_evm_tl_user_led_pins[] = {$ u& v/ B2 [* o
/* These pins are definition at <mach/mux.h> file */
$ a5 {* W% H. `. `: i# h+ p ] DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' Q+ O* J$ j! B5 i; p
-1, |- U% d! L# P* P& I' }% Z
};
/ ?+ s6 c. W* C4 ~4 S
' X; h; ^. e) q: Jstatic struct gpio_led da850_evm_tl_leds[] = {, @& ?- o5 |- g
{
8 b6 O9 k" g7 `0 _" V6 } .active_low = 0,
: }! S; p0 T5 n3 |. M# r% U$ U2 b .gpio = DA850_USER_LED0,# ^# }4 ?8 I6 m9 u
.name = "user_led0",
`8 E% r4 a# e. _ .default_trigger = "default-on", r/ x. M) g& C* _5 _, Q) u* f) C
},
, s" O( L& } ^' v0 A$ c z3 h {$ O9 x- c1 B. k' e
.active_low = 0,) t Q! O, E$ t/ k0 }
.gpio = DA850_USER_LED1,
$ C8 e( |6 ^; z .name = "user_led1",. Z4 c1 n8 `' M9 I/ K$ m% R
.default_trigger = "default-on",
7 C% a f% \% M% N& d, W },
7 s7 Z) ]5 R2 g {+ R9 w- l( Y. U0 E% |. T
.active_low = 0,
, A$ M; e: p* @& E, T& e! k" f .gpio = DA850_USER_LED2,
' ~4 j; F0 [+ j$ H .name = "user_led2",
* W5 T' K4 w8 [3 }3 p: a' l7 i .default_trigger = "default-on",
8 k9 ~6 E6 t2 t. U- e4 _ },
7 t7 l. Q' `& X {
0 N2 a) W+ n" N* C .active_low = 0,
" V4 U9 }" n# R+ Q1 P7 [) r .gpio = DA850_USER_LED3,, L% {/ e! `/ b1 k
.name = "user_led3",
, K$ b+ L# R, Z+ t, `6 y% e# T .default_trigger = "default-on",- G, Z( ^2 e H' \7 [& z& U2 ^
},
4 T: U9 ~8 ^! l, T};
2 s* `9 K9 t! e: M8 B# t. t8 |& l% G/ |
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% R' q6 h) f/ |- q& @( J9 h
.leds = da850_evm_tl_leds,
2 |9 i- D; B9 O, G$ _ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 T# c2 ~) |0 n0 X% D};
5 i6 ~+ N0 R% f* G8 e2 V9 F; y! W% i3 ?% ?8 U( g4 `4 X Z
static void led_dev_release(struct device *dev)% O, t/ M" t$ X+ E; a
{% A2 k; x7 `: m* f
};
% _2 H$ X- R1 H8 M& {' c( E4 J/ D9 l; c
' Z1 B0 l6 z2 K9 e$ h/ pstatic struct platform_device da850_evm_tl_leds_device = { m, d W! l& H4 }
.name = "leds-gpio",: M( n6 m3 m+ u6 L; G7 s
.id = 1,
1 Y- }$ P, J1 a .dev = {
% f7 x0 @' m( N- J; B% b- q .platform_data = &da850_evm_tl_leds_pdata,; Q. j8 l8 L0 u4 Y+ t5 ?( [" D: ?
.release = led_dev_release,. A+ X! q+ w, Z9 H0 X
}2 j( s: e, `2 M. X
};: S1 }& `! r1 Y8 O1 I
# N* N; U" y2 K0 J9 q2 hstatic int __init led_platform_init(void)
- b3 D; S% t L! _2 p; w{
- R, Q& b2 U% X) \ int ret;
' h4 u8 L+ b2 P! H' P#if 0
' }5 h! E! y- P; ~. A$ O ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! B: [0 i( q* t* M if (ret)
+ S1 S' p7 z# k5 |' d0 r pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ u& I& [6 `) |$ r! ]
"%d\n", ret);' O' N1 B- {0 y! r6 z# p' U
#endif( A& `* J: M3 t4 I& {7 c
ret = platform_device_register(&da850_evm_tl_leds_device);# s- p0 v: S1 Q, o0 ]- f
if (ret)- S( ` i$ H. K
pr_warning("Could not register som GPIO expander LEDS");6 ^) A9 u7 D9 A/ |# h) Q8 X; d: h
else
5 f( E% o" T5 c; i# r0 @2 Y printk(KERN_INFO "LED register sucessful!\n");: m* w( {- M U9 w: C, `6 s3 H
5 I3 k5 D$ b j) B
return ret;
; o; a9 E+ K; y2 V- L}
; ]7 {! O+ } S* j5 P9 Y/ a- S( t4 x9 ?$ U1 R2 U% [& R% P* o
static void __exit led_platform_exit(void) s. L7 F6 [ }1 A
{5 J" C, m* G' {. _4 z% p0 N! m: E! G3 L
platform_device_unregister(&da850_evm_tl_leds_device);+ f& ]% t/ J3 J# K
# d0 E* ]) b9 B printk(KERN_INFO "LED unregister!\n");. d' \- ?' x8 A0 \
}
# L/ j* L- B& {" p- b* M/ d
2 x4 f! u; A+ x0 n9 B* ~module_init(led_platform_init);
- t& A+ P4 y6 X% u7 r- J' smodule_exit(led_platform_exit);
: _ A v( o: ?! ]# m5 p2 D
: N4 i4 H# F, c6 EMODULE_DESCRIPTION("Led platform driver");
, R* q* d$ l' BMODULE_AUTHOR("Tronlong");
( g+ ^5 f4 T0 k; I' A9 A" H& ^& V8 yMODULE_LICENSE("GPL");
, ~2 g" u: D& `0 b3 t' ^8 Y' T% l7 S# E
|
|