|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 ?. W, h$ u, K' G, m0 C+ O- x#include <linux/init.h>
0 O2 F; l; ]+ H# r2 `0 S#include <linux/module.h>, f, t' a W( n9 X$ Y- O: n
#include <linux/kernel.h>
. B8 o, E: J. {' p#include <linux/types.h>
" t8 q6 v. X1 Y; q" M+ {# |' U#include <linux/gpio.h>
n, ]% t) W& a3 a0 V0 M#include <linux/leds.h>
: r* E1 q c0 g e#include <linux/platform_device.h> |! ]! Y1 u( Q2 n3 R
* I7 K9 V+ ~4 M#include <asm/mach-types.h>
P$ l! m' k1 ?# w* c#include <asm/mach/arch.h>8 g/ R; z' H8 q. v$ h$ v; U3 o/ q, P
#include <mach/da8xx.h>
6 V* N) @3 q z6 j/ S; q#include <mach/mux.h>, E4 i r0 d! _1 k) W' I' |4 t
# ]: z% _) S# e1 |' d
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! n6 K9 q3 y# Q9 A% J0 B% c3 ] [
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 M8 }6 o! A2 F( S2 p; I
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& k& q+ m( O6 c5 W; S' k+ [. u* d
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. |5 P% r: r4 O0 f3 E# C
( ~: B: j# W; c. }' c/* assign the tl som board LED-GPIOs*/* G$ S' b: E' b# G
static const short da850_evm_tl_user_led_pins[] = {
) d( e# `. Q& s, p2 J J% p+ H /* These pins are definition at <mach/mux.h> file */
( k3 U, u2 {/ H5 b$ I DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 q; n, R3 a; w0 U! G; ?* j -1
p- f; M' a# m7 Z};0 y2 i8 {- t8 n- }4 \' D: q9 N
, @/ U x& V: J# F# \* S: v' {7 H( f
static struct gpio_led da850_evm_tl_leds[] = {5 {% T. ^3 }+ D: s
{. O) ~5 n: i, H2 ?" U; o
.active_low = 0,
) W! q* B; r- }7 |9 f .gpio = DA850_USER_LED0,' h# l, F( [, G2 y
.name = "user_led0",
9 |5 c) z: D) L* |7 p! p: \& v .default_trigger = "default-on",! v6 F8 z7 s" c, |+ A
},& G! r' i& |% ]$ _9 L' m
{
' B; G; \2 N7 y0 `$ N .active_low = 0,% T1 Q6 b' y8 k: h6 d
.gpio = DA850_USER_LED1,
9 c; V/ Z& G0 `: R1 {, e. \ .name = "user_led1",7 d3 R6 V5 k) S) S. o
.default_trigger = "default-on",! f6 C; ?$ C) b) z6 d4 O
},
+ n, Y5 k% X; I, u" c1 d {. V; i2 A$ I$ k4 b% J* n
.active_low = 0,+ b/ o# j6 T' _7 C# M& G. P- Q
.gpio = DA850_USER_LED2,/ h* b4 M+ e# g. D" J, F
.name = "user_led2",$ M& R }5 p5 o) p6 o
.default_trigger = "default-on",: D4 U7 b' J4 l" v @/ h+ P
},
, X4 S; n! ~0 c3 Y6 @ {
7 X' k/ g: n8 i" p8 i .active_low = 0, F! }5 h" ]: C( S( y% X8 c* {. |
.gpio = DA850_USER_LED3,8 M1 Y4 Q5 \1 {. U4 B, ~
.name = "user_led3",$ p: y7 B" l, { N+ _2 b
.default_trigger = "default-on",
/ m1 X0 S7 T \ },6 G0 G) j1 P. I h: P) K5 o' m* h
};0 E7 S$ I: y: ]; R7 n
c/ A& P6 P/ p3 L& [" j
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ m* H/ c6 x) L9 Q
.leds = da850_evm_tl_leds,# A, K5 L0 ]- | l* \; f) a
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 h# Q: S2 ^0 O& [ Z" O& R5 ]
};
' v' M# e; k/ e2 @; U. s- n1 y/ _
static void led_dev_release(struct device *dev)9 V, s( j% V+ ~
{0 Q+ b2 @+ \! F3 ~; W S; g
};
: s. L+ T* @1 `/ D2 i/ \+ t& z3 D: F
static struct platform_device da850_evm_tl_leds_device = {
# c! j1 |- W: q g! q3 p3 D: O .name = "leds-gpio",6 |) u2 W# I/ F2 @ _( @- j- E
.id = 1," |6 Y7 g/ R1 i; I& N* r+ j
.dev = {
6 x' w2 P) e) g( Q: k/ c4 u: a* v .platform_data = &da850_evm_tl_leds_pdata," i1 U) t: n5 R Y
.release = led_dev_release,. `0 A1 @+ y: @# H0 {& t9 ^ `
}
$ @) B8 d7 D6 H! \};
/ a0 |1 a4 u) \% S% d& {8 U# D/ n$ H
. c4 a9 n" r8 lstatic int __init led_platform_init(void); a: k J5 H' V7 s
{
5 ?0 i6 ]+ v- a5 y% @! @9 ]5 ? int ret;* W4 g. }9 ~' |
#if 0* c6 Q% [! [1 q7 s9 s4 I% ]
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* Q& E% \- {% m% z( ]' d
if (ret)% Q0 U" g6 H" l' k4 ?5 e% ?' ~
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 n3 c9 p& A5 b. f+ N* V- a
"%d\n", ret);
% r ~6 Y* Y3 P; p. G#endif
* B4 ]) j' m- O6 O, U9 b ret = platform_device_register(&da850_evm_tl_leds_device);$ ]" Y6 s9 G& ?9 V3 r1 `
if (ret)1 t7 O F5 n; P3 j! S5 L
pr_warning("Could not register som GPIO expander LEDS");
9 }) N1 h# O- D2 J: |3 ~/ b else. Q) y- {9 S' ^( q2 k3 h
printk(KERN_INFO "LED register sucessful!\n");
% J9 X/ w# X3 @1 H2 Y: q! t l7 |
e: {' d$ J5 u$ P return ret;* e% \9 n; x; \% _" I
}, B# ~* `" R! B: z) S& v
& b1 o- n0 b4 g9 hstatic void __exit led_platform_exit(void)
3 {" c6 }! H% r' D% D! m1 H0 x) O{
# F6 w1 w Q6 e8 V platform_device_unregister(&da850_evm_tl_leds_device);
: {+ `( Z, u$ }: x# \8 p5 c0 S& `+ d6 X& K5 u, ?' f/ a
printk(KERN_INFO "LED unregister!\n");
. R/ L7 v1 @& q- Y+ y4 y. \}% g$ x/ {' ~* \$ a
* G" f7 g' U1 ~: P: U& i, Qmodule_init(led_platform_init);
- U1 t5 R/ H! Y7 U! i* ]' m+ h3 Tmodule_exit(led_platform_exit);( ], \+ q( A {, P# B. F
, X4 q$ I. A! F r; hMODULE_DESCRIPTION("Led platform driver");
, G6 n/ e# v5 y' O, y/ [MODULE_AUTHOR("Tronlong");# y+ h! S5 A8 y6 r% |
MODULE_LICENSE("GPL");
4 G+ k: z" q6 k) t; z2 r0 \/ O; m; U
% N k1 m' q4 ~3 y l |
|