|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; }! z/ x# r! z2 Y+ F
#include <linux/init.h>
3 p+ y+ O: O: b8 e#include <linux/module.h>$ o& o! I3 f" Z
#include <linux/kernel.h>% L, d' E4 A$ ?: b. L$ P% _% g0 u
#include <linux/types.h>
N l6 k1 i" O. n, D/ H. u/ a/ c#include <linux/gpio.h>3 P) ~+ _$ k' P
#include <linux/leds.h>
2 x$ p' f! v* t% p# R: D; o$ [% s#include <linux/platform_device.h>& I& F: j2 Y! g, E" t
; r* `. A- Z& `6 [5 s2 {#include <asm/mach-types.h>
9 w" Y+ \+ n% }4 T5 A7 M1 }$ B#include <asm/mach/arch.h>
# e) _# g, T& y& e- B2 {4 b/ {#include <mach/da8xx.h>
0 B1 K0 {8 y. p# R! x) ^6 i' i#include <mach/mux.h>
$ T! \* h. h- }! o p' _1 ]% }1 U/ V& i6 J# t2 v
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 B% J5 s& E! f7 E1 @' `
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), |6 F, W# T% M( p8 v) `) W4 i
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 j) c* s5 j) @$ _9 w I4 a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 Y2 F+ i5 N* g& a& P+ B
$ t. t/ p% d6 H& c
/* assign the tl som board LED-GPIOs*/8 O; G; ]4 ~: d8 W* j
static const short da850_evm_tl_user_led_pins[] = {
2 c- t# }, C8 ~9 [. ` /* These pins are definition at <mach/mux.h> file */$ h ?' u. q3 x# F2 s4 F9 @
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 n' r/ R& n1 U& a. Z+ R/ M -1
. d) f2 l1 S' U* p# X) |# d};
7 _1 d$ l8 e8 _$ R: d6 V; r* ~* y
3 X) w. r$ K- }( istatic struct gpio_led da850_evm_tl_leds[] = {, r5 Q* t# y7 f1 }" v3 @7 J
{ i% j6 I( o9 v* `0 w
.active_low = 0,) A5 i, L' ~$ p- Q/ v
.gpio = DA850_USER_LED0,- w5 \) {! G2 E; f3 N
.name = "user_led0",% Y1 S d- ]& t1 f0 j! z1 X5 _
.default_trigger = "default-on",. \3 f1 W7 C- T) j
},( j5 p( H. S2 }
{
0 z" c7 G+ F8 A .active_low = 0,9 j& T* |- X6 z0 @- S
.gpio = DA850_USER_LED1,
1 K( L; v# k7 X .name = "user_led1",
' Y7 ]/ q: ^( I2 x .default_trigger = "default-on",7 L& {' n! T: m% C3 M& q7 k1 a
},
7 f. a7 k+ D, v {
. `' e+ p/ Z6 n* \ .active_low = 0,
0 X4 W6 M6 t! \0 l0 |9 g+ W .gpio = DA850_USER_LED2, s! P, R/ M1 ]% O; W* H
.name = "user_led2",. |& n' c2 k+ d+ X7 Z. M3 `, I
.default_trigger = "default-on",2 b1 i" k1 e: A
},: n) [! s; r" n* v2 C6 x
{
1 E4 _' P7 B: B$ D7 S/ _, K0 S .active_low = 0,
9 H! B; A2 E( X# \1 H .gpio = DA850_USER_LED3,
) p8 {1 l1 {/ h& {$ e .name = "user_led3",
2 @) \5 c# b' t9 F .default_trigger = "default-on",% U+ l( q5 Z1 d: H7 ?, k
}, v5 Q/ e3 n8 e! _: l
};
& k) s" Z) l/ m* ?: o& U
" [4 j4 V; S9 d- h0 b/ }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; ?9 X F$ f( Y: ^- P
.leds = da850_evm_tl_leds, ^' A* n0 G; T! T& T0 K
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ ?& Z4 J- M8 N+ \, q6 p, Y};
2 ~* B2 n0 a0 W1 c* L0 S- m$ ]/ y, n8 m2 Q! s6 @
static void led_dev_release(struct device *dev)' |! [: h. n' D0 g
{! `. ^) `1 Y% V
};( X( b; n) v) n! l1 F
5 ^( j2 k9 i' v
static struct platform_device da850_evm_tl_leds_device = {
9 P8 Q' Y" C1 c7 r .name = "leds-gpio",3 c* [" z, \6 G# @! M
.id = 1,/ t. ^" F0 X, O/ R. G$ A
.dev = {
- d9 E3 U1 J7 R4 D4 e! T7 t .platform_data = &da850_evm_tl_leds_pdata,
+ J8 T' [& O2 c: M& b/ P6 K .release = led_dev_release,
+ p/ E4 c) t, x0 f G! J }4 U! H; m0 r/ S9 V1 O$ j
};* M4 ~$ r; h3 S1 e5 u6 W$ h
. f6 M, C, X6 z, P) {% `
static int __init led_platform_init(void)2 E4 d2 U6 G) p$ c
{+ n1 ^2 J* s6 w8 v
int ret;% A3 J2 `7 l8 p8 ?6 c( ]1 K2 [+ C+ x
#if 0. x% |3 e# P5 H. ]
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: k3 p( }$ Z) R {. m: ~4 z if (ret) _8 [* v8 `# m2 f% p: A
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 i" a) ]- ?3 {5 O1 ?
"%d\n", ret);
* ~0 d; A5 i& h# }, L9 j- U#endif
" B: i# T5 y$ O, p: F) m1 b: H+ c ret = platform_device_register(&da850_evm_tl_leds_device);
+ R, O( Z" n0 m if (ret)
8 N# Q0 [$ T0 A# x$ S9 A7 J pr_warning("Could not register som GPIO expander LEDS");# H. h, n' q$ U
else
& h- u2 Y2 u1 } L! ?# U0 b printk(KERN_INFO "LED register sucessful!\n");
) V" o3 v' e+ B" s
) n. q0 W7 H9 a9 q. H( e8 m6 ~ return ret;* i! W0 ^- Q0 W8 |3 L" |' D
}
2 O0 K3 g' L* d. Z) L& J) n3 s/ n) q( n% X6 g7 Z& g
static void __exit led_platform_exit(void)
" R$ t) z& n+ ^* @! r( S{" y/ ]+ R" P$ O
platform_device_unregister(&da850_evm_tl_leds_device);
8 Z( r9 L d" W& _6 z8 k
) S) W6 T: p- c$ M6 k printk(KERN_INFO "LED unregister!\n");
6 b( b' k/ z$ q! O h. Z( ], s}+ G% F% A: X, R0 J6 C. ]
" w: L" O$ X9 L
module_init(led_platform_init);
' ^) N/ y1 [, F9 A. omodule_exit(led_platform_exit);+ y1 z6 e7 v* M6 V+ n2 M- r& H
3 f M3 h8 g" Y3 C6 d
MODULE_DESCRIPTION("Led platform driver");
/ b t O: u# P$ O8 k! QMODULE_AUTHOR("Tronlong");
5 C# R$ S; Z! l# ]& UMODULE_LICENSE("GPL");, d7 D* X" W1 N: a& ?
( W% Y1 }) r" \) o7 r: r( g, Q |
|