|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 \+ Z5 n5 c6 `: q3 M4 ~/ {7 _
#include <linux/init.h>
, B# ~" |4 q, K( R/ j2 f#include <linux/module.h>
5 `8 W4 e& P# n$ L& m" b& ]#include <linux/kernel.h>
2 r& j2 A$ e7 B) M- J( P#include <linux/types.h>
* y3 Q8 j8 U) l* }5 u# w#include <linux/gpio.h># x' g5 r9 }) ]8 o7 @: ]; S0 f4 |
#include <linux/leds.h>
$ y" e4 e% s( { k#include <linux/platform_device.h>6 V# C* C- i( ?5 j+ [- s
& R: B9 Q b# W0 m
#include <asm/mach-types.h># g7 P% g! ?- S o2 S$ h
#include <asm/mach/arch.h>* I* y) _5 a+ |" j0 y; b5 e
#include <mach/da8xx.h>
9 ~. k1 X4 c/ g* S) \#include <mach/mux.h>! S2 x+ q! }& n$ I7 Q
( p# h/ C3 ^* {2 Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! Z0 ^9 ]1 ?# S# Z _6 _; b" g#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 B1 u5 Z0 r0 `: o6 N, f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' [( J) I5 K- M7 A. A
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 o7 S* x5 U9 f* k/ m C: h7 L
) n9 ?9 w. [" h2 O, U
/* assign the tl som board LED-GPIOs*/! N& i, W' k; ?1 ]. Z( ~! V
static const short da850_evm_tl_user_led_pins[] = {
2 z* u8 }$ Q4 E9 V6 s8 r /* These pins are definition at <mach/mux.h> file */
" N0 k4 f7 r9 ?& r$ ] DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 ~1 L( T- \2 f1 `# M8 _; a -1( G" `# L9 t1 l7 J
};
- d5 M+ N# f9 u+ \5 V" a7 y* F* }. V% o ~5 c
static struct gpio_led da850_evm_tl_leds[] = {
4 z/ V3 a( J4 R {
' F2 Y& }1 a. w' i) e .active_low = 0,
, p6 I) E, w; E, W% A9 S .gpio = DA850_USER_LED0,
6 @1 e% W3 `3 Q$ ]3 r) q( E$ w .name = "user_led0",
. h: g/ D/ u/ ]6 f) D) i: D .default_trigger = "default-on",
) t* M1 H M) S/ Z },
) s# U$ d6 K. ^4 @8 J4 b {! D- ^. r6 ~4 ]
.active_low = 0," R# p1 w% `# v" E
.gpio = DA850_USER_LED1,6 \9 e5 p' f: [3 {, a9 D/ V
.name = "user_led1",- q8 j6 _/ r! [# h
.default_trigger = "default-on",+ Y- y# e: x, x: R
},
3 s3 @7 h* `6 Z1 G5 x6 z {- C, a0 ~2 H9 K
.active_low = 0,
! Y5 x+ O0 M6 S; V1 b .gpio = DA850_USER_LED2,( |+ d; s" w' ~* A( v& z/ F6 k
.name = "user_led2",! I* o; ?9 W* |" l
.default_trigger = "default-on",9 @6 L7 k7 t' p# Z4 }, }
},
) S* U) W5 u, D6 }$ ^; } {6 [- V/ o, r6 N! [. L5 K5 Q
.active_low = 0,
. K2 L3 \" \2 b* y, U% D$ q6 v7 Z .gpio = DA850_USER_LED3,
, o7 n( Z* b7 z. V: a v .name = "user_led3",
# ?0 q; i+ S" Z9 X! I/ a .default_trigger = "default-on",
" O. q1 \3 e1 h7 r( g& j$ b },; i' a; b8 b3 q T
};
- z9 g3 ^! ^# Q% D+ j0 B0 t8 m5 W0 L }, q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% y3 t6 ?/ {& a
.leds = da850_evm_tl_leds,
6 m6 T" G: M, @2 U- J! p0 T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 I4 W, V' E5 w4 n9 h
};
- N/ Z9 h1 a+ T+ r* Q! o
* ~2 S+ B0 x7 |* ^& istatic void led_dev_release(struct device *dev)
1 A1 v4 {% D* r' O9 e{: `+ Z2 i m1 s) a2 m/ w
};" [& } p$ b$ a( L) ]
$ P1 V4 h: e% \4 N
static struct platform_device da850_evm_tl_leds_device = {% x9 ]$ y; B2 e3 z2 U
.name = "leds-gpio",6 Z9 Y( M2 F/ ]9 z2 P& r
.id = 1,
: `0 a. @5 E) N& U .dev = {0 \& d) b1 S/ ]( V! g
.platform_data = &da850_evm_tl_leds_pdata,
8 x+ ]8 j1 U% p# C" G# \5 s. { .release = led_dev_release, U0 |6 |$ M5 H- X' N
}* R" N* C* e6 O$ r: X0 {' h
};; E `9 R9 g5 t6 j C; \5 X+ {
' V2 s* t" E4 a9 N
static int __init led_platform_init(void)
2 [ G. x+ m2 R" M4 ?- [{1 |1 l3 @# l. z, `4 D) Y/ T
int ret;, F$ F+ Z+ Z/ b3 u
#if 0
% v d% r; ~1 z \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% N c7 c6 c2 ?8 ], a
if (ret)! `. [3 Y) L& m) {/ D
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% G) J7 z2 _3 |, I
"%d\n", ret);
7 j7 l+ \* J2 z( @! Q#endif
' k) I& |3 o/ Z& ` ret = platform_device_register(&da850_evm_tl_leds_device);
) _2 v9 c6 b% S1 ^6 d5 f2 ]4 U if (ret)
' _ D6 {, e) n0 H0 s2 Y1 n# \! b; Y pr_warning("Could not register som GPIO expander LEDS");
4 u5 h% F3 U2 X( Z else) G* S1 L" w; m
printk(KERN_INFO "LED register sucessful!\n");
( Y0 E3 h, o* V, w. f; U
5 C( z+ j3 Z7 k0 a2 \ return ret; @; g1 e( i" R9 B
}( }: z" A" i) z1 G4 J2 m
# H8 ?; V& V. {" |static void __exit led_platform_exit(void)& N1 |2 B A) T3 v/ P" C5 k
{
& J2 Z" X# I( x& V* G platform_device_unregister(&da850_evm_tl_leds_device);; u' Q+ q0 O& u+ d: A
% c2 K, Y3 `6 [" N; K2 A: q printk(KERN_INFO "LED unregister!\n");
M: ~" q6 W3 Z3 v}
" y. K, p) V0 g4 K; B# [
" Z1 P! {; D9 J: Wmodule_init(led_platform_init);, T+ e* P; a$ Y4 j$ e0 A
module_exit(led_platform_exit);) \' Y0 p* B% H2 S; W" U
0 p2 P9 Y4 ?2 W# e, F A5 m
MODULE_DESCRIPTION("Led platform driver");; Q7 L. K9 t k1 w4 `5 X& d
MODULE_AUTHOR("Tronlong");3 ~7 R0 y: B5 x O: N" n c( l
MODULE_LICENSE("GPL");
P" O5 o6 a. q
9 I+ T9 j, A& t7 r R |
|