|
求大神给下面的程序做注解,请稍详细些,谢谢。2 d2 |* ?5 U0 `1 @/ c& g
#include <linux/init.h>6 K) D' ^: t% Q* V! m$ m+ A0 h+ `( Z& K% [& q
#include <linux/module.h>4 u E# ^0 d9 ], \) H/ p0 Y
#include <linux/kernel.h>
5 I' J9 o! W! c#include <linux/types.h>' K9 k/ S I4 i/ E! V- D, v# J
#include <linux/gpio.h>4 O5 M2 N" r* ?+ M2 ^
#include <linux/leds.h>' [" i6 U; G/ @5 O- E( X
#include <linux/platform_device.h>
$ S: B. N8 G O) O2 a
8 O. D5 R/ M+ U1 U8 d4 L#include <asm/mach-types.h>
4 l$ g1 M5 e* h7 c- G7 f' `9 b#include <asm/mach/arch.h>+ }) q4 Q$ l, l5 }2 z
#include <mach/da8xx.h>
6 Y }8 l- W+ S( V#include <mach/mux.h>
1 D6 D, u; T- s5 D* ^' O) e3 Q! l
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ I. E" c ?; o3 _6 A* Q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 S' Z/ x. d6 J# ~
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ [9 ~9 R/ M" ~% h# ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
@, D! T. E/ G/ f/ i; o$ b$ b. F" w9 r
/* assign the tl som board LED-GPIOs*/" }) i0 C3 ~' i$ c( w0 Z: F9 j) x# {
static const short da850_evm_tl_user_led_pins[] = {% D1 N& L( l. R: a% n; i
/* These pins are definition at <mach/mux.h> file */
7 m. O: Q; z. l4 v DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# {+ n% \8 q, Y
-1$ q9 Y' f; C3 x% h" i5 _
};
$ E/ V4 A/ B( R9 E9 X8 N& s: a) A5 |4 o I! |7 i8 G
static struct gpio_led da850_evm_tl_leds[] = {
- Y7 t- k0 ^$ Q0 c; M R {* B% t4 x. ~3 q$ F2 `3 X
.active_low = 0,8 Z: B5 V# |- @. O
.gpio = DA850_USER_LED0,9 K" X& w* Z4 M( q$ N' W G- g
.name = "user_led0",8 H: E1 w# O, _/ }4 U9 M
.default_trigger = "default-on",+ i0 X2 _& L! l0 Y6 @
},
3 V2 ?- a* _+ V* d5 o( V4 M s {8 o" H3 ^$ ^' ^& W4 b' W5 a
.active_low = 0,+ ~( b& E' ^) r/ R0 M# M
.gpio = DA850_USER_LED1,
) | l1 ~% B% Q" m .name = "user_led1",9 A. k0 q7 d4 o7 ]
.default_trigger = "default-on",; r2 g8 A; |& j5 d) \9 }, A$ C
},
+ x4 P# b/ `0 n5 |- j {
1 E: D+ k* j1 M .active_low = 0,
: u" ?) u9 c$ P/ L2 B% L1 P .gpio = DA850_USER_LED2,5 D- O( X0 Q! R3 o; Y/ {# ^; _
.name = "user_led2",
. o; T+ C( N* C; A" A .default_trigger = "default-on",
V4 I' C* ~, J" e' ?1 C# k }," q! T/ o; l) d
{
! a4 g, {7 f- q0 Q$ a1 l .active_low = 0,
# ]! z* H: `! T6 o .gpio = DA850_USER_LED3,
0 @0 ]* R P. d2 { .name = "user_led3",, X' z3 S3 A' H7 w* M$ x# a
.default_trigger = "default-on",4 f% p3 H8 V* j7 B+ |9 G
}," g. x+ i1 R! ?6 I2 O
};6 L* v& i0 n- P9 g0 j+ `
5 h5 S& m/ T. t: J+ z8 t; Istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = { h. I$ L3 R4 j* N
.leds = da850_evm_tl_leds,
t4 t1 N6 z' i/ p, v5 ~2 L .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* t* x) n: L" e
};
3 w! p1 ^# C% W* d, I! G1 |' \' H$ x, X4 w3 x; w7 K9 @5 h4 y: {' s
static void led_dev_release(struct device *dev)4 p+ [2 u3 Z- Y2 B! v: S0 s
{6 Y' U, ~' u% f
};
' S" R7 v L: j& f& k, o6 o$ B5 o1 S, i$ M
static struct platform_device da850_evm_tl_leds_device = {# C, m1 |3 A6 m/ @5 @1 F
.name = "leds-gpio",
* v" q" F( a7 y6 t1 P6 ^$ n .id = 1,3 M3 W4 X- ?; X1 n) z
.dev = { l5 G1 F: Q+ S" P
.platform_data = &da850_evm_tl_leds_pdata,
4 X8 c" |4 j' l+ f .release = led_dev_release,! [* l, y6 ` d7 e1 o: h
}5 y5 t! M% n/ X+ u& [" ^' K
};& u r# ~ h. K5 F/ _# l5 t% ~* X! U
( B V; D( Y: b+ {5 t/ s
static int __init led_platform_init(void)
+ n7 O/ B9 D5 ~( J6 w! T2 i) s{
" Y3 }$ ^* n+ E; _8 ` int ret;
3 H [- S+ T' a4 \( \3 y# U& h#if 0/ v. s" Y# P& ~; S' ]: Z2 C
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" r4 c1 J4 G; J% L: ]2 A/ S2 {" O
if (ret)% e5 d _+ l0 `% {
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 m6 ?" P; x, W) O) s% n "%d\n", ret);
. u* c9 @5 T7 A' `% r. d* `#endif! @( K# @9 X7 W: L6 T$ A& x/ T0 l
ret = platform_device_register(&da850_evm_tl_leds_device);
6 w; L! q- `5 G( |9 @3 p if (ret)
5 q$ W# M4 k/ ^) a4 [ pr_warning("Could not register som GPIO expander LEDS");
- `* M0 L5 u" T# O! H, O* P6 H5 p else
: a- \) x! D3 R- f. l0 p* w( k9 `- p printk(KERN_INFO "LED register sucessful!\n");
3 {, Z0 l+ ]+ q7 w u9 Q0 c4 O$ J4 R$ W' V- u
return ret;- B! E0 v% r' ^. D0 W7 F6 w
}
Y& I$ M$ |/ h
* R, R$ Q1 e. W' j/ ?5 U* Qstatic void __exit led_platform_exit(void)
8 w( @0 g9 x5 {. f* `; V# \6 [{
/ n- ]( b/ g% X8 V7 @. t platform_device_unregister(&da850_evm_tl_leds_device);
- i. S( L r3 I) I
0 P, a, k8 W6 R# m6 }6 ]" R printk(KERN_INFO "LED unregister!\n");; K0 T8 m; o" Q& ]
}
/ s& w8 `) U Z+ M7 L5 s4 @
- D' [8 `5 L! g4 q% w5 ~* pmodule_init(led_platform_init);2 s" y7 d6 ?8 e
module_exit(led_platform_exit);
7 ^& f0 ~/ [) H G% ]0 a
# i8 w3 p1 `; r8 C: uMODULE_DESCRIPTION("Led platform driver");" y0 X( b) N& K+ \4 ~: r5 x
MODULE_AUTHOR("Tronlong");
& U# x" w2 p$ e# kMODULE_LICENSE("GPL");. F o& `- ?& h( t' p+ \
^2 u, d+ e3 e3 W. E |
|