|
|
求大神给下面的程序做注解,请稍详细些,谢谢。) d) S6 W3 Z/ [, ^4 d2 R" i
#include <linux/init.h>
8 c6 i& F4 C8 b) n; i#include <linux/module.h>2 a% ?% j; P% Z
#include <linux/kernel.h>
- H( w; q2 A$ u& L- M4 K# c! [#include <linux/types.h>
8 [8 ~' [& R$ u#include <linux/gpio.h>
' k; T. j2 B. Q9 e4 ^* v. Q#include <linux/leds.h>
0 b* M" e2 d* \: u, t; N" N3 i#include <linux/platform_device.h>
: H( U: @: k6 r K8 e) ~ j5 K$ ]: Z# C# a
#include <asm/mach-types.h># Y, j4 f) K! v
#include <asm/mach/arch.h>- {& A; s& N+ L. P( X6 N2 b
#include <mach/da8xx.h>
; K% A9 P0 d, J( W# }9 n#include <mach/mux.h>5 r( i5 I+ F5 t' W* B' b I
: e) a6 s* `' m* s" ^' b
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 h' J6 T. R' g! ?
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( x) [7 Q/ l: @! e8 k: Z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 F7 M' K0 b/ r6 N( H5 p5 [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 x K; X9 L; w {* K) \1 b0 J
/* assign the tl som board LED-GPIOs*/
2 O2 z, ]9 i" ^static const short da850_evm_tl_user_led_pins[] = {2 L- V6 W. Q; z L
/* These pins are definition at <mach/mux.h> file */# o5 h! \9 n1 A+ j* a
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 B/ ? e) c% l" D -1+ @. k7 e) l7 f5 w
};
1 C% ]( Q/ p0 u. N2 K( R8 E/ l3 c g9 _. F2 {( y
static struct gpio_led da850_evm_tl_leds[] = { H: t- p9 c9 n7 {
{7 n/ Y$ [/ E, q N) ?
.active_low = 0,
. C* y; S. G4 m .gpio = DA850_USER_LED0,
, U/ n2 [$ y8 M l! p .name = "user_led0",
( h: c# T9 ^* Y0 ^. B .default_trigger = "default-on",
: ~6 g; X3 Z# [8 k- ]$ h- O4 u },5 O/ V! ^0 F+ a( ^, \ |
{
2 O' Z# @# i2 h2 H .active_low = 0,9 z- y# O0 O. K+ O
.gpio = DA850_USER_LED1,1 {7 |- V7 A" \ h; O; n+ l w$ _* I
.name = "user_led1",* [' b9 o9 Z7 E& {; _' n
.default_trigger = "default-on",
9 }9 J% _9 e) l6 p3 X1 X! ` },1 B$ g7 k* \9 H
{
c1 k l* ?7 h( `* `* c .active_low = 0, \0 ^8 D- t7 ]: X5 z# f2 s
.gpio = DA850_USER_LED2,% ~+ D1 S- P/ g& |) @6 q
.name = "user_led2",4 v6 S2 B, T3 K9 O; ~: T
.default_trigger = "default-on",
$ B. _: w; N b/ l- e/ s* B: Z },
* r5 _; g; M4 c; ~2 z5 W! @7 c {5 v$ @4 E& N" l W
.active_low = 0,
9 i& j+ @) r1 i6 `+ P) e .gpio = DA850_USER_LED3, h/ U2 H& K# U2 _0 l6 Q1 P" F
.name = "user_led3",9 y' F6 J& X6 R' E
.default_trigger = "default-on",9 v8 }( y& c- n+ O) i; T0 n
},' r1 B* h' u" ^9 v+ _/ ~1 t
};
+ F, i" M( _8 I# G% {% e4 [! o8 p" r3 C" Z7 ^# z! D6 v
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* b7 [9 r4 s# g. `+ y
.leds = da850_evm_tl_leds,5 W; H N/ X' t6 F4 C2 q8 R4 a7 [4 {
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 Z) @# M6 B# Z
};5 k( f4 [, v- X9 |! \) R
( s2 f) t! g" K9 o2 Lstatic void led_dev_release(struct device *dev)" Y; E; x9 D& D
{8 F" o" i2 J( R. ?, F7 F$ R
};
9 H& `0 d3 D y- D* V7 y# S7 `8 u4 W. b
static struct platform_device da850_evm_tl_leds_device = {# h! d" U5 u" S( z' B
.name = "leds-gpio",4 K3 ?, _8 h& Y% m- V/ t9 l
.id = 1,3 T; x- R! U y. p* Y
.dev = {5 x* Q. j! @! Z' B) s5 z4 L
.platform_data = &da850_evm_tl_leds_pdata,+ \4 G( f4 {9 }. W9 r. u$ Y/ _
.release = led_dev_release,3 r/ B2 E* j2 S' l. q6 \' P
}" t% g) l) D7 i( t. J: ^
};
* q1 o: e2 L4 c7 M7 v
& x' J# s% V! e# O1 wstatic int __init led_platform_init(void) O/ ^( I5 [1 }
{
( F/ N8 C' J' Q! b% N/ {2 H int ret;2 k0 F8 b" ~* ^+ Z
#if 07 W \1 j3 |) s0 d* d1 f$ Z# l
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
~0 g! g& Z- G: g7 L+ C if (ret)
( j, B E0 K/ ] p3 a2 [! N% D. } pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
: m* k! Z6 @+ \$ w "%d\n", ret);! J/ C: }0 t; T Q9 D9 R9 s
#endif4 y4 `. V9 ~+ E
ret = platform_device_register(&da850_evm_tl_leds_device);
" W$ q7 w' j; n' m$ X, } if (ret)
- C: A1 ?+ V; Z n) v pr_warning("Could not register som GPIO expander LEDS");
. v: S, e. k' s5 L5 l K2 d. v else
8 S O$ T5 {% w0 @ printk(KERN_INFO "LED register sucessful!\n");
G) K+ t9 T) w; u' Q9 [: _2 h5 p4 t3 E- \$ f& {5 I8 _ R
return ret;
7 e$ q0 G* S _6 t" I+ U! u}6 x5 e. U* O/ n9 L
6 |: H0 A3 d0 I) W
static void __exit led_platform_exit(void)
/ [! p# J( k+ T{1 I+ S; J1 x2 N9 D0 |
platform_device_unregister(&da850_evm_tl_leds_device);" V5 ]# i( Y/ l9 d& P; C' M: D) \
4 w( l0 f. Y3 @4 X0 V& [; @4 G printk(KERN_INFO "LED unregister!\n");7 {& ^2 t' [, x+ `2 N- U
}
4 j, X- j6 F; i# m. S
6 W- G; {0 ~( w V omodule_init(led_platform_init);/ W1 ?1 t3 B1 R# G% H \* S
module_exit(led_platform_exit);9 m; t- O: j/ O- b2 R
1 ]! U& S% i" b; t& p& E
MODULE_DESCRIPTION("Led platform driver");
$ G8 X" `# w" y/ |( A9 d# VMODULE_AUTHOR("Tronlong");
/ v- M0 \. [' {, s- K1 Z6 c2 AMODULE_LICENSE("GPL");
* k9 x3 W9 t, V3 }8 Y2 J. F0 E8 T& C% P' o6 e
|
|