|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* q4 E: K( C: U9 `# ~5 j#include <linux/init.h>
7 }+ i, n @8 S9 m. B#include <linux/module.h>
6 C Q& ]5 f9 b( ~: u& |+ M#include <linux/kernel.h>* [7 b: r4 T$ E+ `
#include <linux/types.h>
' }: r$ D) j1 w( F#include <linux/gpio.h>
: O, t* Z2 J& w8 k0 |#include <linux/leds.h>" D I$ H" W4 {7 U7 _
#include <linux/platform_device.h>
% V# _7 `; G" u) G9 G, `5 m2 q$ R8 l: \% V+ T3 m+ J2 L J
#include <asm/mach-types.h>7 H f3 c% }0 v- h) M, I: T
#include <asm/mach/arch.h>
! o* H" F: H1 g6 m0 n( m6 E) |#include <mach/da8xx.h>
, ^0 e) O" ~) k9 v; V#include <mach/mux.h>
4 d0 z" _4 i, [1 y$ l P2 }6 s
4 T" D' [" M' X; _1 F3 e! A#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). e/ {3 X6 i+ ?2 {! h! M
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' [; z9 o" [& g#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) S' L/ u! X' d
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, Q1 M' A* v( b5 |$ C7 O' X
) m- H. {0 O0 s! P: ?8 p/* assign the tl som board LED-GPIOs*/
5 z. t* n0 h" T& t5 l! `$ o2 u( l* g+ zstatic const short da850_evm_tl_user_led_pins[] = {4 S. V) Z) h; S1 O+ _# X B% T7 A8 }
/* These pins are definition at <mach/mux.h> file */3 V- L% d6 r+ t9 q! W* _- O! @
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 d( f* J! X8 Y% ~' d
-1
: h% f* M4 }7 a};" j1 ~- g: K( {) ]5 m! s# r
0 D5 d" l7 k. V* p+ U: J1 O
static struct gpio_led da850_evm_tl_leds[] = {
- W% A, c0 e5 X7 D( S) _, A {
$ _! D5 j/ G0 p .active_low = 0,
# I$ ~. E( Y: v0 ]2 }8 d .gpio = DA850_USER_LED0,
& W( Z( |7 l/ P# H .name = "user_led0",) }3 z" G, o5 T* S4 C: |
.default_trigger = "default-on",3 H- F! ]: \6 m0 V
},
1 y2 G0 R7 v3 K& j A; n& q. B {. p" i$ K4 b d1 e' [0 B2 q
.active_low = 0,; y y* `2 _ r7 ]$ G
.gpio = DA850_USER_LED1,
3 `6 z4 _" c1 }/ E/ k& K' w .name = "user_led1",% e# N5 ^6 s1 K" f' A5 v
.default_trigger = "default-on",3 c ~( k3 D+ @7 \
},
# [" F/ g/ C$ q& \/ K, c {. f$ G0 s) X6 f# E" z' m
.active_low = 0,
$ Z/ ]$ I% [% t# I .gpio = DA850_USER_LED2,: h/ M+ @) {6 s8 K2 B r8 I: w
.name = "user_led2",
" c3 [! T; E( e5 R .default_trigger = "default-on",0 s1 }( o3 M, Z3 M2 V
},, H' F3 e1 g& J8 P$ V6 }) s' g2 ^
{4 v6 f4 d9 U; ?$ w L
.active_low = 0,
5 h% H( G5 ^: Z1 a. l .gpio = DA850_USER_LED3,
- }* _8 c! D8 S' ]$ [' z$ A .name = "user_led3",
- n9 f! ]# T* d0 Q8 v: @, o# F .default_trigger = "default-on",; @. t) K" r. |0 z4 N3 t3 o
},
7 V5 w) N6 U) q# Z};7 a8 e9 K5 b; J+ Q
' k- ~: \8 J" tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, Y( y: a" a1 e3 r: p, |+ I( ~
.leds = da850_evm_tl_leds,
, ^7 V% M# b9 K( H% _/ u3 Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 V' {+ J/ S' X3 F$ K; n
};7 l h$ W1 W- s
$ |8 @/ D& i& V8 K1 {
static void led_dev_release(struct device *dev)
0 m& j" J. [; e" [! G/ d{; }* m6 _7 t O& a5 y4 x$ D
};
2 M1 E0 s m4 Y I4 f$ H* N) J
1 r- \8 M7 t- n; jstatic struct platform_device da850_evm_tl_leds_device = {2 s2 H. F; T. v( H2 s. h% {
.name = "leds-gpio",5 }. ?0 q4 A" E( V7 {
.id = 1,
0 o0 K. F n0 ] .dev = {
, N# k4 ~! [% |7 C4 J7 v# ~ .platform_data = &da850_evm_tl_leds_pdata,
3 P- @* ~$ P8 f7 l! ] .release = led_dev_release,' Q- u- ] m, k' t0 u* c# h" k
}5 g6 |( d% c' R4 w, G: g
};
* C1 t* W4 g* I8 e2 _$ o: H4 y/ Q, o# q
static int __init led_platform_init(void)
) Z; j/ c' a* J) V3 j# ~{
" U3 f! E- q5 O: c# u) o int ret;/ t' K1 d; [/ N. Z4 E& ^
#if 0% p& \ P0 x! S
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; c9 K! ?4 V- ^" P* s+ v
if (ret)
% q# L3 k" j. w N& f: s, S, i; O pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ P6 M, H0 e3 M) V3 Z* y
"%d\n", ret);; ~. ?5 D3 f% A: ?' U5 M
#endif) ` a1 m, l* L$ Y
ret = platform_device_register(&da850_evm_tl_leds_device);
6 m4 ]+ ^, }5 T# ^ if (ret)
/ n3 f8 d& G( A# s" Y pr_warning("Could not register som GPIO expander LEDS");
9 e6 T8 i# n" I: W" z; @( r @ else2 |6 q" t$ |1 o- ]5 ]
printk(KERN_INFO "LED register sucessful!\n");
" h6 u K, Q" i0 I* S- Q; i5 V" Y/ ?& J3 I _
return ret;' I$ b$ u$ ~& L; d0 G5 Z! c/ ~! ?
}
% @8 [7 L1 d1 ?, o% h0 L. A+ q9 G/ _; E
static void __exit led_platform_exit(void)& \3 Y- w" G8 T
{5 e! t4 T1 A, W+ O1 [8 T
platform_device_unregister(&da850_evm_tl_leds_device);! C& x5 Z, t2 O' I
6 ^, ?% M3 ^) o: M printk(KERN_INFO "LED unregister!\n");
0 T2 c1 h/ y+ ]! U: \}" w" c5 V8 B$ z) V
- {! ^( r* w% L# ^9 P# v! U% R! [module_init(led_platform_init);
2 S9 M2 s- O0 z. M! umodule_exit(led_platform_exit);
2 n2 E0 j5 Y3 I x6 \" G+ J' @4 U6 s A4 W4 r! C+ i
MODULE_DESCRIPTION("Led platform driver");# E5 |8 v0 J6 x, ~) Y( m3 F- m" F- n
MODULE_AUTHOR("Tronlong");
. `' S7 k1 J8 {MODULE_LICENSE("GPL");/ i2 W+ C3 c8 E
; g9 \/ R' e. a6 j O
|
|