|
求大神给下面的程序做注解,请稍详细些,谢谢。' i5 k( x$ a8 ]* m2 z
#include <linux/init.h>
' K9 O: U( Y" X. L1 |/ C8 `2 ?% L#include <linux/module.h>6 O2 }9 t8 t% _2 t
#include <linux/kernel.h>
i) x/ T* S7 N& ]5 h+ i) `#include <linux/types.h>4 v8 B* Y& Z j5 J8 O
#include <linux/gpio.h>
8 u5 A2 S* e5 Z#include <linux/leds.h>
8 C; g3 p, v8 r( h4 V# k#include <linux/platform_device.h>
# T K2 p* r/ M4 z* Q, _8 F% b. m: M: r; }1 d4 `+ z* w% t0 l! h5 i4 Z
#include <asm/mach-types.h>
' R5 m* U s6 M5 }#include <asm/mach/arch.h>
! \" a9 R* k& o) G! b8 z# C. S* g: q#include <mach/da8xx.h>
4 ^* b( s6 m& r#include <mach/mux.h>8 U5 P/ Q! I* v9 r) D
& y5 l8 r+ Z8 m# T' a( P' g3 I" t
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 _- N: \; Q' P6 y+ w#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
8 x1 B" ~( s! x. z6 V#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ H. Q# f. ~5 O, K7 f9 w
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" m4 K. x. C! ]. g% X
3 \/ o1 @( y+ R1 O( s/* assign the tl som board LED-GPIOs*/1 C1 z9 | [+ c0 I' V
static const short da850_evm_tl_user_led_pins[] = {
; s8 j5 M9 |: N6 N8 S8 u: _+ `7 S. u /* These pins are definition at <mach/mux.h> file */
* _" h9 q4 {% O1 D P# S% ~( q) H DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 Q6 D/ }, R% `9 j; S
-1
- p+ _5 [4 }7 ]+ K};+ W: o! U7 c9 @8 K6 v3 J
4 G2 K( q6 }( B! k7 b+ b2 Astatic struct gpio_led da850_evm_tl_leds[] = {9 i( |% p4 _, h9 d$ V/ w4 G! B
{
3 m; g/ p1 ` g; P .active_low = 0,+ _+ p {5 t0 ~8 U
.gpio = DA850_USER_LED0,9 o% [ N4 W' o, q; u; Y, s
.name = "user_led0",
- s. b9 m& C y: i' _0 x4 v, q .default_trigger = "default-on",
8 w( N ?8 {1 V" f5 e },. M4 |2 B) n2 M5 o3 A
{
! [: U& C8 {9 o4 F .active_low = 0,6 w0 ` S7 u+ o+ b$ C! I' W
.gpio = DA850_USER_LED1,
) z" g* N/ }7 j$ n: B1 W" y; N .name = "user_led1",
3 j! S. _5 u+ t6 p3 Y$ p+ R .default_trigger = "default-on",
6 J7 r% U" @( ~# N' k v7 F },- X" q; E1 V ~ o, B+ [
{
5 G1 X6 Y% f8 D! u$ Y D3 P# n .active_low = 0,
, Z9 U# a8 F$ K( k" `4 o .gpio = DA850_USER_LED2,7 d% B D5 I" o3 U& O2 ?
.name = "user_led2",; V8 U; Z. \( |: \
.default_trigger = "default-on",
+ Y' M; f% H& A. G },
1 t, \- l1 k3 O W5 T, e+ I {3 N2 A5 z" i/ z2 {/ ^9 B
.active_low = 0,7 b/ @9 }, M# q0 A( j( V/ I/ ?% C# `
.gpio = DA850_USER_LED3,$ z. K$ O6 ~ k: y
.name = "user_led3",
. z, }6 M. F. I% v; M% O1 V' x .default_trigger = "default-on",
' d; N6 v9 H% w- k },9 A/ T9 B) [4 ~# {7 i
};
2 [- N" n0 u' t% A
9 o9 \2 o% ^) _$ D+ c, Astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 s6 F2 _7 a8 y5 I5 Z+ U .leds = da850_evm_tl_leds,( s9 \- Q1 ?* w
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' P8 h) n& f5 a4 V};
; E' _: T1 v3 \) [0 S' q- |" H0 O7 ?9 r- q: H* u# Y b1 U
static void led_dev_release(struct device *dev)% @) D- p& u* i' W- g- Y1 N
{
) ]/ F$ F0 o: I: e};
, D" J- u0 B/ @ @0 ?1 e0 C# V& T+ r9 V! q( \5 d5 z
static struct platform_device da850_evm_tl_leds_device = {
3 u, X. e! k" n, {" W .name = "leds-gpio",2 T* n2 M1 V+ I3 i7 D
.id = 1,' C* T6 |! ~+ {
.dev = {
& h3 r/ L' y5 W! ^. }+ S% Z! Z- _ .platform_data = &da850_evm_tl_leds_pdata,
D' m' \2 l. R9 t .release = led_dev_release,
# L" N) \) \ d# ]8 _4 N' K/ _ }
( b) c9 ~+ q2 _) ^};# ~8 m" A& W y) t
- b3 W# A$ k3 r6 u; O! c
static int __init led_platform_init(void)- [) o5 |1 D" d" c6 D0 S: v
{
0 Z1 H! C6 h5 V' w int ret;& o( f' S% a+ p6 X+ k! J
#if 07 X* `/ X9 ]7 W0 d! v
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, r, M. s9 H) C( f
if (ret)' V( {: I. C/ s+ H5 o& T
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( ^* u5 c! I" q2 u' K! M- O "%d\n", ret);: B6 I3 h8 S! `# |0 t( J S
#endif
8 X% ]& x j& U' o% W# Q" y ret = platform_device_register(&da850_evm_tl_leds_device);0 s) p4 a3 H* h" H- d
if (ret)
' u9 Y+ R& X/ D- d pr_warning("Could not register som GPIO expander LEDS");
& o% v" X% d- {+ {0 {5 \ else
# D0 B" |) \3 t' e printk(KERN_INFO "LED register sucessful!\n");
# V. y! e7 G3 N& `, {! s6 ^7 I* a& R4 @1 j X+ L" D
return ret;
7 M- E. S( o- a}* Q7 Q" X6 H4 M
, O* O" E. b/ Y
static void __exit led_platform_exit(void)7 z- V8 Z& @: Z6 n
{
7 ^' S, _/ ~3 c/ X9 `% a: x platform_device_unregister(&da850_evm_tl_leds_device);
2 ^4 z9 ^ ?- R! U0 ^+ f( n5 b# E1 S* q& M8 t: X3 e0 b
printk(KERN_INFO "LED unregister!\n");. L; Z/ w3 w3 W4 J5 S: c1 E7 x9 u
}
( k6 G, [& _& G# `; C, P5 K* O7 c; `# I' V; c) O
module_init(led_platform_init);, m' \1 ^2 b [3 a6 G
module_exit(led_platform_exit);
2 ]" H) z4 Q/ B" z
* e* w+ w+ R' B! ?2 s7 gMODULE_DESCRIPTION("Led platform driver");) w5 ]/ G& k) ?3 k4 z3 @/ Y
MODULE_AUTHOR("Tronlong");
# i& H0 d7 |- m; r0 U+ y0 nMODULE_LICENSE("GPL");
' C) D7 y Y" O* c! p) D
2 M$ q# D9 j3 g* r0 p |
|