|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, Y' X6 |, t+ `# P3 ~#include <linux/init.h>
( ?7 d9 |) F$ R5 h#include <linux/module.h>" t, Y) \ j# i A7 T; ^
#include <linux/kernel.h>
5 q' \ c( X7 j- Q5 n \* z& g#include <linux/types.h>
5 f# K2 N# L) Z$ x* v, |2 Z#include <linux/gpio.h>
, F- r1 p% |$ J8 `#include <linux/leds.h>! d9 `/ F: Z3 K" ^, [- a8 g/ d
#include <linux/platform_device.h>
- M: I; ~/ ]( a5 \+ `" m1 v* g$ B; H" U
#include <asm/mach-types.h>7 j1 F5 G- [: x- u; }$ v+ p9 `" S$ U
#include <asm/mach/arch.h>
& P* K0 E: Y4 p3 A; k# @#include <mach/da8xx.h>
/ @1 N$ S" Y) S3 g1 Z3 T#include <mach/mux.h>; Q- ]+ F, { B
* V# X; v4 j$ j# w) I
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) Q2 }2 I5 u( ?
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ l7 z T' K+ B! I
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ h2 N% j3 l! A6 i( z
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! L. T9 `: v' _0 o% @# P
- G6 S4 M# {# M3 _( L6 p. z/* assign the tl som board LED-GPIOs*/2 u b' \1 f7 E- W4 q, [
static const short da850_evm_tl_user_led_pins[] = {1 X5 K U. n R+ a
/* These pins are definition at <mach/mux.h> file */
8 q% @ _" U" _& A/ {0 E7 z" Q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
+ V3 ]2 x* j$ Q5 [2 w -1! @' w4 m) p- b e$ Q
};! W, G- a! S0 }
) }/ z$ {8 d2 f: L* g9 l, d& M
static struct gpio_led da850_evm_tl_leds[] = {4 r' P! O; H1 d, l U
{# E1 [1 J6 Y+ T1 x3 Z2 X
.active_low = 0,
: K: L- b. v; k! v/ w. ~+ R5 R' u! ~! [ .gpio = DA850_USER_LED0,6 Q3 ^8 e$ V' f2 Q( C+ Z, b" p
.name = "user_led0",
6 L; C2 Q6 p! T" m: f9 u3 v$ { .default_trigger = "default-on",
% U/ J( _1 [$ | },* @1 V) @' O( l7 {
{6 T% q) d* x) S" t
.active_low = 0,
, \* f2 d" a* K# ?" G .gpio = DA850_USER_LED1,
, N* L" n9 a, @) R7 {1 } .name = "user_led1",
" W) W0 A7 t1 \; s6 W2 E4 m% Z .default_trigger = "default-on",& Y0 w7 z1 h0 d; l! E: I2 y
},- S- I3 B% d H% _2 v3 G
{9 n2 p8 a1 B0 m: Z; A
.active_low = 0,; R% |9 q9 U6 `; Q: q) i" t
.gpio = DA850_USER_LED2,2 z0 d# Y3 C1 }/ a
.name = "user_led2",
8 _9 N8 J z$ x2 w0 p .default_trigger = "default-on",% B% I g9 N8 X. O! r1 ?
},
5 A4 m0 s( p% g6 S4 p {
, C, s. g n# o: m* W4 a .active_low = 0,
8 F# J- h" I! _/ n6 J5 T* \ .gpio = DA850_USER_LED3,6 s1 u7 H6 {+ Y0 D& x8 E) f5 ]' p: ^
.name = "user_led3",1 G9 g6 x3 N) M8 q# @( y# U
.default_trigger = "default-on",
7 v1 h& K; o/ c; \6 F) j },
7 ^0 ?2 t+ _: C' c1 u3 @};, A- |% p9 ?' K& M
$ e! P/ X; u) j9 S7 s ~* y5 e& Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: ^+ X- Q0 B0 x9 n9 s' n3 \ .leds = da850_evm_tl_leds,: H8 c$ f6 y: u5 L4 y4 I
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),* S" W2 n ^7 o! ]
}; c2 Q/ k& ]4 m6 U5 p) C
, g4 k' R' O# s8 p1 x& Gstatic void led_dev_release(struct device *dev)- f ~; o/ C8 |0 ~, T- \+ t) z* Y
{6 ?5 W6 _ h6 g3 I9 T! T6 `
};0 A5 |% e2 }0 d5 v. W t% v
( q0 r0 s1 m6 \* W9 v2 ystatic struct platform_device da850_evm_tl_leds_device = {2 p. {5 V. t: L6 R: J1 R
.name = "leds-gpio",
) S8 z7 U/ F v% j- i; v .id = 1,
9 P; W: G0 i2 Q7 y1 w( y .dev = {3 A1 ^' E2 u5 W9 a3 {( Y
.platform_data = &da850_evm_tl_leds_pdata,
. E1 }1 B0 Y" h .release = led_dev_release,; [% Z7 `; z. g# s
}
# T0 d3 \$ ^) C* l. V0 C( Q$ ?8 @};: |4 `: s6 b N$ l& u9 U7 \
5 j- R* Y9 a# d* k
static int __init led_platform_init(void)
* u" S6 }. ]1 \3 G! w" ^+ x' }{
# D/ f% S9 C# k+ U! U int ret;
Q; N7 A% \: N _#if 0
E: U9 V2 ]" R4 m, X ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);: w# p+ Q3 w' m+ q3 `9 M
if (ret)
8 e7 u' G/ l0 P0 u8 d6 | pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ V3 m0 A7 }5 d, k" x "%d\n", ret);- a0 ?4 B+ t& ~. \) ]
#endif
3 o5 T3 |& i- J# k0 ]9 }2 s ret = platform_device_register(&da850_evm_tl_leds_device);
7 g: V4 f$ F* N5 H+ w if (ret)
4 J3 v, G8 L! y2 X pr_warning("Could not register som GPIO expander LEDS");0 n$ b) z! t# {! \3 a
else! x1 N2 [" i2 M6 s6 o
printk(KERN_INFO "LED register sucessful!\n");
+ a* ?; z! {" F1 A/ s, L( y0 R' _+ U, x
return ret;' _# F# k6 W P$ ?; S3 x2 E- \
}
( w1 g( ^, l7 Y. t2 g. y
2 C$ z2 ?8 t7 Q, J& Y% \static void __exit led_platform_exit(void)6 ^7 D2 U/ D" d+ q
{! G4 S/ ^, g I( U4 c* ` [" R
platform_device_unregister(&da850_evm_tl_leds_device);
. C# z0 Y5 n* ^ J' O
4 p0 M; [0 v6 V5 p( B& y$ S printk(KERN_INFO "LED unregister!\n");8 H ^1 J# c/ O& R q
}/ v: w& v+ D5 Q/ }4 G/ \
3 o8 z6 p# P9 u* \$ ~module_init(led_platform_init);
7 W" r8 h; I2 o$ \+ fmodule_exit(led_platform_exit);1 t/ f: b3 Z3 U; G+ V8 A! C
' |$ \( f- U9 D9 m% \* J9 A/ K
MODULE_DESCRIPTION("Led platform driver");* x8 ]- t, d2 q0 S
MODULE_AUTHOR("Tronlong");( W" @" H- p8 N- W1 A1 G% D
MODULE_LICENSE("GPL");9 Y0 c" }. Z$ X6 b k/ M
. o, }; P- ?9 H" `2 C& T |
|