|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 u. z2 o+ g( g3 ?) M#include <linux/init.h>: s( d6 ~' m) `- u3 K) N% z9 ~+ D
#include <linux/module.h>
{2 d4 a" o+ i: H9 t4 J4 p#include <linux/kernel.h>
1 M) P% M+ |7 T3 s: w#include <linux/types.h>
3 l1 W' m$ |- G#include <linux/gpio.h>
! o5 F( S- J& q( Y" r#include <linux/leds.h>! _& A: W% M6 J9 F% N4 | u! l
#include <linux/platform_device.h>3 Q. D% v- I {7 b, Q
0 s. D. _ F7 M' h3 q#include <asm/mach-types.h>! j& |, i3 E3 b, Z- e6 `- X
#include <asm/mach/arch.h>
2 T' @+ U( i% u" \#include <mach/da8xx.h>
) N1 I8 `8 K6 y1 G; v# v#include <mach/mux.h>$ x3 R( j# w0 w0 M
7 q6 [5 p+ J0 s
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& f) B3 V7 p4 e1 y% m1 [. k. x#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 \2 A' t A3 p/ C& p# p% s/ U, o
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 n+ b I1 K3 G* d' v" N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ V# Y+ K4 k. v1 _( Y: [6 x5 F5 @
8 H3 e" T- C! N! }$ m6 h Y. I- ^/* assign the tl som board LED-GPIOs*/
5 s7 o$ ^8 }2 B2 ?3 T' D+ tstatic const short da850_evm_tl_user_led_pins[] = {
9 c. i2 n6 `- E5 P5 b$ X /* These pins are definition at <mach/mux.h> file */
4 Z6 ]6 Z$ s0 U% o0 v) o1 n DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 p* ]2 W, g9 Q& I
-13 i3 X2 e) }4 W) S
};9 i* i0 E5 }& L
& T* G* O7 }# x# W* _7 i% W/ Dstatic struct gpio_led da850_evm_tl_leds[] = {
' `* c4 ?2 Z; `& h" E" P' R/ X5 E% q {
" i" v, t. d; ]- t' g( [1 K .active_low = 0,- Y. \/ x4 n. p1 c2 ^
.gpio = DA850_USER_LED0,
2 L+ {% C9 ~9 b) q/ u: Z .name = "user_led0",
8 B( v* ]1 f4 a; X! n( p .default_trigger = "default-on",
/ j1 s. S8 y1 Q/ \6 G, p3 p },
3 Y/ t( |4 s0 u' b5 Y {
& t& x S7 [- l9 z+ Y! k5 r) f .active_low = 0,
: K8 P0 r- m& t* L n6 P0 W; L5 g- X .gpio = DA850_USER_LED1,
0 Q8 P9 q( D7 @! a5 S .name = "user_led1",
3 }/ n& n9 }! x, v .default_trigger = "default-on",
: g, o. U1 M; A: ?" x1 B$ H }, f7 } J) P( E7 h5 U1 ~2 I
{4 @0 T* `7 t$ U r& d5 u# i1 W* |
.active_low = 0,
L( c' l0 V s- J) s; J6 J .gpio = DA850_USER_LED2,
7 A# c. Q- m) }% Q$ n9 M( S .name = "user_led2",
, @9 X& U) Q9 I1 S8 `" P# m$ |% F .default_trigger = "default-on",# u9 Y: p# b6 h3 `. v. e% H
},
9 v2 v0 O5 h, @" b2 b; n* j' h {/ P" r( ~% k* P5 f- B( N9 P% L
.active_low = 0,
* E1 S4 Y6 w8 E( q4 e .gpio = DA850_USER_LED3,3 t- Z) R; n% ^$ h) z
.name = "user_led3",
1 m& y; Y4 N8 D$ ^) v* i) A .default_trigger = "default-on",% _7 U+ ?" F9 S1 B- f% R
},- a" R5 ]' n1 Z% Q3 L: x/ ~! E
};
- w8 J& m! e9 g
5 i" H- D1 t7 bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 d0 ]) B. p' f, v; w
.leds = da850_evm_tl_leds," P5 V$ R7 L! D0 x5 n
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 j0 Q, @6 J! ~3 Y
};2 y: b% K9 L" U( h4 P3 t
! l6 R1 p7 C& x7 ]. L# Wstatic void led_dev_release(struct device *dev)
j3 X' B9 e+ y{
: E. `8 Z8 e* N. y6 c8 a};
i6 S7 \! P* N7 q1 t7 k, x$ k! M1 N, R4 Z x3 }
static struct platform_device da850_evm_tl_leds_device = {
( _- d4 m, U8 } .name = "leds-gpio",
/ I9 G v0 D) w4 P .id = 1,
# ?* o& Y# G7 K .dev = {
) C, K- S1 ^) L) t, W2 @* k/ D .platform_data = &da850_evm_tl_leds_pdata,
0 P- A1 s$ a% L5 d5 p .release = led_dev_release,4 o0 N& l" ^, n- ]9 ~* j3 G& B
}/ O+ t0 s4 x0 P% K( R# T6 h. G
};
, m) i L! u* S8 d5 t$ Z" @6 S8 F/ c' k: x+ Q) y8 S5 |1 `
static int __init led_platform_init(void)
& F. U; X& N7 W8 [) }{ j9 {* w+ ~0 ?& E, I# T: c
int ret;
! ?0 j5 @ P' Y$ H% N/ G, U#if 0
' I: p% J6 t* F I. n( g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# H; [$ W" M! v$ m if (ret)
" E+ w% A3 C; n* ?" @8 Z8 f* R2 T pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" I. Q* Q7 L2 T3 |/ u
"%d\n", ret);; t( E) n; v) v) j
#endif
1 {# R! G6 D1 y" c+ U, a+ ` ret = platform_device_register(&da850_evm_tl_leds_device);
6 T- l* J8 t7 ~: l3 d: Z) f! l if (ret)
. o! H& @% \2 J! r0 B8 L pr_warning("Could not register som GPIO expander LEDS");/ Z) V' B9 R! l! h5 ]) m, h
else
* e/ E8 Z3 D# n! O* r7 K printk(KERN_INFO "LED register sucessful!\n");
9 N# t" p. k: f+ J9 l& _6 _2 ~0 U, ]) L4 K7 Y) o% G" ^
return ret;5 ^1 x; q- j0 X6 I
}. @4 n! X2 c8 s
% S, @' |0 |! }9 a. Astatic void __exit led_platform_exit(void)
$ a6 l/ Y' [: b3 N; X' S{% X9 V5 @% m1 I- L: w& R# w
platform_device_unregister(&da850_evm_tl_leds_device);8 L/ D; V; { D" S5 W4 U* }" e
5 u/ k4 \+ n, m3 h, f! j. D printk(KERN_INFO "LED unregister!\n");3 l! P7 Y) G2 F: j, c0 q# J4 M i
}
. g/ @: I/ w A, A. S2 k1 c0 t' }8 b* Y/ L" K9 Z
module_init(led_platform_init);
, H$ ]6 F* D9 f5 }) ymodule_exit(led_platform_exit);
* t8 Z/ [& o! p/ p2 J2 T& r6 l% d0 H i/ ]
MODULE_DESCRIPTION("Led platform driver");! [" ]- |. ]. |$ t2 K1 a5 m, m
MODULE_AUTHOR("Tronlong");! v& @- J. B9 r& M2 G( v
MODULE_LICENSE("GPL");2 w1 p5 _7 K$ N& P/ P% L$ h
( `" w* z7 t9 J" m* v. k5 Q! ^
|
|