|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 s0 K) u" D. \6 T" r+ b# d! K- x#include <linux/init.h>
/ s5 L* e5 s* S8 ?0 ]' H& O#include <linux/module.h>5 Q. v" E1 ]& |, ]. d$ m1 W
#include <linux/kernel.h>! t$ U/ u: M. O
#include <linux/types.h>
+ r7 ` r G" N$ L- a/ g#include <linux/gpio.h>
. L- ]. u" h+ K#include <linux/leds.h>5 K7 Y/ ~$ W9 [! g' W4 d
#include <linux/platform_device.h>0 J' T+ r1 s B( t$ }5 v' `
; g$ O8 K: @+ W' ?5 I0 z
#include <asm/mach-types.h>
5 E) s5 W& [9 n#include <asm/mach/arch.h>5 L u$ v, c6 t/ r$ c# `
#include <mach/da8xx.h>
% @: x4 U( T; X) W0 {; I#include <mach/mux.h>
0 I* r* d9 f, `3 J% H* }
- ^6 J/ C7 S" q. _: ]1 c#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 B+ `( V' C+ h' j( ?' a#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). X% D$ V( K( j, ] t
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- Y8 G) r6 ~ N+ m( r; @2 { S
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, D. k( o' _5 O C0 [; c8 R* M$ C5 S7 H- x g7 L8 I# i9 J0 B
/* assign the tl som board LED-GPIOs*/
) R2 g, }% x) m j* w8 ]static const short da850_evm_tl_user_led_pins[] = {5 {0 V) b( K. N: [2 W
/* These pins are definition at <mach/mux.h> file */2 n- h8 O' |- ]. N/ L
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
3 f+ ]0 }! ~" {; L4 y6 W -1* [( P8 n. L' R' Y
};* S; V* x+ v# m$ p7 h9 E) o
4 J0 w& s, G) Y: N8 a
static struct gpio_led da850_evm_tl_leds[] = {
( x# P( J) |; @& D, t2 w# Z {
) M3 m- r2 Q1 u .active_low = 0,
. W( p" d2 D; K) ^- p4 ` .gpio = DA850_USER_LED0,
8 }2 Z6 ]# S! x, P- h1 Z .name = "user_led0",- D: Y# b! b' o: P; x+ z
.default_trigger = "default-on",
: q3 j: Z& z7 K W" ^. z% b },( i% g% ~) V5 f6 X) @
{
" H# ]( u1 R, Z .active_low = 0,
4 S3 _# z4 c) ?+ ]/ ^3 s4 ? .gpio = DA850_USER_LED1,
- t7 t# E, A- O% F& p( I- O( j .name = "user_led1",
# l6 R, G" i6 V" e6 h& i$ ?3 T9 k .default_trigger = "default-on",0 i! s' t0 _- s( j/ i% \1 L& k
},
8 \0 P' o0 w. y: m0 K1 x( [9 L {! ^: F, C% r1 n6 ^
.active_low = 0,
) Z9 d% K- H& t( [; u0 Z- ?% I .gpio = DA850_USER_LED2,
3 ?( ~, d/ |1 j( V1 }# \+ U .name = "user_led2",, E( l4 z5 M/ N4 o" B; C+ z: k
.default_trigger = "default-on",' \. L0 \& M' ~' c9 ?6 z; @7 H
},
8 u" O% N" c- c0 ?1 a4 |$ b {
$ k; ]( k0 M7 D$ a6 A: O0 K .active_low = 0,
; _) u5 X5 o3 s .gpio = DA850_USER_LED3,
5 F; G# R/ O' J1 k0 a .name = "user_led3",
9 i: V# K& O6 Z0 y! V: @ .default_trigger = "default-on",
! d( C* d6 l, ]7 B7 j" ? },! r0 j$ i, s& l3 t
};
9 Y% a( E: \9 t4 k1 ^ `* O& T& K% g4 o- ?
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, d5 d- N" C0 ]/ O; i2 P& O .leds = da850_evm_tl_leds,/ G) X4 z" ]: L
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 q' k. `/ W* q8 s7 c* U" d2 K0 m};
! X2 H7 W9 i' f! \: |8 a7 d0 j% L9 [. _/ ]' m& T0 ^9 `0 y( L2 h; I
static void led_dev_release(struct device *dev)
9 O$ Q) N" e: O* m{% Z. h+ p9 t1 a) L' Q$ U! }! p' S
};& ]/ a2 a0 x/ d
' r; N. s* J# S5 k, Xstatic struct platform_device da850_evm_tl_leds_device = {8 P7 Q2 f) {9 _, t4 X- A
.name = "leds-gpio",+ N8 E" Z2 W: S) f
.id = 1,( p: E7 a# S: Q% T
.dev = {+ `; B- w$ F% z# D+ b1 f
.platform_data = &da850_evm_tl_leds_pdata,1 E2 G8 i3 E) O* r! @; Y$ [
.release = led_dev_release,$ i- l/ i5 l5 m' @5 g( B
}$ j+ I+ L9 o9 S' b; I- d
};
5 z9 h6 ^* t) T/ D2 O* ]% L/ i1 z5 }1 ^/ c. B! F
static int __init led_platform_init(void)7 q( h$ z& [# h7 z3 g
{4 \& R3 M* I* ?! S; `, m; S+ N
int ret;$ [. Q1 b& _3 \- y5 I5 M& V
#if 0; c! P) B, p" l8 e: D
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, {3 T# I( w3 c9 p4 K
if (ret)9 s( z) | _7 E% o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ H) E7 v* c( A "%d\n", ret);
, z N: k$ r9 \% v0 O#endif1 m* }! k) j& y2 p* J
ret = platform_device_register(&da850_evm_tl_leds_device);& q2 ~0 T `5 E Q
if (ret)& i+ U2 c% N2 j, d8 {
pr_warning("Could not register som GPIO expander LEDS");/ o4 [1 k8 M4 K0 O5 p
else
/ o+ K" n& ]$ t. ^ printk(KERN_INFO "LED register sucessful!\n");+ r' C4 F& Y8 \
( @7 H* k7 D) h8 B4 [* C
return ret;
" _( o" H% a% E}. ~$ y5 Y0 o6 P# H, X
2 T5 a* w* d' L: h
static void __exit led_platform_exit(void)" J. C5 G- Z& |6 N) ?5 v3 \
{7 z- S A% [) y: y- R+ v1 O/ }& a- ~
platform_device_unregister(&da850_evm_tl_leds_device);3 ^" n. R' p7 Z& R8 O# b& R
4 F* v/ }/ A$ p2 } printk(KERN_INFO "LED unregister!\n");9 u, O- ?4 @- N6 M7 l- e" Q! h
}
0 d7 I& _) d% L7 X7 f' P6 u1 ^. |; U2 h4 [7 [% w9 K
module_init(led_platform_init);) w- {3 }* W6 O3 @: [6 `
module_exit(led_platform_exit);6 [1 x- R$ g" z: c
' f/ ^$ x- P9 r; z3 q0 Y2 }MODULE_DESCRIPTION("Led platform driver");
4 S" g$ d1 c! A6 g5 u ]) yMODULE_AUTHOR("Tronlong");3 s, \9 U; P4 y
MODULE_LICENSE("GPL");
5 l& C! P$ P( J7 w$ n! H- {+ L
0 P4 `- [. J5 w |
|