|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 R/ a, X+ J# D9 L9 y
#include <linux/init.h>5 H. T, \1 g6 n! B7 a9 o w9 Y$ W2 ]; G
#include <linux/module.h>
. p; G: e9 A8 Z* h3 I2 J- W" m#include <linux/kernel.h>
8 D( a/ Z. I$ W8 P#include <linux/types.h>( c5 @9 W, u2 S
#include <linux/gpio.h>1 G6 I+ }- Z; p# z( J
#include <linux/leds.h>
0 L) t e" J1 y3 P/ r" M#include <linux/platform_device.h>
/ \& w2 Y! S( Y2 N5 C) l; W y
' s4 m3 a' }. N1 g' _$ F#include <asm/mach-types.h>" q1 C1 U) k$ Q! i' O
#include <asm/mach/arch.h>
1 U! J5 y# F/ I' m* t- I9 F#include <mach/da8xx.h>5 a2 l4 b9 [/ S. B. o) R1 X* C" W
#include <mach/mux.h>
2 U! U; P0 A$ _7 t- |) u$ A, N9 s, {+ Y' h+ e% T
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 S9 s3 s) Q3 G5 q. f1 t- ?3 N1 h( Y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ r5 V6 @' \9 U$ Z+ T3 ~; Q+ i#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% @! J7 }8 I9 C- L#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); z0 I k& f! Z3 e, l
/ l% |# D% J% R, M# h' {/* assign the tl som board LED-GPIOs*/' b: U6 K" H+ }4 [8 Z
static const short da850_evm_tl_user_led_pins[] = {
1 X$ R, w' Q+ {! ~ /* These pins are definition at <mach/mux.h> file */8 ?. E, [7 [; v! k1 Z
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. k: n3 [# N2 k5 e8 m
-14 w; o4 M& d8 u
};
) H3 L$ A$ B4 @" | D: U
W. @$ P9 Q- h% V% R! u5 e- b% W& zstatic struct gpio_led da850_evm_tl_leds[] = {/ N3 `5 A. K5 D# R7 C3 x& e
{7 k0 u; o* U1 K" U& n4 }/ _! {
.active_low = 0,7 C. n! {3 Y7 H/ w& `: f
.gpio = DA850_USER_LED0,! U2 d% a: K' m1 k0 r. X6 t! R
.name = "user_led0",- S& p' W* X4 m) n% U( Z' k
.default_trigger = "default-on",7 R% @1 J9 o1 b9 m7 f
},
5 Q( \* P" x( G1 c5 H {
7 J( u! J6 C5 H1 d+ E .active_low = 0,$ m& D( A5 j5 n1 p/ b: i
.gpio = DA850_USER_LED1,
! T5 ?0 H( }6 P8 f .name = "user_led1",; |. d) Y( j5 x7 g, w
.default_trigger = "default-on",
! Q5 e ^. y0 n1 ?4 a },
& @" W4 W( y9 M% n3 }! l: o) c {
6 h; H& L; X% q3 _ .active_low = 0,) f5 O1 w. r5 G* c
.gpio = DA850_USER_LED2,+ @) j, i' t$ ]* [
.name = "user_led2"," _4 t: h: H1 q/ j2 w
.default_trigger = "default-on",* J) ^5 G- K% n- _ t! A
},
7 I# c B5 K8 n- c1 x) p. J3 \ {% Y; T, Z! b/ i* {: s8 A: I7 x
.active_low = 0,% _6 [" G6 t* V3 k$ l
.gpio = DA850_USER_LED3,' z0 E% [6 |9 U/ b& x; K3 x# i
.name = "user_led3",* @/ g# a# n7 K! A4 y
.default_trigger = "default-on",
- B. e$ e7 N; Y% d) D, l/ { },) W7 k* q( H7 C( |
};6 K& g7 R1 Z5 u6 f9 G
2 M# u" |# d) F7 e* t5 Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. @9 r% }1 U+ x
.leds = da850_evm_tl_leds,
$ n, z- D z: x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),) e. w* q, T7 ~
};
& b3 y6 F- ~6 k) i! A. _- Y+ `
: }7 @; m$ X* Y0 R1 v V& Astatic void led_dev_release(struct device *dev)3 i3 J& M4 j Z5 @/ y6 x) P
{2 H" T$ Y5 b8 q& m* @) G1 `
};
" {9 U- P5 R2 u) n3 [ e N3 [7 V' ?! ]6 |& ?# u
static struct platform_device da850_evm_tl_leds_device = {
$ K- e5 q3 e3 ]8 |1 A% U$ q; x$ @' g .name = "leds-gpio",
5 J& ^. _/ M) x; Y. ~4 t7 a4 V .id = 1,
# f2 H& b) K$ q# e( u8 g* A8 R .dev = {8 S$ f, J5 e2 Y- C( q. M
.platform_data = &da850_evm_tl_leds_pdata,
) _6 G5 \9 `. U; Z9 v( T .release = led_dev_release,2 ]7 F; Q- y0 g0 W& w1 F2 M
}0 J/ |2 n+ y2 ] O+ K5 k- t) t! Q" {
};9 W/ \* q: K, O. ~ ]5 U- Y8 P
7 j1 r. i* _2 `4 p% P. Vstatic int __init led_platform_init(void). q. ]" F6 w5 P+ s
{3 C. z4 C$ X7 v5 b# [& o
int ret;5 o0 s1 M* g7 \9 @
#if 0
* u' W' L: q2 K# B ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* ?( t3 Q4 O/ b* Y if (ret)* b/ I# D. F x4 F% F/ @& V2 n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ j& f' ^) [8 X9 e# T' W
"%d\n", ret); _5 G' S: \/ }% ]: h
#endif) }4 B! Z1 r L; {
ret = platform_device_register(&da850_evm_tl_leds_device);
2 M8 J1 w4 N' h& { if (ret)
" _8 w) s& g4 L1 N5 Z% n pr_warning("Could not register som GPIO expander LEDS");
! C* p9 X: I% E% k else
$ B8 o; R5 Q4 `1 Q! t4 C printk(KERN_INFO "LED register sucessful!\n");
; K, f- I2 y4 e+ b4 v- ]. n/ ]: H6 I" {
return ret;
6 i) {' A* z, d* p}
# y/ [3 m1 V8 F9 Z9 ~! Y/ S# C+ r1 J8 Y+ R# Z
static void __exit led_platform_exit(void)5 w& o, l4 h- |$ ~
{" e0 N3 d0 U) ?$ s4 L1 G
platform_device_unregister(&da850_evm_tl_leds_device);$ A {" B" S. n4 q) \
& h) w0 `3 r' z& q) O2 Q+ E$ r printk(KERN_INFO "LED unregister!\n");0 S! x8 a$ G. y
}& |2 |5 i7 _, ^$ |: d; Q, k
. H: p2 m& W5 Q
module_init(led_platform_init);
. |! k- p8 ]& l. `" l& x# Omodule_exit(led_platform_exit);- {7 p; [3 q) ^; R# F1 {. t( c: N. {
# ]$ g0 b+ [8 K7 t) f) d" y
MODULE_DESCRIPTION("Led platform driver");
$ M1 H; ^- ?$ f5 B) fMODULE_AUTHOR("Tronlong");
! s, l! O% S& p" L/ ZMODULE_LICENSE("GPL");
# y) M% p8 c* ~- `
( P7 E! j- T m |
|