|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
) t* C" w. v0 ]#include <linux/init.h>" n6 e% A g$ T. y% t7 F3 y
#include <linux/module.h>: c" k0 T1 ?$ K) W
#include <linux/kernel.h>
/ w% d9 \6 \* t#include <linux/types.h>( n6 d/ ?; x/ J5 ?+ O
#include <linux/gpio.h>1 v3 f) c; G, v& D- [
#include <linux/leds.h>- E0 W% S2 L/ k( f
#include <linux/platform_device.h>) k4 }- z# g) e! y* F4 e
; g6 O% F; C* p* k1 m# d#include <asm/mach-types.h>) s/ \( I) J5 E4 @+ x
#include <asm/mach/arch.h>" m5 N2 F. U4 F6 B) C' Y) N4 S9 ~2 J
#include <mach/da8xx.h>
; j6 w! s3 `" S. ^) b#include <mach/mux.h>
% C6 A A% m n$ z( c. t
2 z/ h5 u0 ^9 e4 I#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: Z+ N' b% x( [#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 b) O) Q6 Z, i" p
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)7 G' R8 ^6 p$ h9 W
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ g& S+ z+ \3 w& ^& V: y3 T5 ?& X) V: S
/* assign the tl som board LED-GPIOs*/* {, G4 `+ N* S: m( ?& Z
static const short da850_evm_tl_user_led_pins[] = {
6 }# s, K2 @; S /* These pins are definition at <mach/mux.h> file */- |9 a, {* \0 m" g `
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 k1 i5 i5 i3 ?2 c9 A( w0 q -1
3 A, F' W; s& q `7 D/ G D& w};: Q, ^1 E9 D7 r4 t# L: [
) r4 B8 g7 y P5 z/ M
static struct gpio_led da850_evm_tl_leds[] = {& J, X$ M9 q( a- f' F
{: x$ O8 V7 Y# o' [' L
.active_low = 0,0 t4 m0 H9 H. R. `$ {" x3 @2 ^) d
.gpio = DA850_USER_LED0,
" h9 i/ a. {% j7 N5 i% C .name = "user_led0",& ]4 X# Z2 q# c1 b6 R4 q$ p% ~
.default_trigger = "default-on",
" K' f' ^3 L- t6 g! T },0 u2 X8 ~) X" s* T N5 }3 ^1 l, n- X
{0 P% g# [1 [2 `0 N. x( L( b
.active_low = 0,
3 ^ E' v0 Z( Z .gpio = DA850_USER_LED1,! u8 Y9 G% ]+ K5 J
.name = "user_led1",$ g* S8 B& P, E8 C
.default_trigger = "default-on",
" g( v7 j& R$ l. _! h/ e* G0 D }, n$ c5 X) | N" R4 u f
{& _; v9 I' H3 {: [
.active_low = 0,
+ M7 r8 y; X3 v .gpio = DA850_USER_LED2,$ U2 J# a( P R' e) ?4 J, R
.name = "user_led2",
7 U9 v7 O, c% { .default_trigger = "default-on",8 Y" _* l. P$ J# d& v
},
- T& n- |+ a- l {
5 S4 G$ O8 i, g" d .active_low = 0,& M+ {/ l* F7 E2 {( ]0 b" D
.gpio = DA850_USER_LED3,
0 H% I% B7 n5 g) B4 i3 R* ^" ]) l .name = "user_led3",/ v" m/ ~ G& p7 n1 [
.default_trigger = "default-on",
7 A. A) J$ y4 `! l9 ?8 N1 O! Y, k },5 V4 ^% T0 m% b
};
$ k- z) ]3 j5 s8 @3 o
5 |4 ^: L8 D+ b% J. t/ Lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ m" N+ ]/ I3 D4 [3 n9 G7 V2 n
.leds = da850_evm_tl_leds,8 I7 {7 ?6 e9 j: O7 m; }8 {! h( J% n
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 v, ~. q \' B1 f};: c, n- i/ z1 X& Q
5 w& ?- |* s) B
static void led_dev_release(struct device *dev)( ~* p5 h+ D* R* T% s2 k
{7 G! ^$ U& g1 W+ p! R5 O
};3 ~+ o. S; _2 {$ ~4 K; Q1 a) |9 n
: j4 J8 k* G% R1 L3 A8 q( nstatic struct platform_device da850_evm_tl_leds_device = {1 K& M* `( C& u; b7 H! R1 @; L3 u3 B+ |
.name = "leds-gpio",$ c7 T& _( _, c
.id = 1,
# S, C2 `, M8 t: c .dev = {$ `( b% q; l6 u0 k
.platform_data = &da850_evm_tl_leds_pdata,
4 X1 e* d7 Q* t2 I! H .release = led_dev_release,, ?! T. S: t J+ C# d
}
$ i: l( K9 {! I) v0 O3 A; L- W2 @};4 l+ e0 O' t% g6 M3 g
- d; s! i2 \( W
static int __init led_platform_init(void)
: W* \7 o8 v+ A& V& b1 M{7 l0 |% s7 f O' T
int ret;. X8 e0 I" i7 m( Q" t& [
#if 0
/ ]. v! j6 L/ E# W( h. u. h- k( g3 B ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ k0 f* V# c; s) x H/ P if (ret)
/ O" _3 n0 M1 V5 H2 l" P G$ M, p pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 U, U' r6 V/ _2 c; R1 t9 G4 j2 M
"%d\n", ret);
, y2 O; Y l% I0 ~6 G#endif* M9 v. d' e6 T" E; C% y9 U
ret = platform_device_register(&da850_evm_tl_leds_device);
& o3 B" ~" ~ `" _ if (ret); c7 b3 K b: x) d( [# ]8 t
pr_warning("Could not register som GPIO expander LEDS");
1 a }/ g7 c1 X- S( ~6 R else
: ^( ~4 v! E& ]- d' S$ i \# r printk(KERN_INFO "LED register sucessful!\n");! K5 ^ i. O0 K |! g
( z) W2 d) B3 Q9 k# `- C return ret;
/ {. R3 _1 q; s7 `$ X}! V+ K" a! o- n0 Y0 x/ C
: c7 m8 ^2 Q/ B0 Y5 f8 Pstatic void __exit led_platform_exit(void)
. M2 l9 v2 A3 M: S' D7 V* K+ O) c{
- U, j8 R/ G9 _/ |/ b3 Z platform_device_unregister(&da850_evm_tl_leds_device);
+ a+ F1 g e8 g3 ?% c( k$ g+ t
& D8 C& U. {" p3 {7 c* h printk(KERN_INFO "LED unregister!\n");& k1 X A+ X4 Q2 n W* w) D
}/ N+ X* W# b0 W8 f0 O. Q+ [
9 y1 {7 O5 ^) v4 E' b; hmodule_init(led_platform_init);3 w! _; G6 w: t) f" [$ j Q
module_exit(led_platform_exit);% [$ _6 s+ \1 g
3 C m s' u: Q
MODULE_DESCRIPTION("Led platform driver");
$ a, F9 e' O" l5 F; q+ s1 ]# O4 VMODULE_AUTHOR("Tronlong");, f. k8 b3 k, Q# o& _8 }
MODULE_LICENSE("GPL");7 x6 U# V; {2 Q* G) O1 Y( t
0 n/ J! }6 u5 l" W% d/ E/ E6 i
|
|