|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 S: b3 f( t' ^1 B/ s
#include <linux/init.h>
# o! b: d* L% N/ S& w#include <linux/module.h>! K5 _) w# ]4 L+ |$ u
#include <linux/kernel.h>
! A2 R1 {3 c2 d; _#include <linux/types.h>
8 w: n+ r' H4 |& J, z! I% u#include <linux/gpio.h>; o+ l9 u2 b5 d5 C0 h3 U" u; h
#include <linux/leds.h>! w5 }# N" @* X1 Z3 T. H
#include <linux/platform_device.h>% h6 @( f# {9 S9 ~
, T% H% M" q5 W0 ~1 G9 c- X#include <asm/mach-types.h>$ c4 t& G1 R7 h# W
#include <asm/mach/arch.h>) b; d- v8 V9 W3 |
#include <mach/da8xx.h>2 i* K' t+ N7 \% K
#include <mach/mux.h> T; w* C" @8 }$ w+ j7 {( @: E/ j
6 e5 f- w/ X& q& W1 d#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) S( i! b; x. u9 _0 w2 q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 P2 l4 m3 G! p) l, d- d# f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' I4 H7 `$ {3 A) L* |3 a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
1 D$ d4 l$ r: \ y$ L" v( D7 ^/ m! b: B8 a# e5 F2 W$ F3 A& j
/* assign the tl som board LED-GPIOs*/
* T+ u0 W" X: mstatic const short da850_evm_tl_user_led_pins[] = {
! s- ?3 S4 e- B7 d' I* ?/ w% A* ~ /* These pins are definition at <mach/mux.h> file */- f% p/ g5 t! |! Q# r
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 Z8 Y" A: p+ h8 C, g8 J1 i -1
* L& x" c q( |7 ?; _ u7 w1 \};
0 h5 k" Q+ Y2 X( a# d
1 k# W7 G3 K3 h% t% G5 c# F3 Ostatic struct gpio_led da850_evm_tl_leds[] = {
% r+ N: w! d6 V" { {
0 w5 `* l1 s$ X9 ~2 C- Y .active_low = 0,
9 F; ~: J" ?. `# G% g& d# b/ c .gpio = DA850_USER_LED0, X& v- J" `" H
.name = "user_led0",* B' [' Z+ D: y
.default_trigger = "default-on",
8 i$ s% s" B- W( z7 C },
* R m- A6 }- K6 R2 a+ h {7 `+ ~8 M& K1 x) w) @ ]
.active_low = 0,0 b$ a$ |0 b* n j' s; ]
.gpio = DA850_USER_LED1,
. d$ [* R3 v/ Q3 t- t" c .name = "user_led1",* u0 M& m { z, `
.default_trigger = "default-on",. F/ }' Q" c( U; R5 I1 Z" w
},# S. v, k" ^6 G4 l# [ g+ m9 ]( T9 t
{
h& q# {, h8 V% W& }, }& ~- q .active_low = 0,
, }7 r% X# a9 O .gpio = DA850_USER_LED2,5 B* }5 }, p# ?3 t+ _. `5 W
.name = "user_led2",9 ]6 U$ R' }2 D( `9 \( V
.default_trigger = "default-on",
6 r) F; `. x* G3 B },
; q/ U4 U/ a$ }6 F {- V U0 }) l. N- q6 f7 V1 u
.active_low = 0,# I. G# z; h# r ?, m5 v, a
.gpio = DA850_USER_LED3,6 I& V, }9 [3 a: K" C* ?$ @# w
.name = "user_led3",& t' Z! M; [# y$ {% A
.default_trigger = "default-on",1 a4 N+ \% ?7 s* l( F
},& D& F* |7 d6 e( N
};# a5 @+ t7 M& \
. b5 A, P6 a- O7 kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. K: v( y5 g! F r0 A# T# U .leds = da850_evm_tl_leds,' i" h9 Q+ i* _1 j8 s
.num_leds = ARRAY_SIZE(da850_evm_tl_leds)," w% g! Q/ x4 s6 A9 F8 R
};
/ y4 P3 d. n; r9 y3 C) T% { S6 ]6 ~; F: y
static void led_dev_release(struct device *dev)
9 g0 a& e% m# d$ t2 K; p3 [{2 m2 L0 P7 V) ?1 K& s7 }& h
};
1 ~" x" N: J$ s( |2 Q e/ w z _- ^9 l8 b
static struct platform_device da850_evm_tl_leds_device = {, r1 S0 c: [) ~6 ~* w* s
.name = "leds-gpio",5 A! n N3 K3 M" l$ }
.id = 1,
7 \5 b1 ?- u$ j/ r4 f .dev = {
* n" L( s8 a7 Y# a5 t .platform_data = &da850_evm_tl_leds_pdata,
9 y8 K0 o0 ^; i# a" e .release = led_dev_release,/ h4 Y, d$ U0 e
}
) P6 E M7 B( B9 \* N; D};& S8 J- i F. c8 M
+ ], p/ N; `7 {5 O1 e; F
static int __init led_platform_init(void)
3 R0 w5 O* _$ Z{
; u; v; @$ C8 U; a* `4 _) T int ret;
( W2 _! C; K5 i/ n8 j; @; }" k#if 0
1 Z% M7 I7 H/ n ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" j/ G! F! r8 S
if (ret)3 R P7 m/ z5 D; @( e
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( X2 _& i9 v8 W, J
"%d\n", ret);9 l, x% D, l/ A1 d- B
#endif
+ N" [, ?/ w/ g2 S# U# R; i; h& [ ret = platform_device_register(&da850_evm_tl_leds_device);
$ C$ I3 T. E% Y6 s e if (ret)
- Z7 ^) n5 F( r+ U' i- Z( C pr_warning("Could not register som GPIO expander LEDS");
. [0 _5 \# X: O+ q. v else
) j; w. y% }( R; P printk(KERN_INFO "LED register sucessful!\n");: g9 ]: ^' E3 m$ @) C, W7 A s
" ?1 N' D' U. j: j1 P return ret;
- D! ^! U4 y6 } e( S6 H}+ \ P0 y, u8 f$ \" N& `
& y8 m) C0 ^1 \2 t9 c
static void __exit led_platform_exit(void)
/ H3 L8 g4 a" M q- \: Y{
3 E8 i5 i( M) Y* i/ i; Q# L platform_device_unregister(&da850_evm_tl_leds_device);1 \. o# p6 W) T! `& H9 e8 k
* k9 E: F. P5 Q) k# q+ T9 e
printk(KERN_INFO "LED unregister!\n");
; R2 h* h$ l$ B$ u7 f' @$ E, P; m}! J! p, n8 g7 U$ E7 \
$ J, O8 w% b7 w) v' smodule_init(led_platform_init);
9 d& K& p8 j' x4 hmodule_exit(led_platform_exit);1 Y* @7 R4 p' R& `0 t7 ?% r% A/ X
& N5 }; _* i2 {3 l' H5 uMODULE_DESCRIPTION("Led platform driver");
3 P# N# Z: D% r6 t9 f: ?* jMODULE_AUTHOR("Tronlong");7 ~& I1 H# a8 v. [" x
MODULE_LICENSE("GPL");
5 P5 B6 h) j4 T; E; ?* S
: t8 a# ^) i+ c/ h |
|