|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' I+ ]5 J2 ^% ]
#include <linux/init.h>
/ ?. D; P7 Q( M/ q4 _#include <linux/module.h>9 M$ e, W2 p' C6 I; D
#include <linux/kernel.h>- x3 }+ W! i' l7 A/ ~% q% E/ J9 Q
#include <linux/types.h>
8 C7 |9 G0 v! `#include <linux/gpio.h>
$ Z3 x& C5 S1 f, _#include <linux/leds.h>+ R) r C# x, T5 E+ p
#include <linux/platform_device.h>
4 @: h+ _/ q: n2 r
& \2 M' n6 o3 ~#include <asm/mach-types.h>
& \, z( ?6 c' h) K#include <asm/mach/arch.h>0 z/ g5 Q+ [% R, i x$ M/ k" s
#include <mach/da8xx.h>3 R) R9 Z4 Y Y% i
#include <mach/mux.h>: }4 Z+ v( V e" P
( C! v `5 W3 |# A' A, r
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
& J. A1 @) T2 U( ~- _' \#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), d* Y+ J: v& l8 `; l! ~! Q% q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% n3 w; I% j, t9 k9 ?! r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)2 O3 C: y) `) |! p
) F4 i5 I, W2 Y$ f# g; s; m) n
/* assign the tl som board LED-GPIOs*/
w0 {5 ?5 r* a9 D3 istatic const short da850_evm_tl_user_led_pins[] = {
+ R' Z3 z: V+ [1 g) i /* These pins are definition at <mach/mux.h> file */
1 H/ a! M4 A8 r G8 \9 Y/ e& f DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. E# ?3 m% X5 ?
-1
" t* k) a) c8 C- I+ G+ T0 q3 |};
. G$ {7 W! b+ y; y4 l0 P- F! \7 e8 e2 O4 S, Z2 _
static struct gpio_led da850_evm_tl_leds[] = {
* d" |" h- o+ g, }+ n {. u% O! q! `% b* L; `
.active_low = 0,! Z$ k6 d( A: ^: c6 f
.gpio = DA850_USER_LED0," G8 E8 f$ l! Q a* P( _
.name = "user_led0",, K* q2 e$ y' M" Y# |' ^* v
.default_trigger = "default-on",
5 T+ H( K- c5 m3 X$ l( a$ |1 q }," p! F" A* e1 i9 Y% d( j
{ {5 c- U% M. H4 `. S5 u6 i* O' H
.active_low = 0,
+ Z' k6 D& V7 v/ i, {/ p2 M .gpio = DA850_USER_LED1,) ?% P. P8 W0 |5 `& X1 c. G
.name = "user_led1",: F; Q! ~- K5 S$ C9 d* F0 r
.default_trigger = "default-on",
: ]5 Y: P4 V" z$ k6 S( v },
! j' N- j7 o. y9 @+ J# r {6 G1 e+ Q3 \, L" M8 P2 \& W( T
.active_low = 0,
3 m9 A9 P0 J. Q5 e/ V% {3 `7 y .gpio = DA850_USER_LED2,- U2 q# A, y& |. o i
.name = "user_led2",
5 b: Q6 D3 d$ ^6 D5 g .default_trigger = "default-on",
4 H L# v- u( ^ X },3 |) m5 H$ {) @' \+ m/ _
{
3 E! v- K+ z) o8 R4 H. y .active_low = 0,5 p- ^) z, k2 N Y; I
.gpio = DA850_USER_LED3,1 j) w% D; k7 v
.name = "user_led3",
% Y) v; T' E! L1 V' P .default_trigger = "default-on",# o% f' J5 T, p g- q1 n
},
+ \+ \, u" H4 u0 c7 l& [}; q1 y* |7 O$ N0 I) {& E8 r' ^% B
$ m! e( ]1 P8 F( Qstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 N9 P1 T9 n, X0 R .leds = da850_evm_tl_leds,
8 f4 p- Q; h& { .num_leds = ARRAY_SIZE(da850_evm_tl_leds),$ w, A7 }2 O; z6 n# k
};% o5 x7 O; y6 ^, O
% f! q/ S- L& I- M* L( ~static void led_dev_release(struct device *dev)4 U8 L$ u a* }* B
{
1 a6 G+ C+ x5 t5 [9 B( T};0 Y( h5 `( ?+ T5 [/ }9 M+ v
* X( z5 |9 ^8 N4 |& l% v
static struct platform_device da850_evm_tl_leds_device = {. o- Z) `) @& Z- X
.name = "leds-gpio",4 d/ ?& r0 }' J* U( K* |
.id = 1,
' ~$ m3 a. C) Z! p" I8 n: ]8 n. Q .dev = {, d/ e# U4 g& u0 g3 r& Z1 E
.platform_data = &da850_evm_tl_leds_pdata,: M7 H8 m+ ~$ P Z3 |
.release = led_dev_release,
9 z4 f; `+ k3 r' o, e3 P! Z } l. d! T, A0 H' d+ I5 }7 o/ G
};
) u& V: Q3 C. ^8 k7 s6 _9 k1 E3 Z# P+ M; m6 R
static int __init led_platform_init(void)
2 [3 X4 J7 k8 Z) c{
7 b b- Z% m- l6 e int ret;
/ n' _ T; o4 @1 i. }- l#if 0' j" j( h5 I" x& b! P1 l9 O
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. n- S$ Z8 | O/ w if (ret)
" x/ X* [8 J; m! u" x pr_warning("da850_evm_tl_leds_init : User LED mux failed :"8 I+ }& u+ Y7 E8 c7 i
"%d\n", ret);! r8 c! r0 @% n$ q# Z* ~
#endif
& G$ a4 F N7 R+ s: Z ret = platform_device_register(&da850_evm_tl_leds_device);
# G& y4 w6 H- L8 _# }4 I I7 { if (ret)( O: K3 A% a" _2 X+ _' s
pr_warning("Could not register som GPIO expander LEDS"); x0 o& t2 J: J0 O( L$ k6 k0 Y, g% V
else
. |4 g2 c3 I& h5 a3 X j printk(KERN_INFO "LED register sucessful!\n");( \* m n" _! X7 w! h" T- X
3 t% f3 e& ?) J2 t+ g( m& Z3 m return ret;
9 M7 P6 g) Q+ `! F, r! S- ^}) R. f7 o4 |$ [
( n a. T0 K8 D \/ f3 J% T& B
static void __exit led_platform_exit(void)
6 E; E9 j7 Y! ?3 {8 v3 G{' |* W& o- B) ]4 A2 J
platform_device_unregister(&da850_evm_tl_leds_device);9 j+ Z+ X. N; G) t6 n
# \+ D& }2 a3 f
printk(KERN_INFO "LED unregister!\n");
% s: T7 m8 C9 ~8 I4 ~$ U% k, E: Z}) R& ^0 y/ h+ m
' j7 [0 o1 H# cmodule_init(led_platform_init);) Y3 `$ M5 @. R) y5 w# x
module_exit(led_platform_exit);+ Z( N# f; ^$ x) [! _" _9 V% w) N% q7 h
, B- Z3 s h) y0 a5 }, i- i- |MODULE_DESCRIPTION("Led platform driver");
' D4 S5 K5 |+ J) c: @$ C7 S% jMODULE_AUTHOR("Tronlong");
% c: P, k$ p3 y$ B9 C z& kMODULE_LICENSE("GPL");
# K6 Z8 H. u. b) M7 I% i1 z. @1 c. |0 y Y1 v
|
|