|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; R! S' J# b6 \! }# l) F/ x, `
#include <linux/init.h>! }/ O7 R) l; h P5 n, [( M
#include <linux/module.h>7 @- e: J" b& S
#include <linux/kernel.h>
/ o" w6 ^) [/ H8 @4 Y: i B#include <linux/types.h>
1 f7 L# w% m3 h! I4 V/ M5 J#include <linux/gpio.h>
( G( X& N6 J9 X1 X/ ?3 s#include <linux/leds.h>
. M# l" o) j! r#include <linux/platform_device.h>
- }+ s2 I6 S' l8 K
/ J( k; _- r6 w( n8 {#include <asm/mach-types.h>
& A `, ~ U8 F: [* L#include <asm/mach/arch.h>
; T( I, q- Y6 n#include <mach/da8xx.h>
. |: x5 k, Z! w4 Q W#include <mach/mux.h>: M9 R' ~ x; w( F* b9 Q
5 l+ B! V* g- Y4 P5 K& i2 Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- n4 G5 r; m& |- `. n#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 d5 `: d5 c3 j1 ?* L: {
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ P8 V# `; ?. ^: a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 v. k0 \9 i; K6 L% u4 l
& Q& G8 X; E$ t6 @/* assign the tl som board LED-GPIOs*/) A9 f( g$ c: }+ @
static const short da850_evm_tl_user_led_pins[] = {" I7 A: f4 i& A3 ~" R
/* These pins are definition at <mach/mux.h> file */
6 m# `7 g5 ]/ \2 Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, ^! |" t0 R. W1 ?0 r- i -1
5 K- P$ y) r& k. y. T t* k};( d; g1 r, l) p1 @" m
+ ^* f n; j* y/ T4 L
static struct gpio_led da850_evm_tl_leds[] = {
; d6 x4 D& n# J) V5 n {/ V! p/ _9 F/ i `8 | g5 Z
.active_low = 0,
6 F$ q- F$ y+ T3 M/ N" ? .gpio = DA850_USER_LED0,2 c5 D6 K1 X% E2 Q4 b
.name = "user_led0",
0 @$ U7 ?7 _9 N( p( | .default_trigger = "default-on",, h) a& k8 r' U9 E& R
},
5 K7 w' R9 K e* [- h% V! D {/ ^; c3 i1 [, s+ K6 g* W
.active_low = 0,
$ R! R! f; g# N# l1 [1 m .gpio = DA850_USER_LED1,: Q/ Q9 v" z3 l: L
.name = "user_led1",, d G4 d9 |6 I" g$ e" Y
.default_trigger = "default-on",
: D" U$ L7 U5 [ m P+ }, ~ },
0 L( p( n( h Y, D* L. L' h {
2 J/ N c9 _* |% J .active_low = 0,
+ }* N$ G3 |: e3 ]) Z" d .gpio = DA850_USER_LED2,1 y) T8 B9 Z7 }, H: I0 Y
.name = "user_led2",
$ c4 @2 f& `" C& I .default_trigger = "default-on",
1 o O9 Q: g) {2 j' P* t6 h/ _0 z },- L& E3 u+ h0 k: a [
{
4 W4 v) X1 e, ~% X8 B .active_low = 0,
0 V- S( p, B1 i: r .gpio = DA850_USER_LED3,
, o3 `* t8 j4 H4 a2 t, d- S .name = "user_led3",4 j2 x) |& Q' V8 \. Y; V
.default_trigger = "default-on",
: b# y6 ~* i7 r- c- l3 }: d4 g5 R }, W3 c+ G& Q, {' s t( p
};
o+ f! @1 E. U7 E
/ }$ T9 k% ?3 z' l, P9 Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 s: [" A8 c; F6 P' I) m .leds = da850_evm_tl_leds,& W* A( l0 F7 }; o9 O
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),& O ~; k1 Z2 D$ f$ |% E$ l1 g0 J. |
};/ d+ `# l( a& _
4 P" ^/ ~- y9 ]! Kstatic void led_dev_release(struct device *dev)- G; @8 P( v; `
{# \/ C7 N* o! g0 ^
};
* r, Z6 v, N) z7 L/ k0 d9 B; L
0 p$ \, \/ `' O4 w6 }! m: I6 n9 nstatic struct platform_device da850_evm_tl_leds_device = {: y( C! _ T1 Y* t: S0 a
.name = "leds-gpio",
1 ]. b2 o- |+ d' D .id = 1,
# F1 P1 w* j9 E( n: [ .dev = {4 W& z& q4 u4 g0 A$ }+ x
.platform_data = &da850_evm_tl_leds_pdata,6 T0 u) g. e0 J
.release = led_dev_release,! u7 _) T+ b% B
}+ i! T0 N+ V( ~( t7 Y( D
};7 O* |, D4 m3 X% W
8 @; Y1 |, p' f/ Q: [0 D& Lstatic int __init led_platform_init(void)
9 I9 L% F. I8 E) w) J{
5 n2 e4 Y! b# [8 k' @ int ret;
' w3 k, C! c6 i. x#if 0
S S" f$ n, s- a: ] ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# }$ p; b# H4 ~5 m. n; i- t" _ if (ret)
: t6 d. A; I' U" {% t( M6 x- f pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ y9 B; }) O+ B! @: G! Q7 X
"%d\n", ret);
0 Q3 B; S" L. y#endif
; H9 j! \- f) F% z7 |/ l ret = platform_device_register(&da850_evm_tl_leds_device);! A/ I# C6 }6 D
if (ret)
8 r. O) a- r( L) f+ U5 u& n; k: Z pr_warning("Could not register som GPIO expander LEDS");
, j1 Z. @% Z; l# G) P: x- v else
$ H9 D% q- O6 F D" U, k; K& b9 w1 y printk(KERN_INFO "LED register sucessful!\n");; g# \; n% w% ?3 m$ a3 Z
, j p, B+ X7 M; e
return ret;
' K' ^& J# x( t9 b}
0 R! n" j- l6 G# e
$ Z m n$ V" Tstatic void __exit led_platform_exit(void)& H: d& g& Q; d5 X+ K2 D
{
0 W7 Z# t" ]6 D4 d* ^/ R7 H platform_device_unregister(&da850_evm_tl_leds_device);7 ~% c; \4 s0 [
, A9 w l- |! j- f% g0 ^" D* K
printk(KERN_INFO "LED unregister!\n");& q2 M2 m- {5 d9 }5 p
}# o( b& F& W6 P8 J
' B4 I0 `' d b- J2 l, D
module_init(led_platform_init);
6 e) H, z9 X- w$ t2 Nmodule_exit(led_platform_exit);' p& a5 R& R8 ^) F0 } D& K
5 I; x8 W8 J3 M: ~0 b5 l9 `
MODULE_DESCRIPTION("Led platform driver");
# C; H: W$ e' i5 KMODULE_AUTHOR("Tronlong");
# E% n0 X4 w, Y: b( CMODULE_LICENSE("GPL");5 r4 x) z& C4 Q7 z4 H
! m9 N" f2 B# B' F& T: F6 L; P |
|