|
|
求大神给下面的程序做注解,请稍详细些,谢谢。; v! }% D4 b5 u
#include <linux/init.h>3 T, I A; c& q% ?% ~" I
#include <linux/module.h>
' a, k5 R: K0 S' S/ \- N#include <linux/kernel.h>- q7 ]' e) b6 m0 P, }- S( }
#include <linux/types.h>( R7 Y, x: u9 g' u+ {
#include <linux/gpio.h>
( T) S: X& J) a P#include <linux/leds.h>4 C: @8 P- Y9 _5 L) b4 w1 ~+ {
#include <linux/platform_device.h>! c- S5 Q: p1 j
- ?0 p2 l0 {. ?' {$ X#include <asm/mach-types.h>
- Q2 P& i) m7 u7 d, N+ S0 j1 _#include <asm/mach/arch.h>' O& @: j+ n) J* x2 \7 f
#include <mach/da8xx.h>1 O, h- i; L+ r& q& c4 Q7 Q6 I
#include <mach/mux.h>
9 G# v# }' m/ S0 W& s T8 x/ L# U
- y$ Z1 o( n5 p) e7 {% E#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' J! d9 X" C! f3 P
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 T+ e s; C3 _" h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 |. f5 }$ ?. Z' n# ?3 } a7 G#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. i { m2 M' U5 N+ O0 v6 ^( h h; W7 H7 ^3 y- \
/* assign the tl som board LED-GPIOs*/
8 C! B- N/ f3 lstatic const short da850_evm_tl_user_led_pins[] = {$ Z+ s7 j) L( d) O" K: V
/* These pins are definition at <mach/mux.h> file */$ A7 D9 ^" h+ h
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 p. J$ l, n: n -1
' r/ q" [% [" W8 h+ P8 [};6 t2 d/ g. A7 Z; `6 ]0 s
% y8 x' S2 O7 O9 r
static struct gpio_led da850_evm_tl_leds[] = {
9 t; W3 ]7 ~7 H2 l {
2 S/ E6 `6 I5 s- r .active_low = 0,. S3 ?7 Z$ u! n' n
.gpio = DA850_USER_LED0,7 i6 U4 `. z- { U" m2 o" ?9 S
.name = "user_led0",
$ l. ], q. c7 O3 J .default_trigger = "default-on",8 Q) c1 j) b6 ]& w* g
},5 h: m% s0 z( |$ X; J$ q! E
{5 r' o3 g, F2 c$ l' u& v
.active_low = 0,* Q" ?$ Y6 ?5 X. Q' b! e6 a
.gpio = DA850_USER_LED1,
+ J: A* H; L( V' m9 x; r .name = "user_led1",
: g, H0 u1 O) _0 j6 ~, [# p .default_trigger = "default-on",/ U/ b! H: O) T% U5 I# U# }- b6 o
},! N8 @" G% A1 e/ x+ P
{8 E7 x( A! Q4 E
.active_low = 0,3 |0 E7 O# H$ r6 L) ^4 ]1 Z
.gpio = DA850_USER_LED2,8 q" c" ]" G1 \- B) z8 T6 u% M7 S5 k
.name = "user_led2",
2 r. S4 g3 J9 W" D! d+ w .default_trigger = "default-on",
; P9 [; ^7 f2 s& |+ x ~ },% }* w7 `2 F" j) i# V: \* ]0 K
{& R) j& T6 j" p# a. ^, R. [( j
.active_low = 0,
8 G; K& P# P& |9 \/ ?8 N .gpio = DA850_USER_LED3,* j- K0 y1 d) w/ Z* f* v: ?$ [
.name = "user_led3",
3 c1 U. r w: ? V .default_trigger = "default-on",
. Y2 U; D2 P. c: H( n* @* H% [/ y },
& i; y S) P6 B1 U0 t, m};
. ]9 N. X4 o- s6 t2 n7 X! \; m. A% y5 B6 c3 d
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" F% {8 u) ^# I. @' ^6 w& z, H; r .leds = da850_evm_tl_leds,, o& Z- Q- A( R4 k2 U* L
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),, e8 Q- e7 Z7 d% Y/ {5 t- `: T
};, L9 B; J# p- p$ `. D: }, @
. j6 m! _2 t. J
static void led_dev_release(struct device *dev)
$ W7 w' W4 @" s( N9 k{5 V7 f$ S5 z( x, ~! b) m4 I8 j
};$ x! b% ^8 A+ `* E
/ m! d+ P ]( @3 Q5 l
static struct platform_device da850_evm_tl_leds_device = {
# j5 K. y2 G0 n( w' N9 | .name = "leds-gpio",/ S* \( B. {# N
.id = 1,/ x; T+ [: S1 H& R3 f" \. {9 p
.dev = {
! F6 B5 Y( C) F! q .platform_data = &da850_evm_tl_leds_pdata, h+ l; S0 I' u. `# T- P
.release = led_dev_release,, ?0 [8 u: O" J( L' G
}
5 l: m# o: |2 h7 R};
$ `8 L! a" V. k" \5 g: z) I$ @0 K r0 X# Q
static int __init led_platform_init(void)" b4 a" a* h9 a. F: x
{5 w0 ?/ ^! y$ A) g
int ret;2 ?. w6 f& H8 V2 |
#if 0$ G5 V6 G9 f( H! A# O! S
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ }7 x& ]) t6 |; I+ A: q if (ret)
: U2 e3 y% n( l& x6 y& k pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, W% W5 f ?; @9 |" K" a "%d\n", ret);
2 H. T! ^: w6 C9 X#endif
3 [6 F+ D$ f u% | ret = platform_device_register(&da850_evm_tl_leds_device);
, s1 J9 R# b* Q& A, \3 j8 `% r if (ret)
. `; ^5 J. C2 c( }- A& @$ S pr_warning("Could not register som GPIO expander LEDS");
0 ~; z7 [5 H4 O; e K& R else
1 s, L. u5 _. k0 J printk(KERN_INFO "LED register sucessful!\n");- ~7 s$ l5 D: J6 N& g$ N& ]+ c
- J9 a/ Q. G2 a2 W: J; I7 f- \ return ret;3 i2 m3 |: A/ K$ R) Y
}% s% x, i8 V! A6 s' X
8 U1 [# R7 ` K+ M: F3 V7 f$ v+ a9 j* O
static void __exit led_platform_exit(void)- Y& W0 u- |2 u, Z/ ]% t! [( {& G
{+ y. h! |, D. a x- X% J
platform_device_unregister(&da850_evm_tl_leds_device);9 P+ ]$ t! l! P& o1 A
4 _; j$ G: S( R' n# j' O
printk(KERN_INFO "LED unregister!\n");
2 n3 ?: c, \+ h1 q# e$ n% c2 E}
% M# K+ y# G* c0 t5 _
/ f+ b1 ?6 n; p; x1 cmodule_init(led_platform_init);
; Q$ G. F q1 g' |/ O1 c) v$ rmodule_exit(led_platform_exit);( }2 X$ V ?( b2 `( k; a
, `3 Z( _: }9 c8 P8 G- \MODULE_DESCRIPTION("Led platform driver");
( R# @: e- C8 ^MODULE_AUTHOR("Tronlong");
5 w: y" \) T2 J, K8 d; n3 c' Q! IMODULE_LICENSE("GPL");7 d B, F* c: s; s6 z5 K0 P- H
8 e5 N2 B/ _- c! a- x
|
|