|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ m3 Y# j m# u% {#include <linux/init.h>
7 e8 [0 r! x6 H3 V6 ~2 I2 P#include <linux/module.h>. r% ?( A+ J- \6 j: F" L
#include <linux/kernel.h> t) ^' M# m6 j5 J6 c
#include <linux/types.h>" [: y/ F8 W/ s! M% v
#include <linux/gpio.h>
! h# L1 m/ D+ B6 Q#include <linux/leds.h>* p7 t# s ~, ]5 z* z
#include <linux/platform_device.h>2 K8 {5 D8 L% _$ p6 m8 e
) @2 i. h/ f0 l" w% t#include <asm/mach-types.h>
3 D& G3 G' ?; E' P3 g6 t#include <asm/mach/arch.h>
- D' m8 X) }: E0 x#include <mach/da8xx.h>
+ y0 u( y+ Y8 s$ Y#include <mach/mux.h>
" C6 C. h, @1 c+ n. @8 X1 [1 F: z2 t- T" E
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% G2 t7 v8 x: l- A) x* Y7 ~
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& f4 q- { ]! W$ l8 L' d6 U0 @/ g#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- O7 ^! b2 I# q% q$ Q# L! h, H3 R#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 p4 I/ q( `+ d( ?" L2 y" p7 B8 v. `8 D: X
/* assign the tl som board LED-GPIOs*/
- [2 I9 d! I/ w' g! z# C* g: @) dstatic const short da850_evm_tl_user_led_pins[] = {
8 |: H- j# x3 y7 X /* These pins are definition at <mach/mux.h> file */
5 m0 n% x7 ~ ?$ o. A DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ N8 `4 ^% {& @2 q* T; m/ S. x0 E
-1
: E/ l0 N% I7 k/ M$ R};
4 r% A+ }5 d( b- k, k
; ~ w0 m6 J( N( ~+ _& G* f& z5 l3 }/ astatic struct gpio_led da850_evm_tl_leds[] = {& Y$ Q1 D- W3 z% K) K" E
{( A* t0 r6 O/ n3 Z' X7 W4 ^& [
.active_low = 0,. n2 z5 G$ P6 U9 W, z
.gpio = DA850_USER_LED0,* e' _* i# c+ h S9 ^3 c" E
.name = "user_led0",
* N$ X/ B! ^8 x; U .default_trigger = "default-on",9 o. h; U" C' y' C2 S- n* B
},
* z9 |7 M3 R o {
/ e) p2 P7 v! l1 w$ o- s' S; ]7 T: [ .active_low = 0,
7 n8 ?4 m k T# ?6 i .gpio = DA850_USER_LED1,1 f6 R8 p d# U0 I7 c
.name = "user_led1",$ G6 |9 l! l- T+ L. |) \: b
.default_trigger = "default-on",
- ~8 m; y, O3 s2 O7 ]+ f) S },' t4 M; P2 z) L; }% C+ f8 l
{
) Z8 W; v2 ]4 k) p5 o4 `3 D .active_low = 0," d- O5 b, ]% F, R! W! C* e) r# V Y
.gpio = DA850_USER_LED2,
' ~: T/ K, M/ f) Z! O .name = "user_led2",
6 P0 z9 B$ B* [( F .default_trigger = "default-on",
% @2 k) q0 K% r },' g7 I1 b( N: ?; p V* x4 g$ l: J
{& r7 Z+ e. Q9 v7 e+ a( z
.active_low = 0,( t8 M/ P6 C9 l' D: v2 J! ?% m
.gpio = DA850_USER_LED3,5 K; e4 V" l2 D( |% h% Z6 ]; S5 @
.name = "user_led3",
* `0 t# d2 U3 e Q L9 r .default_trigger = "default-on",
$ y- ?( ~. b- q* N0 z },( ? L; }& ]5 ?3 a/ a. J
};+ L) _2 O8 h5 ^: t
2 ~) X& N. ~0 r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( {( n9 }# q# n/ r8 m9 s [
.leds = da850_evm_tl_leds,3 T: c) l; n9 N1 J
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ E( T3 N3 k S; S( d& H- v
};
, ^ Q* W% O6 k1 t; r! B1 Z& n B/ i
static void led_dev_release(struct device *dev)
, r3 h k& c) t) L, c% `+ Z{) a4 J o7 r3 ^2 W
};
: e* a* r0 d U
6 \. j0 }7 s- f2 K2 |static struct platform_device da850_evm_tl_leds_device = {/ x0 s: e* K4 T! m' i" S
.name = "leds-gpio",! B8 D, B% ^* N) S
.id = 1,
& ?" A% D0 p5 f/ E: l6 V( y. {8 h .dev = {0 X$ H& V7 K" c1 X& h/ }
.platform_data = &da850_evm_tl_leds_pdata,* s* y; _! ` }" A% ~8 [
.release = led_dev_release,
1 [) a- J- V! y' o: R# x }8 e$ l; o/ e1 H8 G
};
9 y, ^! _. i8 q( V2 D$ h3 H4 I8 J1 _ [+ w. q7 r
static int __init led_platform_init(void)
% o3 U, [" a: d: _% q{
* t N& i2 X+ S& G# R/ C8 } int ret;2 r8 f" N& [/ X/ r
#if 0+ w, k- A0 \4 F' y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 z1 V7 m9 h! M- Z" d3 \2 E
if (ret)7 D- t( E+ U, X7 t8 i0 e
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ u4 I" K, N0 A2 r "%d\n", ret);
6 A2 N- p0 y U& f#endif& p; G2 W/ Z% U3 l z0 \) \
ret = platform_device_register(&da850_evm_tl_leds_device);+ L/ N& y8 w' W$ k' ]* V4 w7 i
if (ret)
9 D+ Z2 W }' g! K pr_warning("Could not register som GPIO expander LEDS");
q/ W. |# J9 ]7 C8 q+ ^) g else
1 D# b C+ P2 w, c$ R printk(KERN_INFO "LED register sucessful!\n");0 _) Y+ f9 e+ u# x
: S1 g# h+ z8 w/ f& n% b b* a
return ret;
; Y% J- I" f6 A}9 A0 R8 l+ b& ^( @) e
7 B0 e! c; n% m6 Bstatic void __exit led_platform_exit(void): Q% c! Y3 D7 a$ j! |+ ~
{
N2 f- }" P* X0 M platform_device_unregister(&da850_evm_tl_leds_device);
5 l" L7 h/ Z7 B4 U. M3 l- ?0 F/ U6 O5 e9 V0 v5 O
printk(KERN_INFO "LED unregister!\n");
0 M4 V3 L! H1 h! U3 x5 q3 T9 ^}
7 ^4 {% i- Q" F- B9 r; K& x) O, _3 k7 J8 l; V! Y
module_init(led_platform_init);
3 ]. Y; ]6 y2 |4 Z8 {: Vmodule_exit(led_platform_exit);) B) N- @, C; N X& ^+ ^ F
$ `8 l* |- l6 U7 b l& b: x
MODULE_DESCRIPTION("Led platform driver");
4 g/ y: W# A" z; l1 B% D5 IMODULE_AUTHOR("Tronlong");. X+ d+ f) Y9 ?6 b% X
MODULE_LICENSE("GPL");! G$ L$ W/ B) `- i# H. U
/ k: t1 c; I9 [ |
|