|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 K' `- u2 G+ r; T; ?#include <linux/init.h>
1 F, `, d2 f" w! u7 r% W+ u#include <linux/module.h>
( `3 M* `4 g/ O3 {* w7 w" \- w#include <linux/kernel.h>
0 A- w9 O3 w1 j* U#include <linux/types.h>
; \% b, q1 D/ H# F#include <linux/gpio.h># q# G/ J7 t; q- d' k2 S
#include <linux/leds.h>
$ D7 W( L9 ?: c9 Z* \, h#include <linux/platform_device.h>; b" q: r6 Y9 q" S( j" ?. m% e6 S
' h! p1 @! g# V# Z0 k A3 s#include <asm/mach-types.h>4 z8 K8 d" F; X$ ?( F6 s! d$ B
#include <asm/mach/arch.h>
" l# X5 L. M2 d: g1 C4 M3 \#include <mach/da8xx.h>
/ R2 c7 X5 G" v8 Q1 L8 B, x- T5 H#include <mach/mux.h>& i) z; o4 n5 b
8 L, v/ \( O- g8 h3 B" j#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 I: o2 q% R4 b6 @3 D#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 H; o" I u) K& S, Z( Z
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 p9 F' O" W+ M5 t* G$ T9 w& m" a
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2), p6 b+ _ g6 l, w
4 n9 Q4 E( V; F* P
/* assign the tl som board LED-GPIOs*/, m- I4 F! M! e: a7 M4 \/ t r( |+ a
static const short da850_evm_tl_user_led_pins[] = {
5 N) e* O. d5 |3 \ /* These pins are definition at <mach/mux.h> file */7 T6 Z, a% d& {1 f9 a
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. ?- T( s& _, v9 n: D -1, Y' S1 ~& ~+ |: h. P! L+ ~) \' w
};. w: a; i2 x/ C# X4 t
. s. ~0 X7 z. @7 Q% P% @2 T. Nstatic struct gpio_led da850_evm_tl_leds[] = {
. r6 ]& Y+ ?1 R- ?8 p1 f+ p {1 h7 ?% n& ~: r
.active_low = 0,3 f/ d0 ]/ _$ w f5 U! o9 u/ Q
.gpio = DA850_USER_LED0,
$ C; }3 ?5 @; K3 r" l' I) Y .name = "user_led0",+ u# N1 Y1 k5 G. m6 P `! o
.default_trigger = "default-on",7 c/ ?! y W# y$ L
},
* G& M5 _$ _4 X* _1 J {
9 Q7 _8 v! c2 s! ?) \ .active_low = 0,- e/ h# [3 q/ M# k% G$ U/ v
.gpio = DA850_USER_LED1,! C+ s5 c* w. Q0 U
.name = "user_led1",. i: h# a4 O% g3 v2 w
.default_trigger = "default-on",! i! T8 e; Q$ ]- t* A
},6 V# o/ @' N) C2 T# B5 G% M; |
{% t* n0 x! K% Y L' |' X V- g
.active_low = 0,
; b; X* k: H, [! r6 r+ I .gpio = DA850_USER_LED2,7 k3 N% Q$ I o. | d, i8 I$ Z6 }
.name = "user_led2",
( B" s2 l7 X: ^0 Y J, }& u .default_trigger = "default-on",
: `, [/ `0 Q* z5 M3 g1 P9 ~3 ~2 A },
6 Y4 Q6 N$ g! ^8 Y$ Q* ^ {! g: p9 X: j. L1 L
.active_low = 0,
# W5 E4 ?% Z* A4 D# j; D .gpio = DA850_USER_LED3,- c1 _/ I4 z7 A( Y
.name = "user_led3",; D, F3 z' |6 ^9 l Z5 }% T
.default_trigger = "default-on"," R) ^. H* _3 e8 f0 j
},
1 I# L, M E7 }% ]+ N# h; N};
$ E8 e- @4 C. {
/ f' ?' b- C8 _ m/ sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- u) a" W0 x5 y5 S. O! c .leds = da850_evm_tl_leds,
) X) X* \ V$ d L .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* @- Y( Z; f2 k E4 @
};
0 ^% W- P) x1 o: R# @7 k' `& ^
3 ^5 U7 r% Y( d8 K# U, H4 `2 i0 ?/ Bstatic void led_dev_release(struct device *dev)
6 c6 C- v$ W' U. ^{
; y: \' k/ n9 v1 [: j% m- v};
2 |' P$ a2 f `& E8 c5 d9 v, [! s0 p3 @3 h( [% S% U3 b
static struct platform_device da850_evm_tl_leds_device = {4 B- K n" U4 A9 V1 I
.name = "leds-gpio",3 p; _" p& B2 f j7 {
.id = 1,+ \3 \. G- C# o8 C: ]
.dev = {
% P! i6 b4 Q. n" V) u: y .platform_data = &da850_evm_tl_leds_pdata,
4 {" Q1 N3 ]! a/ B" t0 n .release = led_dev_release," [ E# O- e9 g' V9 _6 [- q7 {1 y
}& j! O- H* J' Q. K7 V5 |
};
) y0 B1 j: Q: q; S$ m. R4 }
K' @ i/ S. {$ B/ k- W7 P9 D( O" z/ pstatic int __init led_platform_init(void)
: Q* e( U% }: h0 B6 D{$ \) X" u _4 `5 ]1 x- Q) |3 q
int ret;5 x5 l( f' e' {$ n3 H2 f
#if 0
4 @5 o: t2 `3 W, V* n9 z0 N ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. ?8 w# Q& H5 U' O" g1 B0 i/ [ if (ret)8 @! k6 A; ]2 H9 [
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, K1 l* \/ Y# z; c. J; J "%d\n", ret);8 u$ Y) a0 m5 [: a0 C' T' M1 m2 j
#endif
! n1 l2 ?% F3 Q+ z l ret = platform_device_register(&da850_evm_tl_leds_device);/ h0 I3 t4 [2 r! a2 r6 I
if (ret)7 i0 S u8 v; A: k5 h
pr_warning("Could not register som GPIO expander LEDS");6 h1 @/ p$ C9 ]: J
else1 ]0 T) t1 d5 o# e! P
printk(KERN_INFO "LED register sucessful!\n");
: k, L/ X& ~$ C& Q$ q. W& V x3 D7 |& {# [" B* C
return ret;; i H& f8 v' o+ }1 r6 {% X9 P
}
7 I) {. L9 d! A$ v6 g2 g( `
1 p- w' J1 p" M: \1 n* Lstatic void __exit led_platform_exit(void)
, w O$ Q$ ?1 C* q6 Y2 V$ ~{* Z& I, f( c& M4 k: Y7 P
platform_device_unregister(&da850_evm_tl_leds_device);$ v3 U6 N$ I" z k7 f
- ]8 \5 e9 F( E) u7 g+ N B# Y printk(KERN_INFO "LED unregister!\n");
* ?, H+ m8 x8 R: A. w7 e9 W} @+ R% Y1 C( ^; Y% N0 \
9 D2 X: B3 t/ i' [: E
module_init(led_platform_init);
3 s D$ n7 S. A1 kmodule_exit(led_platform_exit);
! U6 n- A# L. D0 @! Z
# x4 \6 f& g% G( J2 WMODULE_DESCRIPTION("Led platform driver");
2 y# E+ d1 e# i/ r4 w% X" WMODULE_AUTHOR("Tronlong");
% h, v0 @* c* I0 a1 T+ rMODULE_LICENSE("GPL");
. U$ |! Q: ]& O0 j
% o, J+ t1 x! b9 X+ x3 K% h |
|