|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# ~, ?: V, H* r b5 \# g
#include <linux/init.h>
* z9 w# W$ x6 _, s+ V#include <linux/module.h>; I& r( B) O: h
#include <linux/kernel.h>
/ `1 U2 b' Y' z8 ]7 j+ T#include <linux/types.h>
/ o% ] R2 Z3 Z4 i, p3 a#include <linux/gpio.h>
+ |+ z7 w) }; @' C6 l, R#include <linux/leds.h>3 \9 Y8 `. f; i8 R1 A
#include <linux/platform_device.h>% C" Y' A- r8 L# j8 L
5 \& f L$ R) S
#include <asm/mach-types.h>; b, ?* y, Z9 w/ O( V& H: I7 ^: `; s
#include <asm/mach/arch.h>
' f/ ]4 @+ A: t% G1 b" S#include <mach/da8xx.h>7 _0 U/ Z) J9 ^5 D' M2 Q5 X
#include <mach/mux.h>
E; ~( G# E1 a
- J' g7 y: N- b6 @# P. L* C' [' T#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# }8 b" ~' ^2 W' ~3 _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 ~- H& f6 {+ c
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- l$ [+ p+ p3 o* X1 T7 f5 b
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ o( f2 D( m" D
' z+ l$ o% s, X2 l5 T
/* assign the tl som board LED-GPIOs*/
- X- J/ f) d3 H$ W7 p4 bstatic const short da850_evm_tl_user_led_pins[] = {
. I/ `. p1 J5 L# L+ o /* These pins are definition at <mach/mux.h> file */; L/ ~# J/ k$ d& g4 n% q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 S) R* l6 i$ B' r
-14 J% f- L# a2 J4 y! y2 J
};$ V0 \: U, s9 s& O
4 N) D+ `/ l' h5 V, `static struct gpio_led da850_evm_tl_leds[] = {
7 f+ \( v' f+ G: D5 ?, m# ~ {" }* t5 \, `4 C; [5 _5 P* C3 @
.active_low = 0,( L2 p) |7 M- L! O" |& R
.gpio = DA850_USER_LED0,4 S4 T9 s: W7 l( @( {
.name = "user_led0",& U. ^8 y# g5 s$ @! V; A6 g
.default_trigger = "default-on",
; `% Q7 S( t) i2 L; @ W7 U },
% A0 C" q7 Z3 U; Y* a- s3 X! d {
. t+ t' s( ?: F$ x5 `) K/ R .active_low = 0,
! X0 h7 U" `4 X3 P$ h" A6 [/ z P .gpio = DA850_USER_LED1,% B* _6 o/ K+ V1 r
.name = "user_led1",
' n% U9 O0 W& l3 ^8 ^2 c8 N .default_trigger = "default-on",: m( G9 m# _; e& G2 E) Q
}, ^8 p3 S. a8 S# ^0 o2 Z& L, U
{. R% D$ l" X& c5 ?7 V0 j& o: U8 \ V
.active_low = 0,
) P& n! N# m3 ~ .gpio = DA850_USER_LED2,( ~8 d- z! c& g$ K& Q% |
.name = "user_led2",
' A! W' ~5 S& ` .default_trigger = "default-on",
4 ~, o1 x1 [; V5 Y6 G1 @! x3 T0 z },
7 B8 P) ~* H ~6 K5 `+ J& w {
5 S* @6 ]" P4 h! h5 s& P .active_low = 0,
' X! z. P8 F/ I" U .gpio = DA850_USER_LED3,! Z1 k) D0 K* n5 b
.name = "user_led3",
9 Q* C- w1 @! |3 P .default_trigger = "default-on",) o7 M/ k" Q% R- Z( M% E
},
3 Z6 p+ M8 N: w5 {- K};
& L0 O' d8 T$ g* O/ a. h3 y
& s E1 ^* @# o. N3 Zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, e" _7 D$ c3 v .leds = da850_evm_tl_leds, J& e7 a& a: u$ c6 @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds), b- R* m$ x% ]
};
) q; m+ L8 [1 I1 V; a4 @
% A+ j1 ]- y) D L+ X) V) U% ?7 Rstatic void led_dev_release(struct device *dev)
" N" ?4 \- d9 M/ p W6 m9 _6 g{2 C; l% ^! p( f& }
};" g) A% Y. k. Z
, ~( K! F1 r- o+ v7 i/ r- G
static struct platform_device da850_evm_tl_leds_device = {; R8 R. n3 V$ n* _
.name = "leds-gpio",$ \! l v7 o* F5 G0 E1 V1 Z
.id = 1,
9 n! h' q% W, W+ K! Y, y .dev = {
6 U% f' ~, T5 K/ h9 b .platform_data = &da850_evm_tl_leds_pdata,
/ I2 U( d& m: d3 Z- M6 O .release = led_dev_release," R. n N# g! }( K3 \
}4 m+ p1 h* w& B
};8 E( C2 w3 X. ~ i/ g
1 L8 G) A/ m7 D' k ]' P; O: Lstatic int __init led_platform_init(void)( J7 B6 d# A: `. K, ]
{
8 q) z! _# z" c B0 g int ret;
. C' f; [* Q: k#if 0& |+ G8 A& f' u, v
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);# \6 j5 l5 H4 [- q, ^" t
if (ret)
1 h( _' t* @- { v3 `9 p" O pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" ?% k3 V# a- A. F "%d\n", ret);
) U7 `" P& k9 t q7 Q#endif6 b6 z. f4 L- ~+ [: V7 X2 n
ret = platform_device_register(&da850_evm_tl_leds_device);
3 ~/ H8 |0 e( ] ]3 v! K if (ret)
6 ]8 Z( X$ R& r+ c7 m pr_warning("Could not register som GPIO expander LEDS");: X8 a/ w3 t5 M$ d* U
else
a- @* i9 g, r printk(KERN_INFO "LED register sucessful!\n");
- R9 h) A) _/ P( p! o) S9 }. u5 p* F6 n6 h3 P! v% a
return ret;3 }. p$ z" n. }* L9 k
}; L0 F8 X$ C, W6 z
$ `* R% J. v! w! u0 t2 o+ O9 q- }
static void __exit led_platform_exit(void)
, G2 u _" R1 t; e" G" p{+ Z, q$ C" e! l- A# m
platform_device_unregister(&da850_evm_tl_leds_device);. H/ n/ P \) V' X. q" Q
, [3 q% \8 x* W- H8 A
printk(KERN_INFO "LED unregister!\n");
+ E; ~4 k$ Z3 W- F7 ~2 t U9 i9 i}
- ^% S0 ^( x( A3 ~2 d$ E# _; ^, c" @/ `% Q7 E; u! x. z0 i3 [; w
module_init(led_platform_init);
" B y6 I3 c- Z& M9 [/ q, I$ \module_exit(led_platform_exit);1 ^0 n' D! c" _( N' R
5 R6 ^# S) V, C4 F) b5 ^* b' |MODULE_DESCRIPTION("Led platform driver");
# J; e- X1 A- _1 W* \0 H" FMODULE_AUTHOR("Tronlong");$ F' J' t- n8 y1 O& z' k5 }
MODULE_LICENSE("GPL");- P" n" Q+ l8 \1 b( [1 f4 Q0 S
8 `& a' i ?6 X1 B
|
|