|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& L: T: {$ q/ K" u$ o#include <linux/init.h>& I, e0 P S. W& y; V
#include <linux/module.h>7 ?2 {% c0 a$ Z: |# h0 r
#include <linux/kernel.h>
" V# R% U: ~+ C( E7 Y' {, j#include <linux/types.h>% z. I Z# M, O0 r6 a
#include <linux/gpio.h># \$ |7 }+ h& \$ z a/ t
#include <linux/leds.h> D8 D4 R4 I& C) N* F2 G9 t
#include <linux/platform_device.h>% m! d; } u9 \4 W# q. l& ^
5 C/ m+ d( e; _, P, n. |& {#include <asm/mach-types.h>
/ q1 X( M" E* b Y4 \+ j#include <asm/mach/arch.h>4 P# W; M1 [# o! _+ k
#include <mach/da8xx.h>7 j. Z0 O/ H, ]4 i9 `/ h- u
#include <mach/mux.h>6 G' m G! N/ o) q" }; P# }. x
) |' Q& p! s' a# @#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
4 ~: a9 M' l( O#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* y/ h, D- b" r& U4 I
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* p5 w) @: O1 \2 F
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) U" H" u3 b: T9 S
9 h. {$ I3 A- i% z: O+ c3 i/* assign the tl som board LED-GPIOs*/4 d' c# J2 [/ g" o H0 k. [, p" z
static const short da850_evm_tl_user_led_pins[] = {( a/ k& d+ g3 U, V
/* These pins are definition at <mach/mux.h> file */ ?. g9 r4 s- K. J$ q! Q# g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; ]( `7 E) ?2 D+ H) y2 K1 v% B -1! v9 l* r B/ U! X% ~( A6 s
};) k D9 Z8 `2 D; g, m
2 v5 H# W3 c1 e7 Z
static struct gpio_led da850_evm_tl_leds[] = {
7 }+ |. y' {9 ~! P& O( `4 R {
0 F# N0 ?. {+ i .active_low = 0,5 M) @" P6 N8 y, s b( C
.gpio = DA850_USER_LED0,( d; z3 z+ t9 S1 \
.name = "user_led0",; D' f. [+ W3 Z/ [2 E0 H
.default_trigger = "default-on",. C; m3 N T8 O
},5 a) H5 f! W/ Z5 J# ~
{6 [4 k" n2 M1 L
.active_low = 0,
+ u. f- w7 Q! a* p$ @ .gpio = DA850_USER_LED1,/ A# W% N& p- Y
.name = "user_led1",; _' t: o, r _9 N
.default_trigger = "default-on",/ @9 p2 H( [+ b$ u
},7 Q. U2 f: E$ p8 F
{3 Z0 s6 ]. g# e7 Z- z$ x
.active_low = 0,
0 W, p* K" ?6 J r# k .gpio = DA850_USER_LED2,/ g: t. h6 {7 _& b
.name = "user_led2",
, J) v$ M8 g* i$ a2 }. ^- p .default_trigger = "default-on",3 Q% o+ B0 b- L
},
* k, R& |) |+ l. k% ?5 U a! K {7 g4 p; L" C6 h1 I
.active_low = 0,
/ L2 r* ^: }4 ]& W c/ n( c .gpio = DA850_USER_LED3,; M# L2 O* D" Z( w6 r& G6 c
.name = "user_led3",
# }' m# M3 L/ D% ^5 @- n# {) _ .default_trigger = "default-on",+ @) D. F# n5 @1 I
},( z. I6 c( e; C$ X2 W
};
& \; f: N( H8 Z& \! B
2 |+ K7 _+ @5 N6 ?" ~* Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ S) l4 k: v% y! m% g
.leds = da850_evm_tl_leds,
% {- B3 Z8 S% Z0 j) y' m9 d# ] .num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 s8 }# S9 Z8 H7 A6 F- Z& x* W
};: v' _7 E' r$ ~& ?9 h* Y1 I9 B; ^* l
) o7 n5 |; R3 h% H9 }8 J$ B u
static void led_dev_release(struct device *dev)
4 F! f6 H+ x' |7 D{, b* @5 c2 c+ i) W1 Q F8 R
};
2 d; `0 X/ }$ X# w. ^7 W6 G
# ~+ B3 z$ L; z9 f, M; Astatic struct platform_device da850_evm_tl_leds_device = {- d0 E6 [. L7 U0 W \ c
.name = "leds-gpio"," q7 f* q2 [+ W- T2 @
.id = 1,
. I9 n) l8 r4 X8 @4 y) E .dev = {& P/ y# u& j# p3 Y$ C; {: ^
.platform_data = &da850_evm_tl_leds_pdata,
$ B& }0 P: g9 _# g. Q4 C. F, e5 \ .release = led_dev_release,
1 Q1 C7 d1 m; P2 p$ b9 U, D- V }. N1 |4 V; [; g R4 L2 |
};
$ `+ `( R9 o2 y5 C( v5 r1 G9 |
static int __init led_platform_init(void)
* @8 K; G. j& N5 J8 z' |9 N6 Z{
1 b/ B9 G3 _1 ?; q# u% F int ret;' F: l/ H1 f4 c1 m4 v, g" K- Q
#if 0
2 f' ]) c1 J3 B2 p+ R ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( R$ A' C# O# g9 s9 k) [ if (ret)
( I* R0 Z+ A& u& _ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 l, \2 S6 h) h" O3 l "%d\n", ret);
# E" a" K5 \% }1 Z* f( _1 K#endif2 \0 Z- G. H/ x4 ^
ret = platform_device_register(&da850_evm_tl_leds_device);8 a' d8 e: C6 \" q
if (ret)
5 g& n0 L. V& f/ ^) A, D# g$ Y4 i pr_warning("Could not register som GPIO expander LEDS");
& @; |; ?; m$ `+ N else
, b& V& T1 K. \1 L- h9 ? printk(KERN_INFO "LED register sucessful!\n");
2 j7 E d+ l* d) W9 x0 o' O+ w% o) T- ~" S, f1 d5 K! h; V
return ret;2 y; ~* N- h! r$ C
}- i- P* C; l& O1 @ ?1 J, I$ p/ V
; W7 Y" T; E; Q7 T1 ~, \static void __exit led_platform_exit(void)/ n9 B3 b0 r0 A Q. T- I
{
* I* [; O- Q: j- d' R platform_device_unregister(&da850_evm_tl_leds_device);( G, y% c9 t1 G9 c. K
1 t# T6 @$ X; N2 W# E2 h* H0 A5 z- }
printk(KERN_INFO "LED unregister!\n");
5 u: U: w& W- ?- A( [}4 W/ s/ b8 J' x
7 S2 G% v4 Y0 |! C6 amodule_init(led_platform_init);# G# k& b# @/ x, x
module_exit(led_platform_exit);
3 s5 A8 l, x |9 @8 u) _2 X
. q5 f" d6 a' E! F7 I# ~MODULE_DESCRIPTION("Led platform driver");
4 H3 {- _- K1 c$ S) ZMODULE_AUTHOR("Tronlong");
8 U. l4 e2 M; b- {MODULE_LICENSE("GPL");9 U* ]0 _8 H0 a+ M5 ]7 H) o. v% m
) z$ c. p9 N/ p6 R: N |
|