|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ w n6 p, ^ f
#include <linux/init.h>
' |& z9 ?( M5 N# w5 |#include <linux/module.h>
0 u5 u! E/ j6 ^#include <linux/kernel.h>
( _( u7 g) n+ c#include <linux/types.h>' O3 W6 C k5 a: f$ z( f c; |
#include <linux/gpio.h>' ]" S! U$ I( C2 R0 i
#include <linux/leds.h>9 l) \0 p- i" T0 {1 P
#include <linux/platform_device.h>
3 b+ e2 I! v! g, f6 B+ j) b; ^# L; D4 }1 F
#include <asm/mach-types.h>
* j# c+ Y4 F! W- q1 Q* V! S#include <asm/mach/arch.h>
& h- V' w* j2 M3 l7 h#include <mach/da8xx.h>
6 H+ S$ K/ W8 z#include <mach/mux.h>4 G3 m! N b! P) K/ j S
5 v; H) q# h1 f& [# J#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) m% u, p6 B1 V! g8 Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) w& k& J+ A8 ` G9 M#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% M* T0 g+ B( U5 {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
4 f3 Z/ V* x5 `) k' z8 f6 j4 D1 L2 o/ G. L `6 q1 M
/* assign the tl som board LED-GPIOs*/! z0 d# {6 a, @/ C5 x- u
static const short da850_evm_tl_user_led_pins[] = {
* ^( Z) X' w+ F6 a: R6 K /* These pins are definition at <mach/mux.h> file *// {9 U: C/ Q# N$ J& O4 b
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 T$ Z/ W' w1 A/ Q" b -1* |3 o; F3 _1 T; W6 C- d
};
& N! ?& T Z: Z+ F
$ g9 }2 H& B* B9 t7 c9 s5 Astatic struct gpio_led da850_evm_tl_leds[] = {; }$ r$ p6 C0 S9 Q/ b* o9 y* L3 b
{6 r& O+ @# Y% V8 B3 K
.active_low = 0,8 Z5 w1 F- o1 `4 c( x0 x
.gpio = DA850_USER_LED0,
& g' y1 g4 N$ F6 f0 q! s; R .name = "user_led0",
1 S. @/ u. Z U8 G9 s .default_trigger = "default-on",( x0 L2 B! Z; G! b# Y( f
},
6 N, W% o) t( Y {
$ j3 h. b: X$ I, P" ]: Z .active_low = 0,: R, v8 u0 y* V i3 e. ~
.gpio = DA850_USER_LED1,' T4 J& x- B* |% \' D# e
.name = "user_led1",! Y# X- V4 c, g
.default_trigger = "default-on",3 V$ j- d# f1 \; u; }0 W
},
2 @0 u" _' k. ]2 T" [: S8 a0 t5 G {1 I7 r2 v2 S0 P
.active_low = 0,
) y6 y0 O C& Q7 q .gpio = DA850_USER_LED2,
4 \4 z1 M2 _4 W+ H .name = "user_led2",
1 T3 r# B9 L1 U V) p, ?4 w) g a1 ~ .default_trigger = "default-on",
% m% f* \; n: g },
$ i8 A/ y' b8 f" b7 d1 |: e( g3 O {# n. e# J* W. J9 G) e
.active_low = 0,! v: L* B' S: W3 B' v7 X
.gpio = DA850_USER_LED3,
0 o2 Q. a+ _9 }3 A" }2 s9 @ .name = "user_led3",# e0 S" ?% _" u C. U( W5 Z
.default_trigger = "default-on",& S0 f- k2 `& j; w
},1 h1 G a; E5 d
};
7 Y" h% m7 I4 J Y3 C, ^1 s
# a1 M7 u! y" i7 w' Hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 Y' [. ]* K, ^+ q1 C/ a# \" D
.leds = da850_evm_tl_leds,
7 A: a4 k4 d! H4 o4 O .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 B# i" k N6 V
};
9 s2 s5 a1 g' f8 C) r% M- D; ^" ^6 c _5 I/ f. k' e9 Z
static void led_dev_release(struct device *dev)' ?2 T1 R5 Z" g3 L
{( H) |1 n, T" Z
};
8 T: p7 x0 x v9 a; `- Y. k( @; e. E, {, h3 y: _5 k
static struct platform_device da850_evm_tl_leds_device = {
3 @$ J9 c# M" w .name = "leds-gpio",5 J5 l: U7 z1 l' d! K
.id = 1,1 a, I5 G, I1 X
.dev = {
" V ?" j v) k$ f7 {6 z .platform_data = &da850_evm_tl_leds_pdata,9 A9 M2 \" C& M- `9 i. s* W2 E
.release = led_dev_release,: ?% a8 Z' b& _# F
}; t5 v1 ?8 b2 G ]
};7 l- ]# a: D% G, @2 a3 m! G
8 Y9 e2 D$ y- A! p
static int __init led_platform_init(void)
1 [# T# o8 w7 w! V f/ n9 E4 m{1 c( [8 n4 e4 l, w
int ret;
# w2 X' e+ ^3 `- a: b# x& j! Y#if 0) A( i4 U, N$ j' x! @$ f2 _
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* U8 b) }* V8 Z) t% Q4 U( q if (ret); |6 f9 E0 V8 U* p. c4 _+ S
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 n# }5 r8 m- M "%d\n", ret);+ A( u2 ]2 C7 k2 z
#endif
2 x0 `/ N2 J" N/ |+ A9 k ret = platform_device_register(&da850_evm_tl_leds_device);% h' D, E" g/ p4 g L* L2 @: }
if (ret)1 s6 B# I7 R3 X8 v2 V. e
pr_warning("Could not register som GPIO expander LEDS");
s n8 H8 ~) p: X' k. n2 v/ ` else7 \: C/ t: _2 A0 ~ v& L- C
printk(KERN_INFO "LED register sucessful!\n"); ]) E* ~9 K; M2 k" }6 D
+ a) {/ z: S: D0 n; t9 c return ret;1 D4 r# A3 j4 ]4 L* n
}
) C8 R; ?1 V0 A- N! X+ C: ^: w! A2 i% @# E( c6 @# w8 C5 _' M+ X( N. u
static void __exit led_platform_exit(void)
. T5 P3 Y* \0 z( \9 I+ t* V{
* A( p- a, ?. Z) g3 A) i platform_device_unregister(&da850_evm_tl_leds_device);4 M' F- D8 o$ I9 W9 ^, H, P
* k& i2 c6 U9 }, R printk(KERN_INFO "LED unregister!\n");2 P$ R$ `" w5 e! [* T- d( l% }
}# d" ~. N% h4 I" E' s- C- Z
3 X; I& _8 u4 a: G0 [/ g1 P
module_init(led_platform_init);0 x Z7 G5 h- I0 |* h* o0 x
module_exit(led_platform_exit);
' L% S+ K# N! V7 }( `
+ {# e! m5 N# W/ J$ D; J, ?MODULE_DESCRIPTION("Led platform driver");$ x4 E$ ~/ \" P) [/ i9 o
MODULE_AUTHOR("Tronlong");
1 X: K8 ~; T% P1 F% oMODULE_LICENSE("GPL");
1 H9 E4 X$ A9 Q% l. P+ j" G7 L! c# y. \+ J- }8 q
|
|