|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; A1 C& n0 @2 X/ a' [
#include <linux/init.h>
( Z% T4 h, P$ K2 Q; `' V#include <linux/module.h>0 ~" R+ G) c$ p3 N) ^) B
#include <linux/kernel.h>
% @! S! N9 h/ s/ ] Q& K#include <linux/types.h>8 R; n V; h, z# b3 l$ W& x
#include <linux/gpio.h>" `; f3 V1 ?8 w6 z( z `0 Q( ?
#include <linux/leds.h>* }) g$ Z/ W( U
#include <linux/platform_device.h>
" k- n& W+ b- E7 p ~3 R1 f: K% l
4 f0 u% {. X- a; P& F#include <asm/mach-types.h>& k. P! Y$ }. l) U2 p/ Q* }
#include <asm/mach/arch.h>
# q2 L o1 Z$ i6 |#include <mach/da8xx.h>! I9 l- E" [" L4 c' F) h
#include <mach/mux.h>
8 [# q, g4 p/ G' z5 b: d5 i M2 P: n2 v, l! U" {# L u* f% A% n/ C
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), ^- c" _- j$ |( U2 @" m
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ {5 F! N' b1 G; f9 d# Y( K#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: O s9 a& h( m' h% |1 H#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# E4 ]7 _# }0 e- s1 ?
- }3 M+ Y1 \) ~. ]9 v* v( w
/* assign the tl som board LED-GPIOs*/
/ y, T5 ?- l' dstatic const short da850_evm_tl_user_led_pins[] = {
& i& p: ?$ X" s- _ /* These pins are definition at <mach/mux.h> file */
( s0 r3 c1 r; b1 H6 W* V DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; d8 z3 H! r3 J
-1
5 h: t8 l3 @9 Q. h0 X! j9 @* D+ N/ z};% Y2 a/ s9 m4 D# x. j% z6 y9 u/ w9 j
# J5 C, D8 V& j2 r; ?1 f
static struct gpio_led da850_evm_tl_leds[] = {
# W& b5 r8 D" J3 @1 u( \1 p {" }( I& t, B/ k+ R0 E5 u* c
.active_low = 0,
- M$ b8 O, D8 i9 H0 a' f+ J .gpio = DA850_USER_LED0,( ^& f; [( g2 G/ k6 _9 C* m4 V9 e
.name = "user_led0",) G8 ~ y* V# r$ O3 I
.default_trigger = "default-on",5 t0 c& e# Z' ^$ i
},% I+ B% V/ `# W! t! |9 q1 X, j
{
% v6 U# L; e @( s/ R9 z, o1 I .active_low = 0,
0 S. r2 W) H7 i2 T& B* k& \7 d& s .gpio = DA850_USER_LED1,
) H3 j) `4 x5 V, ]4 l .name = "user_led1",
' {2 C/ w9 j- w .default_trigger = "default-on", O6 Y! \1 Y& H- s
},
- s- }0 F `4 V2 T {
& P& q% v2 r; b7 g' L% V- G .active_low = 0,8 S0 l$ \6 o& O* p, d
.gpio = DA850_USER_LED2,/ `- J6 }7 {8 A9 k5 X
.name = "user_led2",2 M* [( a- d7 Q
.default_trigger = "default-on",
( J7 C; h3 i0 v+ Z$ v/ x# H },8 f$ r. C8 O$ p$ r
{; M0 A) [0 N& b, a& W/ ]' B2 K3 F
.active_low = 0,1 O; t8 D+ e9 n
.gpio = DA850_USER_LED3,8 O @; I& d6 C: P
.name = "user_led3",3 I: k9 L; U0 j" D1 v
.default_trigger = "default-on",$ d. V6 @, ]- M$ f9 `
}, H! C5 F5 C6 N: p
};
% _. ^5 _" B. z6 L% D. O2 p# K" c% S' c. E# S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 I0 [ j* A4 N5 g% P% a+ q! s% }- F .leds = da850_evm_tl_leds,- f, q0 V3 V0 D9 x! o4 O) Z% x
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 ~$ t2 D4 i) g0 j% \};9 z: _- n, V3 R! ^
: s# N* _+ r1 m D, ^static void led_dev_release(struct device *dev)
! ^6 G: M9 D7 a+ M5 I. e5 x u{
% K% K B+ ]2 I1 U/ e};+ e* A; _- {! H7 E$ y9 [, B- R! X
# E4 r3 _7 J+ l3 Lstatic struct platform_device da850_evm_tl_leds_device = {
6 L& s7 T" b8 d .name = "leds-gpio",
F4 t3 [, b! O& f# E( ] .id = 1,
0 k: Z: G! w! P, U9 v8 _1 [ .dev = {+ o1 m2 z/ Y4 ]( A
.platform_data = &da850_evm_tl_leds_pdata,
! X* w$ z( J! E& P# h .release = led_dev_release, q V: e* B* s1 {
}
+ _4 ?' B! ^% s9 H& e1 U) a};
$ s: Y# f, A; |' P$ c {$ x: \2 S1 k$ s/ s: N5 l
static int __init led_platform_init(void)
+ m& V% K) O5 {2 D( Y{* Z! X" B1 M* n( v+ f
int ret;+ n8 L" M( p7 n, o
#if 0! X b' f6 ^/ G$ F! ?5 G0 {) z% j
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); G) F2 s3 Y+ y
if (ret)
/ A" Y# c1 K/ z1 s7 S7 V: T8 I pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 Y1 J2 L( C/ i m! d
"%d\n", ret);% f$ q6 `0 ]8 x* z' q, H
#endif
8 ?1 e9 H9 y! u: p ret = platform_device_register(&da850_evm_tl_leds_device);; m2 r# b c1 R4 G( a
if (ret)# l9 M+ a' h* \" R0 u5 }
pr_warning("Could not register som GPIO expander LEDS");
! x% H9 |' d- _ K" ` else
! a1 \6 R: t, i1 i: b& { printk(KERN_INFO "LED register sucessful!\n");% N. M5 j& @. F4 R
, G n; M% C" H+ }2 Z) T u7 v
return ret;8 z: ?& o) X/ l1 s) {7 Z
}
" F- `# B0 ^' `2 O% l: z0 y$ P' c" q0 Z s% [* z7 g: \
static void __exit led_platform_exit(void)5 m0 {" F6 U- d6 L1 _, U9 n6 X8 p
{: C/ j/ E5 T$ F
platform_device_unregister(&da850_evm_tl_leds_device);
4 ~4 C& [( Y% u/ B3 Y/ N" E0 ~8 {! A6 m2 @
printk(KERN_INFO "LED unregister!\n");
4 @( T7 a2 e# ~+ N) ^+ @+ m}/ a C4 V7 z1 _; U! s/ b; @
* q& S- }4 G# c8 r) Q
module_init(led_platform_init);
5 Q3 `1 u: r6 y. U1 e) f7 T' \module_exit(led_platform_exit);
) g1 L& j' Y. J& c; N# x
. I$ _ d1 S1 {4 e+ \' vMODULE_DESCRIPTION("Led platform driver");; H4 P/ F5 w* \8 ?0 `9 [
MODULE_AUTHOR("Tronlong"); a/ N% s/ {# N
MODULE_LICENSE("GPL");
4 E( z% \% Y) x: i, ~( Q M, j. D; I' i. J
|
|