|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
u2 ?/ Y5 A* N$ U8 c( l#include <linux/init.h>
+ B6 t+ Q) z$ H5 F8 u7 |) B9 _#include <linux/module.h>, t) o6 M; K: g5 T6 `' K! C
#include <linux/kernel.h>
* y0 W* r6 I0 p1 ^6 S, I( B: }6 `#include <linux/types.h>; Q( O a; f' k% o7 A
#include <linux/gpio.h>$ W& O2 d+ _+ c* y4 M& W8 R% T+ A
#include <linux/leds.h>
8 L8 h, C- t9 j9 P% M#include <linux/platform_device.h>
' d9 Y( d% u) B. ?1 g$ c$ k! ?7 ^+ v' Y! `; M% t" p; b, |7 B
#include <asm/mach-types.h>
) A: N8 R: c2 ~#include <asm/mach/arch.h>
( ]/ S* G9 C7 a! o; a- t#include <mach/da8xx.h>8 I) R) M$ S; k* {1 R
#include <mach/mux.h>, S9 ?7 h. z$ j; ], o" Y' b
8 v& G. J V' o# @5 X. p: K
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 {3 Q9 b7 f* }# O' ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* `& L- ?) X) A8 C#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! a! s4 s. ?5 M1 w2 \
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- z; k, R' x8 Z5 T% X9 k( y2 j% ~) _- _! Y" M
/* assign the tl som board LED-GPIOs*/
; O- `9 u& T# f5 n* Hstatic const short da850_evm_tl_user_led_pins[] = {
) {# ^, p9 X$ M. Z) f/ D$ S /* These pins are definition at <mach/mux.h> file */( h4 c( y6 K2 ^
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& j5 H$ x( o5 {! C8 q
-12 e$ i9 x& Q4 S7 c
};
# D: X6 h6 ~( x2 i. B+ @3 r/ a6 J3 V, P; \6 a1 O* ~( q5 y
static struct gpio_led da850_evm_tl_leds[] = {# ~* [' \: S* |4 E+ d
{9 z* H4 @' T5 W" ^
.active_low = 0,0 B2 L2 [) |& D! \' a
.gpio = DA850_USER_LED0,6 B9 s; O( P% Q8 ]
.name = "user_led0",
5 J4 q. h4 @# P .default_trigger = "default-on",9 @9 y9 F9 [- @- j5 `" m
},6 W; X3 p e$ R4 I0 U. U
{
1 Q: q( O# `; v# h: c- [2 [ .active_low = 0,
0 n; z4 |1 z: j, \3 L! J .gpio = DA850_USER_LED1,
3 ~9 Z. M5 k z3 l$ T# \$ P .name = "user_led1",% `# Z! Q3 V; u" [) K
.default_trigger = "default-on",
/ A( h, e4 p, @1 ` },
* \ v8 M2 o" h {6 [: O* V. Z! h. e' Z: s% N
.active_low = 0,! F1 U0 Q* C; y5 D! G
.gpio = DA850_USER_LED2,, p4 s, Q3 {" A' \2 _. n
.name = "user_led2",
/ d9 z y/ V4 X, N .default_trigger = "default-on",
9 U7 u# m8 `" u3 M },
$ h( K3 ?0 c8 D# A) h, h {$ U! y/ Q0 ~( v, b1 h" D2 R; }
.active_low = 0,9 a: y1 T1 o" [3 K
.gpio = DA850_USER_LED3,
3 O7 N; F4 b5 F: r9 s* Y; Y .name = "user_led3",; Q& g" M- c+ x% J4 G9 D7 ]
.default_trigger = "default-on",
) r% m& ^+ g" P! X3 d- _ },
& P% _% [# k \8 n};
( m7 K6 x9 }1 N: ?( F5 h8 ^& P: R8 h4 L. Y2 Y, Z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 S' r, S1 s" W0 {( } .leds = da850_evm_tl_leds,
6 P p" @- J$ L- Y4 r9 J .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 h, x9 e1 m9 m" B; P1 d};
9 s0 c4 S: r* a& F: T4 J1 ] Y. a" p' B. Y* @; \
static void led_dev_release(struct device *dev)
( h* G" V- X6 g{! j" A5 h% r# \& _1 ]6 i
};% i! G$ P0 w6 g, a# P; N
2 @% N% n8 z6 Z: \static struct platform_device da850_evm_tl_leds_device = {0 J5 h4 `7 W& n1 G* C
.name = "leds-gpio",4 R* p% ~( n$ ~* O. t! D! f: n, W
.id = 1,$ w ]* H7 Z+ N+ [% J% m
.dev = {( f0 B9 r# a- g4 h
.platform_data = &da850_evm_tl_leds_pdata,
* k1 Q+ o, I1 M .release = led_dev_release,
- |: q1 h9 m* b8 P. t% Q }3 O1 L3 j, R* |0 S. A' r
};/ `9 L, }0 J* ?8 a$ B
( p. [& \0 B$ X0 R' a
static int __init led_platform_init(void)
6 J% C( b% u5 A% Z) K" f5 P{" v5 H9 S: r/ Z
int ret;3 P- [7 M* k* D) x+ Y
#if 0! A* s% [- W- x( V$ ?& i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 O0 [' @8 y6 x4 G& N
if (ret)
" K; Q+ q6 K2 r pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 `+ V0 r9 ~% Y3 \1 {
"%d\n", ret);
( p! O$ j( M6 L" M4 t#endif( ^0 O" X. | j4 U& d
ret = platform_device_register(&da850_evm_tl_leds_device);
9 o) h' A/ S& y$ }- {$ E if (ret)# s' Q* J* V, ^
pr_warning("Could not register som GPIO expander LEDS"); f8 D9 I3 ^: U6 B2 b
else3 d1 y( t# L! b. o* V
printk(KERN_INFO "LED register sucessful!\n");/ n( V, B% Z. n: G h
7 N: K. T& R0 n. q8 U: V
return ret;' K8 X9 n% M" Y. J) k# {
}
% r! |2 B$ d8 i q. u' R! G+ l V8 @: n1 P) i
static void __exit led_platform_exit(void)" y) h1 x0 L5 V
{8 l! C: V0 |3 S& W* A7 g8 C6 v
platform_device_unregister(&da850_evm_tl_leds_device);
& d) f1 |/ m, F( Z# A* s: Z
/ T/ C4 Q$ ?6 R1 h, N& {$ K8 @ printk(KERN_INFO "LED unregister!\n");) G& u) f/ k) A& h5 U' m. c
}7 f3 p2 u1 G$ @' ` F4 ?% P) r
$ f7 f6 t I" ]# P' T9 @+ u
module_init(led_platform_init);
5 k) Q2 t8 q+ E: v1 m" mmodule_exit(led_platform_exit);
- q* q" D8 j. C% p; i" X( u" r7 H) J0 L) r7 ^$ r
MODULE_DESCRIPTION("Led platform driver");
0 B9 n& B7 f: g F1 ^+ D. GMODULE_AUTHOR("Tronlong");
! V$ r+ O v. w ]5 wMODULE_LICENSE("GPL");8 n: W% X- i8 F' c S2 c0 A% m% |9 S0 c
2 e4 d/ y9 D" J3 G8 }$ Q: R2 k
|
|