|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ X' n% Y( {! v5 `9 s#include <linux/init.h>! Z1 V- {% |1 p+ G
#include <linux/module.h>8 `- t4 x3 ?7 `- V+ R
#include <linux/kernel.h>
4 \* h0 _' o9 L5 k& O#include <linux/types.h>
' N5 l3 _6 a. v1 B+ _8 f#include <linux/gpio.h>+ ^, A# h: c) Q* ]( u: ?$ w
#include <linux/leds.h>7 o+ ~5 l8 v# h1 [+ |7 {9 A
#include <linux/platform_device.h>
( |3 K5 Z- d; z% i2 w2 S2 ?+ {4 p6 \$ n K- O6 s
#include <asm/mach-types.h>4 h5 b4 x) m3 O/ h* a
#include <asm/mach/arch.h>
7 P. @+ H; Q4 @ R+ N: j% J#include <mach/da8xx.h>9 C9 f0 ]6 M n
#include <mach/mux.h>
) f* Y3 o) A1 ]. \: |8 F A- o. {/ w, G8 h% D m7 V# d
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 J0 E6 K% }9 K! y3 H8 W0 K) C! o) _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( P* _; {: I7 U#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); |5 g# O$ ~ E' q% [2 Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( i, ^6 o, j( H7 t1 \7 ?2 x3 ]- o, E! _/ F( g: _% I
/* assign the tl som board LED-GPIOs*/
! |# y+ g+ z( M, J# M0 c0 j. h |static const short da850_evm_tl_user_led_pins[] = {; E* M. M, }8 v( @
/* These pins are definition at <mach/mux.h> file */
: I `! P4 Z3 ~7 s! x DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: s, r- ^) T) d1 w3 m0 I& J# d
-1; I0 c% B( ?0 x# t. g( {: g
};
& _- T5 q6 k" A. O1 { j' C8 l& _' }9 Q2 Z4 @% O5 V/ w; M$ j$ d5 ^
static struct gpio_led da850_evm_tl_leds[] = {
9 V' f# |/ s- i+ z/ j {2 C& h8 v9 `3 ]# i5 ~6 T; M
.active_low = 0,0 B( g6 L+ _( i! B" f+ R( O
.gpio = DA850_USER_LED0,
1 |+ H, t, R& Z% l/ l: a .name = "user_led0",% @! \5 C, |$ J# @" W+ b i
.default_trigger = "default-on", x3 ]4 F7 e0 C6 V
},
* b* K. B. e. x" ?- w {! ^% |! b/ Z1 C1 V( ?. O
.active_low = 0,- e: ~* z' T% p3 a
.gpio = DA850_USER_LED1,8 ~1 ~+ }2 ~5 w5 L- z; ]
.name = "user_led1",
9 K4 X& D4 x% I: y5 h- g0 m .default_trigger = "default-on",* C4 s, n7 D; q% D: U. ?0 L
},( y5 \ } z8 g; \) m' k
{. C- J8 _3 a8 u. K
.active_low = 0,
, K9 k. b. q" F# O .gpio = DA850_USER_LED2,3 \/ I9 @% a4 q
.name = "user_led2",
+ }6 n9 Y- T9 Q) Y* N .default_trigger = "default-on",
+ b9 V- X; K- D1 L( p8 B3 A( m },
7 `9 j6 t! J" R: W' n {
0 @9 s8 D) X4 R4 A .active_low = 0,8 R* m8 m! g% k; U: c$ w+ I
.gpio = DA850_USER_LED3,
7 ^) O6 a" c6 p4 n# Q. K .name = "user_led3", T4 s- d- N& d5 {$ ]" w. q5 Q
.default_trigger = "default-on",
4 ^" _5 l2 U7 o$ P) H- u },
! K4 w$ A% x1 T};
1 ~1 j B3 }) b( K8 B1 M$ K; l6 F3 |# H# c4 ]5 E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 u1 K; y3 b# A
.leds = da850_evm_tl_leds,
1 w! ^( K7 z2 X+ h+ z2 U* k .num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 R5 j* g/ v3 P
};
2 n! C; ?" h z. h# @& G8 y( J9 G- u& J' S6 H: L
static void led_dev_release(struct device *dev)7 s8 ]9 p: g3 y$ y
{$ q, `+ ^# u0 G2 d# P! X7 o, c+ ?4 \
};; \. E2 a* r' G; c
# c8 {9 o {/ ?/ f! ]7 Sstatic struct platform_device da850_evm_tl_leds_device = {( p; P0 {9 U- }# r
.name = "leds-gpio",; ?& z" H1 g1 R; k9 V
.id = 1,* H5 \9 d$ g" K6 R# Y
.dev = {. H! a% _+ c a4 [! C
.platform_data = &da850_evm_tl_leds_pdata,9 l. x |% O3 K& D5 j
.release = led_dev_release,
+ A( h, b% n- m7 `( Y# L Z" v) @ }
: W1 Y+ I' o. K! Z4 ~2 E! X};
0 ^$ {+ `1 L) J. {; x" \1 {6 p7 U5 G
static int __init led_platform_init(void)
6 l( q- G, `! `. s% c' l{
% Z" W) \8 B, t& {. B6 \( X int ret;
1 x" G+ A; B+ L) H' e8 y#if 0
" u' P$ A3 k. h( Z$ U ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ ^8 V0 n( D' R) [ Z if (ret)
" i) k% K0 o( d) [$ L' J. X pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ m+ I- y- v1 E) A
"%d\n", ret);
; s3 z- g+ [9 J; J. \: }$ M& D* X#endif# i6 {+ s7 I$ ?: d; v# ~0 x
ret = platform_device_register(&da850_evm_tl_leds_device);
W. d; ^7 P1 o4 @6 I+ F0 H9 P% r5 S if (ret)
8 E( \5 g: T/ \1 a! r! f pr_warning("Could not register som GPIO expander LEDS");& p: L; m6 y, c) A4 ~
else2 g) v$ k. [0 E' A
printk(KERN_INFO "LED register sucessful!\n");
4 e9 t; h/ L9 p* {5 b3 {- a- {) q7 ^) f' ^9 a ~" n# N
return ret;
1 H, y) V8 y8 ?2 y; X}: B: c; \: O( y5 _
$ v1 i. I3 r4 Q; T+ a) xstatic void __exit led_platform_exit(void)$ E8 [' ^; g6 A& I
{$ x: U+ O2 r" X1 I/ d! }* I( N9 L
platform_device_unregister(&da850_evm_tl_leds_device);5 n/ G& c$ o, q" a
4 Y/ t6 D! B6 J printk(KERN_INFO "LED unregister!\n");
! x# B! o# H& C1 I8 J# D# a, T}
8 |. } O1 v$ W: L1 y
3 n, B1 T" T7 F* R9 C+ T) d' Wmodule_init(led_platform_init);
$ k* P% o4 j y+ W* v: Dmodule_exit(led_platform_exit);0 O2 n5 a) j# | o0 k' F& Q7 O# k
2 T/ I; a1 p- K i
MODULE_DESCRIPTION("Led platform driver");
; N, I$ K% m+ o# ~1 i6 KMODULE_AUTHOR("Tronlong");. `% O$ ?6 `: X; ~
MODULE_LICENSE("GPL");3 v2 w) f8 I' V- n8 X6 D+ z' V
; o/ r8 h8 P" U- o2 S5 |7 y5 E, w- v |
|