|
求大神给下面的程序做注解,请稍详细些,谢谢。. h' A' V; T1 z
#include <linux/init.h>8 v: \* h- I6 z# Z g, Z
#include <linux/module.h>
; s; n" S* e2 k9 l! O. Z#include <linux/kernel.h>& F- c+ L5 P9 o6 W- x( Z0 L
#include <linux/types.h>
0 u0 S/ u4 X- T- ~: h#include <linux/gpio.h>1 P% ^. N# C% a$ x; @1 }
#include <linux/leds.h>' r: ~/ O( g3 F5 Q
#include <linux/platform_device.h>
: G4 h/ m! v; F! L! `2 h: I. ]6 Q, r* ]9 H9 e
#include <asm/mach-types.h>
' F2 G3 P0 G+ x O# ~#include <asm/mach/arch.h>
) T3 [$ _7 I$ d3 |. `1 `#include <mach/da8xx.h>
u3 M i8 H% i#include <mach/mux.h>
5 e* _+ [9 H9 n7 j( c5 N" A) A/ l$ I! K# {; M+ [* z4 t* R
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): r6 x5 X5 h: q$ M
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
( N4 Q* U! u' U0 p4 V' O u5 ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ ]' }* Z, Z1 C+ |1 [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 |$ V( p. D( A4 }
7 [; M7 s$ z0 Y8 S3 L/* assign the tl som board LED-GPIOs*/
* @. o: m+ Y/ z" ystatic const short da850_evm_tl_user_led_pins[] = {! D# {* o6 W6 Y. h1 P
/* These pins are definition at <mach/mux.h> file */
9 L$ t+ |) u: \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% B1 ~& l- ^; L$ [
-1
6 @! T0 q8 m+ ^; A( l};
( }# s" X5 T: M& Q* o& [3 _/ k; h. c! ~& t2 J5 u
static struct gpio_led da850_evm_tl_leds[] = {% l' V9 k7 U3 @2 u
{5 j7 n' O5 W) X- A K/ c
.active_low = 0,
/ b: A0 C; r2 o4 B' b- S1 _ .gpio = DA850_USER_LED0,
$ {, } x7 S9 s+ ]' s$ n+ L* F: q .name = "user_led0",
; l C* d$ m% p, k' I( K% t3 p .default_trigger = "default-on",9 }7 j0 S+ O0 b4 p( j
},
+ g0 \4 ^* f/ E# M { u* J. t# Y& k
.active_low = 0,. u8 i/ k' Q4 |- V# I
.gpio = DA850_USER_LED1,
5 v# c) t! n7 C* [* K .name = "user_led1",7 e; | ~# n/ }3 F$ H f2 x& {
.default_trigger = "default-on",3 o, Q I, ^9 V
},1 Y% s! |# s2 o9 W1 Z
{1 e0 P# A# C# x2 y7 [# P2 J
.active_low = 0,; b' {) P* x* k; r z+ O9 p
.gpio = DA850_USER_LED2,
8 @/ z. s1 s/ H$ t7 z8 e' [ .name = "user_led2",
q* g4 }" U, @9 f) e& d2 H0 i6 a .default_trigger = "default-on"," M0 |+ ~- f* I* F2 s( C Y" @
},1 P' x: Q" Q0 K# t5 I9 ~% q$ r' n7 b
{( O1 `* g9 R$ M# l8 ` ~
.active_low = 0,
# \' H+ v9 {( `+ }/ W: r/ | .gpio = DA850_USER_LED3,7 s+ y2 I4 |* U9 u6 B. ~
.name = "user_led3",
' D6 ]& E! R! k& l, w: ~( Q! n .default_trigger = "default-on",
( D1 _! m0 f. F! d$ K5 v/ Z },9 q3 V6 b7 ^7 w$ x: V
};# g- z ^+ E' q
7 r' e1 B8 x$ Q& L( T/ B& ]
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& k+ N" S+ `! `3 c; t2 c4 e3 V0 A
.leds = da850_evm_tl_leds,
! z6 K9 }3 h; L* Z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 k: j( O& F Z3 q8 r/ M$ }7 V};/ n9 v# A/ C6 O. v$ {- i+ l5 l$ N
! o6 E# n, F$ H* \1 E+ \8 ystatic void led_dev_release(struct device *dev)+ P5 ^1 B- b- j7 E
{
+ t. V1 V' _+ l};% C( L2 E( D3 M' z @6 Z
) W( V- ^, j9 h5 s- |
static struct platform_device da850_evm_tl_leds_device = {
3 N Q$ U0 q: m .name = "leds-gpio",
1 w( k4 C; E8 q .id = 1,7 r3 w; k0 u, }4 e Y! t. T& R
.dev = {* g- |2 k: C, j9 n2 S( N) L
.platform_data = &da850_evm_tl_leds_pdata,
4 Y: a9 N' n* C5 R .release = led_dev_release,
+ v" d& @: b! K e }, {5 O; V3 w2 X* V* ?
};& D) x; g: W3 K. U1 H
' ]9 L$ O! f) G" ~2 p) k" x, \7 _
static int __init led_platform_init(void)2 z% ?2 `) V6 N" m0 k
{" W# w4 E1 E! J9 D2 n! ]- V2 T' [( G
int ret;
2 S( \7 j* E, x# d# j5 ]" s#if 0
( Z1 m2 W, c& L( Z7 s ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
$ b' i5 ^; H8 M3 w9 U8 F% F if (ret)
7 N7 r2 B3 z; `0 a: Z pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& y" |* ?6 k' o( u# g "%d\n", ret);
* s! |* I' e# R9 I# _' q#endif" T4 |) o O8 Y v* f c
ret = platform_device_register(&da850_evm_tl_leds_device);
. `! }6 U2 N' l" ?( S if (ret)" E2 f" |+ C/ b0 b: b* \2 B" y
pr_warning("Could not register som GPIO expander LEDS");
7 n4 F4 v3 v2 X& j: Z) G8 _( d9 s" q: \9 Q else" B" S/ j( x7 G/ q
printk(KERN_INFO "LED register sucessful!\n");
; W" a0 v: d! C( Q# _0 E6 q# N. q/ B2 U7 z7 D+ ^
return ret;% C( m; x1 C) O8 h: V
}) ]1 U, ^$ q. ~2 ^
2 z4 S! { J5 F& Nstatic void __exit led_platform_exit(void)
$ x% S7 B9 I& f2 U' L, b. X! d{
( h% t* h" c. a8 B platform_device_unregister(&da850_evm_tl_leds_device);3 k, J9 T; K: c
; a6 f# |# ~8 s0 p
printk(KERN_INFO "LED unregister!\n");$ r8 Q$ a; K: j: K5 { X+ o
}
0 Q2 r! v2 ?0 _) m/ o
6 S/ }3 k6 r% l2 D; Bmodule_init(led_platform_init);
5 ?& e# r: D# t7 g1 hmodule_exit(led_platform_exit);
) n! l& M7 U" h K& E0 C2 j7 U3 \7 A, l+ O/ g+ x: a h
MODULE_DESCRIPTION("Led platform driver");1 K+ R7 K2 f% r8 k6 ?3 N
MODULE_AUTHOR("Tronlong");
3 w! w8 l& ]) C9 S4 f! \MODULE_LICENSE("GPL");
! q6 ^. O9 K2 b- v0 e, T, o4 }2 U$ F/ l# ~1 T
|
|