|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, C% L% s" H! ]! \5 g( }
#include <linux/init.h>. n9 W) V# a y s/ W
#include <linux/module.h>- M, G1 U+ g0 A' V( m
#include <linux/kernel.h>
' K1 P) ]! p6 G#include <linux/types.h>
$ u+ }8 z5 M8 R- L3 |#include <linux/gpio.h>
$ P- |. B$ P' P8 X. w#include <linux/leds.h>
+ ]) i) y3 `/ f9 _: a* K: R; v#include <linux/platform_device.h>
4 R3 c! s' m9 E6 U7 B
6 {' b! b- g C#include <asm/mach-types.h>: @) ^7 E" [0 Q$ @7 _( }
#include <asm/mach/arch.h>
' D5 j% i1 a- y( |# f. x/ k#include <mach/da8xx.h>
8 a4 s1 |; j: y. X#include <mach/mux.h>
: N9 O3 {( j7 r
. h: U, D b7 Y$ ^9 [. m#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- v+ [: T8 L+ j#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). t1 u2 ^7 q2 W6 E$ H9 C
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 ?' \9 }9 Y/ t( |! G* Q$ P
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# U" y$ T3 z5 p" E' N& _9 p7 D a- T- m, O6 e
/* assign the tl som board LED-GPIOs*/7 V" ?4 s1 ~: ?7 a% M% J8 [0 W
static const short da850_evm_tl_user_led_pins[] = {
T# I, L1 }( W9 q( m7 g /* These pins are definition at <mach/mux.h> file */
; W3 K; x8 ~4 @+ T/ m( C% J: O4 d) X DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" C. Y! ]" e! S3 O I -1$ R; K! T& l7 R: _ {: v+ C- N, q
};, K7 P7 r$ I1 L
* o; z2 S. S5 ^9 q" a; y
static struct gpio_led da850_evm_tl_leds[] = {
) d( N# a# r& W. g0 ^% o1 ^ {" u8 R, o$ i+ s
.active_low = 0,9 F3 n" s+ b, z6 T
.gpio = DA850_USER_LED0,4 \) n" s: }7 h- y$ D; U
.name = "user_led0",
9 c x- g9 U1 p1 y) ]1 H. G# L .default_trigger = "default-on",
* Z6 e% j Q5 ~& M( F9 P },- e* \/ s% N3 ? X
{4 v& ]; Y+ u. _7 R
.active_low = 0,
- ^* o' s, L/ ~0 \* _/ h* {0 K .gpio = DA850_USER_LED1,6 N0 [ v; x6 |& b
.name = "user_led1",; P* H: ^7 Z: s# ^ V% R
.default_trigger = "default-on",
" n) ]& j ^% o6 E },& p7 c8 [: ?) g C" e
{
) b; x7 E9 A# x ~: S1 n, c7 v .active_low = 0,2 P1 ~: n8 f8 J) d
.gpio = DA850_USER_LED2,
* I' M/ P: k* e s4 E8 T* a .name = "user_led2",! i2 \9 J! a# {2 O
.default_trigger = "default-on",
/ E4 [: R$ Q6 P1 ~& [' F },
0 J- k6 X5 v4 f {9 e7 C. V) f( Q8 J( C) f' [: X+ L5 a
.active_low = 0,
6 s/ [0 \3 E1 i* X# D% o .gpio = DA850_USER_LED3,* J) d P9 E' J7 \
.name = "user_led3",$ Y2 g Z! m/ l: N( @
.default_trigger = "default-on",2 T" P0 [( }) s4 [- E. k7 f9 W
},
: X9 u! r& H7 A: q, R R# o: {};& e! L/ v6 T* h1 Y1 q
5 D9 V; Y) [$ wstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" F: J5 \! h! I' L* F" x; J$ d, i
.leds = da850_evm_tl_leds,
' k' m2 o, h% ^, D .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 r# a) s# ?" j0 b! [) I
};
( l5 ^9 K' W" v0 V7 W0 i% L" J% {2 }& L
static void led_dev_release(struct device *dev)
9 o4 E1 y+ ?) p# L8 }{9 D% S6 E9 Y# `, R( a* n
};5 q" `' N/ q( L% G% K
& y/ D y3 {# I; a5 @* c7 r
static struct platform_device da850_evm_tl_leds_device = {
J9 {/ f6 g$ h& g .name = "leds-gpio",
) ]& z. e& [* k2 C1 P* ^ .id = 1,
6 b, S% Z2 r1 i .dev = {
) m: H* o8 m6 L" K .platform_data = &da850_evm_tl_leds_pdata,
$ i- m* ? v( Q, T3 t .release = led_dev_release,4 e, X* O! o6 _
}
+ U7 k1 t- \ T2 c! ?};+ p( e6 X2 ]& `; @
" p* U# [& n. v
static int __init led_platform_init(void)5 P4 e+ u) k( Q" x
{5 E$ c5 i7 h! S2 [" _! P( g
int ret;
; a/ j8 @! n8 y! p& O#if 05 C ?1 P. R- p: k0 `6 w) r2 r
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' a' D) _- |2 ^: K8 o if (ret)! v: t& \' S# D) B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* u7 F- O, q% Y; C
"%d\n", ret);
% [( ]+ o" B4 ]: F' R" A1 V#endif9 J$ \0 C. E Y% f0 i
ret = platform_device_register(&da850_evm_tl_leds_device);" Y) U( ?0 |2 u5 e' ~
if (ret)# t' C$ i" b: ?7 g
pr_warning("Could not register som GPIO expander LEDS");2 v. X1 x1 |+ B+ f
else8 A* {) t, @* C* ]
printk(KERN_INFO "LED register sucessful!\n");
3 w$ a* B. H* D- ^2 C
# O) z# y" M; x1 j! {7 q4 | return ret;
& k3 {) _, N1 d# d* N$ F! b}( |, p# S' B* z2 O) l
9 d6 m1 {" `3 o1 \& h# S% z3 K L
static void __exit led_platform_exit(void)+ X1 [) L% p; ~4 J3 p
{
' o$ R! _, y$ D2 j9 t& N platform_device_unregister(&da850_evm_tl_leds_device);4 Y; ^- l0 B% ~% D
) x2 K8 r6 v* _: H4 G) L printk(KERN_INFO "LED unregister!\n");/ b, {( Q: P: z, f' [
}6 F% e" ^/ ^' m( q j9 j
6 e: r( o {9 }" @& Z
module_init(led_platform_init);% A9 n) T4 G& a2 N
module_exit(led_platform_exit); P3 p6 r# Y. U: I) F1 o
+ ?7 M$ {1 \2 U t# D% M+ F+ a
MODULE_DESCRIPTION("Led platform driver");1 V7 h, {) R4 z1 T7 _& S
MODULE_AUTHOR("Tronlong");) C- g5 ~5 ?, u! ?0 W& F2 B
MODULE_LICENSE("GPL");( ~$ M, a9 | y# L0 z6 y. U
- q" \6 F6 M5 j+ y) } |
|