|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ I3 [) b: b6 F) K
#include <linux/init.h>
6 ^& Z. P/ ^) s8 w5 P6 ^#include <linux/module.h>+ L0 X8 k- T: g# g! T
#include <linux/kernel.h>
$ b. ^/ O$ O/ w$ ?/ `* x#include <linux/types.h>+ c! e& Q; ]' `' h2 |
#include <linux/gpio.h>
* _; Z3 @, U5 e2 r! Y#include <linux/leds.h>; G" r$ l5 H# ^7 c
#include <linux/platform_device.h>
" M4 C' M9 t% F$ w5 A8 b1 H
0 G8 I0 b: w/ ^: A8 @7 X4 {, C#include <asm/mach-types.h>; O" X8 C7 j6 S0 @4 w% z
#include <asm/mach/arch.h>! b; w5 i! s! Y% d
#include <mach/da8xx.h>. ], }5 B) ^" M; y$ g( l& {0 A* L
#include <mach/mux.h>6 U5 F" z4 A' O$ I# d
7 T, Z0 H. ^! P3 Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ w8 u0 G( a3 F
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 f# o+ L/ m1 [9 k' ?1 s$ |+ B n
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" n. _3 j( c+ w: g#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) y+ x' ^! T9 }( g5 G5 v5 Z, C! s& ]- K# z, C% E! k
/* assign the tl som board LED-GPIOs*/" u$ ` i: C! Z9 X
static const short da850_evm_tl_user_led_pins[] = {
( @. j! s6 M/ G( F5 Z /* These pins are definition at <mach/mux.h> file */
3 A! c8 |2 ]8 Z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) p4 x( C9 L, B8 i
-13 U$ `; o6 T; R; d. t
};
1 n# v3 o8 h5 P* a n
5 J7 P' X5 K: O2 j7 i- _& Y: P1 K: Rstatic struct gpio_led da850_evm_tl_leds[] = {6 h+ P+ T% S3 l" h
{
' I* V# j; ?# |; t! B; b .active_low = 0," v' n4 f6 D' X' e+ t" K
.gpio = DA850_USER_LED0,
/ q& j" z2 }0 u8 ] .name = "user_led0", _/ e( E) `: Q W6 d$ |
.default_trigger = "default-on",8 Q/ L4 B# Q! n/ ]( P2 L
},9 h. q6 p& M5 D
{9 Y5 X; L0 Y5 m+ i% N
.active_low = 0,& t4 h5 }3 B4 b; G3 t; Y
.gpio = DA850_USER_LED1,7 _6 K2 R8 J" Q, `3 V
.name = "user_led1",) ?9 o4 w2 ^4 U2 b
.default_trigger = "default-on",
% h v5 R5 s7 L },
! z- ~$ V5 d# A4 P. D% E: B1 D {
+ S( R3 ^2 T; s3 T8 f: x7 ~ .active_low = 0,
4 F& X: Z; k# r% a8 E .gpio = DA850_USER_LED2,
0 V1 Y( |8 I; i% U5 p) r8 w .name = "user_led2",8 A% U# v! h. n
.default_trigger = "default-on",- V2 R }. Y2 T
},
/ _1 Y! y6 B6 w% w( l5 @- X {6 v" p) d O, O% g: N
.active_low = 0,
5 g v& H+ a. z t; V .gpio = DA850_USER_LED3,
3 l! p5 f8 |& T& ~ .name = "user_led3",
* b) A/ s. L, M9 ?" {4 _ .default_trigger = "default-on",6 y; A- j+ a1 L* Z; c/ F
}," k) V g( }. _4 C7 [1 V4 P
};
, s. Q# f! T/ P% s
+ R7 }+ M8 R; M7 h8 {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: m& D: [. b% u& i' f* x! M2 X
.leds = da850_evm_tl_leds,0 ^* Z) W* u9 l( @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, d3 i7 M g9 Q& B! B};: P; y n7 k3 N3 @/ e
7 ~ S. Y$ x% d
static void led_dev_release(struct device *dev)
6 d3 ]' f9 y+ q8 p, O{
/ [% o1 l( J3 v& t; r# J};6 J; ?1 z( H" @
7 e& L! O. C* h" v/ H/ z
static struct platform_device da850_evm_tl_leds_device = {9 O. ?8 v5 r. }& v1 y! |
.name = "leds-gpio",% @; Q: I* i2 e6 l. p4 N
.id = 1,6 O% K2 C" u$ b
.dev = {
% V/ p9 D. `: Y' P$ U, t$ x .platform_data = &da850_evm_tl_leds_pdata,
! t R1 O, e3 E" Z+ |) p$ h) q .release = led_dev_release,: b4 j# G( ?" S: R
}5 e5 X2 X2 p# r' R1 @8 k6 n2 t
};
# ~0 S' Y2 S( z" F' _
3 V* o7 m/ y6 b Ostatic int __init led_platform_init(void)# L9 _" ]/ r# v' I5 d9 B# ^
{" B& S; h6 ?1 E! o* N I
int ret;+ m/ `" g3 c0 d
#if 06 ~: i M9 N1 I1 i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 \9 U c/ l$ \# i
if (ret)4 W$ D+ J5 a: K& @
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. w( p) {3 Y0 f: j) q "%d\n", ret);, E' J$ }' o' B. f; v4 S
#endif
0 L) R+ Y0 v: _$ K6 G$ k1 U ret = platform_device_register(&da850_evm_tl_leds_device);
' K1 ?) g) s# w/ S% A) p# K if (ret)
0 \1 Q# d) m% r ]7 h pr_warning("Could not register som GPIO expander LEDS");
1 Y ~& t1 i6 u% E& c else
% r2 x; Z( h, E1 X4 K printk(KERN_INFO "LED register sucessful!\n");& b+ C( b( S* L
5 ^& W- i8 `3 R
return ret;1 B: u! Z H1 G
}4 P9 [5 ?% ~7 P# E
z# Q. b- \( F3 [" ]static void __exit led_platform_exit(void)7 }7 v; H' q1 }3 a% ^ T
{
( V- A, a* D; \6 R, u3 E* i! q platform_device_unregister(&da850_evm_tl_leds_device);; K2 {) C" a5 H$ L% z1 m
8 ~. u5 A* U% [ printk(KERN_INFO "LED unregister!\n");' q; L: D3 n- v0 e9 a( z
}
7 ?8 c6 n8 `5 E X5 m
/ e+ C! C) t0 J! M: n" xmodule_init(led_platform_init);
1 Z1 }% _; {0 v3 T# hmodule_exit(led_platform_exit);8 q, O! r% N9 U2 Q I9 A* I0 y
! r# H! S2 z. QMODULE_DESCRIPTION("Led platform driver");1 W# y; n9 M0 {
MODULE_AUTHOR("Tronlong");
! p4 \/ M5 ]9 _; _. r+ p( yMODULE_LICENSE("GPL");: R1 ?' W& ~* k' {+ Y1 o
5 u6 }! d! ~. f# J9 C1 o
|
|