|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% o2 v! C& _3 Q' q" O6 {#include <linux/init.h>8 S/ h1 ?, p! K o% C/ l( Q: w7 E
#include <linux/module.h>
Y) n3 F8 R" q2 G#include <linux/kernel.h>
3 I- R. x7 p) z( Q6 c#include <linux/types.h>% j5 S& ]% f7 l. F* T. i6 I( U- ]
#include <linux/gpio.h>
3 d! X$ T+ j6 _. U5 c& V, o* O+ [#include <linux/leds.h>
' @. W0 r" a: S, T#include <linux/platform_device.h>
/ U: n* J+ W1 ?: Q
7 U8 Y& H. [: A#include <asm/mach-types.h>; S l: N' x2 X, f
#include <asm/mach/arch.h>! k& w) k$ Y) Y3 {* W; _
#include <mach/da8xx.h>
- y# |3 t5 V' Q1 }# F! D#include <mach/mux.h>
" F9 v- H6 m# V6 S5 z* B5 V4 _; F5 _/ P% o
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' K" F3 m& d6 o n/ c( R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) V. ~5 m& _; T/ i#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& ~9 j9 v' |9 f2 q; ~
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 s, B. V, P- O$ [
$ F; F" T8 ~1 j, H/ Q# N. I- J
/* assign the tl som board LED-GPIOs*/3 o, v9 C5 w, W1 ?
static const short da850_evm_tl_user_led_pins[] = {( L" T) K( n9 h
/* These pins are definition at <mach/mux.h> file */+ L" j& x* O9 i# {
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. [/ d$ o& Z/ C: W* M* o
-1% u: H8 C, i5 q3 o' V2 c
};
2 i" {$ T. P2 w$ k- n
% C6 |" k8 w q5 M; m5 T; ystatic struct gpio_led da850_evm_tl_leds[] = {
/ f3 u! a4 T& X7 V {
3 D: ~6 f+ z9 W$ j# g .active_low = 0,
+ Q% a$ a7 D' r$ e) \" a; b .gpio = DA850_USER_LED0,
) i/ [+ V8 Z5 N, S# u .name = "user_led0",0 ^6 Z& @* I# J6 _! y6 Q* m* E$ N
.default_trigger = "default-on",5 f1 }9 m( l: b% }' y
},* t3 `. S: ~4 m, Z' T, m, k, K
{) j. }6 R7 b. f- `: `0 }( Q
.active_low = 0,4 ? H, U% ?! a0 x1 f/ I% ^; [
.gpio = DA850_USER_LED1,( B7 d/ z3 v( C! a8 P
.name = "user_led1",$ Y8 t+ @% `/ w: s" G' i( O
.default_trigger = "default-on",
; v% ?/ _. _: K; G1 I },4 [3 [) l5 I {" C6 A$ a% Y( R3 o
{
- R, N4 ]* a& [& b .active_low = 0,
8 n7 Y: Z- n* y# V- I6 h9 w G .gpio = DA850_USER_LED2,' J3 i4 o8 Z+ n+ x% J. H2 `6 j
.name = "user_led2",
0 v7 [& ~: H) }1 Y. T% M .default_trigger = "default-on",
+ i# ?& @- ? k- k+ ]+ F },0 P! G7 t3 t8 ^- u: z3 n$ Z- A
{9 |) D; y1 l2 M) U+ `+ A
.active_low = 0,
( f% ?) p* P' R( y .gpio = DA850_USER_LED3,
% e6 i4 T4 Q" n! B .name = "user_led3",
( k* |$ X" Q" u/ T, z$ B2 P .default_trigger = "default-on",
( l) r& u( ^9 {% F2 c5 | },
+ I" r$ X+ Q C( V' E$ e: q};
6 y' M7 O: F1 V' d0 Q4 j" ~/ B. @( q {% z( d
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ R7 B$ v- L+ `% c% m% M+ o
.leds = da850_evm_tl_leds,' B( c0 E- t% b( X8 F
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( e, G7 \+ b3 M' _};+ t( V9 f3 l: n. G
3 i2 c/ K3 p: ]static void led_dev_release(struct device *dev)
) j" d3 E9 J& Q) W0 ^% V{0 _9 w5 y: @3 }; b
};- R" H7 y! A: S4 K
5 E8 I J0 p% B/ G3 V' d4 D, v2 ]
static struct platform_device da850_evm_tl_leds_device = {7 y6 r# L8 @; w& k: W
.name = "leds-gpio",' w1 b! b# t( c/ h* ~! Q- U
.id = 1,
% z i7 Z- n: }0 C" A .dev = {
# e2 a9 t% T2 v1 x6 m8 |+ [ .platform_data = &da850_evm_tl_leds_pdata,
/ K% F2 |, `" y' h .release = led_dev_release,
, h- ?' N/ U1 O& d }2 u2 g% j" |1 Z1 C* O2 A9 I9 u0 V
};
b" [& \- i# Q1 {8 S0 U) A; u" ]& q) a6 _5 C( ?
static int __init led_platform_init(void)
$ m3 i" g) b3 n( _0 I{
1 @2 v D+ h9 y8 p9 w int ret;
" f+ _+ \" o+ d: i7 M4 {) c#if 0: g8 H: `# H8 [+ X8 \" {
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# d( Y" }% G0 \ if (ret)
* _" T2 c$ Y$ }" c' P( i/ S _! ] pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% ?. d9 M) g) ~0 S, r" p. Z
"%d\n", ret);; c9 r, Q+ Y+ I0 d
#endif) A! B" t- {- m. _. t
ret = platform_device_register(&da850_evm_tl_leds_device);
' ?( q6 T5 C) U) c9 O W if (ret)0 q! z6 |( G% Z P* N1 h5 h
pr_warning("Could not register som GPIO expander LEDS");$ [6 B7 j! z1 C9 d' t& O) k' l
else
' w' M( U; n) P printk(KERN_INFO "LED register sucessful!\n");
% `: C5 @2 |" Q- l
& H! \/ ?0 V$ j; I7 U7 U return ret;
. ~/ D! A+ H' _}- q3 W" x) T% B5 F7 F
4 Q8 V( }3 u8 J+ H4 R. pstatic void __exit led_platform_exit(void)
1 N8 c6 K6 N4 [7 e2 n{% Q' p; {5 F1 d4 x3 O8 n8 p1 D% b
platform_device_unregister(&da850_evm_tl_leds_device);: X6 `* z/ `6 J# C
7 h2 F/ [5 V; p( [2 ^! P
printk(KERN_INFO "LED unregister!\n");
! u( a( r, g3 ~% g" U}
- `* L9 E; I5 `+ J! U3 b8 x
' z* N3 L1 i) m, f% Amodule_init(led_platform_init);
( n- i: S" z3 X- i1 `4 \* H) |8 Cmodule_exit(led_platform_exit);
- M, O5 g* ]0 P, s2 W) d& c
& f2 w; q' }" _1 F: rMODULE_DESCRIPTION("Led platform driver");8 y K" q, T) G% v" A
MODULE_AUTHOR("Tronlong");
% S6 _* L; D& ~3 i0 `9 _5 DMODULE_LICENSE("GPL");7 ` N) p) d- n1 s+ V
+ o' M( g5 |% u* u# c k |
|