|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- \9 I H& Z% {1 U+ Q
#include <linux/init.h>
/ |* x" F6 E, d1 Y) B#include <linux/module.h> t: `( j9 {& m$ L* t9 c2 D
#include <linux/kernel.h>) s1 f( x, H3 \6 [8 O8 C
#include <linux/types.h>
& K. a6 u/ B9 r, Q# { \#include <linux/gpio.h># |9 U0 H: ?" M% I: `; o
#include <linux/leds.h>
* h% H2 }7 t1 Y H6 {/ H6 s/ y#include <linux/platform_device.h># {% f% [' T. `0 B$ @& h8 _6 o# m
' Z1 j* B& m2 D% A6 f# L#include <asm/mach-types.h>
$ o; }! |" z& k( Q. G$ d#include <asm/mach/arch.h>
, _- n) s' q: |7 ]6 v#include <mach/da8xx.h>5 G. Q. P: {% R
#include <mach/mux.h># ^2 n8 m, n* h
* v4 e8 W& ^( v4 \. o#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ L0 q4 u' J6 p$ U( l
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ M9 B* A5 ?5 K; _#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 R. d$ g. N- T4 E4 j1 I+ F$ B9 b7 m#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 p8 d7 e4 a% W; Y m) b: n5 d- n
. i0 \& X( T# R" t' K6 q
/* assign the tl som board LED-GPIOs*/9 ]$ Q; j* w, Z4 w6 \, k; b
static const short da850_evm_tl_user_led_pins[] = {
+ Y7 q; q/ O0 j) ~. L% n /* These pins are definition at <mach/mux.h> file */0 Y2 O/ M$ C5 e3 g* i% V8 b- e& g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 Q5 w- _3 x! f8 F -18 t7 m6 f& I. G$ o+ Q: M# f1 J8 r0 w
};
; M2 H# E/ c# x* Z( F7 f/ w& \5 R! e
static struct gpio_led da850_evm_tl_leds[] = { g8 Z0 M A0 ~' t" H8 Q u9 W M O
{
# f8 V8 c" X6 A0 H+ a8 z3 C .active_low = 0,& F9 [' P6 Y) P+ V
.gpio = DA850_USER_LED0,
9 H4 `+ `( ^- @, G( c .name = "user_led0",
! P2 h4 W% }5 ? .default_trigger = "default-on",
0 R# L& i) z! P1 [: L/ @! z; g# w a },
1 A( ^% B5 s, S! R {
. x* l y f3 l% N .active_low = 0,
2 S! t$ _3 Y d1 g; S .gpio = DA850_USER_LED1,) x0 i9 Y# Y8 H; p5 a; y7 K6 {% |
.name = "user_led1",( _* x9 O- {& d# A3 u% [9 x/ e, z
.default_trigger = "default-on",* w( d' O$ k' F0 y+ ?
},% V- ?$ _; r( |( b
{
|& K+ ~* |) s& a( p5 u/ l .active_low = 0,& [( B! h/ A+ R
.gpio = DA850_USER_LED2,
o$ Y! ]/ s4 j% m3 A .name = "user_led2", t- e( E* I& f. D7 U- O( R
.default_trigger = "default-on",
* h2 p: n1 m& D w },! ^7 Y+ R% g# q
{( Z6 @. s, j: ]$ N# n7 x
.active_low = 0,3 y# }. W% @" V
.gpio = DA850_USER_LED3,
0 h1 [% L4 k1 r+ y8 y$ t, Y .name = "user_led3",
7 Z- m/ s0 v9 T1 r .default_trigger = "default-on",* H u. u/ @) |" V: E" j
},9 t1 z- T( H4 Y' m$ d; m4 z; E
};
* I- F! F6 y5 F3 e# m. v/ `
+ u" {$ V& B( V3 d1 \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 q& \4 s: |2 e$ V3 M/ q
.leds = da850_evm_tl_leds,
( n% o* a% R6 K4 N. S .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ U$ C% C2 V$ F8 J
};; m1 J- S3 y/ w! D% f. R- y
- u* l/ I/ e2 t4 X
static void led_dev_release(struct device *dev)
! r9 J: m4 W9 [0 l! B+ G{* D1 O+ \4 \# L- Z
};
& w7 p0 [7 }$ o0 s, u9 b. M6 @$ L; N; m: r
static struct platform_device da850_evm_tl_leds_device = {
8 H; [' Y% q+ \; [3 ^) p/ G, L .name = "leds-gpio",, P, C# |& Z; ?6 {
.id = 1,' r2 Y* t/ `# ~+ f$ c
.dev = {
: j, Y" B5 Q ]2 W .platform_data = &da850_evm_tl_leds_pdata,
3 l; j2 v) O3 B% h( D w .release = led_dev_release,
2 ~+ n' i1 g4 r }; X+ u; y& M$ L" c! u9 S
};
2 n2 v/ [9 ?2 o/ a! T% V' n& c- o( C; K( A4 P3 r$ x3 B) C& b: R, f
static int __init led_platform_init(void)5 c) q! O u; j+ [
{
" D. `0 ^$ |8 ^# |+ O int ret;
. e9 r/ }% P$ _ O; |#if 0
3 Y4 U4 C" }1 i ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ j5 \% b$ l" D$ p if (ret)0 @* \$ ^+ F! V. `9 D' }6 X' @ z, \
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ g( \4 ~, j" }( s' O- v: i; h" t- B "%d\n", ret);# V+ [2 W$ l# w5 T2 H6 n4 F% Z
#endif
l. k' j: C8 F ret = platform_device_register(&da850_evm_tl_leds_device);8 J2 b3 s# h" Y- b% `4 e
if (ret)6 n/ i# Q# t1 ~/ O, ]9 E0 N
pr_warning("Could not register som GPIO expander LEDS");; d& b& ?# z% `, R* m
else- N6 S8 e- \$ @: Z2 t3 E
printk(KERN_INFO "LED register sucessful!\n");
9 _ H, ], Z6 T, P' S6 I e( ~0 ^ e* m% \5 P5 A
return ret;8 o. i5 g( _& J- C) i+ t
}
# }5 q' Z) [" }1 U% r% r- ~. [0 n& E2 |# C6 i0 T
static void __exit led_platform_exit(void)
# U, ? y9 S2 _9 C9 D, a{& ~8 a* n; E1 _( w; o9 I! o+ Q8 `
platform_device_unregister(&da850_evm_tl_leds_device);, b, }2 J1 D9 z7 v+ s) s9 ]
7 \/ W8 |3 {2 \2 J
printk(KERN_INFO "LED unregister!\n");
* A- ^) C V+ r: s' N1 ~; z! m! D}: u3 ]. e8 P& l2 L; m. R
4 {( Y9 O4 W3 G, ?% ^+ g
module_init(led_platform_init);( I- w9 }6 H: p
module_exit(led_platform_exit);1 c" n0 m; o+ E0 ?& \$ s8 t
9 G5 u+ y7 L' L4 s3 X
MODULE_DESCRIPTION("Led platform driver");
$ I1 y6 a5 G* q+ F& XMODULE_AUTHOR("Tronlong");
$ {+ ?! b( a1 Z! C$ CMODULE_LICENSE("GPL");
- k( V& p! G) ^0 K. {; h1 ]3 C8 P& Y1 i) ~( v) `
|
|