|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ H8 e+ z6 v& R3 z9 W, a: ?& r3 H: h#include <linux/init.h>
# Z1 D+ A: J1 L$ m#include <linux/module.h>
/ V4 `; r4 X/ ^. T& y }#include <linux/kernel.h>$ L) R- G6 \+ E' `$ X" e
#include <linux/types.h>
( c* [8 [7 B- c6 g#include <linux/gpio.h>- C8 w& Z, V, R1 g3 n% `: F( C4 D
#include <linux/leds.h>. g7 [& ]/ K3 ~" M" R
#include <linux/platform_device.h>$ \: T1 E) V; S- t* @
) O1 b0 Y6 T' F5 A
#include <asm/mach-types.h>
) A. V# l7 T0 {- v4 C" `#include <asm/mach/arch.h>
+ ~1 }" }! ?/ w5 m+ t) L' G4 `#include <mach/da8xx.h>
5 L; x# q, w/ V* [+ d9 e& f#include <mach/mux.h>$ `& E4 Z* Y# t$ P/ Y5 ]
. B' t8 V4 q. \ E6 H T5 x#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% J9 M3 r2 d b' @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
0 I; v- y6 R% \8 R7 v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! T7 A/ x2 D3 |! S3 C5 f7 w9 l#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" I, E* d2 d) B
! M' W9 g: V# y3 T* `$ a6 M/ S: f/* assign the tl som board LED-GPIOs*/
+ w/ `0 w ^' vstatic const short da850_evm_tl_user_led_pins[] = { D; c! H1 M+ ]9 h! P
/* These pins are definition at <mach/mux.h> file */
" K& Y$ G2 ]0 A' S DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( {% ~, g% O! m1 c8 v, Z5 J2 s
-12 x* i: W( R& [4 _
};6 `* a, ]& C V' O7 t5 e
1 k. {, X4 \7 n* b9 S7 b$ |
static struct gpio_led da850_evm_tl_leds[] = {
$ G! H( Q, g: l' p/ ^ {
8 _8 M) B; [) R( D& m- k .active_low = 0,2 r8 c- W, _' |5 m% {; m* V# v6 h2 e
.gpio = DA850_USER_LED0,; E1 Z' B+ J& U! V) {/ k
.name = "user_led0",/ N% J" I% l% d$ c7 Z
.default_trigger = "default-on",
X( Y& r8 m {6 h },) F" f( L) W, a. o# N% ?% v
{
5 n) Z, J: h/ t5 M/ ^6 l .active_low = 0,' N, H4 @* G& L
.gpio = DA850_USER_LED1,. Y6 X9 t/ `( @! N* \
.name = "user_led1",
2 i; l$ d" u8 g .default_trigger = "default-on",
9 _/ F, [0 _& g* ~, x9 @" ]" H },
9 H/ }6 v! s. ?6 q$ t* [8 m2 \ {
7 B+ J! ?9 b2 O- x) Q8 n .active_low = 0,
3 O1 m' s: f/ B! W+ J .gpio = DA850_USER_LED2,6 N+ l6 m4 t( @+ a
.name = "user_led2",
! v/ T" c6 m0 z) [$ Y4 K3 n2 { .default_trigger = "default-on",! S% t% r2 U, t$ w" w
},8 A5 s7 W4 R# j; R
{
! Z3 n! o( P) A% y7 D; b' f .active_low = 0,
v5 `. J( G8 T& _2 F; \; R# E .gpio = DA850_USER_LED3,5 Z( |1 E* v. b+ \: b+ q) S
.name = "user_led3"," O' r# k! ?; a2 S w. J
.default_trigger = "default-on",6 h' N) l! `; F0 z
},7 X4 l Y$ l" u1 b( y
};
0 `: @ [7 a$ U1 V; i* Y( \$ t
* [6 c! a, S( c8 G1 P/ C1 z# xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. c' v) M N. X$ m9 G% h .leds = da850_evm_tl_leds,6 G3 p9 @- K, p8 K c2 G ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) D1 C, [9 y4 p; W}; l8 P S, _7 q( d; W8 i% i
& z: N. V- E5 E% S5 zstatic void led_dev_release(struct device *dev)
A( Q2 c# w! Z& [{1 I3 d; W6 G# z
};9 h& {+ {: Z: M7 [8 [, N; }
4 q' ?% O. }8 P9 nstatic struct platform_device da850_evm_tl_leds_device = {7 q) ], _/ }# C' H" i! f# V6 V8 Z
.name = "leds-gpio",. T7 |8 k1 W6 |/ L. n+ C* x( y: x
.id = 1,
0 Q5 [" a7 N' }4 H p .dev = {
I7 y1 \0 `/ r1 A+ b7 |( B2 B* Z .platform_data = &da850_evm_tl_leds_pdata,7 p: O0 g# i5 K1 [4 ?
.release = led_dev_release,' U2 N& y4 \8 r
}/ x+ @9 n( T4 |* V6 \" Z
};
]2 w I7 h% a4 @3 f! g% K3 `* f% U5 B N, y/ M# _9 n
static int __init led_platform_init(void): C7 k7 C, e8 S7 ?/ j4 @: z
{
7 [; A' j! T; h: T9 S# \" M int ret;
- H7 X# y7 `3 H1 S#if 0
8 V% @: f: l6 g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ t4 g6 D# h) n: k if (ret)
/ Q5 v0 k, c# d( h- O pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- p6 R' S+ q: b "%d\n", ret);" Z- J J$ ~* F6 Q, z) h
#endif8 R# [$ \0 r! _" v
ret = platform_device_register(&da850_evm_tl_leds_device);- N2 }1 }2 V a4 `) F
if (ret)
- u7 s* m* b. c' ~: T7 G- D pr_warning("Could not register som GPIO expander LEDS");
2 L3 A4 K# p$ V1 k else/ ~ R8 B: E4 {2 |. J( N/ @
printk(KERN_INFO "LED register sucessful!\n");; a& n6 E4 B, ?
+ V4 T# {0 F- e3 Z! D! k& I
return ret;! r, x3 I7 i3 {$ K6 {$ k% O( [9 {
}( ?; O% X, D- p1 {$ Z' p3 Y2 K
$ ~( [# k9 C m
static void __exit led_platform_exit(void)
& I+ L- U5 q3 V6 ]/ v% H{
1 g* L8 I- s( ~ platform_device_unregister(&da850_evm_tl_leds_device);
, F$ U% R. n7 E( C: p, F+ \0 g4 ?2 Y) V' u# ~3 S; l- I
printk(KERN_INFO "LED unregister!\n");% L4 m( W. G- |5 T1 Q6 X
}
5 P% U6 k6 M& \- c
4 h& s$ V. ?0 m' l! Xmodule_init(led_platform_init);
7 J. X; z" N) j6 r5 P3 bmodule_exit(led_platform_exit);
; ~0 H# O8 Z! a/ u2 h& j( ^3 E% `+ m0 n, V- M3 n4 d
MODULE_DESCRIPTION("Led platform driver");7 l3 b* a$ s- R+ }+ {& n0 A
MODULE_AUTHOR("Tronlong");6 K0 a6 \' [! Y3 P8 T N# B
MODULE_LICENSE("GPL");
[5 i2 N8 b* q4 b7 w; }' u0 M% }( E9 R: p9 N0 g, E4 R7 l' B6 k
|
|