|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
Y! G- h. H M#include <linux/init.h>
3 R. ]/ z, A) R9 O4 B+ O% ~- X7 }#include <linux/module.h>
) A4 a6 {! `& o, \4 Z#include <linux/kernel.h>
8 {+ @& E2 M- l" E2 G1 w: {1 ]8 r8 q; i" @#include <linux/types.h>
4 U7 k) ]8 \0 p" {1 F0 T$ V#include <linux/gpio.h>4 p4 `( [& ]: O. I1 n# y% T
#include <linux/leds.h>
3 T+ J' U9 X' Q1 `7 ]' t0 q#include <linux/platform_device.h>+ z5 L& d h- E# ^
+ `. \, V3 B( J# ]9 `1 Q# f: S
#include <asm/mach-types.h>
7 X: {4 K" U( N+ r: D0 f" O#include <asm/mach/arch.h>4 w8 j; ~. T: G: E, \
#include <mach/da8xx.h>
u* C. J0 Y6 Q& y" _; X) D#include <mach/mux.h>
1 s h& w1 i+ u/ M9 z
/ ?$ V1 k$ t' u1 }" G; k#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* B% _" ^' g8 e/ O#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 g4 \1 g1 Q" a* C, e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) \; F* p8 e, J$ ^+ ?#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# o& @6 Q* t) O8 D( l9 y
) Q8 X/ |" g+ b# h1 l
/* assign the tl som board LED-GPIOs*/
! F( F! ]9 D) y( [& k( mstatic const short da850_evm_tl_user_led_pins[] = {2 Z) e) ~" m2 y2 R# L
/* These pins are definition at <mach/mux.h> file */1 K% m0 [1 K; g: Q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. E# J2 F8 o& h, V6 R; |
-1; l/ V2 b: H: Y. ~) O+ A
};: E! y9 E" r8 h( _8 i
! D+ H) Y, c r6 }
static struct gpio_led da850_evm_tl_leds[] = {
6 M' j3 X. d9 ]% ` {
! _, \" _3 Z6 ~8 m2 N- m1 P6 X .active_low = 0,
W. w! h6 A: ^. e .gpio = DA850_USER_LED0,4 L9 S5 j+ B. }( x/ t+ E) S( q
.name = "user_led0",/ ]8 ]# [% R8 g& p g; l5 p% i
.default_trigger = "default-on",! V% N0 l/ Y6 k
},, d: \' i f4 ?: m1 L
{+ k" m2 U& o* n0 r
.active_low = 0," f5 r# ^) z6 P, x6 `
.gpio = DA850_USER_LED1,
% q2 m" r+ q: ^% B$ ~ .name = "user_led1", T- N. V# a& J O
.default_trigger = "default-on",
+ R% g0 e4 B# M' q9 p8 v% x },
8 L# \5 h" e& P p1 K {) ^- e& {( ~8 S5 l) j1 Z( A% z
.active_low = 0,, {9 V$ x9 a9 Z& {% S" n6 C
.gpio = DA850_USER_LED2,: f! R7 r1 }6 {$ f0 e0 Q1 p7 N* J
.name = "user_led2",: x' O. Y, G7 H: P% r5 f, X+ z
.default_trigger = "default-on",
7 Y6 v/ n, H- O% E5 Y" s8 w },. R1 S2 `; n9 t T) Z
{& r4 Q+ r; s6 A7 j/ u
.active_low = 0,
1 S) f' q) m& W C2 E* \ F5 b .gpio = DA850_USER_LED3,5 `3 W" U; Z$ {
.name = "user_led3",
+ j4 j5 C6 c2 N( S .default_trigger = "default-on",6 e/ ~; t" w9 l
},) G5 J u$ z" x/ m ~# d6 Z/ v
};/ M+ b. j" J n
& H* y+ x* N7 U. h' a" fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- j5 t" z, p9 J
.leds = da850_evm_tl_leds,
3 m' h' ?- p) } \! W2 ? .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 ^# x! B Y; u) C) T
};. l" x9 S# |: Z* A
" A1 \- r0 g3 G
static void led_dev_release(struct device *dev)* v4 z2 Y- y, f/ }; K
{; e/ {. D5 U' Z/ R& G G M+ j* Q
};/ H& @0 @; Q* d
5 j. |% y& z( l- V, a6 p8 s, Q
static struct platform_device da850_evm_tl_leds_device = {
$ f" s$ R4 D2 D& ?! b4 |' Y .name = "leds-gpio",- s+ ~3 D! F; q0 g4 n, t
.id = 1,/ o3 ] G8 U8 r v9 } R& Z9 y$ K
.dev = {
$ u w0 L$ N! V( i- z( M .platform_data = &da850_evm_tl_leds_pdata,
1 l+ z/ a- q" m [" j0 P0 M .release = led_dev_release,+ e& S7 l( {" B, m( x2 U( Z
}
" `! W, o8 x9 ~" p0 X& _* [" S7 B};
! a# I+ Q+ ~9 L1 ?8 E9 S, H, @5 _# J1 x9 C; P! @8 I9 D
static int __init led_platform_init(void) C) ]+ K: O* [$ _( k. \
{7 y" u4 D8 d* ~/ _( l& j7 Y
int ret;
; |" ~- {7 U) h; Z: p" k; u3 W#if 0
9 @. a: h, e% d- R I: N4 x7 @ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! W3 \/ C( v. m) A v
if (ret)
( B8 }! W; K6 r( V* X pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" p3 ?" z% V) N, J "%d\n", ret);4 M5 u4 H+ N i4 o* _9 E
#endif
4 f& }3 r+ w: d1 r! b5 | ret = platform_device_register(&da850_evm_tl_leds_device);
7 i, A5 @: K6 K: C/ ^2 x' N if (ret)1 z: q3 m0 ~. b. f7 R. Y1 T, X, y
pr_warning("Could not register som GPIO expander LEDS");
6 {( f' e6 j, E else, f9 U3 I& K) ~( ~0 `9 U) D
printk(KERN_INFO "LED register sucessful!\n");
3 ]# L! @7 e% M! }4 G3 h! p9 C" G) {
return ret;
% A6 |3 s& q9 z& k}
$ c; \4 n& P2 _; z; S
! Z# c, }" b. X. K* b& Gstatic void __exit led_platform_exit(void)* G3 w8 Y) ^7 ]2 D* S4 J: ^
{. I) H. _0 Z- q; m. m9 i. d
platform_device_unregister(&da850_evm_tl_leds_device);
. @% s" a- O: w- f/ W2 \2 ]
6 K* V% Y4 N Q' w' c printk(KERN_INFO "LED unregister!\n");
$ V6 `# q% u; k+ J- \8 O% Z}
5 C) A1 m& \* ~% O. F( C& w; C9 ]' c( E% U1 j' i" `5 J. O; {$ ?
module_init(led_platform_init);
# o' l% ^0 d* x' b! xmodule_exit(led_platform_exit);
" c% V! a9 w, Q) c+ @5 \
$ p2 ^7 n" F& T# iMODULE_DESCRIPTION("Led platform driver");" T1 j) z" k3 A6 P
MODULE_AUTHOR("Tronlong");
! n$ \/ h' ^" p! c4 NMODULE_LICENSE("GPL");* D* C1 Z' @' w L7 x0 [& n: F1 V
2 T R. z! A4 I. g! { |
|