|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: g& I; ~9 L E) Y8 D#include <linux/init.h>
2 ~5 w7 x$ J) A8 L' Q! b/ `# a#include <linux/module.h>; S' E- v3 ?& Y1 C8 Y6 r/ f
#include <linux/kernel.h>) {& b8 T! C, H" n
#include <linux/types.h>1 R5 W- S b W _2 D$ v
#include <linux/gpio.h>
# Z" b7 P' B) P: q#include <linux/leds.h>
! N, [/ k& {2 a, N/ ^$ m#include <linux/platform_device.h>6 D. c& N" \1 t2 M" f
3 \$ }) E2 S- S' F+ F( B
#include <asm/mach-types.h>- i0 L0 n+ l/ k5 t
#include <asm/mach/arch.h>" H( I' j( Q. ~+ @
#include <mach/da8xx.h>
' j' a- E. P$ _3 e#include <mach/mux.h>0 }4 L# C* ]1 }+ f% V5 G- Q
1 {6 }6 k D3 g, M5 E#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 x+ J! A) S$ P- Z# b: w7 v( Z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 m: T0 A7 p) r+ `) M. {#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. b$ X" j* R- [6 U7 I#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)0 W( {; ^( a. h+ r- }1 g- E
* Y0 }+ n) A8 f6 L/* assign the tl som board LED-GPIOs*/0 V) C8 j1 Y7 K% V& G) z' u% f
static const short da850_evm_tl_user_led_pins[] = {
5 G0 `4 o* u7 i H. Z$ e. X+ V /* These pins are definition at <mach/mux.h> file */) w% j# R1 q$ _0 W' e: f: G
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' }" h5 y* a7 F: a! O
-1* D$ {! x! Y1 q6 S
};
. m1 j: R) ]8 \7 G4 A/ T( ]' P
0 a' C2 e/ D$ J, u l# Tstatic struct gpio_led da850_evm_tl_leds[] = {
# c" @- x( H& F9 ?9 T+ L {, I a$ z" Q6 c. @ e+ a
.active_low = 0,
8 H/ _' Q3 @' q6 G; S& m9 j% K .gpio = DA850_USER_LED0,( o: H" @: M3 e
.name = "user_led0",
9 L/ K9 Q: e, S .default_trigger = "default-on",
% \: V6 }7 K- w7 m+ |' a },6 `; A' r' n& O& g' w u$ l
{4 K' ~; |$ ?, o
.active_low = 0,* ^! I) x& |- Q/ {* `( t
.gpio = DA850_USER_LED1, h0 m( n, A3 W; x+ F
.name = "user_led1",
9 h I+ w, k3 [; i T M c5 e$ _ .default_trigger = "default-on",
+ u3 T9 c1 u2 a },
7 H4 L& L+ ^, H% X: x+ c {
5 K- o- P, N8 p .active_low = 0,
7 w# J# H7 C7 o+ m. ]/ S .gpio = DA850_USER_LED2,
3 _# T4 r, D$ c1 ?0 K% \. p; L .name = "user_led2",- n U8 {$ g' S' i- B6 J3 C9 D8 \
.default_trigger = "default-on",6 Y5 d, i f1 a2 s6 P2 n
},
% G& a" ]8 g" x% ]5 p. l7 Q {5 \. R9 J! _- b+ h
.active_low = 0,
/ J. J5 X& r9 j- A9 B .gpio = DA850_USER_LED3,
) t& C2 P6 K" r3 m- w, T* ^9 c! I S .name = "user_led3",& u% x+ G+ @8 p
.default_trigger = "default-on",
) R+ g$ |, Z2 n! t. N% `( V },
& { j: s6 r1 T5 t% S};. X7 K1 p- q/ a
) m+ } {- R9 `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 H9 _: h5 F; E, D5 |; k. L: F1 c
.leds = da850_evm_tl_leds,
2 [$ F' x" Q3 d4 K4 Q a$ Z1 g .num_leds = ARRAY_SIZE(da850_evm_tl_leds),* b* G* V' x% `; i* `( X+ Q
};
; y6 \8 M- M7 ~( k8 N! ^
& Q% h$ }. u$ ~# L# P1 Bstatic void led_dev_release(struct device *dev)
& I* m- F) N: N* o% a{
& u1 e9 i3 ?+ {$ L( F" s9 k' b};
; ^5 l! N& i0 b& Y8 h9 M- k# z
+ L0 K' Q) r. p& S% Cstatic struct platform_device da850_evm_tl_leds_device = {0 H K; A" a+ l' [
.name = "leds-gpio",' n0 Z3 O* M1 [; ?- n
.id = 1,
* ]! [- `# @8 y2 y, F .dev = {" R9 z' Y/ y. j2 _7 i6 ?
.platform_data = &da850_evm_tl_leds_pdata,4 d4 h2 c w" L1 j
.release = led_dev_release, x. Y& }8 |4 j! |/ C
}# V: c+ K- n5 }% u: R" P+ ~
};; H3 g4 X( _4 g& U/ A, u
0 ?" W& J. T: b/ X5 ystatic int __init led_platform_init(void)
4 U" r2 |& V f; R3 E{
/ q N% {4 ?& b. R int ret;+ |* B: K8 v1 x, ^
#if 0
" h0 [; m/ J9 u/ w8 j ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 x: y2 h% d! h/ m: C
if (ret)
/ ?5 v% v# X p) T5 y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 s$ {5 p: y, s4 Z8 N6 K U8 _ "%d\n", ret);
! {) |7 _6 [! ?) w! U#endif' {# o- {* Y( D. \) i8 Y. c
ret = platform_device_register(&da850_evm_tl_leds_device);! u* _! w9 ?1 N% f' }
if (ret)
j/ n% U0 z( N* R pr_warning("Could not register som GPIO expander LEDS");' H) v$ L1 {) D h; M
else
5 o/ u" f0 I: A: w2 }4 B printk(KERN_INFO "LED register sucessful!\n");
/ f+ _% Q2 K( ~# `9 O' O. ~. H& h) d6 n8 ?' D2 n
return ret;# y1 v' o. L1 F9 B
}
, a# c: l, X5 K7 `) A* F
* {. e- ]! d+ y& ~. gstatic void __exit led_platform_exit(void)) t2 [0 ] y' N
{
8 t, W9 ~$ s, N/ I( I. e platform_device_unregister(&da850_evm_tl_leds_device);
& g/ R# P( u3 K: W2 b9 w& A1 Y! R; M* [- G3 q
printk(KERN_INFO "LED unregister!\n");
1 h/ q6 o! o4 l}
- ?- F1 S" h/ A, C/ u
: f. q: p: Q) C7 x+ c Umodule_init(led_platform_init);
- ^1 A+ G2 l, H6 @3 @ o8 {module_exit(led_platform_exit);' @; l0 D" F9 j$ H2 k( p
8 A% V1 T# H( \. e/ p2 D( p" bMODULE_DESCRIPTION("Led platform driver");
+ } [5 ^: }3 w eMODULE_AUTHOR("Tronlong");" a6 X* W2 W& R5 _5 r
MODULE_LICENSE("GPL");
3 w7 @, \' n$ B# X2 I8 ]$ l. J7 Q5 x0 y
|
|