|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 q4 t& ?; _/ C& m) C; q. R* h
#include <linux/init.h>6 u0 ?( D( o. j6 n% s4 r
#include <linux/module.h>
8 C/ Y0 y) _* p0 p+ [#include <linux/kernel.h>2 y) S9 w$ e8 S# t" d/ s" M
#include <linux/types.h>9 R* V# n; o% g. h+ c/ a# h
#include <linux/gpio.h>
6 X1 _3 \5 Q! i( V5 i {9 F#include <linux/leds.h>
0 _$ f+ Q2 g) c# v#include <linux/platform_device.h>
( O: B0 C& R# Y- |2 c# d G3 ^3 t* b- r/ d F
#include <asm/mach-types.h>1 D9 {6 r) ^* u/ Q4 ^% \* X! |& I+ d
#include <asm/mach/arch.h>5 M! w) U$ h4 x. z8 W$ J! v
#include <mach/da8xx.h>
/ x' C& N& w* a+ L#include <mach/mux.h>
. g( n; k: ^" |! M
. u( J5 N7 u) f/ S3 K* r5 |+ a1 |#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& c6 e: e/ N9 m% y( b4 I/ |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
V3 m6 J8 K3 h3 K# `& W7 b2 U#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ `' X! N) I {5 G#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& `9 `; {; c2 Q' p% O0 K) | w* R3 h# {, ~" O' A, R# u B
/* assign the tl som board LED-GPIOs*/' ]0 k2 }1 L! ? g
static const short da850_evm_tl_user_led_pins[] = {
" a; d' t% d& I" | /* These pins are definition at <mach/mux.h> file */
8 M; R# W& s5 A- s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 P) ]: z. X! }
-1, ~; [6 S3 x( I1 b
};
- c( E8 _6 }) O# z2 m) v
" n2 \8 P- H6 d9 I, xstatic struct gpio_led da850_evm_tl_leds[] = {3 A: @" U4 R) k" X' s0 _9 ^
{* \4 j: s8 ]. D8 R) t
.active_low = 0, Y" O& k3 j/ l3 w: o( B9 l
.gpio = DA850_USER_LED0,
5 P! d6 n6 q7 v: b .name = "user_led0",
5 \+ f" z% A+ h6 S1 S .default_trigger = "default-on",3 q3 O' p0 t F* B% i m+ R
},0 Y& N& w# }" v8 `1 y
{7 F. x/ x1 _5 W' j& v
.active_low = 0,, Y7 ]; [( X' s! u ^
.gpio = DA850_USER_LED1,2 E0 W& \9 p/ d: I# W6 z3 |
.name = "user_led1",* ?6 e; i2 M/ y1 e T6 q( o0 H" A6 u
.default_trigger = "default-on",
/ ]9 d8 n/ _# z: P( i/ d; P },( J2 J7 g# X$ Z. v: M* {
{
. V7 z4 f3 p3 w7 c .active_low = 0,
' w2 m {' N) t9 F p& ~- k .gpio = DA850_USER_LED2,% c" p- L. r/ h& i/ ]2 ^% @
.name = "user_led2",
! K* j7 G: h+ }$ z9 @4 H .default_trigger = "default-on",. o' r: F1 k8 a! R# v0 F1 V; r/ S
},- K+ j3 I' E+ l, }8 O1 t' x
{
* a( G6 }& a) P+ K6 m .active_low = 0,
3 U) n4 W. d4 k$ t' L. u .gpio = DA850_USER_LED3,
2 }5 {1 ]4 U' ^* Z .name = "user_led3",4 H& t6 ~, i/ `3 x2 g3 b! b
.default_trigger = "default-on",6 s& {% ^( M _0 l& f% o
},6 ^+ n1 z( R D! L
};
: ]' B1 e- I# L; ?! g& r# c& \5 ^! b2 Z( i: F, S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" z8 G3 T W1 t1 R4 J0 K( a .leds = da850_evm_tl_leds,
% a, G: M. f% u .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ v, u( t; c6 t' Z- `# b
}; G4 K2 d' s* { ]2 X& {
4 Q+ c2 A, p; F
static void led_dev_release(struct device *dev)0 i _' ]$ d1 _% s: _2 W8 l, w
{
! N4 J3 R \0 d3 o) [};
0 k7 R- b5 j3 v$ p* ~# \* A2 G: L! L# B8 u. N m0 B
static struct platform_device da850_evm_tl_leds_device = {
m( d5 ~/ j0 ~/ k .name = "leds-gpio",# |0 O2 l7 z* V( _
.id = 1,
1 g/ q4 Z- N. \1 |( h .dev = {
4 ~9 |. v! }7 c! S! l# f c .platform_data = &da850_evm_tl_leds_pdata,7 ~" m0 D4 R4 p1 X
.release = led_dev_release,
0 k3 j. c2 Y; [6 G( @9 ^2 [ }$ b% @% a* H( H9 A6 H
};
9 W j2 _9 p i% [* v
4 e; V) V0 W8 Y2 r) {, A5 b5 fstatic int __init led_platform_init(void)
; _: d& @+ }- \! Z' Z- p0 ?{/ g$ E& C! c( H9 E& O
int ret;& U4 O8 b/ [3 i" C) E
#if 0
6 Y' k2 ^& f Z. L3 E O( L, _' Q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 u' m3 r" {+ z! f$ {4 @ T7 Q if (ret)6 E+ O9 t7 u+ K9 M1 _* T
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( k8 U" m7 j0 ]. e9 R5 j& J
"%d\n", ret);
. p r. C3 k" C: }#endif2 ]; m, `; c2 |% v
ret = platform_device_register(&da850_evm_tl_leds_device);
3 N' N; m9 c; r, v B8 w if (ret)$ p+ l M" M: p
pr_warning("Could not register som GPIO expander LEDS");% g, O; |5 S8 Z+ M
else
& o1 Y$ o0 a% w) t printk(KERN_INFO "LED register sucessful!\n");- J* _+ C3 o& U
9 ~8 ^* m S j; ?6 ]
return ret;1 j& L" \% h3 m7 A* D3 u
}+ y) c: Q- h& P& M/ _. F( p; t
9 T# @7 |6 _& d8 W
static void __exit led_platform_exit(void)4 O, v! K! d* F# E4 T5 E) {' p
{
$ I. Q& D0 O7 @7 v3 {* { platform_device_unregister(&da850_evm_tl_leds_device);7 v4 c& }& w4 s" }$ Q
. l. J& @4 W4 C& U) Y
printk(KERN_INFO "LED unregister!\n");9 s* V1 H! Y9 b, ~
}
- k" ?' a; W2 O8 i5 R# j
6 B6 U/ M1 |8 S+ qmodule_init(led_platform_init);
% `4 u( _! q1 _0 b! [! ?module_exit(led_platform_exit);
4 d& P0 f& m: [9 ^. K* z& Q; K. n$ \/ ]# R3 f
MODULE_DESCRIPTION("Led platform driver");
' \% K5 D% L* ?MODULE_AUTHOR("Tronlong");
% [3 t* ?, Y$ |% f( tMODULE_LICENSE("GPL");
6 d- D9 g# ~/ A/ K5 v# F
; U+ ?+ X# l. l! l4 b |
|