|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 f* Y7 e8 y7 R0 K
#include <linux/init.h>2 n1 o, n( u, u1 T5 {; Z
#include <linux/module.h>
$ j& N7 s1 j l) Y5 X1 C% [#include <linux/kernel.h>
( Z/ \' n4 n5 i( v' p% M#include <linux/types.h>3 x; O4 @9 }3 t [1 ~; K; S
#include <linux/gpio.h>0 s3 D; F" m. Y" Z9 H I$ c
#include <linux/leds.h># U J( E/ x: e, C9 q/ i
#include <linux/platform_device.h> Y8 s) p9 n$ R6 }. B
+ ]& h* f |! G6 J5 j
#include <asm/mach-types.h>
& I& C( m; S8 l#include <asm/mach/arch.h>: r! h l) X. O1 H8 K
#include <mach/da8xx.h>
0 w$ H4 K- c1 L9 T9 x#include <mach/mux.h>. ~: p% \- V$ R- w5 P) m) Q
4 `* `9 S" i, ^% j6 _
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 X* s+ \& s5 O7 @6 j
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), d J/ s& a' R" H2 \
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. Z# {. C. E4 V#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- i; B+ l0 `) K5 Y
# F* P- v; \0 `% g6 K/* assign the tl som board LED-GPIOs*/+ c3 c* u! @6 W1 U& K9 y) m" t# i
static const short da850_evm_tl_user_led_pins[] = {9 H) T' a$ C( f8 D
/* These pins are definition at <mach/mux.h> file */4 s1 X! ^) n9 H! Z( H! {6 j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ s E% {2 O2 _
-1* S F2 B( b- L6 Q j
};4 Z' J# |( b+ W
" [! Z4 G$ q" |7 N" i
static struct gpio_led da850_evm_tl_leds[] = {
5 q1 f2 Y# Q% Z. o& a# m; c: Z {9 W% \# @9 g+ t H
.active_low = 0,
h! Z" q( c3 ~5 W& D& W .gpio = DA850_USER_LED0,
" T) o$ [3 o2 ~" y+ r .name = "user_led0",, ~9 b9 M$ i+ V7 G; e% U9 T5 l! ^
.default_trigger = "default-on",* M' I. @" N( W1 w* b- G
},% S5 @" L2 x8 s+ _, o7 O! C
{7 B2 _: ^- C( C8 j
.active_low = 0,; n4 b" g0 ]% \8 ?
.gpio = DA850_USER_LED1,: H9 S: {' O: o0 I4 d$ `
.name = "user_led1",8 u* C3 Z9 i- k+ w$ X
.default_trigger = "default-on",* N) Z5 s) \% _
},
9 K2 ]7 A3 }, b6 j {7 X V) |8 s3 X. a8 g6 v& N
.active_low = 0,
7 q" ?8 w, L& O X .gpio = DA850_USER_LED2,! Q+ A* y8 m- `) [4 |6 s' h9 \3 o0 @- h
.name = "user_led2",
, T* H/ a _7 [8 }. ]- C .default_trigger = "default-on",/ v4 C% b# R/ S6 _7 r$ _
},
& [5 Q) k" T/ r' h2 [: y {
) @2 u! f9 ^% e1 P6 E% K .active_low = 0,( B- I- {2 X# p3 I+ B
.gpio = DA850_USER_LED3,1 P5 |( Q5 J% `3 g
.name = "user_led3",
+ v! U1 a2 R5 S4 @! m .default_trigger = "default-on",! ~; y, ?4 D5 ~$ N
},
, D* b# n9 e! Y3 j& ?9 o! v0 f( Y* x};
& u7 Y2 N: F2 K5 c; p4 T: U; A4 a) `1 Y5 @# |
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 Z+ X7 l8 n" w) |6 L .leds = da850_evm_tl_leds,
" `( F3 `+ c1 M5 _# T$ w) [0 B .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 g7 R. N9 [2 R% t6 b* Z
};
4 g% U. _' w: S# \) z( A
$ |- ` w) @6 ]* { \8 x' Lstatic void led_dev_release(struct device *dev)
* }9 e/ F5 J. `, c' _4 o$ }{0 |' z! w( w. r3 p- Z7 P0 n
};
6 l) | S1 ?7 b/ x; r' Z$ Q' v* j
- @3 z5 ~9 A$ I! H4 A" d& x* O9 Astatic struct platform_device da850_evm_tl_leds_device = {
3 N) K8 [( K2 J% x8 ?9 e .name = "leds-gpio",
2 S" Z( D6 s' u$ i( O5 O3 z .id = 1,, P) v1 ~5 c6 P, L; z# `5 Z+ Q" y
.dev = {% H) m$ A+ p+ g+ I9 A% G+ Y
.platform_data = &da850_evm_tl_leds_pdata,! I6 j# a( p! }+ w
.release = led_dev_release,- Q9 C! d4 e1 ~* |; l
}4 i) B2 d! d" r$ G: T; N. n
};, m6 Q2 _7 n# @9 R5 J) a
( Y2 d, X/ F5 wstatic int __init led_platform_init(void)
! W8 T. a# e6 D6 l! f& Z0 a{
8 ]( L k, q/ n# }/ i3 b int ret;
- b' n0 G- C8 [+ r$ R#if 0
" `: G; j8 f" H; t/ U( b ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 h# |% c9 r# L P9 x if (ret)8 U2 C1 L+ N6 w+ W
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 J) q' r+ O- U! {* a8 S% k
"%d\n", ret);
% [8 n; C( x9 q/ _5 |) o4 q#endif
* J4 Z" ~) f: D& v/ f ret = platform_device_register(&da850_evm_tl_leds_device);1 D$ w7 Z% A+ w
if (ret)
& S+ S+ e/ W9 H3 l pr_warning("Could not register som GPIO expander LEDS");
1 ~4 z# h5 c7 p$ K& Q: O8 M- x else
6 P! _6 I) L z0 V7 i' S# i l, t printk(KERN_INFO "LED register sucessful!\n");7 s. {: H5 m1 C+ ]3 k8 j+ j
* @5 D: _6 q% m6 p. b9 K
return ret;2 J+ B2 a5 U& T* S
}
" j. Y4 _) h) M) s4 G. m& H2 U8 V/ Z3 c- ]( j
static void __exit led_platform_exit(void)
9 i3 n- M& q+ O0 b! T6 T{
" ] h5 ?* F" _ platform_device_unregister(&da850_evm_tl_leds_device);% h& z8 `2 H: q9 m c
! g. u5 E1 R5 g) @
printk(KERN_INFO "LED unregister!\n");/ k) X1 j4 B0 C# g/ H' S% }
}
* K; T8 @) Q) l) g( E) r9 D0 G _0 u% V& u+ W+ k/ q$ t) D
module_init(led_platform_init);
0 K3 p7 l- f& V/ x! h$ Rmodule_exit(led_platform_exit);
7 R1 ?- g! N1 s" e' F# @- M# R2 q% t* \% t, t
MODULE_DESCRIPTION("Led platform driver");
8 i0 e0 n1 }/ ~, R2 k3 `MODULE_AUTHOR("Tronlong");
b# Y& ]' @$ u% Z! t. hMODULE_LICENSE("GPL");3 Y4 x K8 _5 D+ s
0 H) u( x/ Z/ W7 m0 a |
|