|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! C; z) r3 {' U1 Q
#include <linux/init.h> {9 b- I) G( Z2 o3 ?5 \
#include <linux/module.h>5 Z7 G' ]) T. d) {6 N: `
#include <linux/kernel.h>
: D: e9 V1 _! A* [& S#include <linux/types.h>3 @- {2 D2 W, t
#include <linux/gpio.h>
& @9 }3 q% m9 A; t; w2 V#include <linux/leds.h>
5 [+ R8 F' _: c: E* `2 {#include <linux/platform_device.h>
7 Q) P. ]% D% R& u- C3 f$ W. R. O6 D: e A5 B7 l% z
#include <asm/mach-types.h>
: ?" C) t3 G% }#include <asm/mach/arch.h>6 D: x1 |3 h b3 M( i# I2 s
#include <mach/da8xx.h>
3 v1 L F" P1 _5 ^+ |; m: ~#include <mach/mux.h>
3 Z* ]( ~; R/ m, E; I' F. O
6 _2 Q: E" C, o4 {6 ], { V#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# `$ T/ V1 t" c! J l
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 f0 u; M6 Q: V+ o+ l#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 H2 P; U& y6 U; U8 @8 E" L4 L) Q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 V F# t% v% f2 R# s3 ^+ |4 S6 D# R, [4 R, d0 O
/* assign the tl som board LED-GPIOs*/
3 `5 ^4 o8 u }9 C* P e9 Estatic const short da850_evm_tl_user_led_pins[] = {( H4 w5 _8 x' B& x7 k+ T2 i
/* These pins are definition at <mach/mux.h> file */1 v7 Z- c7 m8 u, h* e
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; O8 j6 c; v N
-12 k) Q& n+ H- I# f( k z6 y
};
5 v& l: g% r- [: y% w4 T& i# w$ r* L8 b: t
static struct gpio_led da850_evm_tl_leds[] = {
! r2 q+ z* j7 Q$ \6 P& N {
' r# Q8 ?9 }2 q) { .active_low = 0,: W. b3 }7 m6 f: g7 S! ?( l3 p
.gpio = DA850_USER_LED0," C3 m9 U' e) \. g- J! O
.name = "user_led0",6 A/ x6 ?* h* g0 p
.default_trigger = "default-on",
7 K% h) w. P1 Q) K6 W" T },3 z: X! K& q- e3 \
{2 k7 {5 D" q6 X. _* o. D7 D. A4 w* I
.active_low = 0,$ X E4 r3 l% _/ n4 |
.gpio = DA850_USER_LED1, G+ S6 Y* Z6 D( [
.name = "user_led1",
) L4 B; w+ J! b3 \$ m .default_trigger = "default-on",2 b4 u: ?# |. u; R$ I
},
6 b% J: n8 O; X+ S+ L$ Q4 w* ?+ b {8 w0 L& @! d: N/ }
.active_low = 0,* J, ^6 H* z# H% g( j I8 o. A4 y
.gpio = DA850_USER_LED2,
9 x# I# V2 |) V$ P .name = "user_led2",
- J2 T. u5 n; W: U5 D .default_trigger = "default-on",
7 M9 K1 q& `0 z' [5 k1 B },
* G( z1 ?. U8 R7 F' }; y {# j" b ]4 o* W9 C v
.active_low = 0,$ D1 V" c7 {. W M% P7 P- S
.gpio = DA850_USER_LED3,
* C0 e# |5 F' u% q4 J; I, K v$ T .name = "user_led3",; ~. |- W' G, x+ T" j# v
.default_trigger = "default-on",' l& j, f( `* b7 J/ l8 x
},
: M" ]/ D0 B+ e! ]};
) z3 ]) E+ i4 W* d6 A, ^. W2 z( G' e' c. M. r/ h
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
8 K$ E( R7 K5 h2 W2 I; Q2 z .leds = da850_evm_tl_leds,
+ h+ Q2 s/ E$ q$ G .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* D7 G% c' f6 x/ v6 z};, R, R4 @1 L1 Y6 m6 ?
; w" b1 k' p' @2 H9 Z; W% vstatic void led_dev_release(struct device *dev)/ m! @6 q7 G, |' f8 P
{, E/ i, {1 ^6 v3 o" O. P
};3 a7 H! D5 @) V: E# e) T4 z L
+ r3 [: `4 g0 F; u# l) ]static struct platform_device da850_evm_tl_leds_device = {* n. r) J6 u& S& A* m
.name = "leds-gpio"," Z6 T/ @6 W: k3 c' U' f
.id = 1,
7 R+ i0 h' w; U% \, ] .dev = {* G7 h9 j7 b- D0 q' I/ ?: ?4 C% w
.platform_data = &da850_evm_tl_leds_pdata,
4 q% p+ I2 l9 V+ j .release = led_dev_release,2 n _& m$ O" r0 }4 S5 V+ x+ F
}# ^3 R$ m7 E: F3 Z& Q
};
; x5 P3 N! c3 x3 r: r, |4 t/ J+ ?* @* `
static int __init led_platform_init(void)
+ L' v. l9 w- A. x# ]% e{5 r% k1 {+ K* |2 [4 s( X% {4 M: j
int ret;+ k5 P9 l. M! e$ }' v: y0 H
#if 0
5 [6 o/ ]# R( H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 t* `* ~( }, L if (ret)
, m( K. {& |: j# e2 n; t i' U. p7 F pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 w/ q+ ]2 t7 [+ L `+ r, p, a "%d\n", ret);! n4 R6 t; m8 _) i: q
#endif
' a5 @" C# i. c8 q8 i" { ret = platform_device_register(&da850_evm_tl_leds_device);2 m% j! f d- S+ o
if (ret)
2 g/ X' @, E% L5 P$ w8 h pr_warning("Could not register som GPIO expander LEDS");8 f. y. {: { W* }; }9 [, C
else! L$ M; T1 h8 O t7 L
printk(KERN_INFO "LED register sucessful!\n");7 L4 G+ h' H2 t" ~1 c a1 @$ ~
2 |! I% B/ [* p: Z7 f& K return ret;
! M% y5 v: p( i0 F, I- ~2 F}
6 d @- H' T# l1 R8 w% A
6 u: u Y- B( B2 f, wstatic void __exit led_platform_exit(void)
$ Z6 s& j; y' F/ L4 o- L' p{' O8 L0 j; B, R! O9 q/ }
platform_device_unregister(&da850_evm_tl_leds_device);
" u. k+ ]0 E! Q1 R3 \
8 }) _6 N5 d' l printk(KERN_INFO "LED unregister!\n");
: @% M7 H- ~8 o: u0 v}
8 w4 o9 ~1 a0 F: F
4 F( ?1 J/ G( U2 X/ Kmodule_init(led_platform_init);
% `/ G9 u* h% m8 U* Nmodule_exit(led_platform_exit);
9 F4 B; e3 j4 I4 f7 Z/ V6 L! N* S' a3 ]8 U
MODULE_DESCRIPTION("Led platform driver");
W9 x' c+ _9 |, }3 j& D: C; n& _MODULE_AUTHOR("Tronlong");
/ P: t. @9 F) W) ?% c. i# WMODULE_LICENSE("GPL");. E# Q- ~, G3 Q9 t8 d- P4 E; E* {
( U, E0 W" X$ L) @" y, n c0 `1 g: r
|
|