|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 s1 I( l+ Q: s, q3 o, k& a4 O#include <linux/init.h>% _$ H* U4 @( Y$ ^- i0 J
#include <linux/module.h>5 b2 n7 {' a+ p" b
#include <linux/kernel.h>
$ @& o6 y; w% b- W#include <linux/types.h>
% Q+ a; ~' y, D; B. z#include <linux/gpio.h>1 `: N" } l) C1 A! {
#include <linux/leds.h>2 h$ S0 J& `- w1 ^' C7 [
#include <linux/platform_device.h>9 L, a, r3 m# ?, J3 k
. g) d8 v. o+ k$ I6 E) a7 |2 O
#include <asm/mach-types.h>6 c' V: e/ S: ?, x* T5 {. S8 O: S
#include <asm/mach/arch.h>" \- |2 w, j' \0 Q) l& p S
#include <mach/da8xx.h>6 a! U9 A( K8 o/ U* p
#include <mach/mux.h>: t; f5 {6 r$ `$ T$ @+ K! f! }
* y5 A5 v/ E, y L#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 u7 M, X) e- z/ g
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( m% o& j+ h7 ~5 W. s3 B
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); Q8 A4 u3 V, G0 X3 Z+ S4 g' B8 J
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ R ?1 Q0 N5 W. y. e" P" H- @. j; [/ [; c( C7 G
/* assign the tl som board LED-GPIOs*/
4 d) L& }$ H" [( h% l' L4 Q6 ~) kstatic const short da850_evm_tl_user_led_pins[] = {
$ t2 G' {" U4 p* s8 ~, ]' g /* These pins are definition at <mach/mux.h> file */9 T ~7 D$ R. b7 Y( C0 e8 T
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' U5 J. ?3 @9 Y0 v. s
-1
/ _' C1 H1 K6 i( A, c I};
; V' R! W# V7 d/ H# Q% I
% ?5 t- l# a- L5 [) ?static struct gpio_led da850_evm_tl_leds[] = {5 C( D( T; ~' }' d9 s1 M- o) |; c
{
- R n0 ~! Q E( g( m6 p .active_low = 0,
p4 u, l, I% T2 W .gpio = DA850_USER_LED0,
# ?0 _1 h% U. p: T .name = "user_led0",+ B8 l+ }5 q+ M# W8 o
.default_trigger = "default-on",: ]% a7 L8 |' _" [( b8 x
},
9 A3 V& {0 q) l5 | {2 k. k8 f8 y) _0 x: M
.active_low = 0,
$ ^" S/ y% x2 a% ?4 @ .gpio = DA850_USER_LED1,: |0 Z/ k$ W0 @: ?9 Y: N9 m
.name = "user_led1",7 @2 \, o! k& \% S j# o. N
.default_trigger = "default-on",# c. H, A4 m3 j2 r+ h8 q4 d/ L
},, d6 E) M1 Y! w! R
{9 p' |( K: D3 F% r
.active_low = 0,
, }9 n) [9 `; K6 T" M8 f- @' o .gpio = DA850_USER_LED2, y ]1 m7 S4 w
.name = "user_led2",( s$ k% b/ i( Q, k$ `
.default_trigger = "default-on"," u" J% z( M2 j, ^' o2 h# N$ |
},' w8 W- d1 L% V7 C
{
1 Q L& I/ O9 d- k .active_low = 0,
6 w6 j) U+ z4 h c& h8 r- H .gpio = DA850_USER_LED3,
0 W! C; S5 Q" I6 q) a- n) B .name = "user_led3",
# j- t7 P1 m8 z6 K1 J .default_trigger = "default-on",2 D2 t/ S |% e
},7 e. L& L- E) h! {2 h6 R8 r
};6 t S- `. Y0 s$ ?1 o+ t; ~
: S/ t3 M6 o( q; Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 Z& H7 @& m3 @. u: |$ l
.leds = da850_evm_tl_leds,; i( ]0 Y# Q4 D# `; h" y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 o2 b+ [% @( d1 Q};; y: c3 V3 @4 d
7 Z# d3 ^8 S5 B* u" ystatic void led_dev_release(struct device *dev)
/ W3 p l& [ }8 q2 H{/ e0 L& e: y D" R# {' |0 x
};
6 O* ^+ t" t1 U+ z M4 p ^! @1 h7 e
static struct platform_device da850_evm_tl_leds_device = {
' L% g4 H0 T- H2 C% S4 e& v3 U. b0 M- H .name = "leds-gpio",. H9 b# y' H1 q3 a
.id = 1,/ M1 W; E& g4 H p3 ~3 G
.dev = {
5 S* T( V" C/ }2 y Z. e .platform_data = &da850_evm_tl_leds_pdata,
) ], p5 s. d( L/ ^ .release = led_dev_release,+ `' N: F \$ ~
}* M/ |, p: ^: J. C9 E i, c6 ?: C Z
};. y: x4 i1 T8 `5 R+ h' Z9 {
8 P, ~5 `2 z+ X7 c2 _static int __init led_platform_init(void)/ r0 ? O' r, W6 q* P0 E5 a
{
) c0 X% o/ _; e5 D' |1 m, \ int ret;7 T" v2 ~: h9 R. [* \" A
#if 0
1 V3 f" o4 a% \* Y1 _# W; \2 C( i ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ t; H: C" Z. p1 r
if (ret)9 `2 X$ {& D6 P
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: p3 v# c+ C; ]* p1 p, t "%d\n", ret);
4 c, R. t# |! v& \ i$ @1 _$ M#endif
$ Z6 k k% T/ r: i0 @ ret = platform_device_register(&da850_evm_tl_leds_device);8 L9 g2 U, y6 ^6 }! k V
if (ret)& s) H) c8 S7 R/ d* N3 S& [
pr_warning("Could not register som GPIO expander LEDS");+ S) u' a9 P1 L: |2 e
else1 w5 X3 _% [' ]: b
printk(KERN_INFO "LED register sucessful!\n");( l: v1 ^' I+ h- F1 L2 X0 E3 P
2 |3 F7 ]& E' X9 a* x0 I
return ret;
/ W W7 e0 x, p. P: I0 Z}
~ S3 n: y+ {( [& L: ]7 ]5 h2 _- S, ]+ y, L8 ^
static void __exit led_platform_exit(void)
$ H! i7 s( R, P0 [{# O. }) x; s9 ]0 b/ ]" e5 V
platform_device_unregister(&da850_evm_tl_leds_device);
& H/ N' ~8 u) s8 U' o" C4 y- G& K/ a( ^" M5 Y+ c: w \; R p
printk(KERN_INFO "LED unregister!\n");5 Q$ M" W2 m" f9 Z; d. _
}
. k6 O+ R7 w3 `* A5 D( Z8 }
: a& U" i8 f, Smodule_init(led_platform_init);
# x E( S3 s* zmodule_exit(led_platform_exit);/ h. w5 l( W' j+ G% L; b+ H! Z
, ?: J0 @! s' n; h1 ZMODULE_DESCRIPTION("Led platform driver");0 y. N- e1 ?6 v; ~# {) o" K* l% ]
MODULE_AUTHOR("Tronlong");
1 i! N3 K8 q! qMODULE_LICENSE("GPL");0 n3 q( l5 q- x. s
0 A& }( w# ~. p |
|