|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" G% h# P7 i5 W#include <linux/init.h>
) n" h# |, N2 T3 S#include <linux/module.h>
) i! l3 ]' B3 J; r' J#include <linux/kernel.h>4 A/ l8 B6 v3 K0 k1 d1 R4 v$ ^" x v
#include <linux/types.h>
, b5 m6 w4 d, i& w/ _#include <linux/gpio.h>
5 |2 ^% o' u! h1 S' o# w( T#include <linux/leds.h>) Z, P* Q( N3 w A" C
#include <linux/platform_device.h>
) K6 q& K# O: @3 g
/ I+ m3 b9 s8 y' c/ b#include <asm/mach-types.h>0 y1 {) ~ g- k" r$ \5 M1 i
#include <asm/mach/arch.h>
/ W$ I4 c1 n* i j$ I#include <mach/da8xx.h>0 }- S( g6 d( y% \: u" G$ j
#include <mach/mux.h>
! w, V# c5 `3 R' q6 O1 M) B" X: a$ Q+ K I* W; o0 s0 U2 t% d
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ B0 ~, E* d9 i. O+ \; o#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( s1 D! w% V- Q6 b#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% Z3 M2 B# J% A; r& r& K; D* Q* O: B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) }, s2 L3 z8 O R# A& i6 k
9 [" W# B" ~0 f
/* assign the tl som board LED-GPIOs*/9 V# T$ _2 n- Q3 J
static const short da850_evm_tl_user_led_pins[] = {% d9 K+ }; f. A5 x/ ?# B0 _
/* These pins are definition at <mach/mux.h> file */( q( G1 b9 a* B3 G9 s
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! `7 M" E4 [1 r: }
-1
& V: j7 `$ e5 j& j. w; Z0 `};
: }% ]7 C! B* u# |/ ]6 M @) y& I5 W/ q( F
static struct gpio_led da850_evm_tl_leds[] = {
, y& N z0 j! r. B- A/ D% U+ r4 N3 W8 w {* O* g. l. E: M) T0 x
.active_low = 0,# g S0 h- `- r. l! l
.gpio = DA850_USER_LED0,
% l$ y; O8 p: s. l .name = "user_led0",
7 Y4 n' Y% D8 y# }0 V* n4 y .default_trigger = "default-on",
6 g5 {8 @1 s% E% w% _ },8 ~( ^* I) @) }+ M
{
( u( W m% x& a8 } .active_low = 0,2 Y" o" j/ \/ O1 L& r
.gpio = DA850_USER_LED1,
, w6 T" o, Q) c# W7 F .name = "user_led1",
3 d* M' f8 j7 N- B8 p .default_trigger = "default-on",
! H4 M) r% i8 [" l5 S O },
! K/ e0 s& ]8 O0 j4 e/ \ {7 _3 c4 ^/ V$ u0 z2 x
.active_low = 0,
6 U6 U" D* q2 L: o V; Z! q .gpio = DA850_USER_LED2,; T- L4 N: `6 S! U
.name = "user_led2",
1 }; N! g7 N- Z2 P# |/ h .default_trigger = "default-on",% b8 n( ~2 `5 M. H
},6 p6 {% X i: j4 Q1 F9 }' G c% w/ F
{7 |* N# _9 ~: O- [" }( T$ [
.active_low = 0,4 e5 Q) F- b9 e. ^8 s- S4 W
.gpio = DA850_USER_LED3,+ s5 {; J0 m& L! C/ h2 n' u
.name = "user_led3",2 q: J8 H, q* M5 a$ L6 e: t0 d
.default_trigger = "default-on",
# x8 b) f% Q' }' i9 D) { },
' A) b1 {4 A& P};' h S: b; ^ h
- _+ |+ ]4 p) [3 U, Wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 H8 D- A% h6 J. w, ~ .leds = da850_evm_tl_leds,4 x1 D# Z+ _0 |+ Y; B+ L
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
4 x0 p8 o+ j2 Y' b6 j- e& [};* Z4 J1 G7 |. i1 V/ t2 I
* z6 O6 `! c7 \$ A9 T( i0 A* k
static void led_dev_release(struct device *dev)& ]7 x( o O' p0 A7 H
{
1 d) J8 K$ V9 k' b! a& Y};
* a2 x% s h4 W; ~5 {- \) f: j5 H' R! }# {4 d/ J2 ~
static struct platform_device da850_evm_tl_leds_device = {
& ]% ?; `6 N+ J! {- z( ?3 L .name = "leds-gpio",
( F( n9 I+ T2 _) x" m9 K2 T .id = 1,
5 M7 G7 [+ u3 I3 f .dev = {
/ P$ {. a( [* [* K .platform_data = &da850_evm_tl_leds_pdata,8 H) E9 `1 F/ D0 I9 v
.release = led_dev_release,4 i+ l v' ^/ m( C# ]' w1 N' x
}, L; V% }$ N8 s4 p# v$ n% g a
};2 x* N; I6 W9 R* L) x8 w
- O4 o% [2 K0 [& s
static int __init led_platform_init(void); I8 L* y {- B0 V; N0 K" I
{4 H: O' I9 h u& @/ V9 d
int ret;
# A, `! e3 H+ Z, L: H1 m+ p9 I) @#if 0
/ I. l% J2 q5 Z3 |/ l0 k* g7 O( B ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* h7 B$ L6 P+ E& B1 i C if (ret)
4 Z5 p' N; g" x& R pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 Y/ l" m2 x3 H1 K) Q
"%d\n", ret);4 j( a! m, s( v" u% B h3 D7 y
#endif
6 Y, {; g% V5 y7 [% [2 p$ ] ret = platform_device_register(&da850_evm_tl_leds_device);
! P1 S; Q: B4 k0 m9 P- k+ U: X$ n if (ret)
3 ^7 ^( S" o/ d0 X5 ] pr_warning("Could not register som GPIO expander LEDS");6 T! U* y; C: {0 d8 a
else
- z8 ?; k5 ^6 Z* M$ M2 ^7 D' | printk(KERN_INFO "LED register sucessful!\n");
9 M4 W! @! c# n& ]: s. V: N
D& `! w% u6 e8 O4 R# r( X, K/ ] return ret;
" Q) M+ L& I' f1 T}
$ Q$ Y8 _: d5 Q7 T7 f
/ s; i' Q( O4 g# |* e0 T6 `# z5 fstatic void __exit led_platform_exit(void)
0 Z5 t- a( N1 p9 a: O{: G5 a% q7 d6 a# B6 s
platform_device_unregister(&da850_evm_tl_leds_device);8 ]2 S1 E2 o; [1 Y
2 w4 ~9 w6 W- A& W! Q
printk(KERN_INFO "LED unregister!\n");$ b9 \# e& T& n" ?
}
. N8 L4 W& p% g' ]+ ^; B1 ^) F
8 u3 W5 D+ W: Wmodule_init(led_platform_init);
9 {- q# |4 M9 j9 p) t' Vmodule_exit(led_platform_exit);- ?! J5 Q. H1 y6 Z) u. n$ S
6 t/ o' j0 r1 _. R( r
MODULE_DESCRIPTION("Led platform driver");
& c( P0 K! N5 C$ X* vMODULE_AUTHOR("Tronlong");1 R8 W/ [0 z$ \* C8 s, G" M" E; `
MODULE_LICENSE("GPL");8 l# t0 C i S$ z9 c/ w4 X+ Z
1 y5 a* N5 f- r6 H& f |
|