|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: A$ Q/ }9 P" R2 S; e#include <linux/init.h>
$ M, ^( \ k, D* t3 f g#include <linux/module.h>
$ a: F9 Y/ Q9 J1 y) r6 U G. y#include <linux/kernel.h>
! `1 V8 k, l7 J2 R3 Y6 ]#include <linux/types.h>2 [$ V" t" ^8 I8 o4 I
#include <linux/gpio.h>' ?. Z: }: U4 N4 d; n$ N0 {8 l
#include <linux/leds.h>
+ G$ \! B1 @8 e#include <linux/platform_device.h>
% @& ^: ^! Z. I$ T3 A" S/ O- e5 B8 I0 t( j
#include <asm/mach-types.h>" v" o1 M9 o/ y' t& U2 |2 ~- E
#include <asm/mach/arch.h>" L* T, S1 w$ P- ?& p, t# K& l
#include <mach/da8xx.h>
! a8 I0 K8 u5 z4 W% g: d#include <mach/mux.h>
6 @" H. Q# h {
- J2 c L% ` n" h# p2 z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! g& [4 d9 Z5 U- {) V1 N#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 z8 `! U- K# U; ^: Q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) C0 t1 w' R- v! F8 T/ P3 ~
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 H: M4 s: x; c
- @4 D, Y8 J5 j1 }- K/* assign the tl som board LED-GPIOs*/1 E& R- Q/ G4 G: k2 o: g
static const short da850_evm_tl_user_led_pins[] = {
/ b, W0 x% ~8 h, a. ? /* These pins are definition at <mach/mux.h> file */! T9 x7 I; X1 E! f
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, m" D% R* g# D" T Y# X! a; d; v
-1/ ~% o7 v- D# N Y
};5 L1 U2 k* L: L# {
& F0 r H5 n6 ~8 u& Qstatic struct gpio_led da850_evm_tl_leds[] = {
: `( F8 R* @ C/ P {
_ i2 f$ d6 C T .active_low = 0,# I8 X3 [, u3 V5 l$ R: G
.gpio = DA850_USER_LED0,
4 ?9 z F- O: H0 u: V/ d7 f .name = "user_led0",
3 y. B: z% @* q- O; t. S .default_trigger = "default-on",
6 V6 K6 A( t& r },
0 {4 v3 l( k, V! k8 N+ d8 c8 g {$ w4 g/ h/ c, Q5 N& Y. o. O2 {
.active_low = 0,: Q, I; x0 A, D- \
.gpio = DA850_USER_LED1,! \- y6 m: h2 F, z
.name = "user_led1",7 ~9 G/ Y9 Q* ]7 t8 F
.default_trigger = "default-on",8 {& ?; U( p* p: a( b x6 S R+ b
},3 q) S+ s. _- \3 F. S" ~
{
/ D2 A9 L. [$ P, X% [ \ .active_low = 0,, F! |. j* I) D$ M6 Y1 S0 h3 g. y
.gpio = DA850_USER_LED2,
# T! a: R0 L" W9 f) e5 M .name = "user_led2",6 B; f7 i5 \; w; @1 q
.default_trigger = "default-on",0 H- A% k+ R& ^
},
1 m. D" o* I0 ^) }" a {
" e& o- }( {3 S( Q; T' r8 }& l .active_low = 0,
/ y6 t, p, U& U4 g/ W1 ?0 q1 a .gpio = DA850_USER_LED3,
. ~( N7 Z' x) `, k .name = "user_led3",
- n1 E' n* L7 y' z .default_trigger = "default-on",
7 o) }! ~" r8 Y) D: W B },* o) q: F. F P4 U6 M+ N9 ^
};
% }, T* G9 g8 z) ]0 [
0 T/ r" q2 A6 xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 A9 d4 k/ Y- J$ s9 e$ m+ _
.leds = da850_evm_tl_leds,2 H, C8 p% _ R! ?# I7 O# R( j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" K; _1 T, n: H1 [5 e8 F6 D};6 p$ `7 H# a: n2 d) r
9 ?1 S! j Z4 n" H) G0 {$ p, L
static void led_dev_release(struct device *dev)- V% l% k4 l3 D" i
{
$ w7 ?+ J d' |* O3 m: J4 P};
' a/ b4 ^( K3 R# F# f7 u( W* j1 Q% N) ?8 U _+ j
static struct platform_device da850_evm_tl_leds_device = {
0 e2 l) d% c) E1 Y/ e0 h3 T .name = "leds-gpio",
1 Z2 \5 g/ ?. L* B) T2 i* Z& L( t .id = 1,# j& [" B" A! v3 g3 ~3 H3 D/ I
.dev = {
' z4 _/ @9 o- n1 G3 v .platform_data = &da850_evm_tl_leds_pdata,
4 g$ V4 V* o1 Q M4 v& a& P .release = led_dev_release,
7 g& z" X' S6 L" a5 m7 I$ ~$ W }1 A& c* M; ?. V3 W# K
}; f7 Z, T9 c; w/ r* d
& n* G: h5 h2 Z x' K0 Q4 V/ bstatic int __init led_platform_init(void)/ H; {; O3 p5 U/ T
{
' n4 U8 q2 Q# f% k int ret;
0 W) B2 }3 Q! W- ]#if 0
- F) X! u0 p" v8 X0 Y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 C3 F7 L9 q1 D if (ret)
3 \7 L7 |8 t `9 N. y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) s. R5 ~4 f; c& ~9 j: P% g "%d\n", ret);. v, W2 Z* m" R/ A* @
#endif
% v+ V8 a# F1 y6 Z ret = platform_device_register(&da850_evm_tl_leds_device);
2 s. e$ d5 U2 Z6 @ if (ret)$ Q, H' b7 {( R4 s4 ]) z9 p
pr_warning("Could not register som GPIO expander LEDS");7 L# ]& `2 Q- u$ s/ z
else
2 a K4 U( ^+ @7 a* B printk(KERN_INFO "LED register sucessful!\n");9 [. G. l% e, j. h. a& Q
! n+ s: k* t& j, b% E5 S
return ret;
$ y' e9 q8 s3 } a}
6 q# s$ k( K# Y0 L" p9 p2 F$ F7 {" Z! l+ k4 D! d
static void __exit led_platform_exit(void)
% I g! a( A/ U% k9 j{9 _" H1 ?8 X, p2 |1 i# n
platform_device_unregister(&da850_evm_tl_leds_device);6 E6 T9 o3 ^6 q) z# k* q. o
" u7 A! k0 T2 [) A, f" w9 T9 u6 n printk(KERN_INFO "LED unregister!\n");3 Q. V3 m# C0 }) E; N3 X
}
5 O7 ?% H/ r# G, W( z4 \+ K, ?% a5 i# W/ a: J q
module_init(led_platform_init);
# c- e& i. Y& R7 U) x% O$ Wmodule_exit(led_platform_exit);
7 R9 C" W$ J/ \9 ?: q" Z6 s
1 U3 r$ l8 Y/ z; s# bMODULE_DESCRIPTION("Led platform driver");" w& ]( V3 t6 I M. I1 p
MODULE_AUTHOR("Tronlong");
$ p8 ~& t6 y) u) O3 Z+ R8 RMODULE_LICENSE("GPL");
) R! S( q1 a% F8 P
; |, R& D6 Y$ e: K |
|