|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ i/ U; B: M2 ?" R4 V9 r6 ^
#include <linux/init.h>, w: x9 x2 }' d- ~" ?' L
#include <linux/module.h>
% ]1 b" Z' l+ Y z& Z+ d0 X0 K#include <linux/kernel.h>/ k1 \! ?( V# C5 G2 x$ H2 U2 j; M* M
#include <linux/types.h># c( \; @- X( h3 [5 e9 B) q
#include <linux/gpio.h>
' G$ F6 _. B0 R- Q6 k$ A$ S#include <linux/leds.h>
/ m$ Y0 R) a2 C. P. P+ {#include <linux/platform_device.h> M1 n2 o# k# R8 R" [8 H
3 B7 \) z' W* z8 ]8 D! w- U
#include <asm/mach-types.h>
) T2 b1 \$ U5 l- o8 r#include <asm/mach/arch.h>+ e& g& x/ Z3 u
#include <mach/da8xx.h>' v3 f1 r7 h' C0 }3 P6 d
#include <mach/mux.h>
) Z# W5 d1 ?; g2 u7 z5 @% {: I; d9 {5 a. {7 O( Y3 j5 D: I1 t
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& H2 _% x4 `: l1 A- @) ?6 C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ s& p$ _0 {4 U& a3 q& I9 U. k#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): X: m' Z7 u+ o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); B8 o" H3 j8 s" b/ F' i
7 j! q% X5 K% Z! `$ U/ r/* assign the tl som board LED-GPIOs*/7 ^+ \6 F! p) n6 U3 H9 e
static const short da850_evm_tl_user_led_pins[] = {
& p3 n# B" f2 h) |# Y /* These pins are definition at <mach/mux.h> file */
& S2 v9 Q" y3 i DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 d8 z9 a% O+ \& _$ c0 q5 h! r -17 n# c0 ~0 y b7 s6 T% L' `
};4 {5 [" a4 a7 p) O7 h# w5 s
+ T; z( C9 G2 Y8 E3 L* K; xstatic struct gpio_led da850_evm_tl_leds[] = { ~: c- N5 f! E
{: }1 j! x- k/ t2 S* e6 h1 |3 m
.active_low = 0,% m, j4 a0 G4 c2 I6 B5 T
.gpio = DA850_USER_LED0,! l* S7 A5 |( u: k8 B, n
.name = "user_led0",+ Z9 x+ W% N- j/ v u6 ]. c
.default_trigger = "default-on",
% C+ [! {9 g# z9 F. ~ },
- ^0 U, r/ C+ Q0 V0 a* c {
$ p2 n; `% Y0 ]3 u+ h .active_low = 0,5 h/ z6 Z- F$ c
.gpio = DA850_USER_LED1,
3 u& M: v9 ^* M- g: Z- j: n0 ` .name = "user_led1",
: P9 h9 ~; s9 H0 O+ _6 R( r( q .default_trigger = "default-on",
% }5 F& C d/ T( t0 g },
7 o- I4 I; ~9 } Q: l. h {1 W$ \' q- q5 k% q' u0 h
.active_low = 0,
4 ^- g' U5 X: ~/ p8 m .gpio = DA850_USER_LED2,5 t% @9 F! ^! J; o& `) s
.name = "user_led2",
0 F: E8 r1 ~: D+ x* J5 ]" Z .default_trigger = "default-on",
& ?; T# x1 w$ L },
6 h, B/ K3 a5 x, ]7 `$ v1 a* G {
) Z) F8 E) q( a& J .active_low = 0,+ Y. ?% t0 @0 T( ? M: L: ~6 V+ _
.gpio = DA850_USER_LED3,
6 ]0 {1 b `5 b* l7 _* Y; Z .name = "user_led3",3 l6 X* V$ \, J9 u% d# g& G: E
.default_trigger = "default-on",
6 S2 S: u8 {2 D( x },. _* \( k, [$ `, F3 a6 v7 i
};
# x: t# \7 e: e& A5 z$ B+ t) C" s3 N( b' x0 y9 h, o5 f+ Y7 |
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 n7 [' N4 l! }7 @6 Q! o& ?
.leds = da850_evm_tl_leds,- J; C/ ^) V, b# F' P
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),* S p; O5 k, r
};: ~2 f8 d; E( j4 ]7 t9 o
" o# k. q' D* F& L; { Q8 V, W# qstatic void led_dev_release(struct device *dev)3 {* ]% l* D; X! m9 |. g
{
& N* S: T7 z7 R" N. l};' e5 d6 n; o: |4 k& k4 g
- p+ ~4 p( E8 f L6 s, H* `static struct platform_device da850_evm_tl_leds_device = {
# S& c# v( r( K8 _$ w .name = "leds-gpio",; q6 q: S _; w/ T- \+ C8 |9 Z9 z
.id = 1,* s$ ]0 ?4 T S9 |8 u3 l0 R* @
.dev = {
8 |3 I: W2 \+ {; ]& [2 n .platform_data = &da850_evm_tl_leds_pdata,' Q" Q" u! P- `3 r/ B F$ n
.release = led_dev_release,# |7 z9 m1 }$ f! I% B4 J2 H" [. W
}
) R# m- C/ H7 |6 T! s/ s. K% J};
( B6 A$ y1 f9 I" y7 q
' j( ?# y' R u" g+ Lstatic int __init led_platform_init(void)0 r7 g( \% ^1 o1 m) W' V
{) M/ }7 {, X+ K% G' O
int ret;
& |' s6 ~. x Q, j8 I" s9 m! u#if 0$ k3 Q" P+ t. _" ~" I9 e( K5 E
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 z- _/ X3 j" U' m% U2 _& n if (ret)0 Z/ g) ?/ [$ T t
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* }1 @2 W( I, D6 ?% W; N5 \2 O4 J
"%d\n", ret);2 c- E; `/ {9 }! E; R: E( L
#endif
3 I+ w% L1 @) |# q ret = platform_device_register(&da850_evm_tl_leds_device);
/ E& ]& ^8 @3 N4 X _( s) l8 | if (ret)
" h0 b/ B( [5 l$ ~1 B1 _; ` pr_warning("Could not register som GPIO expander LEDS");
/ R# w+ T [6 Y! e) Q+ q* U* m S else6 [6 v7 R+ i/ P4 _4 W
printk(KERN_INFO "LED register sucessful!\n");
8 \! W, @9 `* i/ s l8 [
7 ]' z$ y M( b! l2 ~1 j: v return ret;
. I7 n: V( q9 e V' M}/ \. X1 c! O y" k( N) H; O; W
/ J" p% q5 y" C" [, W' e) a9 H
static void __exit led_platform_exit(void)' i) `. h- y9 }
{3 j" h0 B3 I" A/ R& C ^
platform_device_unregister(&da850_evm_tl_leds_device);2 a# g% T/ V5 l! [! w7 ~1 j
4 v0 K0 T( `; ?0 A4 L% C# l printk(KERN_INFO "LED unregister!\n");/ u0 z+ @$ Q! X- r( c" w: C" V& F; t
}
# V8 f. G% }0 f; ]/ L
2 t- ?! }3 P1 emodule_init(led_platform_init);% @, V# X. c" _
module_exit(led_platform_exit);0 G$ T( |8 E+ o! n9 a7 d
$ e3 k6 Y6 L" Y' \9 F3 dMODULE_DESCRIPTION("Led platform driver");
9 |4 p) e* u" \+ nMODULE_AUTHOR("Tronlong"); }8 e, }7 q: [2 I
MODULE_LICENSE("GPL");
. P2 [6 a# o+ m ~$ w6 K" L; _7 }9 E3 ^; D7 a
|
|