|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 J# c( t' N! Q! U/ m7 n#include <linux/init.h>/ G) M5 L0 [( [' p, w
#include <linux/module.h>
: _& s) @# E3 o0 W% q#include <linux/kernel.h>0 a9 A% _7 b2 W2 V) l7 }& R- w6 d
#include <linux/types.h>
2 j! d7 B) A7 o6 u! r#include <linux/gpio.h>
4 m- N' p7 O ?, P& T1 r1 Z$ s4 L#include <linux/leds.h>8 ]/ S) g1 i3 j H7 Z2 g9 A
#include <linux/platform_device.h>
% C: e1 m6 n! V' c$ z7 s4 D0 ^1 Z' I
#include <asm/mach-types.h>
- d( x; K) I6 h. b#include <asm/mach/arch.h>
# A9 u/ L2 w) |& `#include <mach/da8xx.h>: A U; ]: X2 P
#include <mach/mux.h>5 f: n3 u3 R- M8 J
0 `% `1 l4 r1 W7 ?- X! ?% F
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ W X) @( a' \8 g#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( g- f% Z3 G1 I/ p/ U! t#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ Z: F8 V. E. [# N+ C$ f% L#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ H$ a, h1 g% q
& v" a. O, o* M* r" R5 V5 i/* assign the tl som board LED-GPIOs*/% R/ w$ o- G% G8 K8 x- w
static const short da850_evm_tl_user_led_pins[] = {
. v: z0 W" _: @5 X# E9 O. P /* These pins are definition at <mach/mux.h> file */# L+ v" ?) {$ H; f5 A m
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: _3 ~7 x4 \+ u. w& J6 t& }* }# p
-1) u" J. ?) j! E# }- u- X
};6 N2 _2 |% ?6 G2 p9 m1 C- }
p X+ F& I2 K+ E" P( q' vstatic struct gpio_led da850_evm_tl_leds[] = {
' Q+ I6 b" G! m* I. L; ? {
% w# ^2 l7 p/ }! R5 V- Q .active_low = 0,
e. n0 e6 G4 @) J6 @& ] .gpio = DA850_USER_LED0,, a7 c8 [3 R1 W7 G' B* I( ~+ h
.name = "user_led0",
) t/ f j* `7 N& \ .default_trigger = "default-on",
( K I3 c2 N( f5 `) [, f3 Y4 l },% M, P8 k5 w4 H
{
4 t9 R9 T' R# m) n .active_low = 0,! G4 X8 m( j8 h# j& h/ W4 ~7 v% K
.gpio = DA850_USER_LED1,
4 K' _! E& m* \# r/ A2 d$ j .name = "user_led1",# h' R9 w4 I% O" s& P
.default_trigger = "default-on",8 p4 `) B& d- _# z& N2 K
},4 w& r: ^& ^$ [
{; R# ?' K L% `
.active_low = 0,
, n$ ]8 D/ v8 Z3 \ w- q .gpio = DA850_USER_LED2,
( C9 B- D K/ v" b. i m .name = "user_led2",2 i# a1 A! y/ q# k
.default_trigger = "default-on",
# u' A8 j6 B8 ]5 N. ] },
7 g F+ p6 i! F8 ?$ H {
, l% C" Y7 B3 e$ R8 A5 u9 O .active_low = 0,8 P3 B* l/ v8 r8 X2 E# u9 x- |9 R& x
.gpio = DA850_USER_LED3,
) `3 ]. d7 C# \ .name = "user_led3",+ b: u. b9 y' _+ B* Z
.default_trigger = "default-on",
|5 ^: I- v' H5 H( l$ E },
! F3 D# p8 u2 g+ s% d6 b};4 r( q* j$ v3 x! m1 t1 J
- u0 h3 g" R2 v: Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 Q6 Z7 {5 K0 r% T& S' ]
.leds = da850_evm_tl_leds,
! K$ P% O* v- B$ H3 @; O% A. t7 x2 q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, ^2 C" r2 _% d" Q. }9 C};" D1 g1 D, H2 x7 Z8 Z8 W
% w) y3 t2 O& A7 i! c5 a5 ?static void led_dev_release(struct device *dev)
& l; Z( Z% g5 r! {{
5 U2 w1 G( \: D- k; _2 ?};
5 v5 w, c% e# I% d' d+ m8 z r! ]# l L9 r' X/ ?
static struct platform_device da850_evm_tl_leds_device = {
- X# F- d3 v$ X6 O" a R* m .name = "leds-gpio",- G- B3 r5 P' J! U" {! s' f, A
.id = 1," `$ r" J* I! X- h b% V5 |
.dev = {# d- v1 s9 l, c! b) o! g' s2 s
.platform_data = &da850_evm_tl_leds_pdata,
( N) ?9 a% k5 I& m/ {% |; k .release = led_dev_release,1 _5 P/ ? [0 i8 ]
}2 Z5 Z4 t$ B/ I6 A
};
) E' Q4 M5 `4 Z8 u( ? ]4 W8 N2 Y7 V9 O: L
static int __init led_platform_init(void)
~8 k; ?5 V2 o{
7 d* T( Y& x/ h. f- I int ret;3 a. Q# B; X% G) l/ `2 c
#if 0
1 E% d P3 ]' H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# m6 v2 K" X5 \7 |: ^ if (ret). T) V J8 }" G2 O* u# V' ~/ P
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 V. v2 i9 r2 |; s6 n( I "%d\n", ret);
) ~$ `) n5 E0 c8 \$ N#endif
|) ~8 V" U: Q" H# A% J1 B: N ret = platform_device_register(&da850_evm_tl_leds_device);
; V1 ^/ g/ X4 D3 v8 b* M if (ret)
4 G: R, Y+ v) V1 p pr_warning("Could not register som GPIO expander LEDS");0 ]& `2 s+ ?3 U* @
else* n' \+ f: ^* z9 \ ^: @" B5 c
printk(KERN_INFO "LED register sucessful!\n");
8 q. o7 f; U9 K1 n" D @2 U# x+ w- X
return ret;4 M; W8 }! [8 j+ E
}
2 i- V8 W. y/ y4 |0 A6 l$ r0 P4 b6 E" t! P ^
static void __exit led_platform_exit(void)8 r, Y! Z: t, A! B& }2 N+ m
{) c. N, G f/ j
platform_device_unregister(&da850_evm_tl_leds_device);
+ u/ O! A1 x5 `& e/ I( T9 \) e; C0 l" ^
printk(KERN_INFO "LED unregister!\n");
4 p& x7 g0 s# X( |8 t7 k# p0 @& Z}. Q# ^/ A3 o6 T' x$ n
+ [1 J* t/ H1 c& r5 p/ ~module_init(led_platform_init);( `4 e/ Q& K. e% @+ L
module_exit(led_platform_exit);# c0 O& Q% U9 j2 J3 @6 v
4 F( \. z9 ]) o" z# tMODULE_DESCRIPTION("Led platform driver");( i* T- J1 X8 e3 E
MODULE_AUTHOR("Tronlong");6 r! i) w E" F. D# F7 _* h
MODULE_LICENSE("GPL");
* L8 V) X, v1 o
0 a& e7 y1 y* v2 S$ l. }; |1 f% g |
|