|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 ?7 n u0 ]0 z8 O, v
#include <linux/init.h>& M. o" G' w \! h) [
#include <linux/module.h>
) e) f# V* L% o0 S, `#include <linux/kernel.h>
) p" G3 y5 D* n: Z& z) o. E#include <linux/types.h> M) A7 V& f) _6 k
#include <linux/gpio.h>" m/ A+ \# {; h
#include <linux/leds.h>
. X: ]8 \# D9 C7 d Q#include <linux/platform_device.h>; U! h {5 H+ N2 S, s ^
0 _# C, n9 Y& z3 _( }% I- ?: G. e
#include <asm/mach-types.h>
2 |7 X6 b$ U. }8 Z$ V#include <asm/mach/arch.h>" Z/ S+ t2 T/ P: A6 b( ]: L7 X9 n" Z
#include <mach/da8xx.h># Y# @6 Q c5 i- Y" Y( D6 z
#include <mach/mux.h> G4 g& \) ^0 {/ N- l
C( e9 a# z% P- b- f#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! Y* m$ @& V5 M# L9 @7 N#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
2 a! b6 d- K2 B+ G( `" X$ v1 Q5 x#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), {" @+ t6 f2 x3 b
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. q$ J: \2 u0 I* @1 x: T' D5 A! ]! |" `: l
/* assign the tl som board LED-GPIOs*/
$ Q* H+ _6 Y1 _/ g* o- E' Estatic const short da850_evm_tl_user_led_pins[] = {
+ ^0 k8 F/ q& t0 F: @ /* These pins are definition at <mach/mux.h> file */( {- M) ~6 n1 @. U
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. w. n5 L2 |: J -1
7 n- o; l5 P- x' o# w};
$ b( [! r+ J: {" i- Y3 ^
; o( |' j' |2 C: Z g) d, f9 j, Istatic struct gpio_led da850_evm_tl_leds[] = {( w7 Q% h# Y9 L; A
{
0 x6 ~9 h# d+ d; n .active_low = 0,$ `& D) I5 M: Q h
.gpio = DA850_USER_LED0,
* v4 _* ? G# R .name = "user_led0",. q. i# b; K0 O
.default_trigger = "default-on",& j; s: c# Q9 y: E! E# |
},
5 C+ B5 A V: N% n0 o! C1 v {3 R5 S) d% a2 ?8 D* `/ I" M
.active_low = 0,2 |5 k5 [/ s/ v; c7 f. C
.gpio = DA850_USER_LED1,
( ] H8 r: k4 P7 }, @. ] .name = "user_led1",& J7 q. }6 G' n6 M
.default_trigger = "default-on",
% ^+ o; H# M5 B },
( h2 [ G w! {8 U& L {
p* Z( Z* F* j .active_low = 0,% S: q6 Q# }0 U# w
.gpio = DA850_USER_LED2,
+ A7 [3 W- C% s9 V .name = "user_led2",# R3 b& f5 }* Z$ Q) l k0 q
.default_trigger = "default-on",0 x0 e, F3 |- y9 n
},& H# a" x2 I% ~
{
" {2 \ x; |/ G4 Z- D( w .active_low = 0,5 h3 j* ^/ H. A2 w9 \
.gpio = DA850_USER_LED3,
% t5 S9 ]% ^( B) ]3 ~: i6 c .name = "user_led3",% P* R3 |, l5 n6 V* ?
.default_trigger = "default-on",
. D* _! P4 e# I( M& N) ? }, Q" P6 {* C+ u% p5 B9 G: t
};
) x) \2 c% V2 F* \
6 r& D4 P# d, _ y v$ G6 q9 h% \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 W/ R' @8 i* s+ a9 Y# X4 L
.leds = da850_evm_tl_leds,
, T1 T5 @$ K( a: r% r" f .num_leds = ARRAY_SIZE(da850_evm_tl_leds),; A4 O1 [" x1 h) j2 r$ k3 S
};2 V8 h% C6 }; i8 R8 O
# K" L* |, O4 r( c# D& Xstatic void led_dev_release(struct device *dev)5 z8 o, |' e! g
{9 ]0 S0 g* ^3 N
};
8 c) t2 n3 K/ ]4 ]
+ i- d1 U4 P: f* U9 O4 xstatic struct platform_device da850_evm_tl_leds_device = {1 h( b. Q! I8 s6 g+ O
.name = "leds-gpio",9 K& h1 c; g0 G, P+ F- I/ G' y
.id = 1,/ Y8 w9 a; h( C6 `( k, U
.dev = {
7 O, c2 E1 ^! O7 n .platform_data = &da850_evm_tl_leds_pdata,/ W3 i8 @7 Y( n3 r4 o
.release = led_dev_release,& W q0 L& _9 b- p- q5 ^
}
$ q( ~. P4 X# {# Q};( O+ M: E# _3 L1 a$ n* M: a+ {
% e+ v8 ~( U, E
static int __init led_platform_init(void)
( L8 U& p6 n. x" L{
+ m% H+ L* |0 s- b7 K1 v( x int ret;
/ ?; H' k4 o1 o, C8 r3 E1 m7 k#if 0
& u: T9 {/ J- q# \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* c6 |! o$ y* O
if (ret)
: f% s1 K. }/ [ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 z2 }6 q7 p. M+ n& p4 G "%d\n", ret);/ I$ R* h( V* C
#endif3 G7 j0 Q% W6 n; M
ret = platform_device_register(&da850_evm_tl_leds_device);2 e. t- f4 u, A7 K, J
if (ret)) r3 Y9 R2 T! z5 y j' ~
pr_warning("Could not register som GPIO expander LEDS");
3 a. R& W# w6 c$ c9 D4 W else! F2 H) e8 G( p
printk(KERN_INFO "LED register sucessful!\n");
) u& x" Z, d- ?: l
1 A2 ]2 @2 V- e" q return ret;
+ B' `1 X: V( }}: ^9 u8 N# N; ^' h Q7 X& n& D6 l/ f
! P$ m4 I9 I d. I
static void __exit led_platform_exit(void)% z0 c1 v& [2 v
{5 L6 D8 @! T( c' H5 [/ D9 M" G
platform_device_unregister(&da850_evm_tl_leds_device);1 P- u7 T# l5 y$ U0 y# Q
, i8 Y( _2 T5 X6 L# Q6 i printk(KERN_INFO "LED unregister!\n");; m! m: T8 [0 l7 l7 B( S
}
1 R$ Y7 ~5 z. H- X; a% c0 Z) g2 Q# q& B! N
module_init(led_platform_init);$ j, P! O ~/ Y! w1 v8 c
module_exit(led_platform_exit);
' n4 j& Q; [; F
F. b$ i. |( [3 e( G$ \' h; a7 G; gMODULE_DESCRIPTION("Led platform driver");
6 t3 ~2 M* i2 U [' q) yMODULE_AUTHOR("Tronlong");
; L/ x! ]/ K7 s. Q vMODULE_LICENSE("GPL");# Q# Z B L6 j- o& C) w2 ~8 ]5 ?7 c
+ e9 p3 p" u3 U' w) a
|
|