|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 _3 f3 Y, Z6 L6 w& M
#include <linux/init.h>
$ T. O2 \4 t1 x5 E#include <linux/module.h>
5 A- }* q+ w2 Q7 {. ]2 z#include <linux/kernel.h>; n' y) }: m7 ~ C2 ]# U
#include <linux/types.h>
2 k9 z6 S$ I7 K: E7 {#include <linux/gpio.h>
( N8 F; F! r2 K/ h, f& n2 s#include <linux/leds.h>
+ P; |3 Y8 J- R' T) L; c( d( P" t#include <linux/platform_device.h>
4 E" H+ x5 _$ ?1 [5 A& ?/ q8 ^; c) _, `6 w8 O! g* @
#include <asm/mach-types.h># N) \$ R9 f1 U; s# h4 r T# |) c
#include <asm/mach/arch.h>
! L1 v/ _! K- g K6 h) s8 L/ r5 |#include <mach/da8xx.h>
; {8 j1 R& X6 W. M#include <mach/mux.h> h0 O, J; A" z8 U$ Y. a
1 g1 D6 h! g3 T \# c9 y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 ^$ H7 `, W$ ]6 S' @2 b
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 L8 a4 x, x0 M9 `: V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 `8 [9 G e, b2 \- \#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! _% F$ ^1 }8 h* n3 l
$ F, q( C* R J0 Z/* assign the tl som board LED-GPIOs*/
" S5 ~% f# }9 p) X( H! pstatic const short da850_evm_tl_user_led_pins[] = {) D* {9 o8 X8 n. n# ]
/* These pins are definition at <mach/mux.h> file */
5 {* Z/ z4 [+ Z8 ~ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, h0 `1 r: o3 D, Z -19 r% V8 s/ N( O4 [% t* e! h
};1 Z2 Z# C0 ~/ i, X8 S3 o, `, U
3 m e" e1 o& J5 O; _8 i
static struct gpio_led da850_evm_tl_leds[] = {
" }; Z- E/ c1 E" A' _( @' x {" B- F& ]& q+ D9 `& {
.active_low = 0,
" W Z! ~9 ? [/ Z* _, X% f4 H .gpio = DA850_USER_LED0,
0 Q# I0 D8 g- S .name = "user_led0",
& h% z, f. c0 V1 n) F( z1 H .default_trigger = "default-on",2 n+ {) g5 h3 k6 A l/ G
},1 g# g1 o( b! e0 b* |# L: y
{
0 T: w0 \& c5 a; f5 n- J .active_low = 0,
. @; y, |+ y/ v5 O- X/ x .gpio = DA850_USER_LED1,* v% ?( @6 Z) Y& {) _+ H0 W
.name = "user_led1",3 v: a/ l" _ V2 N: C7 p
.default_trigger = "default-on",7 c4 E. Y1 J1 K3 W& T; k, ]
},4 e/ F0 C" D0 Q
{
2 X. N9 v# J5 N$ J2 Z .active_low = 0,
0 W0 [: J* b5 V" V. }0 f8 b .gpio = DA850_USER_LED2,* [1 G; l- r0 X( b! q7 B% \
.name = "user_led2", n( Q4 h2 V' }4 D
.default_trigger = "default-on",: D G, R, V2 g, h8 F( ~2 T0 ~" V7 X9 b
},
. J) M' r# Q( ~3 f {
2 @" L1 k9 ^& v, `( G% M6 g7 K .active_low = 0,
) p: N" ]; n- R' |: @ .gpio = DA850_USER_LED3,
4 J M. ~) `$ @- b' _: o1 I5 X- h1 d! s7 F .name = "user_led3",
9 t! ?, I1 X0 S3 E8 E. ?1 K .default_trigger = "default-on",- x+ m& B* {2 }; R# _
},+ ]8 s# I1 Z. {6 p9 s' B
};) i1 J8 M* t' Y
9 }2 _; @0 W* [% ?
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 A# G4 ~( X& M$ M7 z) c
.leds = da850_evm_tl_leds,% G4 V/ R- |% {! F- b. P+ E& D) H2 Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ C0 \! |6 @/ C8 q% i};( L o5 Y& n$ x7 C
2 `% [ P2 O9 w( `% I- h5 W' _static void led_dev_release(struct device *dev)2 I' h5 C Z ?6 R1 B% ]6 ^7 p
{2 q! a* t- c8 n
};
. {: s3 z- z/ k- o( T# r
% p; \$ K$ W: d( h5 ?static struct platform_device da850_evm_tl_leds_device = {. `! Z, f8 T# v& a9 V. q
.name = "leds-gpio",
. x1 s! Q' z& J" Z9 A .id = 1,6 h8 G1 Y' |5 e \
.dev = {6 r2 E7 b1 B/ o
.platform_data = &da850_evm_tl_leds_pdata,7 x/ k* [# Q( Q' s# p
.release = led_dev_release,
* R/ ~6 ^$ O) l: x }
. T6 s+ K6 R# Z3 n; O6 A) W};- V+ C% q; K6 f7 r6 y8 \
" {& c! |( c! v/ l Jstatic int __init led_platform_init(void)" _% w$ F `: S' [$ v
{
1 `$ d% M$ a4 m& N3 |6 _3 Z int ret;$ k- p0 \1 L8 H# v
#if 0
0 P8 e# ^) ^" K* N; T5 }: J ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 x1 ]9 J8 P g. j" k, s
if (ret)
% X: ?+ R' T0 W: Y9 x pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. C8 D$ j8 x, i; ^% V "%d\n", ret);; W, Y L7 h0 V$ m' U+ B- H0 ^9 O
#endif! k- p/ [( _5 j9 v
ret = platform_device_register(&da850_evm_tl_leds_device);+ G$ v& v1 y: I+ Y
if (ret)
" x2 c1 l" y7 i Y pr_warning("Could not register som GPIO expander LEDS");8 Q) P! T. u" X, h
else
: Z; g7 d0 J- M+ O7 K printk(KERN_INFO "LED register sucessful!\n");
M; U: d; {( ~& U* C0 Q9 v! B% A! N6 K7 L
return ret;
; E4 D3 o; |; v4 [) b; b}
3 _5 y6 E/ r/ } v
2 d7 V3 O- c3 `& j# H1 A1 Qstatic void __exit led_platform_exit(void)/ ]1 R* Q' {; T7 r
{
4 N+ r2 c5 A+ n o) M platform_device_unregister(&da850_evm_tl_leds_device);
! S- V* j6 g7 I
9 _! N" [8 X ?( y printk(KERN_INFO "LED unregister!\n");
7 ^7 h. L8 G8 g1 \# |}
, ?# b5 T: d( I2 d: M
& L: m; W5 g+ V% n& T) L" l! M, xmodule_init(led_platform_init);
$ ?( M7 e) h9 A A- T1 Q. [module_exit(led_platform_exit);
/ |4 s9 h% q& Y% ~0 v, B
' b0 T4 G8 h! a1 i4 X7 ]MODULE_DESCRIPTION("Led platform driver");
* |9 o- V+ P+ s! e, t/ \MODULE_AUTHOR("Tronlong"); O6 _* x/ v" G% W! y* U
MODULE_LICENSE("GPL");
8 q1 w9 j! G' y
9 F; u0 I, A- f2 c3 ^7 N/ ` |
|