|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 l* u7 x M5 l1 X( A#include <linux/init.h>, }9 e; M' G# n* t q5 J- p+ U
#include <linux/module.h>
1 _/ o* y, |& E4 W6 g/ B# T8 M& [#include <linux/kernel.h>
/ }; u- o$ U7 l+ F#include <linux/types.h>
5 ^: }8 I, x7 A5 ^. P+ ?( e3 q#include <linux/gpio.h>5 F6 E2 S3 S- g8 r! c1 F3 z
#include <linux/leds.h>
& }6 D2 r8 {: n' Q$ z# [2 Z#include <linux/platform_device.h>% k7 K& F7 T' h, A" h5 y; X
# B, }5 n' n% M; s
#include <asm/mach-types.h>0 g9 r3 V3 @, y/ C
#include <asm/mach/arch.h>
9 P8 W: \8 {' h: n9 _#include <mach/da8xx.h>2 [, r9 ?- p b: P* }) t& ]
#include <mach/mux.h>$ ]0 g% }9 W8 D# T2 r8 y9 Z2 i
! `; k1 F4 v3 L( e+ H#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 \; d' |/ s! c6 H, d6 O" _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. b: @, E( T" v' U$ d#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! f' d- S# W8 v: E$ _2 @
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 H* W- n9 C. s1 r" R5 @0 V
5 c3 J( u; j% `. o1 T/* assign the tl som board LED-GPIOs*/
, c* n% y6 `& P) {$ D( { nstatic const short da850_evm_tl_user_led_pins[] = {
{: U2 p; n0 d- m/ S9 ^7 d" n /* These pins are definition at <mach/mux.h> file */
& n& i0 G) f/ { DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! s8 k/ _) n/ Z/ h, w- S( p$ e -1# z! s3 m& p( |3 v z
};# ~( I6 p+ @: w( _( y" w
5 W6 Z- M2 K" Y1 w* w3 |# |static struct gpio_led da850_evm_tl_leds[] = {4 @8 Y8 i4 _4 J6 p1 Z$ J) v. E
{; Y- w5 u# E9 r i* k
.active_low = 0,
, C) }" g* q7 U7 m& ? .gpio = DA850_USER_LED0,
' ?% G p$ W3 f5 C* t+ M' K( j% j .name = "user_led0",
, q& A: K+ C; T8 W$ B' F8 C .default_trigger = "default-on",$ z& n/ w0 O" h
},
, S- P! O, H) |, b( v {) I. ]9 @/ B. C+ p5 H
.active_low = 0,
1 C$ ]$ H7 b! X { .gpio = DA850_USER_LED1,
8 N {% z- c) f$ c .name = "user_led1",
. r% A* i) }+ R& } .default_trigger = "default-on",
+ h( W) ^# q! ^ I2 Z* Y# u },
! q/ d9 S, ]' r+ G/ i5 Z8 m1 Q* e/ V {6 V) t9 K6 L* ~$ |2 O3 Z
.active_low = 0,. d6 |1 w" o8 \0 ^) N! ?1 }6 n" S
.gpio = DA850_USER_LED2,# f6 C$ h$ r0 ~* V* q" H, z$ g
.name = "user_led2",
% v Z, T1 A; b! Y .default_trigger = "default-on",
( n3 J- H, y' Q% s' R8 r1 ?1 Q6 u6 S },
; z1 l. @2 Z2 L L3 P0 |5 s2 G {3 u' |( I8 H4 p- ^
.active_low = 0,
- h/ |) T* A! V# V- ] .gpio = DA850_USER_LED3,$ D4 Z' V( I+ x" u- i, f/ O8 h
.name = "user_led3",8 M8 I8 }& I: A
.default_trigger = "default-on",5 F2 a& Z* H. E9 h; X% ^
}, Z8 W3 \! C7 D) I% _; ^3 R- f4 o5 C" u
};
8 s+ I$ U6 |0 P% ]% I; I1 i( p8 v3 n* @) N6 G O! Q* s& l2 C
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 Q* }/ x y/ j- o) W8 t
.leds = da850_evm_tl_leds,
& G' i/ w# i. b& H .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ ]( [5 J, L% c9 ?, ^};
4 J& E* d( U0 x: ]( T9 `
' O; o5 o! J% o( Tstatic void led_dev_release(struct device *dev)& v" L& F& e4 _1 ]
{" t3 @& `% s7 {. t( g' {6 A
};
: v1 a& Q/ L- U0 |" x
0 p: v; Y- o, N% ~$ x- H6 p/ Bstatic struct platform_device da850_evm_tl_leds_device = {; o T1 K1 g* f; T. c
.name = "leds-gpio",, @; f) X2 x6 t$ J. Q) ?
.id = 1,2 A% ^1 b+ @+ j4 ?' w9 H1 t# \
.dev = {% e$ X+ K Q; g8 @, q4 g
.platform_data = &da850_evm_tl_leds_pdata,
2 ~3 Z7 r5 v: s+ a .release = led_dev_release,! f8 U( G( A( g4 a) P
}
- G' q' Y( a9 C" I};
8 G* l _7 F: n5 |2 q7 G g9 f5 P
: M! L7 r C ^! i( L6 r, v, tstatic int __init led_platform_init(void)
$ X8 f! n; C; U6 M9 I{0 u' j4 P7 l7 d4 H# h/ Q
int ret;
S- [; e8 m; S8 @2 y8 j8 f0 O1 ~: R#if 0
4 U2 Y& p: L- H o ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 O1 G# ^6 s2 f9 @2 R
if (ret)6 S2 z; E! R* }+ n9 l
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: H$ x. I+ |, @) k2 a "%d\n", ret);) h9 p7 Z$ M/ z3 \$ }0 v
#endif
? c* [, |0 k: h) n) r% X8 o. t) v ret = platform_device_register(&da850_evm_tl_leds_device);: Y0 J/ x+ M4 O6 a( Q! i2 z& t- ]
if (ret)8 W( j& \- ]! N$ k& \5 N
pr_warning("Could not register som GPIO expander LEDS");0 _% ]: n+ z0 I# t0 K
else) i" @1 o1 P+ I+ a# ?
printk(KERN_INFO "LED register sucessful!\n");
$ p# Q" d, H% b. G
( N) d7 ^' g7 B return ret;7 F; \3 v+ f, j# L% i, _
}
. e+ f: Y* o$ x3 o
$ h- ]% s4 R$ qstatic void __exit led_platform_exit(void)9 w; j! h0 e; K3 c
{
4 k& [% [& z; U( d; Z( \ platform_device_unregister(&da850_evm_tl_leds_device);) \ z: P" n6 ?5 G5 F
, h3 d1 X/ P, C: U& c printk(KERN_INFO "LED unregister!\n");
( z( ?, U- j6 v+ O2 \7 z8 E) s}: a, u# x+ t. g0 y& O1 p
3 Z6 A+ @5 ~" T0 D8 M
module_init(led_platform_init);
* w' D5 Y+ t( ]- \module_exit(led_platform_exit);
/ H; i/ Y/ e& m; D* q5 E
2 f* ]# Z5 W1 B+ N5 zMODULE_DESCRIPTION("Led platform driver");
( O' g7 N I; j8 @3 o( nMODULE_AUTHOR("Tronlong");
. D; D5 C. S2 Q3 @' |9 H/ g R3 KMODULE_LICENSE("GPL");, w$ [0 L- s! r" q
7 t4 K [& g9 ]5 F3 k |
|