|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. M7 y7 I( N# R# @1 i#include <linux/init.h>, d% e' J W6 K1 N% C
#include <linux/module.h>
% g$ t" C. E X8 N6 ^0 H! n# ]#include <linux/kernel.h>! Q' g9 z4 z: z- J& z$ B
#include <linux/types.h>
- j( J, F1 g8 [: k* x/ y#include <linux/gpio.h>7 S. i8 g8 t6 i
#include <linux/leds.h>, m9 L9 Y. |7 }! E
#include <linux/platform_device.h>
0 V1 j# ^# Z1 I1 d8 M6 h( Z
2 p1 o' x f" s4 L1 [0 r#include <asm/mach-types.h>4 s0 }$ t/ d& `9 ^& ?. I Q
#include <asm/mach/arch.h>
# l1 b8 j' F1 o5 j$ u6 E#include <mach/da8xx.h>
* P( c! e7 W3 @6 `. [& Z) Y$ w#include <mach/mux.h>
3 ^8 d$ G9 k* {( @& f% j: ]* q1 Z0 ], c" D" t( a X$ R2 }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 O4 i1 B$ g% m( Q9 `. G o; w) M8 y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 C+ d( U. N2 G3 y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( n+ R9 _. \, K! y6 m#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 F( G! R2 A( B- I) `0 s; f3 h! N3 }3 N" Z; t/ k
/* assign the tl som board LED-GPIOs*/( ?2 ?2 Y0 R- e8 @0 k/ G
static const short da850_evm_tl_user_led_pins[] = {
2 J( J8 u' Q0 k- G3 }" B /* These pins are definition at <mach/mux.h> file */
$ @+ j1 y6 C+ C+ y9 n! j, E DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 K2 b9 |- `2 O4 N& z4 A5 y
-16 {' ~/ O+ s- w. D \7 j) L
};
8 F3 b2 u! p" X
3 S ^. t; X3 T9 E& @/ D; Mstatic struct gpio_led da850_evm_tl_leds[] = {8 ~2 B5 t7 q$ l8 H* k$ S
{1 `3 E, o* ~. W' W0 c1 t. ~
.active_low = 0,% v% _- m1 O# I. |) M8 P+ L
.gpio = DA850_USER_LED0,2 s' o: P% i% z
.name = "user_led0",
, y! ?& q' e# i6 @ .default_trigger = "default-on",
4 O" D9 N9 W- N7 n+ ` },
6 h, a) N# {8 y( ]; V {* u6 g- a: t: X0 ?5 l+ g
.active_low = 0,& C L }9 |( ~# y$ {
.gpio = DA850_USER_LED1,
7 r( i2 V( Y+ } .name = "user_led1",
! q/ j; x& K* A& Z' @6 f# a .default_trigger = "default-on",
: Y% r( o Y* w9 O9 Z3 q },3 v( _- |8 E- @2 D1 \% a
{1 i. F6 n$ z. J+ ?8 T" z7 a, i; q% P
.active_low = 0,
7 f5 T1 c1 Q" o+ q. y$ u* z" ? .gpio = DA850_USER_LED2,
6 n4 g: K6 e# z8 W3 N .name = "user_led2",6 C; m% ?7 H- S
.default_trigger = "default-on",
5 w! a0 u* q6 q) @. |3 U },
/ Y* O& p3 G ?4 s {9 S* k( o$ u% `& X' v
.active_low = 0,
# k6 K# v$ b P1 R1 o4 m: S1 v .gpio = DA850_USER_LED3,9 k2 w, [( j; C. T
.name = "user_led3",
4 P# B Z& ~* I" F$ P0 W8 | .default_trigger = "default-on",0 E; g+ j* ^& q4 b5 o3 c
},# [9 X+ M+ e( ?' {1 K+ U& L+ e3 K
};, w1 F/ N' l2 I' [+ a
7 N% v7 F) P5 {3 i# ?static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {0 _" S0 K8 g# e( O
.leds = da850_evm_tl_leds,# W- i) Y. S% h- o! H
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 `' Q8 ]# o+ |7 Y6 N
};- V5 q+ E9 w# H8 o7 c" q
5 a! N# o5 j1 _& o
static void led_dev_release(struct device *dev)
: q4 ~7 @$ `; m" d6 b, b+ j7 ?{
9 n. l1 w- f) y* i+ j+ ^9 K+ N};6 w) t1 Y0 F" E
[ @* X8 @, |; i# D. e! Xstatic struct platform_device da850_evm_tl_leds_device = {5 ?4 P0 W5 [2 E8 G& h/ j& A
.name = "leds-gpio",
1 ~0 q0 Z4 @1 D$ }9 L5 h; q .id = 1,
8 J; p! q4 S* A .dev = {9 r9 Q8 I: f5 u# J/ M9 k& C
.platform_data = &da850_evm_tl_leds_pdata,
# Q4 C }) x0 @5 V% b) ~! [# D .release = led_dev_release,
" J( _9 F. H9 l7 o H* z }
4 ]/ z2 X. P# J6 [. F$ ~6 h& K/ j% M};
8 W. {/ d' A+ z# F4 }. y, N4 j# q
9 D, t4 |5 I. R" ^6 s* ]static int __init led_platform_init(void)
7 r. M# G# j/ D: B" r$ Z' z{
. _2 m- l& e3 W2 Z+ j7 q int ret;9 U' B; g+ Y' R- h3 N
#if 0
4 E5 i5 y+ s8 F; R, z' z' z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 B' F2 Z8 \2 | if (ret)% N8 f" n4 d: M
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 R0 Z8 ]& V, [3 O* [: d" w U6 y1 ~
"%d\n", ret);
# j5 Z" Y8 w) [#endif1 b$ P0 h; j7 _6 i3 a/ M+ {% E
ret = platform_device_register(&da850_evm_tl_leds_device);/ z7 E) r+ z3 u" g- a7 b
if (ret)
4 m7 ]' [8 f: b pr_warning("Could not register som GPIO expander LEDS");1 m3 ]3 t' O. c! o8 O
else
$ e+ x! P! e% }9 ] t9 _ `# c1 U printk(KERN_INFO "LED register sucessful!\n");
- f. H2 p2 Y$ t5 U6 c" z4 Y* \
1 K+ C' c& u5 d" h4 i) p return ret;
6 |* ?: i9 s d4 `: y1 q}5 Y+ C" [. B# h8 o/ ?. x
' Y! k: x2 t$ ?
static void __exit led_platform_exit(void)8 k: I- D* a, C
{5 j6 n% G' c* K' |" G
platform_device_unregister(&da850_evm_tl_leds_device);( U2 K1 |& G8 ?! W7 r X
! _% R( } V! q. c3 |; `& A' [
printk(KERN_INFO "LED unregister!\n");
' U* H- Z: D4 s# Q}2 L4 g, E7 R9 a9 g3 ^ H2 p9 C5 Q
2 T( N8 c: I" ?; P
module_init(led_platform_init);
6 o, f" C$ e8 V& Pmodule_exit(led_platform_exit);! c5 e) b6 n" q- g3 b2 N+ Z
$ K; z4 H- F" y) z9 C- MMODULE_DESCRIPTION("Led platform driver");
" o+ H: d& V% l$ L, S2 [MODULE_AUTHOR("Tronlong");7 \+ I' o/ W& l7 ?$ @
MODULE_LICENSE("GPL");6 ?7 y w( a% Q- |# H# _6 Q$ ^+ w
: _3 b, e' U9 j! d" w |
|