|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& O& R* W* |1 v+ P& { g# G; t#include <linux/init.h>
( A. X5 [8 J9 W, g4 Y#include <linux/module.h>/ i! T8 c9 o% n0 K* y
#include <linux/kernel.h>
0 r( i; r l* E$ q#include <linux/types.h>
7 b6 H; J1 F; Y. K; o+ ~5 j#include <linux/gpio.h>
5 o+ s' V; M* E#include <linux/leds.h>" b; I1 A! ^$ x+ \# C
#include <linux/platform_device.h>$ h- b5 q8 A) l- d) s: S7 Q" i
' q, R. U& }6 [" {/ o
#include <asm/mach-types.h>
; _) z( s$ }" k9 w- b#include <asm/mach/arch.h>
) [* U8 x& w/ `7 y#include <mach/da8xx.h>
/ m1 G+ @% U+ p) f/ I6 e#include <mach/mux.h>$ A; [2 V- |( a# W% r
! d( d ^, W- `" d ]: ]/ {#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( A$ ~3 S5 K' X7 m# R, L: o Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# Q I6 c( L8 V6 }. ~( l! t0 w& n! {
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' P/ p/ I) f# b5 W( ^: i# Q7 m
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( G! C$ c- [8 f. M, k6 W6 s0 g4 |0 l9 \# m; `
/* assign the tl som board LED-GPIOs*// w! `0 a7 c" o# w
static const short da850_evm_tl_user_led_pins[] = {. M3 b* Q( X1 ~, O1 V" I
/* These pins are definition at <mach/mux.h> file */
4 B' I* W* U P" D. ~+ t2 g DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," B, i8 b1 ~# O/ r
-15 H: N% f- K8 [ T. D9 a
};( |& ~7 q9 Q) ]2 x" v8 P
7 d" B. D& t. \2 Z K# P* C7 C1 \ l* E
static struct gpio_led da850_evm_tl_leds[] = {0 s! @" v1 P" I4 z$ D) m i
{ V7 `/ w& y L; T: [" F
.active_low = 0,# @- V1 |1 c% s, c: N, d
.gpio = DA850_USER_LED0,
2 T9 o5 l1 h- u+ v, Y .name = "user_led0",( N2 U6 V+ a2 ^
.default_trigger = "default-on",
8 q, n$ G+ [* J6 ]/ Y1 X* C },
/ ]6 n: J5 z* x |8 R% U {, r9 k0 G$ m+ Z
.active_low = 0,9 ^4 [% A6 ^) _4 l) p+ |- B
.gpio = DA850_USER_LED1,) ?+ V; y. J+ p, J
.name = "user_led1",
$ M/ O9 z9 K7 ` j7 P .default_trigger = "default-on",1 ]. R& W0 m, a* z& L$ U ]: y
},, u* W' @1 M6 \" P% s& ?
{' {: V; O& {) p) F; t, e) s0 ?
.active_low = 0,
- g4 q/ @) n' p1 Q) r( s/ O .gpio = DA850_USER_LED2,
. \5 p1 J% m2 r+ j# x, q: E .name = "user_led2",
- `( k- t& r% q( A9 B* m2 O/ b .default_trigger = "default-on",: U0 L* [. H R0 b. D% ]
},
7 d( ?/ a+ A1 s$ q# p" s {0 n) S( u0 U. y/ U1 V" V
.active_low = 0,
d+ L% b" a( }' x" y6 u .gpio = DA850_USER_LED3,2 a3 i8 F+ N1 y1 j
.name = "user_led3",
( a1 A. E5 X- a5 Z .default_trigger = "default-on",
0 H" }/ H2 _, O( ^* Q },! o, P2 e! J/ p& t2 t4 K* ], e% a
};
# U, U3 [& @" h, r/ k& E( Q. d9 u/ r5 ?" @. o+ m4 x; X7 f ^
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ |; k' C3 q/ i9 _7 \; l
.leds = da850_evm_tl_leds,
: _, w8 P: g# C8 w .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; |$ A( i- F0 w0 K. ?9 W0 q};
1 ^. w( I) V& o* M" M+ e6 L
* i; U! y8 E& V( Z% H4 estatic void led_dev_release(struct device *dev)& U. ~* g8 Z$ {% y
{* t$ g6 {5 |8 Z: D- o" u! M4 f; b
};
* x6 j% a2 v* ~5 L7 _- B
! d1 u1 L; m' B" n- J6 g5 {$ p& estatic struct platform_device da850_evm_tl_leds_device = {
# B) `+ J' b7 e$ j .name = "leds-gpio",
" m! w" b+ W5 h7 z+ r1 w .id = 1,
8 w+ C! C" {2 p; c) B .dev = {
& ~/ ?7 T1 E& v, j" c) \ .platform_data = &da850_evm_tl_leds_pdata,
0 }, v% G) A G4 } .release = led_dev_release,
- Y. F# Z" C( m& @0 K }
8 G/ a% |# L# o! o+ ~2 e+ i( u};, @, U2 s# T" V5 U
! \9 `& g% l8 B& c! e
static int __init led_platform_init(void)
+ d+ x; n5 |6 v7 H# W3 U{' F( o/ Y2 j( @) b3 c8 P: [4 } _' j$ J
int ret;
4 Q, g- B" M! p#if 05 \) Y1 p3 w& Y2 k6 H
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( k+ i9 x, p4 z4 i- b1 G if (ret), ?7 Z; X/ v% j
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 T4 `1 a# H6 @" @. ~
"%d\n", ret);. Z6 @* V7 d1 U* ^. J' y
#endif4 c! f& w& j8 s9 {3 v
ret = platform_device_register(&da850_evm_tl_leds_device);: C: [( I1 v4 a
if (ret)
; U) f# t3 g: S* F: U! j pr_warning("Could not register som GPIO expander LEDS");8 X( P3 x) z# W) _3 N( `
else1 I* o2 z$ c" p1 b$ o$ T+ P K7 q
printk(KERN_INFO "LED register sucessful!\n");- I# e& ^. j7 \
2 j. [2 v# C2 K) P* m; x7 v) ? return ret;: F: g- Y# s- f" l+ g
}) y+ G/ H* r0 J/ ^ G- J
8 E, a5 B" Z4 z' _$ L jstatic void __exit led_platform_exit(void)
0 V" r5 Y: I I# h* r* |* C/ d5 k{; W$ s6 ^6 i- U6 j9 |8 U+ D3 {
platform_device_unregister(&da850_evm_tl_leds_device);
6 F s0 B0 U9 z! }$ n' b% I# p( w K" p; T1 g$ G
printk(KERN_INFO "LED unregister!\n");$ Z! s. e0 G; S6 t$ K) i! ^
}% x& A7 s6 _# R# E5 o
% F9 ^" Y/ A) @6 I( N
module_init(led_platform_init);1 F+ \0 F1 d5 _6 p7 v% k! [
module_exit(led_platform_exit);
2 i+ |! n$ k% e: I
9 U$ s9 x6 }. E' ^/ z: W IMODULE_DESCRIPTION("Led platform driver");- \( n; V# H8 ]# T5 T
MODULE_AUTHOR("Tronlong");' p# k' P5 s3 W( z
MODULE_LICENSE("GPL");
J/ t- w# H5 a! \+ }9 z9 T7 A& v2 O2 x0 ?# |; m2 y
|
|