|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 j; _- F. F4 u5 S. ]
#include <linux/init.h>
! j6 s( a7 S4 x: o#include <linux/module.h>$ [3 X8 ] z3 b' ?, S
#include <linux/kernel.h>
" l4 C/ D& x# A+ K/ [+ Z#include <linux/types.h>8 S# f0 o# s& P, A
#include <linux/gpio.h>
& J8 y$ I* G: D* ~) o1 Q# p#include <linux/leds.h>
# d" c' v0 }, ]/ [#include <linux/platform_device.h>/ m( N X' z1 q
& I% j2 B2 E/ ?, H; l+ ?#include <asm/mach-types.h>; @. k/ r. \8 a3 j; l* j7 V. w
#include <asm/mach/arch.h>; o: L2 S7 p! x- a E
#include <mach/da8xx.h>* \7 o. H7 o8 r$ X) U
#include <mach/mux.h>- R% @ a8 _' s$ v
5 E' j% L; Q# S7 W5 j3 D#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 [, L5 F2 N8 _- Y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( s' a5 o3 c2 Y3 _! y4 u5 u+ B#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" w$ M% }. O0 [& m4 o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, e% b- E5 E& L- @, V
5 f* \' s q/ C. |; c/* assign the tl som board LED-GPIOs*/, G2 W _2 P% e% Q9 M+ D
static const short da850_evm_tl_user_led_pins[] = {* N2 |* L8 o- ]& ?- g
/* These pins are definition at <mach/mux.h> file */7 I0 N) M$ L2 v0 T, |
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," W0 n, ? f( U d8 l/ y7 u
-18 U8 Z4 E. ?/ w5 I3 f
};
& G0 H5 T) M: i8 r9 m3 V( j* m$ f4 P
. N. ~- |, ^, @) S/ @- r# W" estatic struct gpio_led da850_evm_tl_leds[] = {
' R$ _ H( N4 p {
G1 a; B6 k c& E+ j) N& F! E .active_low = 0,
. ?% t F6 [9 r( t' Y- c ` .gpio = DA850_USER_LED0,
% E: ^; Q# F9 Y0 G; B, Q .name = "user_led0",) ~/ t s4 S' Y9 w
.default_trigger = "default-on",
: B" U: P( G" U2 e. L) T },7 Z5 J5 W/ d8 r
{' [& U! R* i) g9 U
.active_low = 0,: `$ N8 w) X- |. y9 M1 G( b# \
.gpio = DA850_USER_LED1,
, ]( ^$ @. K& ^0 } f# w) ~ .name = "user_led1",, [* ?' S' B5 i
.default_trigger = "default-on",( q( p- t1 I( C9 m; s) Q
},
" x1 i& D7 R# a) v {
9 K: D' _% W% _3 d! d4 I6 E r .active_low = 0,
+ G8 S6 M- z8 j# u, e .gpio = DA850_USER_LED2,
4 v: R! z$ j% h8 f! o$ V .name = "user_led2",( I+ w0 g; E4 F) Y4 [9 a
.default_trigger = "default-on",
. O6 O0 L. b$ H+ ~ },
8 e: x, b/ E7 \( v {
$ o$ D0 q3 Z& A/ S- g1 Y .active_low = 0, I/ ?( j* n( N- k: h4 d# c5 g
.gpio = DA850_USER_LED3, v7 W- O0 M2 I( g6 c+ d! f4 f
.name = "user_led3",
$ x& _5 E( i+ u& x6 M .default_trigger = "default-on",5 G$ Z. J8 X: C# j( D( i) z
},
+ \8 @5 r3 i0 I+ X2 x};
7 a4 F8 j E6 _
! J! @, e) L d- L" Z7 Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 u) C% z1 |2 h- Z/ `" w) a
.leds = da850_evm_tl_leds,
: h0 v( _: F7 `! m' o .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 O) G8 n1 R0 ~; O};
9 z2 y, ?4 d! K# J0 N& b$ r
5 ?. x4 {+ d- j# L( Q0 u1 bstatic void led_dev_release(struct device *dev)
3 H0 X- f) |. g7 h+ I{
: F- P4 u9 b9 B; A};& n; F& W1 m1 s7 ^
& p" o- G% H3 w( {4 V: ~* o
static struct platform_device da850_evm_tl_leds_device = {" m- F% A/ }4 ?) M5 D. L, n
.name = "leds-gpio",
; v' m5 |# g4 Q- P. G: J. q .id = 1,; n+ w/ N1 C0 z* B5 L
.dev = { D" r" h1 w% n; Q* s% Y
.platform_data = &da850_evm_tl_leds_pdata,
9 r- h& y. t- \" V, _9 j) t g .release = led_dev_release,* H+ ]# L N9 f1 Q
}
7 R' q. o3 U3 G/ a};
/ M7 f [8 c, a( ~+ b+ t7 D4 ?- j1 @/ a1 U6 w' N- y0 e& H1 K
static int __init led_platform_init(void)2 Y5 W- Q j, J& @( Q$ A0 n
{ ?6 z- s* |; ]( ?! m+ K9 x7 I( o
int ret;
3 Q+ {, y. W; \3 R#if 0
) G4 b8 A6 t4 p+ N ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 [2 r V# x$ T# i, `/ i
if (ret)0 `' d( ?3 |: t0 u. i3 S% B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: l, B% o. b% ?3 w% h "%d\n", ret);
* C. m& X( B0 z8 Z/ }2 Y& r( u1 x#endif
: b0 h2 d) D: Q1 P! D ret = platform_device_register(&da850_evm_tl_leds_device);
5 K& V: \7 w1 ]/ r if (ret); q5 C6 M/ U, o p) r4 t: N
pr_warning("Could not register som GPIO expander LEDS");
, Q2 `9 |9 f; R else8 r. c/ i5 J% @/ e- N
printk(KERN_INFO "LED register sucessful!\n");1 g* ?# A5 U: G' V; l
: a% S |: A# g
return ret;
# R9 X3 \$ b5 ^8 l( T1 ]}1 |2 ~8 W1 r0 A s! L
: F, H d& N( P" n; {static void __exit led_platform_exit(void)! Z4 M/ [. g, S N# ]
{
: q, k. X: z5 g2 T! d# `2 P1 d. f platform_device_unregister(&da850_evm_tl_leds_device);( ?' [, }7 `+ O5 L$ z4 s) M, ?
, Z9 D2 t# V1 F' ^! o1 ~
printk(KERN_INFO "LED unregister!\n");2 ~' W8 r/ v$ c$ k2 O6 a$ t. b6 ~# v
}1 }! m8 }" `* A. S2 C( U5 z9 P
, @ {0 |2 E' A5 `
module_init(led_platform_init);
) H8 ~, s0 Y3 }- m/ u" Emodule_exit(led_platform_exit);
( c# v1 @( E% r8 g! }: R
4 V! W ~: m0 Q7 F# R2 X2 DMODULE_DESCRIPTION("Led platform driver");; \ Y, o, f! y/ l) Q6 y, m
MODULE_AUTHOR("Tronlong");' {8 @1 Y; X4 \& j: U
MODULE_LICENSE("GPL");; b& T: A0 R3 w; k- T
d! V2 }; \* ?5 M8 Y
|
|