|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 {( w, _7 Z @6 f& X9 X#include <linux/init.h>
9 U6 }+ O+ x3 }& f; a% k3 p#include <linux/module.h>- Y/ t# _% o7 H
#include <linux/kernel.h>/ D- R1 A1 P! o7 d: F: j+ S
#include <linux/types.h>
, V4 K" r# K8 P) E#include <linux/gpio.h>4 P( ?7 Z, M3 o; [$ Q
#include <linux/leds.h>
' t5 I y. U1 i; P0 p8 X#include <linux/platform_device.h>! E6 P# @8 P2 g! a7 H
; r: e' h/ K$ N: l: v9 A0 }/ f$ h#include <asm/mach-types.h>
4 l4 ?; ]6 Q4 h, G' \#include <asm/mach/arch.h>
. i6 j0 a1 q- l2 I#include <mach/da8xx.h>! Y$ E7 W# e7 k, H( g
#include <mach/mux.h>
& @/ w! R! `5 S( R1 O1 S4 K9 C' r: M
g1 S' o* R6 T" p; h$ K1 s#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 P( d- u% |) ]4 j- I; ?#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% [0 `& t5 d; Q1 o6 \
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)* N3 x% \$ E Q0 S
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' C; o L0 U9 s( x
1 U. K E T2 X, N* G. O5 x/* assign the tl som board LED-GPIOs*/
: {; i/ I1 ` h; q( B- P% Z2 vstatic const short da850_evm_tl_user_led_pins[] = {
. [% ?6 E y) ?8 T P /* These pins are definition at <mach/mux.h> file */
; a* m1 ^0 s& a' ^7 x4 u1 e* w DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 j8 {. D% }% n
-1
. L( S, o( s; M8 h: n( x};! Z) ^9 A( m+ j+ Q! U, [ P0 z2 |
% S( W" A+ H3 e+ Q. Q: {, {3 Ustatic struct gpio_led da850_evm_tl_leds[] = {) y) t( i8 h S" y- _5 }6 p# r
{. e$ B9 A4 O* h& N4 S6 l, N
.active_low = 0,
9 y! H i( u4 _. \) t .gpio = DA850_USER_LED0,* q( O# Q6 N- b1 N4 j0 X
.name = "user_led0",4 f! G- |8 [( r) M1 a8 W# N
.default_trigger = "default-on",
, y- W/ X) ? ~$ N) m$ r },: o+ e+ J5 T: M- v; r8 E
{
Y# ?0 M: q/ [0 A8 }- U .active_low = 0,
9 _' w* m- Q# T .gpio = DA850_USER_LED1,, g" S' C5 C$ A$ v
.name = "user_led1",
- Z% s2 [- G( _/ i .default_trigger = "default-on",
v, O6 Z& ^. i* [9 \% H: I },# i" t7 e9 O4 `/ {) p
{
* f' d) ^3 }$ L .active_low = 0,$ i+ V; G" f0 H, R- a |, U$ b
.gpio = DA850_USER_LED2,
% {2 [! G# N3 N7 A .name = "user_led2",5 x& T* F+ ~' g
.default_trigger = "default-on",( J7 v8 A: | t% b3 l; s0 ^
}, S$ Y0 w0 [( C# @0 E5 l% B
{6 L; O- f" D3 ]# P1 G( M( l% C
.active_low = 0,
' Y/ H) W6 N n6 [+ t. R .gpio = DA850_USER_LED3, Q: z3 Y$ s* n% S* x6 {
.name = "user_led3",
0 N+ `8 R$ c. d5 m3 \ .default_trigger = "default-on",
! m/ \: o0 `! b' G& X },
2 m2 q' r: ?7 G1 H7 e% n};
v7 U& m( ?) o* B: L) Y0 i- g L6 }
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 M8 `; }; N+ n' U/ G0 l& o+ L2 G; E
.leds = da850_evm_tl_leds,& E) I% M0 x( c- P4 L% n) f
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- Q2 N2 V6 _! W S! w# q- K8 @};8 M4 {7 M9 }% P+ l( q4 z$ H8 M
/ i8 o7 ^* S. U7 Astatic void led_dev_release(struct device *dev); _9 N' p; z* G- h' r k' I* ?2 c
{- P' j8 X+ b/ r L
};
* L5 i- f2 L' R4 e& B6 Z' J6 h2 k0 V3 E. ]6 V
static struct platform_device da850_evm_tl_leds_device = {. D( R( l3 b$ F( X( R
.name = "leds-gpio",
% T" f( T! p) a q- K g .id = 1,
6 S6 d" B5 ?6 F7 ^& J$ I .dev = {
8 {4 ~4 y5 a1 j1 z8 A; _' ~ .platform_data = &da850_evm_tl_leds_pdata,
0 _3 G+ M% I9 P' E .release = led_dev_release,
/ Z- a* n$ O, J( o$ n }3 K/ h# @1 |+ U5 k/ O, t( J
};
" K, k/ z9 z! L3 ?4 \8 o8 P' l% _, l* R; R [! }
static int __init led_platform_init(void)
d. C9 E9 K) J{- n. E' \% l/ u4 ?& a8 B
int ret;7 i' q( @% u5 S% \9 ^& I
#if 0) N& v/ u: T2 x- P- n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);& P/ v$ v* [3 ?* D R
if (ret)) |$ u, k" r' U8 |. j, E
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
9 Z, J0 F( O; O9 O( W "%d\n", ret);
, E! l( T8 h! B3 ^8 d; I#endif
6 E8 P$ e/ b# H ret = platform_device_register(&da850_evm_tl_leds_device);
! ~1 K+ I- @; j, P if (ret)
0 \0 K: b* ]: \& {' ~7 m0 q pr_warning("Could not register som GPIO expander LEDS");
" t4 O7 l. P J/ d& k else- @. u5 S: P/ G3 _; T
printk(KERN_INFO "LED register sucessful!\n");# g% X$ u# x/ T4 k3 y
/ r! P& D0 B. B1 O( v' {
return ret;( m5 f& s5 |1 N% ?0 E
}
! k) J( O5 B; {# e5 [8 r1 C2 ^4 K# H
5 y5 h# S9 }9 Dstatic void __exit led_platform_exit(void): @* z$ m% H" `6 ~9 t. L0 c
{) V) S: n9 n! T4 s# o! G* M
platform_device_unregister(&da850_evm_tl_leds_device);
8 m7 D7 H! }2 g& m+ d" Q; f6 B1 P! r0 x# M
printk(KERN_INFO "LED unregister!\n");+ {3 q: i L3 _* ~. U* L
}" F8 D: r; w" |7 E0 B
- _# ?9 ^* p) Z* G! h; }9 n
module_init(led_platform_init);
! r# t3 @9 h* o emodule_exit(led_platform_exit);. G2 Q2 F( k' U! v
6 N$ N9 P8 W8 C* {2 |1 z
MODULE_DESCRIPTION("Led platform driver"); F" i5 H$ T. c) N. f" S/ G
MODULE_AUTHOR("Tronlong");
; y: v+ @$ u G. N% X: NMODULE_LICENSE("GPL");0 h- c, c1 D3 O% P# R
6 D! Z! ^5 y3 c8 P |
|