|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* ]! }' o7 Q& t$ i' E: E6 ^+ f. I7 z' F#include <linux/init.h>- R% _$ N" g' K5 X5 E6 X0 X% c
#include <linux/module.h>
f6 S, O- d0 S+ ~( `* g: q#include <linux/kernel.h> H4 m. ^0 t5 |
#include <linux/types.h>
6 h% Z2 N9 J, d#include <linux/gpio.h>; U6 c) ~5 Q$ `5 B
#include <linux/leds.h>& t% Q, w( \1 d& V, M4 `: O9 j+ o* F
#include <linux/platform_device.h>
' i' j7 f' o; _% z$ X
% b# _2 x; ~5 I) H#include <asm/mach-types.h>4 n% ] [$ z) B, t* x; h3 W
#include <asm/mach/arch.h>
, o F0 L+ S" w8 ^0 d8 r#include <mach/da8xx.h> T* m! y- W2 q& z% l& Q Y. j
#include <mach/mux.h>
8 r) H+ M& D5 E H9 N U+ b% I, @7 b
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# y4 P6 K7 ^: B0 ~
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 ^8 C% g5 K# X#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& l' {/ Q& M- }- v, |# K) \1 ~# E0 U#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 _- x, M0 o, f' j5 s, l7 x- W: L8 L; c
/* assign the tl som board LED-GPIOs*/: u5 F5 Q- a# G6 h! c
static const short da850_evm_tl_user_led_pins[] = {
; q" ^& [, \$ v. T, y& m t! W /* These pins are definition at <mach/mux.h> file */
# T9 l. W# d4 g4 ~ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( ^- e2 {# b" f% ] Z% T -1( e- e V5 ?& F0 s% Q% g
};
* `2 S" F( \+ _6 [4 |( K
3 x- {% T5 ]% \9 v ~4 estatic struct gpio_led da850_evm_tl_leds[] = {* {1 \) C# J# D
{
6 ]1 e8 \% N. ?0 c, Q5 s9 { .active_low = 0,6 u& G- V- x, U5 S$ L& Q0 B& o
.gpio = DA850_USER_LED0,
, J+ E3 o/ E- D( N4 ~ .name = "user_led0",
' _- V4 O. g9 o/ h .default_trigger = "default-on",
/ j" B6 r( q& n( G( \ },
' I4 N; u5 w. Z3 ~+ C6 } {8 H- ^8 ^4 @/ y
.active_low = 0,# \1 _' Z( W5 S9 k0 i8 m
.gpio = DA850_USER_LED1,
# d8 S8 Z6 O; T# _ .name = "user_led1", U0 _- L2 u2 [: D/ \
.default_trigger = "default-on",$ n. y6 S* k0 s
},5 k0 c c3 H2 }( N/ E
{+ P2 f; m' p! U; R" K! n( u; U H
.active_low = 0,
% x- K$ U* u$ D0 b; R( G .gpio = DA850_USER_LED2,- h! D, m- Q @1 ~. m
.name = "user_led2",: Y6 t) R0 Y& e& H7 Z
.default_trigger = "default-on",
. L8 r9 Y) \0 c# I },
. D" s, K g+ W {
9 |& x, t6 h, @6 ]9 b .active_low = 0,, F7 ~/ `9 `6 R. H* B' p
.gpio = DA850_USER_LED3,
& c! J! \# ^" J- [5 R .name = "user_led3",
( f! V. L0 k5 J) L* o x! U .default_trigger = "default-on",
3 o$ c" K$ x$ L; K+ b },& J( p" v+ L* l2 Q2 i, G2 o
};
* t8 U+ S/ ?9 d% N9 t, q1 _6 ^# W$ L- d- j% }
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* F2 l$ `/ O5 p2 _, h& ^; u# M" }
.leds = da850_evm_tl_leds,
8 G; ]5 [- b9 U4 R( J .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) u- h1 M. X6 d+ n$ ~+ B0 D5 T9 P};
! D) o8 K5 R# v2 c9 K$ M8 s1 F! r" Z: K" S9 C0 }; _0 t
static void led_dev_release(struct device *dev)
- I. `" n- A/ \( S% G. I, q{4 J0 T) Z, S# c/ E' C. _! O* A
};
4 P, _0 ]: y% Y8 Y" e. ^
$ K% \( q. A; Y. Dstatic struct platform_device da850_evm_tl_leds_device = {' L6 G7 j0 h7 s' }( W, j; a, ]
.name = "leds-gpio",
6 x3 ]6 K* j4 T .id = 1,
7 s+ |' Y: q- O' u, z+ I3 [& W .dev = {( u1 v5 O3 }- r8 f: \
.platform_data = &da850_evm_tl_leds_pdata,
. r- b; D* a D9 v; g$ G .release = led_dev_release,& [5 b6 W! @! v+ H1 j
}: M% N1 X! ^& q' h
};/ [) W+ o) v A) V% v# x5 i; b/ Q
; b, c# T9 R: l% H4 mstatic int __init led_platform_init(void)
- A! F, f* v$ e' G% K% }{% |7 a/ j u+ i, G
int ret;
) E5 p7 a1 M- O2 u#if 04 y5 I8 G" `: }. ~* ]9 Q" ?, e
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 i4 e+ a) j/ s' z
if (ret)
/ I' c2 o( e: m2 x# A6 I- F pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 |, Q4 D0 x1 u/ L! @
"%d\n", ret);9 L4 [4 \3 P. h, ~) f
#endif
/ U% I7 X8 e9 g+ e6 P+ i3 R% U3 x ret = platform_device_register(&da850_evm_tl_leds_device); J3 i# w5 x- S1 L, E' X' z
if (ret)
+ ]' f! U1 _0 ` y' K pr_warning("Could not register som GPIO expander LEDS");2 q4 M( {4 f% j& O4 j
else
$ Q% D: K0 n( @" U) t; y" [6 { printk(KERN_INFO "LED register sucessful!\n");
; M7 h3 x0 B! w {: ]1 W, N O, E5 ~& m4 K0 X0 u: m, D" I7 U( w
return ret;1 ?" ]! O; h4 G" n3 x
}
* R/ [6 A6 Q X' P1 B/ ~7 `2 m+ A- f1 z3 x" u
static void __exit led_platform_exit(void)& Q: @4 g I) Z8 z) J% Y- Q
{
& |6 L/ l4 {* r% R/ ` platform_device_unregister(&da850_evm_tl_leds_device);: [0 j$ H6 @: z- w8 N, U' T
7 \* [3 ^2 a8 Q! h2 P9 ? printk(KERN_INFO "LED unregister!\n");% p Z9 n5 y m6 Z( d* e+ x
}
( v3 z) a% x. ^; d+ \5 @) C1 E L( {+ }6 e$ J
module_init(led_platform_init);
: c3 z& X: b$ L% ^3 p5 Jmodule_exit(led_platform_exit);3 T/ n. Y$ M! {% A" l/ @ M' M
4 b3 ?/ P' k, P3 d6 } r) R# U6 y
MODULE_DESCRIPTION("Led platform driver");
. ^( \0 x H6 \; l; E: oMODULE_AUTHOR("Tronlong");" t6 m( z( v i; b
MODULE_LICENSE("GPL");0 s& q& r# j4 b3 x9 n4 d, b$ j. O
# R, x' U6 N; i& r. T: x* Q
|
|