|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' h3 @% I5 J: I6 f) b% B#include <linux/init.h>
5 O) O1 q) y4 u% X1 v: [#include <linux/module.h>
4 U# i' k& K4 q( |+ g% s& \; O2 ^#include <linux/kernel.h>
' I8 m5 s- `/ V1 H F+ _0 o#include <linux/types.h>
) t9 T4 l6 y. V* ^! d) [% D! F#include <linux/gpio.h>
9 T% U- _3 u ?* ^#include <linux/leds.h>5 z) d; N+ Q/ }) g r$ ^
#include <linux/platform_device.h>/ F. _/ C6 V6 H1 N
6 {$ A' A I& g) D8 P$ @2 @#include <asm/mach-types.h>
9 l' n% A( S2 s6 y( D* K: L3 d$ Q#include <asm/mach/arch.h>
3 b5 E7 [4 M$ \/ q7 a#include <mach/da8xx.h>
1 z) T6 e, u6 @, S2 v7 i" Y#include <mach/mux.h>
+ N& N6 k5 {. }# {2 e' S
) \1 N! C# w6 y+ q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 |( W! J3 S4 |2 I& k6 T
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& C, h5 [ Y# u; R# B#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), u: w; h* O! }0 q$ t7 h7 Q' d
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)% U/ g5 |* W W( q3 O9 L
& p' q: A9 w8 M. P5 k1 G
/* assign the tl som board LED-GPIOs*/% J5 I1 C1 Z5 i( a. S: u" c
static const short da850_evm_tl_user_led_pins[] = {
; `' k, K7 a4 X/ j/ R /* These pins are definition at <mach/mux.h> file */# p# p* N9 @* M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ c" R9 g! a; x! t
-1" s3 N% i+ h* k% t
};* \% [1 G5 c+ @: r/ v3 w# q0 O2 g( E
) f6 v! D D% h5 @, M: l/ |static struct gpio_led da850_evm_tl_leds[] = {6 n! R e7 h5 K( I$ x
{
2 Z# g" g3 L, i6 t' h .active_low = 0,5 f: i3 ^& ~: n2 U& X2 E6 e1 F5 B
.gpio = DA850_USER_LED0,
/ j I+ L: M. Z( U8 w1 M .name = "user_led0",
9 }) g4 m5 m4 `: e' O$ S) Y .default_trigger = "default-on",( R) U: z$ F/ Z1 l( ]) c6 z' c5 d
},
! p% i, o, M; Q7 L5 {- f {& m7 `( w% l) k7 v0 E7 }6 Q1 S+ k
.active_low = 0,
! o; I; x* E ~9 x7 ] b7 k1 Q .gpio = DA850_USER_LED1,1 Q1 \2 W, x! K/ n
.name = "user_led1",
: p* T5 h* k- d- C .default_trigger = "default-on",* K. m. K2 X4 n `8 V
},. e; C4 L* e/ M; w ^) S n5 B( @
{" y+ d9 W: { t3 W9 I, H
.active_low = 0,
! b4 ?/ C8 X; q! p# W: ~6 W( O .gpio = DA850_USER_LED2,
, ~- A6 k6 b2 Y. r, i( M .name = "user_led2",% h0 T: |: E0 N, c$ e- j7 Y
.default_trigger = "default-on", o: D) O0 n: a' U
},
/ h" e& |) Q, x9 H5 J( K6 h {/ B2 ^% d, V9 Z
.active_low = 0,+ h" u6 u1 B0 K
.gpio = DA850_USER_LED3,
' n: d+ {! Q3 C .name = "user_led3",+ x3 D. n7 {: f" E( s- k5 p0 p
.default_trigger = "default-on",
" d. w$ r& [; o8 o },* x- P @/ V4 `( l- ? J- q
};
' ~9 n5 V1 Z7 @8 _/ t) ]
5 {0 t6 C d6 P: Fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 N1 R5 \3 O' m8 p. V: {( B .leds = da850_evm_tl_leds,
- K1 V4 u7 ~* z8 q, s/ \' M, r) K .num_leds = ARRAY_SIZE(da850_evm_tl_leds), \1 X9 c5 i0 s
};' K' Z, W g& D; D
( P- G. K) Y# P+ }5 z, ostatic void led_dev_release(struct device *dev)( \$ C0 A9 x, _: [; u. r
{" B9 l8 t7 e+ ~
};7 }8 `( [' x+ C' Y2 } _3 e
+ C) J0 C. T- m/ S# Jstatic struct platform_device da850_evm_tl_leds_device = {
4 i$ C' N9 j6 _3 _6 F# N$ y( p. n .name = "leds-gpio",
/ }% o2 N$ V5 f. J+ d+ O* N! \ .id = 1,
$ h' i7 N; [) K2 T .dev = {3 E) u4 K1 @' k5 K2 O1 f
.platform_data = &da850_evm_tl_leds_pdata,& c; X+ |3 ` d4 |+ K& X5 K- \9 w
.release = led_dev_release,
: p/ q- T- c3 C$ H3 S }
/ \) G& |0 @3 A};
& G; _* P5 ?8 J0 N$ Z- h) k/ T ~( N1 k1 ^8 W( y
static int __init led_platform_init(void)( ?; j9 ] B6 ]6 z. |" p3 C; A- x
{* v" q* z4 W- y' `& Z- B0 |
int ret;6 q, W" y4 B8 Q" i7 P
#if 01 d; I3 P, N! ]+ l
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 Y0 g( M( Q8 V; p, j1 t. \0 M. |
if (ret)7 b4 z: G) J- g5 z/ v+ X; |
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% |: q- k. c9 }- l5 f "%d\n", ret);9 w: N9 W9 n: x E# s
#endif$ g( ?5 N& z# h6 |: x/ A& R
ret = platform_device_register(&da850_evm_tl_leds_device);
1 `1 f7 {1 J/ p* M7 X if (ret)
% g; g }9 S9 F pr_warning("Could not register som GPIO expander LEDS");
$ G! ?9 A6 g2 u' K8 K else
1 m) u! |, ~# ?4 K printk(KERN_INFO "LED register sucessful!\n");
0 j6 |( q& X7 W' x* K* x6 @5 s5 |: D5 U' H X& k
return ret;
8 Y" d I& \ S6 C) j: o6 |}
( F4 H W* a" n( @
( H0 {5 d0 ^1 \) W3 r0 L7 r! bstatic void __exit led_platform_exit(void)
/ S) h/ I v# S) Z. y' ^{
6 ?+ O" f$ Q$ y: V- E8 a platform_device_unregister(&da850_evm_tl_leds_device);9 S7 q, ^7 i: A5 s
' ^) Q( ^9 K0 I8 }% \4 Q' @5 @* B( h
printk(KERN_INFO "LED unregister!\n");' ?! G' {1 x, @" }& }/ X6 ^: x
}7 B' x( S+ u [: u, G7 K
* K+ I; Z& o1 z, p, @" }module_init(led_platform_init);7 U9 d8 M1 r" d6 S7 a: t. M0 r
module_exit(led_platform_exit);
+ {8 n% h9 E, D! B2 @- u; q
. ^6 W9 N! I5 K/ a3 R4 l: xMODULE_DESCRIPTION("Led platform driver");
% f9 u! K# k0 _MODULE_AUTHOR("Tronlong");& i+ P. i. Y$ q9 ^
MODULE_LICENSE("GPL");
# b5 J2 H3 a+ z9 z+ H: G7 _4 W m b+ O& N$ p0 P6 ^6 h
|
|