|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ U7 F3 }8 \* N, d% c+ l5 k#include <linux/init.h>
' f# X' f* S% K( R3 O; b5 g- F#include <linux/module.h>
# @8 {! P8 {2 H#include <linux/kernel.h>
+ z/ x* `4 U2 n0 H8 B7 S5 K# c#include <linux/types.h># V& G+ `( k7 _" v5 j
#include <linux/gpio.h>3 Y9 w, f& P9 \1 {, Q
#include <linux/leds.h>
$ @" W$ k! {, R/ a#include <linux/platform_device.h>
; }; y1 k+ y ~, z2 h2 q7 H/ x, }7 n u' n
#include <asm/mach-types.h>
; t) @6 C" V) W3 {1 f; r#include <asm/mach/arch.h>% i6 ?- F; P* { X
#include <mach/da8xx.h>
- |, J* X7 _( H$ d# Q. b) `#include <mach/mux.h> U5 f9 c- b+ t% w
8 a& F% y% F. ]; L& W7 L$ _
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' O) G4 S$ T1 S* g1 t$ J
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 ^* M, S: [- g: S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). C" W& x3 R9 N6 c/ J
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
N8 z& R! M6 p3 r; c/ ^( x8 v( ^1 _: M& C; N. I, N+ L
/* assign the tl som board LED-GPIOs*/
[3 C0 O( h- K4 A% \% fstatic const short da850_evm_tl_user_led_pins[] = {/ ?5 Z' \6 D# |. o6 C+ t
/* These pins are definition at <mach/mux.h> file */3 U" \9 P. r# q) K
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 O. f# k8 ]6 {. [) `; `: @2 C
-15 N% _$ N' ]. a
};
6 @; `# s( }3 Y; Y! {) S- S$ ]
7 q6 d. z3 |( r( [, \& |6 zstatic struct gpio_led da850_evm_tl_leds[] = {+ \+ ?5 a. L9 z
{" W" P; U" Z4 ^. C+ c/ K0 i$ S
.active_low = 0,
9 m( f- L/ v* R; Z: H& O .gpio = DA850_USER_LED0,# y% f, p: y# k7 k) t6 [
.name = "user_led0",
0 o( N0 b& q' c1 m m1 `& ^$ T .default_trigger = "default-on",- z+ |9 f8 V/ C- {4 W5 g$ ?* ~
},0 m" s7 y2 d: Q7 X, K1 z
{
! C6 ~' u, L* F8 ~ .active_low = 0,
0 Q: ]* k* ]% o! t6 L7 i3 b; M0 k .gpio = DA850_USER_LED1,( F$ I( P+ m+ P7 h _
.name = "user_led1",
9 |, f7 }& A7 q, ^/ ?4 R. m/ { .default_trigger = "default-on",
W/ E0 C4 k8 n) _ },
1 g& q ~; W2 m$ G8 \1 s2 z {
5 a; f, ^, i! }3 D' ]: j .active_low = 0,
z% [4 T4 m# L" j8 J/ k .gpio = DA850_USER_LED2,: a- c* A+ Q! _* ]
.name = "user_led2",
/ _7 H5 ~" [0 m4 _ .default_trigger = "default-on",
) J. C ^" D" g9 F6 c },/ C: e$ m* F, n& B
{: l9 [' V) ` T& t3 z$ `/ g. G
.active_low = 0,! X \9 w0 b! T* V/ x' g
.gpio = DA850_USER_LED3,
5 O d; ?. w3 X .name = "user_led3",& |/ q q1 S' s" v
.default_trigger = "default-on",: F3 E4 P2 b# S; P: }
},
' D/ R# F# k( a2 f" }2 X2 ~) m};, M. u8 N( a/ a& O( p( _
; n4 v) X# @, ~# J
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- E, Z* R) z7 H* ~' h7 {- d
.leds = da850_evm_tl_leds,: N# F6 g, F/ p0 r
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ l' F1 G; Y" A1 ^
};
- {8 N1 N5 L. t' Z, a6 V+ V0 }3 z" l2 A3 b" D" u( @
static void led_dev_release(struct device *dev)
& n- u3 C; F$ Z7 W3 y1 b{9 r- u! r4 {5 B( f6 U- I! w) Z
};
+ |$ g& ]. W9 C3 C3 a" ^9 A9 \8 a4 H5 W. R( K( e8 d
static struct platform_device da850_evm_tl_leds_device = {% Z7 A( v" d7 ]; u8 h; y
.name = "leds-gpio",3 _% |# Q- @6 ~! G) L8 w. y' M, g
.id = 1,9 Y& L5 F; Q2 w7 p" _2 |% V( O
.dev = {
0 c4 Y7 w8 {8 M8 p$ t9 T0 ]/ F .platform_data = &da850_evm_tl_leds_pdata,3 Z3 T& e. k$ J& z9 L
.release = led_dev_release,
/ \3 ]8 e4 F5 J8 }6 d: g* c }
/ L) M: U) u% ^" L% f( J! n};
6 W/ Z$ y, j! p3 e& r# E( [$ A8 e
static int __init led_platform_init(void)
; [2 K( w' ^/ P, x8 l4 u }9 L{
. f! |" x" h3 a+ P; V" S int ret;% S! K. D6 @4 A: w! t& g8 w
#if 0
! } S/ o$ q% z9 N, `! t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; F7 g* ^2 r0 f- u8 V: y8 W5 P& } r if (ret)9 |2 F" |$ d1 }5 }; a
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 M @0 h2 R/ R( i9 V& l1 k
"%d\n", ret);
1 R* t$ M x8 p1 }#endif* F" [) K7 n) s6 C! r& L
ret = platform_device_register(&da850_evm_tl_leds_device);0 ^: N( R0 D4 K: N% s
if (ret)
2 W3 f, F5 R, ]& V. x pr_warning("Could not register som GPIO expander LEDS");1 m, D8 \4 u& I$ O
else
, S: H z* r6 _ d% c/ X- Y% s printk(KERN_INFO "LED register sucessful!\n");
d' Z! j' W4 i- C5 r2 o' i
; o: s. P) W' Z' Y0 j: R0 s5 Q5 E r return ret;) V2 h+ |, y* [, n0 g
}# O( n9 v, o7 }( I- p
' p5 O# ], N7 W
static void __exit led_platform_exit(void)" ?' m! G+ {8 ^1 ]
{
9 I% z. l. {( G platform_device_unregister(&da850_evm_tl_leds_device);
. w, L, C( @$ ?! e/ N
. e$ ^/ ?( q# y printk(KERN_INFO "LED unregister!\n");' N& V- y- V* R" g9 C
}
% F, i1 M5 t+ g3 S7 t/ m* u- V* ~" G. i5 U8 b) y
module_init(led_platform_init);
% r; Q. a& ]7 ]: Cmodule_exit(led_platform_exit);' V+ J8 I M- i" z- e$ ?3 L+ c
& }0 _/ b- h( f0 H# U, G
MODULE_DESCRIPTION("Led platform driver");
) Y) v0 ~7 d3 g" b, GMODULE_AUTHOR("Tronlong");; O q+ H& V# [- N0 O; H
MODULE_LICENSE("GPL");
- z V+ t6 T8 R; U3 ^
. g0 E4 W+ ^+ w: _ |
|