|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 G7 |$ X7 i; E
#include <linux/init.h>$ y6 s: J7 |3 m# k
#include <linux/module.h>
* D/ A; `3 R) A: m9 A% N$ j3 A#include <linux/kernel.h>. s; [ o6 ]$ V
#include <linux/types.h>% A! X g% D, b4 y
#include <linux/gpio.h>: X2 s2 B* a" v! c& r
#include <linux/leds.h>4 E3 x4 P' g; w
#include <linux/platform_device.h>
) j+ X& P. V/ R" x' L
) ~! l5 A# n1 G#include <asm/mach-types.h>
: c- H" ?2 ]; u: R# X% p#include <asm/mach/arch.h>: [: i, T$ f6 P4 ?4 ?
#include <mach/da8xx.h>
, ^+ o2 G- r) P5 G#include <mach/mux.h>
" `9 B; n* B$ _3 x7 ^
! j6 h- E E' ^: |4 d#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ o/ P# J0 W0 h" H1 ~6 ^( W/ |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 S8 ~% ^; d! h3 k) n+ o/ u
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
1 _& S/ H2 M9 c$ Z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 I$ q$ |. C' x; t! _! Y6 f0 T# D! l% K ?) k
/* assign the tl som board LED-GPIOs*/
8 K+ [7 v; O- A4 Astatic const short da850_evm_tl_user_led_pins[] = {5 j' e* S( S& C4 e( Z
/* These pins are definition at <mach/mux.h> file */8 }. A. }" e- R1 \5 n. t& \
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# D$ m9 `2 v* A% i5 m B+ M, P" k2 _$ o
-1" A6 D. Q9 S. V! r
};
! I) H: Q- E" g' `, L8 ^, w8 E& M9 ?( e6 J0 y" K0 u
static struct gpio_led da850_evm_tl_leds[] = {
5 ~ W. v: _3 l4 @. W! V {
: B/ ~7 _7 Q, F .active_low = 0,
5 p0 i, u1 Z$ a( X .gpio = DA850_USER_LED0,
) N- R+ n8 }: h5 K D .name = "user_led0",# z2 J6 d6 l" ?. E
.default_trigger = "default-on",! \5 ]/ X$ L9 P+ a
},/ A3 T7 z. E4 P6 T
{
. f9 _4 R$ q8 c* t3 t .active_low = 0,+ y! O2 y" r6 u
.gpio = DA850_USER_LED1,
) Q. Q0 D/ E# T, b .name = "user_led1",* D4 o! \2 k T n( M) T
.default_trigger = "default-on",
; o: ^0 b. ` ]/ D8 C },& T( h3 A) w/ y$ |- Z: @6 M/ z
{
1 E3 o- K' O+ G .active_low = 0,9 d6 x2 _7 y" @# k o
.gpio = DA850_USER_LED2," W7 b! C" F2 q6 D, M
.name = "user_led2",
+ J* f# } e; L .default_trigger = "default-on",
& [6 t0 ?3 Y- g5 B },/ m2 j8 e# R6 X7 s0 D$ c& o3 z- l* _
{ o$ C2 G6 _4 P1 T2 G: \
.active_low = 0,
4 z/ ~* @: N, z+ T .gpio = DA850_USER_LED3, l, _& H: v) L& V, G2 P
.name = "user_led3",
8 p8 b1 G9 ^. e& y2 r( z .default_trigger = "default-on",7 i1 M9 v/ _& e) n" s
},& S$ |8 y1 b& h4 a2 u/ e* s
};
6 X) J1 Z% M* z8 K$ y) k8 l( j C: x O$ `% x5 K2 i' |( v5 t* O$ c( s! }
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ U6 e d8 u, I( s, ~2 S
.leds = da850_evm_tl_leds,4 F8 c2 |# N& N5 l8 o4 b$ U
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 J5 s, [! E1 X) H};' l O( S5 _) M0 t. E4 ?
* r0 H. x r$ }2 b; s" w: Y
static void led_dev_release(struct device *dev)
1 C9 Q3 M. @. W/ z{# |+ J4 c, t5 _$ P
};
+ G4 q8 V" X! A7 }
) J. S0 |' G0 U% p, b: Sstatic struct platform_device da850_evm_tl_leds_device = {2 {+ {# ?. h% a C0 K! A
.name = "leds-gpio",8 w+ t( a+ O. T7 L1 h. ?8 Y
.id = 1,
" i& y1 z, f& R( } .dev = {3 [/ \0 j7 C8 n' i% q1 {
.platform_data = &da850_evm_tl_leds_pdata,
1 c2 a1 i7 V& V* d .release = led_dev_release,
, ^( ?# b& J3 d# p8 q8 n }4 c/ x) o6 `0 E H4 H3 O8 n
};, i0 U* |9 R$ t
1 ~( V% H4 Q2 }- _: z$ j3 I9 G
static int __init led_platform_init(void)+ i- j z$ r# R& O# k
{( ^3 V# a$ D$ G! M
int ret;! N7 A: \6 `/ J+ |6 @- _! ?! W
#if 0
1 ~- p- J( ~2 \0 N ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ G* t8 E4 |: K% N% g if (ret)
% y/ K1 M: ?4 v pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 w: H/ Y" }$ v9 m+ d
"%d\n", ret);5 j8 A. M) a* u9 ^& p+ b, t
#endif
6 B; W5 |5 N r) Y ret = platform_device_register(&da850_evm_tl_leds_device);1 [% u" Y9 _0 ]( [+ e, O+ i
if (ret). L6 R$ T w0 S9 ?2 ~
pr_warning("Could not register som GPIO expander LEDS");. W; {- \8 j+ }7 W' m% g$ w
else u! R/ T" z( F+ C- c5 L w# a
printk(KERN_INFO "LED register sucessful!\n");5 A* o& l, W5 M* \0 ~ R. J
2 G U. B/ G" w
return ret;
) H R5 s. v; p}
& `$ A2 b8 j# _6 P7 }9 X' @2 l1 Q0 ?4 X; P, S% ~0 g5 O) R- b
static void __exit led_platform_exit(void)7 A/ p9 T* @' l
{0 E) w9 w! m* y# _: z
platform_device_unregister(&da850_evm_tl_leds_device);0 d/ P0 Z" A% K& B- \9 R& B- f$ Y" q
3 ?3 h6 }# F. p3 I2 x
printk(KERN_INFO "LED unregister!\n");& s7 q8 U5 B% |2 O6 ^
}' Z: i" @4 y5 I
5 `2 f& L& d: ?4 P9 Rmodule_init(led_platform_init);
8 o- l5 U9 G& s8 [* M/ amodule_exit(led_platform_exit);0 [& ?1 I& q' e1 }2 L# C3 H
1 q B! R7 I/ I" J) X& R7 cMODULE_DESCRIPTION("Led platform driver");
, m& [# k L: j9 YMODULE_AUTHOR("Tronlong");
3 m6 m9 u- c5 m6 HMODULE_LICENSE("GPL");6 X% H; ?3 Q. T5 }1 I
) k' M/ D: n3 U- | |
|