|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& U3 D/ D7 z( `3 B( p9 u4 L6 j#include <linux/init.h>
% }5 q$ n4 @9 k0 L# v" M' o3 l#include <linux/module.h>5 H3 l& Q$ S, r6 p4 o# D: c" U, I
#include <linux/kernel.h># v- ^) \3 i$ Y7 \1 R
#include <linux/types.h>6 O$ |0 f# b& g# K$ q" i
#include <linux/gpio.h>
2 s- N9 I% a. n$ _#include <linux/leds.h>3 i) w E0 W3 s. e$ O; T9 P0 D
#include <linux/platform_device.h>
6 W' f2 v0 {6 e
$ Q" F8 ]; n# _+ u+ E& U: n#include <asm/mach-types.h>
3 A' K. V, U2 [* S( }#include <asm/mach/arch.h>
$ [ c4 Z0 M P. G/ Q3 [. ?#include <mach/da8xx.h>
: R j: h; }' d( ^#include <mach/mux.h>) @6 i6 ~% R) n7 U h
4 U7 L7 ^- o& Q8 T#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 \( G& e# x8 d
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 y; y. s4 H) z. c( g
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( \! C, x- V8 c( ]; Z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ h% h5 z8 t3 r2 y- f' N D0 a' }
/* assign the tl som board LED-GPIOs*/
, R/ u* \. g) N+ O8 {' ^static const short da850_evm_tl_user_led_pins[] = {
2 ]& ~- B9 N4 q1 X9 Z; L /* These pins are definition at <mach/mux.h> file */
/ k- T0 M4 n* v DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 {# ^- r( I+ `' ? P: F -10 H, {. K: }5 { r" u
};
4 v' b, x: q+ L% { A' Y
: b/ w& b3 O t" nstatic struct gpio_led da850_evm_tl_leds[] = {& C' ^- P- K% x% |2 a6 Y; }
{
; W* Z; P, I. `4 j .active_low = 0,- u& A1 J" I4 Y6 {( R4 c* X
.gpio = DA850_USER_LED0,) E0 K- {" @& g7 O' [
.name = "user_led0",
% K( S8 K+ w$ G! w5 z4 B' O/ g .default_trigger = "default-on",. D% L: e2 N: ^/ F" x
},
5 o H5 O c/ P/ p {
, u& n; ^, g; k6 {! ~0 B" h .active_low = 0,
( R$ f( D) h# K& z .gpio = DA850_USER_LED1,* P& s$ s: ?7 z- K4 N4 d Q u
.name = "user_led1",
1 I A5 A% ]" ^2 }/ s .default_trigger = "default-on",
2 q1 Z, A9 u9 ? y },
0 y6 q* H8 l9 P {
( c1 k' L4 M M$ K7 ` .active_low = 0,2 I! X+ D4 ]# w* ?
.gpio = DA850_USER_LED2,
* g. {0 k3 G) { .name = "user_led2",6 r9 S$ K2 X& j5 K* ]
.default_trigger = "default-on",
: H) E) G* U' b% ^/ y0 i; O },0 g7 B. s) T: Y% Y* L. C0 i/ N* o
{
8 Z& T9 k: V# c& E' c) d- R/ o3 Y, f .active_low = 0,4 ]3 `5 n0 A B ]3 f1 ]
.gpio = DA850_USER_LED3,; D8 V! f( i' {+ O
.name = "user_led3", A* g( P7 z8 L1 Y* Q0 L, M
.default_trigger = "default-on",8 s& w' J$ B# H4 {' @$ s
},
& q+ J1 D( D/ ?, U. R+ o8 i% c};
; V7 Z$ c+ d8 O/ k+ _- ^5 l
( ~/ S) \! ]8 O8 v5 tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 b0 ^" `3 E* N .leds = da850_evm_tl_leds,
, M @ r3 ]" \5 C. ` .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* H5 T; |5 i0 C}; d: c$ U! N4 A8 Y2 ^" ~
6 u3 x' k) M; b' O5 ostatic void led_dev_release(struct device *dev)0 p9 p' P) h q7 Z! B
{
$ k% d6 v$ G, t1 g};8 R6 l- U2 `& ~/ B. Y1 z
) H( j2 y7 `: O0 [, t4 Jstatic struct platform_device da850_evm_tl_leds_device = {- @. m4 @" E% X3 ~
.name = "leds-gpio",
- h9 `4 s! }# ?! p .id = 1,
# l+ ^1 @( q& \2 g% c3 ?. t# @ .dev = {( r. o; ~, o' X8 E
.platform_data = &da850_evm_tl_leds_pdata,. b! s7 K7 [& H) y: r l+ E1 h
.release = led_dev_release,: t6 U5 l* x) z! \2 v9 j
}
, `0 I7 ^. m1 y};6 i9 c! I% E% y, g
- P7 r3 R/ I0 q! N( `" @2 W
static int __init led_platform_init(void)2 e3 U2 F$ m+ d+ Q# ~
{
7 |/ }0 H7 k7 P) E/ B9 Q. i int ret;
. F. O4 J7 t4 b; B1 T#if 0 O$ C" H$ z' G: _# V4 Z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; @5 X/ J2 Y ^& F4 L- }
if (ret)
' d( H0 K. E, k' d9 c2 w3 t& H: E pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. E8 g9 j4 ~) n! i U5 U9 M "%d\n", ret);
* w4 |9 V8 r) O/ ~+ u#endif
, Y2 d8 v5 |. ]1 X) c9 K. _4 A ret = platform_device_register(&da850_evm_tl_leds_device);
4 }; t# N0 {7 y" f; N! v! z( ] if (ret)7 d) s) C4 _9 q) v- Y
pr_warning("Could not register som GPIO expander LEDS");4 o) h6 H2 ?! m5 f5 u1 m6 C$ n
else
1 h& I: G4 z" C; \% G( U1 W printk(KERN_INFO "LED register sucessful!\n");; {4 G. r& D( q/ A5 \2 c: s; Q
8 P2 Q+ {5 P! B! @% m: r; s$ C
return ret;
) k+ E j1 I5 B. M2 y; b}! T' V3 {# s0 ^3 N
# B' H" I ^0 I0 |( ?" rstatic void __exit led_platform_exit(void)
$ \1 P, |2 N5 K# }9 g. e{
. |7 u* G. A% c: e4 G" a platform_device_unregister(&da850_evm_tl_leds_device);
+ [, i {3 n: D2 `
8 l! t+ O" l9 l) i) K printk(KERN_INFO "LED unregister!\n");- d, g; e8 h& U* }
}
. y+ C' T# h. [0 @: U" P9 D, j. `) ]0 T) h7 s
module_init(led_platform_init);, G- @; B4 x1 ~& D1 Y0 g; y# x; M( L8 n
module_exit(led_platform_exit);& B6 Y- ~1 [6 I# ]- c
3 }* m: X* _. e; H/ ~" S: WMODULE_DESCRIPTION("Led platform driver");, j4 p0 ]: _+ W% T% }* Y9 M$ H
MODULE_AUTHOR("Tronlong");# L. ]( P7 a% s, H; [, d
MODULE_LICENSE("GPL");
) \. w, E3 Q' q8 j7 M1 B
0 l1 b# k' R" T" f |
|