|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 |( e$ a, g+ o' B Q, [4 w
#include <linux/init.h>
1 A5 p; C. C# @+ |) s/ S6 w2 x( H% w#include <linux/module.h>
% L& |. o3 O8 C#include <linux/kernel.h>" ?, v) J- b+ ] }. m0 b
#include <linux/types.h>
5 u# G* Z% n ~( |# r& g#include <linux/gpio.h>
' O/ I5 ]; u' l/ K* D: O) y% I#include <linux/leds.h>0 n1 ~' a7 C# F# [
#include <linux/platform_device.h>
' ~7 B5 V: X6 W8 k$ U+ Q7 p0 L
4 O: t3 M" }0 ~" r' }#include <asm/mach-types.h>
/ }, ~4 P8 f4 G' |#include <asm/mach/arch.h>
2 p, Z8 p& X9 n#include <mach/da8xx.h>/ y( w0 F8 v* _# P n, S: X
#include <mach/mux.h> W. B% |1 t i/ h, E' J
# P8 [; Q% h0 X, r& h5 b4 }& h
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)& _$ Z3 |' S/ J$ Y& v! A
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% ?6 z& I R; r#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' s& B; q- J+ E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
) }' O+ @( c. Z$ A* z. v
5 S4 P4 Q% a. Z- o/* assign the tl som board LED-GPIOs*/
$ Y0 b# f* O1 |+ ?* w- V) wstatic const short da850_evm_tl_user_led_pins[] = {8 W5 V6 a, C. V: \' h5 A: @
/* These pins are definition at <mach/mux.h> file */
6 r: p H ^! n DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 j2 s, ?3 I3 ^$ q -1
) t. L' q! `3 d: x) |};
% j @- L1 n) H' e7 U
5 |4 J. P( p$ F- r( o$ }static struct gpio_led da850_evm_tl_leds[] = {2 c! Y2 D1 ^" q) f) n! D/ t- m
{ E) T% \9 ^$ {* {2 ]2 W
.active_low = 0,7 v+ u% ?( t3 a# ?% q
.gpio = DA850_USER_LED0,* Q1 U, h8 [0 a( j; u
.name = "user_led0",
" S! \/ K! n. l1 C- o# T3 [ .default_trigger = "default-on",5 A+ m) p$ p- N+ f! |& B4 ?
},
4 L8 I7 s, r& l6 @) I y { t) A- e, s) F" b3 B" T* B8 w6 H
.active_low = 0,1 b( M3 ?4 y, }! `- s% o
.gpio = DA850_USER_LED1,4 l) k5 V8 h) |) ?& m7 ]9 W, g) ?
.name = "user_led1",; }9 e0 ?! ~1 `5 ~
.default_trigger = "default-on",$ f4 G* ]1 f; z7 ^1 p' C5 x6 @; l$ \
},
x4 K; ^2 D( S& j# ] {( t( C \& w7 G" B
.active_low = 0,
1 |- n1 a7 A |9 ] .gpio = DA850_USER_LED2,
a# p+ q1 v; V8 T- e .name = "user_led2",
+ P# Z# Y2 N5 u" Q' o. l3 e3 V .default_trigger = "default-on",
. L/ B, d1 q3 V },
" k8 q2 k9 s5 ^8 m {
: Q/ H7 L; M2 j. ~9 `& g .active_low = 0," P0 b( d$ a- Q+ s
.gpio = DA850_USER_LED3,
# F0 H7 t! V, T .name = "user_led3",$ p1 V: e$ s, O( _$ h7 G
.default_trigger = "default-on",
. ?! G8 b# P# y5 q, n T# k },% f. |& H3 Y! F2 O; U
};
6 H5 p; i( \& M+ t( o4 _- c
2 Y$ U3 \! p" N& Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- H$ O* `- V7 }$ m: s5 @/ u
.leds = da850_evm_tl_leds,' @0 j/ C! H/ U% _$ @& Z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds), x9 e- I. B% Q3 h; p" @( Q! |
};3 L j. Y* h5 M6 g+ G
* G$ Z; v" c! [( U5 m' W Astatic void led_dev_release(struct device *dev)
n# V4 Q/ Q, b: l1 {5 v2 B5 A{
1 i; u' t. r2 ^8 o7 m6 h};
% S* ?' _* ]) i$ |6 v* `1 b d$ q' F _; {
static struct platform_device da850_evm_tl_leds_device = {$ X# b3 c1 |. g" C5 e( Q" c) d
.name = "leds-gpio",
2 h% f# e w$ Y3 P" c+ h .id = 1,
3 E! g' U, b. r5 T3 v6 ~+ O .dev = {1 g% `) F* a4 J* K
.platform_data = &da850_evm_tl_leds_pdata,
[ R+ f0 B7 B .release = led_dev_release,% h, X. I1 h: t+ }
}1 m5 D- q* h$ l9 {3 `* F- R
};
9 G% c+ k( S& U9 n* d
4 J! N* k) e/ A. d7 b5 }4 Ostatic int __init led_platform_init(void)- d9 s9 H% Q7 e& W
{" n! u8 |6 M% o+ l R$ ~5 o2 y
int ret;+ P/ ?- U" o& }/ ?8 f
#if 0
F: L: ^* `# l, k/ i0 I: j ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' I/ x s, \- P if (ret)
. a) N# v* B' l& \3 [9 X" m9 | pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 t/ H' M5 u# j( @7 E- N {2 s "%d\n", ret);
: Q9 C- K* d6 D8 S+ v! C* n' K#endif
- d5 x& h4 i( f! y1 ~* ] ret = platform_device_register(&da850_evm_tl_leds_device);8 p$ `7 ~# @, @0 B
if (ret)1 c+ y7 ?. y" @; e, }. r; A& ]/ \
pr_warning("Could not register som GPIO expander LEDS");8 l: Z) v2 f1 I4 a: w. E* f; d8 M
else
! r- c" V$ S2 f7 L' U printk(KERN_INFO "LED register sucessful!\n");/ S1 Q/ }+ l2 L9 z& r: ^, n
0 X+ }2 _4 L" z2 | r( ^6 M return ret;1 b" j/ z# ]5 @* _6 T
}
% p: Z' q' _$ e' [* q+ C* U/ v1 ]/ T1 O0 I2 @% I4 d2 o' ^" L( a- }
static void __exit led_platform_exit(void)
& }! }4 C& Y5 Y, Q5 K7 K5 J3 T' T; z{
7 P+ ?+ P/ F5 t9 Z1 J8 ? platform_device_unregister(&da850_evm_tl_leds_device);
( P9 y% c2 Y, C3 g% ^# ]% m1 Y9 J2 N
printk(KERN_INFO "LED unregister!\n");$ C! [7 C3 ]1 c8 f. J+ l9 v- {' V, B
}
n' g O% }- {) i
; Q; j8 v' R6 c# Q2 _9 ]; q' Xmodule_init(led_platform_init);& @+ G& P# |$ p. {' L9 V
module_exit(led_platform_exit);
: ^. E; d& `3 ?! y. N# M" j
0 [( b. c. P0 F: _0 U( Z. y4 M6 P+ WMODULE_DESCRIPTION("Led platform driver");4 o; g5 S6 L& F9 [
MODULE_AUTHOR("Tronlong");: w2 w' g0 r9 O( `# h
MODULE_LICENSE("GPL");3 y9 P# F" P5 `+ P1 J0 P( S
/ q9 D! u$ N. T
|
|