|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; q+ G7 g$ L& Y5 _% H( ]+ y#include <linux/init.h>
) K6 c5 A7 g* l# g* E#include <linux/module.h># k% F; M3 m. B% e
#include <linux/kernel.h>
! [1 l: B# ?- u" a#include <linux/types.h>; g9 R r* K- Z- Z; M& q: S
#include <linux/gpio.h>2 k, g: H/ d. `1 Q6 {1 T
#include <linux/leds.h>9 ^ _5 z& ^# r. q6 z% F
#include <linux/platform_device.h>
) l# G+ A2 L- }. U5 m% P* [ g7 N6 I: W2 e- s) N
#include <asm/mach-types.h>
) f) a7 C* p0 t" M& J+ |# X#include <asm/mach/arch.h> ~3 L9 `+ L# ]
#include <mach/da8xx.h>$ Y' a3 H6 ~; X( u+ \( ~
#include <mach/mux.h>6 s4 F0 G0 q/ R% Q
4 ]: v$ { w* V9 [& t
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" p& P0 z; I* Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ ]% w# D/ Y) ^ t4 ]4 u
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 ?3 A R/ p/ e
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 m# H+ I# T' t" i7 g) p# ?
6 F7 X& U+ i% f& t8 C
/* assign the tl som board LED-GPIOs*/
3 |6 h4 A4 @0 a* |static const short da850_evm_tl_user_led_pins[] = {
7 u: a9 r- F$ l& r' p% Z /* These pins are definition at <mach/mux.h> file */
' o4 V) r. h3 c DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 h8 f" O3 e( Q: p' g$ ? -11 P( ?3 \# u2 c; l# |
};
3 G. N. ]2 ?: \5 p: _$ E
& l+ a9 |# z, \static struct gpio_led da850_evm_tl_leds[] = {
! i! M& ?7 ]* L4 Y {! g! A7 ]* ^2 `0 Z" V- {" g8 f3 W. _
.active_low = 0,
9 P' r A+ z/ ^ q8 K7 @( v$ ^ .gpio = DA850_USER_LED0,
2 A8 Y* s7 a) x* Z0 s7 Q: j .name = "user_led0",
% P/ S) F# q1 L2 r( i _. O/ C .default_trigger = "default-on",
0 h# \5 k" e B8 ~9 A8 X9 F1 n },1 a9 `/ ?& D5 Y \6 @/ j
{# y) Y5 R% N" H* K
.active_low = 0,# x" b' L: O5 `* y* ^
.gpio = DA850_USER_LED1,. S: A" D% }1 H7 [/ u" B
.name = "user_led1",
' b% U5 [5 D1 z* p/ A .default_trigger = "default-on",8 G4 J- }5 T3 u; d H c+ [
},
Q8 [- [; G" j( d+ }, |+ K0 ~ {" z2 F* H7 u& y5 R: S
.active_low = 0,, t9 }5 B! j, J
.gpio = DA850_USER_LED2,* A R7 N; P% B# J: e/ N
.name = "user_led2",5 z n0 d; P8 r$ {( v" C+ h% \
.default_trigger = "default-on",
. @* u0 h0 e) u( Z+ k- h1 z },
/ r! W7 M- Q! R0 T9 o+ Y. ]) C {
a3 V7 X4 S; f3 L+ ^0 j .active_low = 0,0 S" G6 U1 Y9 E5 e
.gpio = DA850_USER_LED3,
9 P; {$ A# R9 k4 g .name = "user_led3",+ q7 y# p5 G _3 V$ i& W; k9 b
.default_trigger = "default-on",6 M1 f! A! p! R, P
},
. r$ p. {2 @+ H5 K9 H* x* G};0 L8 r% ?9 z, P4 Z3 Q& P
/ b3 P9 W9 N. O$ D5 ^( j' w0 u/ s
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ M& s+ h( O* A" m .leds = da850_evm_tl_leds,
: n$ V: s& T0 E5 { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 e: M, i* q# d
};
3 x, L4 }7 u8 I) e; X; Z5 i4 R% u$ c' |- \! i2 Q0 c W: S8 R3 y3 g
static void led_dev_release(struct device *dev)6 e- t8 o" C6 `) G) e* D
{
2 ~' _) u6 ~/ u3 q# y* A6 [( ]};
3 }" j- w) V8 ?# ?8 p* o* B |
2 o7 C) M6 g; sstatic struct platform_device da850_evm_tl_leds_device = {
; A8 Z; C# [8 N) D7 F .name = "leds-gpio",
0 q* L, V8 c/ ~' {% K .id = 1,
; w6 G a5 P8 \5 ], a, y) j .dev = {; X/ ^! R' z, w
.platform_data = &da850_evm_tl_leds_pdata,
) y" B: U) t; s .release = led_dev_release,( }+ V0 k2 [; H4 {/ J' t
}
k- B. r, @7 u$ E};" l. {* H( d* U0 u5 A- ~) A3 T) y; P
5 k& L" m: r7 S& Cstatic int __init led_platform_init(void)
3 I) y# G, s5 }/ t6 S. C{+ j3 X% H6 s+ z }0 Z' R
int ret;( \3 W. u( J1 `3 a7 l B9 g1 S
#if 0
. S* f0 M; n, r V+ l" D2 g( j ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) i. K! k/ T0 F7 N if (ret)
; e5 |+ v6 f- g* | pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ B; `9 M7 U2 s2 E! F& j0 v6 L
"%d\n", ret);0 ~8 O- v' I, _, Y& O
#endif
* }. b& @) B0 o' q ret = platform_device_register(&da850_evm_tl_leds_device);4 F# i& s/ ~: a5 q8 @8 r
if (ret)
3 c# _0 P' q0 y pr_warning("Could not register som GPIO expander LEDS");
a- R( s h, ^# W; y6 H& T! I else R0 x1 G2 d0 ^5 U A* l5 M- F' u
printk(KERN_INFO "LED register sucessful!\n");9 { \; H4 P$ M
* J0 e% A' h7 d
return ret;
$ P( O; B) H- x8 ?+ `: F) @}
7 B- v! ?8 F7 o" k% e( H! c
( Q8 J+ f" ?, T( G1 _ Estatic void __exit led_platform_exit(void)
2 n& n2 @8 a# t% m7 d/ B2 S; @$ f{
' I% J5 I; J5 l; ]+ x0 T* c: Z L platform_device_unregister(&da850_evm_tl_leds_device);3 k U1 ?: u4 w) {) |) n' ? ~( S
7 c( J4 q2 Y# A+ m) J( m4 X B
printk(KERN_INFO "LED unregister!\n");
) [5 [7 W& M l( G( K- O: a) [}) ]- j# p* |) W7 b# Z3 m
( Z& w3 k8 j' T0 l$ J1 B! i
module_init(led_platform_init);0 Q4 X4 W6 e0 i0 q* P; _9 t5 S) u
module_exit(led_platform_exit);- f; d5 O* \2 V6 X& V
) B# Z% e' e- E" A
MODULE_DESCRIPTION("Led platform driver");6 w' C# {9 p n
MODULE_AUTHOR("Tronlong");
" n) i. D* L7 t% W& \/ u3 |% [MODULE_LICENSE("GPL");
; ~5 q0 @% A m3 t. B4 |* q# E$ P" G
- H4 |4 ^) z$ S" I |
|