|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 s' O0 N* }0 L6 I! E3 n#include <linux/init.h>
- e2 t( k8 v% I @, y) h% o2 J#include <linux/module.h>
- s* W& h& X/ U5 l$ x" Q; [* z#include <linux/kernel.h>2 P4 K k4 F3 v1 |6 {
#include <linux/types.h>7 k1 H. u( j- C# R
#include <linux/gpio.h>7 R. L# B7 m, C' {6 I. [0 d: H
#include <linux/leds.h>3 W0 E& N) Z5 {4 z: l7 R
#include <linux/platform_device.h> C6 B7 X8 O& Y) C
/ w* U6 p0 N# ?1 k, f#include <asm/mach-types.h>
) ^% ?3 V* s& ^4 x# ?- F% P#include <asm/mach/arch.h>
1 H8 \5 L A$ z' `; E$ ?& ~$ Y#include <mach/da8xx.h>
$ }+ M5 X; w! y#include <mach/mux.h>) Z( J: s5 i5 [. N6 d5 w
# r" I) b9 J2 |3 h) V( }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; ^' R- g! B3 j9 R0 j8 i, @#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% S% Q& E" w K, Q8 w* i#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
e- Y! k3 g: p* X* d#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 W R2 u7 C/ r. l. {
6 ~$ Q* R4 `5 P1 g
/* assign the tl som board LED-GPIOs*/; r& M. p1 y3 h+ Y+ s
static const short da850_evm_tl_user_led_pins[] = {
* m) I; K( b9 I8 F /* These pins are definition at <mach/mux.h> file */$ h7 p& p7 ] k0 G' x2 [8 F- @. y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. M4 H+ @$ e" d( m9 c7 ^ -1
/ ]% c7 `5 N4 ^; R) y5 c; B};, i# c1 v3 j0 `3 Z
4 ]/ Y7 L: b/ l5 M6 z5 V. D! L
static struct gpio_led da850_evm_tl_leds[] = {1 w' G% h6 U s' e" H5 w! ~% z
{% m, M. b' h, L1 s: M( j9 W- [
.active_low = 0,
6 Z: w X) E, S/ D( F/ p .gpio = DA850_USER_LED0,
8 m* N+ K2 p/ i2 o+ o) \$ K .name = "user_led0",- c; N" d9 U& J# D$ w" g! n
.default_trigger = "default-on",
8 ]9 ]. E8 u( x! @4 t' ^ },$ ^/ P* \0 J# Q& \& ~/ @1 e8 C' V
{
; n+ E( F( ^8 f0 o1 l .active_low = 0,2 _: v) j$ _. {# w+ K
.gpio = DA850_USER_LED1,: R a% K4 _2 J' d# ?9 x' z
.name = "user_led1",7 S) ^* K+ S- X! T% T1 }! \
.default_trigger = "default-on",
9 p) m% u* H$ P6 K3 m },
+ D4 |" J; S( u9 ^% I8 _- h {9 t0 N$ H1 m; S& x6 [! Z! T" ~! t
.active_low = 0,
- Z& M; w. S* f, s$ g .gpio = DA850_USER_LED2,
; P2 |2 n& x3 m5 J2 r0 z .name = "user_led2",
5 _! r) Y8 y) o3 Z' d .default_trigger = "default-on",+ f+ o% h+ p3 z5 a3 D' N
},
/ S* U1 y. O+ J% X7 z) [ {" k& l- f4 f8 k
.active_low = 0,
: Y$ F" O% ^( [, f. B6 H) ~ .gpio = DA850_USER_LED3,
4 }7 n& I# R0 D! @# j/ O .name = "user_led3",* p' a2 h" |; d5 h* i$ J" Z
.default_trigger = "default-on",
2 D9 o7 Y% L7 N% ~( I8 z },
# D: B# B! F8 d5 F/ C};
P9 {$ i; D% U" B4 g
1 n, w$ H2 k% S( v# Lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* q8 ]& U5 I9 e$ t# e
.leds = da850_evm_tl_leds,) T% `$ Y# H r1 i
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' U! m1 ^$ l# P: z& a8 j
};
) S% Y. _: [& G3 o" w$ e' u" _# X; `0 N$ r- r0 c6 Q
static void led_dev_release(struct device *dev)
" R% w# o0 @1 d6 Y( h, e{
: G6 a, ]! O/ v/ _};+ v; W" B. T# Q0 d& f$ x8 s0 g
$ X- B3 u! _5 ]static struct platform_device da850_evm_tl_leds_device = {% e) X& o! {# P2 J* _0 @
.name = "leds-gpio",
9 k5 d4 A2 y) I. n+ ? .id = 1,
3 Q0 v7 g4 k& [) } ]! y0 R .dev = {& V+ i% B/ |! w R6 H6 b" ^
.platform_data = &da850_evm_tl_leds_pdata,5 d1 U# r2 y& ^# |
.release = led_dev_release, }8 u( ~# g- M1 j6 V0 d
}
- B+ g ?0 h9 u) k( d# W};
2 ]% G2 n( \6 ? c" U. y7 J+ F# Z5 X7 X; R% z1 [
static int __init led_platform_init(void)
% z: c0 s8 ^; L{
) ^6 L) f" B3 A& }! ` int ret;3 S. ~4 V/ b; [
#if 04 P' g9 y( I$ @6 C7 ~# B- v, }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* B% `6 Q' K2 a9 f% O7 ]! { if (ret)
* i% T! } c) G0 Y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 ?( H C: S/ t8 O2 Q1 l2 t "%d\n", ret);
3 _0 K/ j/ r; x+ D2 F7 G( i5 |#endif4 p a- B9 _3 ~ i* D5 \
ret = platform_device_register(&da850_evm_tl_leds_device);
9 ~) E: ]( e( ?' g; { if (ret)8 i O9 b' @6 \1 N( _4 L" _
pr_warning("Could not register som GPIO expander LEDS");
$ z! M( m2 o( k1 R4 {9 N9 C) M else" _7 R& {2 X0 t( y
printk(KERN_INFO "LED register sucessful!\n");
# c& `/ J+ x! M7 M7 w1 H
+ M( d+ J4 B) |, _, n4 g8 n return ret;( G" \6 J2 y- ]
}! {' @: l) p d
" {) @ K/ a/ m1 hstatic void __exit led_platform_exit(void)* W+ K5 J8 n# ^9 M
{4 k3 H6 H* ] Z
platform_device_unregister(&da850_evm_tl_leds_device);9 M# T% |; t" e# k* N: T# E; _
, Q: f# p C& z; Z
printk(KERN_INFO "LED unregister!\n");. q3 j. _( ^& [4 `; R" s4 |4 k
}1 f0 B$ C$ s+ S
$ ]4 P, e6 |- @7 `% jmodule_init(led_platform_init);
2 P2 ]; B& l$ tmodule_exit(led_platform_exit);
, A' w) U4 B/ e( d. m
& [, E0 w6 T" Y( j6 n6 RMODULE_DESCRIPTION("Led platform driver");: g/ \& r% p0 |& [
MODULE_AUTHOR("Tronlong");/ g* t0 M' P& d. A/ d
MODULE_LICENSE("GPL");
6 T, S8 j2 \: E/ A8 D4 D) H8 @% x0 d
|
|