|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 A4 ?; O: n% K4 Y" N
#include <linux/init.h>' ]: y- B& j! h" @/ Y" P, f
#include <linux/module.h>, [7 w; k/ X) X2 d# c
#include <linux/kernel.h>
2 ?5 R& V T# Q#include <linux/types.h>
* c. d3 T2 i3 c% X1 ^#include <linux/gpio.h>
i& m/ Z1 O4 ?! M#include <linux/leds.h>' I& b* e+ {& }) s- w) w( d
#include <linux/platform_device.h>
# }: i2 E8 L; D$ w; d ]) [ F2 @4 J O, B8 h9 q6 G
#include <asm/mach-types.h>
' J/ P5 P& ]3 X& |#include <asm/mach/arch.h>7 R$ S$ V# @% N. O/ R. t
#include <mach/da8xx.h>- x% ?/ d# ~4 b0 N w# F
#include <mach/mux.h>/ T' d& H) y5 a: Y: ~% V& i
0 r( k4 T6 [ y4 k0 ~: z4 P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) b1 r4 ?1 O9 D
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! w5 @0 g8 e8 d' v/ D9 m0 ?& G, m
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), h6 c" i; a- t' D+ Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- V' o6 S: s; m+ h3 Q! t3 K" C- t0 u8 l% c$ S- `
/* assign the tl som board LED-GPIOs*/* T \+ e3 f2 {6 p+ M
static const short da850_evm_tl_user_led_pins[] = {' o$ \+ ^; N& r% G% T5 O {
/* These pins are definition at <mach/mux.h> file */* ^; m' E) n# ~
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 d# q, t; B6 R+ V
-19 o3 J5 r) B Z0 R& x2 F
};# {/ ]+ F# H; \! V1 {8 G2 W2 |! l
$ p/ Y$ H1 e! w' m; k+ ^0 `
static struct gpio_led da850_evm_tl_leds[] = {
' }" \: {6 y2 l2 J {
& Y1 r c( }* T* U6 h: _7 ` .active_low = 0,! W' J8 C6 s. a1 ]; a5 Z" i9 h
.gpio = DA850_USER_LED0,
) _+ i# m6 m! E) d, K N .name = "user_led0",
h, W$ k2 z+ l' q" s .default_trigger = "default-on",8 b( I! ?3 C% m
},# x& O9 J3 s1 f$ u) j W
{ v# o0 ?. I' |, v" W
.active_low = 0,
* R9 o9 d* ` J; g/ q2 x .gpio = DA850_USER_LED1,% a5 }$ T3 v$ o
.name = "user_led1",
# A9 {, T1 l t2 p% A. h* A* d .default_trigger = "default-on",
( k F+ Z# x8 Z6 n% ^1 s },
G, S! Q! a6 Z5 y; \ {" W4 C( V0 o3 p9 Y! `; O; E
.active_low = 0,( `6 `5 _. h B) l# n, D/ _+ r
.gpio = DA850_USER_LED2,
* A1 I3 y6 U, f! S# C" t .name = "user_led2",
4 j- O3 i: A# v( K* R: a+ ` .default_trigger = "default-on", A- l! z4 ?; R6 L3 `! c
},
7 D. W5 T& A+ K2 D% u! h {
( `( r# N9 z! j" i .active_low = 0,- } t/ t f5 j, X; a( ], _* q
.gpio = DA850_USER_LED3,
0 ^0 X/ r" B2 V( H) V" U8 g .name = "user_led3",0 E" F R9 q1 P
.default_trigger = "default-on",
; ]/ m% ]( Q0 q5 S },: q4 A. e0 Y8 Z/ g4 I8 L+ f
};
5 D7 R k# b: {: g, b/ ?* i* l6 A
; v3 b$ v2 R2 n% l# Istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = { E8 I) P; ]5 Q* B' a" ?
.leds = da850_evm_tl_leds,
. F* [$ }1 g8 c% a .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% b* C+ @: b* s) Z};" F4 g p! _# H1 n0 P9 V
5 K" ~, \& j, W n
static void led_dev_release(struct device *dev)% c4 f7 H1 U/ V: {# x2 c/ G
{
0 f- j+ X( o3 c3 R/ I: O0 k};
/ I7 ]! g9 [" ]8 i3 S" u9 }' {7 |: y
static struct platform_device da850_evm_tl_leds_device = {
" @* T# l1 I' z( C .name = "leds-gpio",
; E% ~) i7 G( N% s1 U* b( M .id = 1,, e- a$ K' r7 o' i% B
.dev = {
8 u( K: q9 X# F0 ^ .platform_data = &da850_evm_tl_leds_pdata,
9 m0 G2 u7 r" @+ z .release = led_dev_release,+ E/ r3 A; ~( ]% m7 w6 o) K
}
/ p/ H% F+ [2 l6 G! ]) x/ }};9 }5 n& B+ C; B' @' _
( P# Z9 A: E& R# u3 ?3 b- q5 Q
static int __init led_platform_init(void)* a/ ~* i7 x5 x: ?# u! j( W- q9 b
{( O X5 b0 E) c$ v0 K8 E8 y
int ret;
0 |$ K) K& A: R6 F/ K0 m#if 0( ~/ x! b& T q7 S7 S
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' w! X! R6 g" w. j
if (ret)% v! B2 S, P* S: I; t; C# r% d
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ [8 K! R8 F' d, O, o4 S& U "%d\n", ret);) d7 |# N6 F$ d! j6 a
#endif; D' `1 {8 [( t! `
ret = platform_device_register(&da850_evm_tl_leds_device);- E6 d; y/ C% x5 `
if (ret)8 f; X; n8 D, R* F
pr_warning("Could not register som GPIO expander LEDS");- Z8 I/ Z; z% H* k8 m* I
else- y# s. n5 ]0 A# d
printk(KERN_INFO "LED register sucessful!\n");
: H& {. u% t, w! p. q$ ~1 F6 o% C k2 Y# y
return ret;2 x2 E; C+ J9 @& \* l2 m" k" {# O
}
* w* {' p. ~0 |* \
6 R# o& W6 q! S0 n, U. w% xstatic void __exit led_platform_exit(void)( b/ n, t# D9 b$ I. E7 H
{4 D+ @- s, v4 ]7 u
platform_device_unregister(&da850_evm_tl_leds_device);5 z8 `1 l# c0 Z# p* c5 Z
( \* H1 X; _- C! q printk(KERN_INFO "LED unregister!\n");/ a; d/ q1 h1 v8 b$ C C3 j
}
: a9 H5 c9 K9 d6 a! B; q# u) v
* q0 ~/ g+ p. e% ~& ?module_init(led_platform_init);
% ^' I! i4 t: o7 r/ Umodule_exit(led_platform_exit);/ B" p* {: _- ~8 n4 W. x
" Y: k/ g$ ]8 ]' w+ F) l
MODULE_DESCRIPTION("Led platform driver");- V. ]7 B* L r2 X& U- o& c( |
MODULE_AUTHOR("Tronlong");
8 ?+ m1 W4 L% X! H9 H$ G3 R8 D' |% eMODULE_LICENSE("GPL");2 U$ a% g# v' v5 _
' n1 c5 K9 Y3 I* w- I% D
|
|