|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- k" G) h r1 T! y1 ]& x4 _#include <linux/init.h>/ n* A: h0 p- Q. C8 N# z
#include <linux/module.h>
7 ~7 a2 Z' Q, |& B2 ?. x+ L#include <linux/kernel.h>
3 t1 K+ L$ |; x. a#include <linux/types.h>: S+ Q5 B: L* V/ }9 s
#include <linux/gpio.h>/ `# s8 P$ h4 n' T# s
#include <linux/leds.h>9 c$ b2 Z( E' Z; I2 L! L
#include <linux/platform_device.h>" I# u. _ ^% F) G9 |
6 n6 f; {7 P) `6 @" v9 h b#include <asm/mach-types.h>
) Z3 w" v* e' E t5 ^- o' ~#include <asm/mach/arch.h>
9 d, ^, Z8 {/ y4 h) R) O#include <mach/da8xx.h>
2 r1 I) W& T( X1 I, v1 D7 n9 v#include <mach/mux.h>
1 h( p+ D& L& O3 K1 x# H) `( B3 V
7 Q6 L# t; a7 c6 h0 O5 z, f: a0 v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* U, {1 N. H H) a1 B# Q6 J#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( Y( e3 r: L$ |% b+ V4 i
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) X9 y& w7 X D& v2 g! R& n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ T0 V3 S1 D' h3 A6 d5 q7 {7 o( u
/* assign the tl som board LED-GPIOs*/
: B, S7 A; w6 ] {9 A% `static const short da850_evm_tl_user_led_pins[] = {
( M; D5 t+ f, ]/ O /* These pins are definition at <mach/mux.h> file */# S+ l" e- X& y5 [
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 l; L" j$ B2 X -19 i& B% T" ~7 r4 u3 ]
};9 E3 N+ ?/ Q9 @9 `$ s
5 p5 p- \) d F; k V. ^
static struct gpio_led da850_evm_tl_leds[] = {( a) u3 E4 Q9 i7 b! x+ ]! [2 h/ P
{, o5 q4 S4 v& I t
.active_low = 0,1 F$ P+ l* p2 y* U, G* y
.gpio = DA850_USER_LED0,
& L4 V+ x5 o, U .name = "user_led0",
% g" E7 h! g' Q# u% Z .default_trigger = "default-on",. o4 `; B: x* J" N' r0 k* ~
},
3 ~/ j( X6 k6 W {' Z9 Y. a) D2 p5 j9 r
.active_low = 0,
, J; s& {8 l) X0 O+ Z0 c3 p .gpio = DA850_USER_LED1,2 `$ b. k' i# E5 a: N% C! |
.name = "user_led1", K0 a/ t# y" [. i' C
.default_trigger = "default-on",& g; j; Y* Q9 Y: F, V# [) u
},
* q, s/ e( x- p7 M9 @' W$ n. H {
% T" ~) h" e1 ]& Q, ?/ X; S .active_low = 0,* L( q# w2 v9 t2 O
.gpio = DA850_USER_LED2,
7 P/ g" t1 C7 M' K6 D .name = "user_led2",8 \4 G+ e, Z. z" b, s5 I- e
.default_trigger = "default-on",$ E6 J+ r& D- X( t/ }/ u
},6 C: l. ]$ a' b* S+ d1 {$ f
{" D( c5 \# q! a6 S
.active_low = 0,
) g+ B0 c/ j' B. M" c8 l .gpio = DA850_USER_LED3,
) L2 g0 A3 ~( Y .name = "user_led3",
, m4 ?7 \/ s* Z4 r0 A+ Z5 k .default_trigger = "default-on",
, `3 b; A# L7 f0 C. V },1 [$ v$ R, Q6 d% g7 Q0 n9 }$ i. }$ O
};: p) b/ U& E4 y$ v0 B& a
! N1 L- K+ M/ n, P4 E7 m- i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* k* w: Z, o1 [6 P% ~ .leds = da850_evm_tl_leds,1 n9 R4 C* ]: s7 l
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),) h5 |1 o1 h# Z3 y: s
};
/ g' _6 Q0 w( }- N4 }. c+ c/ Z
- q' Z1 N" _( s# M4 D, K& Z8 ?* |static void led_dev_release(struct device *dev)/ {% m3 K) o# |6 h
{
: |. t7 S" l; d2 V( [};
+ I/ F: A& v/ ]8 V$ n$ I b4 }
# H y! }) d) Z* Hstatic struct platform_device da850_evm_tl_leds_device = {
/ Z% k, N; Y9 x+ I6 s$ o .name = "leds-gpio",
8 \7 p9 t* D( F7 r( ] Y C .id = 1,7 b# B/ i% c/ z) U
.dev = {- d Q4 h7 ^# b! |. o$ z9 W
.platform_data = &da850_evm_tl_leds_pdata,
F2 N5 N% S( S( C7 w8 ~" Z .release = led_dev_release,
! @* r, G( Z, _0 C; ~1 m }
g. D. P: u$ J; r; U3 m5 y};
. C- W* p6 n5 ^, z; O% }0 z) M# m, d1 h2 P% i0 I
static int __init led_platform_init(void)
$ j( ^/ P' M' N; ]- @9 `{
3 Z5 Y4 X6 a8 K+ i9 x int ret;
! l F( k) R# X: P0 ]/ m6 v#if 0
7 v3 X# r% {; P- ?2 z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& b! x4 q; {, ]$ _ if (ret)
6 I8 c" ^7 v1 ~! K6 x. Z- ~% ? pr_warning("da850_evm_tl_leds_init : User LED mux failed :" }, R- K6 J+ n2 b: p& D
"%d\n", ret);
8 \9 R9 t6 C4 ~#endif2 D# v3 o8 A9 e1 e$ L# P x J
ret = platform_device_register(&da850_evm_tl_leds_device);& ]! R0 T, d* C% G& ~4 _2 r! v" j
if (ret)
0 q1 D( V" \2 n7 w( B- f) m pr_warning("Could not register som GPIO expander LEDS");; {* \% s2 a! {4 f- }
else- L" @+ `+ a& z: Q' X" m
printk(KERN_INFO "LED register sucessful!\n");& v* N* ~, c( e/ ]8 m
/ t/ \& O1 u+ b
return ret;5 l* S) c$ W; l- |
}6 D4 z0 e3 o) C7 ?$ Q2 P% \
$ F9 e/ u X; O0 ~" ~static void __exit led_platform_exit(void)# [7 N. ]. N) y. U
{
, X5 K, v- Q1 f, D7 b! Q platform_device_unregister(&da850_evm_tl_leds_device);
( Q7 h: D7 ^. E, Q( P
( m" L& y m' p& w) w printk(KERN_INFO "LED unregister!\n");; V; y# w9 }' J+ L' O
}
8 ?8 m8 b1 B& p$ l
3 z' {7 V4 j0 O% j; l3 [module_init(led_platform_init);
+ {6 z l9 w# L* rmodule_exit(led_platform_exit);
9 |' B! m9 L& D C" X3 U; I5 A
# }- B" j3 b5 h7 R& u' j0 f9 mMODULE_DESCRIPTION("Led platform driver");; ^0 I5 p, B9 ^5 [) c$ n7 Y, ?
MODULE_AUTHOR("Tronlong");
) t( G8 d, J, c/ y# b! W2 o- GMODULE_LICENSE("GPL");% b: ` v# c% }' d# b4 T
- x2 |( ~/ s% z+ Z+ C% u |
|