|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ X! G$ Y9 i1 O; U: m' c
#include <linux/init.h>
5 s/ g R5 ?1 D- `#include <linux/module.h>& L' k1 w6 |# d
#include <linux/kernel.h>
. n0 v. B C1 U7 t ?) M#include <linux/types.h>5 C" s; V B V. [) h
#include <linux/gpio.h>
- G) d7 V" {1 w( N, n+ A#include <linux/leds.h>. f K f4 k; C$ M" l0 ]" [/ X- ~
#include <linux/platform_device.h>+ j" L2 x! o7 u# }) S
5 |3 I3 k- Z* T& S; Y& L
#include <asm/mach-types.h>
& p6 x7 d% D# i; `) z6 {0 }#include <asm/mach/arch.h>$ ~3 z( \( m! Y; }
#include <mach/da8xx.h>/ V7 r) \4 B1 P, x/ e% G
#include <mach/mux.h>3 ]2 K% H( b* y0 o2 R/ j
9 c' V! R# L9 E1 m# q; q/ C5 Q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( Q+ K9 E" ?+ [0 W5 e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)& d0 U3 \# ], L; z2 d% @( D$ y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
' r6 c5 r& n' P#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ I( i: o( w$ r1 p$ i5 J, ? D) ^ Q( `2 V# a% s( P3 n
/* assign the tl som board LED-GPIOs*/$ Z) X. i J$ ~' [
static const short da850_evm_tl_user_led_pins[] = {
2 e/ ? x- w+ P /* These pins are definition at <mach/mux.h> file */: r: ]' c) t( }6 M J6 k l/ x. r
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 a4 ~' K3 G8 {. Y
-11 k2 m9 f! s: O7 @, `+ q( M+ s
};+ a+ H3 n0 l4 L! f/ l% J
6 b& s3 Z4 V% x& U4 n/ V1 Zstatic struct gpio_led da850_evm_tl_leds[] = {
. y% n8 v" B( o9 E {
0 i, [( s' r1 v$ L4 U" r( I .active_low = 0,
; F K: l* |/ }8 s6 o1 O .gpio = DA850_USER_LED0,
4 O+ Q/ ?# y# J5 r- Y# P H7 | .name = "user_led0",
: b5 e0 c4 x) m .default_trigger = "default-on",; C) k9 N# H2 g
},
4 l1 n: H- }; L" Q) ~ {) B- |8 d& A1 g
.active_low = 0,
# V( A0 q6 \- [" e) m4 F .gpio = DA850_USER_LED1,' V, |' ^9 |4 z1 S, M/ U
.name = "user_led1",3 r. L, S6 i$ M0 x- P+ j$ o
.default_trigger = "default-on",; q+ Z) J" Q: `- Q! i
},
- Z1 \6 x( l7 V" c9 G. p' e* e {
9 R3 x2 j, O8 {+ x" V* T .active_low = 0,9 ~/ @- t5 Y0 w" I0 R( h6 h" q& C
.gpio = DA850_USER_LED2,8 B1 w* d S9 ]5 V& o
.name = "user_led2",
( q9 _8 {7 y5 m& \8 l .default_trigger = "default-on",3 C& u# ^6 c* E
}," o5 @: x1 g/ r: i# u$ ]
{) J5 a3 ~. b. z( R
.active_low = 0,
4 c, M; p7 w B1 ] .gpio = DA850_USER_LED3,
3 [1 D; p6 I/ ~( l/ d .name = "user_led3",
7 P' H( d, K* ^/ d .default_trigger = "default-on",
- C1 ]8 S X4 Q8 ]' e) a/ v },! e9 E$ D" O0 n9 p) E5 T
};
: L# U7 H% J" _8 t4 p! S8 W$ F% n7 ?% Y0 P) L0 {2 G9 n. k
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( L, A- I' J' q6 t1 @" p0 Y
.leds = da850_evm_tl_leds,
) d( e, `& s. `' T" Z6 } .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 l9 Z% S/ E. Q/ {6 o};4 [* c/ [, e' ]$ A! q3 w
2 _, Y, z- j; M/ M- Z$ Z+ [
static void led_dev_release(struct device *dev), n8 ~; [" X G# L' Y
{
" U3 D; e+ k U) z9 t2 |8 ^};
8 `) y6 J% M5 |6 q2 L% b1 }
( b4 N; r9 Y& ~8 q+ j' r# [$ lstatic struct platform_device da850_evm_tl_leds_device = {/ S \( X/ i5 O& k3 F+ i
.name = "leds-gpio",
$ Q$ ?. R& a1 s6 @1 G/ Y .id = 1,* I6 v% L) H8 s9 Q! `
.dev = {
3 V* X. M6 x% r; ~6 J2 m .platform_data = &da850_evm_tl_leds_pdata,
! D0 ]) O/ I5 }' } .release = led_dev_release,
$ Z' w! X S. z }
7 J6 U+ M, r( M8 W% b$ ^6 g( i};
# d- J; M) i/ k) H" W
. S1 H: e+ i1 A- n: F/ ]static int __init led_platform_init(void)
7 l3 Z/ o" ~4 o+ z8 g/ Q7 N1 [{
; N2 j" F+ t$ S' n int ret;7 c" ?7 q$ [* r) S# {/ y0 S5 ^
#if 09 k- X" d% n% V8 g" Y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 i! e: Y1 `$ p8 L0 e; D1 p1 \
if (ret)
) f. q9 y5 c Y+ u4 J0 s9 K4 C pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" d* ~& G" @; _( f! D1 O2 q1 ?; v
"%d\n", ret);2 X1 }( k4 x, `2 y# z- }
#endif8 Z7 E3 \8 d* L9 K& ]
ret = platform_device_register(&da850_evm_tl_leds_device);
7 P+ z) N Z# O$ f' A if (ret)4 N4 D* t* b+ F( _% G
pr_warning("Could not register som GPIO expander LEDS");
4 g6 e* l# O1 I! e; _5 m else; P1 Z" N1 i; ?1 d! b! H* w
printk(KERN_INFO "LED register sucessful!\n");8 p% m X0 e, g8 ]; N
* v0 d& v( }5 Y) J9 w h return ret;% b/ S; t2 M# c. I# A+ i
}
! u9 w0 J+ k1 }1 q7 a( _4 r. q5 Q+ U) U+ C
static void __exit led_platform_exit(void)
3 Q5 Z$ F0 a. {{
( }0 |5 v# }4 W/ H% J platform_device_unregister(&da850_evm_tl_leds_device);
, W/ P. C W; R% n b Y6 h! }, F. C- t9 b! Q1 R! Q
printk(KERN_INFO "LED unregister!\n");
9 |& A6 x7 ]2 S" P}
5 P4 ?5 K" A7 u, Y+ I" j$ z
6 z2 }" S5 S/ I+ D) Mmodule_init(led_platform_init);
' ]% p! h8 ?( I5 Nmodule_exit(led_platform_exit);
6 {; w$ ?; p0 I0 ?
( G( K( L: R1 n4 }! VMODULE_DESCRIPTION("Led platform driver");, b$ P5 c! `2 I5 R7 _1 T- @
MODULE_AUTHOR("Tronlong");: J$ l6 o* }# G [( h# B& y
MODULE_LICENSE("GPL");6 G+ `+ D+ m3 f- Y
8 j8 x- L. N4 i6 L7 y6 @+ a R6 v
|
|