|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( x" N: V/ v0 s4 k& V
#include <linux/init.h>
: P2 ^6 ?1 D0 R2 [#include <linux/module.h>' ^+ `# E, I' |2 J
#include <linux/kernel.h>9 e& Q- O% M7 ?; X3 V
#include <linux/types.h>
9 a% w; Y6 H/ y+ X5 [$ x#include <linux/gpio.h>' K( \+ I2 M* Z& ^' A
#include <linux/leds.h>
, R3 e3 U; ?- k8 L8 E1 S- G: r#include <linux/platform_device.h>
8 H4 Y: N/ q* }& P5 a) _& ?- |; ]2 p. T. W; y) v" E3 K X- R% g8 f
#include <asm/mach-types.h>! z9 j" p6 f; o" k
#include <asm/mach/arch.h>( G F; D( _' p8 \7 e
#include <mach/da8xx.h>
1 T1 u x: b+ I( p#include <mach/mux.h>
* X) T( P, B& u! i' `4 ^" v, k. h) V) X- ?5 I9 `3 j
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)9 v9 v# h4 ~& R, q$ ~' G* D* |4 K+ G( E
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) `$ w0 M9 k w+ k: d5 V; [
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
# V$ s# h" S2 }' L- z) x#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 P& H( a3 X* m: R2 e7 V/ y3 z$ A6 g( i0 ?: u
/* assign the tl som board LED-GPIOs*/
% E# M9 p4 R2 Q+ b( _! f9 Dstatic const short da850_evm_tl_user_led_pins[] = {: e: m# h# K2 J* s4 J" k( |3 }
/* These pins are definition at <mach/mux.h> file */
( k2 D3 `* j i/ N/ o DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, Y; ?: B/ u5 E0 D- t/ }8 @) ~3 Z -1! }* k' X6 E6 G) V, x5 P% e
};$ h5 D/ i6 {$ |' R/ ~" W& V6 e
7 N* }6 y( q6 o
static struct gpio_led da850_evm_tl_leds[] = {
4 {" r9 m- j, d& ]4 n' ?4 {9 L {, F3 Z6 m. P4 C N, L2 p/ ^& o
.active_low = 0,
- U( \, D" D2 s4 h2 F .gpio = DA850_USER_LED0,6 a* w. p) p9 C9 K' {) P
.name = "user_led0",$ M ?6 C& T/ G2 l
.default_trigger = "default-on",( q. G& C% F& q6 K( g4 K4 E# {
},! E7 M& x7 \1 H v
{7 Y& e& j' {/ |- Z/ h
.active_low = 0,& i" O. a3 K% E& c9 W
.gpio = DA850_USER_LED1,
) Y6 a, {7 S% T0 N" F. U .name = "user_led1",3 E& h& A L' j7 S4 W7 g
.default_trigger = "default-on",
! p6 W3 r4 m. v! m) g" |9 s },: \, E3 l: N @# k) L
{* U& c/ b. E% a/ d
.active_low = 0,
! v* z, D* L4 b$ {" [; B .gpio = DA850_USER_LED2,- Z1 \6 g9 K* V1 E; B+ _
.name = "user_led2",
1 V# s2 s3 u6 e .default_trigger = "default-on",! N' Y& }9 J' P2 A, x! F: H& L
},
- G" J0 x/ W) c# @# I6 ` {3 b* p; ^; s- h5 F+ d, p" x
.active_low = 0,
" c0 @, T5 H/ r+ j, G" W .gpio = DA850_USER_LED3,+ y, D1 S& ]) G. y
.name = "user_led3",
d; A c& S1 z8 t .default_trigger = "default-on",
- u' n* {1 z0 C; E" S+ g },
% o! K* ~' p- _};
/ g) T) r8 L2 }* u
* P2 k5 {. A( {: D7 {' ^; q' xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = { ?3 H7 V- w: j, j0 L$ z- I; z
.leds = da850_evm_tl_leds,
4 W' c* X1 ~9 c2 [* p4 `# _, S .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, D; R1 A. y! }
};+ N1 R# v- d! v+ a0 B4 @2 }
4 n [1 a Y. b5 _
static void led_dev_release(struct device *dev)
3 K( i9 |7 T2 ^8 A2 D3 S{
& z# L: T: y& `! o6 E, K/ X};
& G3 F U* ~2 P$ n) A, o8 Q, r+ }! g4 \8 x
static struct platform_device da850_evm_tl_leds_device = {$ Y. Z; t7 B2 x, Y7 A* V
.name = "leds-gpio",
" e8 J4 y+ F" D( j- Z& p' P& {! ` .id = 1,
3 ~& X! S! U% U, {, F& E9 j .dev = {
$ g4 ~! X8 G. d" X; R .platform_data = &da850_evm_tl_leds_pdata,
! ~2 }4 c" H( g5 }$ u( J& |3 {. @ .release = led_dev_release,
" A" i3 H2 ^. u2 L }' l2 @- \! V; V! D$ v2 J6 h
};" L/ P7 v4 m2 ] U. l$ V. U- _% `
1 J) q$ C% N8 ]" q: g3 `& q pstatic int __init led_platform_init(void)4 e8 @" G1 o; P7 b+ ^" r9 e
{
: D3 \* c. O8 p; h) w* ? int ret;
( v4 m) S" x8 L% y2 J3 ?0 R#if 0
( o x% ?' G G# x2 F5 A0 B$ ] ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# w& H% n* G0 P1 A A Y if (ret): w+ [! l$ N& Y, P
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 c* }+ a1 `1 W) X "%d\n", ret);. H, e3 ?! V& U. B2 t F
#endif/ ?" ], t/ |# C; m, y5 g
ret = platform_device_register(&da850_evm_tl_leds_device);
+ s; ]# }7 F! d8 B5 R/ [: \ if (ret)( h, c6 ]' M% r' `
pr_warning("Could not register som GPIO expander LEDS");
; @3 T! ?4 L' e( I0 u else: q K. U5 y. L% |
printk(KERN_INFO "LED register sucessful!\n");
+ C# o! o! r8 C. [6 i/ r+ [+ {6 d9 U( N9 {
return ret;: }: c" ]8 h$ R: v- n6 {
}# ^1 @9 } S; ]1 J! p
9 L# O$ S2 } p fstatic void __exit led_platform_exit(void)( W+ {3 u" P+ i- j
{7 @% c, l, A4 z" Q+ }
platform_device_unregister(&da850_evm_tl_leds_device);% O# |# p8 I D7 d5 q* X
5 V9 ]7 _' y# k' b) c
printk(KERN_INFO "LED unregister!\n");
# p a/ q6 y; J" [5 P}6 O/ e* Z% E; v7 i4 `' c
/ ~! }& D) ~1 D2 R
module_init(led_platform_init);. @6 ^5 V b8 V1 J4 @6 b% [
module_exit(led_platform_exit);
- h' ]% g0 V' H$ d
- b) g# x' w! I: |MODULE_DESCRIPTION("Led platform driver");* B; i, c- u, y' Z5 @' f8 j
MODULE_AUTHOR("Tronlong");
Y! P4 x2 g* C3 o3 ]MODULE_LICENSE("GPL");4 S2 Q" w9 T% N) _7 O
2 V: r3 O! ]- n+ @$ {- u
|
|