|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- D2 P6 o% z( W* ]#include <linux/init.h>
9 |2 ?: w+ d, M& P. W- n4 f#include <linux/module.h>, G9 k6 a" A+ G' p7 p& `: `9 i
#include <linux/kernel.h>
, j( o1 ? G5 u- B" q#include <linux/types.h>
: m7 M" Z5 o5 B/ j5 d* U# R# A3 @#include <linux/gpio.h># h6 h3 P C4 H: V* X) h; p
#include <linux/leds.h>! ^' f% F# c4 x: ^8 W
#include <linux/platform_device.h>
% R6 Q) _9 D, t P( ] ?2 j6 {; ?- b* p: _
#include <asm/mach-types.h>
) S& c, {8 |" r$ G0 F7 \$ X0 [+ u#include <asm/mach/arch.h>+ @+ C( J$ l" H2 P/ u
#include <mach/da8xx.h>. C2 D0 n T! `, D: J$ [
#include <mach/mux.h>+ E0 Z: v+ x/ D w! H% S! l9 `- |
3 H/ l$ _% B# F9 U#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ _2 _6 c6 B) }0 N0 {/ u% I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& {' @1 p& C% C#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) k& g: D6 Y9 W, u& D" V X$ A
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
I& g9 K2 k% ?- U0 Q8 \& _: d& c7 N$ v% G
/* assign the tl som board LED-GPIOs*/
1 H4 Z7 A+ F9 B: X D9 H8 `static const short da850_evm_tl_user_led_pins[] = {
: m( d& N% \: X& S% P, R- x j /* These pins are definition at <mach/mux.h> file */
( d) Y6 S* m6 t+ B$ G% s- i DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% v+ S' o& I( m8 G3 L
-1 m/ W! {$ S4 z: [, K
};% O( B7 _) V+ E) O$ b: |9 k
6 }1 A- h' d: ]2 w' j; Xstatic struct gpio_led da850_evm_tl_leds[] = {) |) `) f) {7 p M$ e3 ]* ^
{4 o8 A4 S$ O& m1 A6 Q+ k5 e8 o
.active_low = 0,3 S+ E0 Z& g- X
.gpio = DA850_USER_LED0,
( Z6 d) I2 N& A: Y$ _/ L5 U% G .name = "user_led0",* W7 T ~, |4 g }
.default_trigger = "default-on",5 `; R2 R9 B/ ?9 _: Y& [
},
& r+ `' O5 Z9 S- o0 u: d {+ U1 [3 P3 E. K; x
.active_low = 0, W" n1 y U( `* r, h6 Q
.gpio = DA850_USER_LED1,
5 P( U8 P7 D* E$ `5 y$ c6 _ .name = "user_led1",
4 U7 b+ G2 J- C9 D4 }* q .default_trigger = "default-on",
' W$ R0 U! g4 j8 O* n },
! V7 `8 a8 U: D) h2 L/ f( L {
0 B5 y9 A' E6 }0 o, P5 H; o8 O$ Q .active_low = 0,
3 j O; P. R3 ~5 d2 I .gpio = DA850_USER_LED2," Z; f: U" j J8 ]- m; |
.name = "user_led2", D& r/ L0 @) m1 t
.default_trigger = "default-on",
4 y# e2 N4 m! h5 N* @( O1 L },4 l& H& ?: b) r
{
. x+ g. d8 y5 d .active_low = 0,4 }. ?5 ?( c5 c3 n7 T7 v) p
.gpio = DA850_USER_LED3,
; w9 }/ |( c- x .name = "user_led3",
B: l+ ~/ @( u L1 R' V! s: ^) S .default_trigger = "default-on"," n, ]" }/ a+ \; H6 T+ s i5 y
},
& Y" L8 s2 ^9 `" P! x: O};
8 H: [' d( @. I9 t0 N* R+ C w( I% {
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' U( }1 S, C8 L0 d4 g/ Z, P3 o* u) u6 H .leds = da850_evm_tl_leds,
* _4 B9 p% a: y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
K1 x+ F& k. J};
1 I0 A" ?9 O# V8 h- p$ |' Q. N
7 L8 x4 @" h6 E. J( pstatic void led_dev_release(struct device *dev)0 _: t+ `) ~2 P, R* P5 q7 `" ^/ f: f
{9 g5 Z' P/ K9 x3 O/ O
};9 l; i0 D+ k8 ?9 M! J9 e8 c/ s5 q
. c+ ]$ T! i6 V1 T) h; q9 @static struct platform_device da850_evm_tl_leds_device = {
+ f8 U. w8 ^& \) l* c6 }! [& y .name = "leds-gpio",
5 c N; i }3 K) i2 X* a$ f* S .id = 1,( r8 `8 B9 f7 O: s
.dev = {& Y( i# w8 d3 i( ]( T1 V# ?
.platform_data = &da850_evm_tl_leds_pdata,
& A) |& ~- o) {( ]* i .release = led_dev_release,& h2 u7 c) [8 F7 b3 e o
}, I: Y! Y, m* C+ ~
};
& U8 G) ^& {. g3 O* k5 B* r# n7 x% c+ S
static int __init led_platform_init(void)
1 R9 J* t3 x+ u2 b8 X{
. x3 R+ T3 I6 |4 S# Q. B int ret;5 {7 r5 E! j( c4 o" E
#if 0# f" k! n1 |" K0 U `1 K
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 K& b1 b" r& p" E* G) F7 ]
if (ret)
p2 O1 ^, Z" k9 g3 E" a% F pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ d5 q# ^ I. L! V
"%d\n", ret);
? |- ?1 v6 ^5 W3 ]#endif+ ~0 ?) r4 U2 ~$ N; C/ d6 Y- K
ret = platform_device_register(&da850_evm_tl_leds_device);
& n8 S& K5 i" N/ f if (ret)
]* T0 T- [9 J pr_warning("Could not register som GPIO expander LEDS");
! [" I/ H8 V( Q% r' w else
% S; v, z: o) C. T printk(KERN_INFO "LED register sucessful!\n");
2 H7 q# Q5 ], F) D+ g0 k" u: M& x0 w0 \7 y4 D
return ret;1 D5 W9 O5 D$ Q$ x4 i( f
}
6 B. O! V; v; u1 l, D: H; U, ?" n# F% F8 p; m/ X
static void __exit led_platform_exit(void)
( X# ]" H# ?/ }5 i! g c{" b' Q W4 |, x9 U5 J/ I! G
platform_device_unregister(&da850_evm_tl_leds_device);
. f; m6 T5 x1 ^0 C& ^+ _* u% k$ q: H( k/ \0 k
printk(KERN_INFO "LED unregister!\n");
& Y3 U. W! a+ X) ]6 }6 O}
) S$ L9 [+ K1 [# R$ {, j& u
5 f" [# h# I9 J) s! t" f) A) Tmodule_init(led_platform_init);# `# X4 \3 [ K8 W1 D4 W4 a5 g
module_exit(led_platform_exit);! U' y: l/ X6 v
+ \0 M" F8 \2 h3 ~7 Y/ s$ _
MODULE_DESCRIPTION("Led platform driver");- h8 A, B8 R5 v9 }3 E
MODULE_AUTHOR("Tronlong");
$ O# J' b8 j+ \4 lMODULE_LICENSE("GPL");
" s5 i \2 u6 b7 D
7 j9 v& B. s. X( K p |
|