|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 X! F" v0 i4 N' A# E" K0 m U+ `: J
#include <linux/init.h>& W3 t) t5 h7 j/ d& b) h( ~
#include <linux/module.h>* n8 Z9 F0 {( \+ m5 o
#include <linux/kernel.h>
4 Q) _% J; |+ l#include <linux/types.h>3 _$ L$ `) y1 k! \7 w
#include <linux/gpio.h>, ^- f% K: `( L' J4 h
#include <linux/leds.h>
: R2 b% r% _( T5 ?' G#include <linux/platform_device.h>
- e/ H' I3 G& `) Q# ?
4 `3 a* Q! L# F. v/ K, @#include <asm/mach-types.h>
! F+ |# A. g* W, f$ A$ n" P#include <asm/mach/arch.h> e2 y! S% l: `; L$ W
#include <mach/da8xx.h>- t t0 `5 c" P% J, o4 }" g
#include <mach/mux.h>1 [2 l6 j$ x+ s u: a
3 A I+ F2 L* T# ?. n#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' p4 z) V! S' _/ V/ j0 c#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 K$ c( s2 J. ~7 n3 }6 E
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 C; w8 B& @1 q: a6 M
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; m, a |& j7 R9 a" Z
: i4 [9 _0 P! k/* assign the tl som board LED-GPIOs*/
- u" l6 T1 Y5 @2 k) t7 T7 Nstatic const short da850_evm_tl_user_led_pins[] = {
( w( Y; U7 ~ P8 {" X+ `, P9 m s! @ /* These pins are definition at <mach/mux.h> file */0 d- Y/ p1 G, @2 R% L f2 h
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 h( C; z, k( z$ O
-13 E- ?1 H2 A2 l' l. X0 ?
};
, \* Z* J1 h# V1 S4 L9 C" _" M& X- z; m6 ]( T9 ]
static struct gpio_led da850_evm_tl_leds[] = {
6 i y) r% R' _/ C {
0 e- K3 ], [( ]# {: g3 q .active_low = 0," A# k d" N- k6 O B" s% E, h* Z
.gpio = DA850_USER_LED0,; p m3 d# c1 ]1 {5 w7 b
.name = "user_led0",
- q4 S S4 ?. A2 [; e .default_trigger = "default-on",
3 _9 ]) W) }9 J g$ E },. D ?+ f5 M$ J" f' p0 Z9 a: L
{
6 F+ {3 ~, C5 B" g .active_low = 0,
' ~) H( s( q2 y k .gpio = DA850_USER_LED1,+ F. t$ u O8 c1 ?
.name = "user_led1",
" @3 s) B! Q( _2 N. @ .default_trigger = "default-on",( ]- y% D6 O& X2 c: |
},0 @4 Q& ~% _5 m" T7 _
{5 M @! C5 F( ?/ ^3 i
.active_low = 0,
( ^ _3 ~5 T$ Z6 F, z$ _/ M! a .gpio = DA850_USER_LED2,
0 o2 T; S% d; ` .name = "user_led2",% C5 \# x- t/ `6 S G
.default_trigger = "default-on", v* |, m7 x: v) F
},
6 [9 {* n" n+ h6 L {' U( e) `1 B8 {* C
.active_low = 0,
" x4 j! L+ k. W. S1 `9 c& ] .gpio = DA850_USER_LED3,
/ u7 y8 |& l. l; q8 x .name = "user_led3",9 W, Q3 O h% X, t, k
.default_trigger = "default-on",# E. B8 c: K C
},$ m2 t. E0 x! @( R
};+ D, y& k# G, l* \/ Y w
2 |3 o) Q* t0 t: u& `" Qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. E/ e. A5 I' S, P+ l7 c4 C .leds = da850_evm_tl_leds,; n+ _" K1 X. ~5 p5 y" g0 r
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
& d( m1 R, h: @. T3 p};
, l( ]1 k' E- }9 c- m$ a0 v C
! B* O1 w- {4 T: }( E7 Tstatic void led_dev_release(struct device *dev)
2 f; h/ E& v; Q0 b{* f+ H7 Z# I! o" f5 P
};
* o8 X7 |1 b4 j' N! W
, {0 i5 U4 a& {! }static struct platform_device da850_evm_tl_leds_device = {9 z5 k ^; n- H. N
.name = "leds-gpio",& O1 v& w0 _3 X# |% S
.id = 1,
( r; Z! O9 d3 o; c/ D/ e. W .dev = {3 e5 l5 @7 e5 k d" B
.platform_data = &da850_evm_tl_leds_pdata,8 b8 H/ I/ h% a$ h3 N
.release = led_dev_release,
0 @& M! ]2 t; `; z }" J0 ?4 e0 a4 ^6 I9 q, e: A
};6 y( l4 G) N/ s- V
9 G: P' U& x! o: S9 p1 `
static int __init led_platform_init(void)$ N9 Z" [) q, @" C6 r( r! F# j
{
3 i+ \: X& [2 n; V7 I int ret;
* p k, L0 w) G9 ~#if 0- m8 Z. j1 r3 b" J7 R% g9 Q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. M0 ~; m9 X: [
if (ret)
0 w' G) n! g: r4 J" A- F pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 u; Z$ s- ~1 h, `) f "%d\n", ret);
3 U* z6 M6 ?, a$ z. m' X3 z! a#endif
* ?8 m" \0 u* Y# A: `/ D% r+ X- B# n ret = platform_device_register(&da850_evm_tl_leds_device);& ]% K. R0 T. N. K5 u
if (ret)
8 [0 A5 o* P% w pr_warning("Could not register som GPIO expander LEDS");
% u$ y+ H& r0 w5 `6 | else
' o: I, O9 W4 ]8 p5 b' l# l printk(KERN_INFO "LED register sucessful!\n");
* h* @6 `; {3 @2 ~
) n* p7 w8 A5 N! E! d' Q/ { return ret;
4 i0 N {; @" |/ d; X& p& ?}* F$ f) U" \ v' V+ z6 z( w' f4 v
. K3 H- A6 K. [$ L4 Dstatic void __exit led_platform_exit(void)3 p1 j; s0 G: p7 ~/ T5 b
{: D" t5 ?, W# g* S( g8 E
platform_device_unregister(&da850_evm_tl_leds_device);2 N; u7 l$ E9 {
5 y2 k" B2 c+ Z' g+ u6 G
printk(KERN_INFO "LED unregister!\n");
% ?& `; c% p" }1 T* D, Y}
* [- S* e( e5 R, j6 F) A$ \) x
; i& V- R7 s! m4 T# F2 w0 X, b; bmodule_init(led_platform_init); e5 s1 t- _" _+ y8 S5 g, S! @ G
module_exit(led_platform_exit);6 G; `( S* `6 q
8 p' l# Z. O9 ~MODULE_DESCRIPTION("Led platform driver");: d& u7 T" ?+ Z7 v2 ~
MODULE_AUTHOR("Tronlong");
; d- b' Q/ ^* J$ l2 j( JMODULE_LICENSE("GPL");* V# F' j- Z0 @8 i! k- H7 b7 ^) \
9 a, X: k1 p1 I7 n" D9 S) u! ^2 h/ r |
|