|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 R, m) @5 L5 ^$ c( p$ r
#include <linux/init.h>
' L8 Z6 [9 f% o. q# s& r% o#include <linux/module.h>
6 P6 L" J1 X) l2 ?: \; ~#include <linux/kernel.h>
5 {0 [2 W& j5 H* v0 n# F#include <linux/types.h>
2 \8 R3 j& U. t7 b! C* G( Z5 X! l. a#include <linux/gpio.h>' ?7 w1 |$ B$ I7 L" X9 e
#include <linux/leds.h>
! Y( [2 u/ e2 S% H3 d3 P#include <linux/platform_device.h>
k& ?/ h, p `
6 L1 c( N- T, P. u, h* i6 ^/ Z#include <asm/mach-types.h>/ ]+ r8 V; U2 S; {
#include <asm/mach/arch.h>
4 x9 c% A+ J$ j" L+ N- p8 H: w#include <mach/da8xx.h>
4 L! ~4 j( ^; a* ]. w4 P7 K#include <mach/mux.h>! ]' f& a; E5 a# K8 O
. F$ z2 h) ~% o7 |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 ^3 x/ q5 F0 p. S) U: ?& ]$ P% h
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 v7 R4 }2 E5 I$ Z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 G1 b' V/ a" e. L#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% u$ V/ k% t) l' g' V+ ~3 t
6 g0 |" _4 g& h% B# ~6 U5 ?/* assign the tl som board LED-GPIOs*/
' R$ ^- Z R% {: E' |static const short da850_evm_tl_user_led_pins[] = {. c1 m" x+ H' Y) F
/* These pins are definition at <mach/mux.h> file */
4 ?! T$ F! C! b Z; K9 r" C DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ G- r. A( V2 r
-1
0 q _3 @6 b% X9 C6 @};
6 w6 O* {9 a4 F0 O9 X
& P, e: c& \0 Z, y9 |" p8 ustatic struct gpio_led da850_evm_tl_leds[] = {
m B+ {1 {" U {& s: a3 ]! ^' Q, D) V2 o, A$ E' s7 p
.active_low = 0,; }& ]3 W0 C6 Y; u7 a. I `& c; ]
.gpio = DA850_USER_LED0,
! z7 \ {& f/ }+ f .name = "user_led0",
9 H6 Q" }* h" r .default_trigger = "default-on",. K7 J' M. J5 {5 D" M5 E% I
},4 J7 E. k9 D% Y7 P! q
{8 f u6 N8 G* q: d {# l& |& f
.active_low = 0,
7 d4 J! t0 K$ m h# [ .gpio = DA850_USER_LED1,
4 B! ]) C9 D0 y$ o$ O .name = "user_led1",
- `& V6 M" l1 A1 z7 G: [, ]# c .default_trigger = "default-on",$ p% {; W# j- O& ?, Z0 Q6 r. D
},/ e* H1 X9 N; J/ Z! @
{2 W2 H! m: A& _1 i, g! s
.active_low = 0,% B) ~5 s0 q) c& a0 v, }% l p
.gpio = DA850_USER_LED2,5 L; k3 A! i0 B9 a; z
.name = "user_led2",
2 u: h, @& d7 X) J/ M4 G .default_trigger = "default-on",
% ?" G' u9 W; m9 A },
$ }, u4 y+ t2 O: n' f- v" | {; N7 _: r; R, F
.active_low = 0,1 B: c) _4 N" d# _
.gpio = DA850_USER_LED3,
8 A7 i0 U8 @ n I. q1 e .name = "user_led3",
: o% b. Y5 X \/ C; G# ` .default_trigger = "default-on",; a1 T7 j/ B1 h9 b7 Z
},
# q- S! l- L; X2 H; S& J/ Q1 I}; K" j ]* z2 d3 m8 ]
0 a* N8 L3 }2 O& ]$ ^0 r" Y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; ?& ?% q. P2 g; l% ~7 ~7 O .leds = da850_evm_tl_leds,
# G/ [, Y" p5 X$ k& N .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 q) v- |& Q6 k$ q6 i};7 S4 {( u+ Y G' }- i) l# o9 j
9 }6 y, \& d5 L
static void led_dev_release(struct device *dev)! e6 c5 t3 r' d) b
{1 s" c2 v/ P: t: l5 t7 b! N
};
5 a) m, r! t! p4 b3 z. ~: h" ^) `/ X0 s# L
static struct platform_device da850_evm_tl_leds_device = {1 l3 v6 F2 j+ C5 _0 j. G( M
.name = "leds-gpio",6 f* ]% G9 `& L+ ^) w3 Z5 P" V3 @
.id = 1,# T) F2 P0 u. y8 U) ?
.dev = {
{9 e1 D" ~6 V& i" ~3 G .platform_data = &da850_evm_tl_leds_pdata,
- v/ W. ?8 p& e: A, Q .release = led_dev_release,
$ x3 q$ H/ h+ X/ X$ ~) @ t, ? }
" f0 ]6 x7 |6 M! h* }) l0 Y$ r};
" n+ R% f: ]) n
; n% b& @! H; e2 b3 b9 ~4 hstatic int __init led_platform_init(void)* p8 {" d2 F/ v7 M8 k
{2 t6 j( J9 R& P
int ret;. W8 W# S6 k& d1 h6 H" }' V
#if 0% M1 U. e# Y0 A: o' E" ~/ J
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 v6 X7 E: S7 g; e. ^
if (ret)9 p: _ i1 C0 I0 L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ b& @0 F% B" u7 J* c. K5 }3 A "%d\n", ret);
" K( ^7 u' ~$ m" r" b. U1 L#endif
7 u% V: n* Q! {* W! n0 | ret = platform_device_register(&da850_evm_tl_leds_device);
! v1 f' \2 ]7 t! | if (ret)
6 t# B. d$ T5 }# @ pr_warning("Could not register som GPIO expander LEDS");* S# l( F9 D! \. l
else
' m# U2 D; e/ r- r: N1 m% ] printk(KERN_INFO "LED register sucessful!\n");
" n8 Q ?5 j$ P; ?5 u2 e+ d6 m% b
return ret;
. b" ^) p. C' a( c% Q}6 _2 P' t' a0 z, l: q+ i0 ]
% a3 t: B, B0 rstatic void __exit led_platform_exit(void)+ ~1 ]1 }# ^( Q `1 P* ]
{6 z# m0 f; Q! \( U q6 S
platform_device_unregister(&da850_evm_tl_leds_device);6 X1 r8 _" e% j* X
6 ?2 s, y; O. X printk(KERN_INFO "LED unregister!\n");+ z8 K$ O: R% ^( l- y L [
}: F Z* j, v- b. E& u
) X, c; f4 x+ u" Z- e4 lmodule_init(led_platform_init);
- e7 _5 U B r9 Lmodule_exit(led_platform_exit);
" x3 N+ X& {* j1 \( u0 |" K1 m
' i3 C1 K& A9 d: g% s% vMODULE_DESCRIPTION("Led platform driver");
5 V9 o( G0 R3 \: qMODULE_AUTHOR("Tronlong");
# x* t z3 F) ? r$ |. a/ QMODULE_LICENSE("GPL");
6 S5 }8 v) a8 {- \# u% p* e) H* O& k% H0 i: t
|
|