|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# L* i9 Y j. }
#include <linux/init.h>
6 _( Z: S! g0 _& t#include <linux/module.h>( P; l* x; Z" \& r2 y0 v
#include <linux/kernel.h>; U1 z8 i$ h2 y: o
#include <linux/types.h>
% d% s( L/ ^5 s% p#include <linux/gpio.h>
- ?2 o, C1 x+ K% c! J8 p+ `#include <linux/leds.h>
# P4 m( W4 c# l2 p#include <linux/platform_device.h>7 m% M/ [0 W5 ~
2 S; b7 M! d. {#include <asm/mach-types.h>
* s Z. s: q4 w! O, Y#include <asm/mach/arch.h>
- N8 l I" X% {( q }8 {#include <mach/da8xx.h>
9 L0 R: i2 K- j0 ]7 ~, L& a& Z$ j" A$ C#include <mach/mux.h>8 {' G1 P# A- D6 a
4 d2 t. p. I# _+ @5 S#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ D3 C6 O. U3 W. z( t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( [2 B' T7 x$ T$ N1 W- n( x#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) D! S0 D% Q. Q; v#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
L; U5 I( v" y/ x/ N* Y3 n# n+ Z: T. W8 E& m, j
/* assign the tl som board LED-GPIOs*/
3 R$ v3 k: s( R$ x9 Y( }static const short da850_evm_tl_user_led_pins[] = {
; W3 V9 j; Z: x6 b5 H /* These pins are definition at <mach/mux.h> file */8 o1 \2 ?5 ~2 [8 y7 @+ i0 L
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) \6 T) ?4 c! x% Z4 B9 `7 h p
-1
& R( n% }- a' Q};# c; w5 ?8 _5 }+ \9 G& O
: _5 m3 h" A) |0 P* lstatic struct gpio_led da850_evm_tl_leds[] = {
" X1 E" ?/ ]* F% q {5 _5 x$ Q& c" |$ N% R- p
.active_low = 0,
: u* D3 G7 h) r" C" y .gpio = DA850_USER_LED0,3 a. A; \( {3 }4 B0 ?
.name = "user_led0",# A, S+ x( H* u
.default_trigger = "default-on",
5 \5 i8 b* c: W( s8 e2 T },
* V& E" A2 ^* J5 g2 }6 ]8 A' c7 T {1 `# }0 `' f- f5 e4 i- K
.active_low = 0,, U, _: T; n8 {2 K$ ]
.gpio = DA850_USER_LED1, l$ H# z8 ]! A) l
.name = "user_led1",3 x2 A! U8 w2 o1 }8 Z5 |; F# L
.default_trigger = "default-on",2 G; K/ I- g8 [' W
},7 l! ~2 R2 G# w" g% A4 Q
{7 s6 }. X8 O9 ^8 s) Q9 Z+ ? T" r
.active_low = 0,8 g$ _& t2 a, s; X
.gpio = DA850_USER_LED2,& N, ^) O- _& Y N/ ^: o1 O
.name = "user_led2",) _' r7 r/ `& s. l
.default_trigger = "default-on",7 N/ a: R7 L6 p8 c, p- [" k1 A
}, B' k; o% n. }- j& s
{
v9 T# E5 M" K9 B; |2 g .active_low = 0,
/ d8 Q9 j3 Z0 c% h' U' u .gpio = DA850_USER_LED3,/ F& C8 Y0 l! a7 Q- b
.name = "user_led3",# ?. H8 e4 a! [+ e' ~ H- d, n4 f
.default_trigger = "default-on",) L; K; U, I% l' a2 I
},( J3 ]3 O" w' L6 B# p u
};, k6 e- ?& d# {3 [: c, W8 k4 z
! y; a4 R# y- V r3 G: h
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 A o9 m8 f( J6 C$ v .leds = da850_evm_tl_leds,. _& D" B; y: t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),, v3 m5 G* W- x$ S# k5 `1 j
};
+ K4 ]& s g0 A: u: I) Q" c5 X+ x \ X. H. I# N( f+ L/ Y; u' g
static void led_dev_release(struct device *dev)
6 Q' O; U5 g1 p/ c- a{
8 Q. G4 N* W5 W" o, L, k' _};
( @& v5 X' [+ `3 Z: C8 X7 m7 R+ {0 n' ~
static struct platform_device da850_evm_tl_leds_device = {
/ }% p# I" ^ |. T, Z+ L5 \# i- m .name = "leds-gpio",
# M6 |& {5 a, [) u .id = 1,
) p1 i4 {& z" [ Y .dev = {
4 z" M, `* L4 v; m; q .platform_data = &da850_evm_tl_leds_pdata,
3 W* j8 p7 S1 e) M) U% O .release = led_dev_release,5 e: s' e' Z# U! w$ }6 h
}
, P6 P1 g7 u* X( Q) a5 A};
' {/ [- ?. s3 x4 m" s- i) H: D4 t5 Y S" A6 @% ]
static int __init led_platform_init(void)# D* V6 t0 J \3 M5 S
{
7 e% `# k* a0 r int ret;% I" f* E, `- O
#if 0* n3 C! Z$ [* L4 d8 A
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" U% _( `8 M3 z- w
if (ret)* z& D# F" h, S& n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 N, Y" H+ L4 W# ^& W
"%d\n", ret);
6 S# w5 f. U) J/ p) E( @#endif
+ V2 Y' d7 ?2 t) v ret = platform_device_register(&da850_evm_tl_leds_device);' p2 E e" k9 k7 R, x1 Z# j
if (ret)
0 r9 `2 P+ j* Q0 U/ { pr_warning("Could not register som GPIO expander LEDS");+ c6 V N; _- Y) d5 w! V
else
; M U4 f* l- p# ` printk(KERN_INFO "LED register sucessful!\n");3 F1 t" F. }- j% e" [# M
8 ~6 f& H; y# n; _ i1 |. \ return ret;6 M- s1 N' _- s
}( _, ]3 o. I- f( d, y& G
+ Y f' Z a. c1 Zstatic void __exit led_platform_exit(void)5 q, _. Q: c' y4 i2 d: U
{
* u4 F7 T" @" I platform_device_unregister(&da850_evm_tl_leds_device);
! o6 R3 @4 F- F, L
! H! D+ j1 ]4 |" { r: Z5 o) T printk(KERN_INFO "LED unregister!\n");6 W ]" V& M* L% D- ~7 T0 v
}
) {) e2 h$ y# n; `; f" N2 G4 S) B6 A7 w+ `) O
module_init(led_platform_init);& U' y% Z @5 {6 I( I; [
module_exit(led_platform_exit);
2 i3 H) g6 R1 L4 x& z% c; t3 S% O3 \8 z; a# Y7 N- h- D, v
MODULE_DESCRIPTION("Led platform driver");. F: |3 b9 w r* Q7 E3 Z
MODULE_AUTHOR("Tronlong");& j. T& d9 |4 x( ~
MODULE_LICENSE("GPL");0 b' I! r, z3 F; m/ ~2 F
4 n+ ?% @) S; _/ w) ]
|
|