|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, W* q4 s; m$ U+ t% h* p8 C2 k0 l# D. C#include <linux/init.h>6 l! b) S6 M/ D. a
#include <linux/module.h>' n3 {" o. d5 R, ?- ~
#include <linux/kernel.h>
) Y; |8 A. |/ {( X6 i5 h#include <linux/types.h>. a* i7 H5 p* r. Z' T) A, b
#include <linux/gpio.h>$ Y$ m# u; V1 r; }' c' c% ^& q- Y
#include <linux/leds.h>' ?) ?0 v1 s* @ k7 I
#include <linux/platform_device.h>
: ?6 B6 X+ a% s/ f( q" o( h& X8 B8 @5 Q# @" B. o
#include <asm/mach-types.h>
) r6 h; _6 u( j; a: E+ Q/ \#include <asm/mach/arch.h>+ s( a, b8 f# T4 g5 d
#include <mach/da8xx.h>
s* e6 n1 M7 q( R! }. d) y#include <mach/mux.h>
y6 u) A# }! e& N5 F* ]/ m4 j0 U9 `2 M9 r; q# G/ }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& Q7 e( L4 V4 A! z0 _8 y6 C
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' w1 @( n- {3 S r4 |; M#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ c& h5 c2 S! O#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 x U# s6 {& R6 s6 [1 K$ b) [ o" E
/* assign the tl som board LED-GPIOs*/
& q# T. c, f+ `' ^4 n% q+ h5 e3 J4 ?( {static const short da850_evm_tl_user_led_pins[] = {
" q4 l8 k- Q9 X& R8 A8 g /* These pins are definition at <mach/mux.h> file */
% e" ]; l p b DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) g4 u0 O6 l; P2 u: r0 c8 k9 V# F -1! ^! V( m7 ^, ~7 s: T$ _) ^
};
; Q4 m" g0 O! \- ?7 `/ w& W3 t0 k5 E0 |+ m0 d- M: h
static struct gpio_led da850_evm_tl_leds[] = {
* U! L1 o* v% q {. q- {7 c+ I% J) ?. j
.active_low = 0,, o) n7 {' P9 n1 k
.gpio = DA850_USER_LED0,. v& k* P+ ~( A5 J, n
.name = "user_led0",
: S0 L- Z' h/ X0 L) N" f G .default_trigger = "default-on",
+ C, ~- o1 G, _0 h/ r },
$ t H' f$ {+ |; b* F {) Q0 m- A! F( _/ Z: @
.active_low = 0,
c" i! s0 ]0 k: [5 O3 @$ { .gpio = DA850_USER_LED1,
( [, J: {$ e% W3 c I0 a; k$ n .name = "user_led1",
% Z" @- y- L; N .default_trigger = "default-on",* \% }% ^4 V4 x0 ~
},
2 O# o& y' U2 n {3 ?0 E* b' y7 k4 m& V
.active_low = 0,, y/ x) ^* P6 ^- `8 ], {
.gpio = DA850_USER_LED2,
" P- k) C) W. ^ .name = "user_led2",$ @$ d& w! `. I$ F8 U: e
.default_trigger = "default-on",& K/ h+ u% ~# N4 T/ Q' B2 R
},) J8 Y% d* Q, w- V" [
{: O' \: n6 \ F- w8 O
.active_low = 0,% D; a2 `$ A3 V% e' p N5 I
.gpio = DA850_USER_LED3,
; y2 S3 F$ ?8 i, I1 `9 y; H" E, o .name = "user_led3",' A9 K' o0 Z9 w; Q6 Q. s
.default_trigger = "default-on",1 ^! n+ Z8 X! Q- [% x
},
+ ?* {8 \% ]$ E1 A3 E( c0 y};
t. ?7 d, T4 ~0 T, ]7 F* Z* \0 O6 c' F& ]# Z* ^" T9 f3 P, s2 Z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: Q: r$ t6 I# c; d
.leds = da850_evm_tl_leds,! { E. j3 u4 h* J7 _7 B/ x
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 `7 }: q* b3 b) \- a- r};
' o# S, K5 ~* n1 i+ [+ [! q, |" }8 }$ Y1 P
static void led_dev_release(struct device *dev)
1 v) A) r; ^/ v6 A) D{% m `& w! h5 \% J. }, ~
};
+ a% ]7 I J/ q0 N0 B' p7 b" k" D: `$ x/ Y4 Q; d
static struct platform_device da850_evm_tl_leds_device = {! x2 G7 m: j! T
.name = "leds-gpio",
+ @* J" I) {; y* h( m$ @ .id = 1,# t. c* D6 K/ g t) h
.dev = {" C0 u, W* R% Q9 |* \- t3 g
.platform_data = &da850_evm_tl_leds_pdata,9 I/ t7 d6 \, R" `2 _) |* D
.release = led_dev_release,8 T. O7 Y9 i& y& _! g
}; W' n# z2 _( U& g, P( X+ f
};/ h" V& r7 Z& `. |' y4 P) f+ W
7 s' k" J- G L! {/ b, n6 T
static int __init led_platform_init(void)9 V6 |' }5 U# A- e6 Q/ t3 y$ h
{
' V' u8 u% I( k- d int ret;
. _: C5 x4 u0 e2 a0 t; P" L, j#if 0
; l3 ]6 r6 z* `1 G ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 U* [$ T8 ^) c* j
if (ret)+ m/ p: h+ H& F0 J
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, N9 I* i. N( } ^8 e "%d\n", ret);
) y3 d& |: s" |. j2 Y, w! u4 [#endif
+ P3 {. c2 {) s! Y2 f c! x: q ret = platform_device_register(&da850_evm_tl_leds_device);+ f( x" W% t+ S$ b/ k! q2 ~7 s# j
if (ret)
6 m0 v8 g3 {8 n* S5 D0 G pr_warning("Could not register som GPIO expander LEDS");. X+ k) y! k6 ]) M9 {- S
else7 l7 ]7 h4 P0 z* k- X' @
printk(KERN_INFO "LED register sucessful!\n");
! J+ B( N2 G$ T1 I$ E. g0 @ @. [; o+ Z% `' [0 o) s" |
return ret;8 ~" D6 l# F3 c4 s" Q7 s# y
}) a* |% ]; |- ]! \& I4 }4 x
; ^" ?4 Q# G2 lstatic void __exit led_platform_exit(void)5 G# u4 D n! u& B0 A4 _5 b
{
$ y s+ E1 F* s, W+ H1 m& A platform_device_unregister(&da850_evm_tl_leds_device);% t L; Z0 D) a/ \* A
0 ?# F* Q2 b3 l; ~3 b% O
printk(KERN_INFO "LED unregister!\n");
6 ?9 `2 A( X: e}" Y/ W3 \- l* Z) r
" }: O" a0 D" w: L6 vmodule_init(led_platform_init);. f0 |, K: M- m# a- H, m& Y( d
module_exit(led_platform_exit);
9 q+ Q i( |; d" G# S. R1 ?4 F* Q
t8 l" a3 P* Z, i- SMODULE_DESCRIPTION("Led platform driver");
, c2 l& i9 D( _7 h7 F* nMODULE_AUTHOR("Tronlong");
* {4 N0 M7 q+ G/ u R2 pMODULE_LICENSE("GPL"); ^( ?2 R' j5 ^9 J6 S
5 D) Q# t# k( P7 |; g, B |
|