|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ n7 \9 U, d/ ]1 F
#include <linux/init.h>
8 {1 E4 \ ^+ |0 s5 s#include <linux/module.h>
7 Z9 j, V- l' c; x9 V: X, e9 Z: c#include <linux/kernel.h>
3 S _' _/ F7 J#include <linux/types.h>
s! l* ^: p+ D7 U0 F: Q#include <linux/gpio.h>" [- j! ?2 ?+ i q7 s
#include <linux/leds.h>
3 }8 U6 l4 U# L8 q) v, ^1 n#include <linux/platform_device.h>
3 H# u) ]6 b, ]7 v7 O) O2 r% F- A
4 J1 ` }9 T7 N+ s( d$ j#include <asm/mach-types.h>6 {7 `; l+ L) {' @. ?" J/ V. Y
#include <asm/mach/arch.h>
( G) S8 S$ A$ C9 A) ~9 D#include <mach/da8xx.h>
. N6 a3 [' A' v; l#include <mach/mux.h>0 b4 |* G9 E( Z. D) W) p( U, x
G. I% F' |" x' X
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 l0 f; }+ k) P! J8 @5 w
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) F0 {1 [9 h- b. R2 e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 A& ]0 E+ O3 N) J
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)8 e% @+ ]# L! [ n9 y
: `8 P. }; n# q& R& k0 P/ o/* assign the tl som board LED-GPIOs*/
4 U' `) J- O, F7 Kstatic const short da850_evm_tl_user_led_pins[] = {$ Q: R$ v( [0 P- Z
/* These pins are definition at <mach/mux.h> file */" S* r" g2 K3 o8 r( \* C6 k" ~
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( O4 F" E. i( h9 v
-1; a: i1 Q5 b; W# z8 [
};: S8 c0 D W b
# Q+ P5 \9 W" w7 S. N' ]static struct gpio_led da850_evm_tl_leds[] = {- ]+ s4 W; A) H! j8 e5 X
{* {' \6 P1 R3 q1 \2 A3 T
.active_low = 0,+ v) Q8 {( _% z
.gpio = DA850_USER_LED0,
H. O. Q7 k, u .name = "user_led0",
8 w+ n ]7 X* X& i* m0 u .default_trigger = "default-on",! y; e6 P+ s, {0 F
},
6 g c8 @/ l# ` {
* h2 d; X8 C' c7 j; Y* N .active_low = 0,
4 Y. j) g4 Y: v; ? .gpio = DA850_USER_LED1,
$ z4 |4 w6 R. f6 r- w, l8 S .name = "user_led1",
4 K* C2 S/ j% b% H8 S @( D .default_trigger = "default-on",
; N# w4 `+ i+ M! X, F$ E },
0 s: s3 f: @4 X6 b; y. A {* e9 {6 L4 R' I! b' q, I
.active_low = 0,
, O+ n/ e: y/ b. P .gpio = DA850_USER_LED2,
9 E& L8 T! k1 A .name = "user_led2",: b8 W" N- E0 O$ @( u& X" K" p- ~
.default_trigger = "default-on",# e! m4 f& n$ c
},
( B" e m8 x7 I {$ o! K. A, l; z2 |: j
.active_low = 0,. i; q0 R7 k: O: J7 \
.gpio = DA850_USER_LED3,
Z- q: x8 }/ `9 ?9 {3 a' ~ .name = "user_led3",/ a; F' W1 v$ ~, x3 [3 e
.default_trigger = "default-on",6 G$ i0 p$ B& U+ _9 g, t7 j
},
. Z' v0 }, A3 B: x w( z4 S$ {: X};* i- p. D; U& S4 Z1 i- M
. a- ?/ ]* Q2 [' B9 \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. s; m3 c- W2 `! _6 [- o0 b- y" Z0 ] .leds = da850_evm_tl_leds,
* h, @4 L+ `. A0 N3 ? {( a .num_leds = ARRAY_SIZE(da850_evm_tl_leds),( N# v0 E. a% G7 Q3 E
};
4 P9 Q8 U5 f: c) p: t) f' W# W. ]8 g2 y6 ~, F
static void led_dev_release(struct device *dev)
3 W" c2 L; y U- ~{
$ `. p+ A# | T};; d! _5 T% V) n9 |: R* \ K
' x6 T. O8 R5 B. E6 g
static struct platform_device da850_evm_tl_leds_device = {
; ]5 t3 B' X7 R: q9 K' W, ]2 J .name = "leds-gpio",
, K4 ~3 H0 X0 J: b .id = 1,6 g" h& l( v% n5 s- O; l
.dev = {' M1 C- x3 y& y
.platform_data = &da850_evm_tl_leds_pdata,
?: w9 G+ t- w( p% K8 y, G .release = led_dev_release,
3 u# A0 c) {& y, c% c6 Z) u }9 h! g }2 H p7 p
};
1 }: c: b7 F( x2 l+ {$ Q( G
: u* q q4 k$ Y9 i# I3 p$ `static int __init led_platform_init(void)! j; F; d7 U' X( v& r9 T s
{
7 O% t8 M. a) B int ret;
8 G* e9 x" f/ a' u3 l0 n" A' Y#if 0: ~/ ]) P! j, U' w% ?' e) \
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 k7 P5 o- f7 Q" ?( |
if (ret)7 n2 t& t: G2 Y ~" I: u
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ b) ]4 N1 T& `5 z9 o" d
"%d\n", ret);- u/ g! h* l" A* B _
#endif; `* |- H: k! D p5 L) V
ret = platform_device_register(&da850_evm_tl_leds_device);$ D3 y% c% d i, R- Q
if (ret)5 z! q6 g, A9 y T: |: i! h: h: q
pr_warning("Could not register som GPIO expander LEDS");
* h& G& U0 K! \" v% w$ { else
9 N8 l. x" [) H/ ^2 D; Y printk(KERN_INFO "LED register sucessful!\n");! u* ~5 K' |1 Y5 T
, o8 k/ s5 ]" K0 v( G" C
return ret;
' P# {! n* d& g4 H1 {} V9 Y* O' b' ?8 V! g$ [* G& E+ X
8 l8 b8 u t N
static void __exit led_platform_exit(void)
! e" R' d( l% h1 i{6 t4 X3 N& p5 [3 K3 ~
platform_device_unregister(&da850_evm_tl_leds_device);
; j, W; a% V$ `! ]. ~
6 l8 J# i6 R( }& q printk(KERN_INFO "LED unregister!\n");
) y! `# p6 ~$ ^; m+ x}
4 Y3 L3 T( \1 B" i( e- q; Q0 R6 w6 S# W8 M- u
module_init(led_platform_init);: m: V0 f% K. u+ T! k# P8 I
module_exit(led_platform_exit);) c! o9 @+ n7 z6 i' v/ i s' H
: s3 S% Y2 r( I2 ~$ C6 f& yMODULE_DESCRIPTION("Led platform driver");
* _6 K, d" E7 s' b- i! O/ h; g( e( cMODULE_AUTHOR("Tronlong");
* l. }3 g( F. Q7 f7 x7 s2 ^MODULE_LICENSE("GPL");5 p$ k) Z9 R J( Y% O* t
9 O0 o \' u# R" R6 l
|
|