|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) t6 Q8 U9 O& ]#include <linux/init.h>
3 B/ B+ U! @. N" ?#include <linux/module.h>! L/ }/ _1 x" g" J) O k
#include <linux/kernel.h>
5 D- L; q' B m5 g& N- w#include <linux/types.h>
3 Q. C& Z% y! H) }: K2 v B5 T$ b#include <linux/gpio.h>
. l! p+ s9 w, c% L3 ^% Q& I#include <linux/leds.h>
) B$ @- E: L4 F- J#include <linux/platform_device.h>
# o6 j5 I0 P& O0 k# a
6 l0 u% I4 v5 \ K#include <asm/mach-types.h>' p6 o) c8 J2 f5 ~
#include <asm/mach/arch.h>
+ }! D$ v; X, d2 u7 |#include <mach/da8xx.h>* [& n3 r* R/ g+ O7 i+ n
#include <mach/mux.h>
' B/ Q3 ~4 ]$ }" U
, Q' |+ _1 [3 e/ L0 g#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# |7 d1 X- x# E
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 ^9 n: z& }1 D#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- a, V# |# C ^1 M% V
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 P8 x& P G/ R9 O' \
( G1 A* d! {& N) T/ \/* assign the tl som board LED-GPIOs*/
8 u, [7 e) {4 Kstatic const short da850_evm_tl_user_led_pins[] = {
3 v: Y" U3 `# Q3 Z/ w /* These pins are definition at <mach/mux.h> file */4 L c% ~- f. \
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
p# G ]" T$ y' M \0 B- h9 S: W a -1! z4 G, H" H5 i2 q8 K
};
/ y( p9 Z! u' q% a7 G
! S9 z6 j8 P3 }9 lstatic struct gpio_led da850_evm_tl_leds[] = {0 x3 W; i' I4 u/ a
{2 H6 w% r* K+ U. u2 W; I
.active_low = 0,
5 d) c, } ~/ i6 T9 q0 n .gpio = DA850_USER_LED0,! B$ f5 O1 t* L* ]
.name = "user_led0",( [; Z8 P6 Q- B5 _$ b+ k
.default_trigger = "default-on",/ M- j; [# X1 c* |
},) r% v7 Q8 |" l* y: K3 v
{" E+ t/ n. w# A# \2 B& Z
.active_low = 0,
2 n! Q7 ^% y k; V; u4 @ .gpio = DA850_USER_LED1,
9 |: r* \- |0 s+ h9 j7 N .name = "user_led1",' G: C6 Y0 M2 s% q$ V( R% n
.default_trigger = "default-on",6 U) m+ w4 `5 w0 I3 v' N
},( n: \5 l% ~$ h
{
' h4 Y4 J/ B- c; K6 \" e* | .active_low = 0,
) s* s( \/ m! l! u .gpio = DA850_USER_LED2,
( e' \, }# _" b! j( } .name = "user_led2",
' n% I8 ?( V0 o1 `% T3 F' h .default_trigger = "default-on",, A: V6 e% {" s$ ~
},% Y l# k* a3 r2 z% v, A# I
{& h: A& |% E- f' B
.active_low = 0,% v+ W" }& M- o \+ Y, J/ X3 r
.gpio = DA850_USER_LED3,
$ g( Y, C7 O5 f, e .name = "user_led3",/ b4 O. q& t7 x* \7 O5 B
.default_trigger = "default-on", c1 P4 u1 H+ P' }
},$ j1 U$ U9 A5 t# X
};
& o: U( V+ K) k, R' ^; T
9 b. |0 \( K, u# astatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ f `9 e, o. m- ~5 k .leds = da850_evm_tl_leds,1 @; {4 j3 e) L6 {
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ W6 a: v8 c+ e& k
};4 ^6 w3 l1 C/ N% }+ {- b! K
, ]6 u5 E. z6 ^$ Q/ vstatic void led_dev_release(struct device *dev)0 M" }( Z$ {6 [: X1 _
{% n A8 r6 ~5 h9 q! R) \% y
};
9 L: t+ J" U: _) f& ~) Y3 B) t- X
; s) _6 V: Q7 Q- y" y! Y% h+ m8 Y5 Ystatic struct platform_device da850_evm_tl_leds_device = {, X( L3 N; |) F1 B
.name = "leds-gpio",
! @$ b4 c1 C% ^/ i! Z .id = 1,
) b; p1 T$ B. g& E .dev = {: \% v% ~% `# Z/ q( i/ s
.platform_data = &da850_evm_tl_leds_pdata,
. J3 z, y2 z9 ], n' Y5 N& @3 t3 d, } .release = led_dev_release,! F- r- i- V- z. U
}
a' j8 p- f- C, G9 G};
6 e# { L5 |& A4 p0 n8 S6 B8 s7 Z8 x: D6 W6 ~
static int __init led_platform_init(void)& o9 X: A1 m+ u6 f5 q
{" C# h8 O) |5 |0 z# U% J
int ret;! s& h2 `. |8 o) ^/ o8 n
#if 0
4 {/ ` l n3 E% t( J/ } ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& w: `# W" u( X2 i% Q1 J" G if (ret)
0 b4 l0 _# P; A6 u, I) P pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 \( n2 P# I- \% J6 U
"%d\n", ret);; _9 _6 X* A- X7 c
#endif. a7 T9 S7 s: Z: `) W4 M
ret = platform_device_register(&da850_evm_tl_leds_device);
6 C) { K+ x8 T$ b8 N9 s4 l if (ret)0 S) t& }! c0 C' |
pr_warning("Could not register som GPIO expander LEDS");
2 q5 i2 i0 ?5 L! ~, R else
& Y( S# v( G; J" z* S printk(KERN_INFO "LED register sucessful!\n");
% N9 a# y, h6 K! s% v- n9 ~; }, e
) m' p& ~8 z' V4 D% }8 l return ret;' u, b) H+ ~) ]9 p/ D7 M& c
}
' w) A! b0 b5 d+ U, [1 S8 n$ [" C( J. ^% _. H; k6 g5 I
static void __exit led_platform_exit(void)
, Y# x/ g) n7 A2 J+ s [{
9 ^# ?5 R K! y platform_device_unregister(&da850_evm_tl_leds_device);
5 [8 E i; S( `- `7 j" }6 [& { a7 ]( o
printk(KERN_INFO "LED unregister!\n");9 n( F0 @& _; |3 J% u+ U
}1 {( o0 {2 ~4 C# ]% S8 u
^2 Q2 J3 f) B) E b2 Lmodule_init(led_platform_init);6 Q: w4 ?/ C) b, ~' ~
module_exit(led_platform_exit);
6 A( s& j' H- D+ b7 ^1 X1 ^2 b) P, Q. Y2 Z" J2 Q
MODULE_DESCRIPTION("Led platform driver");9 ]8 j' P% ?) X7 g& f( N7 O
MODULE_AUTHOR("Tronlong");
4 e C. P: _8 V( i( z ZMODULE_LICENSE("GPL");
4 P5 N+ P7 P5 \6 j2 m+ O8 u ?( b2 o0 N! j
|
|