|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& s, b6 _# [0 \' N' O
#include <linux/init.h>
( V' ?5 j# c# u#include <linux/module.h>6 {( a% ]# a6 C& J
#include <linux/kernel.h>+ v7 m1 u. b& E- E3 i& D7 j5 [/ b! a
#include <linux/types.h>
. M F% z1 ?$ i8 p$ n#include <linux/gpio.h>
4 Y( L( ]* w! m& v1 `, X#include <linux/leds.h>
L4 L- V& f) }4 W#include <linux/platform_device.h>
5 {2 Q8 A3 T7 `3 Q% I0 ^. Q4 a- v# V3 ~" e4 L) K- p g$ w
#include <asm/mach-types.h>' L4 z+ y( h! O3 y2 i- f: c- d# h3 z$ _8 |
#include <asm/mach/arch.h>. Y( K2 g% T8 y6 Q6 R
#include <mach/da8xx.h>
8 t! D% L( w5 _: e; D, d4 B#include <mach/mux.h>
# H3 y' M' ~: Q4 t' n* r% Q6 F2 A
0 |# a5 x |" t#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 e5 h2 {8 \2 E2 }/ }" @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ @+ h k$ A7 m4 k7 h0 b' } h% k
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 u) J4 Z$ e) A
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( ]. Y' u! I8 o# I# d. I& f, Q
; K" ~! \3 g# w% n
/* assign the tl som board LED-GPIOs*/
+ o5 z8 `" J% _static const short da850_evm_tl_user_led_pins[] = {
4 L: ]0 b! R3 ]) a! A /* These pins are definition at <mach/mux.h> file */) R% q9 C) n7 b: W! I
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) [0 m$ _2 |& h -1 [7 T9 P0 |/ Q1 k8 ]* X
};2 z" c/ t8 V$ c1 R- e d$ I6 g
4 |6 }- z. j% E; p9 M
static struct gpio_led da850_evm_tl_leds[] = {* Z" ?5 u$ p9 g9 J: E: v; s c; n
{" I7 |# {8 C! M$ `0 w+ T$ K
.active_low = 0,$ [3 A" v# w2 D, |2 q# X2 r+ S
.gpio = DA850_USER_LED0,% [# p% M. S" W! N5 q
.name = "user_led0",8 z, V5 L+ ?0 w& o
.default_trigger = "default-on"," S2 U; M( p3 i: f4 Q/ M. f K8 o
},
- S1 r7 r1 U+ j6 o {
- _. d3 b9 h- Y2 X# Z1 l .active_low = 0,
. d- k! u/ ]& p3 o) ?& U# f i, N .gpio = DA850_USER_LED1,. r! v: m' k2 Q1 N; j5 h6 C% m1 P) L2 `
.name = "user_led1",
7 Z; |, W, c! S& X .default_trigger = "default-on",. O' f8 M2 n- ~+ N
},# \2 f6 q2 j6 ?5 e
{, G6 ~% G1 t& S2 {, \6 w% v
.active_low = 0,
* x8 R8 L# v+ f* ? t! p- V- S6 Q: _ .gpio = DA850_USER_LED2,
- U0 S6 n( I1 H9 a .name = "user_led2",( Z5 C: V$ ^$ j3 Y# Z# k9 @
.default_trigger = "default-on",
( ?+ ]( S! p' d4 ^; Q; M },# t/ T9 R5 G4 z0 c @
{
" f. H G/ I/ x E% d7 K1 ?9 ^ .active_low = 0,% l7 R7 e1 j4 \; w: Y% L" ?* ~
.gpio = DA850_USER_LED3,! y3 q" C) a: h$ h1 {5 F
.name = "user_led3",
1 s6 U5 y7 B0 ^, c! X/ P .default_trigger = "default-on",
- c+ F* V1 O" U! i0 j' u },/ q) g+ C o. F) s
};
7 R# ~) g, V: m5 X+ i# r
; a! L; v2 u/ m+ w! m& fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 i# B7 \# M- C/ \! j .leds = da850_evm_tl_leds,- W& g' O" _$ |% C) E
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' n) Z- z) E) r$ u# z' p
};$ b1 J; {8 D P
1 h b7 V6 ~4 l$ |' pstatic void led_dev_release(struct device *dev)
. N# N: i* e4 c8 E* L' a. V{
- R/ p5 b& J: S- K% r7 n};
g- g( V o- n. b, o3 h4 i5 z9 X y: ]. {" C- n7 @# i
static struct platform_device da850_evm_tl_leds_device = {3 D5 r# h3 H) b& [
.name = "leds-gpio",# ]7 P1 ^( i: F2 U' v$ m
.id = 1,$ ]1 m1 G8 ]6 [9 I: ^: M7 P0 _
.dev = {: t+ y3 }% y( b/ @- d( H
.platform_data = &da850_evm_tl_leds_pdata," ~" ~9 D u) }3 _
.release = led_dev_release,! J; {7 B; P! l! h3 v
}. o5 j7 J6 |2 u
};
: O: W% P% ~6 `3 ?/ Z- E3 h
+ s8 t/ j; o9 X `* [* Dstatic int __init led_platform_init(void)2 `5 X: @' `/ r' u1 L! w
{8 g7 h1 X2 `4 S8 i: n- F3 P% `
int ret;
0 c5 w4 I1 G t9 ]. O#if 0
2 @" W) M7 D2 V1 T9 [ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! e) B) o p6 b- z$ d" x& V
if (ret)8 k' d( G5 B) U& v$ a$ V0 O
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 c. A; h/ m& f2 C" l3 @/ C) n "%d\n", ret);, c, s8 r4 Z$ A+ U8 k9 M. y, f
#endif% U# l; M U' p8 i" t
ret = platform_device_register(&da850_evm_tl_leds_device);0 Q& Y' R. b& ]) [7 p
if (ret)# z5 M- E) k+ F$ p3 u; w+ a! \
pr_warning("Could not register som GPIO expander LEDS");
: [* B* r' x. o else: I& A5 P x' W+ f
printk(KERN_INFO "LED register sucessful!\n");
) q. c0 W+ r, @6 |) Q/ h# H1 U
5 ` l6 w( L! d4 {9 V& A9 [ return ret;& g( C% R8 A) S: p
}
" j6 D# H9 q0 [( }2 L. l8 y9 K) ?0 x# @2 B
static void __exit led_platform_exit(void)% y/ @7 m9 v9 s- e4 Y
{8 G, \% T& [' d
platform_device_unregister(&da850_evm_tl_leds_device);" U, n0 F- O' p
5 @/ Q6 C! n# F printk(KERN_INFO "LED unregister!\n");1 ~) _$ ~( M& F" `8 \+ O5 p
}
& I/ ^5 k8 Z$ p1 \4 z9 G, G2 }" P& u- I
module_init(led_platform_init);( d3 R ~3 e" E% u+ k
module_exit(led_platform_exit);
) H+ `$ z1 _5 e' h' A7 @" {& S
. l1 }% o* b0 A+ J! O d/ mMODULE_DESCRIPTION("Led platform driver");
8 R4 Y. _" T2 y& T5 h- hMODULE_AUTHOR("Tronlong");: b) r, b* u% Y9 I" r. e+ U4 E
MODULE_LICENSE("GPL");7 [( y2 Y( t3 T2 V3 @7 U. d
9 X' O7 v- L; u! M
|
|