|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( M4 g& z/ i' V; |: m& a& v& p
#include <linux/init.h>
5 q* g& j5 Q* r2 m7 L# x A#include <linux/module.h>
2 O% W" S' J2 L+ a- t' t, T#include <linux/kernel.h>- S! Z) m% k3 a) b/ f" k0 w
#include <linux/types.h>
$ ^( z! @; r" v/ L* I#include <linux/gpio.h>8 ^; ?0 N3 f+ M/ R
#include <linux/leds.h>
' q* r, Z( `* Y#include <linux/platform_device.h># @3 f1 H+ s/ B$ s9 n6 D
+ M' b; ^% ]2 t6 W& r0 Y+ ~/ w, {
#include <asm/mach-types.h>: m. V. f7 a; |; n9 X
#include <asm/mach/arch.h>; x( `& ]7 c; K$ z% _% X$ e$ T
#include <mach/da8xx.h>
+ ]8 N9 q7 ?: w( [" y# F#include <mach/mux.h>
% d! j# H3 U6 k
9 r5 k" V7 i' J# Q( [3 q$ M#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 p7 p7 d0 c2 e( Y' g3 C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 V# F1 _: {: H" }( G. u
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 ^5 ?% Y# A9 _+ b: V+ v
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' ?' B4 g& U- [8 N" ]7 r1 l
0 Y" \; r5 z' S* W. x2 w' W
/* assign the tl som board LED-GPIOs*/
0 ?; @9 J0 m) y0 B7 l: i2 Rstatic const short da850_evm_tl_user_led_pins[] = {
9 }! q9 L+ f5 T9 i0 S4 E q! F /* These pins are definition at <mach/mux.h> file */5 U3 m& ^8 \, `9 w& F7 b& n9 H& K
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ A" r! `5 A# z3 r* Z5 z: D
-18 q1 J& m7 y) o
};
& B& I- u& E- {9 V5 y+ g& I; w" D: t A3 ?4 `6 ~9 V
static struct gpio_led da850_evm_tl_leds[] = {+ n( x2 D; R4 D1 x8 M! u2 T. ~
{
* t# s6 k% k2 b% ~( z- r8 g, r .active_low = 0,) U; K# j3 `! ~& w
.gpio = DA850_USER_LED0,
' i6 H) j, S0 K7 z .name = "user_led0",$ ?" h& f# ?4 t6 Q) X
.default_trigger = "default-on",/ M7 [) s4 |. S7 S# T
},
# g; t% B# H }" G: F" Z G {
5 ^! D" L* a: w N: ^ .active_low = 0,- ]/ m4 l" ~8 M# t. H, I
.gpio = DA850_USER_LED1,
. u. J% D4 N2 @4 b" t3 }. A5 M .name = "user_led1",! K5 }7 C3 b0 C$ l# D% A& K- ^$ A# d
.default_trigger = "default-on",
3 F; A7 @6 |! v( Q8 o* w, m1 a },
0 y3 K& _. k5 x- E) Q% U) S2 P. y3 g8 B6 A {
& P3 d4 e5 @$ H .active_low = 0,
8 R3 }& i' \* @: r; G' N .gpio = DA850_USER_LED2,9 }0 _6 z7 |6 J# o- u2 Y
.name = "user_led2",+ U& h- ]. B1 {4 F' Y3 J+ t2 R
.default_trigger = "default-on",
3 U9 b$ J& L% d2 u' H, ` }, ]. J2 G! f m& m# e o9 `) |
{9 e; F% \ ^3 b: ]6 d" _- Z
.active_low = 0,
4 w2 g3 X( m& X' ?! @ .gpio = DA850_USER_LED3,
9 ], X& I3 b4 h9 d `+ J& G .name = "user_led3",
; Y: d# M1 b- {# w% w. {7 }/ i1 L .default_trigger = "default-on",+ E/ A# o( }2 ]* F# T/ D" _6 @
},
A# F8 c1 c# Y};: E7 v" e( a6 d
C5 r* e. [8 X$ ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" p( {' D, G/ a- P1 Y .leds = da850_evm_tl_leds,9 O/ `5 a6 V: a" g& j! o. P0 N3 P6 h
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" Z6 M. ^5 t+ N* [/ }};
* N& F$ o4 k2 |- u, N. `# |
' c9 ^4 z7 b# K$ G+ S; Kstatic void led_dev_release(struct device *dev)
6 A6 k: a" M# M2 ~1 P5 F{, J$ i. z1 I2 \' m$ i+ A
};
7 j* r$ h7 B, e* c( h. u" U! U2 F" l" a. I8 w h" ^
static struct platform_device da850_evm_tl_leds_device = {0 d6 j3 W. c1 w% ~+ `$ S$ e) m( s# [+ \
.name = "leds-gpio",
) Q/ B$ h, e0 F/ o s& |3 Q .id = 1,
- l, c9 D4 b6 A/ Q .dev = {
3 O# t- F3 V0 r1 Z. Q .platform_data = &da850_evm_tl_leds_pdata,
9 u4 q) Z! d( g .release = led_dev_release,
! J; h* p/ E, Q) d+ P$ _, _5 z }
. ?0 n6 P/ B2 e3 O% p# |};5 i; [0 Q. R+ k( d" S) }
/ |6 ~; q% h5 d* n \8 L" _static int __init led_platform_init(void)! y3 Q, U1 s) P7 t) P) w. G
{8 V4 t& C8 C0 }. X7 i4 t* o! Y4 K
int ret;3 G# s; O) p' s4 D- Z
#if 0- F) _7 i- G$ F! b1 }7 i# ], x/ u
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 I* \/ q3 ~8 k. b% ~$ {
if (ret). b1 o7 K+ @ E0 [* w) _. c
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- `- I7 }9 h! z# y# {
"%d\n", ret);
, U- X6 u& L* ~0 T) K R2 h$ O#endif
2 g# l4 V0 l: ]: z9 O F* j ret = platform_device_register(&da850_evm_tl_leds_device);
3 T! @) [2 C% i/ x- P3 b if (ret)
6 F( ]6 u$ `+ D3 F8 B5 R' E1 `0 i pr_warning("Could not register som GPIO expander LEDS");0 j$ T* q! P; z, n8 n
else
6 q- [) y4 O3 R, c _9 j6 F printk(KERN_INFO "LED register sucessful!\n");
+ Q5 [0 p4 z0 N7 t- _9 ?+ @" f+ m8 p- @/ p6 e# n
return ret;
- e: _5 l1 ?. U# {) U- H}( ?, B) Q% q) g5 c4 s
4 P" l0 n" n- G/ u
static void __exit led_platform_exit(void)' f. c) u, w0 B/ [+ v8 [
{
) b H6 B- O$ |) _" Y# y3 ~ platform_device_unregister(&da850_evm_tl_leds_device);* R+ z# F7 \2 ]% u! u
4 r: z5 q/ l: O; Z
printk(KERN_INFO "LED unregister!\n");
5 i$ P* K" k0 o; {/ z}( L* k$ h& {' |0 n
) f2 k9 U5 Z% _+ G$ q& }' W
module_init(led_platform_init);
% f7 g M( h b5 U+ t- \! Pmodule_exit(led_platform_exit); z3 V8 t8 z. V% R8 w7 K& s
# j) M& c8 c9 H/ c; C! M ?
MODULE_DESCRIPTION("Led platform driver");+ d1 Z8 h, b* I U; A0 @# ~
MODULE_AUTHOR("Tronlong");5 x# |% @) W$ ^9 ? [6 e7 i5 F
MODULE_LICENSE("GPL");* `' |- e f* Z* g1 `. m1 a u+ t+ ]
, c0 t$ H( e; ]+ O% O4 J
|
|