|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 R8 n( s- Z+ j6 d( C9 A9 p( ~
#include <linux/init.h>: X9 s2 k+ S( c' s+ ?/ X
#include <linux/module.h>4 a: R C j! c( r9 v5 p0 i
#include <linux/kernel.h>
8 l& `$ D# w3 R/ l0 s! B( z#include <linux/types.h># ] l8 h/ Y5 h. i. ]
#include <linux/gpio.h>3 {2 ?, f! J1 }7 l% ~
#include <linux/leds.h>0 p l+ y9 u4 s% P
#include <linux/platform_device.h>: a3 p- m0 a7 ^8 L9 i
. T8 a# ~7 o d& a
#include <asm/mach-types.h>* M3 E( q9 J; _' s5 A
#include <asm/mach/arch.h>
\+ H2 L! M3 C2 Z' P. q#include <mach/da8xx.h>3 z8 J3 k9 n0 C; @8 _8 S7 @; G
#include <mach/mux.h>+ {/ M" C. b, X: q
, ?8 s; N6 ~0 R1 n7 `) G
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 v# Y. g+ \/ i# @! @9 b
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* @ {1 I+ q) `/ ~
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 T$ ?: i' p( t5 t6 O& x3 P, i
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! ?2 w R/ v% a% d) W. q9 n% j0 N+ ?
: `0 ^. o/ E1 I" A- `! u4 y/* assign the tl som board LED-GPIOs*/. a4 k- \+ r) _3 c1 P8 j- R
static const short da850_evm_tl_user_led_pins[] = {
4 l2 a3 v& p# C# f( m+ K* v /* These pins are definition at <mach/mux.h> file */4 s" }: s' b5 @. j1 g" q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
( E5 w3 i" M! X7 V+ t# i0 u -1
7 Q# `! h! l1 b+ G0 S' \6 }5 R};$ e" X' k) k( f) r' i
: m Q: }! {1 i( e1 \- o8 C# W3 D
static struct gpio_led da850_evm_tl_leds[] = {+ f8 O* Q" }+ f& z% i8 T& K
{& [" q" q/ C; @7 F% j
.active_low = 0,6 }5 R6 m# J0 Q4 u# A
.gpio = DA850_USER_LED0,: E& A5 z6 I. L4 q, w( ^. L% I/ }
.name = "user_led0",3 D7 y# w5 w+ u
.default_trigger = "default-on",
9 A; {- x: C7 @& a, _3 q },! l% [* I+ p2 u, R& Q, P
{
% F8 p7 I9 f3 l) X .active_low = 0,
0 Z6 \/ T* W8 k- E; h4 h }0 B4 V .gpio = DA850_USER_LED1,3 N1 Q; o: q2 {# T# W! L) u
.name = "user_led1", t; c' ?( K1 S% [, r
.default_trigger = "default-on",
# F2 M- O/ Z( N! Q( v4 U, ~ }," P* d) O2 z, E+ ]
{
+ P' D) A/ G0 b- B) m .active_low = 0,
9 G3 N" ]9 \7 G* d, J .gpio = DA850_USER_LED2,- U1 x. c. `5 l2 J; n8 r
.name = "user_led2",5 f* H4 ]6 L" l) m8 ]& h8 v; q
.default_trigger = "default-on",
) Y+ C% Z: V( }4 a# k },7 j# o. D1 f/ T
{
$ r( q! x" d& i# l5 U/ p+ P .active_low = 0,! S) w% U& x9 L& {; k
.gpio = DA850_USER_LED3,! O( v9 \) ~9 y( M) c. j- d
.name = "user_led3",: j. {: l2 z: T! S4 V
.default_trigger = "default-on",) [ h* m$ l! L: q) K; F0 d
},& h" |8 W) g" f& k; D$ [" u3 n
};8 b4 b/ Z8 [5 h0 ~
% b7 i; ]* ?$ D* E$ B. Z9 A, Q1 C* Y t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& a4 E! Z1 N7 g .leds = da850_evm_tl_leds,5 [) O6 i6 ] _) V. ^
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 ]' G- P) w7 V$ K, _/ F6 y
};
$ J! _7 X5 T3 L2 ~! s: ]/ a7 g9 e1 ^% n# e: `; ]
static void led_dev_release(struct device *dev)
! p- Q8 H0 Y8 K' Z1 _{* l/ a, |/ A. n8 \2 P$ Q4 B7 e
};- q l3 z7 P3 q+ W5 k [
s$ p- I# ^! Q
static struct platform_device da850_evm_tl_leds_device = {- f @ c) H9 t& z4 b
.name = "leds-gpio",
% Z* X- i+ S; J) A1 p, o6 I .id = 1,& V1 ]8 F9 y, ^+ j& ]6 j2 L
.dev = {
$ G) t( i0 k+ X .platform_data = &da850_evm_tl_leds_pdata,
% t# s: G& O' h5 j9 t+ r .release = led_dev_release,
# t: ^; F1 Q& F! Z* ]. D }
z* l! ^8 ?5 c! |1 D7 F) A};
) {. L/ U8 w, e2 x! e% u/ X
) ?- \1 h8 ^) x/ z- O/ E; pstatic int __init led_platform_init(void)
6 K' _) h7 q( q1 q/ a4 f# g{
- Z! E# `: U. V9 s int ret;
! h Q9 o6 \) H( Y4 ?#if 07 Q8 P. Z1 f5 w! l
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);; c; G- u2 Y+ V/ b' Y: E
if (ret)
" u) Q+ R: ^# Q- R pr_warning("da850_evm_tl_leds_init : User LED mux failed :"# m; z! x! n9 L% M' D5 C! H: C
"%d\n", ret);% V3 b( W9 r7 H1 D4 ~) y- A" ]3 [* C
#endif" z- Q7 M/ \8 S/ {- h
ret = platform_device_register(&da850_evm_tl_leds_device);
3 E2 l# n" E q# y" R if (ret)
1 [) Y) W: N( h8 E3 X- U' ^" X+ C) ?% F pr_warning("Could not register som GPIO expander LEDS");; _0 ~3 V2 @( C; N7 q! H
else
/ l K4 R( ~1 x2 | printk(KERN_INFO "LED register sucessful!\n");# Q; w5 r0 w( g; Z$ `" s
- f) N: W& y- x
return ret;
) X9 u' {/ @3 L" |" }& N7 o}
3 A) {( ?0 b; W6 Z6 ~8 y1 \. y2 q: j6 t6 @4 R& f) o
static void __exit led_platform_exit(void). V" j" a# p+ V$ u A, v ]. O
{- y" s1 I* t! g4 \* R" e# s
platform_device_unregister(&da850_evm_tl_leds_device);5 Z: ]. k) j) z0 _' _9 E& s9 ~$ t
. E6 a$ n. [" i# } printk(KERN_INFO "LED unregister!\n");! C; h' f s# u
}
% K" Q7 \; A: z& L/ A
- T5 j7 D6 m, g% x0 `1 r* ]& Pmodule_init(led_platform_init);' A0 `# ?8 @& x, l! ^
module_exit(led_platform_exit); h: Z9 z& }. ?; E9 n
& G0 ?5 i0 }2 ~0 I0 VMODULE_DESCRIPTION("Led platform driver");% D9 m0 e) Y }# u
MODULE_AUTHOR("Tronlong");6 v( j3 C& D+ W2 x# ~' a
MODULE_LICENSE("GPL");
" H# E5 {% S% x7 Z" G- e# |& P: M$ Y# Y( |* M s/ ^( i
|
|