|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 O/ z$ n) I$ L
#include <linux/init.h>2 x% a3 z4 W' R+ q$ w- j: c' d
#include <linux/module.h>
: n. A n u) R; p. g8 u( Y#include <linux/kernel.h>2 ~: J) M- ]* F" X6 G
#include <linux/types.h>% l3 ]) M4 ^& [& u* z1 L# g
#include <linux/gpio.h>. o! M( C# u/ x- Y y
#include <linux/leds.h>
8 }. \% U4 U+ I4 w4 a# ]#include <linux/platform_device.h>
5 G6 e- i) q1 q2 q0 v+ K0 v# s& W
( k/ f# @9 L) k#include <asm/mach-types.h>
/ N3 a7 A. E/ D- g" _#include <asm/mach/arch.h>
/ U1 m$ I: {1 u: J& H#include <mach/da8xx.h>
% p& g9 c3 W) n2 p. Z6 S& K' _; I#include <mach/mux.h>
: t0 w, I, T1 d# P" E- H+ @4 |* }
1 e0 m+ e! u: V9 `/ ]" L( x1 W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' z$ w" L4 p+ w8 H( J6 d8 q. q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' K7 @: Y. E6 u' J) w
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! n2 ] r- ^8 Q0 x1 A" U6 `, w
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 t9 b: E# o6 g# ?$ o7 c
6 L, q% q8 o0 P
/* assign the tl som board LED-GPIOs*/
1 i6 o! A7 T, u/ q1 D; Istatic const short da850_evm_tl_user_led_pins[] = {! o7 g- Z: Y# s: Z P N
/* These pins are definition at <mach/mux.h> file */
) G. M# P0 z7 v2 A" q" X DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! G* m2 x6 c. w, g) q
-1
" B0 Z: P4 k' E* I) C2 T, A};. O" Q0 s# d! ?- n+ g: n9 K7 ]
2 C" S7 T! H1 ^9 @static struct gpio_led da850_evm_tl_leds[] = {' Z0 N8 @7 h# h9 |, V5 L
{0 h& R3 J; n' x% ^) D& |& L! v
.active_low = 0,
4 w" a* m$ _- C$ N5 P) Q .gpio = DA850_USER_LED0," G( ~' J: h) i, f' u
.name = "user_led0",8 Y* ~; S- @- @, B
.default_trigger = "default-on",
; x# I6 M2 l" t2 U' `) {; k& v },
) x5 N+ V L: M# |% k {
, `+ F7 e. j: k( d/ F5 t .active_low = 0,
! R" P5 }/ a* T( u. v .gpio = DA850_USER_LED1,0 w& z( s; i! ]% F
.name = "user_led1",
4 N& k$ M! ~+ U ]/ e .default_trigger = "default-on",' }" d o8 J- K7 f$ P
},: A. I) D- ?' \' r" o( l
{% p( Z- D# p6 N7 Y2 Z* D
.active_low = 0,
6 }: k4 A7 O+ P* i .gpio = DA850_USER_LED2,
( _. e1 n" U6 J/ J' b. ?" }$ X .name = "user_led2",/ ^. Q2 _9 W4 f/ ]7 ~
.default_trigger = "default-on",& E" K; E% m, u9 W! ~2 y+ z6 |/ ~
},
8 ` j2 y# o" E$ q8 z {) I& P+ Q/ U0 |: @1 l" u8 N
.active_low = 0,
% P$ q4 J: D0 f3 u+ B .gpio = DA850_USER_LED3,1 B; {0 u0 F; }$ e" n7 _$ x( q P+ v6 V# J
.name = "user_led3",
. ?) U& ]+ w" @' v* d .default_trigger = "default-on",+ j1 R, m" n+ ?$ m9 e4 _
},0 N* a) Q; Q% e: |, K
};5 Y& V4 L/ _) R5 }1 G6 w
7 a% d8 X% D! E6 y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 n6 P' C) U& q$ n1 p .leds = da850_evm_tl_leds,: J7 n3 O- U7 q& y0 ]* ~8 r
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
u" u) P6 Q1 T# p$ L4 `};1 l, X$ f' B) P7 x% d1 F
% u3 k3 x" `6 l2 l+ _
static void led_dev_release(struct device *dev)) h1 P2 E3 R! v- L, a
{$ M" \$ T9 ^, R* N5 w% C
};
( }7 e: P+ e& B4 D6 W; ~, y& }* x. H! C: c4 ~- @/ ?
static struct platform_device da850_evm_tl_leds_device = {3 ?' V. ^/ L( ?$ o5 |; L$ D
.name = "leds-gpio",
) \# z, Z* q b, i% S .id = 1,
; n' d [# G. T1 K! s .dev = {
( _6 }9 R' _' I2 T1 B/ b, [ .platform_data = &da850_evm_tl_leds_pdata,
& L2 Q* m2 e, [' r) \ .release = led_dev_release,
5 [. I, y) M6 Z- V7 k }8 L' H9 q; N5 i+ W, e5 U# |: i2 i
};
4 I1 X3 D" r8 L0 o0 a+ _- s0 J# y2 @
static int __init led_platform_init(void)1 K* x, o9 E9 ?
{6 Q! t4 s' B" N7 S3 h4 }* ~1 q U
int ret;
- s0 d( s$ i6 `8 n( h1 T#if 0
/ s! Y, E! x( o5 n; Z2 S3 z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 T, i5 W/ f# V; _( U+ G/ V
if (ret)$ d4 @+ w) d+ n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" z) \6 u& |; S$ B) v "%d\n", ret);
" m) \ i, G9 ~& p/ v2 q0 r( B! U#endif6 Z9 A! I7 W% Z" |$ d; U
ret = platform_device_register(&da850_evm_tl_leds_device);0 [- w ` x( B8 w) W, d
if (ret)
% V. w' b+ m) G7 Q. y$ k* D pr_warning("Could not register som GPIO expander LEDS");5 L" m) M4 k6 Q1 P6 d5 {- p
else* [" {3 V" H; x& |0 L
printk(KERN_INFO "LED register sucessful!\n");
% O- O7 K! P7 c+ Y- w, O
; w4 A, w; t. z$ v return ret;4 w' [9 S/ m- k* R5 T+ |) T) d4 U
}
6 u( A, {9 x2 G
: D# i* \2 U8 C2 I" ?0 vstatic void __exit led_platform_exit(void)
5 l5 ^$ U4 B6 w( A& i3 @6 z{
& l& |0 P7 z5 q& e2 C V3 U platform_device_unregister(&da850_evm_tl_leds_device);& Z9 U2 t$ }2 _* |) O
/ A) S1 t; b$ i8 |$ k
printk(KERN_INFO "LED unregister!\n");
8 r2 M7 y8 H8 }}
: w7 u9 a$ ?1 y$ a6 h' H% n. t* F- G+ l
module_init(led_platform_init);* G% J0 o& Z- \' _. H# V- l% z
module_exit(led_platform_exit);
/ \+ r2 _' O: y( |6 t, X; m1 x. ~, P7 Y# t
MODULE_DESCRIPTION("Led platform driver");
4 q, P2 X% `, L7 m7 BMODULE_AUTHOR("Tronlong");: U+ O* c. s. E6 X0 I
MODULE_LICENSE("GPL");
7 F" E" z, e$ X) }1 k5 S. |5 q! E# }" k3 X& u
|
|