|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& Q9 o6 { @$ b2 l# E
#include <linux/init.h>
8 O0 r! X& y+ v! }; c#include <linux/module.h>
+ @8 S, I( b' [. ?#include <linux/kernel.h>
0 d$ s+ s4 }! K' f#include <linux/types.h>$ \6 I% N9 x; D7 R; S
#include <linux/gpio.h>/ |; B1 p% n$ U! r* e
#include <linux/leds.h>
; W; h( W, w* r4 _9 l+ ^: |* L6 u+ |#include <linux/platform_device.h>% Y# X9 O$ g; w$ N5 K+ A; f! V
+ u# Y8 [$ E2 Q#include <asm/mach-types.h>
$ k0 _; k+ V+ r) [" H! Y#include <asm/mach/arch.h>
- x v0 R5 N* e+ |7 d1 v- n- Q#include <mach/da8xx.h>% G! r2 n! I9 E# G1 F/ G
#include <mach/mux.h>
" b9 r( N: B2 [2 l4 J9 i2 j- i. D2 ^5 {* y S; ^5 ^
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0): D2 \+ c3 k4 W) C) B5 Z' y
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. x2 G5 D/ T$ u: T. O0 V! k- m#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); g+ f, l/ T% V4 t
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 N/ `: l# `# T/ V3 B: }
3 Z1 n$ h! T0 j* @5 }1 z
/* assign the tl som board LED-GPIOs*/
) r" ^& H$ m: Y7 ]6 ]static const short da850_evm_tl_user_led_pins[] = {5 J: x1 n# F" m( m, l
/* These pins are definition at <mach/mux.h> file */& f* t; w4 l; ~; q) {* q# e
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
) |0 Z/ N! R8 H( E9 x! ` -1
4 h4 R+ }. g5 o};
" N( `1 |+ U2 }' l$ f& s* \" [* a5 x3 W) g$ O
static struct gpio_led da850_evm_tl_leds[] = {
) n5 i- F- ?$ U {
1 S7 B f7 X/ T& G, a9 @& t9 G$ K .active_low = 0,1 F5 ^6 R5 k3 ^
.gpio = DA850_USER_LED0,
+ o/ v$ L. _* L* x0 i; E& W .name = "user_led0",: [+ h. d4 V' P( F0 e6 v# V [4 F, N
.default_trigger = "default-on",
$ u* K/ t; K& u& \5 c; \5 V },. g; C2 o- _8 c
{
# k" \ b, z; B! p4 v .active_low = 0,
2 w0 |6 y% [( \ d; }2 e .gpio = DA850_USER_LED1,
, q; F0 N4 |% f. b .name = "user_led1",
" z9 m, Z* e$ Q3 | .default_trigger = "default-on",
6 m& Q6 v8 b, [: d$ [8 | },' F( R* R4 }1 X8 P4 D/ {
{
2 c$ Z+ @4 \" B/ Q- |7 B2 { .active_low = 0,
: x7 u' I' R7 b$ [: }! M( D' v .gpio = DA850_USER_LED2,
2 q9 M- I3 K9 ~+ E0 U D* \ .name = "user_led2",
: R7 g/ y+ o- n+ t$ y E N G6 E .default_trigger = "default-on",1 x3 N6 V G* z
},, s9 f/ k$ w! u. \* u* P7 K
{( _6 X; k2 b# h5 v. b/ l! ?
.active_low = 0,, P5 D1 @: a* E- y" n! j* b& j
.gpio = DA850_USER_LED3,
0 [2 b" T% f( a# D .name = "user_led3",
( }' Y4 Y. z" @& @ .default_trigger = "default-on",
' Z4 e5 D( K0 s- l3 R9 O+ p/ ^, X },
% s I1 }/ c/ d- k4 F/ y};
) H) `3 j. b# Y' [+ D
' _2 S T. C4 o9 L5 S D, e4 fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# j/ ]2 f2 f: L: H, S .leds = da850_evm_tl_leds,
( F) c+ G0 J6 a% L) L, ` .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ u- b. p( Q) |" B5 x};6 s8 h d$ G- y8 u7 z
5 D3 G3 O% q* `4 R# ?+ ^static void led_dev_release(struct device *dev)" h3 G" P$ v4 ^. ], q
{
' r7 P, Z- m! Q& K& {};: S0 C) {+ ]- T
5 U6 C; m: H2 B' G% T( X: }* s& y) k1 Vstatic struct platform_device da850_evm_tl_leds_device = {
: j: O% {; d+ g8 ]1 ` L" ` .name = "leds-gpio", [7 S! u- G3 y3 G" R
.id = 1,
! L$ T8 g* t, Q% I7 a. G, I& }3 P .dev = {$ Z- N+ _# v1 y' [) L0 ~! }
.platform_data = &da850_evm_tl_leds_pdata,9 d5 u% _. {, b; {9 \
.release = led_dev_release,
# s, E3 p/ G4 @% b0 N }
) B, L; m- O5 v4 N};
* k9 J4 M! n/ y0 u& K( g( R
$ s+ c: u. e' x2 m U w+ D, wstatic int __init led_platform_init(void)
S9 O' v, E0 A) ~{
+ `/ m2 l& E0 {1 m/ j2 O int ret;
* c+ b- s! y+ W/ v9 ~#if 0
+ ^. S5 [6 K& p0 |: a# G1 `5 C ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins); Y" [1 z6 ?% n, t, Y- G/ @- E
if (ret)
4 P( R9 M3 |* e r3 e/ W, P pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
u5 d5 \0 O8 A "%d\n", ret);
& h* b: v) n# ~! }#endif
5 V$ z K4 A* E7 }! q5 ]2 f4 k ret = platform_device_register(&da850_evm_tl_leds_device);
. C( g4 g, l0 g6 K if (ret)5 P; w$ B/ W: P O. \: y7 g" c
pr_warning("Could not register som GPIO expander LEDS");" T5 ]0 `! k" Y
else
, n9 C: @# K9 n( q4 N/ x printk(KERN_INFO "LED register sucessful!\n");* t* v b5 B( B0 C, \- Z
, t6 l# B" Y/ X; B
return ret;/ N2 A- U! m8 g
}
8 b$ e/ k, {! W4 t
& B: y( K a4 `& x8 J5 C i8 Fstatic void __exit led_platform_exit(void)
* |" w3 b e% Y9 c6 E) L' H- U{
6 _/ C4 r# o) o! U' g platform_device_unregister(&da850_evm_tl_leds_device);& C2 D1 ^9 J+ w3 _# j: o" L! _' l+ q
4 d# P( [2 g: l J& |# {4 G* V! O
printk(KERN_INFO "LED unregister!\n");6 _7 f* r* V9 b& B
}
9 Y4 R" y. W0 |; L. O% S" ^8 [/ |# z! H
/ k& l) O" ~* }8 Xmodule_init(led_platform_init);: b3 e0 G( A6 m! z. _
module_exit(led_platform_exit);3 `7 Z9 D5 \0 R+ q( t( O
! m5 g3 j ^+ t vMODULE_DESCRIPTION("Led platform driver");: @; }% s4 L; i0 o9 |0 v7 Z+ v6 S
MODULE_AUTHOR("Tronlong");6 ]; U, Q8 \9 `" X
MODULE_LICENSE("GPL");* f. p& B" s4 j7 r, X. \
1 a. g% V2 l' b/ F
|
|