|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ V2 l) o O7 G' }5 d+ L2 @; q% E. ^
#include <linux/init.h>
2 }. ]: Y' I& Y% b" z#include <linux/module.h>
2 n$ K' G! W6 m; F" S#include <linux/kernel.h>
8 p; y0 v; r, ] S1 ^#include <linux/types.h>
9 E0 h. S. |8 B$ [' |) Y8 V#include <linux/gpio.h>
+ e& u% _# c- B3 E3 W' J#include <linux/leds.h>
7 m6 |$ ]$ A: y1 A1 w7 ^& y* |#include <linux/platform_device.h>
1 Y* j7 _# B+ V
; b% u6 V' h; f% u#include <asm/mach-types.h>
' z: w6 b, Q9 b! S; O/ H#include <asm/mach/arch.h>0 `3 k- f+ b% o# Z$ A
#include <mach/da8xx.h>
: x9 j$ `! z# B% u* ~. r#include <mach/mux.h>, C" I! v1 h- |, N$ M
2 A, r2 E0 a" n# m6 o: Y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 U9 V# L+ x$ P' T7 z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- Z% r4 M9 S! [7 h$ v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 f3 _2 G7 e! w& g- R9 c#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 S2 }$ Q* L, }/ H% l. p# f1 G1 O$ ^# i8 E% z
/* assign the tl som board LED-GPIOs*/
3 H" D9 {; D3 Y8 rstatic const short da850_evm_tl_user_led_pins[] = {
* n/ C# o! k8 w, t# ^9 W. M& t/ B /* These pins are definition at <mach/mux.h> file */; K7 e% }2 S0 g" H2 P" V
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ I! X. K' Q0 l( s% w* a
-1
% W! \; m0 J/ T9 r `. @2 U) j};+ c& x+ c: n9 j$ H4 e
3 n+ S3 L8 [' \
static struct gpio_led da850_evm_tl_leds[] = {# S4 N$ Y6 Z; F/ [& b
{1 y6 E8 F+ ?) B8 ?" E
.active_low = 0,. X! K A: a, f; f
.gpio = DA850_USER_LED0,$ \6 [2 H- {+ N. ]+ Q5 d
.name = "user_led0",
$ B. g, d/ m; e. b3 x! j .default_trigger = "default-on",
7 c* `) t! F: i8 P; J6 J" N2 ` },+ ^0 K. B* U9 t
{
$ i3 v* U" s% M$ r2 c G2 x2 B .active_low = 0,
, Q( N) W9 Y! I) x q .gpio = DA850_USER_LED1,
4 e# F, v6 Y9 p0 I, W+ r @ .name = "user_led1",+ ~( W$ N' D) d5 t- S: ^
.default_trigger = "default-on",, G: Z6 o' ?9 I1 H: S2 f% ~
},
& c+ |% x& C W2 T7 c4 K {$ I% F5 K1 H- v4 l5 y
.active_low = 0,
- G. [( {7 l/ x" T/ p% k0 S .gpio = DA850_USER_LED2,
5 _* G- G' C' l% z- A# B8 V5 z .name = "user_led2",
4 V3 q% K* ^8 k. \2 C: n8 Z .default_trigger = "default-on",- W+ p! L% {* J# \% s
},( w7 x6 J7 H: X S- }% e( L$ d. H
{9 b% V8 R+ y0 y# [+ d7 Q
.active_low = 0,4 M( K* w2 X1 g7 r, k1 w/ ?' E
.gpio = DA850_USER_LED3,' a+ L+ ^, Q6 w. n- p/ `5 K2 N
.name = "user_led3",
' x8 W/ V7 T# S* m0 t: k .default_trigger = "default-on",+ e/ }3 H7 p6 E7 e; H- s1 `
},
, ^$ u8 h" G5 w* M( P- T};
) a/ U' `9 ^, u h# Z1 D
: a A* T+ h3 f+ V3 Nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; ?9 C" ?2 w: e! ~- T$ _$ v .leds = da850_evm_tl_leds,
; _0 {. G/ U" j W3 P .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! R5 j* D' |' F. n1 Q; i1 |; [5 R$ c
};
! k. a2 y/ k# c* }, {$ ]5 u, P% w5 ~
static void led_dev_release(struct device *dev)1 D7 L0 {, z0 S& @4 l6 G
{, P, f' ?2 K- e& Y& }4 z6 J* v7 g
};
4 T9 E' R: e: h" S, w+ ^2 D7 `
( A" r3 | x5 E- estatic struct platform_device da850_evm_tl_leds_device = {. o, b+ q3 P7 R2 P3 o0 A% t2 N' K, U
.name = "leds-gpio",
+ c( {: u; _7 {) y" o7 q! ^3 p1 P2 q .id = 1,
$ Y7 n. l4 W, Q) ~. E% A8 a' S .dev = {. N5 D, S6 w3 `0 z
.platform_data = &da850_evm_tl_leds_pdata,
w4 Z8 L9 m; d; h# T+ m .release = led_dev_release,0 K) T2 J/ Z* Q0 t+ X% M0 B, M
}' u" Y, b4 i& `4 ]
};
( d+ g* C, |7 _5 k+ m/ O# G7 T% A2 b* Y! W! T
static int __init led_platform_init(void)1 q5 G7 P6 H$ t0 e
{
1 x% }& R6 \' Q6 q/ R int ret;
. N& ?: T5 b- \/ C6 I#if 02 ?2 l- x- u! E, A# l. a: [9 b8 w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) {! Y6 j0 J# _/ K0 x4 K+ C if (ret)0 M; C u& P+ Z9 C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
j! e- p* j2 w% ]3 }" V2 j "%d\n", ret);
% P8 _- v- }5 C+ B/ Z#endif" ^6 @' W* L5 W4 V( R: q* V, I
ret = platform_device_register(&da850_evm_tl_leds_device);7 s+ K- ~( o7 y" a, F; v
if (ret)5 A; p. B b4 F2 S9 R
pr_warning("Could not register som GPIO expander LEDS");( F4 _, D. s! L! D6 t
else; p! e7 b: }8 P, [9 K
printk(KERN_INFO "LED register sucessful!\n");
: ~ p2 ~9 p& J
# n. T$ o: ~: x' _! W return ret;
+ s# Y8 a, h! I. x! }) v6 x) P2 B}
7 q7 }8 E' `+ \/ I" _+ I% z4 O
. Z7 T) w, P9 w# C2 K( L7 Gstatic void __exit led_platform_exit(void)8 `+ T; W# [7 E5 z7 t
{. k, y+ K( t/ W: r8 m- F5 _
platform_device_unregister(&da850_evm_tl_leds_device);/ R' [- c! O, }) P4 A- |) X
+ t' Y7 }! ]# \
printk(KERN_INFO "LED unregister!\n");
7 |; T! j2 y) w: K} L( ^; H* v3 ]
2 z0 M' F5 [# k1 D% K9 \module_init(led_platform_init);
1 G7 H' H, U& z% r" Zmodule_exit(led_platform_exit);
1 d7 Y3 K0 Z: B) j( f b, s
7 y5 J% M0 ~4 n- ~: U$ O1 ]$ MMODULE_DESCRIPTION("Led platform driver");9 v" I* }" k+ o& C
MODULE_AUTHOR("Tronlong"); d3 A5 c$ ]7 L& c
MODULE_LICENSE("GPL");
: u0 Y8 ~2 z, W! I+ [
2 B0 H8 i8 D3 I; _3 R2 @ |
|