|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! g5 l( B! F9 n/ \( X
#include <linux/init.h>" O2 z( A. n9 q0 q3 b9 I; o
#include <linux/module.h>9 z; B, l" V" c, S
#include <linux/kernel.h>
% q8 Z/ m6 q. c#include <linux/types.h>
1 U. q# j# t6 N0 \+ _' j#include <linux/gpio.h>
~, I* g: ~* G8 i#include <linux/leds.h>6 L+ y% b& H/ h0 u$ a
#include <linux/platform_device.h>0 M( v& {; v( I6 \
8 G* I0 l- t) U# ^- I5 V
#include <asm/mach-types.h>$ ?, T, b9 o4 Y6 @2 I8 u& O
#include <asm/mach/arch.h>1 F" v7 b5 b: Y
#include <mach/da8xx.h>
- O4 e1 a M4 i8 V4 h% O. w& E#include <mach/mux.h># q( S5 ^" s8 E- @
; ^" F7 U. J6 V#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ h4 c' u3 `# B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 X7 D5 O$ M% A6 r% X" z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 g2 w" T. z9 o6 _0 V1 w/ \, A
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, @) G1 B* P% P8 h) A" W3 {& }
J) \& f, s! p/* assign the tl som board LED-GPIOs*/
6 U& ]3 S5 I1 J( V9 wstatic const short da850_evm_tl_user_led_pins[] = {
4 I# g6 l/ i! p1 Q2 i8 e, c /* These pins are definition at <mach/mux.h> file */
7 O; K, y) S7 i DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 a7 R2 }$ M( y& I$ M$ u: G
-10 x& k9 m" r1 Z! j- \
};
0 D5 [+ M6 b3 y% P/ j
4 G/ D1 }2 T5 A0 H, N+ O! |$ t# tstatic struct gpio_led da850_evm_tl_leds[] = {$ t' C) U9 k3 N h$ o" ~1 f- J
{
4 F- l' K5 P- I" k1 X .active_low = 0,* o |" m x, q5 m. ]7 v1 l5 v/ R
.gpio = DA850_USER_LED0, _8 b7 X, M3 @8 N3 [( u6 I
.name = "user_led0",3 X! G, d/ w' T
.default_trigger = "default-on",
# V# c6 c6 F2 p2 M },
6 y* r& C6 x. W4 E* Z& u3 C {
1 P1 y+ j6 X8 N4 P9 O2 f .active_low = 0,( N6 n* [4 e/ m0 _2 p: v) G
.gpio = DA850_USER_LED1,. F6 S# g6 X/ @! t1 |* l0 s
.name = "user_led1",
- G3 }# y' ^$ { .default_trigger = "default-on",
- N- H3 N/ J5 E/ ]7 c2 ~ I },
$ w( A7 }% x% m {$ k' L& I7 R5 Q0 G, {8 }- y
.active_low = 0,( Y& W! r ^9 e1 l" {8 ?8 ?
.gpio = DA850_USER_LED2,
7 k/ I- W! d& n .name = "user_led2",
: {3 J( i' h( r& m6 ~ .default_trigger = "default-on",$ K, q- a9 v% {: N0 n$ E5 g8 u
},. k3 g' Y* u1 ~6 q
{
$ t: H% g9 q# ~+ ]% ]/ u .active_low = 0,
. i& R0 Z; i& I .gpio = DA850_USER_LED3,
l; ?4 \7 p- p3 f# J% r% @ .name = "user_led3",
" u0 W4 }2 E$ x% B6 _, m$ X u .default_trigger = "default-on",
8 m! \+ j1 R& v K9 h },
3 t8 ~0 D' `3 Z! m, P% b' \/ j};2 o: N8 w" |' G) K N$ a
2 u5 q: U( m* q; Q; pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 y$ k9 d- V' {, Q3 d .leds = da850_evm_tl_leds,7 u$ t' T( r# _, a
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 s T+ w+ x$ B9 U( {& L
};
9 c0 } r! W" a% X4 j% }1 L& S n
static void led_dev_release(struct device *dev)9 O/ b# R0 F `$ d2 I$ t. ~
{7 d0 G( K) G! N# V
};
: R9 g' r* o! B: {& Z
. K, W( b7 \; Astatic struct platform_device da850_evm_tl_leds_device = {
\- S- B. ^; o- l0 k .name = "leds-gpio",' o; [; w& d, e
.id = 1,
) U$ j; b& _# b! I# q' @- s .dev = {* O2 }5 b" f/ @& B9 r
.platform_data = &da850_evm_tl_leds_pdata,2 U5 a9 t: {# d5 l
.release = led_dev_release,
8 i! _6 s6 Y( s' R% n }
; w3 z! G+ z# s) m3 u$ \};
: c. R1 T' b9 W6 W4 ?4 b& B- H/ S8 G$ E+ K" y( h
static int __init led_platform_init(void)& Q6 T2 c7 _& k( ^' D
{
: f2 `) X( H( l F( c* m9 R int ret;
2 _0 G1 z; d+ j) T; }& r#if 0% A- l2 }) E/ T7 c5 h
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 Z/ V1 P/ [% I# E5 u
if (ret)7 f5 a4 c: g* }4 \' V9 ^9 L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' d4 q; ^% {) P2 N3 {9 f& b/ V$ c "%d\n", ret);
/ k; _6 @( ~& i2 U1 {7 ]& A#endif
: D% \% m% i2 x/ C3 o ret = platform_device_register(&da850_evm_tl_leds_device);1 E0 d) A3 E! U! J
if (ret)
_4 t. a/ d z' y4 }! l9 } pr_warning("Could not register som GPIO expander LEDS");7 E2 E7 ^3 p/ E
else
7 P7 Q& X' v0 G" \' R: [1 }$ l printk(KERN_INFO "LED register sucessful!\n");
7 }4 O2 E6 t: L _ ? J9 A5 [ k) W2 X
return ret;9 w7 }4 g, m3 s X; A J
}5 s* o! j4 S1 `/ J9 A0 J
1 o1 Y; ]6 o: b2 X$ ^* j$ E8 wstatic void __exit led_platform_exit(void)
! a# j/ o' u2 z; V, X% \- L; f{& h; _- `7 J) {" ~/ B
platform_device_unregister(&da850_evm_tl_leds_device);
/ x$ p; W/ r3 _! Z, o
0 c/ n$ S f7 Z- c. x' @ printk(KERN_INFO "LED unregister!\n");
- d6 G7 h- u% r k5 B t1 {$ K}
- w& M1 t5 h; [$ O
@% F8 v j' Q) r8 }module_init(led_platform_init);
" d2 c( U) v0 O4 l( C1 p- ~module_exit(led_platform_exit);, @; n! W# X- D% C
. p7 d" e7 U8 }0 U) C
MODULE_DESCRIPTION("Led platform driver");
5 w$ K) k5 f4 w' R& _5 q. `MODULE_AUTHOR("Tronlong");
% e- X$ |- s( n9 hMODULE_LICENSE("GPL");
- f4 R/ w( A9 _3 B( Z5 j1 z
* r) s% y3 N2 e% g |
|