|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
2 w' B" u1 w) f- |. [#include <linux/init.h>
5 H p. e6 D. ?( f#include <linux/module.h>
7 w/ Y0 g. n. C9 P, W1 r#include <linux/kernel.h>
4 u3 W. E6 X$ {7 e6 b# S; z Z#include <linux/types.h>
# R$ R$ m% g1 A+ O#include <linux/gpio.h>
# S1 ~. q( ]7 O) Y" i1 T' B$ i8 ^#include <linux/leds.h>
- Q- h8 e/ i; {1 `#include <linux/platform_device.h>
5 W& m% s1 D/ Q+ _# T+ E
+ y8 N/ U7 Y& h0 h#include <asm/mach-types.h> D& [& V" W* T) }
#include <asm/mach/arch.h>4 y; w3 b- R* D" i
#include <mach/da8xx.h>4 ~: \( I& G7 L! R. ^
#include <mach/mux.h>
# u+ _9 i/ V, a! u2 h" l7 F: |# j w4 k2 T
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# b" U% H e: r6 Z3 I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! J+ g) d! ]! q- H, E$ B- G; t
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ D0 ]2 O& b( B, J( Y" S/ }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( z- [$ E* I8 X8 [2 Y" x; Y' t! x
4 d& w9 o: D8 p/ a9 c- w% _/* assign the tl som board LED-GPIOs*/
6 p* w0 e2 ^# ]/ V% hstatic const short da850_evm_tl_user_led_pins[] = {
7 ~# ?2 Z% F$ i% F /* These pins are definition at <mach/mux.h> file */
, r5 G3 A7 D1 v' I; x- M+ @9 |* S0 M DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' H1 w, `- ]! ^' W/ V! `. Y) n. W4 | -1/ L; m* L# g1 @* ^
};) r% j( y+ ^. h6 z
6 D" u+ B5 L3 [! j& X
static struct gpio_led da850_evm_tl_leds[] = {, n8 B2 \- }0 G% B* T' c
{! a4 [! d3 S- H$ c. C
.active_low = 0," k: o& ]) |+ H. e; T
.gpio = DA850_USER_LED0,
5 A) p& ?: e3 o% S .name = "user_led0",6 ?& p3 G: `+ q
.default_trigger = "default-on",: H Y* I) M# {- o/ i8 i! y. C
},2 N# \- u. r6 _8 n
{( H# n* L4 q+ S# {* e7 L5 I5 j5 F( s
.active_low = 0,
2 c; h* _: ]0 Q! ^4 @5 E2 K3 R .gpio = DA850_USER_LED1,
& T6 Y8 o9 x- `9 e .name = "user_led1",
2 u& W' A. b _7 Z .default_trigger = "default-on",# }. p4 S5 N. j3 {/ c4 y) {
},
' j$ Q4 j) J+ P7 T/ k# l) j, b {. f& |4 Z2 g5 [3 B3 m3 m6 G
.active_low = 0,2 w: M% B9 _8 h3 v3 `
.gpio = DA850_USER_LED2,8 o# ?; @2 E0 Z9 Y, Z4 x
.name = "user_led2",( O( i9 }" Z6 z( J6 b
.default_trigger = "default-on",- U# T0 T1 t! A( \2 T$ X; I
},- o9 R, H- F. w* s
{
# z4 H; R* N/ ~7 _( w( \- U: L* Y: l .active_low = 0,- {! v% t) r" X1 g0 @) b7 M
.gpio = DA850_USER_LED3,
0 N' c' N/ h" _1 q- S7 p: Y .name = "user_led3",
& x' y1 Q5 s- E D# u7 l. l .default_trigger = "default-on",
* m( R4 q* f1 j& v0 l },
+ q! h' k8 w. V4 |) I" `9 s) y+ J1 @};
! m8 R3 `+ r3 G8 |0 N }9 m7 T' p2 }( T# Q7 V4 c9 | ~) f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 ]9 w7 {" @+ s u* i7 j
.leds = da850_evm_tl_leds,
/ d* I; J( B/ A# Q% R) { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) f* s. ]1 V* R+ g
};
9 I1 @$ X5 u) }& E/ ]2 g% ?9 k7 ^, z+ A- l3 o/ P
static void led_dev_release(struct device *dev): J/ l; w* L0 \5 v
{
* x2 V; g; G" X};
, w2 t9 {, P' P8 g( H2 `6 z6 _5 t6 ^- o/ z b1 e: \
static struct platform_device da850_evm_tl_leds_device = {& `9 E2 P8 d2 k' J3 ]
.name = "leds-gpio",2 c, `/ X/ b4 Y1 N) u% \
.id = 1,
7 ^. D9 V* u o9 l- L; N .dev = { s: m2 b- R v2 C
.platform_data = &da850_evm_tl_leds_pdata," B4 _& y( L4 Y6 B
.release = led_dev_release,
: \7 |% U) E2 L, J }- }: b0 F2 a, `8 Q; Y4 g) h' o A
};4 t6 U7 B! M$ n# b) w: p \
- ], W* m# r7 Q; B% R, I5 `* mstatic int __init led_platform_init(void). s t1 a G: M6 W6 V+ k. ?+ x
{
9 o& s5 y! L# H: y/ C int ret;# i( |* L& ~1 H! w( q
#if 0
( i4 O6 ?+ i9 N5 P- |" Q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" f; h2 t7 }; V0 n* b/ O* e4 H
if (ret)
5 h D9 ^" I3 H) Y# q2 Q1 i pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 s3 m6 @7 V8 v0 l, B+ o! v( o; o
"%d\n", ret);3 t7 w- j+ w7 s- Y: V6 I
#endif
0 J# f6 h/ ` n$ @ ret = platform_device_register(&da850_evm_tl_leds_device);' G: K* L! a: H# l' E, ~' Q
if (ret)
1 k$ b: [/ C4 X5 y) J4 ~' C pr_warning("Could not register som GPIO expander LEDS");
5 T3 ]; \" M. W3 Z else9 b/ g9 T' N2 u3 z* r
printk(KERN_INFO "LED register sucessful!\n");: l+ Q Y; g2 S h1 N7 O. S
& X1 A, ?4 n$ C& S
return ret;) P I3 m: c! o) e9 |
}3 r# a2 s# C$ H& h
) o$ x) F) w9 F# b1 k/ @static void __exit led_platform_exit(void)
, c7 v$ H7 I- @ ~9 M{( M H& \5 U1 b3 B$ ^/ k
platform_device_unregister(&da850_evm_tl_leds_device);
/ w! |1 _0 O: o
0 K" P! T4 ?2 R9 q7 |) J( D$ x& Z; k printk(KERN_INFO "LED unregister!\n");" H) W) c, U+ a8 i2 N; J
}
# x; i7 c6 Z8 D0 N7 S5 F6 p! a9 ?/ V, s# l, L3 @+ x1 H+ T
module_init(led_platform_init);* M2 W' }- w" w5 a
module_exit(led_platform_exit);
' w; t3 t" x3 e S! a* c% d+ T" N+ ~! K; s
MODULE_DESCRIPTION("Led platform driver");
; _' m7 w$ W1 }3 u. f$ m# jMODULE_AUTHOR("Tronlong");: ~/ O2 b6 i' X! D6 O
MODULE_LICENSE("GPL");# P x" k5 K0 T' W# z o
; A2 c& |( `5 F* C
|
|