|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* L! E* u# \$ g, {
#include <linux/init.h>
: p G- N M1 v M _6 s#include <linux/module.h>
/ Q. Y9 Y. V* E) F2 c4 `2 {#include <linux/kernel.h>
3 m, |) e! t5 @+ P#include <linux/types.h>
0 E3 A: O% c C! M: ^7 Y#include <linux/gpio.h>5 ?- Z0 {% K$ M+ w+ P$ p1 i1 ~1 k
#include <linux/leds.h>
B; T/ @( p' q" d& E* z#include <linux/platform_device.h>
$ r, b1 Z: X- a0 e
9 c( m2 p- Z* t/ _* |9 Q#include <asm/mach-types.h>
9 h! b0 h6 l J; s#include <asm/mach/arch.h>5 x0 S+ ~9 k! p
#include <mach/da8xx.h>' w5 ]5 W: p6 Q. L! C& @( i) p x0 D$ Y
#include <mach/mux.h>
: f7 _' y& X1 E1 ?8 q
4 i4 } |" g* L; {8 _, b% T#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 b$ \& _7 O$ c6 @" W" Y, O
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 n, u0 X& V' E# Y% o5 c#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 j+ m, K4 o4 z. _& i6 K5 [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& h" u; T( Y% ]5 }) ^
9 K' g" Z X: i/* assign the tl som board LED-GPIOs*/
9 {* H" W* f. u' istatic const short da850_evm_tl_user_led_pins[] = {
: u3 _' `% u3 Z' Q3 |" a5 E& K& S /* These pins are definition at <mach/mux.h> file */
- t, W K/ V* p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 h; H8 V/ M' S4 J. \# M
-1
6 \! c3 Q8 H5 o' W/ u! I};
' f$ O/ M8 K' T
: g" d: w' J7 r$ ~, L0 Sstatic struct gpio_led da850_evm_tl_leds[] = {, k& }1 |- m/ U/ y- F& ^4 B
{
, t* i- p) I K& S( ]7 e' m) G .active_low = 0,
$ _( n. b7 R3 Q6 P! Z& S8 H, T. G .gpio = DA850_USER_LED0,5 x* [ B$ o. p8 d" I- a( z8 P
.name = "user_led0", D7 Y! C# J0 [5 _. \# z! H5 v
.default_trigger = "default-on",+ T1 u! I `9 V4 {4 ]
},0 x3 l# j+ S, T4 L
{, F- _ [% m) I& k3 e- r" C9 C
.active_low = 0,5 a+ \, q: n$ D, a$ [
.gpio = DA850_USER_LED1,
H' X2 D: Y( W1 w% ]3 B4 l .name = "user_led1",9 ~) W- H+ [: O6 s/ q
.default_trigger = "default-on",
: u2 x- k/ _+ ~5 L1 A( }2 I* @ },/ B, V, p+ ?! |- k
{0 ~& M2 z1 T; o2 r
.active_low = 0,
$ C! k7 A; I# b' o h; M9 ~" I1 G .gpio = DA850_USER_LED2,, U) w" `* m0 ]5 V8 u
.name = "user_led2",
: y1 h/ Z7 y* E' {' a7 T* e .default_trigger = "default-on",/ ~* B+ @$ c9 `
},
6 D, e, ~- r/ V% n( S3 ^ z/ r {
$ E% @% N3 R% y. E1 ^2 c0 r* p5 w; x .active_low = 0,
0 P* ?( r- S& Q- | .gpio = DA850_USER_LED3,
" C- \/ F; R8 d7 `% h .name = "user_led3",4 @: c: ]! R5 V6 M0 Z6 U# p
.default_trigger = "default-on",
2 w8 d/ w0 x8 i% Z. G$ j$ n3 l U. E },! }- O- \$ _* q! h4 \' M
};
+ m/ S2 y& c" L
. x6 Z8 A$ a5 G. c [' c7 D) Ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 T) |& S: d4 [8 l- H R+ V, L .leds = da850_evm_tl_leds,
; i# J) _$ ?* K- t! [ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ F/ f! P( o, o" |6 [. @};
; s6 @( ]" J! ?9 B) V' [9 P" R2 C/ I+ C' ~
static void led_dev_release(struct device *dev)& Z3 z6 h0 q* Y x1 }3 {$ a
{6 O; S! K6 \0 {! t
};8 E# ^" R% I! M3 [; |( n
1 b$ X, }' O: m, ~6 q
static struct platform_device da850_evm_tl_leds_device = {
, v6 ~/ x! q9 b3 O1 q .name = "leds-gpio",
5 P& r/ q, R9 W2 l .id = 1,/ Z n4 C* Q) b3 H8 U9 p
.dev = { R. X, Q. R" T0 k2 U
.platform_data = &da850_evm_tl_leds_pdata,# H/ Y6 `! ^9 ?: `" ~
.release = led_dev_release,: q$ F" k- Q! y( n& M
}+ z& D4 d. J6 ]2 H I, C/ G
};9 J* H; i+ A5 c6 b9 }% S) k# f
8 ~( A; S' O6 {static int __init led_platform_init(void)
( B, g/ t- v v; l& \{3 ~: ^9 @8 X+ j! q
int ret;
3 {6 I- t# C% c$ ~#if 0& I7 y: q9 E" a/ ]- w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& g1 v( F- ]: R i) e8 R; l5 [ if (ret)9 e: K( C# { d1 c5 t) u
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) u6 r$ \8 g1 A0 P "%d\n", ret);
; K" x$ v2 ?' e; i6 g" m" o#endif
' i( l" C+ d8 K2 C+ ^ ret = platform_device_register(&da850_evm_tl_leds_device);$ U% G) h7 |+ }/ q @
if (ret)6 {# o( S) g& U3 r8 {& M. U" ?
pr_warning("Could not register som GPIO expander LEDS");3 r4 C" P% @; u. ^4 b: }& [; y6 x% Q
else8 t* g" E- {, Y4 @+ h1 ^* W. o
printk(KERN_INFO "LED register sucessful!\n");
1 r! x( u. r4 E* h/ p/ i" I: x! _1 K3 u& A {5 F0 a4 {- I
return ret;- v0 Z; A+ T- h3 Z. I/ t
}+ h& Q! V+ S" C2 X( ~5 ^9 i: D
( R4 C' K/ g% @# }4 L3 m! A
static void __exit led_platform_exit(void)+ z Y: ], E) P) D* ?4 `
{
7 K O; R- }7 P$ R9 k platform_device_unregister(&da850_evm_tl_leds_device);
! C) g( I) {- b7 d5 ?! e$ O4 X& C. q
printk(KERN_INFO "LED unregister!\n");
" Y9 e, m7 t, s+ w0 A}% t# i* x* i* L+ R0 z3 q& o
. ]; L5 t7 i3 c1 Z3 c4 t; F- fmodule_init(led_platform_init);
6 m3 A& l% u5 S* c9 v, q9 Qmodule_exit(led_platform_exit);* t4 q* c/ b! `$ ~6 E" y g
9 A: O6 m$ ?7 w0 d1 Q* GMODULE_DESCRIPTION("Led platform driver");
! X& W7 V7 K; a0 pMODULE_AUTHOR("Tronlong");6 F" ]9 g: z6 h& `* `, M
MODULE_LICENSE("GPL");- `+ E T9 W) t! e" q+ C
+ O& j( \! e& d& Y3 {% u |
|