|
求大神给下面的程序做注解,请稍详细些,谢谢。
& F8 Y: T- P- u- f7 l5 m4 A# Q#include <linux/init.h>
, _/ \, u* H: F/ q2 ?" c#include <linux/module.h>
- r* s+ L3 |* L7 A, Q& B#include <linux/kernel.h>& m- B8 r2 y) z: ~' O3 ^1 ]3 d
#include <linux/types.h>9 F; h$ n9 z8 h) x" ~, |- K/ m
#include <linux/gpio.h>$ v' E& e1 x7 \# k) \/ ^* R* k
#include <linux/leds.h>
# L7 o* o3 l5 U( S \, u K( ^#include <linux/platform_device.h>
0 F) ^+ e+ W$ `: D) f; D4 n/ i6 M n" @
#include <asm/mach-types.h>3 u a% w2 l4 N
#include <asm/mach/arch.h>
' F' n# B7 b9 ]#include <mach/da8xx.h>
0 v- {5 Q3 ]0 I E* e#include <mach/mux.h>
: q0 p! F2 @: N# c2 Z. c7 P
. G! q# Q; ~7 s! n3 S2 b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. n/ a+ o3 ]& E# ]" ]#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); J+ ~/ F: V! c) C& P+ N. Y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, R% ? p3 H5 c5 G$ z1 L#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 `. {* j; M7 n% j5 k( t+ g
7 O) z& G' G0 O( x& m8 l. @1 \/* assign the tl som board LED-GPIOs*/
: q6 V7 `1 {% m7 I6 p6 ?+ x9 F( Mstatic const short da850_evm_tl_user_led_pins[] = {1 ?, J- e; W) b" ], S0 V: p# g) v2 z
/* These pins are definition at <mach/mux.h> file */
7 J, a0 O3 @* ~+ ~( i9 f+ _0 ]$ @ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
- _$ l( y( @% j' u -1 F# n- g, j* d1 p1 z. I; @
};% e; b3 B- j- r. o! ]9 E8 t
2 q9 ?8 F: C1 }
static struct gpio_led da850_evm_tl_leds[] = {1 R5 X2 q. }, P4 b' |/ Y
{2 o" n; r& @! w, s
.active_low = 0,
& w8 Z! Y. z) ] |/ W .gpio = DA850_USER_LED0,
+ ^( ?0 t5 ~$ _3 p ?4 w .name = "user_led0",# l/ m/ X% B" W; v& o( I U: C9 ~ B
.default_trigger = "default-on",
" l/ w) m: L, n' `9 i },
I! K% v7 Y9 T* F7 r; U {6 W1 t) ~! f( c; v$ n; x
.active_low = 0,
' e: h u8 ~4 q0 n* @5 E6 p .gpio = DA850_USER_LED1,
+ V" |$ q2 x* ^+ S0 S- x+ u2 b% ? .name = "user_led1",- W$ N! ^( z, D6 Q, u# c
.default_trigger = "default-on",
, _5 {7 c" G2 W0 ^8 S9 q+ [ },
3 S$ _' [3 T, R* }! x! l {
9 ~6 F6 \; t4 ^6 n p .active_low = 0,% i7 R+ s8 U* h) e) U7 y
.gpio = DA850_USER_LED2,
! ]! }6 Y8 Y4 _$ h6 R$ z .name = "user_led2",: c. @ ]* S/ I0 u2 r
.default_trigger = "default-on",/ ~3 ^' @9 B( P; w
}, H' L9 E; R9 M9 w1 q: [# r5 W
{
E& h% ~7 b1 e$ k- t .active_low = 0,
$ F3 E6 n. Y. l3 u, n .gpio = DA850_USER_LED3,
$ m" p0 _/ Z" q9 K. i0 J .name = "user_led3",
' P$ `; w0 s& A8 Y .default_trigger = "default-on",2 ~. Q; f. L3 @7 b8 b
},( D& \; ?% P: O: R6 {2 i3 m& B
};
5 p/ p; g# l- G) Y! f, U, E+ L5 ]4 a! t7 j) p, n9 Y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! x, ^" L2 f3 K+ }8 z7 \# j) y% K .leds = da850_evm_tl_leds,
; c* K8 B" ?2 i# P, ^$ }5 U1 D .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* \( e+ H% R9 w- Z M/ G};; I' h! X1 S0 M
# }0 g3 g/ L7 l6 estatic void led_dev_release(struct device *dev)$ J' a6 b/ D( T! R4 _
{1 e( _( h. L6 }, d
};9 E7 {; o# ?0 N8 Z, L5 a4 h
# b7 v# r* g$ w2 a9 E
static struct platform_device da850_evm_tl_leds_device = {
+ q3 n- z) u1 N8 r) A' E, h) n4 G .name = "leds-gpio",/ j8 H( q8 Z/ m7 H& b3 @, f: s4 ^; ^
.id = 1,
3 s, o- L; e# w+ m$ y .dev = {0 E2 N/ \0 f& X
.platform_data = &da850_evm_tl_leds_pdata,. E8 s. Y% ^+ H( x7 S
.release = led_dev_release,4 _, ?2 A V# N, F
}
4 i5 j$ T H0 m" o, G};$ A9 J2 X$ a* k. E+ J4 ]
, k* C' k |: J, _" U1 b1 c/ u
static int __init led_platform_init(void)
) y/ |* j. m. Z& u. r i0 U+ l{: K* R2 Z ^& M9 }+ q* F& o' ^
int ret;& w/ y) A2 @7 ?" c- l3 ^1 m
#if 0
4 q) L! f7 K4 t' O ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 p, y$ x7 B L6 v5 n ^( n. P if (ret)* } b/ ~ G/ g" I8 H" u' ]
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 `- c* o1 |9 U
"%d\n", ret);
- h' X9 M; A5 W8 C: e4 X5 T#endif8 D! @; Z. T! [! d5 ~ f) w/ h
ret = platform_device_register(&da850_evm_tl_leds_device);
$ v. e4 m p" S) P, Y+ @ if (ret)2 `6 E5 }* x+ e
pr_warning("Could not register som GPIO expander LEDS");# z& ?9 o) c* ~: p
else) b, _5 n/ H( j2 z: C# E3 T
printk(KERN_INFO "LED register sucessful!\n");
% \- m7 y( t/ E
. F9 _. j% g" R7 |5 L6 Z return ret; t/ z' X( z3 o, b# [( c. o
}
' H j2 B$ N4 O( O! Y7 m8 \7 t$ L& H
8 | R y; G3 i$ p9 X8 q. V% k7 {8 Estatic void __exit led_platform_exit(void)! n! B. p5 J( ?) a$ P0 [9 E A }
{* S" P: A, [' |0 a& y; I
platform_device_unregister(&da850_evm_tl_leds_device);
! b" h- N& {0 c; N$ _; P" _) C" T1 U
printk(KERN_INFO "LED unregister!\n");, u, |2 \, v. d4 b0 }; W, J5 F
}' h& J! R; i8 q' U
1 P. }7 K/ g) _: G6 O
module_init(led_platform_init);0 E+ Z; Q/ A# N5 j2 h' F* S
module_exit(led_platform_exit);
9 R5 u8 l$ q% f, M
4 d$ G* F Z' F1 o( \MODULE_DESCRIPTION("Led platform driver");
# J8 N, R& Z6 p: a6 G& kMODULE_AUTHOR("Tronlong");/ Z% P7 C) i S8 a2 ]( F
MODULE_LICENSE("GPL");
$ a' u0 |4 t: b# {4 a; u- u: d: _, ?
|
|