|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% [# y3 @4 y0 B5 b& w8 T7 l$ [8 D9 N#include <linux/init.h> D2 R5 y. Z6 H- p% y! [
#include <linux/module.h>
0 C: F3 r$ L @0 p( @. `#include <linux/kernel.h>
8 G3 S' n! @0 ?; T: J: j#include <linux/types.h>) F3 z( i" f8 T5 B
#include <linux/gpio.h>
( E u, W8 _: P* d) A#include <linux/leds.h>
Z+ ]+ i2 h ?( V) D#include <linux/platform_device.h>. N' I( G) O4 ]4 i
0 N8 |6 U' n$ V0 y5 o
#include <asm/mach-types.h>+ g4 `9 \1 |- M5 @- ~
#include <asm/mach/arch.h>& ]" _, L& q4 l4 @
#include <mach/da8xx.h>
6 E, ~4 x& H5 B% \. R) c7 }#include <mach/mux.h>! }) x% ?' i- e: j( `' c3 E8 g* w q( y
5 f8 ^" A- ~& z" ^* Q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 k3 X5 V: f, ]. D8 N#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) L) z* r z. G& B6 q. G& P+ P: y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- S5 m/ d- ~2 m#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" {! Q, x, K, T7 d& U
5 i2 U( I& W! r& _1 _7 ~0 }
/* assign the tl som board LED-GPIOs*/- ]9 l0 ^$ V* \) U* r* F& x1 v' I& O
static const short da850_evm_tl_user_led_pins[] = {
( W J* `$ u7 v& l /* These pins are definition at <mach/mux.h> file */3 s' r e% k/ T" p, X( i6 |
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' q# l) K4 V# e3 i
-1$ z6 z/ H& } D; S, Q9 g
}; o- t% [' Y5 d/ A9 D0 q
$ \, V% R/ B4 u
static struct gpio_led da850_evm_tl_leds[] = {, K5 x h9 [7 H& _4 S# X
{" v0 X1 s d/ P( F5 e4 M
.active_low = 0,
" L; {: {; f3 t! Z( |/ q$ y# a .gpio = DA850_USER_LED0,
, \3 o; w2 P" W8 j, L .name = "user_led0",
+ }# v4 d* {, [: |2 C# H .default_trigger = "default-on",
/ @3 J( g/ S& [3 L; f4 a },
B/ E! U# y; U- S6 u/ o$ Q" N. t {
9 [6 n1 w4 ]( s. h! V .active_low = 0,
' ?$ {6 D4 o% I9 ]+ i, W .gpio = DA850_USER_LED1,
3 G0 x$ z0 q7 t2 h/ n; x: w .name = "user_led1",2 `; s+ V2 v- W6 c! Z
.default_trigger = "default-on",. k- O- A2 G1 x& ?8 ~8 e; W
},
" p7 ~! l$ z8 { \/ Q {9 c* J2 d1 M0 I1 O
.active_low = 0,6 o, S4 W) w, I$ s" Q/ t8 N' s
.gpio = DA850_USER_LED2,, U4 n4 K/ s2 P: l% Q
.name = "user_led2",* t( O8 f8 F( G. |* U/ `+ F
.default_trigger = "default-on",+ ?" N. w; P6 T; S" R, m( ~: e
},+ K6 i& h; |" q! t3 W+ z% O5 n
{) l- D( \% T! U) w% A, ]% r
.active_low = 0,
1 P3 [ O- |7 |. R! [# H5 T .gpio = DA850_USER_LED3,
; A- \7 e6 i4 p T .name = "user_led3",+ A. _3 f" D, h; q% u
.default_trigger = "default-on",6 X4 D% B; |2 d7 m5 ~4 h( W; o
},8 R/ s# k9 h6 o
};
& `0 s8 \0 U L8 `8 l& t$ ^: I8 G# P4 L& D. `' k9 J; v# J
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {, k5 ]4 C& D- T; u6 k9 a
.leds = da850_evm_tl_leds,* A( E& w) w* [) E4 E( V9 _
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
1 _/ x' u" z( J- R3 S* L! y2 o, e};4 H. o2 G$ F% |
+ f7 g* F4 V7 c: z6 L. Jstatic void led_dev_release(struct device *dev)
! O( [9 i4 B" I' K7 ~) g{" G, `* h, Z( ~
};
( l0 a7 |5 U8 t+ D; ~: Y
2 e* N, c3 T2 q. S; d* I- N# _static struct platform_device da850_evm_tl_leds_device = {
4 _1 Z# `! E8 h( Y: s' S .name = "leds-gpio",4 H5 C$ X4 M( p0 A
.id = 1,
5 N8 ]* V9 Y! w9 Z- [1 c! U .dev = {& H' i, q+ ?; @5 Y; n, W8 m
.platform_data = &da850_evm_tl_leds_pdata, n/ V- z; L. a7 u+ F
.release = led_dev_release,# h5 E9 b* }: n7 k/ G
}2 l6 c5 k. g/ z" @' j( g' @, G+ u
};
6 n4 e5 P; y- e- E: }) {
t) N2 v2 g" D' hstatic int __init led_platform_init(void)
% u @ B; x) d& z8 {! m{ ^2 d& h7 H g1 ?0 a; ?% J
int ret;1 d; P! B5 U4 z A+ i+ Z
#if 0
p& M. l9 {' D. C- m5 @0 m- a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
W4 d# w! w. ]: R! e if (ret)+ P/ h- T+ X7 |! ?' P6 o
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 \9 O* s1 Q3 Y" T$ N( h5 \3 V
"%d\n", ret);
0 ^7 Q* C c' a0 `5 y7 b#endif
; |2 g+ B' s4 @; w3 t) j6 a ret = platform_device_register(&da850_evm_tl_leds_device);
0 u. ?7 l+ T! F9 q if (ret)
' [+ w' \ u( u% {! R, d7 T pr_warning("Could not register som GPIO expander LEDS");; `% S+ i5 A0 d" E# V! j
else
; a; x0 T o5 U& D$ k$ ` printk(KERN_INFO "LED register sucessful!\n");
y1 K3 m5 |2 c. J
1 h/ m# b3 k+ |+ M+ j3 H return ret;% Y8 q8 B! }7 p2 J
}
1 x. l' F, L' w1 `! _2 e1 ? J( ]4 _5 C, d* q
static void __exit led_platform_exit(void)
9 {3 S' L6 t* |5 C# j{ ]% [7 o# u% |% O
platform_device_unregister(&da850_evm_tl_leds_device);( `! g* D, e: s) ^
9 U- e' j8 u, v
printk(KERN_INFO "LED unregister!\n");: X! g( X; |' e! |% V% Y5 i% X, c
}, E! y6 t+ ]$ h V( g$ ~3 ~
/ z0 b9 t( r' n, nmodule_init(led_platform_init);
: F# E' H4 b0 R8 m2 Fmodule_exit(led_platform_exit);
4 u0 ~: B' P+ B+ G7 a2 w! k- ?4 } _" Y d
MODULE_DESCRIPTION("Led platform driver");+ O/ |, P9 b* B- z
MODULE_AUTHOR("Tronlong");
( j; y* l2 p* [+ V3 Y- J0 w1 AMODULE_LICENSE("GPL");5 c* w) y3 X- G: P1 z* o% P0 z9 c
: x9 m: h4 e& Z/ X |
|