|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, l& M2 Q/ X3 o; b2 w0 P: Y5 x
#include <linux/init.h>2 a" g# |: `, o( |% {3 a/ E
#include <linux/module.h>, a+ [1 ~- M* k; H8 H3 H. G
#include <linux/kernel.h>5 X) \ i8 ^* G
#include <linux/types.h>- x4 O# V. A) j$ P# ~8 D
#include <linux/gpio.h>
) E$ A' S% l O4 F#include <linux/leds.h>2 A* W/ `: |7 X7 s4 ~) Q
#include <linux/platform_device.h>8 l- p. r8 b3 s! U
; R5 I* g0 Q! g" o# L( l _#include <asm/mach-types.h>
t4 p! v* S6 y0 z8 }" @9 @; T; z0 J#include <asm/mach/arch.h>
$ c3 ]8 U6 ~" X& O#include <mach/da8xx.h>
$ k; S0 n6 l4 ~/ ^#include <mach/mux.h>( t8 a2 c0 R4 p$ x
' U5 W' O* E! P9 q9 D4 b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' @2 b% ^6 U# M, L0 p
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" e# z) H# `8 W! ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 ~& Y4 q+ v! [% V ^$ S#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# e4 T t' ]; i5 _! E% a7 U
! s, U' N0 \: s3 \
/* assign the tl som board LED-GPIOs*/
, O" V: [9 } K5 d" Z9 _8 \static const short da850_evm_tl_user_led_pins[] = {# ]% H& w N) t, C9 j; ~9 d. K
/* These pins are definition at <mach/mux.h> file */* G5 b' f: x% K0 L% {9 ?4 h/ @
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& u4 @$ [/ X8 s
-1- X. L" T0 P) h$ y" x
};
% n* B! _: R, S! _! j/ S/ W( L% A% j* s9 w2 @
static struct gpio_led da850_evm_tl_leds[] = {$ Z; X$ R; O( U0 _( |
{( p1 W, ~5 t( _( W; }: f
.active_low = 0,) g+ n+ V9 F/ ]/ y$ h
.gpio = DA850_USER_LED0,
( S# T* {1 b% {* X$ z# v .name = "user_led0",1 `+ o! }/ m1 B
.default_trigger = "default-on",
9 r! h8 U/ S- P },
) J, {. Z7 S" _2 } { {% S0 h3 R- j8 `
.active_low = 0,
) d* Y2 {0 B: Q8 F _% j/ l8 _ .gpio = DA850_USER_LED1,
8 ~7 N. g3 r9 ~6 r2 G, [" t) ]. l .name = "user_led1",1 B# E9 K# {3 I- O" H
.default_trigger = "default-on",
2 j z) a% @; R! o3 \1 b! w },5 ]' O6 ^! s8 s0 z
{' f7 \0 f; J( @
.active_low = 0,
) l9 Z: h. R3 S1 d7 f .gpio = DA850_USER_LED2,
3 k0 Z- Q/ w8 q- i- ?+ r, l: { .name = "user_led2",3 m% A8 o! q0 N5 Q' O5 R6 J
.default_trigger = "default-on",
( h% q$ G, u: g. V8 T; n8 ] },
2 |) f- l% ?# O6 B1 t2 _) V8 f {' E- e) s' n: l. f) a2 G9 C& g- f
.active_low = 0,
8 C% L3 L p. }3 T .gpio = DA850_USER_LED3,
5 |) r, q1 j1 t5 F$ N) S! a" Q .name = "user_led3",
* v @+ W! ?9 U- H2 ] .default_trigger = "default-on",# B( u% s( { ^: r# E% y: u5 \
},
7 O ?5 N$ _ t% H) f, @};
( A1 j' \$ E8 |/ N4 G! J2 X/ ?9 f' y& b0 K [" q2 I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 M" R% e9 n* R) d+ K( d9 F, N .leds = da850_evm_tl_leds,
6 {( R1 `2 ~+ z0 r$ A+ S .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 T2 d1 B. A1 C, D7 H
};' S; c9 y8 A0 }* F
1 \! v! U8 O! u% f8 i$ u& E( ~static void led_dev_release(struct device *dev)
2 e) b: D1 ?) f& q. J2 @. [{
" w( p" T4 y: Z! d$ L9 ?% {. @};
% o8 o( ^ P# O. Q# I4 f/ F" {( z! Q( l$ ]. V
static struct platform_device da850_evm_tl_leds_device = {
; E7 w; z$ K& u) D# z$ W, M .name = "leds-gpio",* P9 l, g) t$ v3 D/ U, f2 k
.id = 1,) w0 A: u# `3 K4 p6 ~9 h
.dev = {
8 Q, M) B3 T2 v( ]+ {0 e+ w .platform_data = &da850_evm_tl_leds_pdata,
: c) @: H# U/ Z. @$ T .release = led_dev_release,
; d( D; ?3 a% i2 X0 Y4 ~' y }% C b( \% `4 d
};
; \8 h0 j) A/ F4 g5 v0 I
7 s9 b( U n* I6 j1 w0 o% _" f9 fstatic int __init led_platform_init(void)/ K+ |- O3 s. U2 X0 u
{9 Z* g* E6 ]5 b, a
int ret;$ y+ X7 B' g8 L& }
#if 0. P% ~6 X; e0 a$ @$ x5 m, X
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' a5 ^7 ~* K# u" h7 @" G( t3 d if (ret)
. D c9 e3 R. Q& l8 u# M pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 n& D1 {7 p1 H2 v9 o( z& {7 g
"%d\n", ret);" f+ h9 r1 Z) b, t
#endif
9 \+ S5 \) q3 u/ A" ? ret = platform_device_register(&da850_evm_tl_leds_device);5 h% a1 X, Z# T @
if (ret)3 b9 ? R0 a8 ~$ k1 h& L
pr_warning("Could not register som GPIO expander LEDS");4 ~2 F# P4 n$ {: @# i8 L
else
0 H- M( Z1 T9 A, y& j printk(KERN_INFO "LED register sucessful!\n");4 _5 u4 W/ X c4 s6 U
" U9 o* W2 {9 B2 P, Z* j* I return ret;
6 z* m% t# {- c" {; |# T# i}8 r% e" B8 M' \2 b) Z7 Y5 z
; r2 H; G2 r5 @* E! s* x2 S& d
static void __exit led_platform_exit(void)
% E8 {" T- L: M8 T{: N" [0 V: ?, x
platform_device_unregister(&da850_evm_tl_leds_device);
6 |6 b9 \% L \7 \+ h, h% ]& V$ a+ j4 x8 J! g. B4 b
printk(KERN_INFO "LED unregister!\n");" s3 h6 {! m% A l! \
}4 E* h$ _/ ^- J+ u: g
. @) M1 Y% P8 v4 [# H
module_init(led_platform_init);
; R( x" d4 c: @; d/ cmodule_exit(led_platform_exit);" E$ n; k2 V% \8 }8 f" T
: j8 G" o1 R0 i5 Y. BMODULE_DESCRIPTION("Led platform driver");9 k7 a. }9 b! _8 h8 N9 W6 |# B5 E) }
MODULE_AUTHOR("Tronlong");
3 C5 n# c" t2 v+ e0 L/ _MODULE_LICENSE("GPL");" Y4 j% W5 Y) x1 _! Q
5 _: _& [8 ~* J7 J* [ r7 {5 p
|
|