|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 f! {! p, R8 N* x#include <linux/init.h>7 l" H1 K; K+ L8 a- }$ u
#include <linux/module.h>
6 o) q+ U7 m: i Q% g#include <linux/kernel.h>: C9 [: a6 S: Z, t0 z2 e1 [, k
#include <linux/types.h>0 X5 V& A/ z- y
#include <linux/gpio.h>" j3 K- |; n9 ]- K2 q5 s- m+ `
#include <linux/leds.h>
5 G+ i4 J8 U9 m#include <linux/platform_device.h>
4 f0 x7 D. y$ T6 F
0 _; v+ P1 z d) _9 t6 V" g#include <asm/mach-types.h>
# }0 V' ]& a J#include <asm/mach/arch.h>' }# U/ s- }+ r
#include <mach/da8xx.h>
, s1 ~) a% J8 {/ K#include <mach/mux.h>, p3 [6 M; f. p n: o/ I9 n7 A
+ F9 M4 q% X/ I. k2 z6 `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' V* i; A8 x e2 R#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! N6 y& ~& ?) S. T0 Q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 }/ w1 h: j' [( Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ V' ?1 ?7 s: \; d/ H
& |& d6 w& H4 F) X/* assign the tl som board LED-GPIOs*/) i7 B1 j/ @5 i; W
static const short da850_evm_tl_user_led_pins[] = {
; i. b7 w' g. l. | /* These pins are definition at <mach/mux.h> file */
% G) d$ A, q9 I( J, N" \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ m: H! \1 I1 C
-18 ^2 P6 Z, D! {& ?+ B; l& _5 M
};
, m$ g1 e. P/ w4 r
( e) _1 M0 V: A" U8 h( K/ G5 J" }static struct gpio_led da850_evm_tl_leds[] = {& z( [* q; R% |% I: I6 T* H/ z2 r" D2 x
{
" G$ i" c8 g$ v0 A O0 Z* B .active_low = 0,- g2 B1 b+ T: ?$ v/ \
.gpio = DA850_USER_LED0,
7 C3 F6 P4 b2 I! X0 H .name = "user_led0",
, U5 {* F9 P6 Z .default_trigger = "default-on",/ x+ N) i0 y O/ u
},8 \) T! c1 ~# @/ q- w4 O& r, l# n
{ U2 Y9 N6 Q% s- I; E8 F" D, b5 L
.active_low = 0,
8 I" {9 C! H: a7 Q .gpio = DA850_USER_LED1,
6 _7 T1 k, V% q .name = "user_led1", I0 `9 b* J; _) F1 S8 T) _8 i9 k
.default_trigger = "default-on",
: C) o# y& o8 g" T7 f },' @9 ]5 w+ S! C a$ V
{, m, N3 e; h8 |; ^+ U1 h) e
.active_low = 0,8 H$ y0 Y, d6 k: I8 C9 H3 q
.gpio = DA850_USER_LED2,
; C }2 \1 M' y9 e( [8 ~ n .name = "user_led2",3 p) ^1 w0 D; D/ y
.default_trigger = "default-on",' g6 P# D$ F1 I) z$ l
},& Y3 K4 V% ] v/ d9 N/ x
{
& i" c3 X0 A) K z .active_low = 0,3 b8 N1 J# h# ?1 P) ?% v
.gpio = DA850_USER_LED3,7 u8 U4 u6 p4 |5 A- _" n
.name = "user_led3",
/ W5 h7 {+ j& `% l .default_trigger = "default-on",+ ]6 Z; b$ ]6 z: R; s
},5 r# l: P9 ^8 ^
};
4 O8 r, W; i: d/ V
g% Y V$ u5 U6 X* hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! M3 a& Y$ U# t8 n .leds = da850_evm_tl_leds,
$ Q3 @8 R z. c6 S .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% t; ?4 a/ [! O4 Y" \' ^" [};) b: ^* ~/ |3 h) Q) [( `
. Y6 q6 c# q ]/ z7 u8 i2 Q5 ostatic void led_dev_release(struct device *dev)
" x. t0 Y+ u, W- [. s{5 H/ S& y; X# o0 s; W4 a0 F3 Q
};" Z8 g6 G& v. _ `; v
* u$ C' q9 M2 s' O8 U
static struct platform_device da850_evm_tl_leds_device = {4 y6 w- X/ v$ S2 m+ d% I
.name = "leds-gpio",
6 N( T- Q9 V/ K/ q .id = 1,
0 F9 r' F1 d' p- l; s5 f .dev = {" }% t" F! d4 h& t1 g" K
.platform_data = &da850_evm_tl_leds_pdata,- @. K% u4 d4 R4 S' M" q
.release = led_dev_release,
, I% J! I9 F8 y N }7 f* d" t* u5 @1 Q
};% m( @) B/ p' U0 A8 u
; E3 L) P' H* t: Z. S4 b0 \
static int __init led_platform_init(void)
3 D, s8 {6 W5 D{
3 f9 x: x6 f; v+ u. Y# l# n int ret;+ c6 w7 U+ j4 a4 a3 r6 k2 o
#if 0
# A8 s3 `8 }& ^: t0 N# K2 i8 W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 N7 K l4 w0 E
if (ret)
( s1 u' \" e. n5 v% X& [0 H pr_warning("da850_evm_tl_leds_init : User LED mux failed :": g J4 a& w7 F: e2 ]
"%d\n", ret);! i8 h$ i" R3 h& }/ N# K) Y
#endif
7 N3 c0 U: p3 K8 y ret = platform_device_register(&da850_evm_tl_leds_device);
$ K' x* P, Y# f5 }* w if (ret)
; ]$ j6 W! C. c& m" k pr_warning("Could not register som GPIO expander LEDS");9 `4 U# T# Z- b: \2 K
else
1 l( Y& t$ s5 ? printk(KERN_INFO "LED register sucessful!\n");" i0 ~- ?' k: C; m9 D
, t3 t' Q- p" X! l* d$ `! r3 M
return ret;' r; v: H: z- K
}
$ V5 G5 V2 o/ U) q s; A' c
$ R7 U; V2 K1 t {. M+ ~2 Lstatic void __exit led_platform_exit(void)
2 T: [3 I& ~. Y{" \& I' |) _9 q1 a: \% n2 q
platform_device_unregister(&da850_evm_tl_leds_device);5 [- p+ h# o& Z9 W8 i
' c$ z! G/ E0 F$ h printk(KERN_INFO "LED unregister!\n");
8 B( A+ t. k: N8 \; S8 v* E}
! g9 h9 T+ r) F3 \' e. G: ?: w: f; D4 S
module_init(led_platform_init);
7 R7 c+ v2 ~% l6 G& q8 ?: e. cmodule_exit(led_platform_exit);! d! E1 \5 v" i6 C" K
) i& x0 ?. B# u* R: K w
MODULE_DESCRIPTION("Led platform driver");/ f9 m4 t% `- [2 g2 y+ l+ _
MODULE_AUTHOR("Tronlong");( i5 F! ?. a1 O. P, R! N8 u
MODULE_LICENSE("GPL");. Q4 F/ Y- F7 s1 t' W
) y6 ]5 A0 o& b6 N9 [0 l( L* u
|
|