|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# L. {& B6 I$ u' @% Z
#include <linux/init.h>: t9 m' K: y ^8 w G
#include <linux/module.h>
* J9 X1 x/ I& R! c g#include <linux/kernel.h>
2 l k7 V; i6 N" F0 k#include <linux/types.h># E7 K: }+ I/ f9 d5 \2 m: h
#include <linux/gpio.h>
1 @( w1 r; a G0 z7 W#include <linux/leds.h>1 ~; j- ~/ E' [. @2 I# a( d8 ^
#include <linux/platform_device.h>* O% J8 U% _% o% ]+ P4 r$ C. u9 s
% l- r2 q1 n5 h: w#include <asm/mach-types.h>' Z2 G* o& O; j2 h
#include <asm/mach/arch.h>1 V/ M( g5 r3 ^6 y3 t0 E, v. k3 E
#include <mach/da8xx.h>
$ T2 c5 h% f. y2 [8 x: h& a#include <mach/mux.h>' ]) N6 ]% x S& q' e/ |9 ]
% [: G& p! H( S E! ]#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* T0 i0 G, ]# _% V' _( t! \: s
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): `/ J/ j; ` N+ Q S1 @. v; ~
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 K6 n2 f3 P2 i& E; M* I! J#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 G* K4 h8 u0 H4 q1 w- x
) N" H9 e" B4 Y( c# ]
/* assign the tl som board LED-GPIOs*/0 c8 J3 s. o: J$ e7 S
static const short da850_evm_tl_user_led_pins[] = {
L% Z9 M3 J# X8 E" v3 \2 m /* These pins are definition at <mach/mux.h> file */; Q# @! Z* q# N" h; B3 Y+ p, K' o
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- \2 Q( C5 }& o _
-1% z' v; a, w7 |) m+ Y; @3 z
};
" _$ L" N' C: m2 _, Y6 t
5 A$ M2 o3 l: |6 y+ ?8 Sstatic struct gpio_led da850_evm_tl_leds[] = {$ z, m( o! {4 Z; X. r8 d9 l2 q6 D
{
% W! D6 m! r/ l .active_low = 0,
8 H) C( d; F" t9 C .gpio = DA850_USER_LED0,2 o' v( ~: J8 ?9 m' `
.name = "user_led0",
0 i6 Z$ X4 \2 |" t0 w# Q .default_trigger = "default-on",
9 s% N' z; @% `" T },6 _* A- n' Y! y% {
{5 d. r L' a% a5 Q" f1 r. O
.active_low = 0,8 a4 g+ l" y( v0 r {
.gpio = DA850_USER_LED1,
# r0 B" T# U% ]6 _% d6 g+ r .name = "user_led1",( i# k Q5 U T( o* Z9 l
.default_trigger = "default-on",
0 Q* t0 T! t3 H4 [7 G },
2 `* O- e# D( l4 e6 ] {; e- V3 N/ m! p6 R+ z
.active_low = 0,5 d {0 I" X4 F) d$ b% t# W; E
.gpio = DA850_USER_LED2,
$ [" z! N* b1 K5 {3 _% z .name = "user_led2",
4 f+ b% a. n6 |" @) X5 @ .default_trigger = "default-on",8 v4 g9 D Z3 q3 O! a
},
8 q/ b+ x; V0 C/ ~ {3 p7 W# d2 C' J5 ]) a$ n
.active_low = 0,
( D" b8 g4 W2 X! o0 O4 `- X .gpio = DA850_USER_LED3, f9 ]1 f; L8 k) ]( Z5 o
.name = "user_led3",
, v3 [ _* m" |3 c" l) s1 x7 R& @ .default_trigger = "default-on", y5 A9 i" E) s% d
},/ y' }* O6 A- T2 `
};
& ?2 z7 T+ Y! U1 Z& t7 T) w( `$ A2 L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 _5 V3 [& O# a6 q/ r% d9 S .leds = da850_evm_tl_leds,* e4 W, S3 f2 c0 b6 {/ H; ^
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 C% C. A% f7 S* V- \' \4 p};
& d; Z. _7 h% t( g" z/ O& s! y# q7 n8 A
static void led_dev_release(struct device *dev)% _( Z5 R& V0 p4 f5 H8 A/ S
{" L3 G% q1 d/ \
};1 y* f6 u9 e; [8 C' [
/ K) i" ^5 g9 u& N
static struct platform_device da850_evm_tl_leds_device = {
# o7 _% j: t1 K/ D( A$ N .name = "leds-gpio",+ \2 f5 h+ D/ g( W! U6 u; y+ I
.id = 1,
) U6 u; ^8 w2 ?6 r7 Z .dev = {
* v5 I) m: l, g9 t% K .platform_data = &da850_evm_tl_leds_pdata,
2 j# y; |& S+ ~: N2 _+ Z .release = led_dev_release,7 s: S; Y: k: P, |) X; N! B! ]
}
5 G' k- k( H( j" Z( O};
* B2 V% M0 L' U$ |9 {; R. A- q" l& z3 J6 ^; K& h3 }8 y
static int __init led_platform_init(void)5 P. |0 L, b( J! D! h, c: Y7 v) F# p2 t
{) N' a0 N1 t4 [8 b& f) X8 ]9 J. \
int ret;9 b; s- U$ n. z4 J
#if 0
$ h& R2 v$ d' @7 P ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) `* x0 U' V* A7 t0 W# p if (ret)0 o: r# Z. S+ o4 f9 l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, B7 i! G7 n* ~2 Z "%d\n", ret);
- K2 C3 g# ]7 X3 b* d4 ^9 H#endif
* y2 ]( u# l9 a6 D$ X% L& G) {8 l% s ret = platform_device_register(&da850_evm_tl_leds_device);
8 }1 e, w# Q& [ if (ret)
7 A# ?; n$ {5 C, f pr_warning("Could not register som GPIO expander LEDS"); E% ?# {) u6 M4 C
else; L& m6 k n7 h& L
printk(KERN_INFO "LED register sucessful!\n");% J7 o7 f0 i8 i9 x i
, |- G* ?1 @, {; b0 g return ret;* f# _- ?- S8 x
}
+ V# y* B4 J$ p: }5 i
: ^" ^8 G& y$ z" fstatic void __exit led_platform_exit(void)
/ i8 s: m, u0 ^5 R% c+ V{
5 p. ?, h% v2 X G y) N5 j# K% {' p3 ? platform_device_unregister(&da850_evm_tl_leds_device);
1 F! n9 R$ _4 } \/ l; m. M. r8 ?2 {6 P. @; O& o+ \1 l0 e4 r
printk(KERN_INFO "LED unregister!\n");( L; }( R5 l7 }$ D4 E. A* r
}& g/ i2 R- m% J
; X* o# _( N _7 r* }0 y* u+ ^& Omodule_init(led_platform_init);0 {' n" E$ P/ u, U |+ ^! `
module_exit(led_platform_exit);& n" b J! I3 y% O6 T
6 ], z4 Q6 n5 l8 V8 LMODULE_DESCRIPTION("Led platform driver");
' ? ~' ^( e, w6 mMODULE_AUTHOR("Tronlong");) \+ u; _3 `8 X/ R% M* k
MODULE_LICENSE("GPL");/ s) E3 X! c# o/ W9 u& |2 j' c/ ^( C
: }5 x7 {" u k' `" D6 e. q |
|