|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* x) Z K7 ~& j, E$ K4 v% c#include <linux/init.h>
% }; |* h# Q: r4 o#include <linux/module.h>
a* ]$ E" |3 i. q8 z9 B l#include <linux/kernel.h>
& Y; ~$ M$ j: D/ _0 m#include <linux/types.h>0 f) Z$ `2 c- l/ T) D0 }3 m
#include <linux/gpio.h>( k7 S; ]( C, a; h
#include <linux/leds.h>
X& J6 a% Y5 q" A0 |3 z! H#include <linux/platform_device.h>
, m! ?. N0 w; i* n# v, t2 k) ] I2 J c9 u1 A, X1 Y
#include <asm/mach-types.h>% `: Q/ E4 C5 X2 g8 u9 o; w; m$ E
#include <asm/mach/arch.h>* {3 a' X: I+ ^5 d4 q6 K. X }
#include <mach/da8xx.h>7 i7 k2 H) k k' ^8 f, [3 N0 {( u
#include <mach/mux.h>
( S* K1 j0 c6 ^8 p, n3 a4 N
7 B. V+ S. \% r. M; ^) O* G' E#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ J" L( a* z+ o; D+ u" q4 p6 ]7 B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' ~! A ~- e+ C8 b3 f# Y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 M' w1 N$ s" O3 {) |9 u- q8 J( P2 N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) W4 h9 G' S9 w: V5 C3 o' y& |; \4 A- h: Z4 | }& }' L
/* assign the tl som board LED-GPIOs*/% H. j6 g/ G+ d9 M! Y
static const short da850_evm_tl_user_led_pins[] = {
' {8 o$ P- |7 B1 n: H1 H( R /* These pins are definition at <mach/mux.h> file */
' ^" y0 P2 l# ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 W# x. D4 ~/ a0 s& S -1( ^5 z1 V8 c, H
};" ?+ O2 \+ l j$ ^8 [" ?% z
' T! J5 U5 \& |" h! @static struct gpio_led da850_evm_tl_leds[] = {
+ B* X. k5 {% H" _# s" a+ J& k {
7 L2 _( B; m9 A a- C$ v .active_low = 0,. L3 r& i' {# M$ N" Q
.gpio = DA850_USER_LED0,( A) j L0 e! s
.name = "user_led0",! I* j4 P5 v% Q2 U: U; x
.default_trigger = "default-on",; u0 o. o; q# m
}, q& A3 ]# D3 t; y2 w. a, O
{: m8 y; k( B; Y# }
.active_low = 0,
9 \9 E4 [6 ] m! V$ |- ` .gpio = DA850_USER_LED1,
+ `, R5 l# b% ?+ r' h9 v .name = "user_led1",; F; j! p* \0 n3 C) c f; e! e7 l
.default_trigger = "default-on",: i& g/ ~8 t o# ^
},
* j" ~2 D2 B! o+ z B: |" t {5 S; ^! B+ X* f* x- n
.active_low = 0,
, g$ D' x6 w. U9 C8 w8 w! q .gpio = DA850_USER_LED2,# ?$ {" `$ o' _7 D$ ^* R9 n/ |
.name = "user_led2",
" X) {# D/ |- i* L) e8 p .default_trigger = "default-on",6 o. J. K& x3 S6 p) v
},( w8 ~: D: D* L' \, \# H- T8 v
{( t' \8 \4 ~) {" j6 H1 r3 a% w
.active_low = 0,
0 P' u3 B X# l .gpio = DA850_USER_LED3,
+ Z. C, u9 e7 }) x/ u A$ N .name = "user_led3",# G. Y! W/ e$ n d7 M6 u
.default_trigger = "default-on",
, Z: \8 Y& ~$ L' C+ t6 m },) V6 r$ c2 U- E% V C2 }4 f6 F5 t% k( O
};
; b2 X p$ N5 `& P2 j6 ~0 B7 l- W6 L: G6 i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: K1 P: w8 T$ I% c# k+ X
.leds = da850_evm_tl_leds,
9 s" f& K! c1 |# n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& ?! }; l) D$ o* ]+ t
};# Q' S' X/ E/ U. n% ^: x
8 U: W' _& d* `
static void led_dev_release(struct device *dev)
8 [+ j3 m6 g+ a" g9 E6 f. V; B{) v2 T k8 ?4 k) i
};) Y8 g" A! D1 U3 d* z. \* C* F
/ Z8 i# u# i; R/ M6 Q4 [static struct platform_device da850_evm_tl_leds_device = {
7 y! j6 M6 P+ u1 q& C .name = "leds-gpio",
/ `: D; b& p ^( I. M% W .id = 1,
7 q: d! k0 X! F" i- b4 i5 r7 b .dev = {
$ [. l1 Y" u1 l' k& b .platform_data = &da850_evm_tl_leds_pdata,
' M2 j; e7 X! x+ `3 X .release = led_dev_release,
2 A0 t/ ?4 d; f2 K6 y) x) C }
) i; P9 P8 H1 J# k7 F; W};
1 [; d' V/ ^: ~, |' h" X( r7 V9 z/ ?% X# n$ M( | g5 O* m& ?
static int __init led_platform_init(void), y L9 P' l, T1 e" ]4 x: A8 E6 N
{- o* V& U0 q% V! {) J: X' u
int ret;
- U& S0 }4 g; |" B- c& ~" j#if 09 S! d/ _/ }; P. A( ?& }( g0 ?
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ v$ s/ ~) b6 m9 Y
if (ret)
+ S- T8 |" {1 u1 z/ s pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 V% t( l8 A5 r "%d\n", ret);, C. n+ m8 Y* f! B) [8 _$ c
#endif( n; J' p/ R! x" o4 a
ret = platform_device_register(&da850_evm_tl_leds_device);& W: v V' ? `0 h9 \
if (ret)
) B( K3 r, d) B' B pr_warning("Could not register som GPIO expander LEDS");
4 x' g* N) E& a/ v: P4 ^- z else# E) b; @2 f2 p! Z; ]
printk(KERN_INFO "LED register sucessful!\n");) n/ a0 m7 O# F" I5 C
# O4 h, ^0 j* i3 n3 g
return ret;
, P$ `# X+ k+ Y/ ]! D}
8 s% }. F/ ^1 {& R% w3 D" z" f0 ?, ?$ A' I; W6 |
static void __exit led_platform_exit(void)
3 r0 Y! }, ~: m{6 z% i$ c$ ~1 ?# y9 H
platform_device_unregister(&da850_evm_tl_leds_device);. M8 H! Q) j2 o+ w. T
# l- N9 I4 z; U9 V" G printk(KERN_INFO "LED unregister!\n");$ T" t& o- Y* ~+ ^- I; f A
}
) ]3 u6 q- w4 k6 W& e" J% g
; k' s1 W% U5 Z6 B: {module_init(led_platform_init);
4 b% x$ D9 r l3 ymodule_exit(led_platform_exit);+ R4 B. T' y3 g/ F4 ?4 L+ A
) s) s0 Y, |# [% p* R+ P
MODULE_DESCRIPTION("Led platform driver");) ~+ d) M3 w( Z, M
MODULE_AUTHOR("Tronlong");
. | X _' z n, J; e& u' P) d& y- eMODULE_LICENSE("GPL");- }8 E* b. B9 j/ Q1 T* v( W
' c3 K3 g, }! D/ Z$ |* z |
|