|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ u2 F' j1 U; j9 H {+ t: n3 d7 m
#include <linux/init.h>
4 w" L5 ~% |" f$ ]' m( R! v! B#include <linux/module.h>
8 E- C: F2 [7 l% |( B#include <linux/kernel.h>
/ W; @* w1 L" u8 Z$ H. o/ J: V#include <linux/types.h>
% h0 v* L! ^; d+ K& ]#include <linux/gpio.h>
" L4 ?+ z- o2 \( s- N& C/ x#include <linux/leds.h>
9 g6 ~- B' I# O C: q. ~#include <linux/platform_device.h>
$ }- `9 \: p/ z6 j. _$ h" g8 }9 p, ]- q0 X7 s+ x9 L1 i
#include <asm/mach-types.h>" y$ a" ?% B u
#include <asm/mach/arch.h>1 V/ j5 X+ Y4 W$ ^3 G1 A1 m
#include <mach/da8xx.h>8 e6 i- U7 K" C. q
#include <mach/mux.h>
3 H7 N I7 X! @+ \$ s9 E$ p& P: e, o# W
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% j: h+ F$ e" s! a. k% F2 y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ c4 c. e! w% H7 s#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 g: i$ @. X; }% i/ i. i7 K#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& E$ G/ C: t0 V
+ w; a+ {$ o w/* assign the tl som board LED-GPIOs*/( j" ?+ r$ K5 r0 n# G
static const short da850_evm_tl_user_led_pins[] = {
9 I) }5 C# |0 m8 V /* These pins are definition at <mach/mux.h> file */
4 W- T& M4 `" d) P( X DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 c1 e4 }' }7 F8 }( H* A; l% L -1# l( {, p7 u. c' I" N
};
) |6 g3 F1 o% g- y0 X0 X7 d" h+ _" g7 b' O0 m" B0 t
static struct gpio_led da850_evm_tl_leds[] = {6 r5 N$ E/ Y3 [! a0 |
{
. s; U- L/ [4 v1 ` .active_low = 0,1 j v# _' j! u. M
.gpio = DA850_USER_LED0,
) |0 b4 E0 U3 d9 Y1 T, ^5 N .name = "user_led0",+ x* [! d$ X6 B3 ?$ [
.default_trigger = "default-on",
1 Q# ]5 d& v- k },
* t9 C+ {' T: O8 ^2 t$ V {
+ s) e ]2 @* i9 L) |/ q .active_low = 0,; J# h0 t4 x1 [/ j8 j% ?
.gpio = DA850_USER_LED1,
* f; ]3 d% J* W( F5 d- m5 i0 } } .name = "user_led1",/ m! J4 [0 [! L; h1 a( P
.default_trigger = "default-on",
' t" i2 d- U9 _/ ?0 C },
* q9 X! O# f: c! k' X {
3 L# ]9 Z3 |) P: Y4 W% I .active_low = 0,
7 _2 J. A& E- t% j$ f: c .gpio = DA850_USER_LED2,$ Z& X& J9 v* _4 J
.name = "user_led2",$ a; {+ t6 n: j# p
.default_trigger = "default-on",5 Y9 R( J' g; M
}," t# R x2 l! p' I4 c2 n4 O
{
/ ~( E" W" i7 s8 W' L/ b .active_low = 0,
2 N, J' K% k4 z# Q' h7 Y .gpio = DA850_USER_LED3,
; ^& {1 K5 R/ y9 G2 T J2 ?* u% I! { .name = "user_led3",
8 B8 N6 I& N- _9 j) G+ k .default_trigger = "default-on",
1 x% M+ P7 O/ c8 q9 ? },
& o) X+ P, l" [0 ?% ~4 N5 l+ E) w};% T+ ]4 e6 w: [4 C7 E
4 x* _, C) { d& R7 T5 ~static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; A5 E" P$ ~9 T$ V# o7 r
.leds = da850_evm_tl_leds,1 J. r: p0 r; F
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- S5 d: X: w2 J- e6 j) K9 p! ?};2 [1 G7 I% k4 u9 K2 |1 h
" l6 I' S3 K8 a# kstatic void led_dev_release(struct device *dev)9 n5 S! G3 e9 n8 J
{
& [; s* p3 q; k9 @5 {' m" e};
' B5 |- a" |/ E% h- r1 E0 u% r7 F9 _4 R! {1 @3 a
static struct platform_device da850_evm_tl_leds_device = {
3 \% w1 q5 O% `, N! v9 d .name = "leds-gpio",
- W3 }8 }0 \- q) ^0 Y/ Y3 x( m .id = 1,
' w4 ?& L+ z7 D F' ~ .dev = {
1 j$ Y/ j& i& r% ]- i8 K) b6 } .platform_data = &da850_evm_tl_leds_pdata,0 @$ t+ @: g0 }. a
.release = led_dev_release, s8 p$ [0 K6 [- e+ [
}
9 ^4 F1 ?! p; B. G2 [};
* }$ n" f$ N, \# I0 t8 h& Q# v" o1 h- [" ^2 {) U4 x8 L, ^
static int __init led_platform_init(void)
; ?& ?5 t* D' Z2 G{
$ ^1 ]/ |" N/ u( N5 U% Z% ` int ret;: r7 g; t2 D6 B; k f6 W
#if 08 I2 [# y6 L$ L! ]6 j4 ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ t/ L7 O: \+ X" f) M if (ret)+ |3 L8 S- s- L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' I, z" w0 ]0 M& t& Z( x. F
"%d\n", ret);, N# c: Q1 h; f a; X
#endif
* s5 G H- M: q) s ret = platform_device_register(&da850_evm_tl_leds_device);1 d/ Q7 q: ~: G2 \5 E8 r' m
if (ret)
) r- j& L; ^1 o# k pr_warning("Could not register som GPIO expander LEDS");
" I. q" y! |- e& j5 d( Y6 D else' n, E0 X" q# g% {
printk(KERN_INFO "LED register sucessful!\n");
6 ? k6 N( x. `7 }. R: ?( H$ P! M! n K9 W/ J& d& k
return ret;* v# ?) n/ d: I( O9 F, I
}9 v) ~5 ~5 ]# m$ A& R3 G5 x
& m; [3 r) r7 O& l0 w+ [8 Z
static void __exit led_platform_exit(void)& \ T4 c& N% M7 u/ W% {/ T; {! f
{
9 y9 w% ^$ {& | A! \ platform_device_unregister(&da850_evm_tl_leds_device);
z( k8 N) w# V+ |/ V4 m( L' j6 o
0 J, [5 j' b( L+ B" ^, R7 w printk(KERN_INFO "LED unregister!\n");/ N/ \8 t1 M" R' h/ ?- N( \
}
+ K# y+ Y: R* s. E9 {/ T
$ M4 M6 F9 L% X' ]6 xmodule_init(led_platform_init);& C* G$ X c. S" V' {
module_exit(led_platform_exit);& J5 z# _9 E* {0 G' {
2 B. N$ _9 f* N9 Z4 J
MODULE_DESCRIPTION("Led platform driver");; {; `/ r3 j) q; t! l
MODULE_AUTHOR("Tronlong");
r. X9 s) n0 {, R* `MODULE_LICENSE("GPL");. P0 O0 A, t- Y4 J! t6 s, w6 f8 s
- a# j& k$ I& X
|
|