|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& C: m5 ] Z u/ M s, q3 w: k#include <linux/init.h>
; l1 A# R" k* [7 [. M5 f7 T#include <linux/module.h>. { T! O4 c2 A0 ?1 E
#include <linux/kernel.h>7 u: \- U* }. o6 ^
#include <linux/types.h>
`" M7 k( Z! ^9 {# y#include <linux/gpio.h>( U* {9 g0 K, L2 }, \% }# c0 @
#include <linux/leds.h>
# P6 ]5 e; J$ R) l1 W' s( U: m( d#include <linux/platform_device.h>. h, Y* p& j" G" J+ R
& Y. Q: y7 O$ Y$ W! Q" S#include <asm/mach-types.h>( F3 Y5 o- _% s- n" a
#include <asm/mach/arch.h>' J" W1 g( {/ E7 ?
#include <mach/da8xx.h>
/ i/ [( M, F/ I' S: w+ Z#include <mach/mux.h>/ F% V9 y2 j4 q8 N5 Z1 o
: H |6 i. ?: I0 }. J#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- a/ x; `8 a" s m; I: U' O c, ?#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" T, J/ a" b. k* @9 g3 s" @" ~ |2 y9 n#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ r+ ^+ ^7 L( ^
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 ]; m! U1 S; b! \: B
C; U: s/ Q5 w3 g6 M( L4 D/* assign the tl som board LED-GPIOs*/
* y6 G O5 p- t( astatic const short da850_evm_tl_user_led_pins[] = {
+ A) ]6 V6 g$ S* c /* These pins are definition at <mach/mux.h> file */
4 d; y9 k! _* {8 O) I. k DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 I* z! }1 ~" P -1
: ^* W9 J* C3 h};7 m' P, P& y: r9 C; {. |: l$ p
+ z! }! {5 B' x; G! U9 H$ P o' \static struct gpio_led da850_evm_tl_leds[] = {
' t8 Q( G3 N/ u9 c0 K6 Y {7 J5 ^! `9 u- G
.active_low = 0,
1 f% Y1 |. i/ E .gpio = DA850_USER_LED0,5 Z' ?: z8 S! o7 N
.name = "user_led0",
7 C4 E% n& _3 M6 f1 ?1 C .default_trigger = "default-on",
$ A4 |- r8 T/ D8 f& U) M# x# ]0 D },
# I& o; g7 V6 e( g+ Q {
: `9 W1 S0 a" o. ? .active_low = 0, c# A+ c, e2 y6 K o
.gpio = DA850_USER_LED1,, P+ D- Q+ J' [4 P1 o# G4 R! K
.name = "user_led1",
- N% H5 i5 h F+ r- ` .default_trigger = "default-on",$ h; a, F2 M& M6 D) g: V6 U
},+ D5 e( w9 W/ ]* N! c
{5 G b, {. i- s* Q# V" B3 v
.active_low = 0,
. K* \5 h5 ^) M# r .gpio = DA850_USER_LED2,' Y1 {9 r ?" c( B; ?& t/ `
.name = "user_led2",& Q) C3 e3 l( d/ [* y
.default_trigger = "default-on",
N: r8 ?, U( x* d },8 c+ i0 h) z4 Y) C5 F2 t7 j9 n/ u
{' c( m$ {; Y5 y1 J: r
.active_low = 0,' T4 U q" X0 e, O/ j* h7 q5 X( X
.gpio = DA850_USER_LED3,
/ l$ p8 b' ]0 D! M .name = "user_led3",
8 V+ ?8 \& U2 r3 c1 W4 I6 f .default_trigger = "default-on",
4 W {! U1 B9 }2 j6 K },
# C$ d& {$ D2 A( J9 r};
' u. x% i# W$ Q- ?! `* {0 q
8 P* G9 C. Y- {; T3 z4 _3 s1 Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# v7 t" d9 \9 e, u d; Y
.leds = da850_evm_tl_leds,
$ h6 B. @& `' g, i8 [2 Q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 k3 w k8 B+ J$ k
};
6 f- G& W5 l: m. j9 }; M# {+ ~
* j$ C4 k v+ K& a$ i3 S4 Ostatic void led_dev_release(struct device *dev)8 x$ ]+ e% ~+ e6 h7 M1 O0 ?
{4 V6 J1 C, ?: H, f
};
- b _0 E8 `8 h8 f- G$ n6 u# q5 A' x
( I3 M. |' W2 d# L/ B4 f' K, }static struct platform_device da850_evm_tl_leds_device = {
* u5 w1 R9 y, X0 t8 m6 ` .name = "leds-gpio",
) P7 C8 O" F, P( P; o9 _ u .id = 1,
- ?* u3 o5 f! q4 d8 [( v# W" q .dev = {
! W( _7 Z( ]' e% E( ` .platform_data = &da850_evm_tl_leds_pdata,
& q3 ~; T P( E+ J, w' Y .release = led_dev_release,
. p5 W I& Q) F/ P1 ^ }& B. ?5 }3 Z8 Q+ l' n9 M. R3 e
};
8 z; Q9 q# N7 P, E; e2 R* d4 y! p- }; I* p9 f% u
static int __init led_platform_init(void)/ X3 W5 F% L( V! t& ]2 D2 ^
{$ R4 d, @. Z4 s( [5 k) O
int ret;% m- K2 y4 h4 E" T
#if 07 e J ]0 m( e2 A, l; C) L4 m
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 N2 g# s% p: Z" X
if (ret)
( j k$ M3 b& m' I @# ~ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 V+ B& x4 B; }# q
"%d\n", ret);5 {+ J3 [" ~; ]* F- S. Z0 X4 n
#endif
0 ^. q6 L: D+ z% j2 S# E+ Y$ l q1 [ ret = platform_device_register(&da850_evm_tl_leds_device);/ d3 B# D5 ~& Q
if (ret)/ O5 x, }6 f' f8 `8 _
pr_warning("Could not register som GPIO expander LEDS");
/ }" R1 Z8 n# w P else
P& P. A( G$ D! t( [( H1 E printk(KERN_INFO "LED register sucessful!\n");
, N' ^) D p! R& G% G3 Z S& b M3 L& R$ ?4 w
return ret;9 ]+ e" n3 h* [0 D8 ?
}
: J0 s* |! L3 m) |% j
/ J- p) v; }9 e3 f' T5 {4 x- ustatic void __exit led_platform_exit(void)6 q4 E" E% J: I% m: ?; v8 c
{# l: ^ k G$ Y8 Z, A. |; `* n
platform_device_unregister(&da850_evm_tl_leds_device);
& s$ x+ q: l1 M" W1 u# q7 k9 y$ T5 w) q- x/ G
printk(KERN_INFO "LED unregister!\n");
9 h0 B/ {+ j. ]3 V}
s- y1 L. T6 J' g9 l
7 I. u, o5 n ?0 \. M" T. Jmodule_init(led_platform_init);
% M. t" V# x$ {' }module_exit(led_platform_exit);
' c% { ^! A8 O; \5 l
( o7 U+ u w4 ?2 O2 H4 W% H/ h- DMODULE_DESCRIPTION("Led platform driver");& x5 H) t% Y$ l% m" x
MODULE_AUTHOR("Tronlong");
# C( }6 `' ~0 I( zMODULE_LICENSE("GPL");
, z: ?" V3 G7 k; O% i/ I$ c5 R" m) r) s! H# b* u$ d, ^
|
|