|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) A5 G5 L- q1 m4 V#include <linux/init.h>
* U% l+ `5 h6 ~ }- D#include <linux/module.h>
- X+ j: q/ d0 l4 j#include <linux/kernel.h>0 `& b) F4 z, V1 y, ~- w; C1 R( u
#include <linux/types.h>" k8 R5 g" ]4 C
#include <linux/gpio.h>; K# {# S/ ?$ Y! K5 [- L r- R
#include <linux/leds.h>
4 C8 d6 Z4 Q3 O1 B3 a#include <linux/platform_device.h>
" y! R# h* ^/ g- d& `, E3 X' S; D* H* {& q3 m6 E# n& s+ p+ C
#include <asm/mach-types.h>$ h3 I# @3 @3 j ` s7 \# p1 b
#include <asm/mach/arch.h>- X" ~3 a9 o( T# i4 p
#include <mach/da8xx.h>
0 g- v; E) |6 ^: _2 {#include <mach/mux.h>
$ v4 Y/ E4 H1 R+ o' o/ r
& v5 u+ c* H3 e* ?#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ ~ k' _; d: i4 ]* C; h3 W$ B#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) T/ w }& _+ d, o) s4 Q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 d) o& h {' V8 ^; t
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
r: f8 l' `$ `+ q
7 X4 _* {1 q+ C/* assign the tl som board LED-GPIOs*/
) I2 \) u7 i5 @& d& v/ a* H1 fstatic const short da850_evm_tl_user_led_pins[] = {
( H2 N& X# {& |9 \5 O/ E8 B3 Q0 g /* These pins are definition at <mach/mux.h> file */# U: A! `3 v: M) G$ A6 k& T7 y' h9 j
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 L" s0 R9 Y& }/ ` -17 v1 e7 r, p$ m2 ~
};
2 f1 I2 ^4 [5 a
. O: t0 H' R& Astatic struct gpio_led da850_evm_tl_leds[] = { P! l% y( x: b6 j- f1 |3 v8 J! P
{
) ~: ^* T1 j8 J% U, a* r .active_low = 0," W; m- a1 x2 M4 E$ _
.gpio = DA850_USER_LED0,
" J+ B7 N& Q# j$ B# a9 ? .name = "user_led0",, T! ?5 V$ l* _2 N: b
.default_trigger = "default-on",/ v. P; x( Y% F6 M7 [8 u
},7 \' y1 [- q* U+ J: b& |
{ M9 J2 [* K6 }1 R
.active_low = 0,3 s9 M+ F1 _7 G. Y: T. A, e
.gpio = DA850_USER_LED1,
; [# ]+ x& a$ i6 W7 S% r .name = "user_led1",
$ {' Y& c5 ]( `$ T/ Q2 G .default_trigger = "default-on",
: V* V0 D: ]7 z7 B1 D9 D# U5 K5 g },2 F* q+ @/ \2 c. j+ W9 ?2 t
{' [9 _& _+ s9 H7 q: F
.active_low = 0,
6 z! e& j- B6 H1 y( P" H. A .gpio = DA850_USER_LED2,9 G9 w6 c: v) j& J& J9 d. a
.name = "user_led2",
+ W" U4 [" A3 }. C .default_trigger = "default-on"," x# L+ r- E6 q6 y
},, g! G+ q4 Q3 }
{, J- }. _- O1 s9 K5 P! Y
.active_low = 0,; {3 P) Q( L+ I7 F: c7 A
.gpio = DA850_USER_LED3,3 S6 t& r! M" ^2 t, Q
.name = "user_led3",+ ~) A" E5 i# I* W9 ?3 f# C: N% |; I
.default_trigger = "default-on",
, |9 h1 ?+ o' r/ _ },+ [: ~& h: ^( Y" M: f7 ~" k
};
( p# w0 M5 \* D0 _( \9 P% K: ?4 Z0 ^. N* D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* C: J" z2 ]( W3 J .leds = da850_evm_tl_leds,
' p- r# }& s0 E { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% d4 a' e3 A* H4 K) y' V# v
};* G% O. K7 r1 A* v/ a5 e
8 Y7 s( l! x' e0 Z* y' J4 {
static void led_dev_release(struct device *dev)
9 G4 n# U- m( G0 D4 J{) Z9 O& Q y/ x! @+ }$ \# a
};
9 E" I% x+ r/ d6 }
/ ?& [, z w' l. A9 ^static struct platform_device da850_evm_tl_leds_device = {3 U, P+ `$ H* c, T7 h
.name = "leds-gpio",5 [" E9 m, e5 j4 x9 p2 v
.id = 1,' X% e5 p$ H) n* h; p
.dev = {7 ~" e0 ]$ T6 J; }9 s
.platform_data = &da850_evm_tl_leds_pdata,6 x+ T E! a1 r9 l' c+ d* r# x9 t
.release = led_dev_release,$ m4 S9 Z h9 z; _9 l
}
, @8 s, x: O0 y6 V+ I& f X6 A};
# ~: l+ [0 i; j z
, r0 q( f- E4 Q8 Xstatic int __init led_platform_init(void)
5 z5 u4 _: m9 J0 K{& n# G2 x( S {' `# U# r
int ret;5 Q' f6 }! \2 ~+ t+ w! ?9 R; V
#if 0
# n% u5 M7 @& `7 v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! q, ^ P) f+ o0 D$ H
if (ret)! D& Y3 f7 i a5 D
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' V- u# E, @! h7 a "%d\n", ret);
4 Y* @2 r: }7 ]#endif
# ]5 i8 X2 \8 g3 G% X* D% [2 i* B9 [ ret = platform_device_register(&da850_evm_tl_leds_device);
1 y; o& Y L" V V if (ret)- f( K! i0 g0 Y: m, |& d
pr_warning("Could not register som GPIO expander LEDS");
' A1 t) S, @- T: u `7 C else4 H! H- I3 c8 z5 E
printk(KERN_INFO "LED register sucessful!\n");
. ~. \; |7 U2 I, p' D6 _/ S, N2 x$ [9 `$ _
return ret;
4 p% m- M% o$ ?}
* q; R( C9 M' M6 r' L% P. h
5 @2 P* X( v/ W7 nstatic void __exit led_platform_exit(void)
, R" g$ x) J" h$ Z5 G2 K3 l{8 \" w. I6 n9 l8 W3 P
platform_device_unregister(&da850_evm_tl_leds_device);
" w' p: `4 \ g9 S
' ?/ O; K! }0 d9 l$ \& L printk(KERN_INFO "LED unregister!\n");
+ g* d( ?, ]0 m' ]" `}" u, Y @& d J5 i* P4 l
. m3 J6 Y- `. S& y; O
module_init(led_platform_init);# P, H- j8 i1 N4 k5 s
module_exit(led_platform_exit);/ N9 N1 D2 Q" o
. {2 ~5 H1 ?: Z+ E- A
MODULE_DESCRIPTION("Led platform driver");
* k: f5 ? Q% Q% G: J0 ^3 _MODULE_AUTHOR("Tronlong");
4 M; `8 w1 _8 ?2 i9 j- c4 X1 sMODULE_LICENSE("GPL");
; F$ o7 L, b" {' X3 w
& {. N& H, v; m- j2 T* ] |
|