|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 G9 h8 T( b" @6 u2 J+ P. v#include <linux/init.h>/ s' ]' a6 U1 O$ R0 H
#include <linux/module.h>1 n, W" x$ a' h/ B e" a4 j* z" p" ]# ?8 f
#include <linux/kernel.h>, ?5 |- Y) D5 P
#include <linux/types.h>
5 V3 E1 @0 M$ R& M& S2 M9 W; N+ ]! G#include <linux/gpio.h>/ l1 s$ y5 B# U0 |; }
#include <linux/leds.h>
( C. x0 k. R: y$ D6 k! A#include <linux/platform_device.h>" C% ~" q# L: a; V$ o" c
$ O* _* Q- I0 f: ?
#include <asm/mach-types.h>9 t4 c/ |+ q' g* g3 c7 y1 `
#include <asm/mach/arch.h>9 P% l0 E7 d, N: d9 C; G9 Y7 u* v
#include <mach/da8xx.h>1 z P7 F& `' i8 E- k! {& L; x$ K
#include <mach/mux.h>, ]$ K0 P! H* y: P- G8 P
2 O& \1 m5 ]$ }# W3 k8 N3 `
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% `+ w/ ], A( m7 Y# ?
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 j) i( E. H; \" f
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 u# q8 J8 {' H! \$ Q8 J
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 M9 {) l2 V) `2 g9 ~% k6 i
2 ^8 p# R8 B9 A% d8 P- g& M/* assign the tl som board LED-GPIOs*/
- K9 d8 V0 I$ A+ x7 i& b( Zstatic const short da850_evm_tl_user_led_pins[] = {1 f7 R" A- |& h' L% [+ _2 |5 j$ u
/* These pins are definition at <mach/mux.h> file */
o' Z9 l0 Y) W DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, s" w, J8 q5 i4 J
-1
* @. @5 G d* z- O9 _3 n7 q};+ y1 s) y/ _* o7 F. o# o! G
- g9 G7 i1 N( m; y; I8 ?
static struct gpio_led da850_evm_tl_leds[] = {
# f5 I! a8 r( o: T G6 _ {
- s" W. t9 O, ]6 B6 C4 V7 h j .active_low = 0,* _( D* h; V. M% P- V$ {8 ~
.gpio = DA850_USER_LED0,
) }% b7 I& n& e! k: o4 J2 t/ ? .name = "user_led0",% }; ~% i' ^9 Z$ O8 }
.default_trigger = "default-on",
* J0 H; `8 P1 _/ W },
" c. i& s6 L8 [4 I0 E {9 X/ n& J* k3 |: B
.active_low = 0,& z4 X% P' u( x5 H7 U
.gpio = DA850_USER_LED1,& E3 h8 b, Q' p& \
.name = "user_led1",3 I$ d7 W8 k9 O& G
.default_trigger = "default-on",
& [0 Q* A8 A. I0 T/ ]3 I! a! ]4 d },. j7 v/ i2 c i- D- j8 a
{
% C' M1 `8 L' s( g .active_low = 0,
& q; o' u) J+ t. Z6 ]& B! h .gpio = DA850_USER_LED2,
0 ?; S6 T0 m/ j/ p5 F: V$ f+ m) Q( ? .name = "user_led2",# O$ [( t, O! u- r! C
.default_trigger = "default-on",: |# A; Q$ Z5 N& b
},
5 Y2 a+ r; \% E3 w) q0 A/ Q {. V+ R! y& k9 g" ?- J7 N
.active_low = 0,
3 h4 v6 L' b$ s. H; q8 s .gpio = DA850_USER_LED3,0 }0 P4 ?, t9 _- d: o1 U
.name = "user_led3",
! k5 s# r( q: o& V' v5 U4 @ .default_trigger = "default-on",# t, ~& @# q7 ]3 y
},. m0 C/ H$ M8 u4 |, G. J
};
3 L6 b# }4 R4 f& E
1 g7 k/ @" }8 ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- }+ w6 a/ I$ [; N5 A
.leds = da850_evm_tl_leds,
- c" A$ k- i; K* R .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," J9 q# r, z n% M5 A
};
, N* ~; m9 P# m/ V
' _2 h( G5 i( o: Y0 }4 l; q+ k" r) ~* ^static void led_dev_release(struct device *dev)6 z+ y! b% Z( j
{: C4 e5 D) r+ Q7 E: l5 y* Y
};
M6 X6 o2 H* f* I( Z/ m
. X1 ?5 R+ A/ p# m' Astatic struct platform_device da850_evm_tl_leds_device = {
2 b8 x# G7 k/ b$ v .name = "leds-gpio",+ f! n% E* N9 E
.id = 1,
# L; g$ a) g) n2 D6 e* B .dev = {8 o4 `1 n1 A# ^ i! S8 k
.platform_data = &da850_evm_tl_leds_pdata,8 }3 x$ R# I, q3 i6 z
.release = led_dev_release,
" Y5 v6 M$ p. j8 ] }6 N8 G; B, w1 ~5 V; M; K7 m i/ V# S
};, V- B: F* B6 ~2 N% _1 s2 T
8 }+ \: F/ H) O, s+ s: K0 s7 V8 ystatic int __init led_platform_init(void)
( W& N3 W5 N' }: H) i0 I" p{
C8 R9 n8 i; }$ ?& q int ret;7 Q- m8 }7 J" u6 E" a% \
#if 0) l) v( w% }) R
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" ]# `9 ^0 Q) ~2 J- z- _: i if (ret)
5 |* u( J# y0 ]8 h x pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 b$ P' I9 Z$ p8 O1 N* m "%d\n", ret); v% O/ r) n6 V; u: c3 J1 V' t: n
#endif
) n+ p, h1 Q- [* Y( X, m ret = platform_device_register(&da850_evm_tl_leds_device);% y( S; ~$ g! |) u3 D
if (ret)% s4 [% K3 g/ J' N% I
pr_warning("Could not register som GPIO expander LEDS");$ h3 f" e/ y) _. Z
else
+ i; T" w6 O) ^6 V6 f# ^6 H printk(KERN_INFO "LED register sucessful!\n");
/ l/ ~2 l' }, Z% a+ W2 W( J( O& ^/ J0 b9 ]1 Y" n, M% f. O7 K
return ret;
; i3 X4 n9 h$ [) h. x}
/ x8 r3 {8 K% B3 R* t
" h( }1 `$ r3 Q& ]static void __exit led_platform_exit(void)* i3 ]8 w, }, r: Q) t
{
& F; p- d* E- C) X+ l( L9 m1 i platform_device_unregister(&da850_evm_tl_leds_device);
0 E9 ^/ j+ m- ], `1 D4 ]
0 U* d# L0 I9 `; ] printk(KERN_INFO "LED unregister!\n");. H& D5 f9 `+ g$ n- J
}
" c! h) |# D; f" X9 n# |8 h' z9 T( p% f2 F* o& ~
module_init(led_platform_init);6 r4 S: d5 \0 o! Z
module_exit(led_platform_exit);5 J5 E- X q- y `; r! V
; ^1 b1 K/ u7 o# i7 i
MODULE_DESCRIPTION("Led platform driver");
/ V$ N/ U, J* v% F1 T4 oMODULE_AUTHOR("Tronlong");9 A+ `7 Q9 N4 F* ^' w
MODULE_LICENSE("GPL");
$ a3 P0 m, v* ?3 e6 M7 s. R. x- ~. ^! N& r& g4 S' T2 |7 n
|
|