|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: }" [; C( A8 ~9 m' L9 i1 V) h+ N
#include <linux/init.h>
* u3 e" m# ?) [" u#include <linux/module.h>. g9 e9 @" j/ l+ m8 U5 p7 e* ~
#include <linux/kernel.h>) z/ T" C- E' D5 z: x$ q2 r
#include <linux/types.h>
/ A. Q) I0 C3 m#include <linux/gpio.h>
3 _6 n1 l5 b1 w4 ]0 N( v' W4 i. \#include <linux/leds.h>) w& |5 `/ @! M5 k! E
#include <linux/platform_device.h>4 q! I; ?! Y& ?6 a9 v
: Q( Q, D8 w& l `. b8 Y/ ~4 a) W#include <asm/mach-types.h>
1 r l5 L4 e& {' W: u#include <asm/mach/arch.h>
9 g4 v# O4 }0 g# f; T ^" l& ]#include <mach/da8xx.h>
7 \4 V6 h: e0 j#include <mach/mux.h>
% s) i0 G. \/ s: J% y: e
# T3 b7 E+ S {1 f. b6 J7 G4 k#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 t1 T* v/ b2 R; c& s+ H1 A. s- m: k
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). R s6 n' q5 L! i8 t ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 p5 l. Z b) s; ?0 a! S5 W#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
R8 J1 a6 D+ K' L; n7 a+ _ t* F. _* a" v6 Y* v- _( O: k& g
/* assign the tl som board LED-GPIOs*/
. z& t8 }# T2 Z, {1 R6 p* Gstatic const short da850_evm_tl_user_led_pins[] = {8 G+ E0 G9 o3 E& ?
/* These pins are definition at <mach/mux.h> file */9 [! d% S/ K$ w# j) f. [1 [
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 a% J4 n9 n2 j -1
9 [* A( b+ j+ A; U* |5 p};
& H" C: s- e6 a3 a% {/ p! G
# ~$ j8 A1 p; Ystatic struct gpio_led da850_evm_tl_leds[] = {7 `' B) e V+ A: u3 U
{
8 a9 \: e2 r c$ { .active_low = 0,
/ D4 K6 {* V( W5 n0 ~/ v .gpio = DA850_USER_LED0,' _& w! i& p2 K+ p* m+ @1 ~. P
.name = "user_led0",* v1 k9 ?; v* z7 u. _! E
.default_trigger = "default-on",
. V# C9 y- ~7 {# { O$ C },* u; T" h0 v, I) c
{
- O l9 ]" F+ ?$ ? .active_low = 0,: {% \; a* Y4 P+ a
.gpio = DA850_USER_LED1,; ]- d: Z# U9 H+ a
.name = "user_led1",
1 u1 ?- ?5 s, e .default_trigger = "default-on",+ _* {' [' P `2 _
},
/ [( d3 n. x0 v9 c {6 o/ @8 J! h, z1 \4 e1 v! O
.active_low = 0,3 T3 h" z2 ^) |" A) U" E8 M- i
.gpio = DA850_USER_LED2,6 {' u4 G8 }0 b0 a+ Q6 j* ]1 _
.name = "user_led2",( F9 E q1 M7 s( q4 p# q
.default_trigger = "default-on",. w A" x7 a# T! V5 |
},( a+ }1 Q ?3 M G8 q# a) s
{2 x3 q; f1 A5 g9 j
.active_low = 0,% O6 P, ]2 K: r4 [; K+ N5 M* R
.gpio = DA850_USER_LED3,
; n; \! y8 y" C+ i; W$ d% `6 g .name = "user_led3",- e. S! Q u& [6 S( {
.default_trigger = "default-on",
, O* o/ v8 E0 }- e* } },
7 b" s& ]0 y! P, y0 }};
; C: T9 J0 p! U; R6 o9 l- g
8 N+ X3 e# j# Q& A% Z& i: }; n$ ]static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% A) B2 h1 X; @, h4 g .leds = da850_evm_tl_leds,
3 W7 s6 t i6 X5 @ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),- n: ]& ?8 W: s% W8 {1 T: n' y: o2 X
};
. o( k# F; X/ ~! Q- Q7 I
1 d, R8 H/ ` J; G$ |& @2 Ustatic void led_dev_release(struct device *dev)
! e2 D2 x% N. n9 I a{& i) v0 q% j; Z" K* k, F4 F
};
# p) k; e' b# M8 |5 g$ ^3 |) M0 \, J' y; w5 w
static struct platform_device da850_evm_tl_leds_device = {
: C. F3 {0 i2 L( J2 l% x$ ~ .name = "leds-gpio",! x% d/ H: L! e `
.id = 1,4 G' h) ]9 c1 H% j
.dev = {
* G! p& {6 R6 U; U* ]+ T) x .platform_data = &da850_evm_tl_leds_pdata,
0 |% e( ^" y: U1 D' T .release = led_dev_release,
: S. R7 ^+ _6 C# M2 s& Z }
% g) {1 z/ H* e$ M7 p( L+ w};! G4 p q: N2 X2 e; W
% e# o; U3 S* s; w: ostatic int __init led_platform_init(void), n; e% M% t, H; e0 J) |: g- C, v
{% K. V! u* c a$ T" w, {9 ?
int ret; m7 Q/ w3 S0 g7 Q
#if 0+ N. j& s* \; S. V- x4 K
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
" D, Z b3 c' t$ L3 o if (ret)
& E, ?3 O7 O% B: N0 E+ ] pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 b. D! e- n5 {5 w4 ~1 C# M
"%d\n", ret);
1 A9 Z" W9 R! G2 x#endif
. z, O0 K9 W! D/ q h ret = platform_device_register(&da850_evm_tl_leds_device);
- @( x% O& E# G1 j% } if (ret)4 r v( P0 o5 H
pr_warning("Could not register som GPIO expander LEDS");" K. x# V. [. ?
else: N$ }! l. T1 x' J
printk(KERN_INFO "LED register sucessful!\n");
. l4 Y/ a7 Y1 j7 @/ q; p& t: n2 ~: x8 {1 @- {# c! F6 c ?
return ret;
- M: V2 i/ C2 i# Y- Z}
5 D% O( Q/ C2 u. w; c# s) T9 P# k* U; d: o5 R
static void __exit led_platform_exit(void)
& M! e. ~6 D) a6 X{ s) P$ A' _3 b8 B. l
platform_device_unregister(&da850_evm_tl_leds_device);
7 Z+ |6 W G2 e, y; r# [, F
- `2 s. s- d' W5 m+ Z3 _9 e) T# { printk(KERN_INFO "LED unregister!\n");4 _. W; s* b1 T+ n5 h% h$ D* m, T
}
`& F- x: I5 Y2 S' P* L N& r- Y9 }6 ? e" a# e( i
module_init(led_platform_init);: j0 e# g- g: D4 R S4 X
module_exit(led_platform_exit);! b* c- d' _( j7 l6 o. @! v- B
y9 k) S: z! p& f' T
MODULE_DESCRIPTION("Led platform driver");5 g; m, W% U* P1 o& @: f! _3 R
MODULE_AUTHOR("Tronlong");: u# m0 Z- y; V, P: u& ~4 O
MODULE_LICENSE("GPL");
3 q ~. g2 M4 g( b J# ~8 J& W' C! @: y! w2 \
|
|