|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' L l) S: Q, c6 @( r0 M. r#include <linux/init.h>
5 Z ]9 a7 j' L9 E" C. \. Z2 P# P) q#include <linux/module.h>
* j5 _1 P# L. L Q#include <linux/kernel.h>
7 c% j8 |* F4 }; f) w: i#include <linux/types.h>
6 S, ^- {3 f# o5 W" \$ a2 p#include <linux/gpio.h>
. H, W: U9 `+ a" Q) Q6 M#include <linux/leds.h>
: [% k8 ~1 w+ n( ] y1 r$ W#include <linux/platform_device.h>) f& M7 V1 J7 u0 i: p: f
" W+ ^. Q- y; }! U
#include <asm/mach-types.h>- v" q$ \4 c Z# k, s3 `
#include <asm/mach/arch.h>8 X' W! K1 z' b8 A! w& X5 k# s4 _
#include <mach/da8xx.h>
$ U6 k! ^& a) B3 X$ r/ J, y#include <mach/mux.h># C( t, n. P( j7 T2 R5 k. M
; m* ]6 J5 h$ B$ ^& V2 w& w#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ K9 z$ k. Z# R% m, F#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. g, Y# E1 G% k8 c# P# t5 \6 ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) P: ?- w, X& [6 |" l. P a. e' f
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 i4 f* p) o' k
- u, k/ I' h/ Z3 B5 \' a/* assign the tl som board LED-GPIOs*/
3 {2 p4 b- t; s% X1 I) e+ [+ ustatic const short da850_evm_tl_user_led_pins[] = {
& D, P) A, i6 o5 J /* These pins are definition at <mach/mux.h> file */1 ?. S5 ~$ g, Z8 Y7 F
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 E1 E$ n/ W' Q( r3 o/ n
-1
; N' s) d5 @: o- t- v" i; Q, i};
% t2 n& W' k" D
) N, x9 E; K7 b8 v C% `0 U& Estatic struct gpio_led da850_evm_tl_leds[] = {& R8 _1 Q% V& i# j2 \
{
4 A* o: c* O2 J. n .active_low = 0,' F* U& R7 `3 N
.gpio = DA850_USER_LED0,: q3 B" T' p& }- g$ O
.name = "user_led0",
/ R+ i( B& L& t# q ^" f' ] .default_trigger = "default-on",
" T. _2 y* `/ [0 R/ M; Q },9 ?$ X/ h% D' w4 n! M, q
{
. b6 _2 X% ^, L .active_low = 0,0 ]: \% v3 U4 [ y
.gpio = DA850_USER_LED1,
0 P) |) C' {0 K+ P& S6 W7 j, _ .name = "user_led1",- q2 P+ Y" S2 E" L* n
.default_trigger = "default-on",
" i# [; u" G! P4 A' F u* S },
% ^7 |9 U; J* v% N {$ C! T2 \: O) W* l$ t6 N; h! W! F
.active_low = 0,, y8 a+ ~3 M& \3 b
.gpio = DA850_USER_LED2,9 ~. e& U/ [9 c8 _( z( a/ H) h
.name = "user_led2",
. f2 }9 J0 k& H# R .default_trigger = "default-on",5 r: |2 P& a# Q; I' C) E
},
# Q+ E8 }: z% H {& }0 M* s3 |2 P! G4 E
.active_low = 0,, k% I, R+ O/ K. Q4 q
.gpio = DA850_USER_LED3,
- h0 e* T! |3 c .name = "user_led3",1 f; f j9 R) F, U
.default_trigger = "default-on",- b6 j# c" L% r; ~) A
},
. q; n3 Z) s3 y7 J( S};+ d# K1 p3 S1 r0 Y' b3 t$ r) ]) _) p
; M. E5 y6 m% i0 H1 e- y$ k+ |, dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# Q) `) U. K2 S3 H) b, H- P .leds = da850_evm_tl_leds,
) G# k+ C- T$ w0 S! z( |' U .num_leds = ARRAY_SIZE(da850_evm_tl_leds),; l$ w. l2 Y4 p) b5 }
};
6 a; _: r6 x. U& B5 @3 f/ t7 D) V6 M7 p% z3 M7 z
static void led_dev_release(struct device *dev)
) {( g/ U! ]2 o{9 d0 r+ W% {) N: g4 j
};! V2 C6 \$ v V* K$ T2 F) A, ^
, j1 C9 _9 h& [: C8 o2 a( S
static struct platform_device da850_evm_tl_leds_device = {/ M- r% K/ G# s1 I" l4 R
.name = "leds-gpio",) w( v8 ?$ e- A7 s
.id = 1,
. A& e+ h5 h7 A% [8 i1 K .dev = {' u- X# h) l! @1 @& Z& e
.platform_data = &da850_evm_tl_leds_pdata,
6 A: C7 ?! F( M .release = led_dev_release,% c I$ p2 W0 g H( `
}
5 j% Z$ q ?% r$ T};
9 Q! O9 b6 \" X2 f, ~6 E- q5 k" c( r5 G7 D8 }) z' A6 y
static int __init led_platform_init(void)
$ ~; X8 H, |" ^% _3 B{
8 I A+ Q( n- y int ret;- |. z( _9 x2 I5 v
#if 04 O- Y+ N6 m4 ^' @, C& R3 y# h
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 m" ]! @) H( t Y8 P" X4 K
if (ret), @9 D8 R5 x3 a: Z$ M7 B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; V$ T( ]$ z b
"%d\n", ret);: Y4 ], Z0 I) u, q- t
#endif* i; k; U+ l/ R9 W( ?3 `
ret = platform_device_register(&da850_evm_tl_leds_device);4 w8 Y4 G- f) j# M/ v, G
if (ret)
: J0 Q3 U9 A" u) u pr_warning("Could not register som GPIO expander LEDS");
w) }3 e" ^/ g; v2 W; l0 U else
& J) U* g# o9 V6 o# h( z printk(KERN_INFO "LED register sucessful!\n");2 ? F0 r3 h- \5 S9 i1 o! A( E$ L
4 p! z; B2 c2 e$ n" |
return ret;0 r+ P! \1 X6 T6 o0 S$ j% \
}
# f8 h/ j% ^; w" Z, a) [& W) K& A! g0 `& }
static void __exit led_platform_exit(void)
4 x0 |* c$ r) m6 v{1 B F3 p8 w, A
platform_device_unregister(&da850_evm_tl_leds_device);
7 W3 X9 H# @8 B3 {% \" X* \! l( [; r
printk(KERN_INFO "LED unregister!\n");0 A8 l& N e/ g( v
}
7 z E: e: |0 w6 Q2 o9 D4 m% E8 g2 k# L$ S5 p' u
module_init(led_platform_init);
# M6 ~% P8 p5 J" K5 U" x `; ymodule_exit(led_platform_exit);
/ u z5 }% r; W5 ?7 j# ~* m. n! p- _" S- _# U: m+ s( j6 C4 C6 K
MODULE_DESCRIPTION("Led platform driver");
; U5 C' A5 t! EMODULE_AUTHOR("Tronlong");
+ x c; Q q& E3 A& q7 E n- JMODULE_LICENSE("GPL");) i$ D, w- T& Y. {, l
1 }4 A$ R4 c7 }5 `4 s$ _* t+ w& y |
|