|
|
求大神给下面的程序做注解,请稍详细些,谢谢。5 o @4 [& T r/ P# n4 O
#include <linux/init.h>
* q0 }9 g. c6 {5 W: y/ ], q#include <linux/module.h>6 M; ]& f- \7 p* K& V. N
#include <linux/kernel.h>& j3 _8 |( V& B
#include <linux/types.h>
$ P# N& r$ { N$ H4 X5 R: ?& D#include <linux/gpio.h> r/ i+ g. j& L4 ?% j
#include <linux/leds.h>* [7 M; @9 m' |- h, E, Z* }* N
#include <linux/platform_device.h>: n' D. [$ P2 }9 p7 \: ~: r
* T2 K* y6 T/ z, S6 a* G
#include <asm/mach-types.h>% s1 ?- j4 p9 H/ G% {' l8 `
#include <asm/mach/arch.h>) l& K$ ]5 \) C o' b
#include <mach/da8xx.h>' j1 Y4 u% N1 y9 p3 D+ P
#include <mach/mux.h>
* d( k1 L# e, |+ w5 t( g
' w$ r1 l$ M- i! Q3 H# m9 l#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) i$ ^/ P& N- X$ E& J! Y" A6 M#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 W) f3 F8 R7 \" u9 m) J" G
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' _8 n9 O1 A9 t/ }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# R1 N1 B Z9 H2 x: k; E0 l
* X9 A7 }4 Z) v
/* assign the tl som board LED-GPIOs*/
6 `) C/ T2 e, ?/ _% N2 Xstatic const short da850_evm_tl_user_led_pins[] = {
* ?; w: n' _' G; z% x /* These pins are definition at <mach/mux.h> file */# z7 v* q. Z7 Z3 F/ }& s! k
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( ^9 f3 R2 [: ]5 q# _) z- t, ]8 v -1. t+ D4 Y" ?! j( H* @- [
};
: ]) g. m7 s. W- u2 C
: B) _3 N; X9 M' |' G) ^" B8 S qstatic struct gpio_led da850_evm_tl_leds[] = {
. L4 w- ?+ X9 y S {4 H2 V) m8 Q/ p. s
.active_low = 0,
8 \/ ~9 C4 `6 p# n8 O3 E .gpio = DA850_USER_LED0,1 `, z' ^! z, n, v; `) n. a
.name = "user_led0",9 ?* h. M4 g$ @
.default_trigger = "default-on",
8 x6 U! a9 F1 K7 J p },) u! s9 l' b0 V# s/ P( N
{; i5 S2 z9 ~$ D
.active_low = 0,
. M! R T) B- l7 I" K .gpio = DA850_USER_LED1,; k; }& G; y, E$ h/ }) v& _
.name = "user_led1",% C+ A/ k! L" H2 C& K
.default_trigger = "default-on",* U6 j1 |6 i& o' s# X
},% d/ @8 n7 _) e9 i
{
- }; @# |2 f/ P* E1 I1 G b7 U. Z5 X .active_low = 0,/ _' C* |+ C9 y7 b: T
.gpio = DA850_USER_LED2,, ?% s `2 O0 o
.name = "user_led2", f) [) P. r1 b0 i3 ~1 V- N1 x
.default_trigger = "default-on",8 R% ^1 l, v' S* ]% l' @
},. u5 q% Q$ d) y2 l. K
{7 x: z( I: V O& W5 a: U
.active_low = 0,
4 q" `5 J5 }2 h .gpio = DA850_USER_LED3,$ w. o; {8 o a7 e) B
.name = "user_led3",
4 [. _. r' u3 @7 u5 o7 D .default_trigger = "default-on",
; c' l S" D8 }# M- u% S! g* V( w },
$ u! |5 C3 k5 T9 ^+ u* r};5 q c/ Z+ {/ n' f
$ n& B- r) Y$ s
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { Z" V+ f- w' o1 u# q2 h
.leds = da850_evm_tl_leds,
# E# U4 v" N) R .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: w5 H) [2 _0 ^' w7 E" n W
};
# {0 U0 _% o+ A# |* A' C
6 w3 C8 A. b2 Y" Y5 istatic void led_dev_release(struct device *dev), j, B7 J/ n# u. ]) m7 t( H
{& ^) A5 I) C0 A9 N& u! A
};& U* e9 B5 H F; y
: q7 A& E0 Q, _6 ^6 e/ c9 x
static struct platform_device da850_evm_tl_leds_device = {. y9 O# {( ^2 G# _1 L( [7 f
.name = "leds-gpio",
8 g- L: G! n8 a; e. S* h .id = 1,- v/ b/ ` S, N' T. [: Q, Q
.dev = {( B" c. n6 ~8 `7 K( Y% [
.platform_data = &da850_evm_tl_leds_pdata,
9 E& o8 u, r" i4 \ .release = led_dev_release,% g, k" W! Z/ _5 g4 C
}* q" Z5 {& I6 A; x
};* i2 @/ Y8 i0 c2 C# ^% D6 S( N: ~
# K" H' x2 J; |5 U
static int __init led_platform_init(void)$ i. D, r" Y, B6 i6 m% l
{
; B- d# d! P' z0 d) k/ w* T+ h int ret;8 [* q% e* B/ ~ i" O# r
#if 0
2 [" I7 J7 K5 ~. v. C ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' \" P; Z3 M* g
if (ret)
* @8 H4 d$ J; F* l5 e5 z* E pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 o3 N8 z2 m: \3 ^9 n
"%d\n", ret);
6 w6 A S0 x& y7 O#endif
# k( e( S6 U! n J ret = platform_device_register(&da850_evm_tl_leds_device);. M G: w. ~4 O1 Y l
if (ret)/ F- ~5 `6 x8 Z8 {: [% B3 n9 E
pr_warning("Could not register som GPIO expander LEDS");3 A% l n, P3 @
else6 B' D& e: {4 N5 R5 x8 K
printk(KERN_INFO "LED register sucessful!\n");4 O! m$ E# t X0 R( u% B
) w0 E5 C3 u% l: Y: B; _
return ret;) x/ f4 C2 c, p) Q
}
$ z$ l# X" [$ a
0 b- O' F& @3 _2 v; S4 ~static void __exit led_platform_exit(void)/ s! o6 f- D B% m- w: O4 Y
{; I- n2 _ _2 d. ]
platform_device_unregister(&da850_evm_tl_leds_device);7 e( W" G4 f; t$ F9 f6 U
) H7 |2 Y* h2 d- d; V* Y printk(KERN_INFO "LED unregister!\n");/ _/ i: H. ?' B6 e- `8 h! O+ u
}- T6 n$ {8 Q8 `
- @8 T4 ~# _" a& ~* Y2 dmodule_init(led_platform_init);
0 G3 r4 l' S, f6 |, h/ [) Pmodule_exit(led_platform_exit);1 g+ ~. P" }. d1 y+ H
- H; d4 n( D) J! ~: }; rMODULE_DESCRIPTION("Led platform driver");. s, Z, T7 Q" r2 ]
MODULE_AUTHOR("Tronlong");
) W( A0 Q: v) O- S) h& Q. C9 V( H' JMODULE_LICENSE("GPL");
. M' A6 {/ O3 j; x' X1 U
1 [- f% F/ {# A0 D) \, P( u3 s |
|