|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% }- R& [( l, _#include <linux/init.h>
/ \$ d7 u. m2 l$ }9 c% B$ b#include <linux/module.h>
, G" t$ L; f( u( Y4 v. t, a0 ^#include <linux/kernel.h>5 R2 F- ~* F) d
#include <linux/types.h>$ [, B7 S4 A9 e* U* T) E
#include <linux/gpio.h>
( I1 _5 `3 h/ I: b9 z#include <linux/leds.h>
4 }, Y1 S$ o! k" v#include <linux/platform_device.h>* ?, G/ H! v+ O. ^
: x2 f3 G( x, N: b+ Y. y
#include <asm/mach-types.h>
( Q2 W! k" Y6 C- x& F#include <asm/mach/arch.h>
0 I+ b% b) l+ m! T#include <mach/da8xx.h>1 N, l. ~- Q5 y1 w5 T$ i: g( Z
#include <mach/mux.h>
+ Q) S# Z$ P8 V" ]) X* a1 h3 @1 t
/ \4 s2 z- u+ a P#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 D7 u, x' U! l: K7 x1 s. E% P
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# O& M! H, ]0 N& k3 t#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" [9 }3 Y* s/ Z8 T) `) g#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)5 t; \6 O9 W* X) G2 L1 v
7 I; p7 z7 n$ G2 f& T* k
/* assign the tl som board LED-GPIOs*/, J! X! V- \, Z$ m# q
static const short da850_evm_tl_user_led_pins[] = {: a+ ~9 K' `; M: N4 M
/* These pins are definition at <mach/mux.h> file */( ?2 i' j* A5 ~% G
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 y$ m- K9 H7 Y3 m$ u/ h' a, f r( { -1
+ t) d, v; {) |: c; G3 K4 N};
O; d, T2 P2 j$ ]" T( g$ x# }- Q! c5 p6 H4 {$ E' X
static struct gpio_led da850_evm_tl_leds[] = {
/ S3 q, J7 E/ T2 `2 O8 w% d {
* ^4 z& j' E0 b+ y0 w1 O. h. y .active_low = 0,
! G: c! a7 g# O4 y" d: x7 t8 D1 M .gpio = DA850_USER_LED0,# I5 Y$ N' G4 z0 S/ S; d0 Q! Q2 \
.name = "user_led0",( m. U( |5 Y0 M
.default_trigger = "default-on",
! o5 l8 H+ n2 Y },% U: G, n8 A0 X# J3 j9 [# G; |
{. h$ I- [* K7 E) k, ]( [: n7 |
.active_low = 0,
# A- Y+ f0 U( c" P) _ .gpio = DA850_USER_LED1," b; p: |( }- U
.name = "user_led1",
8 M% Y" E" I# V' _: Q .default_trigger = "default-on",3 x; b, \- v" X# l! Y
},1 B' h w4 f, N5 L1 j3 ~
{5 @8 z4 u: n5 j. w" `) ?
.active_low = 0,
9 n0 |0 a! p7 W) `2 l/ ?& l" @+ a .gpio = DA850_USER_LED2,
1 N7 }$ }$ Q+ d% [3 i1 }; Q* C8 _ .name = "user_led2",( |) ]: Z: i2 d; R
.default_trigger = "default-on",1 n# g. f6 N, b0 q
},
4 p" _- t2 p4 j8 s5 G7 e# O* ` {
; ?* X$ m5 N( a, q! ?( C .active_low = 0,' g( M; t4 `5 W {; D
.gpio = DA850_USER_LED3,
& z0 h9 Q+ q2 L8 x6 Z .name = "user_led3",
1 `+ a' [ S9 L v% { .default_trigger = "default-on",
y% T& x" n: X, x/ T },
" b) w3 J5 o/ e k};' H" w; s6 H0 V9 e. y9 }6 x
$ }6 p. r0 q M5 ^ {: O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 G' x9 L/ D, q( [8 @$ Q6 \: B, G .leds = da850_evm_tl_leds,3 A$ T% F9 D+ v$ @6 |
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),3 {$ b$ T# }" s6 }0 S0 ~
};" E1 ^& o5 ^/ C2 `7 n! x M; V: u
3 Q9 t% U( k5 h- hstatic void led_dev_release(struct device *dev)' W. ^& K9 e' w" n4 _
{: S+ z) F! E% @8 s
};$ _3 R) X$ H7 l0 \7 z
3 T1 z; O% g3 G+ h2 A0 x _
static struct platform_device da850_evm_tl_leds_device = {/ N _! L9 {- u! e
.name = "leds-gpio",
; M u+ ]: y5 G# @ .id = 1,7 S) A: M# A# B' ?" r) x
.dev = {3 F/ z& }; g7 c1 K. \# F
.platform_data = &da850_evm_tl_leds_pdata,
% v. P* K! S& C# _* X4 q .release = led_dev_release,) @$ ]. x9 _. `9 a! J
}
1 r" W! @8 @5 Z};
* _: b1 S' X1 ~2 l7 D+ n- L0 j r7 \) H3 R' U
static int __init led_platform_init(void)
# i( U% B8 B8 b- p( ]- \ @6 j{
& t8 V# z h. i, N/ a1 R int ret;! D; y# m4 Z h* t" [
#if 0/ H, D. ?$ x8 b4 b. t! `) g3 i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);) D6 b; Q; P$ m2 f
if (ret)
7 g1 x5 f' H Z8 }4 b pr_warning("da850_evm_tl_leds_init : User LED mux failed :" M- Q. b5 B% R& T
"%d\n", ret);4 w& [5 T, ?4 M3 ~
#endif
4 r, B6 H( s0 O% g3 B+ Y; @ ret = platform_device_register(&da850_evm_tl_leds_device);, d+ T) Y' C. b. Z
if (ret)
a8 U- e# o$ {6 I pr_warning("Could not register som GPIO expander LEDS");* N. d5 f' o* Q; U9 P v+ W4 s+ x
else% Y6 c2 |* g+ P, m% }6 h
printk(KERN_INFO "LED register sucessful!\n");
+ W: f h8 w: N) X- ~" I2 Q: i/ |/ Y/ |8 W4 j
return ret;1 e# q' \8 K, |6 N+ _
}1 {7 ?. q0 u$ r6 [* s/ k/ `8 a. E Y
& W/ u: O9 w p0 f8 ^% i% y2 Q) i
static void __exit led_platform_exit(void)! U8 K" @. R0 ^9 C1 p+ X+ g- h" Z
{9 C; [! G. R- d/ C' ~ N& i9 T
platform_device_unregister(&da850_evm_tl_leds_device);
, u, l1 s6 ]! t
# N% g6 q$ ^# q8 _7 V9 ]) Z printk(KERN_INFO "LED unregister!\n");
: }. x, R- T4 M$ _ g5 `}1 N! v$ k/ e; V7 {1 `" U x4 y- B- m0 e
* ^7 M' u" F. n' A* X; a/ P7 jmodule_init(led_platform_init);
; Z1 _6 m' V! v' i( }8 Rmodule_exit(led_platform_exit);; g, b1 O9 y6 H9 b y5 \
5 M- f2 u- c/ A. bMODULE_DESCRIPTION("Led platform driver");
- ~7 L8 Z' F, e) C2 J% nMODULE_AUTHOR("Tronlong");
2 d) S% u# u% @2 w! NMODULE_LICENSE("GPL");
: {7 J: ~3 b% J$ y' M6 e1 k2 } ^$ g0 i3 ~
|
|