|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ }! t: v* d9 R#include <linux/init.h>
% m# g% l# Y% f8 O) Z+ F4 E. y. t#include <linux/module.h>
6 ?% N$ o4 p* W) Q/ [$ h#include <linux/kernel.h>
/ @/ H1 G9 P" D& W" S7 J G! E#include <linux/types.h>
- \& X0 a# y! {$ A% I; U#include <linux/gpio.h>& @* ]/ I) y, s/ K9 i) X
#include <linux/leds.h>0 ~* K9 x+ ]$ t2 l' ~* w2 n
#include <linux/platform_device.h>% U5 H% b9 v5 n1 D2 H8 l! t
1 z5 A& |$ [' N3 E9 {( Q0 L& F! B/ t
#include <asm/mach-types.h> ]5 \* i2 Y7 ~
#include <asm/mach/arch.h>
& A" i) S3 Z2 F. _#include <mach/da8xx.h>1 u* l' t4 O4 x* U; M
#include <mach/mux.h>
, o8 o P& ]6 B: Q' r2 F+ u
7 j6 g7 v% E8 ?+ t( _#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ C5 b3 X! s+ M; m7 N
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( Y$ x$ `& P& f8 m, W8 |2 a0 J#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ n2 Y, O) [& i) F2 {9 G3 w#define DA850_USER_LED3 GPIO_TO_PIN(0, 2): Y- e! ]: e5 l2 N6 I
4 l( Y' C+ q$ s; e/* assign the tl som board LED-GPIOs*/
1 F8 a" a+ c$ B" g; j5 @7 U( Cstatic const short da850_evm_tl_user_led_pins[] = {
+ H3 `& B# S( E3 g0 @ /* These pins are definition at <mach/mux.h> file */, c+ D# L% Q2 [4 H$ l: I: ^1 q$ F, D7 D
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! k# c* b( B9 J/ ] -16 o* k& O7 X& c; O" ?' J8 F$ J% l" A
};- [5 h& M7 A+ x" f8 c
* L% R5 g. @% u0 }static struct gpio_led da850_evm_tl_leds[] = {
3 v! W* d g% ^ {
2 d+ K9 L- R4 G u& D( } .active_low = 0,. V. \. _" t- \
.gpio = DA850_USER_LED0,7 J' R* f/ U$ U, y4 I0 P, K
.name = "user_led0",
) m4 O" D" A% T; d .default_trigger = "default-on",) h; T+ Y: E. l6 k. l% G
},% [# l) j. W7 D* D# q
{0 U9 [ U( h& m' l) o3 C, ^
.active_low = 0,* R9 Z# g0 l( H, `! T y+ t$ w
.gpio = DA850_USER_LED1,
: o2 q/ K! k! ]6 i .name = "user_led1",2 q8 p* `7 d) h& {0 h! p3 G* `
.default_trigger = "default-on",
% s( b9 X$ j* P },5 w$ f2 O. J. a0 Q$ e$ s, l
{0 o" v! a* F0 _* i
.active_low = 0,
) m( I& v6 g) ~ .gpio = DA850_USER_LED2,; {! M9 T _9 U; o# J
.name = "user_led2",' Q+ w9 a6 y" M b: S- g9 n1 V" ]& K
.default_trigger = "default-on",
/ p9 i! x) L4 a& I/ w: C; k; x8 X2 F },2 u0 d- E9 u' [! Q5 I2 r0 {3 T3 S
{5 J% ?. x& b' @& [5 N
.active_low = 0,
1 x% t9 z3 I: U2 \0 t# _ .gpio = DA850_USER_LED3,
+ z3 \1 }' j6 Z5 K2 {; j .name = "user_led3",
" o" l5 U% b+ }: b3 I' W8 a .default_trigger = "default-on",; m) e& p! e' y2 ?: [, p7 s1 L
},
, Z) Y6 T/ T% u3 ?# K7 c$ Q};
- i" R0 Y2 g6 j# v! F2 i- F' Z0 g6 a1 T8 h% D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 P# E" P+ k) N% _ .leds = da850_evm_tl_leds,! ~' f5 z- I: w! A- t2 k5 h
.num_leds = ARRAY_SIZE(da850_evm_tl_leds)," M/ ?& ]" d9 F* a" W Z
};3 W) @! {" h+ m! m) E$ h1 G+ p
$ V. {: {; q% U/ A: tstatic void led_dev_release(struct device *dev) f1 t7 M) ~0 P# f. Y" D
{& U: {+ s0 W |- ~
};8 G: c. C. j& |8 U2 @
. E" ~: j2 I; u" h, D- z2 nstatic struct platform_device da850_evm_tl_leds_device = { U( ^! p2 [. s- n% R2 l: d
.name = "leds-gpio",
' Z1 O4 o3 T( I .id = 1,
{ ~/ `' q# }% T& |/ b .dev = {
5 G# K1 g3 N Q. P: I .platform_data = &da850_evm_tl_leds_pdata,$ }+ E, h+ b7 \6 D! t
.release = led_dev_release,
4 T7 P9 n8 u- n5 y" }# m' z }
8 y, o6 T' q5 p0 h9 i};4 P+ X! M5 M( w. `. B! f6 s% p/ p
0 D: |; b! p/ v3 H) P( estatic int __init led_platform_init(void)5 W7 F I( p7 V$ O/ ^
{6 `6 @" p6 K% R" Q+ j' }
int ret;
% B; \% |6 X" T9 t: y7 V#if 09 |/ V. i: D- ^
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! t) r0 l# {8 `
if (ret)9 L X; Q- c3 e8 I2 |% Z7 p2 v0 p5 N
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! X8 a* X- q- R; j ^: S! ]7 Y
"%d\n", ret);
+ K7 g: R% S( o#endif. \9 D" f: \9 @+ f9 w
ret = platform_device_register(&da850_evm_tl_leds_device);
; o' s# m9 y& w- h if (ret)0 U$ Z! G1 Z7 R. [& w
pr_warning("Could not register som GPIO expander LEDS");+ P& r0 F1 a$ u3 B. A7 E
else _% [! | o- b2 J: _, @; h
printk(KERN_INFO "LED register sucessful!\n");
' ^9 H: \. p) z* M, y
0 y5 O* q4 C! L' G return ret;
?4 Z* U/ e8 Q" J; p}
) M2 C, q0 E% _* y4 R6 M3 w/ Z5 p, o& i, M6 N2 w4 [, [
static void __exit led_platform_exit(void)
x1 q# J* ~! \% j/ l{
9 t( P' {3 _$ _; | platform_device_unregister(&da850_evm_tl_leds_device);. {% B9 Y. v, n( n u# j7 N6 U
. T1 v; ~+ N1 w/ A+ g& o printk(KERN_INFO "LED unregister!\n");
" w5 B4 m! E; Z* f, Z}
: y! T& M' u* f: F5 t) }0 j y4 C& C( ?7 I, N, w
module_init(led_platform_init);
$ I0 ]# P* |' C! W* T6 Kmodule_exit(led_platform_exit); V2 x, _' f. Z5 }) m6 {6 B; u
3 X: ~- a9 C% ^; F6 c
MODULE_DESCRIPTION("Led platform driver");- j7 [4 W0 ~9 L8 e9 o
MODULE_AUTHOR("Tronlong");
# B" t1 r/ n) J d& a7 C7 J. A$ XMODULE_LICENSE("GPL");6 m- w6 w2 \! }, E' g. |( q
( W6 p/ b8 l/ F |
|