|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, j) W9 F" m1 n# k B/ ^6 | C" [
#include <linux/init.h>
/ j' M0 A3 s& z; D# d9 }#include <linux/module.h>; f) j, V, [) Q2 O; i' z
#include <linux/kernel.h># B/ y% N6 A& q, [6 H9 }
#include <linux/types.h>1 Z, H9 _3 n3 o0 G& P2 }1 f7 L
#include <linux/gpio.h>4 k, K$ u8 F, ~8 n, u1 `
#include <linux/leds.h>
, c% u. p+ ] J" R#include <linux/platform_device.h>
4 T2 X" i$ J& m% h9 n( `* O) \8 ~- @5 A. {
#include <asm/mach-types.h>: m! I8 W# B, @8 T9 |' P9 G4 R
#include <asm/mach/arch.h>2 h, a' ]" J) C4 k: ]
#include <mach/da8xx.h>
x# l& ]/ {' E- |- z#include <mach/mux.h>
7 N1 {% E5 `. ?$ @9 p3 R% Z6 ^; m* f3 o/ E( x( S( @8 Y. [. h1 T) a
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)+ F X7 x/ B! b! N
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" Z( @& |3 E7 @" ~. X# D6 x" b- T
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). j; U6 o3 X- q V, f2 |5 {
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# S/ L* r4 N, K8 b% K# d; l1 x
4 a4 R/ ^7 g, v, l2 m6 l/* assign the tl som board LED-GPIOs*/; j- L6 Q2 ^+ P6 @
static const short da850_evm_tl_user_led_pins[] = {" @$ t/ w4 j9 @9 U* c" A
/* These pins are definition at <mach/mux.h> file */- x9 n3 F+ q7 E" i* \* S, h
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 W' X' \* v+ n$ B3 }
-1$ i8 S7 a' @, c5 w, _# ]
};
2 t3 D3 w4 f# `4 r7 p" _0 w9 A o6 n
1 ]3 a' @. @, F- Fstatic struct gpio_led da850_evm_tl_leds[] = {( |, w: q+ y" ^9 ~ y
{! O8 B4 q! I3 H v
.active_low = 0,( V$ v" J y/ v. @0 ^. Y# Z) _
.gpio = DA850_USER_LED0,' Z" ?) o( x0 q& O
.name = "user_led0",& k; R9 j5 ^* m2 J8 b
.default_trigger = "default-on",
0 U' {! q9 F$ }5 {5 M },
+ B/ i5 i7 M+ ^ {: v2 [) [8 z: @! ?" m
.active_low = 0,
- D& {9 C$ Z# |& @ .gpio = DA850_USER_LED1,% K& |8 I, y& U# V q# f
.name = "user_led1",* P3 k$ I6 E2 q5 r
.default_trigger = "default-on",
3 K& S" f3 @ c3 y3 [ },
3 V* f2 P( ?2 D4 D9 ~) k& Y% \ {- A$ r% i8 Q9 X, z, n0 L3 W& w
.active_low = 0,) m$ @9 | n; s. g# y+ |
.gpio = DA850_USER_LED2,
1 ? x' h/ N6 A9 D& Q- B .name = "user_led2",5 X% N- w4 f. s4 `2 D
.default_trigger = "default-on",* K3 m1 m7 r3 k* r
},5 E% z" W( r$ M. T' ]
{
) V% H6 T9 l4 L8 \5 ?, c .active_low = 0,) @1 i; G( Y) q0 _- c
.gpio = DA850_USER_LED3,
9 c$ p% B) ?: C8 }! t( t .name = "user_led3",
# E7 C4 L) I% S .default_trigger = "default-on"," o. y3 }0 T+ J! Z: k ]& w
},/ D1 U! N3 x$ U& q
};. e3 `4 H2 ?2 L1 w) M/ M+ D7 Q
* Q# J+ z; s, |& V, F8 s3 U- Z5 Pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 a3 e$ R+ O) X, c6 R' R& B .leds = da850_evm_tl_leds,
2 N; h6 K6 P- f) W8 K .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. X) P9 s& x, ~+ C% r7 H% V! L$ n};$ {4 N& |* R% b/ Y
$ o4 V' x0 d: p6 d* Z$ s3 Dstatic void led_dev_release(struct device *dev)) m- e* \$ ]6 c/ S
{
( {8 s$ t' z5 d7 f! J};( R* _; s; i# X) E
+ b4 m) Q3 e5 {& _0 c
static struct platform_device da850_evm_tl_leds_device = {% Y& f& ?- p( }
.name = "leds-gpio",6 Q+ ^ u7 S {6 L# d
.id = 1,
4 R% Y+ N0 ^; \3 ` .dev = {0 i$ A, C; E. S# P0 y
.platform_data = &da850_evm_tl_leds_pdata,
- x* V4 N+ v# u ~+ U .release = led_dev_release,6 c( j7 V1 x% ]# t
}
7 D7 ^, |4 T& }& ~};+ A6 n3 X6 I- D, h
7 A9 s; C, i+ h! P* |1 I
static int __init led_platform_init(void)0 n& l3 A! l8 o4 h/ i6 x" _
{ \: X, g M1 t9 F+ G! o: A
int ret;: I7 O7 I) \1 r' z/ ^& w
#if 0$ K) K& R$ t# ^2 {4 o- e& S
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 l. w& h3 n# ^3 K5 c4 h/ C8 C: o8 p- t3 D if (ret)" q7 C" G4 S" Y$ p
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& N3 {# A( A$ T; D4 S9 t "%d\n", ret);
/ g% m- `/ ~, a* G! {- s#endif: c$ N* b o* N
ret = platform_device_register(&da850_evm_tl_leds_device);8 y6 j, L$ Z% q7 }; l& X8 F
if (ret)
. Q/ m. [5 H* I. C, @0 I pr_warning("Could not register som GPIO expander LEDS");
% B# r4 i j( T6 z; h else. r) a. s$ X( F8 q2 d2 M
printk(KERN_INFO "LED register sucessful!\n");+ B' K: P; I+ P$ q$ X9 w5 o
2 T/ z0 u; f2 r; I
return ret;* ^0 V5 m4 a3 V H5 n& p* Q7 _
}7 r" ^9 @- H' z
' H) U3 I6 c) e1 n: f( }
static void __exit led_platform_exit(void)6 K, V+ r( ]$ ^# `* C) |
{
' p5 x2 w& a$ J s" g" ? platform_device_unregister(&da850_evm_tl_leds_device);
7 @& Z5 R: t4 p
: V, m$ f* T' l& e% Y printk(KERN_INFO "LED unregister!\n");
+ U/ [3 c8 r- r% ]9 ] i' Y3 _9 q}6 [8 C' h( p1 T0 C8 Q/ L3 J. Z
& N/ o' h4 ]3 j5 L- k( V: M
module_init(led_platform_init);0 n6 G. u$ i$ _, b
module_exit(led_platform_exit);
' d: w. W2 G' m6 @ N" M( a, p' \8 T( N3 r
MODULE_DESCRIPTION("Led platform driver");1 c- ?. s+ q c4 e8 n
MODULE_AUTHOR("Tronlong");: {8 g- z2 U& ]# P) V: `
MODULE_LICENSE("GPL");
. Z8 ]( d7 X( S$ p. G$ O0 k) t# S) Z7 W, c
|
|