|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( T- m8 J# K: k#include <linux/init.h>! c. k* h" o) F; U
#include <linux/module.h>
' q% t: {% u8 O k. x- p* s# d# _#include <linux/kernel.h>7 w- h( N5 i$ H& l9 C0 i
#include <linux/types.h>
) D. s1 \6 U2 D#include <linux/gpio.h>& o* ?' a. K% p* G3 l' x8 v6 L
#include <linux/leds.h>- I8 }2 B% [ }5 _9 o/ r3 a
#include <linux/platform_device.h>7 k: B/ I+ J" }: \. u5 _
9 ]; W( W. U+ {9 E; k0 F- E#include <asm/mach-types.h>$ Y, T+ W' a' X2 r. Y ^
#include <asm/mach/arch.h>
L1 S$ s4 b# d3 j, |* ~. o6 H# i#include <mach/da8xx.h>/ }6 x m3 U- t. W! H4 }
#include <mach/mux.h>
" }6 L+ c& C% f7 ?
% T+ R( t$ n2 o, r% N0 y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 S* H \& j. h9 K* p#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* r8 |$ ~& A, o9 K& i#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) D* u4 E- }) A# I* I#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): U( z5 k X. x1 C8 [ h
. `2 f4 Y4 h; ]4 |% |( G) x8 P/* assign the tl som board LED-GPIOs*/
, O# I3 u7 w, ~& m7 |static const short da850_evm_tl_user_led_pins[] = {2 r9 O# v* s6 Z ?
/* These pins are definition at <mach/mux.h> file *// j$ l0 `, x' S( P: ~! `- \* _
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- w W) Y1 v% U9 D
-1/ E( X6 |+ z$ k' W
};
9 x9 r$ ]: `: p0 h0 v/ M
. a4 ^8 r- M, |4 W& Hstatic struct gpio_led da850_evm_tl_leds[] = {
^- K/ H0 ^9 {+ L3 y {. a! x3 f. J2 a6 {2 C* |8 K) @( M
.active_low = 0,
4 J) t6 T* }9 m& p .gpio = DA850_USER_LED0,
w# H$ W+ f6 n" _3 i7 P .name = "user_led0",
$ k1 I: V# v6 E/ h .default_trigger = "default-on",& t9 g5 j @8 f
},
+ V% \! E: w( H+ O: M. b {
/ I' | x) c/ D: m) w .active_low = 0,7 q4 K/ m" x6 K5 Q/ g" _
.gpio = DA850_USER_LED1,
. _3 R+ k2 B# e8 J3 [6 w .name = "user_led1",, w) \/ J8 N1 [2 y. M
.default_trigger = "default-on",: d+ { q& \; D% @- q5 v
},
6 u2 J/ y: Q; h {
5 J1 `6 C1 t" v9 J .active_low = 0,
0 c |8 T& m3 l1 l .gpio = DA850_USER_LED2,
$ n) ^8 M8 w$ o, F. B .name = "user_led2",
8 ^% e4 r- Z' Q0 u2 z .default_trigger = "default-on",9 Y8 x* p6 |8 y& S
},
3 H4 Q1 B% m! r; A9 O* G# x {" }* y1 ?* q. q3 b" E" C% D
.active_low = 0,5 j/ W9 W: p- S- ]' [: @+ m
.gpio = DA850_USER_LED3,
. F! O) Q( E9 Y2 s( K .name = "user_led3",
# q+ H- ]7 o6 K' e6 r .default_trigger = "default-on",
3 ~" m/ x( c% @( F5 I+ Z },. L* L/ Y( N8 l4 m
};
; _7 z1 ^: _: @9 y/ G
) ~: _$ T9 A- M/ ]8 p- S$ Z3 J4 Zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* `2 O$ p% M7 o) {+ }2 a0 v .leds = da850_evm_tl_leds,: X" T1 {: \9 ?
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 Z3 [' J& U7 |- ]6 `1 @}; w5 b- q- ?3 \2 k
+ A& o4 s% P$ ^- j5 r, P
static void led_dev_release(struct device *dev)7 \ V+ K" S% x! \! e; `
{' b% }" W* Y& z% t2 d) B2 f$ G
};$ p; S5 e) r' @0 d
3 Y5 P- N% |) v: V! ]! y
static struct platform_device da850_evm_tl_leds_device = {
/ {* X& I v- |7 c. t# c .name = "leds-gpio",
; X( J9 b: j% m$ g+ F0 w+ F7 y .id = 1,: H1 G4 S/ z* K6 u/ n6 L$ N: D8 |/ m) ]
.dev = {
9 @( [1 j9 B7 A, P& ]1 j8 \ .platform_data = &da850_evm_tl_leds_pdata,
3 H, U2 z7 [- f5 e" t .release = led_dev_release,
0 t4 R- X, p+ _2 t1 v* B }, ~# Z; V* d, ?/ h7 ]
};
: s; Q( r8 b/ L, @& g( L+ p5 ^ t! b
static int __init led_platform_init(void). n7 ^2 V9 }3 y/ L! i9 l: J$ f1 e8 v
{0 p+ L( ^: ~ }; r7 Y! P! P
int ret;' M0 j$ A( @7 [7 s& u- f6 b
#if 09 }" Y/ Z( V9 j" ^) l. w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ Y6 A9 u s$ a0 a/ |/ p" G# d% ] if (ret)
" l# I; G2 ^# [$ }5 d pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
~/ l& y& x: ?. w" S3 e "%d\n", ret);+ Q( I3 _- G5 @4 k2 ^
#endif
% l+ O8 h6 E/ u- F ret = platform_device_register(&da850_evm_tl_leds_device);- d/ ^) O# C6 ?0 _# [. X7 m
if (ret)
* E" q6 A& B9 \9 ^4 B pr_warning("Could not register som GPIO expander LEDS");
B! x4 A9 c- z+ f9 b- M! | else
' \; D( A2 U N( c printk(KERN_INFO "LED register sucessful!\n");8 a/ l. G/ g! F' ~$ C5 P
0 w4 ]5 r& z/ B
return ret;/ W( w0 N* ^1 W* `/ d$ I* M
}4 |/ ~& u( i1 }# ^7 M. A
" _3 W/ v7 w# h/ W! _7 C
static void __exit led_platform_exit(void)
& W0 R, O5 w/ c{! }: u. d8 C: Q# W) i# ^+ J
platform_device_unregister(&da850_evm_tl_leds_device);" _7 M; h( z$ g! z6 w0 D' U
' i) s- q8 j- ]& Z3 q printk(KERN_INFO "LED unregister!\n");
4 P" f7 P% m: V. {( M}$ E& H/ o; {* H/ U3 u
6 h& l2 g2 I/ m; \+ Tmodule_init(led_platform_init);
: r6 g) V* P1 S) dmodule_exit(led_platform_exit);+ m# ?! O% i; X; ^% `. t0 N7 b
7 h2 M9 v$ L; c/ l% h; ^
MODULE_DESCRIPTION("Led platform driver");0 m5 b1 W; \# K- K. C9 `. V
MODULE_AUTHOR("Tronlong");
8 ?, X$ V+ _: LMODULE_LICENSE("GPL");- E/ z4 ?4 y& ?* |. U8 X V* E
6 \" D9 _( M# r# n2 P, ^) n
|
|