|
|
求大神给下面的程序做注解,请稍详细些,谢谢。6 Y0 t8 ?1 Q3 r8 n0 F
#include <linux/init.h>: [( @, i6 r6 a$ E% v& [" D
#include <linux/module.h>
, u' O: h" Y; J' r3 {/ |#include <linux/kernel.h>
. D& B' ^( m1 n( |" ^; E3 m4 v#include <linux/types.h>
; m' h: g3 |9 h8 j& P" c#include <linux/gpio.h>
$ o9 u& x) A, J( J#include <linux/leds.h>
1 Q6 Z: Y8 F# f#include <linux/platform_device.h>
5 ?5 K$ [+ c. }6 ^$ A( H4 o) S$ e$ n7 j, w# |. d: T" P4 Z1 U
#include <asm/mach-types.h>& L, t" U7 i7 ^4 u$ ^, M- x
#include <asm/mach/arch.h>3 ^, E7 H, L3 @+ L7 l& N
#include <mach/da8xx.h>' _3 C1 `; o+ v0 k, o0 P
#include <mach/mux.h>, r( d, ^' y, ?3 a- Y
- y0 j" [* n/ v9 A#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 r1 `4 H" h1 b$ A( E3 a#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): V, u3 J* S9 C6 g$ m6 g
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- ?. t( U2 @8 L& w& s8 O7 M#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ a L* Y' @! ~6 J4 k3 r
" d6 E, _) M+ q+ `0 X/* assign the tl som board LED-GPIOs*/& u2 a9 r- a( i6 g$ [& }/ G
static const short da850_evm_tl_user_led_pins[] = {$ U4 `- i$ y, [) w
/* These pins are definition at <mach/mux.h> file */ Y. M) j6 f: Z. e& r
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( N# q+ E9 h" ]# _
-1
1 l* L+ |% D7 T, b};2 g0 {9 S1 X8 A+ T0 n0 j+ W
+ _$ M; A& c! u: H G6 I& d( Jstatic struct gpio_led da850_evm_tl_leds[] = {
. b K* O6 R0 F9 L; { \8 v5 X {
2 `+ K1 k/ C5 W7 |' X3 r6 i4 d .active_low = 0,8 a* s O* u5 `" D4 {
.gpio = DA850_USER_LED0,1 a7 v/ Z/ {7 u. s# e
.name = "user_led0",
: H3 q- A0 T" _+ g Y) A& E% d1 \ .default_trigger = "default-on",, ^8 o" O- @- P: p9 T6 T3 @1 f/ p- a
},
5 f* s3 j) w, B {
' P g/ C" j+ W% H# ` .active_low = 0,4 H# X& Q; B6 I: R c; f& k
.gpio = DA850_USER_LED1,
- w- b; o4 }6 W; \ .name = "user_led1",
+ {6 i0 f2 \* g' U: A .default_trigger = "default-on",6 C3 s/ m5 \8 ~
},9 \. j' W V" C
{$ L( g* y3 Y2 A. p
.active_low = 0,4 k" t% l4 t6 L# o( x1 d
.gpio = DA850_USER_LED2,- E4 i! C. n( N( {8 D5 g
.name = "user_led2",
$ W7 w) u+ } N6 U( z .default_trigger = "default-on",( d* J, a/ ?& j/ X
},
) X* N' T+ n5 M+ _: h {
' d0 Z7 m S b+ I .active_low = 0,' E4 j) {, e9 L; k
.gpio = DA850_USER_LED3,
0 Z( R0 A3 u2 k9 a6 n7 y) g .name = "user_led3",
# y% O! i/ u9 `9 X8 ~; ~! N .default_trigger = "default-on",
: Q) A% P& X: ]0 f },! v; F1 f1 F( {' V' n
};( a1 @$ c! z. t/ p% C* Q& Q) R
9 |( k' b& O% S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
& c1 I' U. b5 p a2 L4 S6 I/ e( c .leds = da850_evm_tl_leds,
' ?0 Q0 ?8 h9 R! I/ @ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),9 e! i- h1 I% \3 r( o
};
' ~# e3 c9 u) }: G1 x: ^6 n) b+ B, k$ P( Q* Y! A" \& G% H
static void led_dev_release(struct device *dev)9 K- n+ l u! A1 H6 S, F. O0 g
{: R" Q' k( N# L
};; x- c: R# a0 {% W: p! \; ?
1 q) L) U8 i& I [static struct platform_device da850_evm_tl_leds_device = {
1 O! R* E& z$ D$ @% S! i) _9 ^( r/ C& } .name = "leds-gpio",
5 a6 d; M. C) n) D .id = 1,
4 d' D# w9 h v- P* x* T .dev = {
, v* |2 c T9 a" Z' G; _% q" C) w .platform_data = &da850_evm_tl_leds_pdata,1 w. H! V) f; s, u; b
.release = led_dev_release,; ^+ c& q! @. ]% \
}
' k/ z5 J( B) t' G};
4 R& N. X' k9 f, O6 ]
) [5 f. @$ H1 M$ n3 r! W- \ Lstatic int __init led_platform_init(void)
6 s4 Q% L$ M' i$ P8 S{
- e/ B7 O( N$ s# {$ A, O8 n+ y# h4 @ int ret;, f. y2 o( P1 i+ M; j
#if 0
# h W* ]$ {. S6 P3 w" a4 J- {' r! J ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 U( R0 m, H7 K6 x/ U% [ if (ret)
) B* f. H5 [$ s4 f, \2 W, \* t- b0 S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" |* C' t/ d" Z- o# F7 S: ~6 L
"%d\n", ret);
$ n9 z' D1 {9 q7 ?, ]#endif/ D) v+ X2 y. S) l
ret = platform_device_register(&da850_evm_tl_leds_device);
: `# C3 Q2 t6 o& n+ v5 H1 L if (ret)4 O4 u& k9 G) }. v2 n' L
pr_warning("Could not register som GPIO expander LEDS");
5 V5 b" h$ H( q# I: ` else
* Z r% ~6 p0 f$ _- w: v2 G3 j' `5 t printk(KERN_INFO "LED register sucessful!\n");
* r" a/ S/ d i
+ r. L* W* @+ _ return ret;" K$ H9 Z/ H5 |
}
$ a$ u. L, b. Q' I7 y( K) S# ]. p" q: v: a3 E$ m$ V/ D% {$ k' }
static void __exit led_platform_exit(void)+ J6 d8 q$ d/ @8 M8 B* V
{* e( z5 S _: f9 D+ H3 d
platform_device_unregister(&da850_evm_tl_leds_device);& t' S5 X0 {5 t
8 f: z& B5 t# K' }/ B printk(KERN_INFO "LED unregister!\n");. s2 d/ P2 R+ Q+ m9 ]
}6 @1 o i% Y2 k0 j' v
X9 e4 n+ H" M. f, H
module_init(led_platform_init);
2 `' N1 i) H( O% }9 H6 O; [module_exit(led_platform_exit);5 w6 M4 U: }) o8 V5 T/ b
3 h! A+ P0 Y: d DMODULE_DESCRIPTION("Led platform driver");& v; p7 b0 O& d
MODULE_AUTHOR("Tronlong");+ b H" m6 t8 Z/ J' B
MODULE_LICENSE("GPL");
5 y8 n8 V, A" d k0 y! H& ]' e; a+ I* o
|
|