|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 M3 }; u% k$ a! g4 |#include <linux/init.h>' W5 \3 ~6 I v0 c6 y
#include <linux/module.h>
7 P9 b& p3 N5 h# E( ~1 P i( ~% K#include <linux/kernel.h>$ {5 Q( O" W, e- T# q4 }
#include <linux/types.h>
1 X6 l9 g: i/ X5 B9 h: V8 u#include <linux/gpio.h>
' y& h" z0 u, K#include <linux/leds.h>
4 x2 b3 l0 K1 ^- G b#include <linux/platform_device.h>: m! m) i/ D2 s6 q& Q; S
3 W: M+ |5 `+ T+ Y% X#include <asm/mach-types.h>1 h2 m4 R) T; |
#include <asm/mach/arch.h>
7 ]4 W" l8 S# E% i, A, C/ R- I#include <mach/da8xx.h>: S% c- f% C% G6 ^% Z; H
#include <mach/mux.h>
, o1 Y0 Q Z. b
0 y# h1 ?* b; y1 y# b6 h' D1 x#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 p' v" ^# s) J/ @9 `
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 A, x D5 p& D2 j' D#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; Y# O" R* `# z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" k- N. f ]; I& d0 a, N. E
8 d: e3 p( v9 o; X
/* assign the tl som board LED-GPIOs*/) _) C! s! G* m/ d) S+ O1 `2 S& \: w
static const short da850_evm_tl_user_led_pins[] = {
: H6 Y. W( l6 ~, ]1 c6 m/ K+ A /* These pins are definition at <mach/mux.h> file */
8 l" E, o) {% k6 W) U* ?0 U- q) l DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; V" {5 B/ z/ K
-1
4 g; P: a- @: w4 B};! [/ F9 S% z/ p/ P
. r. {+ H) Z. N/ u6 @static struct gpio_led da850_evm_tl_leds[] = {* v0 s, ^$ d0 B% b) o5 h
{
9 R2 @/ ~& r0 w9 G# S- Z .active_low = 0,
5 n% a$ c" O! L" W) M5 } .gpio = DA850_USER_LED0,
: U, m+ ~8 B6 q. ?; P .name = "user_led0",8 {; Y/ a: Q3 K/ O8 C+ |
.default_trigger = "default-on",
6 c; O( X; U1 ]; t }7 ~ },+ K* p% S! G2 U& R: ?; R0 t
{
5 @! I5 o: M! } C .active_low = 0,
9 p- X/ R' [+ n .gpio = DA850_USER_LED1,
' E8 O# d' j2 ?; `) R2 ^" m. }" P0 B .name = "user_led1",2 i0 ?+ r# ] K# i5 w# D d5 O; V
.default_trigger = "default-on",3 H! l2 i/ F# I
},
: q2 T' Q, b+ X {
" ?6 X5 x: i- a0 K% | .active_low = 0,& l. n. K* H8 y" C2 ~
.gpio = DA850_USER_LED2,
7 C) a) A+ V' E: b4 j6 A .name = "user_led2",& r0 g6 ]8 t Y
.default_trigger = "default-on",( m Z7 @' Q% O t
},3 m( F9 v* y" k1 D
{
. x+ \: K1 d/ o; k ~' f9 ^' q .active_low = 0,5 ^& Z+ L! g: l" |* h
.gpio = DA850_USER_LED3,
/ Z% s2 a" M, }5 U1 |3 i( ~ .name = "user_led3",+ B: \ Y, n, l& h; }2 y* N; f
.default_trigger = "default-on",
" m, k9 c- W8 \8 l },. F# ~2 x! V# G8 G* Y8 w
};0 v" ]8 Y9 H& X, M4 |. b
& j6 @. ~& {/ C' U |. l+ E8 X& istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 J7 N. x, M7 i6 d" Y9 g .leds = da850_evm_tl_leds,
9 T7 m- R& W$ g: G8 B4 K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# Q! B1 S& o" U- L4 O1 l+ X1 y9 f
};2 X# _6 X* o7 W2 h8 z+ {+ d0 s
: S9 n4 I0 P W! F l8 m
static void led_dev_release(struct device *dev)
, A( _+ D8 M" R$ }5 o{$ j1 \9 u, v' {9 Y' }$ F% y
};
; `( \5 C; R. B
+ x$ d b% F. I1 O4 vstatic struct platform_device da850_evm_tl_leds_device = {
/ y* D) l0 S* J2 ^8 q .name = "leds-gpio",: Z+ F, ?: d# A; v
.id = 1,
5 a1 ?6 o' ?) [$ p1 n .dev = {* f' W8 S6 g9 r" m X
.platform_data = &da850_evm_tl_leds_pdata,. o3 t- A+ |; c' u- @1 t
.release = led_dev_release,/ A9 S* h# d' K6 n; b) w
}
- \. b1 a* u/ v- p2 ~- K$ _( ]};) y7 R8 @' S. D
7 Q, ], z* `, b, }( K! Istatic int __init led_platform_init(void)5 Y5 u3 f4 |! s
{$ V2 V0 C3 K) j& l& D; e
int ret;
- o: Y4 z$ {/ I; f# E#if 0
( O- i% I7 E/ ^ o0 E+ [ o& n- X ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 X" @3 w/ D0 ~
if (ret)5 @/ I: d* j0 z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 m: h5 }8 S; Q# _4 Q4 n
"%d\n", ret);
- k( C7 l, v) ~* U2 P/ f- m#endif5 Q/ i7 i0 r' [) y! i. R" x/ \
ret = platform_device_register(&da850_evm_tl_leds_device);( k5 S: H. ~7 L5 H
if (ret)6 g) }1 S1 t m4 t
pr_warning("Could not register som GPIO expander LEDS");
' I: g' s a5 d& j, ?2 G else
3 U4 X4 Q2 S4 l8 A; [4 I* Y printk(KERN_INFO "LED register sucessful!\n");
( k& v. ]5 p$ S9 ^- `, k
3 w* a9 V' e9 l/ ?* s% i return ret;& M9 x9 m/ W( W, {9 \7 X
}
1 R) Z# ~0 e6 t) J& U5 t+ o; ^' x& }; ?; Y
static void __exit led_platform_exit(void)2 ?( \1 K% A% M4 L' w! L9 H
{
1 e1 l& l, O4 T I$ i. a6 s platform_device_unregister(&da850_evm_tl_leds_device);7 g3 I" c$ |& t/ ^
& N7 x% s8 ]) W. |+ h$ L
printk(KERN_INFO "LED unregister!\n");0 E2 j1 J( a3 _" f* @% k5 U
}
; c9 x. Q+ ]6 S5 g; s" e( o0 C7 v8 @% a. k( Z+ `' K
module_init(led_platform_init);
3 C6 ^5 f* |# I9 x' m5 w; d' s8 hmodule_exit(led_platform_exit);
8 n3 l/ q9 D/ ?: E$ d) z3 Q' P5 N% ?5 I
MODULE_DESCRIPTION("Led platform driver");
4 U) a; g4 Z5 @% t6 @. H6 T& |$ ^MODULE_AUTHOR("Tronlong");& q1 m/ g3 O: ~/ L) a- k
MODULE_LICENSE("GPL");
; I5 z8 s. _9 _& e% M U+ F, l+ n
|
|