|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 ~7 y; y; k4 @6 E4 Y
#include <linux/init.h>" j7 u7 o( }( V; q; S) j
#include <linux/module.h>. T5 O6 k9 Y9 M% I3 A' U4 }
#include <linux/kernel.h>
* D, b. _5 T; i! L) g#include <linux/types.h>1 v+ o+ f0 U. T; r. v* M
#include <linux/gpio.h>
0 G+ F3 l4 G4 g9 g( U, s#include <linux/leds.h> o& }+ L, k* [
#include <linux/platform_device.h>
5 _2 @0 W1 E- O/ ~; Q- K8 ?0 Q9 g6 e0 n7 h h0 f c1 O; p3 a
#include <asm/mach-types.h>
) a r6 D5 D Y( i& ?#include <asm/mach/arch.h>
4 t0 M' X1 Z2 A+ j6 U#include <mach/da8xx.h>
3 _5 q' f6 [ g2 [) J) n! J/ C" D+ {#include <mach/mux.h>; Z# M6 T) k4 p" ^
# c3 g3 q; y* L3 `7 S#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' I( u: y0 X& o* U* K+ O" k2 h' @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 A+ |" M. P, M5 J- ?
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 b# N1 S3 k* \0 t
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ m1 R/ G8 l3 l: c2 l$ @. }( I% g c& j+ G# m( c9 O
/* assign the tl som board LED-GPIOs*/
: B& a2 {/ Z0 |( _) Mstatic const short da850_evm_tl_user_led_pins[] = {
' \8 y. F W- M! e' j, K' r /* These pins are definition at <mach/mux.h> file */( q. Z4 G4 d+ _/ u1 e, c6 n* H
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 F% F6 P. z6 L0 R -1) Q7 L. \) M$ ]
};
( w+ F3 G* \- ?4 J }) U; L( V; n0 o3 [1 F j# s; y2 o8 a$ u O
static struct gpio_led da850_evm_tl_leds[] = {6 K2 {; O$ _# n/ a, b* U9 N
{# z+ V8 S3 T" [" x# u
.active_low = 0,- u" \, z& `& Y, W! V3 ^+ Y! S
.gpio = DA850_USER_LED0,- |; Y* ^5 Y( R1 o
.name = "user_led0",& C+ R6 ~* ^$ @0 _0 A! x3 a$ P
.default_trigger = "default-on",' X, C3 i7 ?4 ^) q8 w
},
5 {) n7 L, B' E {% W* c: Z1 I9 D
.active_low = 0,) S* A; w6 o/ Q
.gpio = DA850_USER_LED1,+ {* K# e: Q8 z& O' x
.name = "user_led1",! ^0 Q/ C+ z7 \! o
.default_trigger = "default-on",$ d0 g( g/ M* \ x: j; `
},
& k2 u3 L8 \0 P8 W {5 T+ i# u* ]3 z
.active_low = 0,
7 J! Y2 i3 }5 D* u: Z .gpio = DA850_USER_LED2,
8 m$ x! s& c- c5 v: V) U8 \; j .name = "user_led2",
6 F% X2 p" ^& X .default_trigger = "default-on",7 _3 S3 c! x1 g- c& s6 K. b0 y
},
% k- n9 [ w3 Q# j {
" j* \ a+ M. s, d: o2 P .active_low = 0,# R( Q: }3 K6 s" X( G9 N
.gpio = DA850_USER_LED3,
: e: ?7 v5 z* K2 I# b( p' Z .name = "user_led3",8 B! l9 A5 }+ W& x$ {% r
.default_trigger = "default-on",' ?8 `+ q* ?9 R# E
},5 }) I- b! c: K" N. `+ F
};
& k/ g+ k5 m1 }: @% P7 d/ ]: X* [
& J' `7 h; e) ]8 i$ \% ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ V' g/ S8 U- z6 M8 d7 N/ o; o( m8 y6 r
.leds = da850_evm_tl_leds,
# E, z! i h7 x0 S9 K2 m .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ H- b4 {' i5 n% W8 q2 O8 [* @3 V};/ ]& U: w" N6 s
3 e4 [+ {: o0 hstatic void led_dev_release(struct device *dev)
?7 G# Z" R+ S& A6 E2 [) W{
: d. y5 B6 j. F7 i};
& n+ e$ [& S) l" H6 O+ C# N2 x/ c2 A
static struct platform_device da850_evm_tl_leds_device = {# B8 w4 k! s2 l, c3 ]9 R3 `
.name = "leds-gpio",
" P2 B4 A! C/ [ h+ a5 r .id = 1,
1 j5 X! p+ q* \9 a& T5 o2 k .dev = {
1 B2 I% ^" S6 y8 ?6 o: [. a .platform_data = &da850_evm_tl_leds_pdata,* Y$ M; V# A, X. M1 p) D
.release = led_dev_release,
$ m! J1 D: V4 K2 F }/ b. P4 ~+ c* _" _% M4 F$ B
};
& s0 o! C) S9 V' v$ E8 s6 E: ~/ O1 G/ A% I' r( y" X- X
static int __init led_platform_init(void)0 f% m4 e1 x& m( v+ o+ m0 O) C
{* h1 i6 }! @% v$ s
int ret;: I: _# a0 i6 y0 E( M* Z) Z$ w& A
#if 0, \' ]: S1 v) P
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; W" p3 ]! u2 u, W$ P9 J! S5 h if (ret)
( ?4 b$ A S. \9 U; T pr_warning("da850_evm_tl_leds_init : User LED mux failed :", h3 ^& J0 d. Q* |
"%d\n", ret);0 J/ `0 }. E& p# {7 }& c- v8 ?( e
#endif$ ]/ n2 |2 d" m7 a6 n& H
ret = platform_device_register(&da850_evm_tl_leds_device);
0 L8 r5 B2 b+ U- y9 d2 h if (ret)7 y0 j2 z" m' f
pr_warning("Could not register som GPIO expander LEDS");
$ ]0 i# G P: ]8 |% U else
# `: t. D* b- ?7 o# T1 U% ~9 I3 t printk(KERN_INFO "LED register sucessful!\n");& U" U2 z$ h0 F7 L8 U& h( t
: N4 o$ v0 U' m* f, ?
return ret;) G& j: z) J# ~1 _& d, p$ U
}. q. s9 \& M& h$ S
3 [+ M( \, \ U Istatic void __exit led_platform_exit(void)1 E: c0 M! e% f4 {
{9 _7 W0 Q1 s0 d; }3 T. C# k
platform_device_unregister(&da850_evm_tl_leds_device);" j, b1 w. O3 F, {' H# j
, U7 U" P$ x) e4 Q8 t' c. ]$ M printk(KERN_INFO "LED unregister!\n");
, s( W8 H" F$ g; C}: Q0 x8 U( z8 E6 s* t+ V+ \
9 m3 x5 y: R+ T2 X$ ^: ?module_init(led_platform_init);8 q/ u, S( {- `
module_exit(led_platform_exit);, f3 Q7 x2 v( R
7 y$ N( s4 L8 O; n5 U, r M
MODULE_DESCRIPTION("Led platform driver");
5 v) E" p# e( y- }5 X8 ~8 }: Q$ ZMODULE_AUTHOR("Tronlong");
w, u+ p0 B0 ZMODULE_LICENSE("GPL");$ o9 G' E8 ~5 P" p; p
2 ?3 n3 W/ w8 V: D" X( B |
|