|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ t) L" i, s* }: N2 O- p#include <linux/init.h>
/ s T7 n$ ?! d, ?# `, @% o' m/ H#include <linux/module.h>
' z+ s9 N' l( a; ~" d. E- G#include <linux/kernel.h>
/ C0 \3 g9 ~3 x% [$ n; W#include <linux/types.h>$ v2 C% |7 j- y" }2 m7 h
#include <linux/gpio.h>
. R' X) W4 H. ]7 O#include <linux/leds.h>
- E6 r6 u8 x$ C4 b* b+ N#include <linux/platform_device.h>
! `/ a- L* m2 s7 H" p
9 O/ G$ m3 v* I$ P" J6 C#include <asm/mach-types.h>
* c7 P- s1 B9 \% f6 s#include <asm/mach/arch.h>
0 e2 Z& k. T2 x j ~% J# X#include <mach/da8xx.h>
3 H: ]( ^# j" l( x* ^#include <mach/mux.h>5 U, z' |" Z* s5 K
- P: f Y0 B4 E$ ^5 t#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# s, V! o* i0 _#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 \& f* f( }7 x& U) {' r9 a#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 X' |4 e/ Z' L' q, b
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( `6 y' v! b9 |3 K
: { o& u2 o" [
/* assign the tl som board LED-GPIOs*/5 w9 C8 Z4 L C9 P, x
static const short da850_evm_tl_user_led_pins[] = {
) P$ F' u+ r: e$ j( B* s: ?% C+ Z /* These pins are definition at <mach/mux.h> file */
+ O- |/ p4 P/ F0 g) n1 S/ C DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 O' ^# H! k% k5 k5 \/ k
-1
$ I3 ?1 |0 }, u/ Y; q2 q# J3 I: @- w};
! ~- a1 B4 l$ N7 x1 x, F* C* g F
static struct gpio_led da850_evm_tl_leds[] = {0 x7 e: I; |( {( a3 h1 L1 m* P/ e
{ P+ ?+ _; ~4 U2 |
.active_low = 0,
* r0 J1 k& w- E: [/ E4 Z .gpio = DA850_USER_LED0,
! P7 Y: q( s' Q2 F6 P .name = "user_led0",
+ B! `0 R: \4 p6 [% K .default_trigger = "default-on",* c) L) ~' A- O% O% L% T! o
},
$ b* @0 J" U% G {
, a2 V8 ]7 _4 o; P .active_low = 0,% C V* Z. ^/ `" o
.gpio = DA850_USER_LED1,
5 }0 \, A( l' L4 r& u, w! a. Y .name = "user_led1",
+ O6 m# I/ A2 c .default_trigger = "default-on",
) O0 h u- j4 A/ R6 l },
" V e$ Y% V( k* ^) Z {; g j; e D4 O" U& T4 u
.active_low = 0,
6 I* A: n. W8 U .gpio = DA850_USER_LED2,$ m6 V+ b9 u$ Y
.name = "user_led2", {# ^ e" d" N4 U: b
.default_trigger = "default-on",9 b0 W/ b, P- |" ?1 ]
},
: _& e7 L& G3 R# k {: M, x- s! E/ K* U/ y! H E7 x
.active_low = 0,
( l' z- d+ a8 `& M5 ~ .gpio = DA850_USER_LED3,; X4 K/ r: z3 S+ R" ]5 |) g" ~
.name = "user_led3",
8 w8 X4 [4 x* i$ y .default_trigger = "default-on",
/ t1 F! b3 i2 H4 P$ G0 p7 g: N },; h/ {+ }8 l- g
};
6 j B* C' l) V* c1 j2 h4 t/ i) v
8 Y4 A7 a& R9 v2 N0 p6 }static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* U( @# F2 w1 g ?9 u, g$ i
.leds = da850_evm_tl_leds,
2 H& O. V% F: k .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
* d4 b: O( A9 ?: J7 U& W% A, N};
. u: n+ L" F; G( B/ g5 v6 J- H) s& Q; e
static void led_dev_release(struct device *dev)7 \4 u# f4 S. [2 y( w' I) P" e( F Q3 E
{5 ?- T) Z- Z6 t
};
, l8 k9 {+ l& |, Q
2 S ^4 |/ H$ _$ V$ q; ]; ~static struct platform_device da850_evm_tl_leds_device = {
6 w o$ u% w, x .name = "leds-gpio",5 g \# r/ J! F1 x$ H$ {
.id = 1,9 Z$ x5 Y4 R! U3 y/ r4 {5 D
.dev = {' |" ?# h, E7 J* R$ U8 B8 I: o8 R
.platform_data = &da850_evm_tl_leds_pdata,1 C( {& j7 s% z- _- [: T( R
.release = led_dev_release,2 E; I5 O+ [% n$ C' u
}' ]/ Y! O' \2 \# ?4 z
};
' T! v, W; Q3 e2 i, {7 Y ]6 }. P. k3 D5 [* k. l% F7 Q3 T
static int __init led_platform_init(void)$ R/ }5 U2 \# z; D/ g b7 c8 o
{0 M( J# r4 _0 t0 T" ?
int ret;
( W K( q& G+ A! `#if 0
& N6 D+ _% c" T, T& \ H& L: z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);/ P+ t, D- d: I o0 u" q7 X" e* w0 P
if (ret) Z& e% V/ t$ H' Y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' l2 B0 m. I7 [ Y+ Z "%d\n", ret);
# a2 U* X+ u* z0 k% p( q& p#endif
! }7 W+ q$ r ` ret = platform_device_register(&da850_evm_tl_leds_device);3 K- p- U/ j7 [; K; o% f
if (ret); |6 t: d# b* d q+ [1 I0 l
pr_warning("Could not register som GPIO expander LEDS");
4 ^ _( a- i! v- t X else3 N# j& L, x. u& |2 U; v
printk(KERN_INFO "LED register sucessful!\n");
6 Y% y* c1 x/ u( A& U s
7 U+ z0 t* m6 h, a return ret;: q! l4 O- B4 w
}: g% n/ y! d0 e. W2 J3 ]
6 ?. @6 O2 Y' Y4 m6 v
static void __exit led_platform_exit(void)
) ~) ~' M$ }4 f# Z/ z3 Y{0 d4 R! s# e! k. g5 O
platform_device_unregister(&da850_evm_tl_leds_device);3 }/ q# d, D) @/ U* `3 k
" l& Y6 G# F) V, O4 x
printk(KERN_INFO "LED unregister!\n");
/ ]* `9 K. v- L0 F+ L" ~; B/ e}! [& g' J# `, h( u
- P6 ]0 n% x: t
module_init(led_platform_init);. Q4 b6 j9 a8 M. r
module_exit(led_platform_exit);$ N- ~4 Y1 s7 v$ |3 @; w0 }! T
" }2 I# O% ?% J' \. ~; eMODULE_DESCRIPTION("Led platform driver");* P" B7 U- }) _- }0 f
MODULE_AUTHOR("Tronlong");4 d& ]! I6 l0 k' @+ ?+ m$ o
MODULE_LICENSE("GPL");
4 \2 R- {- D" K4 T8 U6 h2 c2 a7 g6 X' M4 f5 T+ {# q
|
|