|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* ~4 F; u* V0 ^
#include <linux/init.h>
9 {/ J V2 M0 b& ]) |; ]#include <linux/module.h>0 a, c0 B' Y+ r( Z
#include <linux/kernel.h>) S2 j+ W+ p9 M& b4 K* S) s9 X% d
#include <linux/types.h>4 @" P. h) u# o# o! Y
#include <linux/gpio.h> O) Q" f; ^5 r) |8 T9 U8 R: N; ~
#include <linux/leds.h>
3 r, V* n( B. e9 P8 e* y#include <linux/platform_device.h>9 ^4 O: M4 k. i
U! ?# z9 k l3 x& Y4 |3 a
#include <asm/mach-types.h>
2 [- X& _/ V1 k1 a# ~9 O#include <asm/mach/arch.h>
6 ?; {) }; G2 N2 ?5 A' [( ?#include <mach/da8xx.h>
# l' K/ W3 F g- \#include <mach/mux.h>
; \ g6 S" a! |7 ?! Y5 f' p$ N9 L/ ?5 Z2 p! R. d/ Z: f$ U
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 a+ ?- |5 S8 I( \! A#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). ]8 X' Q1 U. j, P( M2 l
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 P8 ~ h& u/ x; ~5 P& w b7 Z5 O#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& @! K5 t2 R% h' h* T1 m, n+ H" k
% e$ o5 u: f6 \/* assign the tl som board LED-GPIOs*/! b3 t, O# D, \# m9 L; p' _
static const short da850_evm_tl_user_led_pins[] = {/ g9 J/ f2 k5 L' j6 G/ B
/* These pins are definition at <mach/mux.h> file */; l9 f" @! g1 ~& K
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# x( w" [! H/ s! Q2 z+ O) O; J -1+ \& G4 m; P- a: z: U* }# ^5 L
};6 \# h5 y4 h0 w9 i3 y: B$ ]" N( d
0 N" `! d- t7 H5 O: ]* t
static struct gpio_led da850_evm_tl_leds[] = {
7 S; u4 }6 v/ ~; c {& X8 R1 \9 g. c% P; Y' t
.active_low = 0,
: @0 d$ z) y, Q& M$ g .gpio = DA850_USER_LED0,
9 Y7 F5 u, B' x, B5 a" \2 i .name = "user_led0",
+ v# d6 L/ @& g) Y7 x/ l) ? .default_trigger = "default-on",2 @0 G/ @+ y8 B6 @: |
},- |6 ~3 J7 w( A# O8 E7 Y% N4 m6 F9 C
{
1 K2 i2 b( ]. P% w .active_low = 0,
$ s( S* W& _( w6 J y9 ~ .gpio = DA850_USER_LED1,
?" Z: s$ t( C .name = "user_led1",
% F& i( R; h2 z: x4 d" k .default_trigger = "default-on",
# g3 D8 H9 g6 E/ Q; a2 } },
' \/ G- ?! U. Z3 ~. R9 \& } {6 O( ~- Z2 c" e2 Q4 A: |1 }
.active_low = 0,& Z; I+ g% l: q0 ?/ O: r1 D
.gpio = DA850_USER_LED2,8 _4 \' \0 f& }" s1 {
.name = "user_led2",
# T, m$ V* \% e! l/ N7 J .default_trigger = "default-on",
7 p* W! h. [) J7 |# ^ },
0 w! E% E: {( c- a/ l+ e {
% V' m6 |! H& @$ t# O$ j .active_low = 0,/ \7 a" t5 K7 K
.gpio = DA850_USER_LED3,
7 o. y* A1 F2 R .name = "user_led3",
( }, \% r2 H5 S' E0 L1 G# g .default_trigger = "default-on",$ i$ N! `) a, V! V2 ~- ~8 _ Z
},
* Z3 m( k; g$ _" y; A5 {. x};
5 }, D J; w) d! ^: K2 S5 g& L5 ?* F! G+ b, W
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( W/ @& P/ V8 {$ n+ g$ P
.leds = da850_evm_tl_leds,
) A( ~5 o+ g& h0 T .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 y% V+ p/ `- p
};
1 O( w, K" R: h0 ~6 j* S, K
& ~3 q5 [$ T0 P- l. P! P4 o' v7 Zstatic void led_dev_release(struct device *dev)
& D( m: z! u; C5 R* E{
# i6 e$ t( Q: q" w, X( k/ S};, v6 \9 @! }. [* W# P2 H
) R# c6 d7 f& |8 g7 _+ x
static struct platform_device da850_evm_tl_leds_device = {
2 b5 j# O% O0 O8 T .name = "leds-gpio",, y+ \/ z# u8 k$ P% f/ |3 f
.id = 1,
+ W& |7 p- w2 A: l* J$ C2 F" b .dev = {( r/ e! _. X1 E' J" B
.platform_data = &da850_evm_tl_leds_pdata,( U4 G2 N( F+ h/ ?# r+ ^
.release = led_dev_release,( f. g" m+ n+ k# N
}! J" C" c" d+ e1 P9 H0 s
};( b. P. s- n5 j5 Q/ B' ~4 q! [
W& m b9 ^' zstatic int __init led_platform_init(void)
3 G% V3 ~ x9 l& M{6 `' k7 f- O, t! u: u
int ret;
7 j& C2 {# o8 j$ L2 j, h#if 0( X6 s) w+ {9 ?5 m, W
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 z/ X, Q) W5 P6 P6 S( H if (ret)' ~; h F* i$ p/ f4 k
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 K: b. j( q/ ]# w. Q! K
"%d\n", ret);
5 E% v. R, |& E#endif* S: t8 f( z( I, Z
ret = platform_device_register(&da850_evm_tl_leds_device);
4 @+ T2 t3 j" i5 I4 i. F if (ret)' T$ L+ P+ R" b! v% ?2 R
pr_warning("Could not register som GPIO expander LEDS");6 n, h. O" o5 V- |
else
+ _ J& `7 z" ]5 V. g; A printk(KERN_INFO "LED register sucessful!\n");
/ U' O# o1 j9 U( |+ R7 T- `
" v; M) n6 v9 Z) C" ? return ret;' b" F& _& v3 t2 n
}) p4 F9 G* L! e1 n( F* j/ s
0 X4 l5 f$ V8 z A$ Xstatic void __exit led_platform_exit(void)- m- l+ C- a6 J+ m0 ~& g% k% A
{! H' m3 |# v, _8 u- Z' _2 O
platform_device_unregister(&da850_evm_tl_leds_device);1 }5 q& T" P. n+ L p
; I0 K3 ^; i- S. Q& H4 R! U printk(KERN_INFO "LED unregister!\n");' l( L# [" f' P
}
( M* L. S% j# U; P( y- H
. F1 W$ e# G& P, {: }0 amodule_init(led_platform_init);% s) z1 s8 X+ c D) h) n) Z- e
module_exit(led_platform_exit);
5 _2 @& ~2 X+ j2 D% V1 R1 K8 L2 b9 @( t! e4 e
MODULE_DESCRIPTION("Led platform driver");- O* N, b) n4 P7 A& i1 W- w# T
MODULE_AUTHOR("Tronlong");
& Z* g4 j o4 hMODULE_LICENSE("GPL");+ s# e$ ~ u( I, U; r
" D3 l' U4 |6 F+ [; O0 B
|
|