|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
9 F) d8 T8 N. Q" P0 H4 F3 a#include <linux/init.h>
) ]- f0 @' X$ g) b) B' ?$ j P#include <linux/module.h>
. f2 a9 f" {: x6 o#include <linux/kernel.h>2 f* V* n V5 C
#include <linux/types.h>
' d* p1 _( d2 K$ P#include <linux/gpio.h>
3 t; E+ q' C, j+ K( d#include <linux/leds.h>
) m8 h$ t, C: ?3 l1 b0 |- p, h. h#include <linux/platform_device.h>
' N6 W c4 t0 E6 @; f: }7 k( f( D4 p4 x2 q; t4 u
#include <asm/mach-types.h>2 ^2 k, u* b* V/ T6 \
#include <asm/mach/arch.h>8 C% X2 k0 u. l
#include <mach/da8xx.h>5 i, k; ?2 W. N- }" n ?
#include <mach/mux.h>
" |7 u# U9 ?) e3 R b5 M* \ ^( r# f; x( ?% s" N' U
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 e K3 l/ C0 W$ r) K! H+ P0 x#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 o6 X; g+ b1 I, J/ T; o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) S" Q# w: ^7 I* q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 {5 X+ P4 B) x2 g: B* U+ G$ z! ^, e( o2 ]4 Q% ] L
/* assign the tl som board LED-GPIOs*/, w3 E0 I; B) y
static const short da850_evm_tl_user_led_pins[] = {3 T, [5 I; V9 ?( s
/* These pins are definition at <mach/mux.h> file */
# O8 ]( O L0 K% y) Z. _7 H DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% ~' Z/ o! i0 f$ I2 l: l F* a a8 U, t
-1+ F. y) `. m6 @/ a+ a
};
) U* A# }+ C9 D+ @; X
3 B Z: K7 R8 xstatic struct gpio_led da850_evm_tl_leds[] = {" L% z: p; J- S$ d4 k5 w4 A. C6 ~
{$ X* ~6 k" i8 s+ W5 [# _
.active_low = 0,
" t5 z5 A5 C8 H" P; W6 O$ T .gpio = DA850_USER_LED0,8 y% a/ J# E ?" y% Q _; m
.name = "user_led0",' e4 H, G1 U$ d- U2 K
.default_trigger = "default-on", N" @2 t% C% z
},
+ }; [' v' s$ g9 J) n, D {
& C8 r4 Y2 W2 _2 P ~ Q2 S# A .active_low = 0,
& n# j8 L4 T5 y5 K/ Q) A .gpio = DA850_USER_LED1,3 y& e. g6 t5 @) f
.name = "user_led1",
5 H1 {# E& m9 ]6 P* ` B" X .default_trigger = "default-on",
5 q6 z8 v5 { j. i: @5 w# }& G },8 ~0 j( m- [8 k, [8 t
{7 z9 H* g3 C9 n( S+ D, E& t
.active_low = 0,6 h+ [# d, j8 |1 c9 d3 _8 v
.gpio = DA850_USER_LED2,
4 a! c! _4 m* K. p; |3 E" N .name = "user_led2",
! Y. M4 X, h R, M) x+ }3 o .default_trigger = "default-on",
- Y5 V7 K2 P: ^( z/ M! ^5 k },
0 C0 Q9 w+ l; A( G) E6 v {
8 A8 P: t. B, c8 ` q( @ .active_low = 0,
# f7 o6 P+ r6 R+ X .gpio = DA850_USER_LED3,
% F* D9 c4 F4 u# W2 j& u .name = "user_led3",
, P. I1 e& T J: A0 i .default_trigger = "default-on",
) l1 y1 E5 p, Z8 b! W& N; O/ z# H: ~' D },
) e1 g! d: k2 g. v; E};
2 p/ w: S: \3 p4 O# e9 V: z3 a
: J+ ?/ {* D9 H% k7 C' g! x5 Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" d4 d3 I) X) Q5 c/ G .leds = da850_evm_tl_leds,
) [! R5 \+ N1 K* y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( `" `1 B9 W' `" Y1 t) l* `# S$ q}; M- @5 ^; C) g) G
9 y- F1 C' t- }! }% mstatic void led_dev_release(struct device *dev)/ l, R' N- S% k1 j2 [ u# k5 h
{, f- N1 u, a1 f! V5 c
};) V' K+ W0 r4 T
, {! B0 @4 G d5 g. Y
static struct platform_device da850_evm_tl_leds_device = {5 ~, U4 X4 c0 U/ y7 R# K0 X+ p
.name = "leds-gpio",$ C1 h' B+ Q$ N: [
.id = 1,; h3 n G) e. w* p
.dev = {
I# J. ]- d- L$ k" y% Y .platform_data = &da850_evm_tl_leds_pdata,3 R; q* b# r/ \, E3 \
.release = led_dev_release,
. T/ I9 ^" ~* F: ^8 i. E }& S! W0 X! S6 g* N% `5 K
};8 V8 w' {& m& ^
. U5 Q: b6 w5 a, S! [ Q( T) ystatic int __init led_platform_init(void)
9 M; p' {; C6 g0 r{3 W/ K" D8 C: o
int ret;" p8 j; l, Z- x b; C/ B8 ]
#if 04 M C5 a$ F/ K6 i5 R
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 F' \9 H, z/ N& X0 Y6 }& m if (ret)
6 ]% F% V* x1 t2 q B- a6 v pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 d2 r; W Z" j* L& Y& P H "%d\n", ret);
- A8 z2 H) C8 C3 u8 f. C, P5 l2 Z#endif
5 {7 ~5 Q" m. u0 W9 [7 I ret = platform_device_register(&da850_evm_tl_leds_device);
) S9 m3 O; _/ A( P6 D if (ret)
; S4 h: `, z( s9 C0 i9 `; e pr_warning("Could not register som GPIO expander LEDS");7 a& G. a" ]7 c# Q1 U; ]" l
else6 L& j$ g9 q( E/ x- J
printk(KERN_INFO "LED register sucessful!\n");1 Y# v& v! `* d5 m5 A3 R
& J8 _/ b: ]" M8 e; t
return ret;/ U, g* R# \+ k2 T- m
}/ u9 ?* v7 x% N! @" W* S4 q
1 H3 r3 M1 V9 m4 p' D" _7 {
static void __exit led_platform_exit(void)$ q5 G- _$ g d2 k& e
{
4 s8 T) x. _! f7 j' {$ [ platform_device_unregister(&da850_evm_tl_leds_device);
; [$ J7 B- e. H+ W* l* R u5 H+ a5 w9 i$ t
printk(KERN_INFO "LED unregister!\n");
' T& J) W* Z$ U* z; S}
% E1 ~% z9 Y6 ^4 l* B2 ~8 `3 i" ]7 w. `; {1 h
module_init(led_platform_init);
$ r& h2 Z3 I! l* dmodule_exit(led_platform_exit);: J7 g, P' R6 n3 P. I
5 ~+ R5 `/ t! j% X
MODULE_DESCRIPTION("Led platform driver");* f, |' x" |" R. U. @7 `
MODULE_AUTHOR("Tronlong");
4 w& |3 g( x' _5 QMODULE_LICENSE("GPL");
+ |4 _% A4 y2 m9 f6 i" M; W8 v: C. I+ n2 T( r' M
|
|