|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ V" `5 q' r9 Y. S#include <linux/init.h>9 l* r( V* W5 \( m' a! E- T5 u0 m
#include <linux/module.h>
5 S) A2 t& Y5 z6 K#include <linux/kernel.h>8 q4 c% l) c3 c
#include <linux/types.h>9 U3 ]/ p- |7 V
#include <linux/gpio.h>
: w3 r0 u8 ^# S4 x#include <linux/leds.h>) k$ H8 g& e0 m' ^( o+ V! ?6 ~7 }
#include <linux/platform_device.h>
+ A$ E* {* [: ^/ k& z9 H; O+ x0 U+ [# ]* x0 U# E8 V
#include <asm/mach-types.h>
# c' j6 X+ b# w# g% Q# [7 Q#include <asm/mach/arch.h>' P; i" A- F, v# a$ j
#include <mach/da8xx.h>4 C' |* v3 b/ s& }
#include <mach/mux.h>
$ E; ~: O0 X( ?- e! K& k. ~5 I- b- R: L( ]
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( a& m2 `5 D3 A4 Q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& j8 h( I; m! ?& u0 i#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), p4 e9 u: y z. M' @! a0 B) N" }
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 l* S/ z8 L. r1 |2 n' V
& t( P+ H4 M& c8 J# i+ r
/* assign the tl som board LED-GPIOs*/& J# [' `- X/ F6 g2 L, M+ V$ V
static const short da850_evm_tl_user_led_pins[] = {0 y! H2 n) p% a D; H$ e J. H
/* These pins are definition at <mach/mux.h> file */- c5 t3 K- u' Q$ @( }+ D- i4 a1 M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 j4 r) f! g' l3 M9 K- u
-1: ~4 ?! A: y L" k6 l" C4 v' `7 ~
};- h) \& C0 T. ?8 z& n3 s/ Y! i! z; R
% r- \5 o% Y; r/ A) X
static struct gpio_led da850_evm_tl_leds[] = {) l: M5 A2 l; J) G* D8 H2 X
{
8 z" ^4 h$ \$ [$ k0 X! [; z6 ~+ i .active_low = 0,
' z5 C w. f3 x7 `3 F .gpio = DA850_USER_LED0,( _9 v4 y1 A" g0 S
.name = "user_led0",+ t3 \1 h2 k7 y1 V. w4 _1 d
.default_trigger = "default-on",1 v1 J0 U- k' O( q, h$ k7 Y/ J/ T
},
% G( v. \4 N: S8 a# |; | {8 E, x6 o: e9 a5 E W* W
.active_low = 0,+ w+ ?2 d% |; E7 F& y/ T% y
.gpio = DA850_USER_LED1,; @! L. a% z. L
.name = "user_led1",6 x( _7 O3 h: f; [- \$ H6 l! V
.default_trigger = "default-on",
8 I/ b7 I- A1 U9 Q# B [ v% b/ e },
: o( l- j: U* [6 h7 F {+ R, ^; K) c# C f, k. c) C5 F. d2 E
.active_low = 0," R4 i7 G9 p M& M, F& q
.gpio = DA850_USER_LED2,- P+ @$ [8 r' `2 ?* v8 B& d
.name = "user_led2",
8 ]7 F9 F2 j: T .default_trigger = "default-on",# H; U; Q. m& {
},
# @$ o" U' Z" N8 R9 x5 O3 z {$ f4 `; b7 H2 }- p3 X
.active_low = 0,
4 m; H0 D# e" c) f" A$ [ .gpio = DA850_USER_LED3,
. N! k! k y# A* J) |) g .name = "user_led3",
. ~& e! P$ N* Y- S: | .default_trigger = "default-on",
. Y6 S" R0 s4 b: Y6 n$ g },
7 W9 c- I/ `" L) g3 H};2 _: M- P4 q) S2 g6 n6 }; M
7 K2 z2 i* d" s: W6 estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {# N' ], `+ Q( k/ h5 o" B
.leds = da850_evm_tl_leds,
: n. U' s2 a- [. I$ E( l) f .num_leds = ARRAY_SIZE(da850_evm_tl_leds), x6 E; Z0 |, V9 c/ H" t0 S. r
};
& l3 V$ U3 K7 v& L- n% h5 d3 ?
! W) ?# f* U2 u8 X. T& h$ O; nstatic void led_dev_release(struct device *dev)0 ]8 ~$ S6 _" X0 G- p
{
' j& o: H, P; ]' p/ N: l: r' K: T};" B- T) M. s4 F
+ w0 n% {# w6 k& A4 ^# ^6 z: {1 Xstatic struct platform_device da850_evm_tl_leds_device = {
0 Z( w" u z5 z5 m2 t .name = "leds-gpio",$ Z$ I: _8 y) c7 z! K
.id = 1,
5 `9 S7 n$ c: h. b5 C# [+ B- i .dev = {% y) I9 y [+ ^" |5 g
.platform_data = &da850_evm_tl_leds_pdata,! l' C# ]2 t7 U& ]6 o
.release = led_dev_release, w6 N) u" \: O' N5 L+ H1 U j
}7 H) D4 Z; [+ F" m) ^& q
};( a# f- V7 G! J7 B
h4 G# Z. s5 h+ H0 Y
static int __init led_platform_init(void)
# ~- A7 G1 x3 W" }{
, t! P. s4 e4 S4 p* o int ret;
. j4 J6 f' N c( s#if 0 \& v. p) C& j
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 F6 F% T& H, ^, d* i
if (ret)
$ k; n/ u# X9 l7 x+ \! X pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
r, D& N) K3 A* v* Q% c "%d\n", ret);; t5 a) `8 r( X, T- e% P% N, U
#endif& }- [9 a; I% ^
ret = platform_device_register(&da850_evm_tl_leds_device);
) R) D9 a# q4 r: _' l+ D3 u if (ret): R5 n; X7 Q: t _" F
pr_warning("Could not register som GPIO expander LEDS");
0 O3 r% k) J0 K' h- c4 \% _ else- y' S$ L5 R9 S; t7 U
printk(KERN_INFO "LED register sucessful!\n");" S3 [; x' ~8 ?: a
% p- |, Z/ R6 f+ M) g
return ret;
6 X! E. e3 l) V}
: m' p" \# H& d5 \% C
# A U' M' B) C' l Y, ?1 q1 H# Ystatic void __exit led_platform_exit(void)3 M& b7 B2 E/ U; N) R M
{ y' r* N: u! q w; g
platform_device_unregister(&da850_evm_tl_leds_device);1 |, ]( D+ z3 P
; [& F B0 \! ?" A- h2 ^* X2 Z6 j
printk(KERN_INFO "LED unregister!\n");5 g4 _ r- b* Y' n# s
}! \, i$ M8 N2 G" Z
; d1 T6 ?; t# C! N8 O( _2 h) V/ e
module_init(led_platform_init);* Z& p, Q- d1 f$ U' s# }+ f9 Y9 k! n
module_exit(led_platform_exit);
! ?& Z* C2 T% Y4 x, i' ~, k* H7 ]* i! |, n/ _
MODULE_DESCRIPTION("Led platform driver");
& b- r' l6 T' u8 GMODULE_AUTHOR("Tronlong");
X3 g. v9 X4 \, Q( O! wMODULE_LICENSE("GPL");
8 c* p9 f6 s1 }: D
" ]& h6 n* y/ ~0 T8 _4 p |
|