|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" Q, {9 ]8 [" t- o
#include <linux/init.h>
% m* h+ m: m3 k [* {0 S: B#include <linux/module.h> V& G f, y. K3 J* m& l
#include <linux/kernel.h>$ D/ X8 o% x* i" c
#include <linux/types.h>
" H7 \6 ^, ~1 W3 o" `7 {#include <linux/gpio.h>
! _2 l2 V6 e$ U( |: Y#include <linux/leds.h>
" |) B! l1 u, Q* H: }4 Z; Q& L#include <linux/platform_device.h>, t1 @5 j* j6 ~% q
7 s/ e( v$ [$ t' ?4 q
#include <asm/mach-types.h>
: n5 |: W) r3 u3 M: I#include <asm/mach/arch.h>, c! e' p9 G% _
#include <mach/da8xx.h>: J8 g% |5 R8 G+ x/ S# M4 T
#include <mach/mux.h># K* m: A3 d: k0 z6 x/ S' y* ]
- z) D# N" L! Y
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' o' p. w6 _+ x' ]$ v& j
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% {1 I) C& {0 G* F3 b/ @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, R8 e$ ? V2 W& I* R#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& W0 w' v. T0 ~: j( z) J/ n6 Z1 W3 a6 L2 M7 J s: L0 ]. d
/* assign the tl som board LED-GPIOs*/3 n4 D* p+ `4 g0 w
static const short da850_evm_tl_user_led_pins[] = {
' g7 q+ F, G1 f$ d* o% {- { /* These pins are definition at <mach/mux.h> file */4 ^' q8 u4 m# `' f/ V- \
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, u% i+ h' V1 C! z7 Z" f5 ]3 Q6 R- _ -1/ t, }" x6 D, T+ g
};+ ? y1 z2 l" e' ?6 E' ~9 [
0 R3 Y2 p0 F0 Mstatic struct gpio_led da850_evm_tl_leds[] = {
% s5 |& n( `5 e* ?3 y: n {
3 x. k) D/ n- H/ x, Y7 v7 {) V1 D .active_low = 0,6 i. p, n% R" F7 S; K$ m
.gpio = DA850_USER_LED0,
, P. n) j4 `% X% U .name = "user_led0",3 Y3 G E% g$ a& H3 e
.default_trigger = "default-on",# s/ o" t; C% e: ^' s" x6 x# ]1 T8 }
},
$ @$ D! a- _' \ {2 _1 J0 [2 |2 E" v% ?
.active_low = 0,- M! l: \9 U( F \
.gpio = DA850_USER_LED1,
/ V1 ~1 L" v% F .name = "user_led1",: r; y& x* n9 s* X$ s2 a0 ^
.default_trigger = "default-on",! [; k2 ]! I) ~
}," S$ Q6 |, W7 T) Z" j2 Y9 j: J4 Q
{
5 w a" I* q3 O4 f( Z% i i .active_low = 0," u3 a6 x- w# {, B, d, ~. {- K
.gpio = DA850_USER_LED2,
2 C3 k/ D; B; E0 W5 K- ]" Y3 _+ z; B .name = "user_led2",5 ^4 I% J9 v2 ^9 w" n" E
.default_trigger = "default-on",
9 v9 i0 }4 z& J: a },
5 H* `$ K0 {! R0 Y- n {
6 h) K5 s6 D7 D0 E v .active_low = 0,( @8 b7 ]* p3 Y, X
.gpio = DA850_USER_LED3,
/ j- f' u, \3 }+ [8 s .name = "user_led3",$ g& i# j& a. ]3 W7 k
.default_trigger = "default-on",5 o& D& h3 \+ c( y# t& f
},
% m7 }8 Y4 U6 V9 m% m};* m1 l5 }# X" v# U# Z
: M2 @+ ]0 q+ Z9 E" V1 Zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 _1 Z/ H) E+ G; j
.leds = da850_evm_tl_leds,+ ?. [5 F5 F5 K( |+ R! a& y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 z: a% W: d8 k, ^/ P, @- `# l* o4 }
};4 Q0 a; {$ `& f1 ^1 X9 R2 L# p- a
4 ~6 ~: b6 ?+ v2 kstatic void led_dev_release(struct device *dev)
. m( t# E# o" x! v{
- E' G" G1 r4 Q1 ~# e6 Y, a};, ?( ]( b( @3 d% O. q
) I9 I! ]' ^) p- q$ B
static struct platform_device da850_evm_tl_leds_device = {5 t$ c5 U2 H6 Z7 a f8 h
.name = "leds-gpio",8 i, H( @3 F1 [4 W+ k
.id = 1,& L3 W. ~7 Y) Y& @& B
.dev = {
5 R8 L$ J/ V4 k* ` .platform_data = &da850_evm_tl_leds_pdata,
) g: _" ]7 F, Y- Y .release = led_dev_release,; {9 p- A! H1 a0 }& E
}2 w# W) K" I. b7 s/ ^& p) [
};+ v! [* b; d. @$ n$ E
; ]8 H3 Z* B/ I, W+ t
static int __init led_platform_init(void)/ A, k* x% Q1 X1 j; t
{ s" L6 S! t! H0 {* A! F" i3 c
int ret;
- m7 I" J7 l$ ]/ i7 a' c#if 0: g4 {, b; O/ G% x* {6 S+ j4 b
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 U( A" }# n7 Q
if (ret)) Q% g8 W5 ~, Q( L
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ P5 z: Z6 J1 b) W4 J "%d\n", ret);5 h3 g7 l5 `1 _ x. b* l: E
#endif* O" K5 N/ _ l, ?9 l
ret = platform_device_register(&da850_evm_tl_leds_device);6 d3 K$ d* L- f# O9 N# D" A; c
if (ret)+ a/ D) r$ m8 V% u7 V" J
pr_warning("Could not register som GPIO expander LEDS");
: \$ @2 N. z/ F8 J. ?! B else/ u6 E" J) P" {- X
printk(KERN_INFO "LED register sucessful!\n");
1 Z2 q* S' o8 `. e0 R" b6 B8 U" E' m- {2 d- U9 m
return ret;2 P& A1 f5 @7 D" Z% Y4 G' c0 A
}' h( |/ k ]: X+ Z4 i, M
1 e; j$ D. a. n, ?' rstatic void __exit led_platform_exit(void)0 |& n3 |8 ~' V4 {
{/ I+ R3 |% x' x# Z. H- l
platform_device_unregister(&da850_evm_tl_leds_device);
/ L7 K+ ~4 W& `4 @0 T) ^3 v" f" {# d4 S( P% z/ ~
printk(KERN_INFO "LED unregister!\n");2 N# B# z! B: ~: c8 L) E" I6 M
}
: T5 Z( k2 \9 @
* i2 J) z4 D1 Mmodule_init(led_platform_init);
2 p$ ]1 V$ m. d3 b& imodule_exit(led_platform_exit);6 D) z' Z4 \2 F3 v
/ U# a0 |& y; f. I4 P/ F: ~/ X
MODULE_DESCRIPTION("Led platform driver");
S- P' I2 k$ y% j' m; \+ D4 S3 NMODULE_AUTHOR("Tronlong");& ]1 O' [* C1 F+ h/ j
MODULE_LICENSE("GPL");
' Z: L; f. d0 P% `% S+ u; {$ _
. c1 M2 B; f1 p! \* @# e' B |
|