|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
" @2 u/ M% @+ J0 s+ E% `$ Y#include <linux/init.h>$ M! c/ ]- N/ e$ s( J6 [, y
#include <linux/module.h>; N& j0 }8 X" j* g9 k$ _) H- ~
#include <linux/kernel.h>7 I4 U3 e% f5 D
#include <linux/types.h>6 Z) y5 \' c9 U
#include <linux/gpio.h>: R L" _& e6 V& ^$ Y
#include <linux/leds.h>9 f7 Q. ?8 O* O" C4 }
#include <linux/platform_device.h>9 N, {2 a3 _& ^; N
. v5 r9 q% x: E6 J. f0 w! D* o
#include <asm/mach-types.h>' F9 H! ^" P( B. C: {( d
#include <asm/mach/arch.h>/ n F4 d- p" E
#include <mach/da8xx.h>
* _' y+ D1 K) |1 n#include <mach/mux.h> Y* v6 |" z+ ]/ M3 V
' Y! {: E" p! K/ D5 ~2 r- z) `
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); W' G; H; r2 L$ M
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: h- u, `8 O) D% P4 ^#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)" p( j- i% Y* X5 f* I
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! r _2 }8 H2 Q% @5 p, |3 x
: o/ ~& J, J! L+ H/* assign the tl som board LED-GPIOs*/
, {1 H5 t) e0 D5 u2 [/ ?% X4 G9 mstatic const short da850_evm_tl_user_led_pins[] = {4 r% s- f% W2 I7 T+ Q- Z
/* These pins are definition at <mach/mux.h> file */8 {' Z7 Z! g: p& M
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, r8 c! U4 m2 E/ A6 e& r -1
" E3 q4 V7 p7 W' ?, [) |: K5 j `# i& U};- J. Z% G) J. ^$ h# X
. U; H! }' e+ v. K9 E3 Ystatic struct gpio_led da850_evm_tl_leds[] = {+ P5 @8 S, C' h" k
{1 R. W# P7 a) t- a5 o. S
.active_low = 0,' x2 C1 n) e) a1 n' w
.gpio = DA850_USER_LED0,+ @* m: B8 R, L9 Z# D
.name = "user_led0",; `, m! W" r3 Q! Q; k. T, P
.default_trigger = "default-on",
8 P$ D @& D' d# w: T: U },
- V3 L4 ^# @7 {. X; }( r }4 ? {% V: w7 k, U4 }+ u
.active_low = 0,; C, ^- a* d( {$ r6 \* W) o
.gpio = DA850_USER_LED1,
7 S0 L5 {+ W* X/ f# A/ V9 f .name = "user_led1",1 w" L0 Q: }( m
.default_trigger = "default-on",
2 P/ P5 O( ]6 j5 q" u2 {) G$ L! @4 }/ ? },
1 D1 ?; q! |5 L {
( s' h* x- H+ J& q1 i; b- I% O0 t( r .active_low = 0,7 Z+ e, ~6 V% Q5 v2 } o
.gpio = DA850_USER_LED2,
+ y/ Y- g: [( J+ f; U2 Z .name = "user_led2",
0 `. E' ]' H" C$ E6 ~ .default_trigger = "default-on",9 h' d3 t4 H" c
},+ G: B6 c6 \- D8 e4 }* s( p
{* K! a3 W! }9 t
.active_low = 0,) a/ x+ E8 n1 E" k* u. o* T! ^5 {
.gpio = DA850_USER_LED3,7 c! x+ m; M; ]+ Q
.name = "user_led3"," K3 _# Z1 j! K' E& l4 r4 k
.default_trigger = "default-on",
( @8 f8 B V, l, R& P$ R },# P" K& \! K3 \2 k% O
};
9 R! f- g6 ^7 K c+ E3 H
" C; @) v! ]; O3 x# P- q3 ?static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& g3 p7 F0 Z8 s5 Q4 d/ O
.leds = da850_evm_tl_leds,
9 D" Y8 l/ T T0 w1 }5 E: ^ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 E3 k8 x f3 h$ S& W$ R* Y- J+ o: R
};
+ W( I# {0 @2 S# |# U5 w- q
5 Z" f( z5 ~1 {* L3 vstatic void led_dev_release(struct device *dev). M$ O! A6 v( Y& X9 R: s( ?# d- J9 I
{+ W& O$ t `6 b k0 U# h, h. o) u
};
( o0 N, h& p! R* O" D3 ^9 \& K! {) i
static struct platform_device da850_evm_tl_leds_device = {
8 g- ?9 O0 }/ o .name = "leds-gpio",
$ D. d8 W" n+ ? .id = 1,
8 Y2 } Q0 I- e .dev = {$ W- P, |' \; t/ d5 i9 W8 W
.platform_data = &da850_evm_tl_leds_pdata,7 [& R" T: [. @6 `" D. |; }& D
.release = led_dev_release,
. U0 H* J9 f' e/ g, ?+ W }
0 @/ J0 b) F4 O+ k- z2 t5 B% q4 v4 T};
9 T; E) l$ d& B+ ~2 x/ [1 p9 a; S+ t
static int __init led_platform_init(void)9 n8 t0 q9 b0 m" S
{$ z0 a) J# W9 l5 s2 y
int ret;
8 c- g' w9 C! ?0 T9 T E% I9 _#if 0
7 p" O( Y( `* Y. n" G. \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 R9 ?% i) l# K" u
if (ret)
2 g" c! d8 [& W pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' _: F. Y/ @$ ^2 u- l5 [9 h8 o "%d\n", ret);% I- K5 S( U5 _$ E; H6 A
#endif
, T' g6 F2 T6 x' ~) h ret = platform_device_register(&da850_evm_tl_leds_device);
0 {+ |% w+ t0 B+ G if (ret)
1 N, F: j+ G+ e9 w9 t# q& M pr_warning("Could not register som GPIO expander LEDS");
. H5 D' }2 J/ H6 t. Z else O1 {1 s! e8 w; Z# S+ g
printk(KERN_INFO "LED register sucessful!\n");% N5 H3 P ]2 O; p9 I
& H/ ^% o$ ~: \' N; B return ret;
7 C$ r/ c/ V6 s3 ^* _( q. h2 o* ~}
' @2 U4 D, c( i8 N0 J3 h! S" ?# l$ W! M0 l' R A$ o
static void __exit led_platform_exit(void)& h$ w, y7 }, Q3 Q. w
{9 F) Y- p- p* b3 G
platform_device_unregister(&da850_evm_tl_leds_device);4 E1 t8 k1 T- i% Y
$ m* ^. M3 |1 |
printk(KERN_INFO "LED unregister!\n");/ \# E6 k+ T# d0 m" \' k1 \% q+ _9 X
}
5 ^' z% [4 v6 R: E" f3 n
. P$ Z7 w5 {: i$ {! \module_init(led_platform_init);
' |9 q# L0 _/ R' ?9 }* Vmodule_exit(led_platform_exit);
: G$ h: Y; l8 ]( C! r6 `5 G/ B5 p! }4 q7 i1 e& {
MODULE_DESCRIPTION("Led platform driver");
6 c6 Y* R2 G0 n( _MODULE_AUTHOR("Tronlong");9 n ^+ `8 l# j# B
MODULE_LICENSE("GPL");
8 C4 O/ Z% I9 X4 U2 i' q2 _' f) T
|
|