|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; j. M( n0 F6 D2 K4 T) J#include <linux/init.h>
3 {) J$ C+ n$ c" T0 L#include <linux/module.h>
* `6 ~0 a4 t1 z6 D/ ~#include <linux/kernel.h>6 _! p7 j* ?/ A/ l, u6 f
#include <linux/types.h>
) L% r, g+ L2 t6 q( c! {" ~#include <linux/gpio.h>
0 @" u1 p. q/ I+ a#include <linux/leds.h>( ?/ B2 H9 `, B6 F9 W- h5 K* X
#include <linux/platform_device.h>7 W( Q: q" B# e: W
) X8 [: F3 P: C: i" m! i
#include <asm/mach-types.h>
7 @% j1 j0 ^9 _ C' T#include <asm/mach/arch.h>0 ^/ r( ]: h N
#include <mach/da8xx.h>) l& l5 d% M; j$ C* w
#include <mach/mux.h>
& q# V, E! C" P. B9 N r1 H0 B6 F; z+ y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), T+ {" P" w. U0 c( w7 _' I$ y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 n/ O) \" [2 E# s$ O#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- { ~' s; X+ P# k0 x: Y% ^#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 j, T; e8 G! v1 X, z: v
) \6 f. y8 i8 Y$ L2 C- N
/* assign the tl som board LED-GPIOs*/% r! Y' n# I; g# r- A0 \1 G- t e
static const short da850_evm_tl_user_led_pins[] = {( c. M+ T$ \" r1 d) _( y7 z. \4 v
/* These pins are definition at <mach/mux.h> file */( v4 N; V9 g. c) N' k z/ c }
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 @6 ~( h P1 N' \
-1
2 q4 |8 m5 T+ ^- D0 l};$ X$ o9 h1 Q' \* l i
6 @: h$ e0 R n: i" l7 g5 kstatic struct gpio_led da850_evm_tl_leds[] = {. h4 @% H4 x9 l9 Q4 q" B
{
* j2 R* x* i2 }0 t9 F a7 ~% ] .active_low = 0,
1 b# j$ l- Y- v; [* R. _+ h0 P .gpio = DA850_USER_LED0,- B" q6 r6 {) {8 |+ o
.name = "user_led0",
; U# e# J! y6 E, ^) B# ]/ f; r* R .default_trigger = "default-on",$ N& g" P, B$ ^8 z( {! m
},% t, H: g6 q. s, B4 j- Y
{
+ z$ C( P* i) U+ ]# w+ p .active_low = 0,
/ T0 `# T/ C9 A1 p$ V& |; _8 ` .gpio = DA850_USER_LED1,
5 B! O- R. O1 N7 f- I6 [ .name = "user_led1",
/ w/ G* z% V5 P .default_trigger = "default-on",
- f, Z9 s, D! L" M& z4 D7 x },8 d1 X( ?# K7 c( z
{! Q- W: M0 x$ l3 Y6 o4 j8 I! ?
.active_low = 0,
2 T% l4 z. ?0 Y. l+ k' o .gpio = DA850_USER_LED2,
5 T! h2 T( F" i, K# j* _4 v .name = "user_led2",. Z/ A, I3 B. }, G+ h+ a
.default_trigger = "default-on",2 r' m( M B2 a/ O! X
},
2 T3 @% _7 d' _: Z {
- G# T" l! w( P* z' U0 w- s3 _ .active_low = 0,$ s; z7 L. O8 S0 V$ m
.gpio = DA850_USER_LED3,
& W/ s1 R* |5 K, S .name = "user_led3",7 i; W3 V# h9 H& z$ I x6 `
.default_trigger = "default-on",
8 U; n$ k+ z2 r: |9 P, J% s },- U3 S% s; x% l+ b5 i: F
};' F: Y. ]) {. i5 @
2 ^% C( V4 M# ~% U) ]& j& z, Jstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 y* h% G6 I8 D# B$ U6 M .leds = da850_evm_tl_leds,5 P1 K4 m- Q) f! [) v
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% x- q1 N+ | K" L3 K' p};4 e. l5 [, f; y4 z; Y% V R
; p+ C% S1 L" U6 ?9 ^static void led_dev_release(struct device *dev)
: d% t3 f' k z& m{8 u K4 r% b0 Q
};7 b" A; ?2 p* U s% y0 q
% _2 [: g- w, g; Estatic struct platform_device da850_evm_tl_leds_device = {
$ V/ ^( o2 E+ @& X8 ]* J .name = "leds-gpio",; A9 H! b; L5 h- v" |9 Q# ]
.id = 1,
) ]. b' j; ?' Y* N .dev = {
' C% Q$ X q# u .platform_data = &da850_evm_tl_leds_pdata,
7 S* b6 S, N F .release = led_dev_release,
3 g! J! e/ t# E. { }
6 j/ j, l# E7 J+ J9 x};
. A- E, A, x8 r3 _$ U+ L9 P2 X) B2 v9 y; }7 V: B% M
static int __init led_platform_init(void)+ Z; G8 P( x3 X9 g
{; M5 S! b$ w7 z9 C& R
int ret;
3 o* ~' {" ~& _) [+ h; D! D, S#if 0! {( j7 ~! a7 _9 v- B; J- ^
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 v3 [0 h3 Y/ |# t+ {
if (ret)
2 i8 u( K5 Y" l3 y! U* x pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% z% |1 F. D8 s) I3 `' w* u9 h
"%d\n", ret);
& w: w6 `) }& c7 f#endif+ `, l. {! m) y
ret = platform_device_register(&da850_evm_tl_leds_device);7 F1 C9 H4 q' b& J; u
if (ret)' w2 |# ~' C8 }8 D' {- N
pr_warning("Could not register som GPIO expander LEDS");2 V" r) ^, O; w0 w
else4 e+ r$ G* ?, `! |/ ~2 \: C$ Q
printk(KERN_INFO "LED register sucessful!\n");8 N/ d8 l7 k( [: E5 k8 v g" @6 a
; o. R. L3 A6 }- _ return ret;6 H5 q4 f# y% z
}
, ~# [% E' q3 g w r) u. ]8 G1 b% S0 N; m( s
static void __exit led_platform_exit(void)
$ n$ W& p: g( e, L{8 x- Y5 R4 u' F
platform_device_unregister(&da850_evm_tl_leds_device);$ e1 S& j) Q$ A7 M0 e4 B
3 M$ O2 Y2 S b1 A9 s# O& F5 q
printk(KERN_INFO "LED unregister!\n");8 j9 \# ~0 g6 Q4 V. X: Y
}$ _: G; e% I0 R5 n* a8 t' ?9 A; S
4 n1 q8 M% }% _! O3 c# F3 bmodule_init(led_platform_init);3 r+ B( V }5 d4 Q0 _$ a$ k0 i9 A# O
module_exit(led_platform_exit);5 {2 W% H6 r5 g, [
9 E; _& Q0 A8 p
MODULE_DESCRIPTION("Led platform driver");
) j4 h5 W8 J2 h9 t1 jMODULE_AUTHOR("Tronlong"); t7 Z% H/ V$ s! B
MODULE_LICENSE("GPL");
" P/ G! ~ p9 [4 `" x$ C4 T1 r; C3 L m7 ?3 C6 k6 ?
|
|