|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 P; ?' ~" V8 v1 n- i* G9 L
#include <linux/init.h>3 x2 O% e9 y9 ?: ~( f$ m# \7 o3 N
#include <linux/module.h>
+ {+ s3 g( d" E# D7 A#include <linux/kernel.h>' z# s/ }& K) w# p1 w7 E% ~6 U
#include <linux/types.h>
1 {+ S# K: \1 k#include <linux/gpio.h>% d3 p9 A, l0 F7 D
#include <linux/leds.h>
* ~ S& @* F; Y8 Q+ o: G6 a5 T. G$ q#include <linux/platform_device.h>
: e5 ^* f- J1 B) B& h# T. `; B/ q! c& W* D0 t/ w3 E: }
#include <asm/mach-types.h>
# j, U( w% H$ Z/ D6 c# v P# O' X! c#include <asm/mach/arch.h>
+ |8 ?! }0 l W, N8 U3 ]#include <mach/da8xx.h>
- F, ^" h+ h/ m8 w* y#include <mach/mux.h>
$ V4 B% Q' f. e& `& K' z; n/ y' w; y$ X4 ~7 ]& q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 C& r* O8 s" `0 C" l8 p) q/ h2 m3 s#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 J j* l( n$ q& [. ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- |" }3 j* c" }# H5 x/ h#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 o$ g9 N8 }+ }+ U w: i
) S8 t, @4 W4 r& t z; J2 V9 S4 }/* assign the tl som board LED-GPIOs*/9 ~6 m6 }% o' _/ P$ ~0 b: O
static const short da850_evm_tl_user_led_pins[] = {# E c6 _- { a3 l
/* These pins are definition at <mach/mux.h> file */
0 o/ p; _( A% T2 L" i! @" D DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! h& t1 s) Q& ]0 b -1
; p& r M* w) |4 y0 Y7 Q7 I};
5 j5 n$ m5 I6 p4 L2 ]9 Q3 C- V" L( v
static struct gpio_led da850_evm_tl_leds[] = {0 Q0 |- H3 \; d, h" U
{
* {) @0 ]) f' s3 U6 Z: v .active_low = 0,
. j: \# M8 E7 s) {: K .gpio = DA850_USER_LED0,
; A) C+ b# C7 Q# o0 x .name = "user_led0",5 a U) q7 X p2 h! ]5 A
.default_trigger = "default-on",: j/ z' S. J' Q, |
},
/ A; A, U \- r) I" a) t {
8 \* M; u. s, n8 P9 [4 I .active_low = 0,- u# O( o9 c) y% e* L/ M) Z
.gpio = DA850_USER_LED1,' x B" Q2 U. S9 p% \( e
.name = "user_led1",0 n4 a+ L R" V4 f* m
.default_trigger = "default-on",6 u) O. U5 W+ h ?: S6 P
},
! k4 @; k3 d" L% }( k4 @* J c9 ^ {
: C [: ]0 [; k j3 B3 F/ l8 \4 m .active_low = 0,1 A5 ]" p/ T+ H& T# A8 s7 T
.gpio = DA850_USER_LED2,
1 s# j5 t8 _) `; m1 p5 W .name = "user_led2",
5 Y8 C2 {: S* c8 L7 p .default_trigger = "default-on",' {9 B7 p) }3 E0 ?4 b5 R i; l: p
},5 g6 }; b2 B$ Z; c y. Y
{
: V+ t. h, J/ J2 P' r .active_low = 0,- v& j( ]: v# s; s. E' U$ h" l
.gpio = DA850_USER_LED3,
$ ^- }3 u5 M" [) _/ f .name = "user_led3",
5 H+ Z+ h) B7 a7 l# R( N5 F .default_trigger = "default-on",& H: m: v/ c* C9 e/ L: f
},
+ k. L- i2 V I& N* @};) G; I( l! b$ x9 z
4 w) S/ L/ E" Z; D: _" j% Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' v1 Q0 ^8 W! y, j .leds = da850_evm_tl_leds," U4 {7 O4 K' T0 x! M4 s
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ p* H* W' _4 S, \
};
( v O2 o7 e2 b6 }. y
: z5 ^# R# C; z% ]static void led_dev_release(struct device *dev)
E b: U& {! ]+ G5 Y{; Y2 S5 }9 {4 E: V* u7 @
};
5 z! H$ l% G* H4 t1 i# T
( D1 P; ~, \+ L/ _9 y8 C, r" Rstatic struct platform_device da850_evm_tl_leds_device = {3 s# D. P+ N6 l) B9 J& Q
.name = "leds-gpio",
P9 B D5 w$ p2 s4 ]% |7 A5 s+ I .id = 1, x7 F% _! |! `3 g* h `' v
.dev = {0 n) W" K# a( I; m* N
.platform_data = &da850_evm_tl_leds_pdata,
9 b$ I& o7 F$ S8 e3 r+ U .release = led_dev_release,
4 Z& P3 P$ K6 _: K! p }
, S$ H. }5 s/ d) G};; Y# V7 W* P, J+ q4 ]) X/ Q
: ?8 i$ c8 d, R7 @2 d8 ^static int __init led_platform_init(void)6 |5 A+ z, Z$ l2 u r
{/ }* D( E( z$ O: x5 U6 C. A: |5 G
int ret;7 y4 Q9 ?5 T. ^! t
#if 0
. {3 N. W+ o6 d `- u ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
|% i' v6 K8 n3 F if (ret)
! Q( K0 A/ L" I ]/ G pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 r+ l1 A7 D" q$ P3 E1 X
"%d\n", ret);
0 _5 X" H8 G9 ?/ y: C1 |( L( P#endif; E' [- S( Q9 h5 D
ret = platform_device_register(&da850_evm_tl_leds_device);# P. |7 }2 d+ {( e3 H8 u' Q
if (ret)
. R, s+ l3 u; Q; q& C: \% u pr_warning("Could not register som GPIO expander LEDS");
2 X; F; P; S( k; O$ n) ? else
$ @( R n/ f9 u* C/ r. D printk(KERN_INFO "LED register sucessful!\n");
) [8 t! z6 S! {8 x" Q& Z$ ?( g- l2 W2 `# ]
return ret;
8 j7 A4 |; h" S4 d* m, \}( m1 |8 f- |; a# V1 K" ~. k
0 q, W7 z, W5 w+ T
static void __exit led_platform_exit(void)
- Y9 b" ]# i, I. i1 `5 x0 t1 y{& B4 ?) S5 [6 `% J6 H5 L
platform_device_unregister(&da850_evm_tl_leds_device);
. [/ ~! J1 J' [- ~2 x C+ a7 R4 K. L1 a* \9 P# G' x' A
printk(KERN_INFO "LED unregister!\n");
. O6 Y$ |: {; x7 `' _+ V* d}
0 D4 Q- w& G/ F4 @4 Y x$ z/ c- V+ f, L; B7 i
module_init(led_platform_init);
& j! k8 |9 N% l9 Emodule_exit(led_platform_exit);
2 |/ ~0 Y4 b" L
S; D# z" q0 MMODULE_DESCRIPTION("Led platform driver");% |( k" g& d- Y- D. t, p
MODULE_AUTHOR("Tronlong");
+ j$ U4 u# y! l9 f) W- d9 ZMODULE_LICENSE("GPL");
- ~ u' ?' n; D! j* B" }6 S5 Q/ Z' ~( ^
|
|