|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 T5 \+ c/ q+ y n: W1 ~5 {4 j5 p% S+ G7 k#include <linux/init.h>2 v2 ]9 v' K& i) _$ {4 O
#include <linux/module.h>, D) D+ V5 @5 ]) J1 }, h; A3 _& z4 x
#include <linux/kernel.h>. R% r0 J# @, J# N" d
#include <linux/types.h>
- D: R; G0 B7 q0 y% t7 N. J) i#include <linux/gpio.h>" O- }9 s. ~0 d3 u
#include <linux/leds.h>. [9 ]7 ?& z: `- `/ p( e
#include <linux/platform_device.h>
# g$ H6 J6 G1 c4 V+ R* _
& S6 E! X4 v; J G#include <asm/mach-types.h>
" f* l, e0 d+ U$ e#include <asm/mach/arch.h>
, U9 t1 C, r, J) `#include <mach/da8xx.h>/ y W( z8 i9 `
#include <mach/mux.h>2 _$ ]0 q0 W5 y0 N7 |4 i" H
* L$ n& {6 Y: R$ O& n
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ U$ c& k2 i& {- H- a
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) T7 F8 H8 w w& ~# Q' i1 e( c! V#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) @+ [0 j6 K+ [0 q% ?8 O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ `. H: D9 U7 \ A$ z
4 \) ?$ j0 E7 j% W$ z9 }/* assign the tl som board LED-GPIOs*/0 t( Q8 E; a8 {$ A
static const short da850_evm_tl_user_led_pins[] = {1 A1 O" e& d5 J. c6 H* ~
/* These pins are definition at <mach/mux.h> file */: Z9 M; ~$ [: D5 ]9 @- }
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, t7 @" S2 i0 O6 z3 ^' M: _
-1
+ ^ l8 X% C' F0 p/ Q7 K};
" w" _, f3 k/ r- i. g- s/ _2 A2 [& V( a, T6 d; V- M
static struct gpio_led da850_evm_tl_leds[] = {
+ K9 A# S$ q5 `* V, k; ] {
0 Q# E6 t$ j, P0 r1 Q .active_low = 0,
# b# t* f# J& m. N4 J) I .gpio = DA850_USER_LED0,' q8 t4 i3 a) b( H
.name = "user_led0",
$ j- X( i2 V. {$ y) n0 Z O .default_trigger = "default-on",* I' _- T7 |( \( b
},# e2 X. A! I8 k+ [$ F9 s( k
{4 \9 t! i( G4 m Q( h& i4 t' `
.active_low = 0,
) z" C$ x6 r; D( I% g% }! _2 F .gpio = DA850_USER_LED1,
" d4 c: ^$ N$ l6 i2 l .name = "user_led1",
8 b, e- a% o- z" S; _ .default_trigger = "default-on",7 J- q3 {6 l5 q' j; y9 ~
},1 M$ h ?% g6 Q( A" `. Q8 ?
{! `- _( M* \/ @. B7 V9 z$ d+ I
.active_low = 0,
! o4 C2 e# z" A1 [- }& _ z' M .gpio = DA850_USER_LED2,
% e" T$ `' M# B! V6 ^ .name = "user_led2",# T$ Z. d( |. ]
.default_trigger = "default-on",
5 q6 x: I: F% t' |8 P8 q. g },
F% u4 h) K- U5 k {6 y) @' E2 }& Q' z0 Y0 g6 w- v
.active_low = 0,; i2 i7 M% W& E' C9 \9 X! G. I
.gpio = DA850_USER_LED3,/ J2 v4 O! q8 U5 D1 V+ d# G' J& Q
.name = "user_led3",/ t7 Z1 S8 J7 ]; S/ A! j
.default_trigger = "default-on",
h7 ^, \; Y" T8 P5 U },! @) D! ~6 x- M8 D$ v
};
4 H/ {+ y7 B/ K
: t/ @ P* \$ V$ I$ l; mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, F* a5 W6 U' m3 C8 u .leds = da850_evm_tl_leds,
- \5 A) v4 Z) \ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& l5 ^" b. {6 W# F* c8 A% j
};- i$ Z! J3 {( r, n$ { ~
- F4 ?7 B: R, n; F8 E/ _static void led_dev_release(struct device *dev)
9 g% S& h5 Z9 D# `; U( _8 y( o, `{
4 n: D! I/ y4 e# K) S7 X- a/ P};. O% G+ h' `# s2 Y: N5 f
3 S3 `2 p2 M, j+ b( P8 v
static struct platform_device da850_evm_tl_leds_device = {
, P4 a: H. X4 T9 i- J6 |; A1 o$ n3 t$ ^ .name = "leds-gpio",3 g, V# M9 i/ F, s x
.id = 1,
! s9 c& q9 d, Q4 i' Z .dev = {+ g- t3 H; y: [$ H' g4 h" M! Y
.platform_data = &da850_evm_tl_leds_pdata,
( {; v9 M5 N5 }" P7 o, o .release = led_dev_release,
4 ~& x; ^$ Z! c }0 ]: [: Y) d) m; d6 @
};
$ G0 ^2 e! \) G" j4 T# |6 C% V
- W/ @" i6 J6 D1 M; i& u6 qstatic int __init led_platform_init(void); }1 V4 W: }' A6 f
{# e5 A3 }6 _6 ?
int ret;
, q+ ?- s4 f" f5 K$ O#if 0
" w/ l- C. E/ y3 t5 S0 Y ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 [0 J M9 r7 K% |2 u: L
if (ret)
+ @* F8 R4 Q! m9 K$ p pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ T- l! I* e( w "%d\n", ret);* C! M0 r4 E9 B) y' o0 p% K
#endif
0 ?7 Y: X3 C' u8 n ret = platform_device_register(&da850_evm_tl_leds_device);" F2 |; g/ K% g/ b7 s5 p, r
if (ret)- u' [( f& ^4 f6 C! Q- E" |
pr_warning("Could not register som GPIO expander LEDS");
X" d6 v& b- _ m, B# Q! u5 f% r else' ?1 x, ^" K5 _2 h' N
printk(KERN_INFO "LED register sucessful!\n");
, O, D( y9 }+ M) o
4 W7 k6 F* m6 J8 ~/ F* h return ret;
# j: c$ a7 y6 w1 }. y" @/ h}
- T2 W5 ]# {% W. D# V, M. L7 M4 v6 [% Y/ N# P4 Z
static void __exit led_platform_exit(void)4 `& E( }4 A; c) V& j
{6 d$ L& F) v0 h# g+ W; Y- ?7 K; x
platform_device_unregister(&da850_evm_tl_leds_device);1 u) i3 f( g/ W9 f. M# |6 `
. H' \0 a; w6 @" e* B' P) l/ x0 D$ T
printk(KERN_INFO "LED unregister!\n");
7 L6 u+ d; Y7 i& H3 L+ |! }8 \}
" X0 `( M2 \" K! T$ i: f2 ^8 Y. B0 c% o9 H1 q
module_init(led_platform_init);
" a' s* d/ @; b" h: I4 {6 B) Qmodule_exit(led_platform_exit);- b% G7 g) N7 e$ h0 d* j
% @5 c0 C& L* a' k5 T
MODULE_DESCRIPTION("Led platform driver");& Y P# N) Y8 a. q$ z
MODULE_AUTHOR("Tronlong");) `' P+ l) O5 }+ \
MODULE_LICENSE("GPL");5 j: g0 H6 A, C& q) {$ W" n) R
+ t+ N! c4 p$ @/ E# ?9 Z: j
|
|