|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
, g, O- F: Z% X' ~# |#include <linux/init.h>1 K9 n9 l1 I& o+ n5 y2 H! w, v
#include <linux/module.h>
; S0 M$ i; S4 U! L& s( m1 m% f#include <linux/kernel.h>
" F/ a( ]4 ]7 l: S- H#include <linux/types.h>) h+ f. G! i( A4 m* `! ]
#include <linux/gpio.h>: ^ Z8 t6 X2 L5 F* ^& a
#include <linux/leds.h>
6 m( T6 z! I+ \; W- v#include <linux/platform_device.h>( X1 u$ b2 S# c8 R7 A
. Z" j+ e0 r" k' V
#include <asm/mach-types.h>* ^# j7 r$ n8 K7 Y5 g5 o8 y
#include <asm/mach/arch.h>3 }. z' G: K/ O9 m% k; L5 s
#include <mach/da8xx.h>* E$ G0 C' w; N7 @. Y! Y
#include <mach/mux.h>
, ]2 {; A! K c. a4 S- }# }; p
0 P) [3 }* X- H7 y K#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 o) A& j9 R- b4 a#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ a$ |2 X8 g8 V6 m' v$ K( [% }
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 b! D5 j+ G. q$ {' k u7 P n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" |& [8 N3 C) M6 w: m6 [* u5 [& o) l) B9 R- C8 }
/* assign the tl som board LED-GPIOs*/
+ _7 d8 ]; y" `/ Ystatic const short da850_evm_tl_user_led_pins[] = {- [+ }& T6 |7 E, T2 {7 l. e
/* These pins are definition at <mach/mux.h> file */2 Z* e( E$ X& J% N: g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
: P# l# e( e% O) o# J& x -1
- S' X; ?8 A! ?};
, E* F# q4 J$ t6 p' W H
2 }$ O+ Z9 f4 R9 a& O% ^6 \$ M3 X0 Vstatic struct gpio_led da850_evm_tl_leds[] = {2 c0 K6 w1 v" k& Q% Q f$ R
{2 S9 a- z* A/ C
.active_low = 0,
7 J8 B9 ^7 E9 u% c .gpio = DA850_USER_LED0,: o7 M: ~( G! [. f* {& x% l. r4 K
.name = "user_led0",+ M$ D) T2 W/ b& K7 L7 t
.default_trigger = "default-on",
* j4 c3 w& M' a6 ]0 @% t },8 n* G+ h' y/ M! s- v
{ e/ L* u5 p9 W. a$ K
.active_low = 0,! v2 f( M9 D- h+ `8 i( `, ]
.gpio = DA850_USER_LED1,
2 D8 i* A/ F; y .name = "user_led1",% }7 z4 A v# J* B% {
.default_trigger = "default-on",
$ ~" Z0 b/ r& @. V: Y6 f; I3 Q. I }," M* e5 X) \4 m) e% _% H
{6 q$ t3 P& W/ {1 R8 [/ S& `: g- m
.active_low = 0,8 d" w1 G+ {' E
.gpio = DA850_USER_LED2,
6 F: o, W4 K! ^( U& f- p .name = "user_led2",
: O& N7 V$ Z# o9 n% H .default_trigger = "default-on",
1 l8 V% O* M5 l& s H% Q },
) i' C! [9 L- |% w {
0 f+ t* x# X; Q0 C, U .active_low = 0,9 e3 S- S. r/ [
.gpio = DA850_USER_LED3,3 A' l4 Y) P$ U8 @) ^; R& L% \
.name = "user_led3",% V% `+ A& l! W- k( U
.default_trigger = "default-on",
) s" o/ q- x+ i( e5 c: l },
. ~ f" I0 L8 n& r3 D6 V, a3 N};
$ W" D! |1 k2 L
; T+ e) k `. H5 ]static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% Z2 c9 C" T }7 \# N; Z1 }, a .leds = da850_evm_tl_leds,( V8 u% f# [( G: d9 P7 N
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
3 i; @7 x8 \ h# a. b};
0 _. h3 O2 G- l5 K: b& {6 `- K
$ d Q7 Y6 Z! A' {& Tstatic void led_dev_release(struct device *dev)
+ k6 k9 x3 o8 d, v* i- f8 c{" r" {8 F' I0 Q) {4 d) j
};
4 G# R) r3 G9 I$ h; Q1 ]1 B% W, V) v3 ?; }. C: ~: H, s! J
static struct platform_device da850_evm_tl_leds_device = {
' O1 V5 f9 {- _5 x3 b( h .name = "leds-gpio",, |& h- u, f! m: w; d
.id = 1,
, |8 i0 ^# E$ y& U .dev = {5 _1 v7 d9 g9 d0 h9 p3 S8 R
.platform_data = &da850_evm_tl_leds_pdata, `9 E& Y: X# ~) o; e' F0 z
.release = led_dev_release,! m! G3 |: g n7 l6 C6 [3 z; q+ i, @
}
" _% a# M5 s1 Q5 P: X};. x E* s( t" p$ w3 G$ H$ R
7 I! ~2 \0 u% e3 {! xstatic int __init led_platform_init(void)
, [/ Z" Q; m) [5 Y% _{/ I" S9 ?) Q. @2 }
int ret;+ M& {, [' d9 d$ }, ~# B! b
#if 0
' X; n( A; ]$ v: S. Q* ^ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
7 y3 e/ G; h+ I) _3 y% I# B if (ret), j2 j3 T u& S% {
pr_warning("da850_evm_tl_leds_init : User LED mux failed :": s: D! B* z/ W V
"%d\n", ret);
/ Z8 _4 r& [4 s" U+ g#endif
' E$ o1 a: j8 ^( J, _& r ret = platform_device_register(&da850_evm_tl_leds_device);
' C! I" w2 }* S. r! Q2 D) i if (ret)
! m+ Q( \9 l9 \ pr_warning("Could not register som GPIO expander LEDS");) \& D8 @9 Q9 X- G$ @! O; Q
else
5 e' k X9 h0 D printk(KERN_INFO "LED register sucessful!\n");
& K; y* r K1 d4 h3 _1 U, i9 C3 k, R G0 ?: G3 J' I, @" S( E% ^
return ret;
* ?( a0 h# w) L/ g8 I}
6 p. G/ f( Y0 }: t4 K% ~: q
2 e. [/ q0 `. i D3 C, G# d0 Ostatic void __exit led_platform_exit(void)
9 l# e1 A$ i) i0 r{- R+ U4 g3 v2 a0 n
platform_device_unregister(&da850_evm_tl_leds_device);. C; ~$ K7 x* J' T
# Q0 f B, _7 k7 c; E8 | printk(KERN_INFO "LED unregister!\n");$ V6 U7 n6 J& b
}
3 B; j7 v7 r K8 ?+ c+ D
( {, g! P- d% p. `module_init(led_platform_init);: r3 D' Z1 y2 f/ v" o
module_exit(led_platform_exit);6 N$ D- ?5 u* W& z p7 i: {
/ M; Y1 T, d( }
MODULE_DESCRIPTION("Led platform driver");* N/ K8 q/ K8 U4 `& X8 m$ b+ j
MODULE_AUTHOR("Tronlong");$ ]+ f' ]! t- D$ I* ]3 w
MODULE_LICENSE("GPL");
7 S1 L/ r+ y4 O, r0 _9 t7 o% r1 `9 k9 g" d2 ^6 M! |* |
|
|