|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& @, y% }2 x- U4 t" q
#include <linux/init.h>& O$ J: m& a! X5 k: K6 p5 E$ o* ]
#include <linux/module.h>
% a$ a* W. @" l4 h2 K#include <linux/kernel.h>
' M* y+ Y8 N) F! L$ Z! w#include <linux/types.h>5 u2 c }4 X$ I( L
#include <linux/gpio.h>
4 F/ v+ }; J" B! P#include <linux/leds.h>' S; N# f0 w6 N3 r$ H0 h
#include <linux/platform_device.h>, m3 C f* _' B! M3 e% Y6 E
2 ^- F) H# v+ _1 a. m
#include <asm/mach-types.h>; \, | B9 x9 i0 ~
#include <asm/mach/arch.h>& A$ B7 H4 ] E* {0 l
#include <mach/da8xx.h>
1 F. d, G- Z B) A, l#include <mach/mux.h>, R- M/ G% ^ h
0 ~% T( i6 r3 y/ p A# Z6 }#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* W( @3 `# w5 o" k2 h- K& c
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 m$ ^% R; z4 m. O& `
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% R7 H( `; t9 g! Z5 D% I* n; Q; O5 a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' V: y( j! u/ [' l/ S5 f
# X: n, [( @& {# h/* assign the tl som board LED-GPIOs*/
0 X/ [3 i! e2 ?static const short da850_evm_tl_user_led_pins[] = {
) J7 \& R; C' I$ H /* These pins are definition at <mach/mux.h> file */
& @: l W9 s) V+ `3 {' C5 B DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. c7 Y! c8 g2 o1 J2 V7 L. Q# i. ]& D+ s
-1- ?: r6 t- r+ ?7 K4 X
};
" F5 P2 W7 T! @* {5 _- P
8 b5 ]/ s$ o1 ?) tstatic struct gpio_led da850_evm_tl_leds[] = {; R# M: u- } r* U
{
: c, g. G7 C) o/ u7 z$ R; Q! b8 P .active_low = 0,
/ |1 m- n! P7 W! D7 W2 j: y .gpio = DA850_USER_LED0,: n: {/ }* N1 i; k5 O! h
.name = "user_led0",
9 N t6 e: ~; i& C! M5 o6 z# \ G .default_trigger = "default-on",
|! u- L1 ?% \ i/ X7 z+ j% I" [ },
9 N- N3 K; M4 q3 r; d$ ]" `' |% ` {! s Y; [4 q9 E; M
.active_low = 0,
: L4 y {* ^1 d* ^& e7 T& C .gpio = DA850_USER_LED1,% W/ A0 w3 o$ }$ P( c4 F
.name = "user_led1",& J! ^& c( i2 B" z* k
.default_trigger = "default-on",7 W0 ~7 B; c1 f7 D, |5 } T
},
# F! n7 |% T- ~- z8 G8 g {+ N: U& o. ?7 F# B
.active_low = 0,
( `! s9 r( `; X .gpio = DA850_USER_LED2,
" Y7 `, Y" O# D+ r, f- Q9 Z6 r .name = "user_led2",
1 I% S3 D6 e3 X% `6 T C4 T1 S$ l .default_trigger = "default-on",/ c) U1 G; n( ^; q: \
},* _4 p; f/ r8 s& S' j
{
' E/ W: d8 }, M) l .active_low = 0,
' c; Z$ ^" p9 ]" O# E) y0 `' u .gpio = DA850_USER_LED3,1 Q; z1 Y& Z: a- O
.name = "user_led3",
2 C( ~% l+ N5 p8 u% F+ `% h+ R' |3 T .default_trigger = "default-on",
2 i8 | i2 X0 H4 Y7 u },# l/ ^% a$ }) Y% V& L# D
};1 @( x9 C- s- a) v' T3 O& d+ O
+ F x4 X y: |' M$ O; ?
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ e8 K5 T7 g$ b4 O6 b- X: a; A% Z .leds = da850_evm_tl_leds,
9 Z* A. r* n* ^, U .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, N; ]7 g7 X- _4 j& S4 t$ i
};
q$ n6 ~8 n% Q6 a" o5 o
1 A1 d% e/ o7 d4 X: Jstatic void led_dev_release(struct device *dev)1 N, Y/ t1 f3 c" \+ R
{9 u) Q$ P) D' _4 b
};5 E/ r1 w0 x0 @! {" w
7 K: L8 i, a; v5 sstatic struct platform_device da850_evm_tl_leds_device = {$ ]/ V5 k5 b% t( Z2 a- S' g Z
.name = "leds-gpio",$ }7 L2 S5 u# U2 j/ h2 ^% Z
.id = 1,9 k+ d) @, Z2 m& Z
.dev = {( u$ t. C" B9 `
.platform_data = &da850_evm_tl_leds_pdata,0 z; q1 {" C1 j$ H" u* c: I
.release = led_dev_release,
6 O# B- e# ? |" R }
. L( G8 c4 W, l _( o};6 j* h; ^/ B' o/ T
, f0 i* N* V; i- h- C/ I4 U/ _static int __init led_platform_init(void)( }% K( h% N5 v: |
{7 O/ }6 G9 L; J" ]! p/ s' I
int ret;
0 b/ u x2 ]/ T; Z* N3 o#if 0. d6 w/ U5 z9 K7 s4 `' f
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- {0 {3 I7 z% M! J if (ret)
2 k2 c0 h% t& G# Z) W pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) ^& q# W) O; u$ d" y "%d\n", ret);+ }, r5 V2 R1 f9 |5 S: |2 g
#endif
. ?- R; @" ]% T9 u ret = platform_device_register(&da850_evm_tl_leds_device);
' n8 ^8 O* h- E if (ret)
. i0 B- [8 O$ m pr_warning("Could not register som GPIO expander LEDS");, b: T* I7 W# i2 n$ l) `5 Q% o% S
else
1 A8 D' J% N% l' _ k printk(KERN_INFO "LED register sucessful!\n");- X% K7 z. B! W0 m6 n) a
: i; {7 i, S& ~4 [9 A
return ret;0 r8 V) I7 `# e! B! y
} V- g& z W1 ~9 S6 M
V: i' y& o q, l/ O, F1 e
static void __exit led_platform_exit(void)
: @' h2 }; K3 L1 \0 J) ?& ]{
( o1 _" B U) R$ q6 ]# I; o platform_device_unregister(&da850_evm_tl_leds_device);0 {, A9 G& K* t0 y
& b) ?# s+ S3 Z' ^) ` printk(KERN_INFO "LED unregister!\n");( v; n+ f0 Q3 p ~* \7 t3 X
}) o- V1 R6 A1 D- j2 o, R
3 \1 y" w/ r1 ^* B; W* f0 I& p! _module_init(led_platform_init);5 f$ l6 N T( W) g
module_exit(led_platform_exit);4 e8 s# o! l* C5 n& T
- R7 d) u7 U( |7 R+ dMODULE_DESCRIPTION("Led platform driver");1 v! a: k0 i" H/ E* E, l, F5 t) Y
MODULE_AUTHOR("Tronlong");
L/ h* F3 [# f" A# c8 u, J! I: CMODULE_LICENSE("GPL");
4 i) k7 \( k9 i9 \) ~
% Q( D: X+ K" E# M$ x! L8 T0 z |
|