|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" z$ E4 i! \- P" f#include <linux/init.h>
3 w5 R( B0 ~8 B#include <linux/module.h>) D/ B6 T8 z# O @
#include <linux/kernel.h>
) R" u! T( I. l2 J" b; y0 k1 C#include <linux/types.h>- y2 U) b7 e6 z+ W- y
#include <linux/gpio.h>
, N* y' O( t9 @#include <linux/leds.h>7 a; G, v5 P/ z+ _
#include <linux/platform_device.h>+ j7 \2 D: K: X' ^+ ~8 X
U( R1 F3 s5 U7 y4 L) O/ |6 _
#include <asm/mach-types.h>( n f0 a& @) Y6 x% \
#include <asm/mach/arch.h>/ a5 U5 x6 m, r8 N/ B# o
#include <mach/da8xx.h>0 O2 t n0 ?0 N: L- F6 s/ u
#include <mach/mux.h>6 A0 @$ Y. ]) b+ Y
' u! X5 q7 e& M5 R Q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 b" l8 h. L/ Q. e' g& z( x; ~! t: f
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ \: R; e H% y/ x' `+ p
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' x7 x7 j1 q7 x- ^" v2 `3 X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( p& g4 |) a; n3 b/ Q0 b7 }" M. C8 T; i) V J) ]
/* assign the tl som board LED-GPIOs*/) e2 v& A6 S# [9 F+ I
static const short da850_evm_tl_user_led_pins[] = {
# r1 X4 }4 ]- G* W /* These pins are definition at <mach/mux.h> file */: k1 t8 {9 G3 R8 W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 n. _* z3 H3 {5 t+ G3 J -1
4 C3 o# w6 ~" h9 u};
! ^8 R8 \0 f) J% p( v1 r: A* U7 u, X5 C, C9 z [% h2 r
static struct gpio_led da850_evm_tl_leds[] = {
* ~" t% l4 |% u5 `2 U0 ?; ?. K {
( O6 i& _+ v8 m: W4 ? .active_low = 0,) v- b" s& V9 i+ R# H
.gpio = DA850_USER_LED0,
8 z# a: R4 [7 c .name = "user_led0",
) y5 ~( g( b$ _2 K .default_trigger = "default-on"," r L3 ?# w+ m+ P3 b% q
},& K' Q/ a" i8 g9 X3 }
{9 A/ r9 w( Z3 l9 c- K( x' t
.active_low = 0,# W1 G, n5 v$ G
.gpio = DA850_USER_LED1,3 U: N+ T& x6 ~. u% f4 r5 f O/ ]
.name = "user_led1",# G8 D! Y3 k: y3 O, M: C
.default_trigger = "default-on",4 x( {) ~, {3 L' n) L3 t0 ^
},
5 N6 d2 [5 Z5 B. Z {, s2 q- w7 ?6 ]5 I
.active_low = 0,
5 N V3 K$ m2 x# J0 b( B3 c) f .gpio = DA850_USER_LED2,3 c& I* r! Z/ r6 {( X
.name = "user_led2",: ]: X) b$ X/ v( z! x
.default_trigger = "default-on",
# O. N# z4 w. x. O, ~ |+ N# } },, o y9 r$ d3 m a5 g9 w
{+ V$ p+ i/ m& U8 J2 G
.active_low = 0,
/ N+ M1 S0 y8 C .gpio = DA850_USER_LED3,
3 q# k/ U# A3 @ .name = "user_led3",; y# d: B8 W: E
.default_trigger = "default-on",
5 C. C* B% P; a% ~# o3 c( A% J },, X# u* L# [ e: t) P
};
! I( W+ N, v9 q0 R- {0 k2 @% Y, w0 ^7 c& `8 k, n" j' J3 `& E
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ o2 T$ ]/ o( E
.leds = da850_evm_tl_leds,
: I7 O9 o! f% A- B* m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. v: A+ [9 o- ?, m2 X' g0 o5 b1 U
};$ g+ m. K4 n2 I* g; M
. v4 T3 ~* `, r2 hstatic void led_dev_release(struct device *dev)
" d& ]+ {. f& S" c( e2 H0 M2 D{
( V# x+ M: v+ E- K- V- K};/ z6 C4 m t# u
( n3 ~) ~/ _; w! _" }static struct platform_device da850_evm_tl_leds_device = {
& q) G) ]+ R: ?! c/ H/ Y X$ D .name = "leds-gpio",
9 Y3 K9 z. c) v- w+ h .id = 1,
W2 y) D5 H1 a+ [/ ^- K% V .dev = {
7 A( q! M+ [, O2 P) M8 O0 |, x+ x3 V .platform_data = &da850_evm_tl_leds_pdata,
( {8 f# V" Q! x d .release = led_dev_release,
, i% y1 q7 N( W' F }. g1 L+ W. U9 n7 J
};
s0 p* s1 d. j6 o R2 Z
+ |$ Z) {: j1 {static int __init led_platform_init(void)( {6 g( q5 g0 E* J% f$ R
{8 k9 K, E0 @. V
int ret;
8 D$ { J4 A* t; J! {' C#if 0 J. Y. Q: X; Z3 h, I) q8 B
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& b! {! `% S$ n+ c7 n0 q( V/ q if (ret)) m- A; a& D' t: ] `3 H0 ]
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# P t2 a: I( ?+ Z8 X7 [ w3 P
"%d\n", ret);7 {" f& G) P, u! z
#endif+ y4 e$ f# \; A3 x) H# T9 z
ret = platform_device_register(&da850_evm_tl_leds_device); p0 C/ G9 l5 _7 ?- j- \
if (ret)
& |( {& }8 A+ D, q pr_warning("Could not register som GPIO expander LEDS");. }% F0 G, C: n& X1 r) E
else
6 h m: _! C! e3 W `+ _6 b printk(KERN_INFO "LED register sucessful!\n");$ k1 l$ W7 j1 O2 P
, y5 j4 {) J/ U+ F. d% F A/ r( D" I
return ret;
) i; L$ N: |& J}
6 P9 G/ ~+ r6 f1 D( B6 Z' s3 y- p1 ~* \ u* Y2 K* k+ _! \- p
static void __exit led_platform_exit(void)4 K: L0 `' y' x, _6 K1 s7 `( ]# }
{
: h4 b0 @4 T2 w. V v# [4 j platform_device_unregister(&da850_evm_tl_leds_device);0 c+ [% ]. Q# N0 [
. r; l9 ^0 s5 z1 p' Z8 d
printk(KERN_INFO "LED unregister!\n");
/ ?" o2 h7 m. }" e: X}" i( E0 R l, d4 F, A$ d$ N
3 h0 R0 z$ W1 u
module_init(led_platform_init);8 x. |; n5 [" ]
module_exit(led_platform_exit);2 n, |: o4 l/ L- u2 d
0 h. w5 G$ S* ~MODULE_DESCRIPTION("Led platform driver");+ z5 H) f3 i) H0 ]: Y6 g, I
MODULE_AUTHOR("Tronlong");9 D1 W7 |5 E, P9 A6 N- I+ A
MODULE_LICENSE("GPL");2 r/ p- m( d6 Y& x0 |! P( _
; S$ U, q' J* P6 ~/ E |
|