|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 r7 ^( ~, m1 D" P7 j& t" f4 Z
#include <linux/init.h>
6 X! M4 R, E/ J3 T( Z* z8 ~" B#include <linux/module.h>
: s- L8 D+ J: r( ?% R f, q3 O#include <linux/kernel.h>4 Q. o2 n5 T8 d3 v$ T H
#include <linux/types.h>: f$ g1 k1 v7 a0 h0 ~# g
#include <linux/gpio.h>6 Y* S! Y! b$ o1 ]0 n( m
#include <linux/leds.h>) q4 u1 [% l6 J) Y' S
#include <linux/platform_device.h>
' Y$ `% d2 F" X2 `$ e
2 Y0 z4 n! I" M3 i5 K# I#include <asm/mach-types.h>
& {2 J% c1 k+ `2 r3 Z+ ^( ?+ G: E/ f#include <asm/mach/arch.h>4 p- \1 ]7 n/ T. s
#include <mach/da8xx.h>
4 p/ k- [- O0 n9 a4 u2 N2 h+ x#include <mach/mux.h>
- ?: |2 i) {$ {; ^4 n9 d
+ V! l( \ x/ `- _! @0 m" V#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- c1 D3 N/ |( v' J" }% n9 L- o#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) K! N* p( a4 R w3 b& z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) a8 f3 l$ K" Z6 L7 x; Y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& p3 L( h0 z# g9 W# a: I& x& ?6 V5 m1 a3 K
/* assign the tl som board LED-GPIOs*/* A& _& J7 Z. A, f8 r) C2 N4 I
static const short da850_evm_tl_user_led_pins[] = {
, w7 \3 \ y# Y: t. w$ V /* These pins are definition at <mach/mux.h> file */
: O+ Q2 R2 z6 k' e& Z+ H- | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. \; R r" H" g9 \9 b, _1 C
-1" m* S0 I }) @8 ~; t
};; J3 e4 V) P d y: o* P
2 c' Q9 f- a# X! C! p4 P8 u$ lstatic struct gpio_led da850_evm_tl_leds[] = {6 O: X0 n$ p) G* M
{
# {1 X. w6 ^! k0 ~( n .active_low = 0,
1 X# F( T& m( U! _: x .gpio = DA850_USER_LED0,& w5 o! Q( Y% D2 w7 Y" k* t% N
.name = "user_led0",7 o' M9 G% [- x% l+ m: b2 g& G4 s! D
.default_trigger = "default-on"," _1 e8 d% Q" x
},: k6 t' J0 ~, e0 x
{7 b% y1 \- H7 Q* R% h
.active_low = 0,
% w+ [' G. p: E5 Z0 ] .gpio = DA850_USER_LED1,: v/ U2 o! P* B/ Z" m
.name = "user_led1",% L- c$ c. V" x2 X$ |* Z
.default_trigger = "default-on",- R% b! s/ F- I
},
& z4 l+ F1 x0 h; ] {
' `* i8 w `( R7 R' W .active_low = 0,& R: J2 Q! X3 p% G
.gpio = DA850_USER_LED2,. k( K+ D3 S; X
.name = "user_led2",+ F) c2 M3 G1 B6 s# x; N
.default_trigger = "default-on",- a& f9 a6 A2 D: ~. S
},7 t! r) p* ^2 A3 C9 N
{
0 k" ~- A0 }% E( }7 |- f .active_low = 0,
( k0 X% U7 k- F: T. Z7 }8 a3 N" F .gpio = DA850_USER_LED3, o$ N; J8 W( l/ j/ z" c1 E
.name = "user_led3"," X" d% A5 L0 `+ }6 _! H
.default_trigger = "default-on",( Q! M8 M7 e5 U) u% W! q, \% d
},5 o- y+ r. J9 a
};: H; W A# |: M1 ~( f# Q
+ T; F. l, f6 {8 e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" [9 R5 p. H! ?# J" M
.leds = da850_evm_tl_leds,. Z' a7 A& P8 b
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 H" C. o5 s3 W( D S
};
# _- N/ Z$ g# z: L( h: N2 h0 s7 I0 a) i% J6 m
static void led_dev_release(struct device *dev)
) B9 u- s- p+ Z# {{
0 X! ~5 y- b! Q) _9 Y};. [4 L; F5 {: n* {6 e$ }
7 H2 ^& G( {* i. D, W! f- b
static struct platform_device da850_evm_tl_leds_device = {9 E. _% W( t M. _: \ W4 Q3 A
.name = "leds-gpio",6 m, I* ~7 q$ Z& `2 v+ N
.id = 1,! l8 q9 n n9 g2 ]
.dev = {& v ?! V# J6 R3 c- d
.platform_data = &da850_evm_tl_leds_pdata,, X2 L! _7 Q4 l0 Q- A
.release = led_dev_release,
; G6 E5 q l B% C( p, H: L4 D, t) r }
- g& b# g4 u/ P0 [9 C8 w- Z" y, B6 Q5 K};
0 ` b! z) w2 c4 Q: Z @8 p
- _$ r% F! b, P8 S5 v+ ^& Lstatic int __init led_platform_init(void)" X, Z" X( b# f
{/ }. a5 p7 [% f) F/ t
int ret;4 J; A+ s" T, `( }+ c9 N/ A: r
#if 09 R" @% \/ m; F1 L8 i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- l8 v1 }% J- Y/ P. [# Q' W if (ret)
& {0 w) b8 r2 f+ l pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 a1 R4 |% w- B! K* N5 G$ h "%d\n", ret);
- G$ q! G$ Y4 {; v3 q! Z# X+ q#endif; m {5 C; w. t) z5 w
ret = platform_device_register(&da850_evm_tl_leds_device);
5 L( N; h$ Q0 }+ v. } if (ret)
& z9 O3 O4 _2 [6 `0 U a! F& C pr_warning("Could not register som GPIO expander LEDS");5 J- c" M4 l! D; K) V8 y7 j- i! i
else
7 S: Y7 [! A5 e0 J" \ printk(KERN_INFO "LED register sucessful!\n");
4 A- K! x* S8 @3 r3 k, I
. x7 [' |7 T3 F2 P2 H( { return ret;* r; b: g# A2 I5 b
}
4 Q( x; ?! E7 O" ?% V _" e& E U6 ?& V6 @/ X$ b8 z
static void __exit led_platform_exit(void)
* x3 N* }& C: X9 d{
5 f3 u: @& i) t+ [7 c+ n platform_device_unregister(&da850_evm_tl_leds_device);
- O. c+ U, b1 q8 l8 v; {" s% B1 J# l; \9 R' v3 x
printk(KERN_INFO "LED unregister!\n");
0 _# ~1 B# H/ ~: p( h3 d! s}
- `2 }; a- a. i; j3 [
9 n" ~2 Y7 j# r$ Tmodule_init(led_platform_init);' K9 t5 u% v& n9 ^+ d. [- d
module_exit(led_platform_exit);9 \# Y+ C" R; ]: {. [8 _- c
' r) u, D' C5 C" u$ g3 B& u: z' e U
MODULE_DESCRIPTION("Led platform driver");
% }' E3 I3 n# T# i. m, F4 ZMODULE_AUTHOR("Tronlong");" o2 U: t7 ~# n5 ?. M1 u' G
MODULE_LICENSE("GPL");4 P' O. r4 m4 C+ R5 C3 { m; B3 Z
8 k% B" j8 C7 P4 m& c |
|