|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; }# ?& Y) w ^8 m* V#include <linux/init.h>* z, m3 m! @' r
#include <linux/module.h>
1 W$ D8 @/ V* |2 k {#include <linux/kernel.h>
# s6 f& Q, u( z8 ^/ _#include <linux/types.h>
) R2 q7 ]; U' M/ n1 ^. t- H5 g( q9 b#include <linux/gpio.h>
5 T9 U' t, i3 B8 G#include <linux/leds.h>: c3 @, x( |" n
#include <linux/platform_device.h>
& q8 g' Y& _& @# t! ]' @8 J8 E# Q- A3 {: ]0 X+ s' p3 z
#include <asm/mach-types.h>5 f( A7 S: P0 j/ {% ^3 d" A y
#include <asm/mach/arch.h>2 k* s5 `' T- E* a
#include <mach/da8xx.h>( H" W% o) M4 [8 j2 Y9 H2 m
#include <mach/mux.h># k# b5 G: m1 _% c. N3 h( L
! I6 e' P( j* }; }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) p9 p+ v* {7 o9 k1 B8 m#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 X1 f3 N5 k+ b- e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 a" Q% E: S: N+ T: W8 _0 w#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 k, A- w5 ?* V$ h
1 E9 h/ u! r/ I; Q/* assign the tl som board LED-GPIOs*/
9 D( T, H1 S, Jstatic const short da850_evm_tl_user_led_pins[] = {
. J1 v7 |9 \8 G* C3 ^4 V /* These pins are definition at <mach/mux.h> file */3 R4 k6 j: x& \, v; z, u+ k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 `. x# _8 B# O4 c -1: P% o0 ]9 C2 \
};" q s' Q+ u3 m, Y
4 s+ @. i! V( m7 f' Q# istatic struct gpio_led da850_evm_tl_leds[] = {
+ L4 z7 B0 c0 w {; g* r5 h) ~6 V/ j5 y# G T
.active_low = 0,
1 o5 b- @ M1 c7 l: l .gpio = DA850_USER_LED0,& W. [' m5 X V% ?. l7 [( ^" g4 f
.name = "user_led0",
8 r8 w; q* V4 j) E, I .default_trigger = "default-on",4 H( \: B, R) I) ]2 e) n% Q+ D
},
% M' m9 u$ J l9 D {+ H' n' T4 i, Q7 H
.active_low = 0,. R; @3 c6 o P2 c0 N$ X( T+ R
.gpio = DA850_USER_LED1,
. C9 a3 y! Z6 ^4 R$ E .name = "user_led1",# R5 D; J) Q: a9 `! R% ]7 U
.default_trigger = "default-on",
! P9 u$ e: [. s; i& M },1 v' j) O) f, P) W
{
) W: x2 v& V; W! n# c .active_low = 0,
" ?& {% Q7 `1 J0 { .gpio = DA850_USER_LED2,+ m2 [7 G! p! N) g
.name = "user_led2",
8 p6 x3 W% o: g1 V .default_trigger = "default-on",
2 F- W3 B9 l5 k3 K, K' [ },
" [; }: w& d- q4 @ {) v) |( f3 D/ Z
.active_low = 0,& C0 k* @. @! t' K* h
.gpio = DA850_USER_LED3,: C& M% M* }2 K, A
.name = "user_led3",/ ~0 @& w* Q8 S( Y( D, c* k
.default_trigger = "default-on",) W3 I' \& Q1 ?- n7 X3 A& z
}," \+ s$ i- d' m% C& t* o
};
! I! \) H2 k% p$ ]* l/ f* E: }, h) J8 Q# R# d1 I& ?* g
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 e9 I' m- U, d1 E0 [$ u4 y .leds = da850_evm_tl_leds,
5 h, ~: b: o+ C* x, ^ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' H. l$ A- T U. L5 Q4 L! P};
3 R5 Q1 h, g7 N7 M9 s% @/ X0 {7 I+ v- { w
static void led_dev_release(struct device *dev)8 }1 l7 h" w3 U o6 P: A0 V- y: m
{
* m+ V+ m+ _6 H};
8 p6 a7 W: b7 b; N9 M
8 Q+ S- e8 s R$ dstatic struct platform_device da850_evm_tl_leds_device = {) \ D2 o4 q) ]6 r
.name = "leds-gpio",; D" u+ r3 y7 M6 m1 _; F* f3 V
.id = 1,
5 @" T. U8 A" ?$ d .dev = {7 O, R) P. C1 T- c
.platform_data = &da850_evm_tl_leds_pdata,7 ^; I. Z7 W1 x- l7 `) C& I
.release = led_dev_release,8 v5 V9 Z6 V# ?# N; k/ H( B
}. q- ?7 z% H8 X6 |
};
& A x$ W6 y2 {4 Z) n- t) k$ q# X+ z0 z
static int __init led_platform_init(void)
* E; a$ ?* H; |- ?' m( U3 J{8 }* t- g. B: _! v$ t/ j
int ret;5 h, }* r7 \! K' P9 S3 I$ W
#if 0
2 `+ R! q0 I1 n( w$ [! @; X ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
Q/ c9 Z7 O2 P% V/ W) v if (ret)
* D7 F% l. r$ }+ m! f S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
$ J2 [! i0 C5 G* e "%d\n", ret);
8 |$ X1 I- }# j/ Y6 _) x- }: v#endif
( z7 t- n0 z; K) H a U ret = platform_device_register(&da850_evm_tl_leds_device);
/ B# w/ k; A2 a if (ret)
3 g; u) B9 |5 U* j) |0 ^ pr_warning("Could not register som GPIO expander LEDS");
$ o5 r9 d4 H. x' } else
4 C& Q, @/ X, w printk(KERN_INFO "LED register sucessful!\n");
- O5 w/ u* }& S* O/ u% d5 S' [& L
return ret;/ }0 r0 s; H+ @) j
}
9 M4 _5 r9 {& U5 t* }1 u/ R2 C2 h; p8 K! v; V& n' X) j( @" ~, s
static void __exit led_platform_exit(void)2 {0 `0 U4 ?+ ]& P
{
0 ~. n+ \ \6 z1 a: M6 v% C platform_device_unregister(&da850_evm_tl_leds_device);& P+ m% ], B0 T, o/ I' H' Q
5 I1 |. J+ j$ V; }5 [+ f+ e printk(KERN_INFO "LED unregister!\n");
: X4 e: o! g) e' |}
/ Z) e6 Q- \! A2 |& _2 p2 n. _) C! V3 h$ G# u) S! {5 {
module_init(led_platform_init);
. ]; X" v3 m/ i" Tmodule_exit(led_platform_exit);6 p) D( b! \' o* k% `' s
6 Y. D1 F, ?2 y* {; Z- T
MODULE_DESCRIPTION("Led platform driver");7 g# {! {) J" g/ E8 G
MODULE_AUTHOR("Tronlong");" r7 W$ C1 \' y$ g
MODULE_LICENSE("GPL");
# D8 ]1 q: l+ u) O! m9 ]8 M3 V
* P# B; |" A# b; b: l, R+ B |
|