|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 _: x) W; v5 V' k" Y. I0 N( s#include <linux/init.h>- }1 o. W1 C- G2 i# U
#include <linux/module.h>$ s4 h q0 }9 h4 b& ~
#include <linux/kernel.h>
, E& [2 K7 v/ A, o#include <linux/types.h>) `1 }- p" `$ q$ C7 n
#include <linux/gpio.h>
$ _. }/ c, A- ~3 }$ R#include <linux/leds.h>1 Z8 J1 c& s7 b( S- F- D7 d7 C
#include <linux/platform_device.h>* O; D# A9 g/ g! N7 X6 p
3 ?4 P# ~4 H3 r/ l8 K7 k+ b: C#include <asm/mach-types.h>' e% Z& q9 W3 F J; @
#include <asm/mach/arch.h>6 I& a/ G. t* B( {- V
#include <mach/da8xx.h>8 s, ?# |) F& p
#include <mach/mux.h>
) @+ A c* K/ f$ [4 E
2 ?( m: M! b5 f9 u& ?$ }#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; U7 ^8 o: q% c$ v$ P* G; V' Z. N& v#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% j7 ^2 }1 S# |6 y5 g3 M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 t9 E2 N* I, i: m
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) O/ K* G$ b z' P
% d" O6 B8 d* V/ P4 }/* assign the tl som board LED-GPIOs*/
7 e; c5 @0 _' _+ ?' g" @$ vstatic const short da850_evm_tl_user_led_pins[] = {
8 z+ u6 o4 Q3 O, E2 M /* These pins are definition at <mach/mux.h> file */
, z" u; ]4 _8 K6 N' q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 M$ g# }0 M# R$ Z6 W1 j6 |0 d! M -1
$ f" C( _% `; F. G};
* M7 V. B0 w0 ]5 V/ C* s
9 x! @' T6 G8 n) Ostatic struct gpio_led da850_evm_tl_leds[] = {" t# {' V: l% C$ A4 ~* L- }
{ ~' s: g( t" x5 G w! U
.active_low = 0,; M- B5 K( M' {2 u6 g7 e3 g: ~7 [
.gpio = DA850_USER_LED0,3 o, Q5 R5 E1 z* o+ N
.name = "user_led0",
$ W4 b e3 @4 E1 ] .default_trigger = "default-on",
: F/ ]% \+ z, l },+ f0 `* w+ L+ e, j
{
7 |9 v. L6 l5 I5 B# O/ R1 d .active_low = 0,
' h* a2 q1 m3 T% i/ Y .gpio = DA850_USER_LED1,
" {" a- a; B! ~) h5 {9 n- B .name = "user_led1",
0 l, O% U/ b& w5 z4 v .default_trigger = "default-on",: D4 R( p0 O1 x" R5 f$ Y5 M
},
. w0 ^# i* `, g" r3 m+ G {
* ?. W! ?7 Y, Z) A4 S3 b* o$ ~* w .active_low = 0,
W. H: J2 [& M6 {& V/ _+ D .gpio = DA850_USER_LED2,
! T+ }" k% ~) N2 o( d .name = "user_led2",
" e% A( E, ?8 d- t .default_trigger = "default-on",
9 L/ E$ T4 `5 h& x* n },
/ w" {# K: Z! p8 |2 \ {: I+ j, c; r% k. u2 d
.active_low = 0,* I$ w1 ~; b7 {! K) f6 M- C9 @* x
.gpio = DA850_USER_LED3,
' d1 X- L% G+ f .name = "user_led3",
6 q5 x+ \6 z5 S6 Z2 }2 t6 V* K .default_trigger = "default-on",/ n% H8 u; v0 f: U# W! \
},# D# O" W- M: F. F. r. `, j
};6 { j' ?3 x( q
* k+ u7 Y. h) z; h7 r( Bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) r" ?9 c/ W( p/ c .leds = da850_evm_tl_leds,
8 ] I% m/ @3 \; s6 T8 x! O .num_leds = ARRAY_SIZE(da850_evm_tl_leds),, v: r, G# L& t+ ]. J/ f$ I1 W
};0 ?6 w c S7 l1 {8 Z
* O2 D; `& F2 [7 ?8 x/ A* ^- g1 {
static void led_dev_release(struct device *dev)$ M4 {1 g! N" O2 a, M+ e; q
{2 O( T3 n: ~" r6 y% W5 P
};
! z) S2 m2 x8 S3 A* Q1 [& u' l! v+ v2 t
static struct platform_device da850_evm_tl_leds_device = {7 M% Z) s5 G5 d* }5 ~
.name = "leds-gpio",% {2 T+ t) I# {( N
.id = 1, T5 E$ ~: Y/ [" v+ g/ |4 H6 o
.dev = { ?6 q5 x& w1 ~2 e- r( }
.platform_data = &da850_evm_tl_leds_pdata,7 k) x; g7 X* n( A. S6 [
.release = led_dev_release,
, y( T4 v5 j8 G% T }: |5 Z/ {/ f( H1 H5 C F
};8 e& T/ b! M( _( ] a, Q2 R
8 X3 h6 u' _& ]9 q! D4 R }6 `
static int __init led_platform_init(void)
' N4 @0 }& x8 A) y{( l8 Z Z. x6 B" I5 W
int ret;$ e8 G2 m3 y6 W2 u6 ]
#if 0( m* c7 ]: U2 V s" P' R( v
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 ^3 s' o) B2 |4 G$ _/ I( g/ c3 ? if (ret)
0 v, s; B: G, j) k& j/ K5 v pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
, N& Q) S/ s) O0 ` "%d\n", ret);
% x5 l" K0 b4 e8 Z' e#endif* @. [9 R: ]$ ]- J7 @
ret = platform_device_register(&da850_evm_tl_leds_device);
) l8 W/ y$ d `$ n6 f if (ret)
! @3 I" r: |) L) @8 X pr_warning("Could not register som GPIO expander LEDS");
! z8 C n1 ?7 A# X5 E' n else% |$ t `9 q* g$ ]
printk(KERN_INFO "LED register sucessful!\n");2 G- G1 v8 g0 j. H
. w5 t+ E% y5 a+ q6 U
return ret;
# O% I6 Z' P: u+ _- ?}9 g- n5 V5 h E: V) t
- j2 A& o" U7 m- s& tstatic void __exit led_platform_exit(void)
+ v$ v4 n& o- X8 P$ d; _9 g( U{
1 T/ |$ J' ^7 d7 z+ j5 K* W+ M platform_device_unregister(&da850_evm_tl_leds_device);
+ y' b- Y- \. L, D9 A' {- W% B& n! J7 \& I
printk(KERN_INFO "LED unregister!\n");( n, Z, }# K4 a. W3 ~' m1 H/ Y
}
! t$ ?6 r0 D" ^% e9 C6 e- _. u
) I4 Y9 r+ d/ e- k2 Ymodule_init(led_platform_init);
8 U1 n% }$ w( cmodule_exit(led_platform_exit);
3 v7 `( @2 H- n9 _& Y, x8 |" \" M' k ?3 T& p! B) z D
MODULE_DESCRIPTION("Led platform driver");
( N9 \3 ^2 m' {MODULE_AUTHOR("Tronlong");& f' m$ N: Y3 V* J+ V* {4 m# D1 k8 W
MODULE_LICENSE("GPL");
8 P( I) G. ]% _7 e2 i, i
. K# s. o% ?4 l) O7 E8 ^ |
|