|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" d7 h+ c7 B9 Z& s! {' Z+ k
#include <linux/init.h>
; ^; @. X, Q- r#include <linux/module.h>+ {4 U( g. z) d
#include <linux/kernel.h>
J$ h( |6 Y# D$ z4 C#include <linux/types.h>+ m* [. {5 O# z: `1 T/ c! f
#include <linux/gpio.h>
9 R' E0 i, {. h1 Q% }: f. C#include <linux/leds.h>! Q7 U9 n. h' j( }1 R0 g
#include <linux/platform_device.h>
) N3 \; b0 `1 A7 A# l
) M1 i+ o; t) s: F8 F#include <asm/mach-types.h>' F" R+ C, {* O! o3 i
#include <asm/mach/arch.h>9 g! T% A# D! m, c
#include <mach/da8xx.h>
0 G, V) `& j5 t2 p U#include <mach/mux.h>
- j, ^$ K. t+ r' m% G4 I# T
, n9 m6 _7 ?) |0 e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ @3 A1 k8 i y, X, `5 V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 y, `; K4 E9 _- S& p( \0 F#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! Y# h6 W/ M1 _' q2 \1 B5 w
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), G, x f a& {' c, v% j
$ n6 J* @7 n6 w( d0 [) T
/* assign the tl som board LED-GPIOs*/
0 d4 _; h+ t$ ~4 ]static const short da850_evm_tl_user_led_pins[] = {
# l) i# g7 C6 u /* These pins are definition at <mach/mux.h> file *// Q+ y/ C& r2 M/ ^: ^
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ j) y$ s+ h# s8 D; t -1
; B8 x# {6 M3 q8 M6 Y% H. d) n; ?};
! y% U2 b" y1 O0 L' f$ ~
. O. Q* s) o$ S! \0 T, A% w$ U* ystatic struct gpio_led da850_evm_tl_leds[] = {
8 l7 x1 G; f/ o1 Y [! F {! U* b M" x/ s/ |7 }
.active_low = 0,
2 B6 ^: H7 p) d+ O .gpio = DA850_USER_LED0,/ x6 }" C( Q9 m3 Z* W
.name = "user_led0", s* ^1 _" T/ U: Z& Y
.default_trigger = "default-on",
0 Q( P- c, A" ]; e# s( C, x },
) }0 K: T) v3 D# b: H. M {
7 R! s3 e% Z/ Z' U& O2 Q$ J" l: t .active_low = 0,# y& J% z- k- U" I1 B" |3 p
.gpio = DA850_USER_LED1,
0 T m0 T% W! T( r8 n9 g .name = "user_led1",
! }9 n5 l4 N1 n, b" n .default_trigger = "default-on",7 O5 e! J \( l3 ~
},
9 H! t# L/ b! u: o {% k( u+ Q" c1 b8 Z! J0 q
.active_low = 0,' k. T F: `9 ^+ A5 w
.gpio = DA850_USER_LED2,, S% N0 V l c- d# @
.name = "user_led2",
1 m2 I1 J; M \( O9 X .default_trigger = "default-on", R: v2 P6 h" q& p3 s/ r9 N. h
},
7 j4 f5 c) L6 W* @. @3 {5 S8 _ {2 _, o: A [% `) @- O7 ^
.active_low = 0,
" Y# [; m# E; l .gpio = DA850_USER_LED3,) H3 \; s' r0 a5 y
.name = "user_led3",
. D/ z4 ~& l$ v. _ .default_trigger = "default-on",, Q8 y$ C1 b. J( i6 A6 \: Q2 g r
},- |1 x% C' a- K1 V T# X* _
};
; A" x- N& r/ f4 @% x1 i. f9 r' t- n
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 }7 H, S0 m z$ T( Y, N
.leds = da850_evm_tl_leds,5 `4 O7 [9 e$ `+ s: V/ c
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# f& o' x: B" S7 d" Y# x};/ f; t5 J4 e9 x' i; A
( i& O, V/ z4 f4 F1 O6 d) F$ L$ \
static void led_dev_release(struct device *dev)6 A+ }5 j1 T2 X) i; A
{
9 i1 t3 ?6 s0 Q( D7 P};) a1 v4 u0 C9 b
- K) f3 I9 b5 e
static struct platform_device da850_evm_tl_leds_device = {" ~: O; U! M" d
.name = "leds-gpio",
8 b$ _3 y3 y6 U0 } .id = 1,
2 |- n7 |+ |: ?& U/ _' B' X .dev = {
2 } @6 o, w7 e6 Y" q+ x .platform_data = &da850_evm_tl_leds_pdata,% A( X1 ?9 b* r, O+ K
.release = led_dev_release," v1 s, Q! i8 J- q2 D% e
}
7 g; J" Z/ \) n, K};. f8 f r6 d* n! m% Y4 ]
! n/ \3 k" O/ ^: Y* \/ Xstatic int __init led_platform_init(void)
7 ~- O8 x0 I2 |{+ s9 X& s8 t) }$ F; |
int ret;
9 J+ T4 w: y5 q+ @2 o: s+ K+ U#if 0
" S: A$ J# K. g3 U ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
g5 z Y( X( {1 U if (ret)
) s! j# a9 l% {4 w7 J! ^+ } pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 P2 l% d- Q. W0 s6 V+ W; e "%d\n", ret);
8 P. w* ]0 G' n+ o8 _" {. W#endif% S( w' ^6 B' I/ S
ret = platform_device_register(&da850_evm_tl_leds_device);
9 n% ?1 A5 I3 c9 V l* x* y& A* W if (ret)
8 T, {% |/ d( j q3 k; y; j! U pr_warning("Could not register som GPIO expander LEDS");7 z; B5 A: g5 e& V
else
" \6 o* }8 Z) E' W" g2 `) R+ h printk(KERN_INFO "LED register sucessful!\n");0 a* }- A# _/ |1 M
9 k9 R A$ ^) |! Z return ret;
7 y1 q5 H- M: h( M: f- m1 G/ U}
/ `+ c5 N9 A1 N8 \- w4 @8 v7 y
% J4 o9 j# h0 t3 a/ M- Nstatic void __exit led_platform_exit(void)% k; w) h% T/ [) f. I/ h' u9 d
{* @+ Z+ f' I; C5 A$ a/ |# S8 a3 i
platform_device_unregister(&da850_evm_tl_leds_device);
6 U7 w c, f2 |1 O7 ^, S3 U' k5 S5 v$ c! j5 D9 b
printk(KERN_INFO "LED unregister!\n");7 [; I2 M. ~' G
}$ h* m+ J- S6 [. l7 V
. Z" P f' t |0 S" c, o3 W7 Emodule_init(led_platform_init);
+ j* ]* l' s% F2 R$ `module_exit(led_platform_exit);
( p4 j' s0 G# g" b! ~5 s
, U% [2 A( Z `( ~0 V, Y M# a$ D# e YMODULE_DESCRIPTION("Led platform driver");
0 q: ?! [ V4 `MODULE_AUTHOR("Tronlong");9 J4 J; H( U' ?1 a# F* z/ {
MODULE_LICENSE("GPL");
/ Y/ {: X% ?) U% y# e- I. r$ c E7 ^( B0 p. V" T
|
|