|
|
求大神给下面的程序做注解,请稍详细些,谢谢。% [. m+ {0 e2 i0 l
#include <linux/init.h>& q: X3 ?7 S% Q( F
#include <linux/module.h>9 c7 I9 P* h6 I1 w; u- y
#include <linux/kernel.h>: ~7 V$ S. z3 P! q
#include <linux/types.h>; R0 K! X% E' ^2 Y9 ~
#include <linux/gpio.h>: R$ `: o5 a1 u% f( F) I0 |6 D: I
#include <linux/leds.h>3 W O5 [! b; P( n8 y
#include <linux/platform_device.h>
( n Y9 @ k# h. t o0 ?: r' B4 L1 T( E; Z0 y4 H( l
#include <asm/mach-types.h>
) q8 Z* q7 W0 l" G* L: _2 k#include <asm/mach/arch.h>$ S7 K$ K+ R0 S: @4 Q0 @# U4 b/ V
#include <mach/da8xx.h>6 x; w; n8 _$ p2 P; m2 U
#include <mach/mux.h>
8 w' r: C' {4 J7 E
# K3 F. T- f- ~; O0 V5 F3 J#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" r* T4 {+ g0 e3 f4 }#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
T3 @# h& h) f' U9 H5 w1 t, n7 M#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ B- ~( L7 M+ T4 `
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ c6 u; s* ?& {. C. e' o7 U
5 p/ t# I9 a$ d* W" m R/* assign the tl som board LED-GPIOs*/6 ?7 i2 n2 V _; f# U q5 E
static const short da850_evm_tl_user_led_pins[] = {
& L+ T" S; \3 J$ u* n% |0 f; H /* These pins are definition at <mach/mux.h> file */, G% N. N1 | b) F, F @
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 y m4 Q. V, { -1
- f" e7 k5 h& p; |};
7 c8 r$ S1 ?9 d6 ?: @2 v
) {, T/ p; n7 D/ z& Fstatic struct gpio_led da850_evm_tl_leds[] = {
' Y$ p h( T& g {6 O7 K# g9 i" W6 V+ U6 p
.active_low = 0,
6 k. }* a6 S3 {8 D' a( C: E .gpio = DA850_USER_LED0,
7 @0 f0 i( D% {5 I .name = "user_led0",
d7 i/ [" f& a% R) { .default_trigger = "default-on",
) g0 E; N, E2 b4 ` },
4 y$ Z2 R& O* _- r+ |, ~- a {
7 Q x5 z' U, a3 b .active_low = 0,3 ~5 W; A' `; m4 u
.gpio = DA850_USER_LED1,
# M( h5 o, g, ?: u4 ~7 S .name = "user_led1",
3 D9 q- }$ N7 M* l' H .default_trigger = "default-on",
, k& H1 s7 b# q6 l },& b/ ? ? t: k8 v2 O( ]
{
" N7 p4 l1 S7 _& Y! K& W .active_low = 0,
a. s) J: `5 N" {! S0 {1 H5 x0 Y .gpio = DA850_USER_LED2,
$ S5 t7 t8 ^$ r2 |% J' ^ .name = "user_led2",
$ `% H. d7 |$ H9 _3 G8 d% y' f* ? .default_trigger = "default-on",5 p% P6 r2 E6 x: ]- s
},
$ O2 Z9 s' L5 M& ? {
U3 z6 g1 D3 O1 s; P( K .active_low = 0,
: k/ |) z+ w) V( r: [1 M3 P .gpio = DA850_USER_LED3,5 ` C7 t3 a3 W8 \
.name = "user_led3",2 L, w# b+ X& L2 y2 ]% S
.default_trigger = "default-on",
/ X8 m8 h/ O4 k% j, g0 k },4 A: @3 _7 |8 E1 I; m+ N4 o2 `! ]5 l
};
0 I1 M0 q+ `3 b; S9 q0 i) a( p, N! d1 p! \4 e
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: L* S; M. Y( T/ n/ e
.leds = da850_evm_tl_leds,! S! F2 i' D& u( k4 X* `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. Z( a3 n, w& B" ]; _};8 E8 A0 ^) Z' E z6 p
$ V+ }% _0 p% S0 u
static void led_dev_release(struct device *dev)6 v1 r% V9 j' Z: [
{
2 Y9 e8 P/ m: `1 ~5 M% x0 H1 t};9 l( ^1 m/ ?0 z
: n9 z7 H! U& y- f6 a/ L# o/ d+ Lstatic struct platform_device da850_evm_tl_leds_device = {& Y/ @/ M, a" @7 {3 \# r) o
.name = "leds-gpio",
0 I& U4 q' T! X2 K2 g/ m; t .id = 1,( z' {- h3 H- }. }9 i! s( c. B
.dev = {0 p6 C9 x! x1 Z6 r0 X' C1 H
.platform_data = &da850_evm_tl_leds_pdata,
% Q" z9 @- {! R. l: w$ H5 j .release = led_dev_release,, n' E3 k A' h O* o+ y4 }
} A& [1 R" q% {( l9 ^# r
};# I' n/ B6 W/ X' @5 V6 F4 d
' t9 p8 M7 N1 e% k
static int __init led_platform_init(void): F: x1 E- k2 n
{; g/ C7 [7 |: ?9 k2 W$ P4 ?
int ret;
* o0 G# n" i; ?5 @; E#if 0
& f9 h) S( e' l! w. z; s6 a+ ~ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; r( J. c: M7 p; x
if (ret)
7 w! X0 v* L4 P pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ S8 K3 D: W4 N9 v/ y: a
"%d\n", ret);) I1 A d$ G# c5 d$ C
#endif$ Z4 }- U9 \) O5 ^1 b
ret = platform_device_register(&da850_evm_tl_leds_device);8 ~1 t! w% j0 \: f6 t" y% I7 X
if (ret)% \' h& C8 ?: \ i. Q8 Q3 D% x# Q
pr_warning("Could not register som GPIO expander LEDS");. R0 q# Z5 k" O* _6 K4 M, A9 V
else
5 w3 F _" j' R5 s* m printk(KERN_INFO "LED register sucessful!\n");, z! q9 G, O, \( J+ b
" \% W0 @% l+ x' Q
return ret;- o ]( k% `! v9 }+ I
}
4 L `4 y* i/ B8 E/ K) y" l' |4 l# d& k/ u6 { F b+ e
static void __exit led_platform_exit(void)2 V% c1 j$ P- S" S. P( o
{
9 X: _7 [/ l2 ~: ~/ M) O platform_device_unregister(&da850_evm_tl_leds_device);8 o( q+ Y$ X: J" u
8 J, q7 c2 p: X# c8 M printk(KERN_INFO "LED unregister!\n");# f+ [! J% j8 R
}: a- A. P$ Y- W2 b
, }$ `. a. ^4 ]0 D4 e
module_init(led_platform_init);: P# S: s" G1 \ S3 D9 A/ b
module_exit(led_platform_exit);
6 K# W- ~' ?" o% F8 r0 [ L9 G" p7 d$ G! K
MODULE_DESCRIPTION("Led platform driver");: R+ H( o0 E+ ]; x* H
MODULE_AUTHOR("Tronlong");7 v+ R1 ? I4 W: |% |) W3 Z
MODULE_LICENSE("GPL");; P4 u. u; }3 j" S
0 q$ P( v5 N. [- U |
|