|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 J7 H6 m M" j7 ^
#include <linux/init.h>
% H: ^ s2 f( f9 W+ N3 H#include <linux/module.h>8 I+ `2 B8 D% r8 u9 ^
#include <linux/kernel.h>/ a' l( ]% r4 {
#include <linux/types.h>
! {8 ]9 o; F! u#include <linux/gpio.h>) {" b/ v! j |$ {1 L
#include <linux/leds.h>, t7 N% |5 {* q; \
#include <linux/platform_device.h>+ a: T9 b" ~& @ f% L6 @& |
/ x" K5 h$ p8 t5 R' [2 n
#include <asm/mach-types.h>9 ?+ b2 A$ F1 I! o# \. l
#include <asm/mach/arch.h>
5 R! T7 ?' O V9 T: D#include <mach/da8xx.h>3 V+ a3 ^3 H' E) t& V
#include <mach/mux.h>
; q# |% J8 w b) x
+ H+ u8 e" L$ L* ?#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 j- M* w0 h6 w5 e3 P$ P#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# Y: T/ I5 O% z* Q( K#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
V: n+ _9 z( L' `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 t l6 X& S0 a* f1 e
7 { B" ^3 r8 H- t/* assign the tl som board LED-GPIOs*/
" S% e; { T, p @1 R7 Tstatic const short da850_evm_tl_user_led_pins[] = {
4 u x X3 S& K. ^ C /* These pins are definition at <mach/mux.h> file */% s% b( I5 C& H, M/ J
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' l z# i% X( u- ~ -1
2 O2 {$ h2 X& A2 |) Z9 x};; e y/ |5 @8 Q4 O J, }: E2 f
" q, C8 o2 N- w* @$ h9 A3 Mstatic struct gpio_led da850_evm_tl_leds[] = {
* G: R: \; h% a! |( | {
" |/ ~2 P% ]- @ ~ .active_low = 0,
! R' x' ^: l+ c# E3 {0 f .gpio = DA850_USER_LED0,5 k# q: a4 W2 g6 T9 m& m8 x3 q
.name = "user_led0",) a. ~2 j* q9 {, }; A
.default_trigger = "default-on",: H9 ^3 m8 B. k8 A+ e6 ^
},6 F) l! p' f9 x4 p$ d7 A) H1 S8 D
{
/ n% ^& b7 ^7 V3 H0 u. ` .active_low = 0,
$ p: W: Z: n6 w1 o$ d) J .gpio = DA850_USER_LED1,
2 ~' |, x7 |2 j, v: g, Z .name = "user_led1",
1 i0 q$ Y& h+ z* I; j% H .default_trigger = "default-on",
3 P; e' q6 |( _1 W2 c },
- o4 o5 H* x- z" ?5 T5 E {, P% r. d6 l6 q' o; h: h
.active_low = 0,
7 ^/ s9 }$ |9 N' z .gpio = DA850_USER_LED2,
) R6 Y6 n* L$ g" H. y% g/ g .name = "user_led2",5 @# P$ U+ @) J, A0 n
.default_trigger = "default-on",( X* `1 K- y* ?7 s
},7 `) _7 U8 z9 M/ z1 w- ^6 |
{
; R8 k& O D L .active_low = 0,
7 l* y+ X2 y* P. O ?' s .gpio = DA850_USER_LED3,
/ u- R6 j# I5 `' ?1 R1 z( C& {7 Z .name = "user_led3",3 V' M5 e1 d; A' n
.default_trigger = "default-on",1 P' @9 F- O; @5 q$ W1 b' }
},
\8 h$ G# k* z$ c};
- ?% |' w& k9 G+ {9 y
% l" Q V* n2 o ?7 rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* R p8 e/ M, @$ J7 n0 M
.leds = da850_evm_tl_leds,
/ m$ {0 V) M6 L7 h( I& t7 N# y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% q9 [* d; W$ {) N% B};' s& @9 g$ Q, j, E8 s9 ^
1 A: x5 M& m$ l
static void led_dev_release(struct device *dev)8 N( h; E+ B4 t- h/ T# y5 ]
{
' V9 g+ d6 W& X. Q X};: ?+ I! k. ]7 `( o
1 N: V# Y. S5 p0 i2 bstatic struct platform_device da850_evm_tl_leds_device = {
! O' [9 M4 d z- s .name = "leds-gpio",3 W& s; [) T% E
.id = 1,
/ B/ w2 T" r9 w0 `; O; O7 ]& N- o .dev = {
. }3 ~ @+ H4 F# v& I" @ .platform_data = &da850_evm_tl_leds_pdata,
# L/ C; A$ i5 f# ^7 p' d .release = led_dev_release,/ {) u4 @& H' c- ]
}1 M2 C/ V+ I- P
};' a& [( i$ j' p, G
2 t9 N% e4 q" q' Y, ?. L- {
static int __init led_platform_init(void) M" i; y6 U( Y S4 [
{2 {/ Q3 S6 b# h
int ret;
( B5 t; t! k3 A' @. X/ ]5 i#if 02 N% @2 G) C, F, A( t* I& }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 Y0 t$ |/ G8 J f
if (ret) @5 o6 Q/ F% K
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: v; r* o& a& i* u: g "%d\n", ret);
! A/ N/ P. ]- N9 N#endif
( i. ~- `% |4 }' B. ` ret = platform_device_register(&da850_evm_tl_leds_device);& {( v# X2 q0 r/ o& d% N6 m
if (ret)
/ P* Q+ e b7 I' Y pr_warning("Could not register som GPIO expander LEDS");
3 ^& H' u5 R0 D( H0 k" G else
9 E; C9 X9 \! Q# q& X1 v6 V printk(KERN_INFO "LED register sucessful!\n");
2 I. {1 o: u- f5 w- h, u9 _# Y8 W* V- r. X: c& n
return ret;3 s' I! v6 Y: {- M
}) r3 |' v, K L- f* f& B# i2 K/ F
# H# a) h5 _+ E6 o
static void __exit led_platform_exit(void)
# K' H: k: q: C' w+ S{: Y4 d* a" A3 f9 {, ~' Y+ z) W
platform_device_unregister(&da850_evm_tl_leds_device);/ L- u' T9 e( U; b. u9 n
) l, G2 o9 [5 q; l, i( |4 m printk(KERN_INFO "LED unregister!\n");+ j. l1 h) {* L. L
}
3 E7 y j$ [' K1 {, O) d& g; ]! E# r6 c- \. c3 S
module_init(led_platform_init);
) E1 k. I3 P$ Ymodule_exit(led_platform_exit);
`" l( H* o* ^" q, d0 U
4 J) v) t( d4 ^MODULE_DESCRIPTION("Led platform driver");% ?& I$ {- c4 r4 q8 }
MODULE_AUTHOR("Tronlong"); p9 x2 L) _& I7 p j9 q
MODULE_LICENSE("GPL");
% u6 ?- @: e% J7 N& l9 O [5 W- E+ y5 S; X% m9 T# V. ?9 |
|
|