|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; Y. ^+ o: t/ O7 o6 @5 v8 b#include <linux/init.h>7 D; }" r' c# Q
#include <linux/module.h>
6 n6 x+ y% n* v# Q#include <linux/kernel.h>( ^" m0 c/ g- ~. c8 h
#include <linux/types.h>% v! s- L# s3 M8 q
#include <linux/gpio.h>
8 Z* G% ?6 L- o% Z1 G/ h' {4 @#include <linux/leds.h># g2 s0 |! U, v) K
#include <linux/platform_device.h>
L7 O( {1 _3 w9 R* w, {. G6 y: N1 @
! B4 R0 o# }2 i5 Z9 f$ I7 d/ M( W#include <asm/mach-types.h>
?2 l/ y' Y+ B1 {#include <asm/mach/arch.h>
S& y$ ?) e+ Z' H: N# ?+ M. h#include <mach/da8xx.h>% P& P! h& C H1 o
#include <mach/mux.h>
: X5 G. v: s2 Z7 _1 m3 C9 |2 f3 h) R
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& M' o) g v" a& K v. S
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
F# v9 j3 t4 y( s0 m& G$ R#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 T& H5 N0 B) G% ~" `, @- a
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 a. L# m3 F+ k7 n2 D
) S4 X" u0 y M& u% g( T J( C/* assign the tl som board LED-GPIOs*/
9 t9 n' J7 @5 q% a8 N% Fstatic const short da850_evm_tl_user_led_pins[] = {9 J' ]" Y/ e# w" Q; z: j- _
/* These pins are definition at <mach/mux.h> file */
- R3 q/ u8 F' M) j' i DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 B6 }$ j' S9 V4 N
-1 Q8 k& M {" Z
};9 t6 }. q* ^# C, d4 ]. g' O
6 z+ }3 E d4 u& Astatic struct gpio_led da850_evm_tl_leds[] = {
4 s2 i1 `0 H8 V/ d/ E3 E {* A U. i3 I* D6 M- l
.active_low = 0,
8 J9 ]3 c, e7 a4 d0 C .gpio = DA850_USER_LED0,
: [0 }, R, R" T H4 _# { .name = "user_led0",
% v; }, R {+ _$ d .default_trigger = "default-on",
0 Y# |! |% M+ A* q7 W! Q: a },
8 e' x% U! V* A# R8 G% A {: i$ {& f/ I. M3 e! a7 e* y* s
.active_low = 0,' a f) Z; d" ]& U
.gpio = DA850_USER_LED1,
. ]2 H0 W4 s& G7 \0 k% b4 f/ S! ]( Q .name = "user_led1",' w8 p9 \- K7 l6 B/ p8 n
.default_trigger = "default-on",* o/ F5 \* B& V1 v8 X; A" m
},) U/ c4 q7 h" E V2 ~# k0 [4 q
{
/ t. I5 G5 o6 s$ c .active_low = 0, o2 Y, E2 W- H0 D
.gpio = DA850_USER_LED2,7 R3 o' f T7 l" p9 h F0 V
.name = "user_led2",
# A; p3 m2 E) i( z .default_trigger = "default-on", g8 p5 B2 L/ T' e3 p0 v
},
) @3 h! B) C% o {2 Z/ J7 r: f: X& G1 f
.active_low = 0,
# T! K: ?+ [$ g& b" s; J j .gpio = DA850_USER_LED3,2 }* C) Y' p# L9 W8 _
.name = "user_led3",
. `/ B7 P2 |" p# c0 l .default_trigger = "default-on",# L+ s( y6 Z3 \2 ^. ?/ \
},
0 x# v- H H4 v0 a# K" c};
9 \" S% b9 v0 m/ A9 H
8 P* K3 w8 U& Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% [* W* s9 l0 I6 i# \3 x+ B
.leds = da850_evm_tl_leds,
$ l) @0 \, ?( l! i4 N) A9 w7 H .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 j& ]0 F5 F4 \1 v5 `" p
};) l+ R" U0 }+ l$ G! u, R9 n2 M* U
( r9 k, S1 ^8 w/ k
static void led_dev_release(struct device *dev)/ A! c: p. F& |8 L0 A' t$ _; Z
{
! M$ n$ ~ Y3 J L};
9 w4 \9 U; L' k8 ?
, h4 U, Q ?3 y$ m: S$ L, ~static struct platform_device da850_evm_tl_leds_device = {
& Q6 [% m0 d9 \6 H* ]; P+ i .name = "leds-gpio",3 e- z" c' i7 |
.id = 1,) U* V5 @( Y* a
.dev = {
; S9 a; f4 x! y) \9 A5 D7 ^ .platform_data = &da850_evm_tl_leds_pdata,
% C& Z1 }, p3 L! ?* o .release = led_dev_release,
+ B/ r0 O9 F/ Y9 H, p3 A }
3 I. ?8 ?- h, [/ i7 S0 V! l};
q, M: x. }$ ]0 r) w! O5 c3 y7 a3 k6 W" o+ W& b
static int __init led_platform_init(void)2 v Y9 [0 G0 m. M8 X$ ]' S
{6 t$ ?2 m8 `* H. o& c i, J
int ret;
% q& N# j' Y. M% V; C* N, k6 _8 `( k#if 0; H3 i! i b x3 N- M. e( W! `
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. }/ \$ ]0 h! x+ z. m" }
if (ret)) Z* z9 E5 y3 g+ i( E
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 @' g. w3 ^) r V% S# z6 l
"%d\n", ret);
# P3 D6 W$ p) ~8 n: f! R/ h#endif* X2 X6 S& Z8 d% g; c3 ^. `2 B% _
ret = platform_device_register(&da850_evm_tl_leds_device);+ t X5 ]# N) |5 r; I/ L0 g
if (ret)
' J" \6 h8 ^5 b# E% B" s% K2 w pr_warning("Could not register som GPIO expander LEDS");$ ?* ^3 y" f, y0 Q5 l" ]0 A
else
( K" m; M( x' D1 I4 Y% S printk(KERN_INFO "LED register sucessful!\n");
! y; M0 I9 J# X+ W" r! B! z
, V7 @' g: i8 T+ L" c return ret;# P+ M. }9 ~' M/ o8 f. h
}% c, w( p1 h' w: K* u
: w6 t4 [# s1 o8 Z8 Wstatic void __exit led_platform_exit(void)
* J# C' N" n& [9 ~. p0 `- E{4 y5 ?1 v1 N+ K6 x
platform_device_unregister(&da850_evm_tl_leds_device);
2 y/ `* i) [5 q) f5 G" m
' b$ L2 B) c" {3 l printk(KERN_INFO "LED unregister!\n");
M/ P: C" m! c) k+ H0 |' |5 g}
0 r4 v* \& Z2 S% B. b$ R( @1 J- G" R9 p
module_init(led_platform_init);9 `8 q! D& X- k& l( \ v% V3 M8 L
module_exit(led_platform_exit);
4 R/ W( x$ F, X! G
4 M( e& J" w$ BMODULE_DESCRIPTION("Led platform driver");# F! O- z! u3 K& ^4 I
MODULE_AUTHOR("Tronlong");
$ r2 b/ j) t8 ]MODULE_LICENSE("GPL");% f: I; F. t6 }) A
: d! ?6 w7 T$ Q$ b
|
|