|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% {" A8 i v3 e8 o; k#include <linux/init.h>
* ?9 y( y2 H3 o( n2 s7 Q5 F3 Q#include <linux/module.h>$ x- A6 ~% i! h5 m
#include <linux/kernel.h>
8 i. A( P( ^, G#include <linux/types.h>
) F/ D5 P% D/ u W5 h#include <linux/gpio.h>0 U& E$ J z" G! H
#include <linux/leds.h>7 q& T: Q4 I3 o) H
#include <linux/platform_device.h>
^( U$ V( ~9 ~! D3 X* Y# a( A$ Y4 R# W
#include <asm/mach-types.h> Q' r3 i y; I3 ^: b& o: K
#include <asm/mach/arch.h>2 V7 ]! m- p" q2 ~
#include <mach/da8xx.h>
) |! G4 x h$ i#include <mach/mux.h>/ t. Y9 }0 e# ^. ?; h) {
: s" u6 p: \. L0 P/ ~
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& F& v$ h# s. q# ]4 S; n' T#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 k* C+ d1 h1 m6 H7 Q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 R* b5 l$ d4 E9 e. m
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 | h& {. d+ r% }2 C' i! c
: e a8 r; a' R/ X. S& }" [/* assign the tl som board LED-GPIOs*/( x s! N$ m) o! S8 ]3 j
static const short da850_evm_tl_user_led_pins[] = {
% c S, l- D! I$ a; g2 P _ /* These pins are definition at <mach/mux.h> file */: ^, ?5 A% Z. p7 `, v0 _ U6 b. Z" t
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ G2 P0 J8 A2 W: N -1
" p: D2 U: D1 F/ r) O9 f};; p' L8 L! E# G1 @5 o+ W
# _" T4 w( p. m. d. g& k1 N dstatic struct gpio_led da850_evm_tl_leds[] = {
$ u! C& M; B- G. \0 M {
' q' v: ~% l1 c: Y* ^ .active_low = 0,2 E0 K3 a2 T: `% T. H7 A2 S1 s
.gpio = DA850_USER_LED0,+ A9 j9 a x9 z
.name = "user_led0",
& y+ \6 W& v& E W$ _$ e+ J .default_trigger = "default-on",
{9 D! o- \% h },
0 ~$ N: A! g! o- ~$ v, N3 F4 M {) }- J, [. w$ u+ A- |. ~8 U4 V
.active_low = 0,
* n0 r& E, H( X# y) x5 ?# f .gpio = DA850_USER_LED1,% l5 G6 @8 F4 N |) p& T
.name = "user_led1",. A9 |2 j* `1 w' N
.default_trigger = "default-on",$ S4 C6 d! w" W7 h2 Q9 M( \0 S
},
+ o9 f9 R; d9 ~1 @6 w {
) F% Z' s; }; Q8 U .active_low = 0,: n; f4 z* n/ N$ M
.gpio = DA850_USER_LED2,% I8 a6 V0 s- ?; \$ j: Y# G
.name = "user_led2",
3 B( f' V7 r( A( y4 B% F8 @ .default_trigger = "default-on",: Y+ i* r3 I% ]7 t7 X- I n5 i
},
! c" ]9 P& C/ L% X7 W' H {2 L$ E1 T6 q9 y5 p S
.active_low = 0,* B+ ]- @. P/ R% n8 n8 K) C% z
.gpio = DA850_USER_LED3,
" h; ^2 r8 w' k! ?/ z& c .name = "user_led3",
7 H& f+ T* G! X+ c# i6 j S .default_trigger = "default-on",0 V9 b5 p! j( A5 Z
},
( k" c7 q# U3 S% ~* w; e# V};/ N! U( |* Q3 V9 D
& E4 N4 i; u- c( Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! n% N- u' l8 P. @ A8 o .leds = da850_evm_tl_leds,
) `2 p6 V& y: u3 l! f" M- l, Q! x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! r& S2 `6 V; M e3 `' U
};- J6 p% g3 e2 p. m3 q$ k. X& _3 x
) _) v- K. z, g6 ^# c+ a; @; ustatic void led_dev_release(struct device *dev)& \: O; y. K0 m$ I. d5 l" D; u
{, O. @* Z5 ]- w, v: C
};
- ?& a' r) Q) ?) e+ A2 U0 H7 S. r' f: \1 J
static struct platform_device da850_evm_tl_leds_device = {
) H2 W- A% d' c5 n& e m! _' M .name = "leds-gpio",
; f7 r9 P$ `0 i- F .id = 1,
4 w8 P$ Q$ M. ^) F& ] .dev = {
3 @6 w5 D1 y* H5 V- C. Q% K .platform_data = &da850_evm_tl_leds_pdata,
$ a0 ~8 S. h' P& `# \: a" s$ @: I .release = led_dev_release,
" F6 [: L, k$ E6 ~, G) i }
% g% x& H. N. V1 I1 N! G& Q};5 K, O% z+ w" u2 R& k
+ r) @8 G& _& ~/ Z
static int __init led_platform_init(void)2 d; C5 {) E* v0 s5 _% T
{/ P# {+ I& m: L, Y
int ret;
2 W5 M% J `; v#if 05 E a" f& X, d) Q' t
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ y. ^9 ?8 b' ~4 \( N+ x: [
if (ret)( H9 |, \1 k8 C Z( s( {* y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 N2 ~2 v6 s# ~
"%d\n", ret);# W* g P( D& R5 ~% p
#endif* l3 J, |1 F6 S* I: z- H
ret = platform_device_register(&da850_evm_tl_leds_device);
1 @$ S4 l# v3 x# Y1 v( v if (ret)' t" V2 S: b& ~ \: C
pr_warning("Could not register som GPIO expander LEDS");$ d: |. E0 _. _) b. @- U9 j, n3 `4 d
else8 ?* V+ {- {% c6 q) g' N1 Y0 `
printk(KERN_INFO "LED register sucessful!\n");
% F& ]! ]& {% ]- G i& H. z( b, H, R7 Q! l( Y
return ret;
2 z' e4 I# H. ~6 G$ [# X. ?' O$ k8 ~}, s8 x: e3 w& a
3 H, e4 Q" t+ \' ostatic void __exit led_platform_exit(void)
{2 V. A/ K, O/ o# E{0 ~$ S* h" m7 D% x& S. v9 R9 g
platform_device_unregister(&da850_evm_tl_leds_device);8 f5 [1 q0 J! ?# v8 V- x
/ x+ }2 H8 \5 P) m$ W+ a- { printk(KERN_INFO "LED unregister!\n");7 n8 U# ^2 l& n, V7 V8 P! |5 A
}
9 n& P# p9 V' O! ]; G- \* Q- z
' l! _/ t8 b* X0 wmodule_init(led_platform_init);
0 |5 z l, u( A P( F0 P, `module_exit(led_platform_exit);
9 L2 c- v3 U: t5 F/ R l2 m* P* u
2 \0 S/ e# }6 |# b# VMODULE_DESCRIPTION("Led platform driver");
1 I, O# m% s, d7 S3 ^5 C" vMODULE_AUTHOR("Tronlong");
. s9 m% ~5 s; F. CMODULE_LICENSE("GPL");
) F# k: b+ V2 f7 _6 ?( \
2 _ r3 y. h& ~! j |
|