|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' [0 k) |" d* O" `3 A4 J$ ?$ N3 }#include <linux/init.h>
! e* w+ z* f/ @5 K2 k8 p. W; @#include <linux/module.h>6 t& v, M2 c. @5 n! c
#include <linux/kernel.h>
+ g8 k& C+ t, Z- T0 S, j' O#include <linux/types.h>* D; w6 f' c( O- c: Y
#include <linux/gpio.h> Z* Z$ D; k: @; }5 c5 D# I
#include <linux/leds.h>5 T' X9 M- O: ~2 {0 ~* {% r A
#include <linux/platform_device.h>- v# ]( {( R7 \8 N+ B% }
4 J* l2 c8 K9 K#include <asm/mach-types.h>( E6 C0 a' c0 w
#include <asm/mach/arch.h>/ x5 I# g/ ?5 d3 q# V" d0 ?' s) a2 Y
#include <mach/da8xx.h>
3 v- {* x; k% \2 {* s- U#include <mach/mux.h>4 H2 h# y+ J- h4 D% {: E3 L
3 X6 b, ?6 e; T) ]; D
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! e/ Y3 V- y% v ]% e, R#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* @5 r8 ^& U# Z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) ? S' y$ ?# c+ b
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 J* {$ B b- u" h% j+ ~- Z1 U" |# w' j$ ^9 z% B
/* assign the tl som board LED-GPIOs*/0 \1 f" S# I* q3 D% M; Z
static const short da850_evm_tl_user_led_pins[] = {0 D' f8 ~" h4 G5 c; ]! P
/* These pins are definition at <mach/mux.h> file */# w! q2 H- G/ X6 G1 o, y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: P6 v3 c- d* f7 M: e$ z0 d3 W% b -14 |3 d* ]( T5 ]) b( Z( F$ v
};
! j6 h. G4 G! Q/ F7 w2 r0 P) b2 E; G8 V; _9 I6 d8 R3 y
static struct gpio_led da850_evm_tl_leds[] = {
- j$ s7 R5 C1 K, y: p- y9 L) t7 b/ e6 N {
. ^: A' ~/ o' h& E: o .active_low = 0,& \; v7 K( `$ `6 i8 G
.gpio = DA850_USER_LED0,
; i% t. Z" M2 V; N .name = "user_led0",7 G2 N4 L$ m* c8 O) S6 _
.default_trigger = "default-on",* C2 M" S2 w0 H- {5 b. d. N% U/ P2 }
},
D9 s0 s" X& \$ y {
7 a; f6 G0 F2 V( R .active_low = 0,
2 h% N+ V2 m2 B V# A .gpio = DA850_USER_LED1,
9 u S0 y, B4 C$ J$ O6 r4 A .name = "user_led1",9 k. g }# h4 M( a1 i
.default_trigger = "default-on",2 v/ H3 N+ g. ?2 t. Z
},
5 u1 W$ m' ] l {
: A# {2 O' q. P9 ?* z& ~ .active_low = 0,5 R) C; W1 e9 F2 ] r" a
.gpio = DA850_USER_LED2,
5 D: B5 O, l+ J g+ {3 K .name = "user_led2",
. z( T) f7 v& {* q/ v+ z& Q .default_trigger = "default-on",0 z$ ~* f$ V5 z k) U& `5 s
},% L! u7 S( _8 @# A2 M0 I r+ H
{
" T) q( m* l3 E( |" M; E& v% K .active_low = 0,
0 e" v% F8 I3 y8 I( N .gpio = DA850_USER_LED3,4 c! a# u" ~. q) c# m& S
.name = "user_led3",& u8 ^8 ~3 i! X |6 Y
.default_trigger = "default-on",7 S; w0 h# v; V# L* A |/ k- t6 ~
},
- Z1 y: x) }% w! G: i};7 s: a& ?/ e. J6 I' a! e3 ?8 [- g
& q8 S/ {( C- k$ f$ Z7 g |2 L
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 \" ]8 Z; O4 Z- g2 h, v' P3 i9 V; X; T
.leds = da850_evm_tl_leds,1 T' P, K. X( C2 ]
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
+ a; k& d( l2 Y};/ D# x9 ]8 t' h
# z0 D1 L- s6 a, b) p# e8 istatic void led_dev_release(struct device *dev)
! u a, z7 e9 S, e{
8 [% R. r3 R; Q3 g};; W: |+ t; Q8 G* W: m5 }1 |6 ]- c
# A; q, I; l" X! }. i) |2 \
static struct platform_device da850_evm_tl_leds_device = {; n+ c# _$ ^9 b) o2 ^* q& D
.name = "leds-gpio",
) T+ h* w3 _8 k( W .id = 1,
- P$ H; ?/ w9 }% ?. D1 A .dev = {5 Q% Y4 G# R% ^/ W5 L, P& p; Y
.platform_data = &da850_evm_tl_leds_pdata,6 g$ D' T& Z" G- c
.release = led_dev_release,/ k9 i5 H8 V4 n8 ]1 ?* u' R
}
) N; g2 T. z' \/ n% P3 t; ~};8 [3 K8 i$ Z0 ^" b8 ]6 [
5 o1 ~0 m, j& ~
static int __init led_platform_init(void): Z8 C; U8 K5 [( w5 X% [
{
0 k$ B4 _+ f, b8 J4 y& U int ret;
3 S( O0 S4 P: x) b) d+ o#if 0% L7 K- Z' K- D6 V7 B; Q, |( A1 i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% ?" S; i% l# l' w7 Z if (ret)5 E7 P& ]9 Y. E7 s
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 @3 S8 G- \7 H. O "%d\n", ret);! O) a R l9 b6 c; K
#endif9 y, ~6 V- R! m5 z1 K% d
ret = platform_device_register(&da850_evm_tl_leds_device);
) N" d( b4 }$ q if (ret)( ^3 D( J( h q8 f) \; u2 ?
pr_warning("Could not register som GPIO expander LEDS");5 p" L! X1 N& Z$ w7 @4 |$ d/ p
else
# u$ W+ b; Q& Y$ P printk(KERN_INFO "LED register sucessful!\n");7 U: D* T4 ?- P7 D1 @! G& o, ~) X* W# A' ]
1 F! Q5 J% O3 o+ Q3 C% R1 {) ^ return ret;% A/ J" V" g- e% s
}7 j+ Q4 z/ m( j" l. W; b# }( C; J
0 \: L9 X! }1 s1 y' T8 B+ I( ~# M+ B# _
static void __exit led_platform_exit(void)& z% m9 j% p Y5 a! e, W4 B
{
+ N6 b) i' J; q- d/ S platform_device_unregister(&da850_evm_tl_leds_device);
, j2 l) `" t& {' v- H9 R [5 D3 {- x9 q1 F4 K# J3 L
printk(KERN_INFO "LED unregister!\n");
/ O# l) n- B) F}' S, Z4 W r0 d0 ?0 T- O
& V0 k. T. I. R7 U" M; \
module_init(led_platform_init);2 g# S8 z5 K: `
module_exit(led_platform_exit);: ^. B1 @) J, e) H
3 p% ^3 Y* v0 Z/ xMODULE_DESCRIPTION("Led platform driver");5 N# q ?4 u! p) p( h% z5 p4 `
MODULE_AUTHOR("Tronlong");, x8 I/ l v& q. D7 `2 o0 K) Q
MODULE_LICENSE("GPL");
2 I1 E# F- o N1 i) b" H- S
2 D g2 N7 A7 \* x9 E5 V2 P) F1 }6 o |
|