|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 v. Z" v0 `% h8 b$ @
#include <linux/init.h>, r$ C7 V# x! y; B9 {3 Q
#include <linux/module.h>- }- i- V% n4 c% {- {3 k
#include <linux/kernel.h>7 S! Y1 G6 K3 x2 B
#include <linux/types.h>0 L& v" z) W* J/ m, J! h+ J
#include <linux/gpio.h>
! B7 D2 K+ t- C; @( E8 ~/ A#include <linux/leds.h>: x5 x# K" R- F7 {( F6 Q
#include <linux/platform_device.h>
8 e7 j2 t& [ j. K7 y9 y! ^; v* ?9 z
#include <asm/mach-types.h>4 Z4 Y& Q4 k6 B$ I( T
#include <asm/mach/arch.h>) e6 w1 k" }, z; N' ?
#include <mach/da8xx.h>+ Y5 U. r" h- `# D
#include <mach/mux.h>1 Y: n" A5 | Q2 o$ @1 N3 U) n3 d j
3 c8 ]2 a1 B) @# L5 r9 ]" x. t
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! O O7 R6 u' z& y! w. u
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 s5 U- b0 s0 E' s7 \) i0 c#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, Y3 p9 C6 Y. q; g0 X" o8 r1 L% B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ E8 p; y% C) v) t
2 q" }* L) ^6 ~) w: }* R/* assign the tl som board LED-GPIOs*/
: z1 h* M# a v' i$ Gstatic const short da850_evm_tl_user_led_pins[] = { Y+ E! K0 s6 H8 S
/* These pins are definition at <mach/mux.h> file *// ]+ O* M$ v2 m& {7 j% `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% s4 W0 T9 u2 J9 p
-1
. I9 [1 q# k& ?. R8 T1 b};
0 d! H; S; [7 t: r& H, Y* [& f. U$ p
static struct gpio_led da850_evm_tl_leds[] = {
2 ~- [8 g/ F2 \2 p. E* \7 h7 Q {
$ U* x: n) D# p9 }5 j .active_low = 0,$ @, a) _: c' i4 l% I* T1 T
.gpio = DA850_USER_LED0,
' M6 b. F1 v$ F2 D8 w- o8 w .name = "user_led0",
$ }! |* _8 Q4 F+ f .default_trigger = "default-on",# ]' w% M. ]' z( p& Y
},: \. t, s; G: q0 V& O1 u4 H L% X
{
- O- Q# ^% y" c$ z" w! | .active_low = 0,; y+ j; z0 o# H0 }7 A5 B( d
.gpio = DA850_USER_LED1,* x8 m3 e( }: |9 b7 w3 G2 E4 C p
.name = "user_led1",
" l p$ I2 i. N, f) ~ .default_trigger = "default-on",
* ]7 m _2 t" L3 E" } },
8 A) S9 u' B! `8 l" ]# Y {
' B8 a% x: B5 l. c! S .active_low = 0,
; \7 _, O" }5 m5 |/ t .gpio = DA850_USER_LED2,4 g! \4 H6 V5 N6 H
.name = "user_led2",1 y! P# ^* K2 W, S- r
.default_trigger = "default-on",* o+ `' ]% ^+ B& z; x
},
R1 K& x& H! ?; i {
* B, V4 u. J5 X1 u. d0 R5 [ .active_low = 0,
" I8 c7 J, }2 f" [' o, L0 a .gpio = DA850_USER_LED3,
( U5 _) q1 Y% C$ K .name = "user_led3",
. B+ X% g9 j+ E1 n- z .default_trigger = "default-on",
! R) [2 N, X! E& n+ N( C: ^+ o },) l4 a# L: g3 H( p' x0 G3 A5 W' p
};
7 m) Y) @5 U+ N: D
3 }6 n' I8 s* F0 W$ gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 z4 h, S- ~/ C: X: ]: y
.leds = da850_evm_tl_leds,
$ ]1 c* N1 G% A .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ t6 V7 \$ j# C: s5 q( r' w};
* T( y$ S8 F$ F- m4 C. s/ a* y, r3 f7 ?1 `! I( I
static void led_dev_release(struct device *dev)
0 n7 o, E7 f- ]4 i; [" s$ v{1 N: { R, V( x( O9 w6 ^( C7 H
};
4 g6 r) Z- i2 @! X. a
- n z7 G' {" _( r: g: estatic struct platform_device da850_evm_tl_leds_device = {
. X p4 G' P$ u .name = "leds-gpio",) I% l2 i) M. A2 E. ]9 x8 J5 ?
.id = 1,
' h* d4 o$ ~5 ]4 p6 F \ .dev = {8 P8 o9 ?. x( A( D
.platform_data = &da850_evm_tl_leds_pdata,( H5 i: v0 V/ ?5 G7 L! k
.release = led_dev_release,- I8 m/ x4 I8 ]8 \5 q+ L1 K
}7 A* w3 |+ b' |5 ?
};
9 N8 m3 I5 q1 Y5 z t! C- z8 {/ ]& w7 T2 j3 |) O3 [7 j0 _$ ?/ l0 r
static int __init led_platform_init(void)1 V/ R6 T2 x, u
{' v6 n3 B' p4 C+ @) W! ?: A
int ret;. V) d) }! f8 s% ~: y
#if 08 u6 b; D4 p2 I7 T M
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' q& M! X- @2 v" Y5 Z( e if (ret)' m8 A" ]/ U; r! D
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 t. w6 p: h; @$ U, e3 \! E3 Q "%d\n", ret);7 d4 |8 {4 J. `7 N4 U" u
#endif
& U% X* \5 V1 }8 y! ]8 W/ S _* d ret = platform_device_register(&da850_evm_tl_leds_device);- f- R/ E+ ` L% K( Y/ L9 ^( `8 F
if (ret)
; _0 s* ~% U: c5 G5 o- ~# @ pr_warning("Could not register som GPIO expander LEDS");& G0 v0 t! A3 {; ?
else
& |' @0 V+ H! b/ J printk(KERN_INFO "LED register sucessful!\n");" Z; c/ z, e1 }* ?; K
0 l( y) X! q! q3 |% L6 _- f return ret;" z9 U6 ~& O2 R3 A0 Y$ N
}
+ a5 h2 M* C4 ]% R
/ |9 t: ~. }1 O( estatic void __exit led_platform_exit(void)
; G/ N) |9 b/ G9 A{
z' P: O. j9 y4 i6 g# d' s platform_device_unregister(&da850_evm_tl_leds_device);. ~4 Z2 K7 Q( ~5 W7 \+ j9 }! S
, c- G+ a% Z1 D# B) v) ?- m8 V
printk(KERN_INFO "LED unregister!\n");
9 K g) t% F( [! B}
. Y! a0 }% F b
# _" ^. {5 d! x2 }7 |module_init(led_platform_init);( u" E$ e* g: ~
module_exit(led_platform_exit);: q3 i E: O2 P' n% X4 p
6 }) m9 }! ? V7 TMODULE_DESCRIPTION("Led platform driver");3 d6 Z" X- _" v4 g0 B! @
MODULE_AUTHOR("Tronlong");
% ]: _: }" b* f7 DMODULE_LICENSE("GPL"); `0 V. [( B: ^, c3 }2 ]" w2 t
, t# v8 T$ v+ Z+ I, Y% S) X7 l
|
|