|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# g+ n' D% K& e0 {0 E#include <linux/init.h>
2 ]+ V& ~: @5 w e2 c+ {) t) n#include <linux/module.h>
3 _ N, b, z+ e2 ?: k' e6 z7 Z#include <linux/kernel.h>
* g5 j6 J/ J; ]0 a#include <linux/types.h>
H5 \$ |+ S; Q% y0 z( k* F#include <linux/gpio.h>
" u: {7 t9 m9 v2 S6 B3 y( N#include <linux/leds.h>
0 k3 V4 u, E1 R- y( u1 d6 V* }9 p#include <linux/platform_device.h>! y- w" y2 P7 l" B. S9 M/ ?
9 o+ ]6 c$ C+ f( A5 e#include <asm/mach-types.h>
4 ]& o) F& q" S9 x. d( f3 P#include <asm/mach/arch.h>0 }4 f& i$ }! G V& U5 F5 r
#include <mach/da8xx.h>/ H: K- h% E3 a) \5 K
#include <mach/mux.h>
; i$ N" D) g9 v: r
( [# }5 @4 t! x# G& ~# m/ s+ V `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 Z3 r5 c: C! o. J v+ X3 {#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. H. V8 j8 q, ` T9 [ J v! E5 I#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 u9 ^6 `% X( k
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% A$ E* a6 [; b) h& p% b0 f& _; m1 V n
/* assign the tl som board LED-GPIOs*/, f/ }: g; a! w$ o' n5 }
static const short da850_evm_tl_user_led_pins[] = {8 v* J% l, W7 F8 ?( O: X9 y
/* These pins are definition at <mach/mux.h> file */
+ u- A$ {! o- m" c DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! f7 C+ K* I/ U6 c8 }0 B8 [0 o7 S -12 `6 B0 Z) a& H8 o
};
4 R, h6 X9 |; V K" |
8 C" j+ y7 R9 Istatic struct gpio_led da850_evm_tl_leds[] = {: a; ]% T" }+ v5 [* @- G
{$ Y! X3 p% z) z8 j i) u4 j! p
.active_low = 0,5 L( x( i! x+ r* q2 [; P0 D' q
.gpio = DA850_USER_LED0,
) b5 m1 t2 @6 n9 I .name = "user_led0",! r4 ?; ~9 V! B4 R% W3 W
.default_trigger = "default-on",
9 {% Q6 ]7 ]' n( I& E+ } },# \. p) O* E( U R8 `/ R2 ?% I. x& q! S
{" A' U; D2 N' X& h
.active_low = 0,
& J# D/ K1 D: {' Q .gpio = DA850_USER_LED1,, G9 A3 w7 E2 Q9 I( Z
.name = "user_led1",
* s* K: S0 E9 ^+ L1 s% h .default_trigger = "default-on",( t/ v6 C8 G# O5 g) F$ Q
},
! }' Y: l6 `2 s2 w+ O {* w9 q" I2 {% O" _, c, q' G9 \
.active_low = 0,* K; V8 r1 z' K+ T, y5 d2 ~' r( K
.gpio = DA850_USER_LED2,
0 D: F9 p) |5 y* G; \6 S3 L .name = "user_led2",
& X% t8 z# f) a7 c$ w, g+ e .default_trigger = "default-on",
' g7 c: A6 n8 I4 M2 r },
. `! O9 S8 M3 D* Z {
9 _7 f' m5 A" l. U6 E, X" s# G .active_low = 0,
6 r n8 G+ u4 f# d. N# ?: c .gpio = DA850_USER_LED3,, [) ~8 M/ L ]' ]8 P9 {
.name = "user_led3",3 i: h: ?7 D( \+ L& ] }
.default_trigger = "default-on",
# R/ v' }, D7 x6 _5 g* S },/ z7 _" v) |5 Y6 r: X3 l0 O
};4 ]) c9 w/ I- S: K5 O. n$ R7 @
0 I. Z- V7 ?6 l' L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& l1 S! K$ A% z& d( w! f' L
.leds = da850_evm_tl_leds,' l# s7 E7 i9 c1 n* [3 J7 r3 F) @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 h- i6 z6 S$ Y9 R! R};: ^3 P* n: }5 e7 x5 S- W+ d# _
$ ~( p+ N# H6 {3 E% W6 |2 |3 m
static void led_dev_release(struct device *dev)
+ ]/ S3 C0 i7 }) ]$ U/ p) J8 K3 m0 l{4 w# ]& _( Z/ k: @+ r. M
};
9 f! M& L% d. s. G; O, u
. ]1 B l9 q! Z& {9 J" m* |7 Sstatic struct platform_device da850_evm_tl_leds_device = {" `# F3 q+ {- I* V
.name = "leds-gpio",, Z8 V+ k/ `/ F: p- A
.id = 1,( n( f' Y F- [* F @% `; @1 Q
.dev = {
; e$ ~0 g1 f$ w$ u5 T9 F& Y; e5 { .platform_data = &da850_evm_tl_leds_pdata,. `3 `* a. ]3 k
.release = led_dev_release,
) V& q; E/ y. a9 u }* l( S+ t- I# a9 \2 {( v, f- ~
};
% d2 w h" e }; C8 A& u8 }, p2 i
% A9 t/ w6 k2 X* l% W& S. astatic int __init led_platform_init(void)
7 q* W Q8 A' [: b7 }# `{
2 a; x# e# _- B) n int ret;
0 E$ M' S5 k0 U#if 0 U4 x2 h8 I. C, ]" Z) H
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
s; C; h, p1 J+ [4 q1 I& `+ h; i if (ret)
8 S1 i& s) W1 F9 ? j pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# ~, X, |$ \& E' I; I# o
"%d\n", ret);
. a& M; ^1 V" o& |1 n#endif
x1 g2 y) f9 n' w ret = platform_device_register(&da850_evm_tl_leds_device); l1 A2 k; T9 r: l. O
if (ret)4 U# \$ Q/ k9 W V. j
pr_warning("Could not register som GPIO expander LEDS");
# w) r6 M- C. s; e# j+ K else
( T' Z1 b; T, `2 c& S% s, P1 S8 ~ printk(KERN_INFO "LED register sucessful!\n");, W. N$ L+ W5 ^2 \
2 W0 J- s" d5 Z. U: G: e" T1 ?; E$ S
return ret;
+ [2 F, V2 U9 a, P1 }: _}8 |! U& Y/ w% `2 }& t
/ m2 v7 T# h1 s+ r9 \$ m+ Y
static void __exit led_platform_exit(void)
2 u4 {) ?2 U" e' K, H, T8 S: b+ {{7 G% W) }7 p+ O! @
platform_device_unregister(&da850_evm_tl_leds_device);
, \; E9 g1 a: o: N) ]* _) m0 y, r# `* u7 u2 z# m* U
printk(KERN_INFO "LED unregister!\n");
9 j2 `% c; b3 i) T0 x* R}' h! r4 L+ h* E1 l/ T
3 ]7 n. s/ }7 Q9 _- a, R
module_init(led_platform_init);
/ ~6 x; O( f9 j2 V2 \module_exit(led_platform_exit);
' w! K" | U+ V4 L8 }: H
, Q. {0 r% M6 s+ B& qMODULE_DESCRIPTION("Led platform driver");" S) l3 c, ~! Q2 r
MODULE_AUTHOR("Tronlong");( M+ i: B6 z0 j# A$ A# h7 h# s
MODULE_LICENSE("GPL");. }; G3 T( [. L; p0 \6 J( B) U
8 x7 P. L2 V$ y( ^* ]$ R1 C |
|