|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# x( h1 w. U G+ ~. ]8 c
#include <linux/init.h>
; |6 ]+ y& L% q/ I#include <linux/module.h>5 B3 E' B* S: C. H7 U) b) Z- I
#include <linux/kernel.h>+ M8 {/ T4 E' Q& B) e
#include <linux/types.h>
9 n8 l" J" q a#include <linux/gpio.h>9 a" `" R5 Y% q7 g3 Q
#include <linux/leds.h>
, Q5 X7 X ]" v( n( T#include <linux/platform_device.h>1 }6 L F5 Q* s$ h+ \; {3 b
1 N* \- B; y% f
#include <asm/mach-types.h>
% f. q8 N$ J" r( Z) Q#include <asm/mach/arch.h>6 A% @% K3 }" T2 C! U- j8 P1 K) N
#include <mach/da8xx.h>
) g9 v. |$ i U) g3 Z! { ~& Q#include <mach/mux.h>0 L& W4 }; V3 f4 {
+ w0 Y) j q. N9 `$ Y+ z' |
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& X G# z# Z* l8 R#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 C1 j* I9 K7 s. ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% S- n+ M4 A" n9 t) ?8 M$ i6 b7 w
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 ~2 F6 ^9 @% `' `
& X. k' [6 f4 o* i% W: X( c/* assign the tl som board LED-GPIOs*/
' B& X' l* }( c9 i' ustatic const short da850_evm_tl_user_led_pins[] = {
9 E4 M% q, {1 d7 Z; z( l" h. E /* These pins are definition at <mach/mux.h> file */& u4 E, m! a7 m8 | }8 A
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& D' x* m) |8 Q, K% y1 _) n
-1
2 T E5 `( t* h9 Q" N' v};
' i+ J& z/ E6 l2 H1 f$ _. K; f% }. ^; r7 F. \4 Y' w) @
static struct gpio_led da850_evm_tl_leds[] = {
) z3 w( ~; m% o1 C+ l0 B {% J) y7 W9 g# M9 U! Z2 B% `
.active_low = 0,# l( ]/ p' ^6 ^. }/ _
.gpio = DA850_USER_LED0,
/ I. f) ^) ~3 R6 B .name = "user_led0",' h6 w1 Y. {: D ~' {# |
.default_trigger = "default-on",* I! c( H3 }. v9 \/ u
},3 R6 x7 I3 M. G0 _; O4 J
{* @7 b Z( l) V# Y7 o0 [
.active_low = 0,
5 G7 F: f% N5 t( o9 C. ]( o+ Z .gpio = DA850_USER_LED1,
1 {& H/ p8 U3 F+ F! u .name = "user_led1",, A. E+ g, V0 l: B- c4 b
.default_trigger = "default-on",8 l4 w: m; [' r) Z d+ Y6 C! w
},
# K* h* |5 X: E/ b: t0 P2 i {% [4 q' m# ^, D4 C% M2 ?2 f: F8 V
.active_low = 0,
/ Q% ]0 |9 u- q7 A' |9 h4 t .gpio = DA850_USER_LED2,4 T" Z) f3 u/ Y% v. a4 h1 n9 A
.name = "user_led2",# G1 S3 p% k l/ B' B6 A
.default_trigger = "default-on",
+ G f* @- h3 p6 s% ? },0 N6 ~5 E& f% h; ~
{
7 w7 R( x& h. H. ^, G1 }* q .active_low = 0,
9 M3 r. b! I5 c( e6 m .gpio = DA850_USER_LED3,
2 ? _7 G, ^" @% {8 e .name = "user_led3",/ |; k; f2 ^% ?" I
.default_trigger = "default-on",+ `) ~, b) Y! _9 T$ e! I
},- ]$ m2 h* y# n% C0 I
};
e, n, a0 [8 A" c- P2 s6 D/ l4 E! j
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! r; c/ `6 e$ r, |
.leds = da850_evm_tl_leds,9 q: B! \$ h* _$ e
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; X3 W9 F3 ]2 X$ V! ?9 b- u
};# Q7 G$ N, ^8 w0 j8 d/ L! T$ A
& l& b1 b, |* B' ~ mstatic void led_dev_release(struct device *dev)
. X! p; b% l. K6 z{
8 f# ~) g/ K4 p" F+ g4 k8 ]};$ Q+ ]* Y" e, b2 T/ q5 B
- u/ L) R% v1 `( L3 I4 r0 l
static struct platform_device da850_evm_tl_leds_device = {" O7 E# B8 _) N8 ^
.name = "leds-gpio",
$ @5 y3 r5 g2 I6 F .id = 1,
: g1 L$ w' |$ v( J .dev = {& ~: n4 G. @$ e9 n( P4 g
.platform_data = &da850_evm_tl_leds_pdata,
( b- _ y" `; Y5 X .release = led_dev_release,- J) s4 L2 |. ]& n
}8 d# j7 @: P: k# P) T
};6 @. R( X3 ~/ A9 J6 i
- Z; R4 Y1 d# x' z1 `( S6 ]3 {
static int __init led_platform_init(void)" P S0 V. S1 p: l2 y/ B
{
, ^& F1 b) y3 } int ret;
" }% \8 h/ Y, [+ m/ q% u4 P#if 0
/ d s* u/ L+ S+ M) W4 h# n* E ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
5 O$ e! w4 ]6 D3 {" K0 | if (ret)
: f) [" V# k0 \ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 }. B1 \+ Q6 K/ Y1 [. F "%d\n", ret); `5 d: ^( E4 Z; T
#endif0 g" a, B% x' T& f
ret = platform_device_register(&da850_evm_tl_leds_device);
+ O2 E- T; C& B& ^3 t2 z0 x1 Q' y if (ret)" |& V# e! R3 S3 h2 J% H
pr_warning("Could not register som GPIO expander LEDS");
/ k) h* J3 m2 }5 |; Z- ] else
( s/ V7 r) C) j& ?! ~1 e3 N, M& L( i printk(KERN_INFO "LED register sucessful!\n");
& g8 I: i7 z% P" U
: x3 L+ V6 S" I0 j! d: x) S return ret;2 o. Z9 E( Z8 P. B
}
& I0 m3 U5 ~6 U0 n; W
n' p3 p! u* ?1 v& W6 A2 A1 [static void __exit led_platform_exit(void)
7 h* n5 R9 H$ \3 D{
8 i; q q" _5 T+ M& ?5 N- z9 {/ E' j; n! K platform_device_unregister(&da850_evm_tl_leds_device);9 T0 Q% c+ }9 J
i( }( s+ h9 d3 @6 c A printk(KERN_INFO "LED unregister!\n");
- J8 v" ~$ O" ]+ m! t}& k' h" _; Y$ Y+ l
( g! B7 C' H. y5 E( ?7 A) y* u: k6 U- I0 E8 E
module_init(led_platform_init);
; \$ I6 [/ @' }, o& h& a* ~module_exit(led_platform_exit);- v# v" d) M* B e5 Y# u
0 L/ a( `: c2 h! t! q( b, o [- }, y
MODULE_DESCRIPTION("Led platform driver");
J4 B2 S9 o* x! f6 S, n" R% l& `MODULE_AUTHOR("Tronlong");
0 f$ }( V7 k2 M4 z' TMODULE_LICENSE("GPL");6 \; x2 {5 C, y6 h0 y: M1 v0 _
: p o) T+ J" J) u D
|
|