|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! h$ B: \. a, U. B1 T8 ~" g* f#include <linux/init.h>
( W5 H$ p( e! q+ J# W#include <linux/module.h>9 z1 a2 @/ n; K S7 e
#include <linux/kernel.h>
6 a$ _- l3 R8 |5 z4 n2 U5 m! g#include <linux/types.h>& \2 ~6 p5 N ?/ s8 b& A" Y* g
#include <linux/gpio.h>
+ V) P5 T7 f0 C% ~6 F2 V#include <linux/leds.h>$ {( ~, U2 `4 f/ p
#include <linux/platform_device.h>1 U3 R1 l. k& h5 U
# q/ b4 R) S; x7 b" M
#include <asm/mach-types.h>
; r5 z5 Z0 H9 R/ l* F- f; O+ O9 ^# Y( b#include <asm/mach/arch.h>
* s3 q: @# A; C5 t% f; S h" k7 U#include <mach/da8xx.h>
) {+ R' r4 \, R- f, [7 M2 V" x#include <mach/mux.h>
! d" Q. h8 B- q+ b5 t
8 S8 R5 u3 J! j/ R" H#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 z- K" }1 b( y3 f% P. E3 \
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ b7 Q8 B3 t: Q) U& B9 S
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 P" k) u' v$ E+ v# _4 \, f& ?#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% h! G/ C' v/ x
9 ]' f) r, l% n/* assign the tl som board LED-GPIOs*/
2 Q( ?/ O* L+ q# f. Z, estatic const short da850_evm_tl_user_led_pins[] = {& U. D- Z" G! Y/ q9 M
/* These pins are definition at <mach/mux.h> file */0 P! i; W; W0 A0 z; f
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,- b! s7 F8 i1 r, d- s
-1
$ n1 x, D. I/ c ^! |}; z+ E b. C/ |5 K5 ]% y4 s
: d2 B1 @1 J# B- B0 [9 Rstatic struct gpio_led da850_evm_tl_leds[] = {% r' i9 Y9 u- v/ G
{
9 u2 m% x4 W9 G1 ]8 O .active_low = 0,
( b9 n4 Q2 W! j) h .gpio = DA850_USER_LED0,
% `3 Z1 v2 s! _% V" W" z8 B, w3 v .name = "user_led0",5 u# F) [. H2 _# u" D
.default_trigger = "default-on",( S! m4 Q% `6 D
},3 l d$ {( o8 T, s
{& L4 P+ d# P* k( E2 y+ O: a
.active_low = 0,
0 _4 h/ s. v- q& u/ {. b .gpio = DA850_USER_LED1,
' t* c1 o m- h$ I' [6 V .name = "user_led1",/ m) ? L# ` t/ \
.default_trigger = "default-on",. a2 J0 C+ M. M0 Z. `$ W
},
' A! R8 j7 `( i2 @6 } { s+ i* X, t. a) a' J+ _1 Y
.active_low = 0,/ X" j6 d6 N' J+ B/ Y- r
.gpio = DA850_USER_LED2,* q# e3 p( s. b
.name = "user_led2",
' X% W) f4 b) Q. H% {, P* \ .default_trigger = "default-on",
( v; T2 @' c- D; Z- D G/ e },
& t+ F% E0 O4 ? {
; n& f7 r3 }0 B D+ z8 r$ f .active_low = 0,* `" l; W# t$ B3 T5 f$ H! _
.gpio = DA850_USER_LED3,1 z% N/ j- q9 e5 R
.name = "user_led3",
: I: A' h: w' h# c {6 S: ` .default_trigger = "default-on",: j: R" O1 {: [3 d
},
& c" W% J5 m! R* |' |% m};
" f$ |, N, c$ f0 _- l; F* d7 ~- I# N: V* X- r
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { P( m: w$ C' Z0 L
.leds = da850_evm_tl_leds,9 q8 Z1 J: W k# Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),) s" X2 t0 W3 O- o8 `# z
};
% g6 N M7 A- R4 X: D' @" c) }4 h% v# D& J& y- H
static void led_dev_release(struct device *dev)
3 v6 V7 j' _1 D% r; l3 @& T{
( ]+ C3 S0 ^! _2 o+ A# b};4 u/ ~2 G1 l/ _6 R: o
& a; Y9 _$ i' f1 b0 l; R( @static struct platform_device da850_evm_tl_leds_device = {! g5 p" ?0 {3 i3 L. E- x, s
.name = "leds-gpio",# I3 ]& f& V! _
.id = 1,
" K4 }6 H9 R* A# i3 g8 B .dev = {# M- S; m7 |% v0 `
.platform_data = &da850_evm_tl_leds_pdata,
S0 h5 f; U- a! j' T( J8 d .release = led_dev_release,
8 R+ N: E. T4 u. V# O( n, y7 r }
* h5 E/ e3 V* w};
2 I2 G# _) Y/ H! O- T
1 Z- i( q6 X4 s4 Qstatic int __init led_platform_init(void)
! r, t* I8 e3 f. U6 H w- S6 g{
8 t4 k1 F. q9 p int ret;
7 w( W/ H2 Q6 F8 i! d#if 05 T# n* D- G& T/ d: A+ n B
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! C3 Q# [6 L. y' Y if (ret)
$ q0 {! j3 ?$ P, i5 s: z- K: x pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& i9 Y) h3 `* n0 q0 Q( C
"%d\n", ret);
1 G/ A3 c5 B8 u6 x9 F1 ~, ]#endif! p# J) [" ?* d- T, u
ret = platform_device_register(&da850_evm_tl_leds_device);
2 e( C3 a; {" m4 A' g: H7 j/ ~+ N if (ret)
# x8 [3 g3 R |9 O `. O pr_warning("Could not register som GPIO expander LEDS");
! j I5 \ X: A2 \% x9 H% c$ L' H else
* v6 X* n; D2 B x3 E; x- U printk(KERN_INFO "LED register sucessful!\n");7 l! B6 C- n8 {) @3 P# P$ z
8 W, h6 M& W0 y, ^, e4 f return ret;
: z+ P/ T- ]# ~' F4 t( M) J( s: V& _}
" e1 k% Y0 `5 G) X; J2 c1 e) K7 K6 F" w& ^! ?% B( C) k7 G3 G* R* o
static void __exit led_platform_exit(void)
# B7 I* {- E4 [' ~{
" |: U7 P! ]3 x- e. Z3 ~* E6 r' B7 K platform_device_unregister(&da850_evm_tl_leds_device);- c1 z2 C& N- a$ J; Z
. X4 K0 t* `6 p9 F- J: ^
printk(KERN_INFO "LED unregister!\n");5 f! Q: T1 `0 }4 U# I) t6 }! ?
}
2 n( U. x& p" P/ N9 |
' X, W0 P# G1 l8 T# C2 }) _module_init(led_platform_init);
3 L$ F/ [% ]' a" mmodule_exit(led_platform_exit);2 E% j% F, r) e l
" a; f4 ^/ R) l0 l9 U- lMODULE_DESCRIPTION("Led platform driver");
8 W7 K: h$ P( X: b0 Q6 \MODULE_AUTHOR("Tronlong");: _9 k! s4 H0 N H6 O7 ]
MODULE_LICENSE("GPL");
: G4 d1 R& P2 g9 c( Z8 w6 T& Y* k3 e3 C7 D; R7 l6 ~6 r
|
|