|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( y2 ? C1 D* ?/ r1 G; ?
#include <linux/init.h>
) O. ~4 O; m( R$ Y#include <linux/module.h>
3 V, T- L0 d& K" X! m) v#include <linux/kernel.h>$ n4 G0 T, ?. {3 }9 d
#include <linux/types.h>
7 O* X ?1 B4 P4 `5 \7 M* W#include <linux/gpio.h>; E9 i8 g3 a& K! S2 D! B/ k
#include <linux/leds.h>
' t P8 w7 V5 [$ s/ C#include <linux/platform_device.h> P! p' B) S: L" p7 K- g
6 ]2 e5 Y8 O% x% W. O5 ?
#include <asm/mach-types.h>, }# O2 m3 I' B+ v
#include <asm/mach/arch.h>
! v6 F) N0 {4 x#include <mach/da8xx.h>
. Z9 @; u; u4 R1 ]' r6 w- r#include <mach/mux.h>' v* W- n2 n% h9 ]+ t' c8 Y) R' ]' ?/ X
( f( B2 @: S/ y/ y! Z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)( |/ q8 t1 M8 M6 {3 e2 b! a/ t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* z2 K- C- Q3 j" b
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 n3 F! `2 `' W#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( \3 X) D x+ S( c% J5 ~0 v! W. z& R' `& r0 U& Z& k+ [
/* assign the tl som board LED-GPIOs*/
. G- P# `5 b5 ~* L; E. cstatic const short da850_evm_tl_user_led_pins[] = {
; e) }+ \9 K: u, a$ _* u' ~ /* These pins are definition at <mach/mux.h> file */ m3 N$ c2 Y( {1 {* Z5 ?
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( u' p9 `7 E( F2 T! Z8 H
-1( Y6 E6 ]* H w( @) |9 ^
};4 _) l& O% P: v; P3 H
9 F" _' L: B; r# p- U
static struct gpio_led da850_evm_tl_leds[] = {: Q& D4 C: a$ i9 }
{ d7 R$ V4 [5 J) B
.active_low = 0,
) O9 [6 `3 h' ?& D* t .gpio = DA850_USER_LED0,
6 s4 p; s/ o$ X9 v1 ]/ x .name = "user_led0",
- w! o/ b; e, T* d .default_trigger = "default-on",- h: t3 R8 n0 {; A0 s& V
},
% u3 L% r' M+ p% F0 m2 a' ]1 ^) s4 z {
, u. r0 S9 @3 g/ Z$ c8 {" a .active_low = 0,2 Q7 R1 C" X; g: a& N
.gpio = DA850_USER_LED1,/ i" f5 g% E6 c" _) v
.name = "user_led1",
, b. u! u) f$ f6 Y8 M .default_trigger = "default-on",* J q/ S9 G9 Y
},) m6 |2 O" {; g7 F
{
1 X; V: L' J# Q5 u .active_low = 0,! |# C6 c$ p1 E' W) q" p
.gpio = DA850_USER_LED2,
5 A' \+ @; |" Q2 T+ a .name = "user_led2",, U2 [5 h. R8 ]; L4 ?" q6 D- |
.default_trigger = "default-on",
/ [# U" C9 ]7 J7 q$ E: q },
2 L( E: T1 u9 o! h& M( ]1 T {/ \" k0 Y+ q+ t4 Q' b9 {
.active_low = 0,5 f- V! {9 n! R$ E
.gpio = DA850_USER_LED3,
$ w1 x& V4 O5 X/ w9 l# t- U .name = "user_led3",
' ^) I" o E/ I R' l .default_trigger = "default-on",
! Z0 D) v8 O M, m },3 i+ g7 J2 X! ]/ a9 O
};
, D7 g" |' P( H0 H9 Z+ f+ z. r- |( R! U; B- f
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! r w1 \/ G" |; s0 C# {0 f
.leds = da850_evm_tl_leds,
1 w% |7 I9 F# j V$ r' n6 R .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 M' P( T9 e7 B/ e
};
3 ?, a; V4 [. i, Y" j3 f5 o6 ^3 E7 i
static void led_dev_release(struct device *dev)5 i+ O! Q, P, ~& v' X3 ^, K- g
{
. t6 H7 H# L' r};) ^+ P4 S1 d( K8 d5 l& r% L- Q
( ]& j+ t9 o7 N0 ^1 P6 ^
static struct platform_device da850_evm_tl_leds_device = {
* P B7 F9 n2 k) U; U) ^. k6 v2 M, L .name = "leds-gpio",
* H7 N8 U! _! Y6 O .id = 1,& N9 F: u {& f4 c
.dev = {, F5 b2 i# q0 m$ l
.platform_data = &da850_evm_tl_leds_pdata,
& B" @6 z t+ n2 _, V .release = led_dev_release,7 T- x8 F5 y+ [* }, t
}
5 f% {; m; [7 b, J; o* ]4 x};! M( f. z) C2 S
K+ @4 u6 c' ?& m. o0 k, X3 E1 u! W
static int __init led_platform_init(void)7 \1 U) u/ ]8 G/ E" W
{
" V' I% [ ~3 x& F( l: ^- l+ c& E- B int ret;
* `+ W& P- j; Q/ p! f5 D#if 0+ `/ i3 ?3 ]7 s# |7 g% V+ O
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( r$ B# V6 X% T9 H if (ret)
& K7 ^; m3 E" o pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ h7 M x; Q/ {, X
"%d\n", ret);
/ J! n" @" q; N. k#endif2 M' g9 s1 M; F. t! `$ w+ W
ret = platform_device_register(&da850_evm_tl_leds_device);
1 w7 `' d* D; w0 k/ Q" c. B# Q- y if (ret)
& ]1 [1 }$ v. v% G pr_warning("Could not register som GPIO expander LEDS");
0 j3 V3 S* n; m8 L& P else
7 `8 l* h0 P$ Z. n3 |5 {; x! n printk(KERN_INFO "LED register sucessful!\n");4 l) `) x" V9 }& L. r$ l& H
L" E3 b5 S8 A( Q1 H [
return ret;! m# U( P5 P9 c) M3 [
}$ z+ y$ b0 D& m; e3 W. c* s
: N( k/ n, t) {$ G" {
static void __exit led_platform_exit(void)4 L, Y( Y& z% k9 P. u$ q
{
( ~( h) K% P2 [* G# Y platform_device_unregister(&da850_evm_tl_leds_device);8 I! q7 M, \8 b4 X1 t6 c" z" H
+ e. F6 ^$ w) B: h2 g
printk(KERN_INFO "LED unregister!\n");- |. f3 U$ O6 T% `' V6 k& ^
}
+ Q( r1 V" M, k3 |
5 K/ U' R, Y/ B5 Z3 u4 hmodule_init(led_platform_init);
2 p3 e; {2 q# Q4 vmodule_exit(led_platform_exit);
/ n$ E) K8 {5 C) e/ j" d
: {. Q8 L/ x! o! e# U* @MODULE_DESCRIPTION("Led platform driver");) ?9 ? g) D+ s
MODULE_AUTHOR("Tronlong");
9 J- {' o) R' {0 R* w; I- c: }: ~* ^, r. FMODULE_LICENSE("GPL");
9 f! [& v P% \. w! C9 y6 f: D
) k, w1 v/ D% j+ j" W$ M6 e& l |
|