|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: ~0 d( T" \* z6 j; M( K
#include <linux/init.h>
5 `1 r) M) z! T4 v7 r% A#include <linux/module.h>
1 k" ]5 l0 B' r7 b#include <linux/kernel.h>
! Y2 |: C0 K% l1 B* H& [! a#include <linux/types.h>
. C; \' e' U* G# `7 i#include <linux/gpio.h>; i& T6 Z# V) i4 I, f9 i6 {
#include <linux/leds.h>
1 I* M [3 m2 }- A" G. Y# J3 u#include <linux/platform_device.h>' {! D7 \$ ?$ k! Z$ t+ \, P
1 M) F% q6 P6 Y+ P" l1 R, P$ z7 q
#include <asm/mach-types.h>4 N0 c6 ]) y) v& J: A3 @6 r4 O
#include <asm/mach/arch.h>$ W% r" E+ b6 ^1 x9 x% w9 M
#include <mach/da8xx.h>1 J) P8 W7 W- E3 ?
#include <mach/mux.h>% ~$ \1 | \9 C" h4 ?+ {4 O$ I
/ Y* z+ K0 L+ r3 b# @/ R1 s
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- V3 t& Y& h `# E; Z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ u5 N3 D& s, L U- J
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 ` L- L% @9 \ l7 v) F
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# j0 `9 q" h$ ^! {1 d- T
2 {* i! L, p" p$ w/* assign the tl som board LED-GPIOs*/9 s; {. Q) v( h2 ^' N3 f% O
static const short da850_evm_tl_user_led_pins[] = {9 S$ v8 [ j0 H# l7 a* {
/* These pins are definition at <mach/mux.h> file */$ b5 U/ [! E( p7 O# X
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: ]( r K, n# Y& X
-11 b$ H5 ^8 ^2 D. L# }
};
# y; W3 e3 `, m9 \3 ^* ~
* D: {: r! [0 n1 m' f( @static struct gpio_led da850_evm_tl_leds[] = {$ S' a/ T! f. u9 E
{9 X5 _9 ^/ j2 y [/ F& h! i. f
.active_low = 0,( Q# v5 S; o* V6 k; i: d( y2 D& S7 U' K
.gpio = DA850_USER_LED0,
: R8 f( L! C; ?$ J .name = "user_led0",
, j) Q% F0 J" P; D! U8 b .default_trigger = "default-on", K: |0 k# M4 J7 i0 Z/ m
},
. u4 F, m- ?! Q2 g8 S5 J, R$ V; n, D {
6 d0 O& C/ b3 _ .active_low = 0,% i0 w; s! z; Z
.gpio = DA850_USER_LED1,
3 H5 ?* T: P+ K .name = "user_led1",
) E. y8 x$ h# D" D .default_trigger = "default-on",) C+ U; w0 ~: e* j
},
$ i4 S, n) z& w+ B$ Y' H) ^, `2 N {! j6 e! U: I) l+ r: _& l
.active_low = 0,
, \- X; h; E8 E' W: X .gpio = DA850_USER_LED2,2 N0 I6 v2 W I$ D2 v
.name = "user_led2",
- X* w7 n) q J, P .default_trigger = "default-on",( C8 a ~% g# \9 U* n, ?# s
},; N* ?& f) I: @- r0 l+ ?& F; C9 v
{# T0 u3 J. X/ L! k
.active_low = 0,
) V: W5 ]$ c) u0 u: A1 ? .gpio = DA850_USER_LED3," }1 J" u# o/ }% } h' e1 b2 B( Y' h
.name = "user_led3",/ k- A w$ ]4 f' y
.default_trigger = "default-on",
* [ ~+ x }! m% k& l) C4 l },3 F7 b/ b+ p$ O' e' M% h; B
};
) f; M1 p: U6 h
; a5 D- P, |% ^$ p4 i5 @static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { d( I3 `( U9 @& B# T$ `3 x
.leds = da850_evm_tl_leds,8 k8 z) } G9 `# S; G5 r3 Z: z7 s
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 e5 }. z" F7 K- W};& q" B! P* q7 V0 H. H/ s; G/ B- h
5 t p% f3 x% [! t4 @2 P S4 g; Sstatic void led_dev_release(struct device *dev)
: w8 ]' M8 ~0 f; s9 f4 _* ^{% C! t. k( E; W* s; ^+ Y0 Q/ g# _( E
};0 x9 m5 j7 c, ~- C# \, X1 L
; \) z6 s" z% e! o
static struct platform_device da850_evm_tl_leds_device = {
6 q3 G; {5 e! c# j$ R3 z3 { .name = "leds-gpio",; L4 e: O6 T) I0 E, y. P; S
.id = 1,
: q7 U5 F$ R# V" |. O .dev = {. b0 V4 p( ^0 c
.platform_data = &da850_evm_tl_leds_pdata,+ B* u! F G+ H- f K$ c
.release = led_dev_release,
6 o! Z0 _7 _0 Z }
) f9 v% z2 d O1 Z6 s( f9 S};
( [, H' u; H, f7 ?) y( z! m1 j& m7 K* l
static int __init led_platform_init(void)
$ V; w* ?& s. W5 e{
" i: H0 ^; I5 H; G+ A8 F1 s int ret;6 M& U y3 X" e Y7 R
#if 0# G4 S4 [, s. ~5 @6 Y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 a$ V* @/ @7 B2 m2 q
if (ret)- P4 [# x0 c# M) p" P/ `! }( e: M, o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" r* p/ W, V+ U, g/ l; V' Y
"%d\n", ret);: a5 k2 @5 @: {: M
#endif
2 |" {1 h7 g+ Q% G$ z' L ret = platform_device_register(&da850_evm_tl_leds_device);
e. E& [+ z' ]; J5 P! {% @2 r if (ret)
! A5 _! N- g. F- ^ pr_warning("Could not register som GPIO expander LEDS");
; N) ~9 s3 C+ l) i$ j2 k else, Q# w* G- E% c
printk(KERN_INFO "LED register sucessful!\n");
) j- K K$ O! ^% U4 z) K
; H/ |) x ?: d \ return ret;
( v9 P. J6 G9 k O9 U& u}1 v! f3 F; |6 R# G
9 G4 P6 N' U4 p: w. f% O, Cstatic void __exit led_platform_exit(void)5 h' |( j. _& x5 l/ i( ^
{
: ?0 Y0 x3 M4 F! k- l platform_device_unregister(&da850_evm_tl_leds_device);7 ^5 M W f3 K. s8 K- y
. V2 Y V8 G0 W- s( E1 S# X printk(KERN_INFO "LED unregister!\n");& {. R8 s7 X2 `/ G0 U( X- I$ z1 m s
}* i: _( @4 W/ O
# k- I; t. h9 L
module_init(led_platform_init);4 f3 T5 F# d/ q3 ?. q. d
module_exit(led_platform_exit);
. a6 }8 ]* j5 e3 l2 P3 T3 _( s$ v' {3 _, _: Q
MODULE_DESCRIPTION("Led platform driver");- o9 h+ z9 s6 Q8 j% T2 k
MODULE_AUTHOR("Tronlong");
: B$ ~5 P/ t/ [' l8 x. f3 iMODULE_LICENSE("GPL");
" [" |" |& t3 x3 A, ^, P
" v: ^8 _0 v4 W |
|