|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! ^; c5 g- c. \- E% c$ H#include <linux/init.h>
) y6 N2 o. }. f1 K( ^) T: K#include <linux/module.h>
3 S2 Q ?" m/ U9 |6 ^#include <linux/kernel.h>
9 ^1 a5 j5 t5 H( x#include <linux/types.h>
2 w w* X( u/ L% F#include <linux/gpio.h>/ c" e( |, O4 @9 G9 [7 o
#include <linux/leds.h>$ s/ w% g# M5 t# w* p7 X
#include <linux/platform_device.h>
' { s7 A$ P# X( U
% z) t6 Z7 z2 l, \' B ]#include <asm/mach-types.h>
9 g: U! U7 x7 t. B% s' N1 p8 N#include <asm/mach/arch.h>6 g* P$ G; m Y* b; `, x
#include <mach/da8xx.h>
1 }% {/ b/ ~5 @! m7 _8 g#include <mach/mux.h> N$ }2 A- {% _; ?2 f
9 d$ s; F+ {" v: N, |) x
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) K$ k( c/ w, Y. b9 K6 Y6 Z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ F5 f5 H* ^5 H, i( G4 Q6 e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% l9 @ r& n# u3 O+ X#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). P! K( T& r( C2 v* V7 G; n
3 u; X& L. g0 B$ T
/* assign the tl som board LED-GPIOs*/( R: |0 L! o$ q/ c
static const short da850_evm_tl_user_led_pins[] = {
1 N0 f+ q. R9 J& {1 {; _. ` j /* These pins are definition at <mach/mux.h> file */
6 w' a; c+ U1 m, f DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: U$ S l5 K. ^) d: H -1
3 t6 V* T. f. t};3 f- }3 m+ \+ o0 `% ~
" c5 s8 s, |: ?# W! J$ mstatic struct gpio_led da850_evm_tl_leds[] = {1 i; K: j7 d7 R) u' j# Q1 q
{
! Q5 W! ~6 y8 J' z( V8 f .active_low = 0,
1 t' Y, x2 ?. A' P9 w( G) J* D .gpio = DA850_USER_LED0,' P& r/ \: r& n& f. y8 A) p
.name = "user_led0",
, \2 f9 ~& `# @# p .default_trigger = "default-on",
* D8 \& K- l9 b; d9 y& b$ t- G8 d },
4 I7 a) N/ ~- O( h' ~+ @* Z {
1 e: S5 \! R' H; F- d8 `6 } .active_low = 0,
( Y/ m8 c# n, u d% I3 D o, q4 D1 w" [ .gpio = DA850_USER_LED1,
) c& {$ m' J3 U0 E4 }, L$ M O .name = "user_led1",( y8 E. f3 y& }: t( |
.default_trigger = "default-on",+ G9 Z! M; w7 q, i
},8 }/ s8 ^+ w2 I8 |& T$ t T, R
{6 [( ]9 _3 X6 o' G
.active_low = 0,
: _( O, V: C4 S6 Y .gpio = DA850_USER_LED2, q1 _7 S) [- S) d1 D+ q/ S
.name = "user_led2",1 b% \! |: r, w+ P: M; J
.default_trigger = "default-on",
) t" l) O/ J) C( J& d- Y },
' W, z! x' x$ } {
& r/ Q1 {, G7 K0 K( P0 Z9 W .active_low = 0,
4 s8 Q- L: X3 u n, G K2 |+ V .gpio = DA850_USER_LED3,
8 t- m6 W) X. [$ ?, i .name = "user_led3", t3 t0 s. c, F) D' \# `7 a! @9 s
.default_trigger = "default-on",2 q3 y6 M: R0 T
},
. L& W$ {, i8 b# C% u: W. P};8 O/ g5 v/ T: P0 n3 U, G5 ?6 I9 ]
0 }( j0 W9 Z" ?$ Y, F: P- Z* Zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. `$ O+ c& F, w4 i
.leds = da850_evm_tl_leds,
9 s/ i3 `3 R: n1 b .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. k( K$ F% h, X5 X3 }2 ~( _};
8 U* X4 Z; W7 X3 r# K5 D. @& r& q+ o
static void led_dev_release(struct device *dev)
* O" c+ D" q5 u# Q3 E{
$ [: Q" a. L7 d};2 m- L, O. h* x5 x& G
( i& e- }6 ~# G
static struct platform_device da850_evm_tl_leds_device = {0 o4 e. u0 |) V% a: y
.name = "leds-gpio",
, P; a% D/ p2 @/ g v# d( N .id = 1,
( F* W6 h; h' y( i( b .dev = {
7 f( t- ]6 @( p6 f .platform_data = &da850_evm_tl_leds_pdata,
3 t- R$ f, Y6 L- T \ .release = led_dev_release,. g( [; _/ B4 I( T6 r' x; W
}! x/ K. U4 p' }( x: N* K9 ]5 y( u
};2 K6 B# M. m! H, {: ^' P, n, N: z5 o
]" }& t. D0 V) B% o, Fstatic int __init led_platform_init(void)
+ P7 U8 P( g" J{5 x# F7 \ `, d
int ret;
; u2 r8 _1 ^, a#if 0( `/ ]5 f- Y& }' c! a
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, z; o- m9 j( E7 X" q if (ret)
; I) l# Q+ y& O6 D0 L1 a6 Z: \ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
8 @8 I; q1 h. _4 u+ i "%d\n", ret);
% y9 U5 r1 n5 d! s0 H* k#endif! u& V& H5 v+ f
ret = platform_device_register(&da850_evm_tl_leds_device);
6 C M: N6 q x# P$ a if (ret)
* ]7 I( j5 C, m: ~3 a2 C4 c0 c pr_warning("Could not register som GPIO expander LEDS");3 R8 H9 ]1 p2 d2 U) l
else5 k/ W! q( @ u
printk(KERN_INFO "LED register sucessful!\n");! Q3 W) c3 X. p3 T' [: C2 x2 v
( [5 |; g: B* c9 O" C/ c @" s
return ret;! f" z1 Y9 Z! a) B5 v& @
}6 C) Q; I- Y! Y* \, j$ \
4 h8 u) B: \( Rstatic void __exit led_platform_exit(void)
' Z% K8 S; X' @! c. F/ a, y6 ^{ o* S& m/ I. Q: U! t) b6 Z( m# N; Y
platform_device_unregister(&da850_evm_tl_leds_device);
" g+ v# ]9 r2 D5 j7 j0 X# W( L' m, [6 e! I5 b1 z. z- e
printk(KERN_INFO "LED unregister!\n");. G8 q+ I$ M8 C
} O6 C; {5 C+ U6 J: k; B' I( E
) c% @# a+ P8 y; {/ m) `; \6 U
module_init(led_platform_init);
9 {; Q& p' S G6 gmodule_exit(led_platform_exit);$ g" E) V9 ?/ m
- O8 r% U/ d! [; A# F: G! n
MODULE_DESCRIPTION("Led platform driver");
. x; E; u& F$ _' UMODULE_AUTHOR("Tronlong");3 l- G; M. k, y* s" m1 u9 H, h
MODULE_LICENSE("GPL");3 a) j3 l' b4 p0 O5 C
& S7 J5 P% |% A5 H; ^1 \0 X; Z3 v |
|