|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; a9 C6 Y$ d; v
#include <linux/init.h>
$ `+ D+ O3 `9 `( I# f( Q#include <linux/module.h>
X' a0 X$ O3 G$ F2 F#include <linux/kernel.h>2 n4 {9 N/ \/ y
#include <linux/types.h>
) v# N* ]' K! z$ c. k#include <linux/gpio.h>; b) C( T" S6 a1 R
#include <linux/leds.h>
8 d, A0 v" g& l7 R$ f! k2 R: p2 U: k#include <linux/platform_device.h>7 F! U$ g1 S" x2 V
9 h" Y! [; h& q( l3 o* `#include <asm/mach-types.h>
3 [& Q* z( o, w! w0 E) m#include <asm/mach/arch.h>3 J a" I9 s3 d2 `3 ~: G7 B
#include <mach/da8xx.h>( w: q& h7 a# e, }4 t
#include <mach/mux.h> ?$ t) h0 a. J4 @4 Q A
" h" U3 s. _$ [ S( m
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' ?! S3 h [' F5 C8 ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* |9 y# T, M& u/ u0 a, w#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* L) h2 O: G' F! a- G$ K
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( T& n z7 g3 F6 ?+ e: Y+ C2 z" ^. w: m
/* assign the tl som board LED-GPIOs*/1 @+ [" t& t2 t: n# D
static const short da850_evm_tl_user_led_pins[] = {+ A- o% k6 ~% ^ H! w$ W3 @3 C
/* These pins are definition at <mach/mux.h> file */
& E# A, V' l' _0 b M! L1 g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' S0 y8 J( W" g. L6 R$ N6 c( V# ^
-1* f2 h) {9 X$ }8 E
};; U: e& E# b% t6 o( T- j9 X9 I0 G
& t) t& l9 _) ]4 l0 c _" v- R
static struct gpio_led da850_evm_tl_leds[] = {/ l' n6 J+ z7 S( e, r# R
{
4 e$ K, t( P5 W0 U9 G .active_low = 0,+ b6 u% B: ?9 ~ M7 W
.gpio = DA850_USER_LED0,, q' f0 g- m4 ~: D Z) n F& {+ t
.name = "user_led0",
) n6 S5 j: ~/ w' X+ g- O1 N .default_trigger = "default-on",2 ?9 M! h1 ]4 d, Z6 z0 ]* b" J/ [5 Y
},* o ?9 Y* _. [8 m
{+ P' y" _, U4 J3 A4 p
.active_low = 0,
; c( r( G }( b .gpio = DA850_USER_LED1,
. `/ y8 w% {! y .name = "user_led1",: ^; T! n& I; G! o/ N
.default_trigger = "default-on",
# s' H' X9 g+ t$ n1 h& P9 U. P },
6 [' d A% E+ G5 a0 u1 {7 U {% x s) `; V' P
.active_low = 0,2 @$ u) R+ G+ a1 ^5 ^, T/ ]
.gpio = DA850_USER_LED2,
1 \ [' u7 G8 g2 {/ K .name = "user_led2",4 O% s1 B" ?# v$ M
.default_trigger = "default-on",/ T) {* V1 _- S/ T B* B& n$ x
},
6 \+ `6 N$ b0 a' W% p {
6 Q" X( J% h- Q: _: A! x) d1 g3 J% o .active_low = 0,2 X. q; O: U, N1 _
.gpio = DA850_USER_LED3,
4 q" J! `/ g; I7 P! W1 y' n5 c& L: H .name = "user_led3",
# ]) v" @$ o, i# M .default_trigger = "default-on",+ r) N# u% s/ J$ k8 V. Y
},
0 S) K( e. ?' q+ e# A% Y8 @};+ M) q+ s) ^) |8 l5 B7 X2 q' W. ]
% s' v5 A2 J* U( k2 qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 E# M- o) E% ? .leds = da850_evm_tl_leds,4 L5 ?: i* D3 z# Y E# Z0 J O; y! W
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ k. q0 O( T# A- c$ M) D, Y1 Y};
3 \" o i$ [/ s, k: k' ?, R
" U/ i0 u& ~7 `static void led_dev_release(struct device *dev)
; b2 e7 \" @! h3 a5 @* N. V{
) U1 r' X2 I. H; D};5 `- w2 Y! |# _- P' @/ K; a
, z& t" f0 s! ]/ j
static struct platform_device da850_evm_tl_leds_device = {
U' k! p( t8 v+ v2 {5 t3 Y3 L4 J .name = "leds-gpio",7 Q1 E' t) i6 {% c
.id = 1,
1 K3 d5 k k5 T) M e6 s) Y! x .dev = { ^% j+ }! }$ j6 e0 j: P, l; }
.platform_data = &da850_evm_tl_leds_pdata,$ F6 G+ F2 l$ H/ g% W8 Y+ y
.release = led_dev_release,' O `8 V: \0 ^. i
}6 e* l- c; e+ o/ t5 Z
};
6 I# r3 z3 b, d, a4 O/ T3 o7 ]) C. c) g. i/ E9 v+ i
static int __init led_platform_init(void)2 r9 [ I( z$ X N8 O
{/ i9 r/ | u7 n0 o9 C2 n8 w; L' ]
int ret;
2 x# w0 p. P& [: K. `0 [. V#if 0- B( E5 T( C2 Z1 A6 }# o" u
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 |$ J; c" B1 n: t% G& R
if (ret)
/ s8 g4 D4 [. M pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
* g" B7 F% Z9 \* f9 g6 ]4 P "%d\n", ret);
2 _5 E% R) U! W9 x, P#endif
: z. U; A4 y7 J g3 B ret = platform_device_register(&da850_evm_tl_leds_device);
4 n" _5 k4 `. J F if (ret)$ K. {# m1 E% B3 ^5 Q& x
pr_warning("Could not register som GPIO expander LEDS");! v4 a2 E+ _( b5 b- Q
else) O* ~ u& c! i8 g
printk(KERN_INFO "LED register sucessful!\n");" S8 }* d: o5 H4 S: _ P8 g
( N4 @! o/ l7 i# f+ S. I
return ret;: z. m M; U, k2 @& j
}* W0 B+ Y" z/ ]2 `4 P" |. s6 F# P
9 d2 P4 a+ Z: B0 i5 pstatic void __exit led_platform_exit(void)
2 ?& ^* ]9 R! R! E3 |+ {{
$ ]3 [; d- k- l8 B- y platform_device_unregister(&da850_evm_tl_leds_device);
) `) N7 m9 ~- d/ ^1 [. f6 Q$ ^# E
printk(KERN_INFO "LED unregister!\n");
0 q7 a+ r, d. S# O}+ @2 C8 a5 R- {
: R# J/ q/ C& R9 Z9 D; ?) ]
module_init(led_platform_init);
: k6 u, F. Q' d; @. X- F6 jmodule_exit(led_platform_exit);
, S6 E/ ?" v, F2 L* u& ?* ~ B: P6 j) f) ~" B
MODULE_DESCRIPTION("Led platform driver");! V4 U- a `" W7 Z8 p3 U7 G
MODULE_AUTHOR("Tronlong");
1 O: B: G4 z. a: HMODULE_LICENSE("GPL");
( ~% o: @' ~* k& h& m$ ]
7 z! n5 a% e, U& I+ H* b, N/ U |
|