|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 w' t) u F% S* ^( C* }8 T- b5 C
#include <linux/init.h>
' p- ~* t7 n0 s2 ?9 U#include <linux/module.h>4 a. H7 z% a! Q/ m ~! D# _
#include <linux/kernel.h>
- W a7 _: q& A1 _* l6 L#include <linux/types.h>
. h' n0 Y8 J% t9 R2 T#include <linux/gpio.h>* o, I/ S! W# S& ~7 s, e
#include <linux/leds.h>
* F# i8 n5 Z( O+ Y3 [0 M/ r#include <linux/platform_device.h>+ Q5 B* c2 ~9 ?$ ^; o) F9 J8 H
0 P7 a3 H# S# W4 x C7 k- b% [#include <asm/mach-types.h>6 T, y% \! p" T% N) l4 R
#include <asm/mach/arch.h>
6 M" v0 ?) ]4 R" Y9 C8 Y2 Z& e#include <mach/da8xx.h>+ Z$ \$ C, B1 @) f3 J1 X1 `" J
#include <mach/mux.h>* I& v1 z1 I( g7 ?8 u, ~, F7 P
2 |& g5 W. ^ q1 s# I: e7 \
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( N3 Z5 w' J. N2 J: ]# b#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 j& }" A) F! W! Z% ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 q# ^0 j; _& q# O7 @. e- s" K#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
_. P+ g0 P- x: h+ N, m; |1 A1 m
/* assign the tl som board LED-GPIOs*/( p1 H8 [9 ]: c9 I0 S0 B& ^- w
static const short da850_evm_tl_user_led_pins[] = {5 G& k3 X# F0 ]1 e
/* These pins are definition at <mach/mux.h> file */' ?9 S7 _# {% d! g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& b' [& q$ C2 T5 D( N$ A5 t$ {+ V -1& M; ]. i. e* ^! L
};
N& J/ d) [# }6 D; x. v& l. I# k% F" T1 L% L
static struct gpio_led da850_evm_tl_leds[] = {$ w q1 ~6 C- j0 T+ H1 w% b3 }# A
{
( l: {8 T; z, [0 a& ~- a .active_low = 0,
! u" J- K. N3 }; Z$ ~- V2 O. a .gpio = DA850_USER_LED0,7 g) A$ R$ {- T" z5 C2 v4 P% n
.name = "user_led0",
v. i2 x1 O3 C .default_trigger = "default-on",. a: w6 K; `+ t+ Z6 |# F! X
},/ `+ Y0 C# D' {' H% E. O: ~8 P0 [/ L
{# R1 Q* L9 Z! m: W
.active_low = 0,
5 H! K/ P+ {$ D7 [ .gpio = DA850_USER_LED1,
. I6 u8 m+ T' u9 C* H .name = "user_led1",
/ G7 W% {# ?$ s .default_trigger = "default-on",
c: N8 d, a7 b; o& p },
7 z+ y* E& R2 }( J/ T# V, S {2 {$ T5 T/ n* }" ^. }+ Y
.active_low = 0,
3 Z: o9 }" h. Q; {# r! C .gpio = DA850_USER_LED2,
) D5 [0 K9 u7 N- l0 b .name = "user_led2",3 Z+ M% L; `. X0 i; O; e+ G
.default_trigger = "default-on",
5 o8 O; q. [/ J# `/ t5 E },
# L5 X4 y2 C4 e- r$ X+ g7 P/ } {0 p- h" l" ?0 U" k
.active_low = 0,$ y7 N1 B5 e" M2 W! g) `
.gpio = DA850_USER_LED3,
6 {$ @- p Y% k& R% f8 U .name = "user_led3",
8 L) G' n" f. Q& h" b .default_trigger = "default-on",
7 ^1 S g1 D' I% ^9 f },. J$ g2 P6 o% ?$ O Q
};
1 Z# Z) G% n- U1 G9 P
( {3 [3 |3 T7 ]static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 z' g5 g* J1 M" @, u .leds = da850_evm_tl_leds,
( n4 W& {4 S; T. l- l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* c" j& n$ Z/ N8 V
};
1 R" Q) e2 l% y! J2 W) ^4 G9 Q4 ~" s2 D* ?
static void led_dev_release(struct device *dev)
, B" G5 s. l9 O1 F: k{8 n9 T% v; {* x- Q
};
# Q- H* U/ c, q. S# ~
$ Q0 P- P$ J! }# k2 r( |$ fstatic struct platform_device da850_evm_tl_leds_device = {1 x9 K3 O& ~$ w( R4 Y
.name = "leds-gpio",* g. U* A$ o9 p2 N! ~6 g6 q+ C
.id = 1,) Z8 d; X. e5 \% J8 y6 @
.dev = {
( Q* P# u# b9 L4 f' l# p .platform_data = &da850_evm_tl_leds_pdata,
. I; x; \) Z4 c: F' w5 L V .release = led_dev_release,% Z. w) n+ U% u% |3 k' V2 U
}! K3 t; K% ^$ w, C8 h6 f
};
- C" U- n+ E8 E" `. U4 ^( [% |; G$ z+ n6 c
static int __init led_platform_init(void)
6 f Z+ b6 J% J! A; U" q{
9 r- P e0 X2 O+ l" w- Y9 [ int ret;
; n R# l. v7 q5 e) M#if 0% x0 i+ ~5 Y" v$ ]: ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ w; K2 C% Y- L3 q7 I if (ret)$ R! f( Y( Y5 g" ~/ J$ C1 y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' M O% |' [# A' e1 _! s5 {& \
"%d\n", ret);# d" s- ?2 F, H4 G# [9 P
#endif5 c2 L0 Q f t% g
ret = platform_device_register(&da850_evm_tl_leds_device);
) h! m" ]* U8 l. K if (ret)* P: r* {' E' D! A+ d) U5 _$ G
pr_warning("Could not register som GPIO expander LEDS");
8 M; r4 Q- ]/ n @ else% Z! `" |, E6 }, }' O
printk(KERN_INFO "LED register sucessful!\n");8 {- x3 c1 u1 F* E1 K
0 z! T1 G$ S, O3 f ~$ z, x return ret;
0 H; k5 z" c$ F2 ^# @( R, y}
. \. i4 M9 M7 I$ z, b Z) ~) T" F: z
static void __exit led_platform_exit(void)
: X/ V9 m) w4 _- j4 J2 L$ L{
F) S$ a4 f# g3 A platform_device_unregister(&da850_evm_tl_leds_device);
7 v4 Q- O$ D! m& N- q1 O. m& j+ `" ]2 h' M/ k9 n* O
printk(KERN_INFO "LED unregister!\n");
3 S( V' R% O! p! m, U$ ?, Q' ~}
W6 o' q6 e( q# C1 W2 D# X
0 Q0 q, Z! W4 amodule_init(led_platform_init);
- Q& k0 w: N: e0 D' xmodule_exit(led_platform_exit);7 ]! v3 Q) t6 f; i. D3 W; ]
2 ^% ^( G2 s+ q3 G A
MODULE_DESCRIPTION("Led platform driver");5 V) H" h" {: D/ q5 W$ S$ Q
MODULE_AUTHOR("Tronlong");1 X5 @, t8 L, |% B: I8 x' f8 a8 l
MODULE_LICENSE("GPL");
2 R! T6 ?# b% f+ ?9 ^
0 R" W- P* Z; a3 b: R7 Z6 P/ K+ z) d |
|