|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 r! s( i2 N! d. a a#include <linux/init.h> ?9 _8 B9 D4 W" S" w
#include <linux/module.h>
* o' ^ B" l+ e8 d#include <linux/kernel.h>2 Z- i. a R: y5 n, H
#include <linux/types.h>" I: p5 Z* o; N6 @/ ]& Y
#include <linux/gpio.h>0 c% A6 U# C% }3 a4 x P9 U5 V0 H
#include <linux/leds.h>- |0 J6 P0 y; s! f$ B9 d d+ A
#include <linux/platform_device.h>
( Y4 @: a4 E) W' p! R3 ?, g9 A
b9 Y- ?4 Y$ L% {7 D# w#include <asm/mach-types.h>4 T/ d z3 u# y1 l# z) O4 p
#include <asm/mach/arch.h>
c: U4 d% X" t G; w#include <mach/da8xx.h>' ?5 O4 O; v# d# |6 `; s
#include <mach/mux.h>2 ]% M! C# x! C/ r1 `. |
/ T- ^3 y* ~ v
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 V; `1 C w3 d" u1 H& s#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
s' d6 U( M+ E4 h) a' S$ C" _5 c, U+ y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 |! u) t/ E. K! i
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 k) `: g1 D+ V+ ?- x( U- b
" ^; A& u3 x" b. L/* assign the tl som board LED-GPIOs*/5 I- i& l' n! M0 h m
static const short da850_evm_tl_user_led_pins[] = {7 w+ k& t+ g0 E% A, p0 f7 r
/* These pins are definition at <mach/mux.h> file */4 B- |& D5 }* q! n, e4 _
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 @2 f; u6 X G -1* P$ n9 u5 L: v! y8 J* G- o2 _
};
, i8 A7 z$ L9 h m) [# b( `* v: `# j' _3 O
static struct gpio_led da850_evm_tl_leds[] = {+ }! A) S* [- U4 Z/ n
{* t2 Z; Z& t c% e8 G
.active_low = 0,) w) [# d! }; s4 \
.gpio = DA850_USER_LED0,
. ~" D9 ^" D/ j2 P8 ? .name = "user_led0",
6 e+ T. Z( e& m2 l( w" q .default_trigger = "default-on",1 |7 O! D! y: h) C2 j
},
E0 S5 Q+ E0 E- O- P+ a( A {# F$ U- ~$ L. p; x2 j6 B5 Q
.active_low = 0,' ]4 |/ l1 y/ t- l0 Q
.gpio = DA850_USER_LED1,) P, w" i4 G, f5 X
.name = "user_led1",# u( s1 o7 \3 ^! Y Z" l0 E. P. g
.default_trigger = "default-on",2 X/ J. c2 ]; u6 z
}," @) p- n+ t. a; o% A* e8 N5 s5 P
{' m4 C1 l% n& J, Z# u B
.active_low = 0,
& Q" N0 R+ ^3 F/ [0 g$ ?2 c8 o7 Z .gpio = DA850_USER_LED2,1 D G, U1 ~0 e; N* W
.name = "user_led2",, J6 J& I4 t/ k5 B
.default_trigger = "default-on",1 p) T, N1 v$ l2 L
},/ y9 s1 E6 u1 M9 M/ U7 ^& Y% M* _
{
, Y |9 N9 w+ L E9 ~ .active_low = 0,
) s9 n) u0 I1 L: T8 @, {& G .gpio = DA850_USER_LED3,3 C) J% e2 ^) F
.name = "user_led3"," K3 v+ m! T9 `3 _/ |5 B
.default_trigger = "default-on",9 @" \8 C |( p, C5 F+ M7 y. l
},
7 s$ c* g) f& Y8 N};* H1 U0 D8 Z' m% R
/ R5 `2 _, [3 G0 S# t" xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
" q. ~) Y+ t5 I* `5 X .leds = da850_evm_tl_leds, |3 E7 R9 ^) f% Z! |
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" r: r$ ]% Y6 I9 R7 x};
3 y9 ~$ O% G. H' n$ H/ f8 N+ H1 d
& M& _ D$ L6 y9 zstatic void led_dev_release(struct device *dev)
9 m+ R6 c- _/ I; q{6 n; j% a) a. r" `
};- c: f, g/ h+ y- U" n! s
9 @% [& E! o( B( @' V& T
static struct platform_device da850_evm_tl_leds_device = {
7 n1 u6 o/ ?4 F4 ]7 }: N( _! L7 b .name = "leds-gpio",
6 W$ l: L/ Z* t8 p .id = 1,
L: _1 N- o2 x6 r9 { .dev = {
6 c! `% `0 J, b* W .platform_data = &da850_evm_tl_leds_pdata,
) H5 V) ` b& @$ ^+ j) o# |& j .release = led_dev_release,
2 w8 o* z7 f. [: U& q) P* \ }
- x4 O( a0 P& Q: A1 a# v: _, Z |};$ p J4 H# J& ?) _# u. N* B
, M4 \2 I0 i; qstatic int __init led_platform_init(void): z7 d6 w- v8 L
{' p' K4 Y2 W/ C1 v5 T
int ret; v C8 b2 t- T2 C1 I+ H
#if 0
8 ?' K0 s4 C0 H# g0 P ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 q: V! A/ y3 j9 F$ i
if (ret)
; @. e k. [6 `7 x pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 T1 s D6 M% r. z- n7 h3 l/ y+ R* {
"%d\n", ret);8 q$ F m$ \* u$ |( G! s
#endif: w* \3 I: f) F0 k4 T
ret = platform_device_register(&da850_evm_tl_leds_device);; s: W+ z* P h$ Y6 b5 R9 }
if (ret)2 u4 }+ f8 W" |7 w' ^& q7 c- ?" b
pr_warning("Could not register som GPIO expander LEDS");
5 E: A E) v2 o' \' D5 n else' e0 ]" v6 F/ L' B- ?" X# [
printk(KERN_INFO "LED register sucessful!\n");9 F' u$ D. p: [+ E% f* H
]" A6 {. r& i
return ret;
4 n: C6 U1 o. o}
$ ^) K6 o, X! p! }8 Q; o. z0 ]/ b: \; x/ ?$ R
static void __exit led_platform_exit(void)3 R- U' X/ b! ^/ s' T
{
2 b8 o/ J! W" X& y1 B2 A0 a6 n platform_device_unregister(&da850_evm_tl_leds_device);
0 x* `% ?/ n2 x# A
2 G: K z* T( @' H% y1 R printk(KERN_INFO "LED unregister!\n");
6 p2 g9 K! { E0 [) D5 y+ @}
, h+ C3 r( c8 m& i" k* e) n6 I% V2 N' F3 i9 ?! Y# j% D# h. `& ^
module_init(led_platform_init);3 `2 L5 }/ U$ B9 h/ t
module_exit(led_platform_exit);
9 r: S2 X2 Y- N4 @$ H" }% |$ w" O/ l, C" S A9 M
MODULE_DESCRIPTION("Led platform driver");- ~, Q; R2 }$ D" j4 }5 H! ?
MODULE_AUTHOR("Tronlong");
/ b& r4 j M; oMODULE_LICENSE("GPL");2 i2 a+ \; D7 M0 u
2 F" [3 N" `! Y3 j! t0 ?
|
|