|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* d2 R( J5 L; A2 r: D# T( v#include <linux/init.h>
. Q' O8 _7 Q$ g/ ?% E$ d6 u#include <linux/module.h>
3 z8 o1 Y% S4 E" G! x#include <linux/kernel.h>
( W W5 [+ c6 ?% f9 ~4 d#include <linux/types.h>
3 |2 {& B6 F1 E$ O5 O#include <linux/gpio.h>: {8 Q3 |: q; t/ o
#include <linux/leds.h>
4 s/ D! ~1 G) T3 i5 p v6 D#include <linux/platform_device.h>7 m0 @+ d/ z; A( y0 n& A7 j
7 i5 N- ~$ J8 g6 Z#include <asm/mach-types.h># B& r4 K0 w2 g' G3 _* O1 }
#include <asm/mach/arch.h> f6 H# z3 G K! b+ Q' S
#include <mach/da8xx.h>
1 a6 |$ t2 b$ }( ~/ H' ^/ t#include <mach/mux.h>9 [, v+ ~2 C# i& d7 c, w; t
, U; S' M$ M; u) k2 Q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 l2 p; Z" ~$ r Z5 O+ U& T @( B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 r% A2 l6 N2 j8 ?' R
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) \7 X* m2 J6 Q" a( D
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# w, P ^3 d) ?) D
' @; Q+ i2 z, b/ {+ S' Y% y( f/* assign the tl som board LED-GPIOs*/
( M ^8 m. @: x* d s2 I; z! Hstatic const short da850_evm_tl_user_led_pins[] = {
) D ?: @4 Y. v) f, S4 o /* These pins are definition at <mach/mux.h> file */8 P. s/ M- B2 c5 k# e
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 K% s6 S* K* N; M6 X! V
-1; X) n' e' }- {( \* G- d$ C
};1 Z8 F' [! s1 j% b
* C: D; y( n1 P$ R' mstatic struct gpio_led da850_evm_tl_leds[] = {9 G, ^4 X- A" ?
{
" X$ @$ r" p: O& v .active_low = 0,0 M$ p5 A9 r" j; w
.gpio = DA850_USER_LED0,) e, A7 N" @; R+ \* X1 L2 U0 m, Y
.name = "user_led0",
4 w& P+ p8 U1 ] .default_trigger = "default-on",
7 B! ` z8 s; i' g },
$ e5 Y. x4 I: h* @+ h {
9 G R0 G3 |6 j7 s2 ?, y. \ .active_low = 0,
9 p, d Y' f' j, z% j .gpio = DA850_USER_LED1,3 M E# p. K6 g1 B
.name = "user_led1",; ~, v3 ~1 F. s/ m- b; W
.default_trigger = "default-on",' h6 f m6 X. `) V9 G
},
5 h% r/ R2 Y ~3 h) W {
) w3 [- T& s7 I7 w& C/ _ .active_low = 0,
+ v# X3 t% o; _3 l .gpio = DA850_USER_LED2,2 r3 Y9 p8 v% n+ Y% f/ o) t
.name = "user_led2",' @" R& s; C" O1 w
.default_trigger = "default-on",
6 }# e/ ], Z2 V$ d- P },
; Z& l' t6 h9 C {% i5 P7 f! E6 L2 h6 s
.active_low = 0,
% ]6 }8 ]) W# Q) E, X! Y .gpio = DA850_USER_LED3,' b* X% K. h4 Q
.name = "user_led3",
$ r' I& G, ?$ N- ? .default_trigger = "default-on",$ z. b9 y, Y/ m" ]* i
},
% ]$ A& _3 T( J4 Z' j+ X- p};& l2 F# s9 j) e" ^) |) `
* [/ ]7 ]. A6 U; G) j& _
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( }1 y' p, D0 s, l .leds = da850_evm_tl_leds," x' `. r# J5 k9 F7 v
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),. P4 J5 O% J' \
};# D) w1 S& G+ z
* u) N/ p& q- U @& B3 Pstatic void led_dev_release(struct device *dev)6 l+ A, x/ G+ S4 R
{3 T+ q; S; I9 f$ x
};
/ C$ z G2 H* j Y/ x( Z' ]
" T; b% Y+ ?0 `2 Mstatic struct platform_device da850_evm_tl_leds_device = {
/ i: y5 i3 U, a# P .name = "leds-gpio",' c" T1 G2 }% E6 z
.id = 1,
# B1 f% \8 L w$ B; \9 h .dev = {4 A0 g+ N; o5 _: }7 e
.platform_data = &da850_evm_tl_leds_pdata,8 a: e9 X0 O1 S
.release = led_dev_release,
/ u e- R$ C* V- d }
7 N& h6 ]* E0 W, B1 _};9 A% U" n, l8 X$ s6 O$ R
1 r9 X" G( H7 M+ [static int __init led_platform_init(void)$ D, d2 `% q( X/ X9 Z
{; f9 e# h7 Q: o) h e+ R. s1 Q
int ret;
1 w0 K4 a; r' L5 P#if 0$ Q& g6 Z9 d! q n' B- K8 E/ W
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, o* ~: C! |0 z9 C* X% T8 ~+ Q if (ret)# ?' G8 s" [, V8 Z) W- m4 s
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 i+ e! n+ C0 z; g7 l "%d\n", ret);
: a: e7 e; l3 j6 D# c#endif. Y# C- c& ~& N# N3 P3 E
ret = platform_device_register(&da850_evm_tl_leds_device);
; F% E) }& H" l+ o+ A if (ret)
) V( k1 u2 O/ v6 W pr_warning("Could not register som GPIO expander LEDS");7 p8 T! ]! [0 w! U- i% V4 a6 `
else$ g! E$ B+ Q! _2 U3 h
printk(KERN_INFO "LED register sucessful!\n");
0 b& ~; E6 k) r* s7 d8 m2 d+ ?: Z, [
return ret;
7 l% a( ~; I" B/ g7 L7 F}. {. g. R3 i; k9 z4 |! x
* f' B2 R2 d: M, b- q$ l) Z) J! Sstatic void __exit led_platform_exit(void)
T! F: \* s# X{8 o+ M/ r, B5 ]0 h5 d' O
platform_device_unregister(&da850_evm_tl_leds_device);
2 F* w5 d! \3 ^& R5 g- X6 p8 p5 z1 z8 K5 f1 Z" U
printk(KERN_INFO "LED unregister!\n");! R$ E @7 k4 Q" ?
}
; U4 q$ H. M) L6 R( e
& i: R* s* Z7 M- kmodule_init(led_platform_init);9 `; W7 r8 Y) m Q
module_exit(led_platform_exit);! M0 e0 J5 h |7 Q
7 Y# W0 ~' _$ R4 ~MODULE_DESCRIPTION("Led platform driver");
* u$ C1 g/ M+ wMODULE_AUTHOR("Tronlong");
6 P# q/ T" n& }8 A7 o. y. ?MODULE_LICENSE("GPL");+ A( z7 r; `% h& P+ G3 v, q$ O/ }
- F7 D7 X3 r9 X
|
|