|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% x- N! R9 E7 e' {, h6 e$ {6 v) I, P#include <linux/init.h>; N/ l7 R$ A: A& {, e+ q
#include <linux/module.h>
+ b" l( E9 a; z. i: t6 W1 S/ K#include <linux/kernel.h>( v P: j/ L4 n- J
#include <linux/types.h>
! h1 r$ m1 P$ [# |3 C#include <linux/gpio.h>, z9 R: t" O& x0 T
#include <linux/leds.h>8 h* u( G# }% ~7 D3 |2 C! ?
#include <linux/platform_device.h>" v8 a, V/ b$ U( ~9 A
& `7 E/ e% o' O
#include <asm/mach-types.h>
% E# L, q9 x1 c0 A+ i8 k5 O#include <asm/mach/arch.h>
! V& q t' o# `; d) `# Z/ {3 w#include <mach/da8xx.h>* r9 `3 P1 b- {
#include <mach/mux.h>
: J, W ^# G% |4 ]" R/ U/ j0 |! s, g5 Z; _8 Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0), R2 O5 o4 M4 B2 J7 I6 {9 s9 T+ w& h
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 ^9 g$ r8 t- M! B# g* j1 R) U' ?
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; R9 n2 n8 L5 ~8 q" F#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); w5 q9 L5 M5 j9 b8 J! _& Z
& p$ Q' ?3 X( \, \+ W
/* assign the tl som board LED-GPIOs*/
' K: b2 y) n6 _ v1 @static const short da850_evm_tl_user_led_pins[] = {
% m& n& e. p# v6 T5 f2 @, [& J# N /* These pins are definition at <mach/mux.h> file */
2 ]# h$ g; C$ G DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ i0 [5 K; U M
-1
$ u3 Y3 B" x/ I3 W$ C};
/ }. p2 w4 j9 O7 _+ H6 [
! q: R3 ?1 M& ?4 dstatic struct gpio_led da850_evm_tl_leds[] = {
( E# c; G# ?# ]) u4 O {( }4 L2 P0 \& ]
.active_low = 0,7 a2 i% b) B6 p+ i( E. Z6 w! V
.gpio = DA850_USER_LED0,- ^# ]3 m- J& m; t( c) ]
.name = "user_led0",0 Y- S3 o1 I$ {0 H; b
.default_trigger = "default-on",
& f0 r- i7 P6 y2 q$ _8 d. D }, o5 f0 b0 j) f2 s' d
{5 ]( E2 d0 j( E7 b, r' T, Z
.active_low = 0,/ C( p0 d% h' @; M
.gpio = DA850_USER_LED1,
3 ?9 z# p x: d5 N .name = "user_led1",/ y% Q0 w) `: ?+ _- W7 V5 e4 C
.default_trigger = "default-on",2 `9 Q7 ~9 S9 G2 r: y2 r
},4 ?8 Z; O1 N: m* `" B: R
{/ a9 \% ?' t$ I2 F9 ~4 I
.active_low = 0,! [9 m" \1 Z7 y0 t) j
.gpio = DA850_USER_LED2,! S8 V$ A$ {- D4 R0 f# O
.name = "user_led2",
- d( d( ~" y, `% e( W; v+ }) P .default_trigger = "default-on",
% Z/ t2 n. c4 y$ R; | },
7 w4 d. Q3 h9 d; i/ V {
) s' ?8 f0 U- g" g .active_low = 0,4 q$ f0 T$ w5 L. c, c \" q
.gpio = DA850_USER_LED3,
) Z/ T( [1 B( x8 O7 L: ?& w& F .name = "user_led3",: t8 f0 h4 W* z! k5 V5 A* s3 _
.default_trigger = "default-on",: V0 o7 j* H/ j, V" {8 S) m: h
},! x/ A( z' ?4 a: t
};: Q$ Y) z% E& z+ B* o3 H$ \" T
9 N: ]) M3 E* w( y8 c1 I+ tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 @6 R4 x* X7 k1 H+ F4 t- V: Z .leds = da850_evm_tl_leds,
% `3 x) J: M$ O4 s# d .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* u4 w8 [) d' { b
};
! f' r% _& N# T5 s( S
& n2 E) A( \" \$ g* f3 tstatic void led_dev_release(struct device *dev)
" C1 w9 k7 ^* }$ M{
( z/ t% l* @7 X; W, z8 e9 H};, k' {3 o3 q+ i; c# {2 o
8 J; \0 d" I# e5 Gstatic struct platform_device da850_evm_tl_leds_device = {% \( Y( R }& a" C* m/ _9 P9 q
.name = "leds-gpio",
' K- }5 q, ?- y, G$ Y5 c1 v! p( v2 i .id = 1, ]! W/ z6 N6 z0 l% y4 l, p
.dev = {
& n/ ]: [- ~: J9 [ .platform_data = &da850_evm_tl_leds_pdata,
u- x( q. {% B) y; q .release = led_dev_release,
. j; W' o4 I( K) n+ ` }0 i# {3 W: Q1 U1 O" K, m7 ]4 E$ x" m
};
7 C) Z; T7 \- w" _; u% a; l# ?8 j4 _% f$ u) ? r6 K; N! p
static int __init led_platform_init(void)
P0 l' y L4 ]9 D' P7 y{: F7 e/ J9 a. n
int ret;6 a5 _! ?0 z# w& W4 G% \
#if 0: ]! k6 o+ V% s
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. B+ i: X7 b& R" x if (ret)
* d9 ?; {) I; C4 Q9 [ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 d$ z# R1 l/ S2 R0 X "%d\n", ret);# H* h+ g/ j! T j* n
#endif
9 y, }& I" P" \2 H6 y" v2 `7 U ret = platform_device_register(&da850_evm_tl_leds_device);" s! O% o; a- e- G# k- `
if (ret)
& G6 O) Z. ?# {* t pr_warning("Could not register som GPIO expander LEDS");
6 Q% |8 A5 E( l A( L else+ H' d0 ]9 R6 L; e$ X9 d* R
printk(KERN_INFO "LED register sucessful!\n");
' l. J! {) C# f! o: K) O1 ]- R# `: F, L# S6 H3 A) H0 W4 i
return ret;
# e& \5 u2 I( P' Z0 a5 B}
: v9 ~# }4 j# z1 {3 M3 O
7 J& ?+ M( ] k6 K+ o6 Sstatic void __exit led_platform_exit(void). ^0 ~) `$ n$ T5 |
{6 _ ^7 R, Z* S" P8 p' \" @. x @
platform_device_unregister(&da850_evm_tl_leds_device);/ M9 ~' A4 {6 _
$ R. T% M R2 C* t
printk(KERN_INFO "LED unregister!\n");
6 |- \/ \, Z+ \}
2 W4 [4 c0 t/ U6 [
' [3 E& N$ |- |* [+ O8 k: ~1 |, t( vmodule_init(led_platform_init);9 M3 k$ P- R3 m" g1 A- C
module_exit(led_platform_exit);
. D |* @' y1 b5 k- z7 V6 q6 g$ e: k. q/ z O8 W
MODULE_DESCRIPTION("Led platform driver");8 ~ W. p0 J; j8 t
MODULE_AUTHOR("Tronlong");" k, d; z& \7 g; k' m& i
MODULE_LICENSE("GPL");- j4 I' E7 ]& ^; {+ b
/ m" t5 O. |3 D6 n9 X8 w4 @
|
|