|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 `0 e2 {% ]7 t4 |% f
#include <linux/init.h>
3 R6 U3 N9 W$ y9 q- B, M I/ L#include <linux/module.h>
( x! g1 {& y+ w$ D0 e#include <linux/kernel.h>$ w2 U5 A9 q! M- {9 I1 O1 Z3 c M* s
#include <linux/types.h>( p8 H( a: `" i/ x0 F- F
#include <linux/gpio.h>
" k& C+ Q& w6 a* }; O0 i# k' m9 i+ u#include <linux/leds.h>
$ L" q- T/ }# C, n6 g6 p#include <linux/platform_device.h>
2 E) ?: B; b- J" N' H
) M4 G8 z) k' T5 p& E. X7 U' ^#include <asm/mach-types.h>% u7 j/ a8 p7 j7 J
#include <asm/mach/arch.h>4 k# T1 s0 h) M. ~2 t
#include <mach/da8xx.h>/ Q" x8 N# g$ ?6 ?5 A# ^* `
#include <mach/mux.h>/ `2 G. n, J' s& r
$ o9 `3 b* L/ c/ M7 Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 L* V5 _/ e$ d4 E/ [" i5 V, X, E#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 ~) A6 y& y0 ~6 r) X J
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); r. F) A7 U, \" v
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! K" F" s1 W9 E; p8 A9 x& ?/ R1 C: M6 }
/* assign the tl som board LED-GPIOs*/
" B0 L) _5 ~( e! M' pstatic const short da850_evm_tl_user_led_pins[] = {5 V! ~* u+ W& q9 ]. \
/* These pins are definition at <mach/mux.h> file */
2 @/ G8 P, O, q* | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. T. I' z6 }' x) u
-1. z8 c% C4 A, p" G* B9 w4 o
};
( n1 }$ H, z& T2 \# p* \& W8 W
5 w# r+ x- }8 }( lstatic struct gpio_led da850_evm_tl_leds[] = {" s$ m* Z: ^/ M9 B2 p: Y) m- G
{& \; `7 s- w7 H+ Z# Q0 |4 d
.active_low = 0,2 W% v2 V" W4 _: q( p2 F
.gpio = DA850_USER_LED0,
7 U# `* R0 l* V' L) m% H5 ?# _ .name = "user_led0",7 H/ V. { X2 E2 B- [" t
.default_trigger = "default-on",. |; S( A0 u- x# o7 X2 e
},4 @/ `+ ]; a( ^1 S3 K5 q
{
8 w, D" D+ A, T/ m! J7 u .active_low = 0,
7 |$ U o& i! ~ .gpio = DA850_USER_LED1,8 r& Z% v$ n6 B
.name = "user_led1"," ^0 _) z' s$ h" X% i
.default_trigger = "default-on",# t7 z F4 e3 h$ J. O3 H
},
1 s; |# Z% |( r {
9 j; T4 g, I d. k3 d4 i6 { .active_low = 0,
+ m' N5 }1 \/ S .gpio = DA850_USER_LED2,$ S! g, e3 H2 ?2 g& _2 E- L
.name = "user_led2",/ R' M% l2 ^8 o! ~ ?% ^
.default_trigger = "default-on",' `* }+ L* V4 t( }/ x" ~8 B" `: m
},
" A$ f9 J6 {3 E& }4 O# F& o# h' Z7 s {
; D1 C; k4 ^% K# X2 @. m. B .active_low = 0," n3 n# z6 p- j; k
.gpio = DA850_USER_LED3,
3 u' z$ E' y- p3 L3 J .name = "user_led3",
" e2 k8 _* ]9 L& W2 Q# Z .default_trigger = "default-on",8 j- l, P8 W% U! @4 t
},
) p/ ~; H. F9 }& @2 s0 K};9 X! ]* {$ ~: y+ }' Q
, R* y' W6 T7 L; _- m& D7 J. s
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 L2 ?- ^1 D2 `; U3 x8 J$ g6 P
.leds = da850_evm_tl_leds,2 q0 p0 |) Z- E/ a( x0 |
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 Y. Q$ j% r. X( \
};$ j S% g& ~8 @
8 Q3 b6 y% j" `+ h! j0 }9 D
static void led_dev_release(struct device *dev)' p1 H$ f$ k q4 a, V
{
% c/ ]) V9 Z; Y+ Q& N t. ]};
2 s! t u/ l/ y! _9 Y/ K1 E6 Y/ d! y! G8 d. A4 z
static struct platform_device da850_evm_tl_leds_device = {( [3 [1 Q3 @) }) t4 M0 S4 B
.name = "leds-gpio",
( R1 n* i5 h1 G2 O' O/ z% f' H2 I .id = 1,% @1 b+ j; k, P" u
.dev = {! R4 d0 {$ B6 Y9 V" r' e) ~
.platform_data = &da850_evm_tl_leds_pdata,
7 ]# P( x2 H- t8 U .release = led_dev_release,+ e2 s3 ?5 F6 S0 J1 z
}
8 ~' p# C$ _( T- T2 q: Y};; |9 w* o- ?/ d* n' `$ V8 s, Q# N
, t1 ?; Y) ?4 M) G1 vstatic int __init led_platform_init(void)8 o7 O2 Y- [9 P& r* b7 v- f
{
2 A. ~% f4 {" U. B int ret;
0 r& r7 {( t5 K, q) ~( V* X$ R#if 0% h5 a! C" S! t0 r8 G U- Q8 i" L
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 c; i- |0 L( y% o/ q/ W# [2 g
if (ret). c- d/ H, s: W3 y; H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- o* [* x5 z. @ B
"%d\n", ret);
* g; y: i: o5 T4 X9 _, q8 n#endif+ f5 D/ n4 v$ y4 n I
ret = platform_device_register(&da850_evm_tl_leds_device); O/ \1 u* q9 j8 j% ]% t: x% w
if (ret)
$ Q( R8 x$ j$ n, a1 k; \ ]' H pr_warning("Could not register som GPIO expander LEDS");
, q! r, F+ `# @) Q" t else! b8 ]( c" k5 C% M1 ]
printk(KERN_INFO "LED register sucessful!\n");# ~5 ?. ?- K$ y1 R! I
& a" R/ i( L0 D2 F; J d
return ret;
1 i$ |2 L2 d* d1 U}
* _/ z% I# ~7 [; \1 \3 @: r8 Z) a
3 z5 w+ ]: x! w l9 ustatic void __exit led_platform_exit(void)9 [3 x0 ]- v* T8 N, \
{
& E2 |2 [, |- B6 X" N platform_device_unregister(&da850_evm_tl_leds_device);
9 O1 I3 S& o. ^: G9 ^, @" \2 W; K8 I6 U, d) A- ? O7 F
printk(KERN_INFO "LED unregister!\n");& }4 `, |0 j, u2 e5 T
}
6 R4 C1 N+ b- L% w1 R5 ]( G6 L( \3 }! U1 z
module_init(led_platform_init);. J5 U% j; t2 T3 V
module_exit(led_platform_exit);9 P1 {: h2 g' `+ g( q
. ~/ [" Z# L6 V5 r" I
MODULE_DESCRIPTION("Led platform driver");
$ W+ s/ f: s, f7 F; V* I- r" HMODULE_AUTHOR("Tronlong");; t+ ?2 q2 q8 M- y4 g
MODULE_LICENSE("GPL");
* D1 v# ~& c% h; a
9 r! N( C4 p! Q ^! b* X z |
|