|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 z- ~+ \3 p9 d9 ~* t0 j#include <linux/init.h>
# \8 E5 _( t2 m4 Z1 o+ O& P#include <linux/module.h>
5 t5 }. |" V- e#include <linux/kernel.h>
+ d4 ]( o6 X6 |6 k9 n1 H5 }) [#include <linux/types.h>
$ a) a+ J, {9 }' {" g#include <linux/gpio.h>9 d& P. e: d" s+ |, \) \) r
#include <linux/leds.h>
$ {& Y/ ?' h* c% U; w( Q#include <linux/platform_device.h>' c$ ^0 l) S/ d3 P; }# z9 [- z
& M& i; r2 t ~8 H! k
#include <asm/mach-types.h>2 E/ K- S( u% {# H: ]
#include <asm/mach/arch.h>
! x0 l" Q j \#include <mach/da8xx.h>
# V x5 x2 c" h6 L: [8 N4 w#include <mach/mux.h>& O& [! o: e: ^+ c9 ~
/ r# B% o5 ^ B3 W7 w5 {
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 T8 b# u$ \: j+ o' D. i) V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)! E4 _& M& P8 J5 _9 I. I! Q, i* v
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# l$ d- Y+ W8 q+ O" w
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 z K8 B0 @, M r: ~& F6 m5 k0 s3 p5 o
/* assign the tl som board LED-GPIOs*/
7 d* |& U/ s n9 tstatic const short da850_evm_tl_user_led_pins[] = {. ~) P- S o9 Q
/* These pins are definition at <mach/mux.h> file */7 N' h, ~8 c$ k' `5 H2 ^
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. x* R6 l% |8 J: E" t$ D1 u- s$ ` -15 l" a1 D/ _2 _0 p5 P! F4 g
};1 l$ U3 Q( X8 W1 q
; M1 k; l2 a% u0 K6 \ D: `, U
static struct gpio_led da850_evm_tl_leds[] = { e y9 X% \! q; x2 ^
{
8 y# ^4 n( e" q( M4 q7 E- F% S .active_low = 0,
7 G0 Z9 q: N( W c& f .gpio = DA850_USER_LED0,
) }. u8 K; S- G+ x* I .name = "user_led0",- R( k+ v, k! ^4 c9 p- X& F: R
.default_trigger = "default-on",# Q: f; |4 y P( f* ^- ^
},7 D, L0 q) T7 H. f: S
{
?% L" \. X! [, J! V .active_low = 0,( o* B* M# C+ v
.gpio = DA850_USER_LED1,
. C0 `4 y1 `4 ]) A .name = "user_led1",6 C$ E$ I- q# o x0 z
.default_trigger = "default-on",
* w6 ^0 X! U& J1 N0 ?* ^ },
- a# n1 w8 n/ | {4 }( D9 t: v4 \& e3 i# Z& e3 d
.active_low = 0,
1 M* N4 G7 u% I8 \% I .gpio = DA850_USER_LED2,
6 I! W; J8 O7 l5 S. R .name = "user_led2",
1 ?% h8 r4 o( q$ z1 d .default_trigger = "default-on",% g2 V/ u' w9 P3 _
},
5 g ]/ y8 k# z* ?$ S {; s; ~5 w5 g( ~& g
.active_low = 0,
^+ H1 T( O3 W3 o3 N .gpio = DA850_USER_LED3,
9 w+ y. [1 z3 j( b/ y1 g3 } .name = "user_led3",. {* w7 r4 Y! w8 ~! l' H
.default_trigger = "default-on",
( I* Z$ w Y# H9 X: P. E- Z },
" h: C J+ `) |9 Q" a; |};
& X7 [+ I- P* {* ^; R4 K( h
, n' S9 p/ v( w/ z3 C) }# \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. {" v' v) y W/ C" u8 {
.leds = da850_evm_tl_leds,
: M4 E2 Y% E5 X1 u+ i .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# S H1 D# Q2 v% H};
% D q& B0 J0 V u; q7 D, ]
4 z3 P5 A: W/ ?" ~" _: b/ {static void led_dev_release(struct device *dev)
! q# y+ e2 @ _9 l{! @5 L4 ^. [6 f" k2 N, L$ V
};
2 h! a# b; [7 ~- r
; t. K4 v0 n1 L8 v. k: Sstatic struct platform_device da850_evm_tl_leds_device = {8 [! U+ F$ ~7 u1 a; ?
.name = "leds-gpio",
' h/ A* _0 Y& l0 g/ u3 v) V! {7 I* [% x .id = 1,/ b" C Z/ f. Z, H$ D/ a
.dev = {$ T* v; p9 q/ [7 D: A% N# P
.platform_data = &da850_evm_tl_leds_pdata,
1 I, I5 x* v! Q2 F# L0 p3 Q .release = led_dev_release,4 j. |9 `( k+ {" e
}- @' C* w: z' o! A
};
9 }- R& w5 Z7 ` J2 ~. c* x1 Z0 a$ |/ n5 q
static int __init led_platform_init(void)+ O2 _/ M6 Y9 Y1 i0 O$ S
{
# j* g% u% } f z7 H int ret;
% z; p9 j# I, L+ w4 o. l! x#if 0& L! O6 k2 E: x- L' Y) s
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# z3 {7 I/ P6 V0 A- U- a6 k1 i if (ret)
- K& s5 z( ~# v4 f8 l$ L pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! T" u" B: g. h; J* K3 ?: g0 Z& d# M
"%d\n", ret);/ h* j& S; I" L8 T' `! g! m
#endif
( N! y; Z' w' l- Q ret = platform_device_register(&da850_evm_tl_leds_device);
. a, [2 G0 k6 D, N: j if (ret)2 c0 P5 j) F) {$ Z
pr_warning("Could not register som GPIO expander LEDS");
6 g4 l) j3 u" x8 w6 k$ O else
; Z6 A. }! H. M/ ^ printk(KERN_INFO "LED register sucessful!\n");
+ ^: ?- E: @. q* N5 r6 O0 r- _9 a: y4 ?' n
return ret;3 D) h" @( H9 x
}1 r$ x% K5 U3 }/ D' t3 [3 H- }
4 J5 T+ L: [ ] {
static void __exit led_platform_exit(void)
" f. v3 Q- M. \{) U( A: U1 _: X
platform_device_unregister(&da850_evm_tl_leds_device);
+ S$ Q8 K* W6 n5 ^+ z m2 e1 c' F& ]; F
printk(KERN_INFO "LED unregister!\n");
. w m+ h w2 n# k: S x) R m}
4 |) B. |# J7 u4 p) h' t: H" g) K- F. |$ U* L
module_init(led_platform_init);# P, u" j5 b2 L+ E) h: s
module_exit(led_platform_exit);& |, N( w/ K2 z- e0 @
. g( E/ N4 @# X0 `5 G2 VMODULE_DESCRIPTION("Led platform driver");
# k& m+ k+ d& V5 {; Y9 oMODULE_AUTHOR("Tronlong");
' F9 [ t2 r1 V& L5 d' z/ `, kMODULE_LICENSE("GPL");
7 t( j# ?1 t q0 ~' h
( w. A# z3 S' V0 x1 p |
|