|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 W& w) r4 x( w1 S- z
#include <linux/init.h>/ N# d0 \& q( z( E& t& i- E. H9 p
#include <linux/module.h>
* S5 ~ q9 |0 b. @#include <linux/kernel.h>9 n1 j* h: C4 R
#include <linux/types.h>
2 x: H& J- V7 s" U#include <linux/gpio.h>
8 a8 V: V" N2 U#include <linux/leds.h>( C6 r. p B& P" J! I. j, U
#include <linux/platform_device.h>
$ h1 b0 Y1 }! q( W1 g9 F9 l' \: v& A' W) R9 ~7 _0 n1 y
#include <asm/mach-types.h>
/ i+ L% ]- Y1 a! e8 q& u5 q+ x: K#include <asm/mach/arch.h>' [' b( o4 ~9 w0 i2 Y& x1 R# T
#include <mach/da8xx.h>& A1 N7 F' H: p U. B
#include <mach/mux.h>
; ~& T$ [5 `- W' y% ? V& ] q& ?1 O" X0 l2 ~3 B& B9 K" ?4 J
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. P8 @* G7 t9 _2 J! z4 |8 d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, T" B4 S9 |8 ~% b- K: ]0 l+ \#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 z9 K. O- v6 n+ v, g7 A1 w1 e
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( q5 g5 Q6 z' ^0 V9 U! [) l
V l% O. L! L' F) t! w
/* assign the tl som board LED-GPIOs*/
# L' Z3 ]' l' }static const short da850_evm_tl_user_led_pins[] = {/ Z7 G' g5 M! X; r$ U
/* These pins are definition at <mach/mux.h> file */
4 C* i! B) b- N; u: z! v7 ?5 j DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 T: r9 ]' q% G1 V
-1' w1 s' _; |' p+ }2 A; a. w# y
};& I. c3 H# d* P7 p
7 A6 T* t1 g$ h% }* Z0 a/ Tstatic struct gpio_led da850_evm_tl_leds[] = {" p+ v+ S3 D% |
{$ g6 n8 ?( c6 Y' `4 V# z
.active_low = 0,
. G# t7 O* U1 f0 i! G .gpio = DA850_USER_LED0,
$ }* A' E5 d' C, U .name = "user_led0",
, D2 d2 Z3 B" t* I: P3 s .default_trigger = "default-on",$ |! r' g+ ^0 d2 K) s
},; X9 {, q. J/ B0 f- D
{
2 m5 H* u3 v8 ~ .active_low = 0,% H2 R3 q; z9 m
.gpio = DA850_USER_LED1,
3 [5 q! p" u+ i: b1 K) F .name = "user_led1",! \% b" R2 V, f! y+ x% q
.default_trigger = "default-on",6 H, V' A2 j0 e- T$ V3 S0 J
},
! o v5 C. }6 ^' Z {% J% [6 g& T4 I8 g3 v
.active_low = 0,
# t# {0 D! R! E& o& c .gpio = DA850_USER_LED2, t7 U6 i9 w0 @- l* k. M# P7 o
.name = "user_led2",, M/ f2 L6 b: } P- N
.default_trigger = "default-on",
% |8 ]0 G+ k6 ~ },2 }6 l% w! W! H: W
{3 ]3 ^, y- s" p" _7 E
.active_low = 0,
( l- P3 K+ N. }. U& E- Z0 n .gpio = DA850_USER_LED3,$ b& c* t: T( L, } t$ [
.name = "user_led3",2 ~6 d5 b' C$ E- N
.default_trigger = "default-on",4 Y8 y" D( s5 ]
},2 Z% _, O# L' [) F: ]) `; p
};9 O+ k1 [* m' o6 Z; e
( S" G" c' t) n- B9 p8 kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {5 |$ V( \5 v+ ?
.leds = da850_evm_tl_leds,
6 b: I+ ] d/ F .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 k: @0 n+ b- y: j
};: {$ s# N/ k; T* d# a6 I4 C
2 E! [) }: j1 J" Q* Z! Y- U8 _static void led_dev_release(struct device *dev). `9 t2 N7 u9 q( ~
{
2 x! d& y o9 \/ N};* S* r. w3 ~* O+ \. e5 W7 \
& q- W2 B0 {3 L: w1 Y% H! \6 D
static struct platform_device da850_evm_tl_leds_device = {
3 ~$ H6 o# {% H7 P, C2 O( G .name = "leds-gpio",
4 X) q. ~# K+ K) X3 D! w0 K' [& N .id = 1,
: a L( r8 `# H .dev = {3 D0 N( M4 c+ S; ^2 \& R3 }
.platform_data = &da850_evm_tl_leds_pdata,
" a& ~8 T4 q' P! z7 _& o .release = led_dev_release, M' e( l" `1 E* ]- v: V$ o: ]# i
}3 J. {( O! S7 i, u. j- P0 B
}; x& x7 V# \" m, R8 g
, J' w1 h7 \$ H) u, |1 ~4 X$ f. ^static int __init led_platform_init(void)
0 o0 F6 m+ H/ i/ c{! ~" b8 g/ R: [0 |+ Y! t' r- a
int ret;, n; |1 S: S5 a4 h! b& m3 F& q
#if 0# i t/ Q! [, b: p! e( b6 N! }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 G0 W) _2 P; F7 v" {" I if (ret)' V: v1 _9 }" s5 r4 g
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ ^/ x& X: s0 c, z "%d\n", ret);& ^/ T# g7 J+ i) l; ]
#endif! U+ x( T/ M! f' m. N' D( n' V
ret = platform_device_register(&da850_evm_tl_leds_device);
! m I6 |8 O7 k/ [$ {. j) | if (ret)9 } Y. h2 m# M1 S7 q
pr_warning("Could not register som GPIO expander LEDS");
/ _, T* O& H: f+ h( |0 }4 n else1 W# B, @1 \% _& V; u( o" S
printk(KERN_INFO "LED register sucessful!\n");
& o) p: J8 @, ^1 n9 }& @# K3 J2 M) ]; a, q$ D
return ret;
+ ?( @/ ]) T* N- T K l. G}
" h+ f0 o( Y5 W) W8 Z7 a$ G: W' l
static void __exit led_platform_exit(void)9 M0 R6 H7 r( |1 |
{
/ |- w1 z+ H) X. {( @/ ~ platform_device_unregister(&da850_evm_tl_leds_device);& p4 ~& m( r. _0 H
/ N) g# N. w# B7 G
printk(KERN_INFO "LED unregister!\n");
, A7 _; X% |4 U. {2 o7 h }}' I& ~1 z+ m; p) ^8 ~
3 i( ?( Z6 p. _6 t6 _, Wmodule_init(led_platform_init);+ z9 S5 ~4 J8 D
module_exit(led_platform_exit);! ~% d# K4 h) Z1 I1 a4 w; q0 F
2 `5 H0 k; m8 J6 LMODULE_DESCRIPTION("Led platform driver");
) p# o) `" A" b, h/ h# zMODULE_AUTHOR("Tronlong");
! w# b( P& \* h! {4 \& o6 vMODULE_LICENSE("GPL");
$ v5 H* V- [4 P, M8 A: }, ~) S
# S9 q7 d. R* t, O* Z& S$ D- f |
|