|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 s4 c; m+ @% p" m( |4 D( i& t( `
#include <linux/init.h>/ Q$ i' S5 n# |1 V' W' y0 ^: D/ ?% y
#include <linux/module.h>. i; n8 |6 E" x6 R2 g5 \
#include <linux/kernel.h>. a- I8 J$ e! p% E: Z
#include <linux/types.h>
) j3 _9 y$ W g5 I. F- k#include <linux/gpio.h>- B+ l) k! _; U2 P
#include <linux/leds.h>0 `( _- V# E8 O, r" n# Q3 d. w
#include <linux/platform_device.h># _' s) Z# q* H0 y
^8 g- f* P$ W; W& s0 ]+ e
#include <asm/mach-types.h># c: Y" c( a- O/ ~- [0 C& }2 R
#include <asm/mach/arch.h>
+ Z3 J2 c7 N: ^% {7 ]+ y, X8 }#include <mach/da8xx.h>
5 x, z; `& x+ A4 n* q( g#include <mach/mux.h>
0 T$ \0 N. r |0 ~$ ]3 @
# z$ G6 s9 i; D#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) n U. i. W' l7 u7 O0 A) X) B
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 T) u; O) k1 j: u$ }1 I
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 T$ d" H- s1 ?. Y; _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
7 T( T0 q0 g. n8 G7 g+ t8 A' F+ d: o5 {4 x
/* assign the tl som board LED-GPIOs*/
! z& _& N! W+ Y+ m2 hstatic const short da850_evm_tl_user_led_pins[] = {$ \. m, L2 b' Z" W1 [0 ?. u
/* These pins are definition at <mach/mux.h> file */' a" e* m% T; Q& i3 ]
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ [% k4 A$ ~; C; o; n
-1
6 a3 d2 o# V# W# ^};
& [3 x# e* Z* f2 z$ O
; S# u& q, t: B( P; b; u( x& Tstatic struct gpio_led da850_evm_tl_leds[] = {; m& G, d2 ]$ j5 b
{
; z5 O: K3 e. @ .active_low = 0,
" M' j3 I. c8 T8 w: _9 P* o7 m .gpio = DA850_USER_LED0,
J. [) i3 }' n2 r' J9 \% d .name = "user_led0",
# H9 |/ D( f: }. A: B9 y3 e .default_trigger = "default-on",% U$ w6 c6 L9 F9 ~
},6 N) e2 W' i( @+ B! b
{
Q. x; G: A I+ B1 V .active_low = 0,
1 s- I+ w1 F1 U3 a& R .gpio = DA850_USER_LED1,/ w; [) q. ]: C: g* i- L) `. n
.name = "user_led1",! c' z1 i* o7 d y
.default_trigger = "default-on",/ |, ^/ Q: V9 S# C7 p
},+ S2 H: a. d; l& x& `1 a
{7 c: V4 T: F. Z# w! X/ g+ \* z
.active_low = 0,
. T0 |6 r; @ _8 c- y/ W. X. F4 q .gpio = DA850_USER_LED2,
0 y9 u6 y' b' Y, e1 P .name = "user_led2",) Y: x% J5 n/ w* Z+ Y
.default_trigger = "default-on",
/ M- n9 c7 }& n$ I },
1 U( M7 S# T2 p7 W$ c. W% ]$ S {
) \' n0 ~. U$ F5 F& F+ T: J .active_low = 0,6 Y2 g! i0 @6 P: Z. T4 W
.gpio = DA850_USER_LED3,
% f1 P3 k& q9 X4 P( R7 a4 [) b3 i .name = "user_led3"," T1 S! D7 Z; @- J- R6 w# r% g
.default_trigger = "default-on",
; y h8 b% n/ G7 \& i3 s },) H4 C1 J _% b: I$ [
};: h7 W) W: Z9 T
- O3 c) N8 A8 k1 I4 zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- q( n3 Q- g8 P, _6 ?2 R/ P .leds = da850_evm_tl_leds,, Q4 a3 L1 Z" }9 b* l2 ?2 E
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 b" }6 E) L5 Z$ Z6 _$ }. D/ e( k3 c
};
% `' p. K6 p3 P' \" ^7 K6 x; c" t$ F5 @ D
static void led_dev_release(struct device *dev)( Q, u! s% \4 O& t
{& h8 `! R$ p# ^2 Q* ?
};
* C, k# Z' z1 n$ d" {! t, x; @0 z3 @! V
static struct platform_device da850_evm_tl_leds_device = {; G1 I" ~9 Y0 W, b/ S o: g
.name = "leds-gpio",
) s: `% h. ?/ A, ]/ W1 y& g .id = 1,+ L2 ~; o" _/ O4 l
.dev = {' P/ x: @8 d/ C# T. Y
.platform_data = &da850_evm_tl_leds_pdata,1 [( A3 i" u h1 Q t
.release = led_dev_release,( h( i+ s4 U9 I$ X+ M
}
$ G0 x& Q5 Q- i. M0 |};3 ]" U) _2 z* ?9 O$ V5 F: \2 r1 ?
5 }7 d6 l2 w2 z6 H7 p" i) i
static int __init led_platform_init(void)
+ ?/ }% E' a) Z+ b{
, _9 v& V) d% q) p) f. @- `9 A. k) ] int ret;
A# C w" I6 d- p& y- J G#if 0
! L$ b( g9 G- k ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, o; S4 \5 t0 |+ a) r6 W: `. S
if (ret)
7 Z& F6 Q/ }: O/ I. f' p2 i pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( j+ U$ R" g3 J) e "%d\n", ret);
7 |. z" y {7 i% J1 q6 s* I( ~#endif
% \8 J0 @4 }7 k4 W6 `# e8 z ret = platform_device_register(&da850_evm_tl_leds_device);
8 y$ f9 s% y9 j7 Q! k f9 R if (ret)/ a) Z+ `0 F! x4 i, W1 P
pr_warning("Could not register som GPIO expander LEDS");0 ?( A1 ^1 g' S. B+ K8 w& y6 G
else7 T% W- }" }7 k. B
printk(KERN_INFO "LED register sucessful!\n");1 ^* I9 ?9 W* m" }6 ?. r
0 g2 |: a0 X4 u# C0 p# R
return ret;
6 A" o- y* ~2 H9 \; Y0 {9 F3 N+ ?}$ A" L" p% w7 i- l
) a0 R( H$ F, ~9 ^' s: ^1 U1 {
static void __exit led_platform_exit(void)
8 \( r2 P8 G! J; y6 u, N& { w{1 e2 x- C5 a5 I$ p" `
platform_device_unregister(&da850_evm_tl_leds_device);
+ R5 f& ~ \8 ?5 P9 a
& k) V5 t l. E' A T4 k8 | printk(KERN_INFO "LED unregister!\n");
' D( c/ C9 U) _, l( c/ y}+ u% O5 K9 x5 l1 e% z% u
. M0 D1 E2 k0 x
module_init(led_platform_init);
. K3 `% N& H5 \: c5 z6 O& omodule_exit(led_platform_exit);/ ~. c4 C Q. i' B& O+ ~6 P
$ V$ f, s% U7 M& Z2 NMODULE_DESCRIPTION("Led platform driver");6 C1 s R. S1 s" v: L
MODULE_AUTHOR("Tronlong");7 A0 s6 F% B) Y l, m5 @( S% N
MODULE_LICENSE("GPL");: u3 @& Y! Y! B7 N ?; h# F6 L
; e& D$ J# U4 k+ `! }, r
|
|