|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 J; b- ^& g+ g- I' N#include <linux/init.h>1 q9 B8 Z8 o7 f" j# \
#include <linux/module.h>
$ L# L$ d" Q$ ~9 Q; Z#include <linux/kernel.h>
; V7 B: z" @& E+ [( ]9 t#include <linux/types.h>
) A+ t& W( U' M: v) ]#include <linux/gpio.h>
) @+ S+ U8 A0 ^% y5 I+ h#include <linux/leds.h>, t7 J0 j! f+ U4 k) w
#include <linux/platform_device.h>4 O& e; k* z. @$ }4 e4 [$ X& J
' t3 a# p9 b; L+ _; d9 L# R#include <asm/mach-types.h>
& T0 k+ a. t! g" v3 y8 o, h#include <asm/mach/arch.h>
7 l0 T' _% ^# j#include <mach/da8xx.h>( |0 g7 ^0 L; u4 P, m6 s
#include <mach/mux.h>4 k. c X' H) `7 t0 F' o* D# o8 V0 u
6 q- _/ S7 O7 R, q0 O#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 V6 v& X8 u& D#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* i8 Z! j% s+ K9 n' v R2 k4 j#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! L0 k, F5 l; v5 I; _! v#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), R6 X3 S! M" W8 H: V( E/ n9 J* j
% e) [ u' P& D4 o$ _/* assign the tl som board LED-GPIOs*/
; V7 k( b& e+ g0 c- D# n6 astatic const short da850_evm_tl_user_led_pins[] = {
; S9 v) u7 O6 }: I2 t' e /* These pins are definition at <mach/mux.h> file */
8 r1 D! B' C1 O5 |7 E* f: L0 e DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 z/ p2 ^ j6 |5 D& q. ^! |
-1& N% X, |6 Z; L# k8 s- z2 n
};
+ z8 _1 F0 M2 ^# x+ b+ \/ V7 c, g$ `6 [: L
static struct gpio_led da850_evm_tl_leds[] = {0 [$ N: D1 @% M, r" i) U7 h
{
' v$ h# u: h i/ p4 d6 p5 @ .active_low = 0,
8 t$ [- K6 K8 b, W/ y; [ .gpio = DA850_USER_LED0,5 v( o" r% V v5 m9 d
.name = "user_led0",
* e1 U1 }! Q5 Q3 B9 g/ t( y .default_trigger = "default-on",/ j! t: M+ k: E6 }' t$ i6 p. t: Z
},
. k) n# J6 R9 R) U; A6 b {0 d2 K/ o n5 W8 ?5 e
.active_low = 0,& V8 p: @. w6 w1 m" I* O
.gpio = DA850_USER_LED1,. |! b2 C7 I7 m
.name = "user_led1",
# P- r8 b i Q/ }5 [& G3 } .default_trigger = "default-on",
( m$ m) i% i! L9 U5 E+ h },+ x0 m2 m' H! s( D5 e' C9 u
{$ Y" D% g2 c0 \+ b; w% i
.active_low = 0,7 z) ~6 _% ^* B1 l1 u, Q
.gpio = DA850_USER_LED2,
1 h3 v4 w0 g: W8 E .name = "user_led2",& I0 I" V ^2 k! J; m; Q- w
.default_trigger = "default-on",$ R/ w' N$ U+ u' m! d: g+ R# w
},
" i8 ^* c/ C0 h; [# Q- s2 D; c {
9 t- _( A, H) M, i: _5 P; C1 Y0 {% x .active_low = 0,4 p6 g# g4 b) Y0 E
.gpio = DA850_USER_LED3,
% `! n( j7 ~2 [! i9 D, L# B .name = "user_led3",
+ n6 B. e2 w( p5 G# |; D .default_trigger = "default-on",
2 W9 Y0 X# }0 ~, @, Y8 y$ P },
& b. g! f a( m4 P3 M c6 `};
- _. J0 l3 [$ a; B- a4 L3 J
& L& Z% H. _' E$ ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! F% A6 [# M! P" n .leds = da850_evm_tl_leds,2 ^! F" M$ C. ^9 A
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ P! v* O. o- w8 x! P W};3 U" b* u# R+ T6 e3 d
% `0 K8 |) m( U/ I) c
static void led_dev_release(struct device *dev)) R3 {$ h; z) p9 w
{/ o, m$ z4 v; z! k5 h- @4 r9 D) p* ?4 O
};2 w1 i: U* p+ ]- s; G% I8 v ?0 C
! f9 h2 T% K$ \3 V& O, d
static struct platform_device da850_evm_tl_leds_device = {
6 O, b2 u3 b; V .name = "leds-gpio",
9 C, J! i7 ^* X; o% o" q .id = 1,
" x. H4 p2 |5 @ p) L& \ t _ .dev = {5 f* n y+ O6 B0 {7 q/ d# g
.platform_data = &da850_evm_tl_leds_pdata,/ \+ \% b: l& J1 N
.release = led_dev_release,* `- d+ N- e. z3 j& c) i3 x& Q
}) w& e: A2 X( S
};9 E9 b+ ]4 L7 M
( u; l$ G: t l. G/ Nstatic int __init led_platform_init(void)
' W3 d# }& l# n5 l! S{
0 S) a0 N9 U7 d! {# X, A" Y7 O0 } int ret;
* s1 H o* p7 }5 O$ P#if 0
- C1 V# p) ^7 @9 c; r$ M ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
s: g' ]# v9 L/ ?% D. X. p if (ret)# ]! w5 w, Y- r4 b5 Z& h
pr_warning("da850_evm_tl_leds_init : User LED mux failed :" j( L! o5 I9 K
"%d\n", ret);
# N. A/ T; W6 `* Z3 j& o#endif/ x6 p2 A5 M2 @' u. Q# h
ret = platform_device_register(&da850_evm_tl_leds_device);
0 k3 h/ S4 q) e if (ret)* u5 W [7 D! O7 l7 {) W9 V" J0 ?9 i
pr_warning("Could not register som GPIO expander LEDS");
* E. v" s( S. k8 O else& b D7 d& m, w1 w5 [/ ^
printk(KERN_INFO "LED register sucessful!\n");
' ?+ |& T. y. @1 j) g: @+ j/ L% g" f6 H0 H6 {/ W9 B
return ret;% [4 [1 ]- R, I3 v7 d- r
}
2 p& P; E9 \2 ?$ |. m% n
/ N1 V+ R @: Y! e! xstatic void __exit led_platform_exit(void)4 F/ `5 A+ X( x/ ^/ k* h ^
{" ?* X$ k W! U0 Y
platform_device_unregister(&da850_evm_tl_leds_device);$ q; v( W: b$ }. ?: K# N0 p" P
8 P2 s; v8 T; l) f5 S. \4 e7 y. y printk(KERN_INFO "LED unregister!\n");/ y6 l) t& W- m" y1 E5 Q7 S
}1 x/ u, f) n- T' ~- p& ~) W# Z9 @! O
# p, K Y1 v# a, x
module_init(led_platform_init);
- l9 l. r. P. t8 s& G9 ^module_exit(led_platform_exit);
: V0 K3 g7 G! R/ N' \
6 O- p; Z2 t& C- dMODULE_DESCRIPTION("Led platform driver");2 u) p0 m8 h) T( ~% U
MODULE_AUTHOR("Tronlong");) k3 q( I7 N5 G! i8 m6 `# C
MODULE_LICENSE("GPL");
2 X' C- X- k6 F3 n4 z: f$ h8 Z5 t" b1 U& W1 m: R* D: P
|
|