|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ L4 }8 I8 j9 ^: I
#include <linux/init.h>
" e* [, [( I* i4 D; a#include <linux/module.h>
9 ]/ o$ u) `! v: `#include <linux/kernel.h>
G! C- j$ P) R- o7 [5 t#include <linux/types.h> j1 d( ?$ B; x* R
#include <linux/gpio.h>' y3 ?! e' c. s$ Y3 K+ x7 z
#include <linux/leds.h>
( y3 C' o% ?( m9 B% z2 T#include <linux/platform_device.h>/ q4 X! J$ j# H, r& g0 _6 X
# \) }$ h" T8 D2 R/ E#include <asm/mach-types.h>
5 k, [0 s# r9 U" [" H* Y#include <asm/mach/arch.h>
: h) j" R0 U) @0 K! G#include <mach/da8xx.h>
9 [* U8 P$ f8 \( E#include <mach/mux.h>4 C6 S- ~0 S; @4 U% E2 A
4 c2 l/ \# d$ L6 M" Q ]4 ?#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 ?% R5 f1 h" m3 `6 v#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 _1 p3 @3 \" T, H#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' Q) H8 i! e! ] i, X9 G+ [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ g! R+ B2 o& T) V7 X6 {; y" j- `5 j* Z1 ~/ Y, J
/* assign the tl som board LED-GPIOs*/* ~9 l. z7 ]' c9 I# a9 n
static const short da850_evm_tl_user_led_pins[] = {
/ y; s0 c! `% e0 A2 J1 N /* These pins are definition at <mach/mux.h> file */
8 a4 O3 r( M( h, ` f8 n; P DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. G' o8 z. l1 F! w# A! ~( J
-1" A( I9 ^0 S9 C
};7 E; D- m8 `' f& K a
/ u% w2 R/ C l$ }
static struct gpio_led da850_evm_tl_leds[] = {1 |* j R$ J/ r6 Q
{
1 u# G6 j0 ]: d2 I. N .active_low = 0,
; R( F* x2 s2 [; ` .gpio = DA850_USER_LED0,; j4 u" d4 h3 n( L7 v3 P
.name = "user_led0",
( U4 t$ {$ J% o/ u+ s9 D' P0 b- q+ e .default_trigger = "default-on",0 P, v1 I4 H" B. {4 B
},
1 F! G% t4 S" r1 b" [, w! i {% x# o+ Y5 @4 ]" b7 V1 J( z! N
.active_low = 0,
) z- z$ k. M# R( u .gpio = DA850_USER_LED1,, F, o3 _1 w- T# }; x1 H
.name = "user_led1",& L! T: e+ {8 b) R9 P% c
.default_trigger = "default-on",$ X3 b; {$ {7 A: J; u
},/ |4 @1 Q6 c0 C0 L8 D9 m
{; d9 B: r7 _# }6 d! z; T
.active_low = 0, L1 W# e: c. a$ b r# S1 z* I; n
.gpio = DA850_USER_LED2," R4 o3 p' D2 _8 L- N' k
.name = "user_led2",
9 T1 @( v) X$ j# a6 D .default_trigger = "default-on",+ ]% Z4 y/ y7 ], J
},
% o; q! d5 o* U& W; X. F {" ~# ?1 E/ ?1 I# F9 r" M
.active_low = 0,: g2 [7 r4 R: }, c% v+ a
.gpio = DA850_USER_LED3,% z9 M: j$ V/ ?, X) V& s+ c2 i1 P
.name = "user_led3",' W) T+ m# {( f/ U' W
.default_trigger = "default-on",' q2 V3 d) o: C2 k+ I
},
+ y" n) w# W% {5 u: A& t};, t5 B2 ?; V1 Y# Y3 ^9 V
' w/ r9 f2 R* N
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% `8 z* C9 b: x; k9 l& n/ `- I" B
.leds = da850_evm_tl_leds,, w2 O( `+ J2 a
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 R9 p0 R4 ?. u/ |5 O! @# i
};) F, Y( i( ^+ L- b8 R( y. Z
# p0 I9 d8 U0 a8 q% C9 L$ s/ rstatic void led_dev_release(struct device *dev)1 O; j" N1 V4 z: i9 _- X) g6 ~
{$ g! p7 c: f, l* k; ?
};$ d0 l3 P' f! a$ o5 N
, {1 D; w* {1 Jstatic struct platform_device da850_evm_tl_leds_device = {
( x z4 N. ]* R K .name = "leds-gpio",
, M1 m, |$ Q6 o* c5 N8 s! h" n .id = 1,5 C; M6 u6 y* L O3 s2 N3 N8 H
.dev = {
- ~3 }6 m& u# n. U1 I. i4 C, s .platform_data = &da850_evm_tl_leds_pdata,
' G$ M4 ~: h" X! f, H .release = led_dev_release,
7 z& E+ M' p! R- F2 x+ M0 x: R }- }7 q2 y& D9 u) o8 L
};
1 L6 s& a2 z7 i6 D
U u2 |2 A/ g: ?4 astatic int __init led_platform_init(void) p* d, A; f8 W; J- a
{' d* m0 S+ h& O- R
int ret;9 y, h9 |( n" V8 C! Q. Z) \
#if 0* c& G P! ~3 `1 e
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 B1 X% o* }9 U# a! z/ p# o
if (ret)
" T% @ p# g- u$ `1 A pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 X- {0 ^6 m8 t6 J. _3 p "%d\n", ret);6 D* P0 ]/ m' K/ t& m- e4 M
#endif
H& m# ?3 L2 S6 b; P# L% F& S5 k ret = platform_device_register(&da850_evm_tl_leds_device);
* [+ i& o# g* [' c L. m if (ret)' J9 ~9 i' q; h2 y+ h% o2 Z! U- f3 H
pr_warning("Could not register som GPIO expander LEDS");
; S$ d( ]3 C& T' d5 A- x else
8 z$ C& r' ?1 V& D7 m) F! e+ l printk(KERN_INFO "LED register sucessful!\n");% Z; G: m. d+ g& \$ e" p
2 p" }% T- @! N* r$ N return ret;- K- m# D! e2 S5 p3 o! H
}
; G$ s! `/ _5 b5 s# b& i
# J( r. n$ W5 s) i0 e; wstatic void __exit led_platform_exit(void)
8 z2 _' ^* A2 a% k+ v3 O# n{0 O1 C; u3 n& _. |: @( f. c# P
platform_device_unregister(&da850_evm_tl_leds_device);+ i' v4 z# u' m* f4 |. ?$ k" `$ _
6 s. p# p; D$ H4 A$ r9 q- y7 d
printk(KERN_INFO "LED unregister!\n");
: Z2 Z1 U/ g# }}0 F$ {* f0 y2 Y( [* l
V4 W& a ^# [) b, i5 vmodule_init(led_platform_init);7 m. ?9 d2 L0 k" k8 d5 w
module_exit(led_platform_exit);, ]* b& c ]+ }1 f) y7 T# Q b' k
" m& y) a% |4 E& i- I
MODULE_DESCRIPTION("Led platform driver");/ J3 A$ X% j. z" C' U2 \
MODULE_AUTHOR("Tronlong");7 y4 J p3 q$ U8 {# Q/ E) D
MODULE_LICENSE("GPL");5 [9 Z2 N6 [# E2 t
& \6 G1 d" A. S |) v0 [- v( a% C
|
|