|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& w' Z# B O" N#include <linux/init.h>" j9 f- Q Z& C: U. H' Y a$ `. x
#include <linux/module.h>8 M' Q" _, g+ Q) }0 U) t
#include <linux/kernel.h>3 C, T$ h( |, I) }' y: r
#include <linux/types.h>
. A$ z/ R, M5 \/ [#include <linux/gpio.h>" Q- \; T- }% T" F3 `
#include <linux/leds.h>* D: d- h' q: f7 w! ^4 @
#include <linux/platform_device.h>
( k+ x! k( a) m: m; a, P1 n- a. j8 ~: b6 `% h
#include <asm/mach-types.h>; T. L6 V3 |( W' D
#include <asm/mach/arch.h>8 Y7 I& i7 ~' t* t
#include <mach/da8xx.h>& F9 m9 K5 V" V1 q$ d9 I
#include <mach/mux.h>" `# H9 }: L) F0 q5 W
0 L2 p. U0 m( T. ]8 q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' F' r$ x5 f5 V( F. z$ O J#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 S) @, A! Z! C/ x0 E6 b8 ` k
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" Q7 `0 \9 [6 y3 J# J2 Z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 [: M T7 D9 u
) `% H, q9 D5 w: z0 w, ]9 m/* assign the tl som board LED-GPIOs*/4 e0 e6 b- w; I
static const short da850_evm_tl_user_led_pins[] = {; h5 U! t0 l) N( x- ` f i) k! S
/* These pins are definition at <mach/mux.h> file */
1 n& Z) S& U: L7 S- ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 D! Y! f* h& E4 d -1
$ M0 \) I, p) c6 i( M1 P};, f9 H, S0 V" q/ J. S' w! }& K. O
$ _) x3 [' S! n8 j: e/ o
static struct gpio_led da850_evm_tl_leds[] = {
4 X- Y4 W# e, @6 A% P( t7 y3 i {# N9 n+ U1 n9 ]9 C
.active_low = 0,
9 ]3 K+ } m% c .gpio = DA850_USER_LED0,
# @+ o5 M9 g8 Y" S s6 Z% E .name = "user_led0",
+ Y/ x0 F& v& I3 L/ ]3 U7 l .default_trigger = "default-on",
& X, y! J2 e" j6 R- { },
) }; l- y7 C% P {; [8 c; r+ J. _1 r. C& M% o7 x
.active_low = 0,
# p( ~: H% m9 d# g' Z0 P; | .gpio = DA850_USER_LED1,
- x- a; r* Q9 |0 ^; w .name = "user_led1",0 w8 V( B* Q z$ L1 K" C2 ?1 i! \
.default_trigger = "default-on",
, t0 _# h `2 B' t, b6 @ },
. ]6 I* w9 ^0 j" h$ }" d {
# X& K& q+ Q1 p# J! Z .active_low = 0,, y% F6 W- V$ d+ \$ j N
.gpio = DA850_USER_LED2,
4 v& c% |0 o1 X3 ^; o3 l0 U .name = "user_led2",1 O' B2 z8 t! O
.default_trigger = "default-on",3 {; q# L! H. T1 i% t3 C& s, V
},0 q9 Q5 c# A/ `9 r2 F ^" ^
{- q7 ~5 l2 I& N; p2 i
.active_low = 0,
4 s0 _5 \0 J }8 }0 R+ | .gpio = DA850_USER_LED3,/ _$ o' Q' T$ |; A: y& D: T
.name = "user_led3",
( z/ r# @* e& ^$ Q$ g7 M0 O. D .default_trigger = "default-on",9 R' z# F$ d% h/ h8 o4 d+ [3 D
},/ C* O/ m H! k9 Q' t. R8 b: t
};3 D6 n$ E: \, y+ w$ x
3 Y7 g- f. j" d, h* Q3 B0 |9 w
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 |; n' f: I) Y7 V: [
.leds = da850_evm_tl_leds,; B$ G, I) A4 d, j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds)," g+ \5 @& s2 L4 N, b( A
};
: N- K. E1 }" ` a; G' S$ P9 n
% Z \* W3 U* y4 nstatic void led_dev_release(struct device *dev); m1 g7 x9 C9 u- Q& ~
{
- S9 ^( l0 @# z3 O* `" Q4 }/ q};
( a' V8 t* J c8 o
8 N6 d. b' S) M6 {% @static struct platform_device da850_evm_tl_leds_device = {
" Q6 G6 V8 Z) E! j+ Y! V .name = "leds-gpio", _6 ^$ ?5 l# I+ A
.id = 1,
5 j6 [* h2 I- O- y1 J* k! k7 u7 u .dev = {- f9 O# e" f# q: G0 Z0 g, V2 Y' a
.platform_data = &da850_evm_tl_leds_pdata,
+ L! `' Y5 S1 L. ^9 q; m .release = led_dev_release,, z3 v2 b9 ?1 q) @4 K: k
}
7 `8 y& B$ r1 }5 j' e( J- C};% ^7 v. M1 U z7 p) N
- H; ^0 ^: ^1 Q! V
static int __init led_platform_init(void)
! U1 f# W6 R' O9 p: V% F{
* P6 i3 a4 N2 W- X int ret;
3 i# x4 B+ n: b, h#if 0
8 s$ @. z' X0 K+ ~0 D7 s' o1 I ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ p" @' n; J2 b+ Y9 B7 L: P
if (ret)
4 m- n9 Z2 g5 t4 q) F) h7 e pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% Q1 J: J4 q- m7 k
"%d\n", ret);
" d. }$ e6 \1 t$ k6 D0 z# z4 v#endif
( N6 m4 F. q5 s! R ret = platform_device_register(&da850_evm_tl_leds_device);
( K1 ^! h6 }" i6 M0 w1 g9 w if (ret)2 n! C$ B. i' c+ h ~" {
pr_warning("Could not register som GPIO expander LEDS");5 |: E* h$ a* V6 ?. l1 i/ D
else, Q, p6 H( V n8 X# q! [6 @/ Y
printk(KERN_INFO "LED register sucessful!\n");
0 X# E" ^ U* P) } m. x/ C1 m! l/ T2 w U8 [! p6 I b/ h
return ret;
1 J$ C' I! g1 B Z6 ^ f}: j6 B/ G0 a, G+ P" K0 b, s1 V
* _2 t. p" _' E' u: mstatic void __exit led_platform_exit(void)) m d2 i5 _6 I; [/ S# X. S
{
% }% F0 \" G1 l. q9 q9 c platform_device_unregister(&da850_evm_tl_leds_device);+ [5 B0 m5 ^! ]- n$ K! M
# V" m5 Q1 h* n1 k
printk(KERN_INFO "LED unregister!\n");4 k2 k. O# F2 P# V/ z
}4 C. t3 c2 p, d$ _) N
/ z2 {! i# {) Z8 V }0 G
module_init(led_platform_init);; ~1 V4 [. D! }9 d h/ e; ^
module_exit(led_platform_exit);
9 D. x& u0 U" Q
- W& F: x; c" {7 A, c! D# V. sMODULE_DESCRIPTION("Led platform driver");( w" C, Z, R P( G$ q [
MODULE_AUTHOR("Tronlong");: l- H9 {: {8 u) K$ J. ~
MODULE_LICENSE("GPL");
. G8 `% d# C" E2 x( v6 M4 ~2 X# X+ L0 ^) I/ n
|
|