|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 p8 E+ @- a% a" r/ w7 Z; B" W#include <linux/init.h>- p* ^. _ T0 H+ i
#include <linux/module.h>
8 s. z s1 G' B" c# Y/ E6 C#include <linux/kernel.h> k9 j8 ~+ r v0 F1 O* E" x t
#include <linux/types.h>, n7 X. x% a) @( R+ U! u
#include <linux/gpio.h>
5 Z l: Z) y% C, v9 e#include <linux/leds.h># \ K! y5 A5 Y h
#include <linux/platform_device.h>
% ~# u4 j6 _" |% Q& D" O
# V- S, s% d. R6 [, q% r6 o" Q. J#include <asm/mach-types.h>) w" ~! [/ @* c5 N; ]' \% W
#include <asm/mach/arch.h>
: i/ Y6 ^+ S% [4 r3 u7 }5 ]#include <mach/da8xx.h>
5 i3 ]' W; d# j' v' J- [- J C#include <mach/mux.h>' ]& w/ \5 X3 B2 l( k4 e
* x! I7 o/ Q: ~3 ]- N
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* ?$ ?8 @# Y7 W3 F) v+ F. e$ u/ [#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 R+ a+ ~# H, w6 H6 t5 C$ c1 N* s
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
& l) ^4 f Y1 B1 W6 s8 ^#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 h, O% a ?" T: V) ? U* v; w: q& x
1 h0 b+ n, p7 L% u W' Q# i
/* assign the tl som board LED-GPIOs*/8 M! E( _) E9 h1 }5 ~/ e. L
static const short da850_evm_tl_user_led_pins[] = {, B/ b+ }* |( d5 s7 o! w. D
/* These pins are definition at <mach/mux.h> file */
% S8 T2 Z! v [( d) b- @: p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ `9 R' |( e2 S3 h
-1
+ r q8 ^0 ^& ^9 h};
% }0 o' N- n) x5 Y G X% f; N2 u) W0 R8 p' i d" ~: u
static struct gpio_led da850_evm_tl_leds[] = {
d. {+ _6 Y% \* A( _/ } {+ b8 w1 J8 \9 F5 ]5 w
.active_low = 0,
% k9 W/ N6 B0 e% g& ~9 J2 t .gpio = DA850_USER_LED0,4 l! L% ^2 _6 v
.name = "user_led0",: G) K4 T% u( ^8 e/ L
.default_trigger = "default-on",6 }4 i# A8 B8 C( A
},& M5 X! B+ q9 G; I; p
{( M! D2 p2 Q/ ?& Q* Y
.active_low = 0,
5 G- Q2 f m5 J( f* m$ n e5 @ .gpio = DA850_USER_LED1,3 w( c6 @! B% o! Y4 _
.name = "user_led1",
" j) _; z, ?" C+ j; y! ~- h6 v .default_trigger = "default-on",
, A x* e9 Z1 j" h; q Q },$ g6 v) |3 l- }0 g6 ^' [0 c
{9 i3 j: \3 |' |- ?) [- B
.active_low = 0,
' F' j' `- [8 f) a- g4 ^$ ` .gpio = DA850_USER_LED2,
; u7 w" i: P0 `3 l1 H! W: Y8 U( | .name = "user_led2",8 P0 h; T9 h5 Z; x
.default_trigger = "default-on",
! O$ j0 z% H) O+ P },% Q3 E* H" H7 Q" i: o! s
{8 C( E% R$ ]6 K0 M" Z/ r9 O
.active_low = 0,% c% M# B2 I+ I( n2 a9 P( i& I
.gpio = DA850_USER_LED3,
; I" g9 l* T+ ^ .name = "user_led3",0 d4 }! a, B' Z' Y% j w
.default_trigger = "default-on",
( q% l" G- K4 w ] },! k1 l9 A$ w+ Q' X" v% x
};
0 Z8 p) C- H$ R! f- r$ v1 t3 }: `3 M/ T: n7 b2 ?' K
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( V" p9 j2 u& A7 t6 @1 C1 X# d
.leds = da850_evm_tl_leds,$ A7 ]. D, k( a$ S# y. c$ h
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),: ]- z& y1 n- ^, E6 p# g0 ~
};/ N( i9 Z) v- d
3 _: ]6 f' ]+ i5 L6 kstatic void led_dev_release(struct device *dev)
* {! G' B) J9 C5 p2 n{
1 F1 U( N& K8 H0 z* _};
& D3 x6 \+ V2 E8 ?
8 D! X K( L- [4 pstatic struct platform_device da850_evm_tl_leds_device = {2 d: \! K$ ~2 u( v4 h
.name = "leds-gpio",
1 V5 F/ P- A$ }8 H$ H9 k' V. y: e .id = 1,
4 {4 ~/ u/ K2 _1 N9 x .dev = {
9 C9 u% H+ J) S1 W' j1 t .platform_data = &da850_evm_tl_leds_pdata,
. R, B, a8 v3 \% X7 S. c .release = led_dev_release,4 r' x0 u8 ?. C, Y; ^$ ~
}
0 g( d) i; C. l$ U2 j9 P" {0 [# d+ V5 g};
y0 I1 j P. j K# _" D7 Y' S* \- N. h' m. \' r4 R
static int __init led_platform_init(void), E3 e% U2 S1 F
{ [8 c) j( t( F( l9 Y
int ret;3 z/ N$ _' q, O, V2 N
#if 0: I* m7 @$ w4 B1 d0 H
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" q4 B/ p3 @4 d5 A/ i4 X
if (ret)
9 S8 k- E0 P z& O7 A pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 z9 C& l* i" ?8 L2 B5 D0 V
"%d\n", ret);
3 k- l& w x' M8 g, E1 P#endif
) j. X. F6 I' y+ G. s; U! F8 T! a ret = platform_device_register(&da850_evm_tl_leds_device);" s) X9 A5 ]& ^$ k
if (ret)3 C2 g0 P% ?0 v9 x
pr_warning("Could not register som GPIO expander LEDS");
4 |! O" p E b else2 E' U! t. ~) f2 e$ r2 M, {; {
printk(KERN_INFO "LED register sucessful!\n");& w8 }( l& x' Q# F' Y. e% @6 E
/ H: M5 J" Q( [8 [1 M, |$ ?. c return ret;* m; i7 o+ D1 [- j
}
2 c$ R9 G; m: W1 ?6 F! n X8 h
- d6 c8 m8 }8 }) `% ~) Estatic void __exit led_platform_exit(void)$ O! T- N4 a" H/ c) `# G4 d
{+ T( ^ M0 W, O* C3 G6 c% O
platform_device_unregister(&da850_evm_tl_leds_device);
; n0 k7 g9 w f# z. _9 Q
/ I W& W$ P( I) q. @ printk(KERN_INFO "LED unregister!\n");( a, W5 t3 j1 B. V
}: y% G( V# @8 Q5 U. ?/ u* z
$ V) @1 O* j3 r3 w2 n4 S: r
module_init(led_platform_init);# z$ G3 ?' w7 l. [. b! `* Z3 P
module_exit(led_platform_exit);
8 p4 X# I- L+ B: T2 m
: {0 d! ]! L; U1 L! j! d; l+ YMODULE_DESCRIPTION("Led platform driver");
U3 m# s; e- ^- I; R& bMODULE_AUTHOR("Tronlong");
5 F$ S1 n9 h8 f r' c5 B. G! ?' AMODULE_LICENSE("GPL");4 ^6 ]$ Q8 B! I0 {9 h* s9 j {
4 J! X8 U" o5 ` Q1 Q$ \4 }' r2 a* c1 x5 r
|
|