|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, i2 {: P- I3 ^6 f
#include <linux/init.h> b' Y, W# S8 a. a, ~
#include <linux/module.h>
. s" t! H2 P+ G. l* o#include <linux/kernel.h>* h* N4 v Y' m. r; t1 U0 ]
#include <linux/types.h>7 ]) f! x- q( w' E z8 r2 C1 I9 J
#include <linux/gpio.h>( e* ^1 l+ j$ B. D* \7 b
#include <linux/leds.h>
x7 O" |3 b' ~#include <linux/platform_device.h>
7 i$ M' ?9 ~5 G2 M+ x% q9 B' \: l; a- y
#include <asm/mach-types.h>
9 X J, X z, s2 V* m/ b9 @#include <asm/mach/arch.h>. P# C' A* W6 K
#include <mach/da8xx.h>
- E/ d- ?5 u* [0 g( B! N% S#include <mach/mux.h>
4 w# Y! B3 g; P/ b1 C
* g+ e" V# Y7 O0 e3 d0 k#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* I: q0 d7 s! t5 r8 c" @/ {9 x/ |: l0 X
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' b& t1 L# }1 [#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): C2 n8 C5 u4 O+ f
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- l/ O) }6 Q. G! F* n+ i) N
, {3 R) H5 I; N! J/* assign the tl som board LED-GPIOs*// |) j c4 C e2 H9 [4 U5 G! D) ?
static const short da850_evm_tl_user_led_pins[] = {1 N. |* j" r& y6 W
/* These pins are definition at <mach/mux.h> file */
) p% R% d4 U3 f6 K DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! o1 n: ]) j3 k: l' g -18 k' L: P- p; o9 R+ [! f) O3 C
};5 f, }) D. M: C
x( c* g6 g% [6 U
static struct gpio_led da850_evm_tl_leds[] = {
* m( M8 W. N7 E, W7 _. S) d {
$ h" o/ ]4 S* U8 d! U* J+ _+ ] .active_low = 0,
8 `& M: q5 e8 Z6 s6 P .gpio = DA850_USER_LED0,# a+ r3 t1 L+ `
.name = "user_led0",
/ \% F& i' L4 b i. J# A y .default_trigger = "default-on",
+ E, O5 q8 c k3 {9 a* E3 f5 H },
% b& b, m' x: U$ D9 i4 o: n4 t {( v6 E. E' B# m0 ^, R
.active_low = 0,5 e) {7 N# D2 E5 ^( B+ _; J
.gpio = DA850_USER_LED1,! b! }. C$ t% Z& B
.name = "user_led1",/ c! A- h# ]6 a2 B+ B3 {6 A6 S
.default_trigger = "default-on",
- u0 t, D& O' ~: t I5 F, f },
+ w' R. n2 D) c/ l% y9 g# c# H {" l/ V" Q3 }( N! t
.active_low = 0,
# S/ H) {0 F i% R" _ .gpio = DA850_USER_LED2,
7 q, f3 U4 L- t/ ^4 ?: Y! M+ { .name = "user_led2",7 R% L# h# Z; e. L7 y
.default_trigger = "default-on",
1 b7 {4 A/ C8 A( L# k2 ?+ t/ T },
/ e5 ^/ W) O2 N# v6 | {. j6 M6 T7 \. X1 d: |
.active_low = 0,! w" ?1 o3 L) i) z- n
.gpio = DA850_USER_LED3,
) X) _4 @) \8 u4 E! \- X .name = "user_led3",
0 p, H" l( Y# _' U$ H .default_trigger = "default-on",
, K8 G0 |4 C0 L- n5 z5 V- W6 D" \ },
; Z9 d& X6 f) P2 T: v0 v};
& G* O! C' M# G) s5 A% P/ Z; z5 Z3 `3 u9 P" H0 ]0 t1 ]
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 _* y% M5 V: T: l5 P- E+ H1 B
.leds = da850_evm_tl_leds,
" q$ J, D! X! T* M .num_leds = ARRAY_SIZE(da850_evm_tl_leds), D, ^; X7 S7 v3 k) v
};
3 E: C. u1 R' v/ x6 E1 S
( @( w( `1 o+ I* fstatic void led_dev_release(struct device *dev)
, t3 P1 k( z E. v0 Y; Z u{& m( G; B- k5 O, X8 B
};( ` k& g! C" w7 E9 m8 g) b9 v% k
g' g6 [* e3 E$ ystatic struct platform_device da850_evm_tl_leds_device = {
r2 D0 Z% {3 o .name = "leds-gpio",
/ o' o& D! N. n" b9 D x9 m .id = 1,
+ m3 v' h' m" ~3 B/ {# l7 [& {, R .dev = {8 H0 Z. z! M1 f# \0 ^% I
.platform_data = &da850_evm_tl_leds_pdata,
1 L6 r v/ T% B* W4 t .release = led_dev_release,
% D* I+ ~$ Q1 ~0 ?" O" b8 s }# g/ ~3 t" |0 e3 _$ b/ A, m3 v
};% w% u. B) D! f. z; u
; Z$ J! y0 L/ ~; |; Y
static int __init led_platform_init(void)* M1 a, o2 ^8 L: t( {2 C- q$ e
{
5 }2 _+ i) g- n& O: B int ret;
: D/ I7 K {2 z4 n& `#if 0
% w6 I- T: Q* X+ M ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 Y7 A: P- _9 c% _/ A7 x j `
if (ret)
N) t4 g8 D9 u0 x pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ t' y+ G$ W+ u3 d! F1 p5 q& T9 W7 s6 ~; D "%d\n", ret);! t& K& t* n5 E, \6 u3 w1 n
#endif
; \; s) s2 b% }# x2 _& {, F ret = platform_device_register(&da850_evm_tl_leds_device);
' Z( e1 S* R. N p( \* K6 q6 k if (ret)
: R) j# w. {/ i$ o" M4 b- E h4 t pr_warning("Could not register som GPIO expander LEDS");
$ F5 L9 J7 {( }4 U9 G) h else5 i" B* |' p5 }9 |
printk(KERN_INFO "LED register sucessful!\n");; E/ [9 x" z3 {$ M
" {: B' u- P* ~; w2 d Z return ret;
1 w& p) {% N' A! H- c; p4 y- }, ?}) g) M- N' U! M! g L
8 G' @* a9 H E1 m4 m0 V: \2 w9 Nstatic void __exit led_platform_exit(void), w% G2 P4 q; z1 d( C
{0 x" \) ^- G) ]
platform_device_unregister(&da850_evm_tl_leds_device);
1 a3 a6 b; G' O% D& N) c4 e2 e v5 } N9 ?3 p+ Z
printk(KERN_INFO "LED unregister!\n");, H- p0 A4 B3 b( m
}1 d4 B4 v& u7 T5 }" g
2 C [, K; i1 j' V: hmodule_init(led_platform_init);
; l; H/ Z. E5 P: b5 s5 X+ `module_exit(led_platform_exit);
% e1 P. ?0 ]0 K* S6 X# h5 E$ Y9 V% {$ h- h" l
MODULE_DESCRIPTION("Led platform driver");1 q$ q6 [8 T& ^. z+ s. Q
MODULE_AUTHOR("Tronlong");) a7 R6 c% I. A
MODULE_LICENSE("GPL");
4 G7 L/ p4 D6 M, n$ F# ]( ?, [( W o' C1 i) i
|
|