|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& b6 T) o% w$ R4 e) H- B+ ~. c
#include <linux/init.h>. r" C2 j1 P1 B4 `( f
#include <linux/module.h>
3 V* z: ]2 [0 a; @3 d! F#include <linux/kernel.h>
0 ?. R: [, ?. A5 p2 Y. P#include <linux/types.h>
# [ T' H$ @9 K& f G" x#include <linux/gpio.h>% r" p P! _" V( N
#include <linux/leds.h>
- R; _' J, i/ _( j#include <linux/platform_device.h>/ I0 _$ }: D: [8 h1 x9 N
! h6 d" y0 u7 v
#include <asm/mach-types.h>
0 J3 O; n/ g2 f3 }5 x7 V" u#include <asm/mach/arch.h>6 M! o! D) X! @, ]- ~$ [
#include <mach/da8xx.h>
' f; p. `, V2 m* n2 L+ a6 r#include <mach/mux.h>
! l4 g! q" t7 Q8 x$ _+ v2 F- N A, n1 Y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ J6 F2 R7 |6 Q9 U+ i- H% u! L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ ^4 ~. {4 G) N#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ y0 t! g( @: e3 `/ \. U
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' z( h5 ]2 `% o. \, t, P7 O& s) e
4 Q% |0 M" M4 ^" C. M6 K/* assign the tl som board LED-GPIOs*/ L% u: f8 o8 A$ f9 d$ L1 p3 X
static const short da850_evm_tl_user_led_pins[] = {
3 \0 Z% o8 S# `' Z! Q' b2 r9 }9 C /* These pins are definition at <mach/mux.h> file */
: ?2 I8 d. [" e5 K, G; T8 c DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ Y3 V' M2 c; ~4 m6 x1 o
-14 F: K" E/ a- \& s
};
( t1 k( H* U0 ~8 z1 {. I3 [- p' L, K: r8 n$ D N- F
static struct gpio_led da850_evm_tl_leds[] = {
( U+ a v1 @' g {5 G# {5 C% G. e8 {- K
.active_low = 0,
# {. e. r9 v8 a H! h .gpio = DA850_USER_LED0,
) {3 Q; o4 n# W {$ M .name = "user_led0",) N3 L8 {3 Y3 ^# {6 a* O( v
.default_trigger = "default-on",
) O3 B: F3 V: c8 | t/ @ },
5 }: o' M5 U; N- B/ [4 x {
0 A* L% d: [5 U .active_low = 0,2 j# Z0 w. ?8 J) e8 [
.gpio = DA850_USER_LED1,
2 O9 L! D4 M" @. g4 ` .name = "user_led1",
; `6 f" `0 N1 W .default_trigger = "default-on",# z/ @3 W N, ~# C4 y/ l0 m
},
' U' y. {, J# ^0 m+ B8 A% x {9 L- D9 H/ G3 L i) m# P; j
.active_low = 0,0 t. \( w$ C9 _
.gpio = DA850_USER_LED2,
# c2 A) @9 p+ u5 f; r .name = "user_led2", d+ `0 B& P, w4 u6 X- H
.default_trigger = "default-on",( C6 W0 G' @! R7 n
},! i5 v7 t5 u% \, e5 n* m
{4 j4 k. ]9 x( f$ ~6 }+ _
.active_low = 0,
% w9 {/ U, w# o6 ?4 T! |! x .gpio = DA850_USER_LED3,2 j( Q8 {4 R2 ^$ v, ~( V
.name = "user_led3",$ C7 T0 u8 R* `1 o/ a$ ~" u
.default_trigger = "default-on",
8 e, N- u5 c2 R9 ?4 m9 g3 q: n5 B },
0 v$ F) }. e: }% n2 k" x, `% j" y};4 s/ a5 J" s2 l! ~: n3 H
- J. F# U' Q) {$ \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* f% G* [+ L7 N7 s0 e .leds = da850_evm_tl_leds,
' I( ^$ X( w: V+ m7 y- y .num_leds = ARRAY_SIZE(da850_evm_tl_leds)," g1 r. U! K* l% t5 D# R
};
, N7 \5 T( W8 ]+ P! p% X2 D( `, ]5 C" G
static void led_dev_release(struct device *dev)
l& h. B8 C. d{
7 b3 u8 I. i: D) k5 X& d f3 l; J};$ W' G3 s% n9 P* ^8 \4 q4 n# f4 H
C, u/ V5 {, N5 estatic struct platform_device da850_evm_tl_leds_device = {
8 }6 t' r1 X8 s .name = "leds-gpio",
t% t: K0 j2 P8 {- U2 o .id = 1,
% x. i4 r' @# E .dev = {
* P- W/ A: u& {- a* T. |- I .platform_data = &da850_evm_tl_leds_pdata,, e! O8 a9 Q) q6 U+ _6 l
.release = led_dev_release,
6 P& m9 n% H! X9 F, O }
6 V4 z7 \1 C3 p' K7 n- U6 j! p7 e7 t};
; z+ {+ i8 c/ X/ X1 u# k; H% Z2 k1 k* G& L; A& g
static int __init led_platform_init(void)
3 {6 g5 V4 E1 m- t( S{
3 }3 Z/ }4 S3 x% P. G& C+ U int ret;( L) m5 g3 l: D
#if 0! M$ I" V& R# q$ N, }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); q$ z% ?4 s3 [: B9 `0 d" |
if (ret)
( u/ g- f* W) ?* l% n1 [8 A( [5 U pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 L- a. t [* Z4 J
"%d\n", ret);
2 A* ?2 P! n) m6 U; v) P#endif
$ t' z9 p& h Y+ [9 S( V ret = platform_device_register(&da850_evm_tl_leds_device);
9 g+ }1 t! E3 i& _/ P if (ret)( r1 z% ^, Q! B9 t4 s
pr_warning("Could not register som GPIO expander LEDS");
6 Q8 ?2 t( R- |9 P2 R. A j else
- t2 C# `5 m- ` printk(KERN_INFO "LED register sucessful!\n");
" {+ s2 x7 T8 g, E* C! a* n& ]' X& {/ ~5 t! X* W% j* J+ D
return ret;
) h2 q9 c1 O6 c2 x5 P5 e, a9 b}
* f# V; s* ~4 n' U4 m
6 b3 U1 P9 g* ~% a1 |static void __exit led_platform_exit(void)
) w$ F/ f( p! J7 L+ P9 v3 |) h{! L' R. {7 f& g, A5 N& G% Z6 Q
platform_device_unregister(&da850_evm_tl_leds_device);! K7 y% S+ O1 q3 g: ]
) p: z' X( H/ }
printk(KERN_INFO "LED unregister!\n");
. V f C* o. K! k, @) Q+ V}
! ~' d/ w8 n/ ?2 O$ f+ [; b" s3 F. O
module_init(led_platform_init);7 W$ x: c' w% ]0 F
module_exit(led_platform_exit);7 o8 D0 `7 D: F7 i# u
6 i1 Z7 \: [9 F, B4 q2 ]
MODULE_DESCRIPTION("Led platform driver");
- r5 i/ O8 p( c0 I" N# z# UMODULE_AUTHOR("Tronlong");
' M y- o& B0 \! `& g9 {MODULE_LICENSE("GPL");/ ^( Z# Z. t: k, I( V4 e* |1 m
+ E ?+ {& ?; M2 `' K+ \* o5 ^
|
|