|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( X3 E/ [2 {( l4 j9 m/ R# S, m#include <linux/init.h>0 H6 Q# ]5 B6 l/ L
#include <linux/module.h>; d, [) P0 c$ Q4 h0 n
#include <linux/kernel.h>7 ?; M+ j& ?4 l$ P
#include <linux/types.h>6 h3 y0 n; ~% n$ L
#include <linux/gpio.h>
. K7 H, W, s3 U2 o#include <linux/leds.h>6 h5 H! W+ l; c1 n
#include <linux/platform_device.h>
( Y+ n0 z* @, D. {' W
3 V$ a7 O8 i, j% o1 ]- d#include <asm/mach-types.h>
6 P" X- T: I& b2 s#include <asm/mach/arch.h>
, G! D0 J/ s( b7 O& Q% {#include <mach/da8xx.h>. `9 z1 b4 V% h( o6 o
#include <mach/mux.h>
: E- L; L, Y9 ]+ j1 a8 D) i9 ~; T7 _* D. ?8 n; T
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% T2 M6 V7 l5 C i* }
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), T, E/ s1 u5 g( ]
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 g4 `& _9 r4 f
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 m4 N( h# C+ A& j6 t( B, _- H
5 q( k! ?0 G$ m/* assign the tl som board LED-GPIOs*/+ l5 x! _ u. ~: V
static const short da850_evm_tl_user_led_pins[] = {! m2 s1 m, l8 i$ W& ^1 a6 s. w
/* These pins are definition at <mach/mux.h> file */
; i% z( k) m/ z0 { U DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
F; ^3 x% X* w0 h- e( n -1& e( J) o, h. p5 m" F8 J
};
o6 v4 B3 Z4 y; j1 q% [
_! P, W& E5 pstatic struct gpio_led da850_evm_tl_leds[] = {
, F- ]: i) m9 a `& G- ^& L1 d {
4 f7 m+ q; O1 Q* T3 [* [ .active_low = 0,
3 T( w5 y$ }. h% n .gpio = DA850_USER_LED0,
/ M0 R8 ?1 P/ q0 A( O$ l .name = "user_led0",# w8 z y' q7 E# ~5 H/ t
.default_trigger = "default-on",6 ^4 c6 l& G: o. t; }! B
},
- ?& a8 _" I1 F# ]# u) @3 q, q/ | {6 I5 z( s0 }: J% w& M; ~5 F
.active_low = 0,
4 O2 k) c3 k3 J6 @+ n) Y .gpio = DA850_USER_LED1,
3 D6 \8 E' p2 ^: V' p .name = "user_led1",
. i; {1 F. q5 u0 m! o& C .default_trigger = "default-on",
! m7 t. j* Y9 J/ F% x },
) q+ U$ |& T) Y! R4 |) X- L {4 ] S& V0 J: l& { O
.active_low = 0,+ f' F7 h( Y& ~! X4 ^
.gpio = DA850_USER_LED2,
. q9 P2 d8 A4 d3 f7 c .name = "user_led2",
! C [1 p d. @4 `, N .default_trigger = "default-on",4 [# t: g4 O+ {1 r
},/ E6 V! K6 C0 D; k) o6 Z4 {
{: U; ?& y/ u3 B+ e
.active_low = 0,0 e, q M; d; ~* N- P( Y6 b7 b
.gpio = DA850_USER_LED3,
& r2 X4 x. z) _2 J5 O .name = "user_led3",
' o% f" w' j0 r: C4 Y .default_trigger = "default-on", L. w! ~: k7 ]' ~' j. C0 Q
},8 b: n" X5 z% X7 {, p
};4 [' Z0 g* @) e" w6 [
: X( i4 v( z4 j3 n2 N* Bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' w6 I L: x$ H .leds = da850_evm_tl_leds,2 ~. }/ \/ {8 I- M& `$ n/ B6 t
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 d/ m& v8 a8 E
};
5 C3 b) _% y7 c( Y ?' n2 c0 i6 {# e
static void led_dev_release(struct device *dev)$ W: A8 @+ z7 h! h- S! Y4 T
{% d7 ]* r4 K- I
};
1 _- H0 X" I( u/ K+ x; z. W z. ]: I
static struct platform_device da850_evm_tl_leds_device = {1 o2 D( _( [7 @4 X: M% L8 h& V* a
.name = "leds-gpio",
. I: v* I8 m& z: n .id = 1,
' q$ W$ [! E# w' j/ F .dev = {
2 h4 w: e. Z6 n* i5 F% M4 w .platform_data = &da850_evm_tl_leds_pdata,; Z4 V: l8 y. E, }) P) ]. }
.release = led_dev_release,
) B7 _$ l0 c0 E7 a( N( {% { }# r; i# z5 D$ h! h( W0 `, C
};0 d8 `. _ U, K" i% N9 k
; x" L9 W; y' |
static int __init led_platform_init(void) R" n8 d4 E9 I9 R
{
5 P1 H4 V' t3 S( @! z int ret;! v6 M! G1 z; h4 F- g7 M! U
#if 0
, Z, p- k3 i; U. g% F5 s ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. F% m% J) N( B; P8 x if (ret)' Q3 }9 k1 B7 H6 M
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; {( d3 ^3 C6 W9 H# y
"%d\n", ret);; y/ a2 Y+ V1 \' o! U
#endif
1 S m6 r% ~" U# W4 @ ret = platform_device_register(&da850_evm_tl_leds_device);: y, I' ]- t* N
if (ret)0 {* N' y6 Q* e/ y
pr_warning("Could not register som GPIO expander LEDS");( K6 ^+ K8 K% a
else
2 D$ d4 g- c$ n: t* ~7 y: V; d printk(KERN_INFO "LED register sucessful!\n");. I* L6 L6 q8 D$ @' ?
9 U0 W: N$ C8 Q' t" V
return ret;2 E. D2 k' |8 Y) }' e1 q
}
+ q t" S1 O' I: s! I! F3 k( C5 z3 w u
static void __exit led_platform_exit(void)
. p0 Y' y- ~$ V{. |6 H1 w$ z+ z; e8 W$ m, r4 ?
platform_device_unregister(&da850_evm_tl_leds_device);# m$ u7 m& R, X" n( c2 W$ d/ ]
& l- ~' g/ [9 w8 X1 Q# y0 I! Q- \
printk(KERN_INFO "LED unregister!\n");' Y3 {/ h Q, { D: {% b# v
}# k" y% S1 _5 h2 H
4 i( G. q1 L) }6 e2 D, v9 p: Cmodule_init(led_platform_init);
% }# ]- a8 \; Q$ \% s/ Emodule_exit(led_platform_exit);: B2 F: ?. {* K8 N2 R( f8 y7 ? [
7 y: r2 V+ ^( f: U4 H7 {1 D$ w, T
MODULE_DESCRIPTION("Led platform driver");' ]/ X% f8 I# Z- ]0 S5 p
MODULE_AUTHOR("Tronlong");3 y- r, v( e& q; S$ \1 O) Q' l
MODULE_LICENSE("GPL");
/ S- n" L2 c# y5 R6 h; {; m
) V: B4 ~# w8 N |
|