|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, N% w% R- E/ C$ D/ L#include <linux/init.h>
) m- W6 b3 [* ^ n#include <linux/module.h>: }3 c# |) @5 s$ y' w
#include <linux/kernel.h> r) M g* }4 F' }: z
#include <linux/types.h>
% T/ X4 k+ P I6 W" }: }#include <linux/gpio.h>
/ w! ]- E) \! c2 w2 R#include <linux/leds.h>
# _1 o2 e) y% ?( _9 W#include <linux/platform_device.h>
& u9 g2 n' X+ i
g0 a6 z' @/ R" S#include <asm/mach-types.h>
. q2 Y: {4 j# p% l) C' g3 \1 U8 j#include <asm/mach/arch.h>" c; k5 ]* S' r4 W$ u4 S* q
#include <mach/da8xx.h>
0 y/ H! A' ]4 t6 D7 ~! D+ o#include <mach/mux.h>
8 t% o: s5 B- T) g2 k
, `* z: w- ]/ U/ ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% E! A, |4 q) E- [% F% M#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ Z$ `1 Q2 F% @1 r8 O#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ B5 m* }& s+ }$ n. k8 e* M* h#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 a0 a- Y1 v4 N6 | @$ Y, q+ v0 ]. j7 L- R! U6 _% \" {2 ?9 z
/* assign the tl som board LED-GPIOs*/7 Z4 p6 _6 D4 c$ y" N, C
static const short da850_evm_tl_user_led_pins[] = {
8 s4 P3 X" k& [* i1 Q0 e% q/ U /* These pins are definition at <mach/mux.h> file */* P- [6 T1 ^9 a
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* z% B4 @8 N( q! A& Y( H7 y/ H -1$ K3 b5 \; u. ]$ h
};7 v0 U& o/ C9 J9 s$ x
5 D- y8 P+ k( ^, Q. f0 w T3 z4 F
static struct gpio_led da850_evm_tl_leds[] = {: p1 F. R; V8 T2 N. D& P
{
* A- c4 C! Y) I" A' W( |! z1 d .active_low = 0,# _+ e8 Y; S6 _1 X1 n2 f* V% \
.gpio = DA850_USER_LED0,
& O7 M6 y% b) X2 Y .name = "user_led0",
6 D7 i; q9 n" f; w+ w) y& P .default_trigger = "default-on",
; P7 S. ~+ L% U; C; V },/ R y {( s* I* L
{+ O9 |. H, l/ [" k' `+ g- L+ f7 m
.active_low = 0,3 d% M3 G, N* O, T" \/ Q
.gpio = DA850_USER_LED1,% C# m9 p* M& `* w% U( D9 ?3 k) e6 m
.name = "user_led1",
% C3 }6 M4 c9 Q .default_trigger = "default-on", J( J4 Q4 X& t+ Q! w0 O
},1 C- z/ W3 h8 \1 t$ c5 I* j6 L
{% X3 {8 o- r6 g8 h
.active_low = 0,
/ U7 L. Q2 d- d6 J3 ~8 V5 X .gpio = DA850_USER_LED2,
r2 \/ k& t6 t" T, | .name = "user_led2",
" ^! F. A+ r2 e .default_trigger = "default-on",
8 F; F# P! `/ |9 I5 D },' M& d, k4 _; p! k0 l
{
# V! ]+ F3 i9 t .active_low = 0,
+ B6 U( H7 P3 }* [9 `3 m .gpio = DA850_USER_LED3,! S; A. @6 r! X. e+ E; c8 I
.name = "user_led3",4 [0 |) R$ h2 C& K% x7 y n
.default_trigger = "default-on",' k8 D$ C2 c9 E) P1 T8 ? R
},- Y! X& c7 }7 F, M; [7 k6 ~
};# S! ^6 O+ x3 d9 |
. O; l9 z+ ^2 u, X$ J* Z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 y7 \, ?$ ?) w2 T4 ~
.leds = da850_evm_tl_leds,% k& o1 k" c( }- D$ \4 G8 A+ K7 s
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 _2 d/ L- Z! n& Y0 B3 i# D |
};) |+ Z2 r+ F0 k: H) O9 d
I% J2 } c% M! {% i( u
static void led_dev_release(struct device *dev)
5 q6 K$ G8 b$ m{% T, u6 V! N8 w F0 X+ ^
};& x- t4 D$ j* L F7 r
/ M; Q8 y) T- ?$ }
static struct platform_device da850_evm_tl_leds_device = {
8 b: @5 D4 H4 Q( u .name = "leds-gpio",
6 |# x) b# [' e6 N5 @3 k2 X .id = 1,3 g5 m8 g& p. O7 ], B3 i8 T
.dev = {) d( V) G" L' {
.platform_data = &da850_evm_tl_leds_pdata,3 ~: @/ q8 V0 ]2 j' T* J
.release = led_dev_release,1 M3 h- W+ C: K
}
' E# z) E7 j7 L8 o: A& e};
. z$ B- ?' u! T b2 f
) K0 R8 l/ f" P5 Xstatic int __init led_platform_init(void)6 S) \5 b# {; X$ _4 L
{0 V) N* j2 i# z# s$ p
int ret;* r) `7 t8 u# x1 s
#if 0
7 \1 w+ o8 ?' m. y, k8 O$ Z0 X ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: i$ M! @. c* g5 ~1 B9 W C
if (ret)
' L, e7 P/ X9 B2 j- b7 m pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ }+ P( I9 z, }
"%d\n", ret);" s& P, g3 P$ s( t" _
#endif
! E( c" s% ]' d, V ret = platform_device_register(&da850_evm_tl_leds_device);: g2 S7 J J3 U7 R# L& T" K; y' Z
if (ret)
0 m- v" I1 w8 \# { pr_warning("Could not register som GPIO expander LEDS");, F! A+ q) @6 O5 b- [" J
else
: V; D" n t* B! Q5 q6 N printk(KERN_INFO "LED register sucessful!\n");
4 i6 r: u+ R0 \6 X( d4 h/ ~5 ?5 X- m1 b: p* h
return ret;' ?1 |- C% b! W5 V' I4 o
}; |! ~7 v$ w& Q& N9 v0 v
7 ?' d5 B- z( P" O6 _* Y$ ]static void __exit led_platform_exit(void), q' X, s# h3 M, J
{7 v7 `/ X* K% S6 K5 I2 a
platform_device_unregister(&da850_evm_tl_leds_device);9 }' f% v, V' c2 g6 U
' d/ a0 U: o! o" C- O0 o
printk(KERN_INFO "LED unregister!\n");
( X* r8 j. i7 b7 `}
$ L. k% _2 v( y. r% x4 h& ^% }9 f
module_init(led_platform_init);
: n* P5 g! C/ Q) Q b- @" G; `7 }module_exit(led_platform_exit);
9 Q5 {5 d l0 r0 E& [' ^9 D* k# m+ v S4 w) g
MODULE_DESCRIPTION("Led platform driver");
n& }- B% \/ k- ?; iMODULE_AUTHOR("Tronlong");" A& E; e( S) J
MODULE_LICENSE("GPL");' h( L: s8 `& O
: W6 r* F9 k6 [# F+ {; O/ `" c
|
|