|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 v0 L' {4 X& X( P3 l) D0 l
#include <linux/init.h>& h2 Y) f5 a2 ?7 a7 X) W
#include <linux/module.h>
8 {6 b: k+ u) z" }4 G1 l4 R#include <linux/kernel.h>
* n( I4 K7 H0 C4 ]/ @. P#include <linux/types.h>% }0 u3 S- k/ X8 f3 i* R: g1 c: m
#include <linux/gpio.h>* f7 @* _3 _ t6 V1 Z( `$ J
#include <linux/leds.h>) V' A9 v0 }; W/ o+ O4 K: `5 i
#include <linux/platform_device.h>/ P/ b5 U5 y0 o' F. j
+ `, L0 T" R6 X1 Z% [8 M5 H: X
#include <asm/mach-types.h>. |% J9 z/ i& U }1 i9 T' w7 X
#include <asm/mach/arch.h>
2 d- T- j5 i/ y7 ?#include <mach/da8xx.h>2 K9 u, h4 P" N c; @8 x! K; Q8 J
#include <mach/mux.h>4 r2 K# h- N( `+ ]/ b$ P
+ s) O0 D( p7 @8 Y# { L' i
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 V/ k2 F4 i7 y2 Q0 R/ i#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 g+ W9 F/ Q4 n5 E8 z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& e: c2 P4 t* y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% M2 t2 D/ l0 p
- Y; `0 S! [# V. Q+ o/* assign the tl som board LED-GPIOs*/
( d3 W: v/ ~+ j7 ^7 @ ^static const short da850_evm_tl_user_led_pins[] = {# j1 E$ P' S5 T- w2 l$ P
/* These pins are definition at <mach/mux.h> file */5 c- q% p2 t$ Q9 W! Q: a, b
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ T* u* p0 g1 [ T& Y -1
8 Q4 L! g- M$ Y' U) Z: g+ J/ G0 N: _};
; ~0 t8 q, C: R# K" O3 E* s& |# [3 y8 k: M5 y7 p g, @" n. J
static struct gpio_led da850_evm_tl_leds[] = {
2 d% q2 ~, o. a, V9 H, l {
! w- K, o; J; c' K9 Y .active_low = 0,- C4 x& P8 x. @, ~
.gpio = DA850_USER_LED0,
" Y! n/ Y* d5 f! F: Y/ e1 j9 U/ U .name = "user_led0",
8 c P2 k1 X* K; o5 I .default_trigger = "default-on",
, y4 K, p& f( A: [ },) j+ m& \$ q5 ?( }! [
{6 {, D7 u8 z7 g) ], f; d
.active_low = 0,. }( p. q4 \6 m4 c4 [& H
.gpio = DA850_USER_LED1,/ j1 g" H8 ~. g( t
.name = "user_led1",# J" S7 |% b6 [- ]; B1 @* F _
.default_trigger = "default-on",; n O5 e( `; V* m' ]* S
},+ @6 B+ e; ~7 I
{
& e2 X4 h( m% k' K .active_low = 0,
$ j% H1 _0 y; \ .gpio = DA850_USER_LED2,
5 }* N. d/ _2 ]8 M .name = "user_led2",
8 @) h! ?8 k) O9 k .default_trigger = "default-on",% r' m4 s C3 y: C+ }& C
},
7 q2 E9 o; Y, j! l {
5 [7 Q. M7 a: g% \- u .active_low = 0,, I3 p/ o3 M$ x) ~! P2 s! V
.gpio = DA850_USER_LED3,+ p" @: d. A, ~0 k& o, n" J4 b+ Z( f2 b
.name = "user_led3",7 m& Y4 e1 u3 h9 i. C
.default_trigger = "default-on",2 f) U) n# s) a; H
},2 g* J# M, a" I
};
0 L# E- p. b: q* p5 E1 i+ f) V4 u# f$ c; L _
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! Y. S9 m# A7 l0 F l
.leds = da850_evm_tl_leds,. }" S {+ ^( e& @- {
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),! m- Z" z, A, `1 S
};9 l, D1 z5 |2 Q+ Z4 ]- x1 h
$ K! ~) ^' m G3 w# ?9 p N
static void led_dev_release(struct device *dev)1 o1 \. k% ]0 u- N5 k- J6 W/ l
{
+ c) k5 ~; _, w* r+ a4 b6 X# M};
) {' x' ?9 u( b9 L1 a2 h4 I/ e+ c& |$ z+ Z: X; g
static struct platform_device da850_evm_tl_leds_device = {) X( W' U r% H
.name = "leds-gpio",# B8 B# j( [2 m9 J3 L
.id = 1,/ q1 T) \% ]. i$ i: o5 C
.dev = {
" V' D5 g4 l6 o& n0 X .platform_data = &da850_evm_tl_leds_pdata,2 p2 Q/ u) o2 Z/ j' b" w
.release = led_dev_release,
$ p7 p. v+ {& W }
/ n7 [& U c) K4 A. u% n};
9 c- g2 D9 Z1 e4 X3 h8 X
$ |) a& X. ^8 j+ u) x$ vstatic int __init led_platform_init(void)' j# g5 t1 f/ q$ U) s" S
{2 h& F6 }1 W( x0 R+ |) L5 B; T8 P
int ret;& q2 \" Z$ E+ ^1 ?; w" Z
#if 0$ @- M5 R! K+ [% w/ N# O
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 k; E+ z$ S' j- W7 D2 W/ N% d if (ret)
+ r' e; v8 N) \5 p( l" M pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 k5 j" R& ~4 K& ]4 a- y) l4 l
"%d\n", ret);6 ^9 u9 O9 j! W9 T; V2 y
#endif
7 P0 n E( \. r, i' @: w ret = platform_device_register(&da850_evm_tl_leds_device);$ V/ Q& p8 l3 s3 \& Q
if (ret)
1 ^ @! S# f# }3 L; R( X pr_warning("Could not register som GPIO expander LEDS");
; a1 J8 }+ F9 n S/ c8 c else |/ M9 U) d9 L) N! O8 m
printk(KERN_INFO "LED register sucessful!\n"); l: Q) A" B: e) [9 e+ r
c+ k* U& M0 q7 q7 ] return ret;
# z4 S5 X' W. S& J# g0 |}
5 ]& q4 G. H; ?/ m+ U: \ O
6 r3 G: d1 f+ g4 V3 b' Ustatic void __exit led_platform_exit(void)
) n7 Z2 Y, V0 k# @+ I' x{
7 I8 d8 f( [8 I% M; ~( t platform_device_unregister(&da850_evm_tl_leds_device);
+ }/ G& B% j3 v9 Y
8 d. p" D" i: y9 s w, M0 C) C1 M printk(KERN_INFO "LED unregister!\n");4 n% T M& H; `* k) O! Z q
}; I, t5 m5 K- W& {6 n9 w, b% ]
3 O& D& y4 a5 t' Q, v+ d8 O( B% k1 smodule_init(led_platform_init);
D7 f2 I& {) C$ gmodule_exit(led_platform_exit);
1 q2 Y2 m8 d# p9 k- v7 M0 b; ^7 U0 T" z" D2 w, p; C9 `
MODULE_DESCRIPTION("Led platform driver");
) a! ]& k( @. E/ ZMODULE_AUTHOR("Tronlong");3 L# i) g$ T, u" `
MODULE_LICENSE("GPL");/ h7 ?7 X& a& f" N* Q
- N5 P5 C5 w* n) p% o5 k
|
|