|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 q6 r# Q: B: X; ^+ i" ~" e4 R#include <linux/init.h>4 ~5 ]* Y! V0 [7 ~
#include <linux/module.h>
6 ?; x" t2 V f O" V#include <linux/kernel.h>8 ?* W2 }% G/ A- C" Q- V0 N
#include <linux/types.h>
8 k; O5 u, H, n3 P" M#include <linux/gpio.h>: l% z8 |& [$ M, G1 x% W" V
#include <linux/leds.h>) i" J' n% p8 Z5 C* J& y
#include <linux/platform_device.h>
2 o- F+ B1 e. n6 b3 A7 u p
. R9 M- W- \3 n! }#include <asm/mach-types.h>
2 C. p* ~9 X9 Z$ m9 B3 `#include <asm/mach/arch.h>
8 q' ?. a; |+ j% e$ n7 V8 S% w#include <mach/da8xx.h>) D) h) Z8 T2 d
#include <mach/mux.h>
* J3 z7 O5 L! s1 ]
/ F/ v& l! M4 X#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) {" N. ~" `+ c& y5 x& p: z) c& }
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 m0 c7 o4 n* H- W* E% b3 v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( H) }: r0 u$ E9 \' D#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% E% c% G: K( S) j6 A4 a1 H- G
" A4 D& ~ j) t' g! ~" q+ Z/ D/* assign the tl som board LED-GPIOs*/# F7 \/ n5 P( |) h9 f- c: o4 P8 j
static const short da850_evm_tl_user_led_pins[] = {% @! X; E2 J$ k1 h7 ^
/* These pins are definition at <mach/mux.h> file */
2 H0 Q% ^" k1 \; N DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* | X4 r3 c6 ^2 C7 y$ U' r
-1- f8 r9 T6 f* Y) f$ _. d+ p
};
1 H+ l- ]: f+ Y: z
5 d2 j* h6 b! L, F+ \& j4 _static struct gpio_led da850_evm_tl_leds[] = {
' v4 i) O% S/ h5 T4 M5 G& w {0 |1 k+ }# e4 j& ?
.active_low = 0,) Q7 d# b2 Z3 y9 q
.gpio = DA850_USER_LED0,, M2 x2 e* p6 O0 O& A
.name = "user_led0",
2 f# s+ U( z' L2 y! D0 y+ U2 h .default_trigger = "default-on",* l5 w+ ]# m$ r% q2 X- o; p
},5 T- Q0 o5 J' b+ U2 ~1 Y! d3 ]
{8 a( n7 }/ i0 I' v' w8 H5 {
.active_low = 0,
: g6 I$ d5 b/ G$ V+ ^ r! u* _. k .gpio = DA850_USER_LED1,- x- \% r4 w# U" h1 R0 Y
.name = "user_led1",
$ F8 p# @- Y+ y* O .default_trigger = "default-on",
3 k- w ]1 ^- R L& D6 M/ v5 N& @ },
' X" A2 T& k1 B M _4 p! X2 g! e$ x4 U {3 u* z- ?+ w/ g+ [6 ~$ Z% h
.active_low = 0,% ^3 F5 d" E2 C, j) P( s, ^( }& b
.gpio = DA850_USER_LED2,
- l- `. }6 q" R5 e3 v( p0 P .name = "user_led2",
' p3 c! A2 l7 j; Y/ @: y .default_trigger = "default-on"," ]7 ~0 b4 t2 i4 ^8 y2 g
},
0 i, {$ R7 l. v+ Z% x; B {7 Q j8 A% }$ V: u! C
.active_low = 0,
- B5 a$ A6 c1 W Y, F* S .gpio = DA850_USER_LED3,5 L7 K+ d+ Q, H8 }& h2 n
.name = "user_led3",7 A* f7 H& O3 }- |& T
.default_trigger = "default-on",
7 [( c* r/ D: j$ x },
9 }0 b& P8 E/ T+ U6 y0 ]};8 [- \% g: ?% d
# z! P; M* r: n) J4 x1 |( K
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* R9 I$ x& `+ I3 f3 _8 ^
.leds = da850_evm_tl_leds,
7 S. `8 a5 E# s# G( y2 M$ ] .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( Q" L# ~" D+ ~* w
};# o1 C2 i% p3 `8 O+ `( e# [
* |; S* P$ B+ n+ Ystatic void led_dev_release(struct device *dev)! ^) H, C# ]1 }4 A
{/ c# ` n4 N# P9 B0 S' G& b# W, V
};
% \/ O' R6 }* ^' }! y$ I* S) X3 j+ ]- b/ J3 M T' X
static struct platform_device da850_evm_tl_leds_device = {
. Q+ {; B5 [8 T: d9 [4 M .name = "leds-gpio",
4 f" t* v" i3 }4 R# c ] .id = 1,
, E, r8 H2 T! K$ I7 ? .dev = {4 N) i& A3 D7 n7 m4 s
.platform_data = &da850_evm_tl_leds_pdata,
3 L% L' l7 l& w" T .release = led_dev_release,
, S/ t$ b, j# U8 H' W }
1 j1 e f. l( f4 Y4 \: {/ F/ ^$ ?, v};
& l8 T& l6 M. _- c2 M: Q5 n$ s( n$ [5 j( P# G/ _
static int __init led_platform_init(void)
, S* {0 e0 C3 d$ G{) l/ I/ _5 e9 F$ R
int ret;) f" l$ j5 _. q" g, L
#if 0
$ t; u: V [7 H* a0 J& n& m( e ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! I! u1 c. d; \7 @- D% V
if (ret)' f, C) [( x0 l; Q" N: n9 X$ d
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 n: N& V# e, K9 w/ W0 u7 R1 r" ?
"%d\n", ret);& q' }# Z; x5 E5 ]0 e
#endif* [* ?& v, V! Y( m/ a! H% Z# i
ret = platform_device_register(&da850_evm_tl_leds_device);5 j* _' z, D7 k( P* t, c1 |
if (ret)
/ H) T. U( C& |$ l pr_warning("Could not register som GPIO expander LEDS");! u3 J- ~; l8 \
else8 e1 }( x2 S# @5 W2 G
printk(KERN_INFO "LED register sucessful!\n");
* R) T$ S! _6 ^" I4 m1 H( {2 |: e! r: b* n- y( u
return ret;
& i* }2 Y' k/ P$ n. p: o}( T/ @" T- ~" Y6 D- J% ]
) l! ]( B" | qstatic void __exit led_platform_exit(void)
! A8 I* L7 v& H. U' c( H{
i: I$ S" l3 b: w; E" T platform_device_unregister(&da850_evm_tl_leds_device);: i; ?: `! w c. { E
# s z. B& C. W! [# ] printk(KERN_INFO "LED unregister!\n");& @5 ]' {8 }; c5 l2 _% m3 D
}9 }/ Z* }( j M
1 ~& N; J7 l, k, a8 Q# N
module_init(led_platform_init);
4 e* o7 g; X7 |: U9 L7 Mmodule_exit(led_platform_exit);
! k* ?6 `+ F& \5 w) i
7 M% \1 s* E6 y8 dMODULE_DESCRIPTION("Led platform driver");
. z' z; L: l* ?2 M5 ~4 _$ {MODULE_AUTHOR("Tronlong");$ Q) O W2 c% A- B! L
MODULE_LICENSE("GPL");4 M; n4 {' n$ C$ s3 I, ?
$ q& R/ C# {' E& O" g5 V* @+ K5 q3 O |
|