|
求大神给下面的程序做注解,请稍详细些,谢谢。
' ]* W% y* C6 _6 E8 e#include <linux/init.h>
8 p4 k+ U, P8 }: c6 M/ I#include <linux/module.h>
3 g6 x& Q$ _0 a- n; B. P0 O#include <linux/kernel.h>5 H) \5 i" k" h# r1 s2 W
#include <linux/types.h>
; ^1 T) G6 F( s s5 d! P- r#include <linux/gpio.h>
% x" y9 r4 t6 C; _$ j* b#include <linux/leds.h>1 ?3 _& T- ?5 |0 _5 s6 i
#include <linux/platform_device.h>
1 M4 y6 X$ g% o9 V# {% n
- g8 x* j! q- n) Y, G#include <asm/mach-types.h>
6 U% t# V7 @& i. T$ S#include <asm/mach/arch.h>7 p }4 L0 R) p7 F+ P$ g! ]/ b" r
#include <mach/da8xx.h>
( }3 I i8 j% n. D. W8 O#include <mach/mux.h>" }# R5 ^5 }- r8 k
6 x3 A& w; s% p* ?6 Y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' V) O8 X+ v" T8 z/ i% `) b" c7 n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 i* b6 J5 ]" [* \9 U% S) d- K" ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" f# [0 {5 `; W- C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 _7 G9 y. w4 Q6 R6 M- ~: o1 F7 k3 D2 o* p; Y
/* assign the tl som board LED-GPIOs*/
6 @+ N: a( k% V I& e$ R; u9 w2 \static const short da850_evm_tl_user_led_pins[] = { J. ?+ _% ?5 }* q5 M# d U ?' b0 ~
/* These pins are definition at <mach/mux.h> file */
) Y( A, Q9 q9 O DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 ]3 ~2 B- q7 I0 V' ], e. m4 |
-1
n8 d; s" b, Y) A};. D0 k5 }% w- f2 e
, \; f% h: ?& y) I) L$ sstatic struct gpio_led da850_evm_tl_leds[] = {6 \3 \0 V( J! R8 g* O- i2 [! e2 i
{! X) [( y1 n) ^2 f! B$ d1 s
.active_low = 0,* T4 e+ X( Q& w: H
.gpio = DA850_USER_LED0,
- F; ] G0 }3 z' @6 Z+ l- r8 z- F .name = "user_led0",
: v' g0 i% z& I .default_trigger = "default-on",
' W9 s# V k4 M- A$ v2 X v },
' r2 A) }; d% v {
+ O) L% y5 }+ l7 u0 M1 v .active_low = 0, g3 n8 b0 x$ }0 k @+ p$ _
.gpio = DA850_USER_LED1,
" q+ W9 g, z6 h( v .name = "user_led1",# m6 ^. U2 @/ ~3 N
.default_trigger = "default-on",
: F- c' O' q4 L% n7 V; Q },
8 N, p. M9 Z0 F: ?; D( }. y {
# n* x. K' P# `" _% x* r* [1 K9 Z .active_low = 0,1 d7 d7 m \3 A& Z+ K
.gpio = DA850_USER_LED2,; e9 Q0 f4 ^9 M
.name = "user_led2",
% u3 }- p$ x. {4 X! Z: U( _ .default_trigger = "default-on",% Y& Y( Z6 G1 t( [ K1 N
},
8 [& R+ `0 g) b' I {2 {. N' G: ]* |; I) E& J' U
.active_low = 0,# o/ K( ^4 N; k5 i c
.gpio = DA850_USER_LED3,# }, S! Y) o$ p( j7 y
.name = "user_led3",2 W6 I+ U/ e% M8 z' E+ M- ^
.default_trigger = "default-on",
6 |% Y: d5 H* }9 g3 F' D0 V$ l A },
( j; |+ U: g8 Y& h! g% Y$ z};
) g! \' g' u% V; ?( D" w/ V( D7 K; i2 p3 B; Y% S. U# T a+ \+ ?! y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* y I5 E0 N- i9 z4 F' y, B) A( M0 B
.leds = da850_evm_tl_leds,7 M' k/ X& [ D+ e7 r" l
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' z! F) T9 E2 E S3 i};0 R1 F& S7 ~ r" a0 T5 w+ {
! z5 i5 k% D8 F2 T; I. ?2 Nstatic void led_dev_release(struct device *dev)
, D* ?8 O6 D1 w{& h6 { k9 }5 f. S O
};8 U5 W& e( K) A# D: G% G
! o8 d. }& }+ C+ }' {static struct platform_device da850_evm_tl_leds_device = {8 u8 x" s( _; a2 K* \& l; z4 D. l
.name = "leds-gpio",
5 H3 G( ~$ y( _7 K3 _ j& ~ r .id = 1,4 A5 e! d3 a V- O, B+ b* ^
.dev = {# Q( H1 {& c4 C, Z/ V. V0 F
.platform_data = &da850_evm_tl_leds_pdata,
! t) W; @- v% z4 A1 f2 F .release = led_dev_release,8 c, z- X, O* J9 U( @
}
) y) o1 `6 f' S7 ~9 P* I};
* @$ N$ |1 f K& x
`7 n9 {$ J& x- J$ q& vstatic int __init led_platform_init(void)
2 Q; ~/ w* l4 ]* h! C{
: W1 a, D( M# @4 O2 v int ret;$ s, L8 g3 \7 h1 l3 j8 Z
#if 0; O2 J# @ N2 X0 H# {3 s% f
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 m) ~ q D X6 K; w: `3 W2 `* | if (ret)
9 \0 \' o& s0 r, B4 U/ w; _* n pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 W: s( Q8 P* a/ G5 u "%d\n", ret);
# C3 \. e# Y$ o3 A! n* W#endif
2 s3 _. j6 W2 C( T m7 Q ret = platform_device_register(&da850_evm_tl_leds_device);
" q7 h+ m* P# F% K if (ret). @3 y5 P3 g$ C( V6 ]
pr_warning("Could not register som GPIO expander LEDS");7 ^+ b2 K2 D! |8 ~ M
else
3 W* O0 m( m1 U2 J2 Q5 d printk(KERN_INFO "LED register sucessful!\n");
6 R. ~2 D4 U1 W- }+ k9 c! O. y6 x- v1 R
return ret;
: F, s0 f) j2 X. r}1 b' a& _9 B2 J9 \! Y" y
0 T/ n& P, [ X% } Ystatic void __exit led_platform_exit(void)
6 e5 ~5 N/ O: K- J, m& f: y$ K{$ h& a4 r& ~8 C# P" a
platform_device_unregister(&da850_evm_tl_leds_device);# `2 T# p' c5 f n+ }4 {
3 {5 `6 B, r4 y6 c0 F* j
printk(KERN_INFO "LED unregister!\n");6 m- Y0 l- w' r I( X, d# l
}4 q8 l/ H8 p, ~, z4 o1 g& u1 p
. I# ~1 A7 c! B. nmodule_init(led_platform_init);
' U' X9 B( `* D* `# @module_exit(led_platform_exit);
! K( l8 P6 ^% u9 ^, j# @7 W, t: N7 T, Y5 U; y! v# e
MODULE_DESCRIPTION("Led platform driver");5 ?: H" f0 \' z+ b; t) }
MODULE_AUTHOR("Tronlong");0 A" A; J9 g" C9 L8 K7 j2 u5 d
MODULE_LICENSE("GPL");' i& I, ~ |: _3 k
! I K5 _ D# u8 ]" t
|
|