|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; ], r( ]9 Y( J* U9 D! ]' g#include <linux/init.h>
7 p; ~: H3 m/ ~1 i8 C#include <linux/module.h>
+ M. T9 Q8 L+ ? Q) L( G#include <linux/kernel.h>
. N( n! s, [, _#include <linux/types.h>0 w+ S0 h2 c2 \" U
#include <linux/gpio.h>
, X! Z& v+ F3 K3 m- v#include <linux/leds.h>
+ C1 F$ m- t; g0 q" x#include <linux/platform_device.h>
, k$ x4 p( ^5 t9 V' _
2 i( u" E2 p8 n e#include <asm/mach-types.h>2 b" V, O h, }7 e8 d% r
#include <asm/mach/arch.h>' x; ?0 C6 U' C. { S$ F) W8 d; L
#include <mach/da8xx.h>$ X- I+ N3 U3 u( b/ J) a3 G; K
#include <mach/mux.h>; P# j. J8 w( I* d! p
) a" c$ u3 n4 s6 h. O* R+ u
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* h! n5 k3 t, ~$ E/ `
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ k1 ^9 T; u1 ?' E#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 w0 m9 w( t. I# }0 j/ L. n$ [7 U#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ m* V- F0 A G$ _$ u
+ E: m7 s5 k. T6 m/* assign the tl som board LED-GPIOs*/" t* E" L# U! `
static const short da850_evm_tl_user_led_pins[] = {
% e! S3 p5 Z* r1 w! o6 [- o /* These pins are definition at <mach/mux.h> file */, r0 P% N9 O' G1 K$ K$ k) E
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( H+ O T& J% q& A7 { -1
# \; B# w, \8 u" I5 ?: G};
+ s( \! i- h) x% n, z
7 D4 P9 n1 U( N, v ^1 d% Wstatic struct gpio_led da850_evm_tl_leds[] = {8 n9 T2 O( n6 K3 T, \ t1 V
{
% b7 W5 q2 r" A2 y .active_low = 0,3 m+ d; Z7 M; ^1 e/ q: z
.gpio = DA850_USER_LED0,* N4 r8 [( R, i6 A7 n( j
.name = "user_led0",8 g# m' Z8 |+ g' d6 x
.default_trigger = "default-on",
4 E% g: h) X2 A6 r1 _ },' ?5 `) _; |' x& x0 I7 l
{) X4 R9 H9 m2 }) D6 r
.active_low = 0,
) E: Q0 b1 n% @, I% D' \' c .gpio = DA850_USER_LED1,6 {3 o) j4 r e$ \
.name = "user_led1",7 A0 |( \5 V' ^: D% y) h8 u
.default_trigger = "default-on",
' a+ ^) k0 _. G9 n0 j- d2 { },
5 Y, N; `; }8 `' Q4 `( E {
9 M, y- A- ^9 h1 Y ~8 g .active_low = 0,' c$ \! h+ ~. x8 P5 q
.gpio = DA850_USER_LED2,+ l! k# y- G& |# A6 L
.name = "user_led2",
' k2 i# S6 M$ i& T" L .default_trigger = "default-on",6 t7 S4 m2 Z2 V
},4 I: |! E3 G, N6 X4 ^0 `
{
2 |4 w' j P; ~ P9 x .active_low = 0,' g/ D' u" H5 K7 g
.gpio = DA850_USER_LED3,
4 m4 J; o3 |! @- v/ M' P1 w" S6 E, L .name = "user_led3",
$ x \2 d4 {6 t% m+ q5 C7 O .default_trigger = "default-on",* H1 a4 w4 w7 l) b% R1 ~0 s. h
},
& R1 }9 D/ d( k6 _};4 L5 }! u, w0 _0 _
6 i1 F V4 X" e5 h1 V, f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 \3 L& `. W7 e6 o
.leds = da850_evm_tl_leds,
; M( e; Z @ [ F0 h" a .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 P& D1 J4 T. l6 M6 I) y};# K) _3 }, g8 x3 A3 q7 ~5 t* Q9 K
, F; H$ s8 B" A- `$ Jstatic void led_dev_release(struct device *dev)
* c) _0 g |) n& @# w+ ?# X% ^* z{6 ^+ p" V1 j9 n" b
};
9 w/ k( z0 e, _5 r, l! H( M3 R f/ m! P O- l
static struct platform_device da850_evm_tl_leds_device = {
! f$ Z' |( Q, f6 w .name = "leds-gpio",4 V* N( c" r Y
.id = 1,3 r( f$ `' z1 R h* u! G" M
.dev = {7 _5 E9 b }9 d/ c2 J+ V$ U
.platform_data = &da850_evm_tl_leds_pdata,' G+ `! m6 @ ~5 F8 I! N9 ?
.release = led_dev_release,5 L; f( L5 p& A$ t
}
: n p9 u4 j. C};
4 v! k' \( p8 B$ y! l: P* _
8 D5 P! D5 I5 i& g; sstatic int __init led_platform_init(void)
: ]7 u0 n- K& H3 P: |* Z{; a* k/ t" [9 Q5 X I6 [: G
int ret;
9 D0 u! M; O- b2 m#if 0' t) {$ e! {, y1 D; q3 C9 k
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% t0 m; S8 V% G5 Z if (ret)( `4 q! v( \- J( E- f+ p
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
u; c2 E3 z* N/ u7 M( @/ P "%d\n", ret);8 c) Q) ?5 ?2 J+ K1 _% @: {
#endif; U' J( c: f$ r4 X" k
ret = platform_device_register(&da850_evm_tl_leds_device);( m, L& b: T8 {0 [' M5 N+ m( v
if (ret)
0 F. i; D) d# W9 S8 C, b pr_warning("Could not register som GPIO expander LEDS");2 }7 b7 c6 c3 G* d8 t
else; u% N( d# R$ d1 J- x1 s; V
printk(KERN_INFO "LED register sucessful!\n");
0 G! J7 ~6 w$ |, o) Z" {1 c, i! \& D" `6 d
return ret;
7 l* D% _: B0 j+ Z2 A}0 S) a3 ]& Y* _8 T* f" }
5 h) _. G) v$ i
static void __exit led_platform_exit(void). m8 d: [/ b% M4 `7 s, A
{: j$ n9 c; n; r& w+ _9 w
platform_device_unregister(&da850_evm_tl_leds_device);: p$ m, K, f& K P1 r. I1 y9 d
) n# Z: @* Q% t7 V printk(KERN_INFO "LED unregister!\n");
2 O' P) V+ x# H2 k/ R}
) \0 r) G) }2 P# F& {4 s1 b9 H/ S4 z" Q) e" l6 G1 k, F4 P
module_init(led_platform_init);1 t/ E9 c8 y1 D4 Y6 o
module_exit(led_platform_exit);
- v6 K. i! }; i% t7 k$ C8 h) ~- x7 v" j
MODULE_DESCRIPTION("Led platform driver");9 p7 G$ g% j% L2 V T. z0 n8 v9 U
MODULE_AUTHOR("Tronlong");
) S5 z* s% ]- n5 }$ NMODULE_LICENSE("GPL");" i, l3 v! W$ |6 r+ Z/ D
/ N: C V9 P H$ T |
|