|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 x/ K' D, Y6 Q0 N( w
#include <linux/init.h>4 [! w3 h1 D; Y+ v' _
#include <linux/module.h>% P9 o8 v2 d3 \3 N% w% A
#include <linux/kernel.h>
' K7 J+ X- p+ K7 A#include <linux/types.h>! H5 b' M; i @& t# r. ~
#include <linux/gpio.h>3 U" ^/ i; H, M1 H" {. F) V
#include <linux/leds.h>0 b. s; u9 U3 x) E, R
#include <linux/platform_device.h>
# h* q+ M# [" F4 B1 f& c$ R' |# Z& ?# b
#include <asm/mach-types.h>
% |& l' O `8 W2 S; j#include <asm/mach/arch.h>
! c* j8 h) J" s" D; _ P#include <mach/da8xx.h>! ]4 l3 d- U9 N, ?" Y5 r3 b* b
#include <mach/mux.h>
) m1 _! Q5 \) O z1 z* x$ ]7 Y9 s' @# h8 W3 J
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 r- P- Y1 X! J7 x+ x9 t$ z#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 H9 K: Y/ A6 S+ e
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 B8 k. `4 e. V3 I
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 Q" D" r0 ^: Y8 `$ ]' s( t3 F5 n" r8 a X! C1 n$ W. Q, ~* H
/* assign the tl som board LED-GPIOs*// U3 ^. K& |: n3 V6 \; m7 Q6 m' j" b6 V
static const short da850_evm_tl_user_led_pins[] = {, y0 T* T/ s2 W2 Z+ Q4 _
/* These pins are definition at <mach/mux.h> file */) Y3 `5 A2 u6 v D( v3 ]1 C
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,: `* M: @* [' b% [. C' u( I* @
-1
+ e' d, a f) \+ X4 o};
1 `, I' i& z" m, E3 w( A
$ g1 l4 G; I# u1 A. x$ v Ystatic struct gpio_led da850_evm_tl_leds[] = {! k% z' O& C( Q$ d5 j
{
, F" Y+ C( @. M, L .active_low = 0,6 _- Z" i) b$ N* S& O
.gpio = DA850_USER_LED0,& J# V0 h, \; q* W
.name = "user_led0",
: `, i2 f2 g/ r .default_trigger = "default-on",- U7 t) I) a9 D9 T: k- A
},! b( j+ i- ~. L, N5 q8 Q9 p0 u! Z
{
. N- a6 E/ K1 I$ L. t' u .active_low = 0,) T7 `( y* n9 b/ c- R' l. n+ B
.gpio = DA850_USER_LED1,3 K/ R7 ^' r: O \8 n: k* S" N; g; ?/ ~
.name = "user_led1",6 D- e4 w2 P% I0 y% Y
.default_trigger = "default-on",
$ d# }; b; I& G4 ]! G- c4 b },
, ~# r/ v$ \# v0 j* H7 h {
U, X7 {' M* v% S( ? .active_low = 0,% A8 f0 R' e0 N- [' Z) U3 Z0 q' D {. O
.gpio = DA850_USER_LED2,- o9 J7 s% L, O8 A3 N, e2 f8 ^6 Y
.name = "user_led2",+ P1 |7 M3 c8 K, J$ V$ z# G
.default_trigger = "default-on",, P, H* ~: q, j* _/ p
},
4 n" A; f* s5 P {
X$ a1 L1 |5 [, f' g, n4 @+ K2 s .active_low = 0,( F+ P% e! |! I' k6 H& d
.gpio = DA850_USER_LED3,1 {8 a9 C& P& `# G
.name = "user_led3",
" J* c2 @) f# x S: c .default_trigger = "default-on",
2 {) z6 c6 G! \* S, e8 ]( e },* ?4 J% M: I! ^2 H3 F
};
T4 ~8 F* `2 g; o4 T4 A4 g- v
! P2 c! K6 n8 q% v' \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
+ L0 N* g3 _6 b6 l' b+ {! c .leds = da850_evm_tl_leds,* u5 I' r# b) {( ~0 X' K j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
, y# r* y- K8 L8 ~! j( e};
8 I. h% T5 i. [% _# P* N" w1 m1 w7 `1 | Q
static void led_dev_release(struct device *dev)
+ m9 j; f4 W4 U" J) Q{5 n" L& x0 B2 q" }6 x/ [/ _$ u
};8 f' d2 a) ~4 H& P9 {
6 O+ f; O" ^5 ?& J ~
static struct platform_device da850_evm_tl_leds_device = {8 h5 ]; {4 x* r. o3 o3 T* V% t+ z1 G
.name = "leds-gpio",) q# k: Y* p5 w$ U
.id = 1,
$ Q/ Z! T* I# L6 B7 k. z+ k .dev = {
- ] _: {4 n! G .platform_data = &da850_evm_tl_leds_pdata,
. Q- @" |( L$ w' H5 S& r .release = led_dev_release,3 b5 {8 y& u i% ~+ ~
}
: b& a# l+ L1 L+ o" Y6 r/ {% s};
8 x Q z6 t6 h; P1 J4 t( E7 c( Y* `- F* _+ d; l7 \- Z: ]
static int __init led_platform_init(void)
8 Y& Q4 _4 d1 m- }0 u# z{2 i9 N% D; \& h, o* \ f! K
int ret;
$ _" L" i) z) U/ }9 h( Q+ R#if 0
8 i- t2 R. r( i' L$ O& m! v6 s% l ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ z, @" P8 H: a, P; p8 u9 ?7 g if (ret)+ X) P3 G6 O6 Z# i, b- n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ D& J% m' f; y( g "%d\n", ret);; j- ^! v, Y( `) N3 b0 r; W
#endif
! F, k$ T; Q/ m- n0 q. a# _ ret = platform_device_register(&da850_evm_tl_leds_device);. X) R* L1 c2 P
if (ret)3 k% ? ^5 u- {5 F6 ], _
pr_warning("Could not register som GPIO expander LEDS");
# ]- I& b0 \' c# U else' O# Z+ ^+ k/ o) _ {; M
printk(KERN_INFO "LED register sucessful!\n");
7 ]: ?% C1 U3 x9 M$ P) F6 `2 D' g+ x
return ret;" D4 w% M8 w) U
}
; Q0 R( z3 W5 F' h& M8 z- ?& s
' n9 A) f. p* Xstatic void __exit led_platform_exit(void)
0 E( Q1 u( p# u! q* f* t{/ A" K% V/ y' x
platform_device_unregister(&da850_evm_tl_leds_device);
7 i0 v5 i4 O+ Q/ j% l
5 d- k; a, s; ~& | printk(KERN_INFO "LED unregister!\n");; t4 X' b# R2 K7 [4 |- ?( d+ i% s
}& w6 A% N9 }9 L5 g4 i
8 j9 Z8 o- y6 X+ ]module_init(led_platform_init);" {; q1 s2 L3 C. O6 i% x. d9 j
module_exit(led_platform_exit);
W* f* f3 A' B9 M6 d' B8 U) x) l( n' C7 m R5 c' T1 R
MODULE_DESCRIPTION("Led platform driver");3 Y3 ~' G5 Y3 y3 e
MODULE_AUTHOR("Tronlong");
& R; l) m. }: ^5 [. B" A9 IMODULE_LICENSE("GPL");
4 i) Y* u( k' D+ S( Q$ C" r7 ^3 c2 g% X0 e
|
|