|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- _( Z- R* J/ N5 A* W+ J#include <linux/init.h>% a0 l; d' O+ I* c! Y. I
#include <linux/module.h>2 ]8 y: T0 u+ T; \
#include <linux/kernel.h>
* d9 I7 }! H1 o) j#include <linux/types.h>
; i8 W+ |* {; Q#include <linux/gpio.h># F" t1 Z! A U% ?7 @. t
#include <linux/leds.h>. J- A9 W5 m6 B+ F; Z1 c
#include <linux/platform_device.h>" j2 g& m' Z7 h7 y* n
" d' i; M9 j# t; f8 y#include <asm/mach-types.h>* p/ ?' L' h9 w7 N3 b2 d6 g
#include <asm/mach/arch.h>1 D* |0 \7 Q, F+ p3 B7 y
#include <mach/da8xx.h>
, D( k2 q# |2 w" r7 c; ~#include <mach/mux.h>; `/ r& k3 u* Q6 W3 }
9 N* y" {' Y7 i# Q5 J. {$ y# z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, c0 v: { s" e( y' Z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ x5 ]" v& M; U$ Z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 L" Z# |9 s. h+ C/ X& W" n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( B. _3 }1 t: K! \
/ {+ G. g: L# k7 A$ I
/* assign the tl som board LED-GPIOs*/# B% r; M t7 [6 N
static const short da850_evm_tl_user_led_pins[] = {3 E. V1 m ~- O3 ?. w/ e& q
/* These pins are definition at <mach/mux.h> file */
, _, e4 W0 F4 s+ o. V- ^4 g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! ` l$ g3 k j6 T, R -1$ B1 Q" t9 f* E4 h: C
};3 p% P8 ]( u* X! e/ d, u
$ g4 o( @% W4 V( O" D i: r, k4 W0 @static struct gpio_led da850_evm_tl_leds[] = {" n, }6 i/ E4 l* A
{, _1 U; |% t. H! v3 u% |: Q
.active_low = 0,
: x4 o8 a$ x5 l- i N. | .gpio = DA850_USER_LED0,
1 j8 s7 @, T, v9 o) {/ y .name = "user_led0",
) q5 |" y) | ~0 y- h" a .default_trigger = "default-on",. W) Y6 P0 \5 o% Y( A8 L! b+ y
},) N. R1 W* b6 L* `* \0 A9 Z; ?
{
' @4 a, e6 J* V/ b( y/ V9 G .active_low = 0,
- b. f! F/ [' | .gpio = DA850_USER_LED1,
" O J* l0 K# M W' G1 }" `& S .name = "user_led1",
& t. |2 T" x/ P .default_trigger = "default-on",6 C# q: Z. w6 M' O8 k, {
},
' R; V( b+ m' R, V6 I {
# W3 Z# ?) ^$ v3 R' B9 r .active_low = 0,: |- ?# [. C* Q
.gpio = DA850_USER_LED2,
: @( n( N L! r( ` .name = "user_led2",- V: B& f* Q5 r0 n7 Q% m
.default_trigger = "default-on", l* u% ?# L+ l0 ]" }
},
% z; a5 t7 ?& v {8 h5 s% {/ b) e& m
.active_low = 0, @, O- A+ i6 H3 R7 U
.gpio = DA850_USER_LED3,
: m+ H- V8 b( r6 t# p% j .name = "user_led3", w# x8 d7 m, L; ?
.default_trigger = "default-on",
* ^6 Z/ ]% ^' t8 J# A; L },2 D8 w6 v' B o0 E: u/ Z: ^5 o
};
) [. \' t+ u9 E/ `4 D
! @* ~& k* b& ~% S7 x0 z* d7 _static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
n1 ~0 v4 F( p4 H .leds = da850_evm_tl_leds,
3 o7 ]. i- }* P4 k+ {5 Y2 t) y4 B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 d' E% C7 f5 N( `& e};$ G$ l7 w8 U% C f t& P' Y
9 k% D: p. Q2 i/ `+ nstatic void led_dev_release(struct device *dev)
W% v' ?" I# t4 R+ N4 y{6 }4 U/ ^) Z" J
};
; j3 k9 [2 b6 i% |) ~8 }
* s. @4 |( t8 T, {2 ystatic struct platform_device da850_evm_tl_leds_device = {9 W/ V& Z3 n( c0 |7 Q
.name = "leds-gpio",3 T$ X/ x# h" T6 k
.id = 1,0 s, `+ h k% g* I) [, f" U
.dev = {* o' n1 B8 {, i
.platform_data = &da850_evm_tl_leds_pdata,( D! \* j! \0 H5 y3 s
.release = led_dev_release,: H' T4 {+ a+ I/ C% u% P7 L% u# W
}
4 k+ m' J1 H" {2 k7 G+ a; Z7 o( L) a};: v7 b9 ?0 `& R, @5 n% L R
- J% L% I4 L2 {1 Q! \0 y* s5 rstatic int __init led_platform_init(void)4 D1 K' w4 \& h" i
{
5 Y2 ?+ Z: @+ t* W C' M int ret;1 r( w" m9 q: b5 e
#if 0* k6 j2 B$ X3 C2 P
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: Y7 e; b5 i* @- e- e* ~ if (ret)
4 p$ ]9 C; H9 V* K pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) y. T# Y4 Z- Z7 F4 d "%d\n", ret);
: m7 E9 E8 T, i! }#endif1 o o$ z& y2 I
ret = platform_device_register(&da850_evm_tl_leds_device);* f8 k/ k: t; O$ p6 T) v' J9 j
if (ret)# g' B, [6 X1 n/ b4 @+ A' _
pr_warning("Could not register som GPIO expander LEDS");1 N: Q/ E& I( ^
else+ ]( E `& G' r6 t" V
printk(KERN_INFO "LED register sucessful!\n");, [2 R/ i3 B# M" t T5 f ~9 J# V
+ u* u( B: C; b* q/ P% d. b) \8 e return ret;% K" y& e" d, P3 H; Y
}9 T/ U6 O l- _" B7 s7 w
+ C6 J1 @# z+ _ r
static void __exit led_platform_exit(void)0 f) `+ q/ |# G- _9 K, y |
{$ O) K. a3 v3 E% r# F+ n: G9 f
platform_device_unregister(&da850_evm_tl_leds_device);; [# d8 L# S$ O- z# h; C
; O/ K! B- v! z' p, P printk(KERN_INFO "LED unregister!\n");
& P3 o3 T! F& N! L1 W8 t}3 h+ J5 M- E1 W' C
4 g, B3 q+ `0 f0 N' s" C1 [/ H% [8 dmodule_init(led_platform_init);* ?9 y* ]2 F4 y H% U" J
module_exit(led_platform_exit);
! O! G. ]- m+ |$ O
3 p+ \: C% W- @, O2 S7 `; O2 aMODULE_DESCRIPTION("Led platform driver");7 w: h- R3 Y8 S+ a! G2 Y
MODULE_AUTHOR("Tronlong");
5 X& R2 V* W8 ?4 I) i4 C: J: \5 yMODULE_LICENSE("GPL");
% I; n( X4 B' X5 @/ L
2 G' r' |' d7 P% e |
|