|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 _6 r4 S$ m1 P- ]#include <linux/init.h>6 v) x. w; |: n3 X6 ?$ @
#include <linux/module.h>
2 I$ v. r, O% t* i#include <linux/kernel.h>
2 S0 ~/ s0 B0 K" _9 I" @4 i#include <linux/types.h>% {, l& g5 U8 @; [: J
#include <linux/gpio.h>
5 O* b% y, t3 m. f9 q#include <linux/leds.h>1 h- G, e: I$ z1 L
#include <linux/platform_device.h>
# X4 U: Y7 Y! p4 r Y$ Q8 `5 b6 {7 y/ z( p3 u" H6 N+ T
#include <asm/mach-types.h>3 k7 l1 j4 a0 g+ n$ a
#include <asm/mach/arch.h>
0 D+ q8 ]6 }* @2 B; S3 l#include <mach/da8xx.h>" u# X5 t, y4 F4 L
#include <mach/mux.h>
' K* F e' C& u5 R2 J7 q+ k; G/ b T# q; R4 ^2 H" ]
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 B6 _6 [' j9 f- [
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 g- [+ L3 x; a9 c( I2 X#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 w" {. y$ [5 \2 n$ ~2 O5 B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 y, }0 _7 l2 X& I* V. A
|8 u1 r$ M! r1 q, l3 r/ M
/* assign the tl som board LED-GPIOs*/ q, k u& b/ E3 E2 d
static const short da850_evm_tl_user_led_pins[] = {
) E$ h) q1 c1 P /* These pins are definition at <mach/mux.h> file */ j4 N3 W& A+ j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ J4 Z: K# r6 o3 G8 k0 _
-1
6 ^- Z! W+ R; ~& B3 u};: i6 U0 C h7 [* {
. k. b- ^$ p, B1 G' Jstatic struct gpio_led da850_evm_tl_leds[] = {
3 D( P9 v' j V% ] {
. A) \1 q, f' P) u, Z3 d' G3 D% U .active_low = 0,
( E% z& h$ y# R, h& j& u) S .gpio = DA850_USER_LED0,) Z9 b! M+ b5 L" k0 u, p" `
.name = "user_led0",( t, Z. j4 N' q* f
.default_trigger = "default-on",
1 X5 u* P# r0 q: E* [ },
; @* }' M3 w: H& d5 E+ r0 ?. m! J {
, y5 s3 L: d9 _$ H) J .active_low = 0,
, k- |( _) `; h3 j0 ~$ a/ U9 N .gpio = DA850_USER_LED1, b, t, \$ Q" c3 }' D
.name = "user_led1",
2 \% P, t; R( \2 w# c N1 j0 Q: S .default_trigger = "default-on",- x9 I6 W0 j7 P. d; N' T
},
5 e$ q2 j1 i" [ d d8 C {( c: Q1 P* D6 O$ a; m* t
.active_low = 0,
- T4 v. L$ u' J- ? .gpio = DA850_USER_LED2,
. S5 q+ j+ y2 q5 V# [: ^) R .name = "user_led2",3 Z+ M) Z C+ Q; @9 u# B
.default_trigger = "default-on",
5 h3 O% t8 r# l2 B2 X5 `) p9 V; \ },
6 ]* w4 I& }. K5 D# N6 i {* M% B( k+ q9 l& {* q
.active_low = 0,
( p9 ^) u) R% `) s0 I. z .gpio = DA850_USER_LED3,
5 u* [1 ~, _2 ^- h2 L8 \5 u .name = "user_led3",/ Y* D6 P% N2 o# o
.default_trigger = "default-on",
( G/ v; d' M+ \" \ },; P* ?6 T2 d/ H7 v0 f( \
};
5 r+ q6 j( Q! v, v
, m+ F7 J9 Y# x# d+ astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 Z/ j% f1 L, @: A .leds = da850_evm_tl_leds,; {* \' F& A6 g+ t8 g; s; C
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 U( A9 d. D! M& t$ H2 n1 O$ ? {/ \};
' p Q/ G+ a. u, q6 G) F! o
. M( |7 ^, b" pstatic void led_dev_release(struct device *dev)
% |. d+ Q% E" A; g{
' \8 H- \+ k7 Y" F};/ `9 m% D( P, a: V( v
4 N: g6 e) }7 \- S& L7 E' s& Jstatic struct platform_device da850_evm_tl_leds_device = {0 U U) ?$ C; v
.name = "leds-gpio",
" b0 l$ t! [) \# D .id = 1,
6 R2 T% d1 a3 t .dev = {0 _$ J) h, Z) h# X+ l
.platform_data = &da850_evm_tl_leds_pdata,
# Z' a) t ^, @4 L o! j/ P/ X" Q& ~: M2 [ .release = led_dev_release,0 \ n) l) G, i/ a/ H6 M
}
0 J z6 i- c7 [# O1 x% p};1 p$ H7 @, e) u8 [+ Y: X9 r" s6 G' \2 k
. Z, ]& X) Z; a2 e% w' kstatic int __init led_platform_init(void)
`+ d5 a! l5 [ {$ J1 E( @{
# d$ C N' Q. A# d, [+ ]& v int ret;
) @; l! z2 F" M8 X) M' b#if 0
- k/ [, s; ]' x# b/ m3 G% z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( m J3 ~, b4 f' G" i: q- L! a1 W if (ret)
* x: [' u6 I0 ?# r# l4 ~* q( `7 s3 B pr_warning("da850_evm_tl_leds_init : User LED mux failed :") k" s n( m% ?; }
"%d\n", ret);. l W0 \# `8 h4 O" d6 Y. B$ a% F
#endif9 a% }( G( w* `1 {: k' e' t
ret = platform_device_register(&da850_evm_tl_leds_device);" G' o3 S7 r! v! V
if (ret)
2 m! O: t5 |3 Z& a+ G( C pr_warning("Could not register som GPIO expander LEDS");2 }+ [' v l+ L- t. t
else" k- @' F( B, f; U) z7 `6 c
printk(KERN_INFO "LED register sucessful!\n");0 B8 P6 v, m& v
1 ~1 G: l/ b% o- O& g
return ret;- [; G* ]8 C, C% U3 K+ r; @
}1 I* D2 y. g7 b
% H+ N5 N1 H2 W9 |' N- Dstatic void __exit led_platform_exit(void)
5 _+ g, t2 G% @1 k{
* G+ ?4 e# {0 n1 |- X' x3 ?4 d platform_device_unregister(&da850_evm_tl_leds_device);1 { `1 U+ Q( o& D
% t" p) V3 s5 G5 C4 ?
printk(KERN_INFO "LED unregister!\n");" B# d: ]* o0 f) m6 l6 W0 ]: D
}1 [$ K4 @: R5 _- U3 \" [
( }: h0 z3 a# x4 K5 g: }module_init(led_platform_init);
, `) e. ?5 `: i# _; N; p. fmodule_exit(led_platform_exit);0 a0 [+ p8 H- j$ n1 z! _
: U, l1 a* \* UMODULE_DESCRIPTION("Led platform driver");
3 N$ O& b5 M A. jMODULE_AUTHOR("Tronlong");
5 t4 M9 B% s- P0 \MODULE_LICENSE("GPL");& H: k7 `8 {2 E4 b5 ~+ L
, y/ {/ f* s! N+ `. r
|
|