|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
+ ^4 j3 S+ h7 E#include <linux/init.h>
k- ^# n$ @( ]( F6 i) R: {# u#include <linux/module.h>
. F" {; ~4 P+ ?#include <linux/kernel.h>8 F$ s4 d! u9 H: Z7 |
#include <linux/types.h>2 _; X# i& t! u
#include <linux/gpio.h> t- P1 r4 g( w' X E) z
#include <linux/leds.h>
t" }8 O) k) L1 I( v#include <linux/platform_device.h>8 K* h2 s2 W$ @( b
- M& }, V- {' T8 k1 E& ?# y
#include <asm/mach-types.h>
9 B1 w9 ~* b4 g8 J8 e#include <asm/mach/arch.h>% ?$ }. q, a0 I% S5 R R9 T; }
#include <mach/da8xx.h>
* Z3 m* A+ [3 Q f#include <mach/mux.h>" g) [" c3 g5 q M
% u4 H$ h+ U; R4 I9 B4 l- Q$ V#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ i7 r; {; c# C8 y- x& r6 I#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): [& |1 \+ A2 i8 b3 b& v" e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; R5 F' D; a% y2 V; J) d0 x' n. w/ B ^7 w#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* P# L+ R+ z, S. @/ M" ^! t
! N6 S8 h) c% m$ F" B) M* n' C/* assign the tl som board LED-GPIOs*/
7 y. p1 l. E7 z7 a/ Lstatic const short da850_evm_tl_user_led_pins[] = {7 B" D w8 {' @. c$ f( h
/* These pins are definition at <mach/mux.h> file */$ u% Y" |" G1 \) L
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ `: i, T9 K+ `' d -16 w( N6 t) T+ h7 D
};
, @# i: I7 c! l" @" ?
) k: e4 d( ?; a/ Estatic struct gpio_led da850_evm_tl_leds[] = {, K* Z$ S6 C/ E
{
~! `+ Z& i3 D+ E! K9 i .active_low = 0,
: K. E0 k; V- j+ @# y9 R8 Z9 _ .gpio = DA850_USER_LED0,9 m& w$ K" w5 j+ w: Y- p
.name = "user_led0",
J+ z2 ?& ^* @* ]7 C .default_trigger = "default-on",6 O% n8 {7 c# L N/ D
},
0 `! v% u" i$ k1 f. P8 j {3 p( ]7 R" o1 O+ N
.active_low = 0,
8 I3 p* d* w' f .gpio = DA850_USER_LED1,8 I3 k2 b1 @$ {8 k
.name = "user_led1",5 @ K) I/ R P) P- V; D0 t, V- N
.default_trigger = "default-on",
+ y- u- c* \8 f8 D8 D },
4 q* V( m0 n) Q' B7 L {4 a. W- P, `! o( r8 C
.active_low = 0,
9 Q* o& v( D+ f: A9 Q) u" e .gpio = DA850_USER_LED2,
8 d" W8 X6 k N# v; k" F .name = "user_led2",
3 Y: Q8 i2 Y& e) M+ y .default_trigger = "default-on",
- u4 C3 G( V# b6 p* @$ z5 W4 N },$ |7 E7 Z* J8 `$ ~1 h" u* }
{% N- S6 m. s, F. b* u
.active_low = 0,
6 i) i' W) d0 u A .gpio = DA850_USER_LED3,
% P, a4 I! `! G8 D# R1 { .name = "user_led3",9 P' H- I- V- A8 Q
.default_trigger = "default-on",: `! S1 f G% p$ E) ~, y
},' k, f4 Y7 y: K6 b0 T: o, t) h
};' H4 v( `; k; N9 J4 j+ a
4 R6 C) M- V' Y/ v& R# f- w
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ H7 T, ~. P+ D9 g" P R0 n6 @1 v
.leds = da850_evm_tl_leds,* O* Q9 K( L! C% [& ~# w: f1 _
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* k' K, B8 M! j3 ~, ~% t. R};
; A; h! b2 i( O: K. p+ W+ H7 c7 T; C) D# k4 Y2 t$ J2 _( M% M
static void led_dev_release(struct device *dev)/ n$ y5 M7 c$ q
{
) ], g2 n$ C8 G$ ]3 ?) K0 M};
P( w8 W. s" O0 C8 }6 X* `: r' u: n+ o! K1 r7 Z, g
static struct platform_device da850_evm_tl_leds_device = {. Z m; |5 s$ O8 z0 w' |3 I- J% b
.name = "leds-gpio",
`; b8 |% c( e; e2 W. v9 }! r3 x) z" k6 o .id = 1,
. X/ ]4 c! M) o" u' O .dev = {
" t1 I2 }6 A- F& @ .platform_data = &da850_evm_tl_leds_pdata,
" _6 C7 a( e$ l1 P/ ? .release = led_dev_release,
, q2 p" n/ f* F& c5 y9 t } p4 }+ @/ ^# s
};
, Z' I1 n5 |. b$ x9 Z) U& _. B; x6 f u, }- |( g. o& u- B
static int __init led_platform_init(void)3 Y4 [* ~- N v# Z" |
{/ `2 R" G9 x* _: K: A8 `
int ret;5 M3 i- I% N0 @% U
#if 0! ?# t) S4 q4 {7 [3 v
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 f. N% o: W5 ]$ e if (ret)& y. L' f- W# G4 k8 ]: P$ H0 k
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 Q( `$ J* O1 z0 h "%d\n", ret); ^$ ]' {4 x* d
#endif
1 x( G7 z( f9 v1 @5 _+ S0 Y; M ret = platform_device_register(&da850_evm_tl_leds_device);
8 r* |, V4 F2 W6 C! F9 h if (ret)9 y+ k1 T2 J% \3 ]% m# c
pr_warning("Could not register som GPIO expander LEDS");
) K. u7 I7 G9 B& D, h else
# L# p$ w" L% B( c# m printk(KERN_INFO "LED register sucessful!\n");
: h! N @: N7 D' _% K k" P' e) x4 e' {/ e
return ret;9 Y' R! z6 c. k0 k
}$ C, {: c, K8 s0 n( j1 c6 m
, d: P' K$ r( F9 A8 e! k+ Kstatic void __exit led_platform_exit(void)
" H- ^; b8 `# s6 ]$ W& L5 K{
7 q3 d8 Y3 s( V5 k platform_device_unregister(&da850_evm_tl_leds_device);
( L' b; D' w l" \
3 ]6 P$ l D; x& y" S) J printk(KERN_INFO "LED unregister!\n");
- M$ O5 {+ p, |: n+ _4 V}
9 y9 W% K! _2 j. B: f' W; t; |) H
module_init(led_platform_init);
7 x9 ?/ V. Q' R4 b! t* _$ }module_exit(led_platform_exit);: ?% l! {5 E8 t1 g; R
2 `- w4 W0 {7 R5 l! o
MODULE_DESCRIPTION("Led platform driver");* Z2 a6 Q6 D/ Q, G! Z
MODULE_AUTHOR("Tronlong");9 Y- w# ]9 ]' C' n4 p
MODULE_LICENSE("GPL");: l* S6 ^! E l. s
9 c$ U& Z& `+ S% q
|
|