|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ s1 Y# P1 [; P6 a' c' Z, B( v
#include <linux/init.h>9 ?, @6 |8 b9 S5 B7 J
#include <linux/module.h>
- d$ Z. R# Q9 g) Z$ z#include <linux/kernel.h>; I* ?. O! M2 d( Z; u
#include <linux/types.h>
. u7 F/ c) s# W* z# ?- f- C5 b8 G#include <linux/gpio.h>
+ v% f" F8 A5 c0 u0 F#include <linux/leds.h>" C5 N5 a& |' t
#include <linux/platform_device.h>+ z/ a: R& O, g* R. \ X% v
0 \8 W$ ]/ B; @
#include <asm/mach-types.h>
7 c9 s0 M' q# r$ J5 ?. x% X- Y5 L#include <asm/mach/arch.h>
! ^( x* P. R' D+ i7 A#include <mach/da8xx.h>
% z5 h- u& g$ n7 G#include <mach/mux.h>
) Z% {6 f* r5 U1 T9 e2 C4 ?5 Q* f7 Y; o* C: X) i4 V8 S. J5 \% e* h
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# ]* ]5 B8 B3 Q! l! P3 {' @# L
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 y/ f0 L( _( `" o2 y5 M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 ~. q: A4 L7 |+ f Z7 l/ P, B w/ o#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 c; t; `* r3 V
' L8 f% X+ e1 b3 D. n6 N/* assign the tl som board LED-GPIOs*/
$ G6 x& b! o2 E: [4 k2 gstatic const short da850_evm_tl_user_led_pins[] = {
: R; f' w8 t6 `$ b* W+ c. u /* These pins are definition at <mach/mux.h> file */# e; t4 E" z7 n( [
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; Z( a3 o& Q, R
-1! U, R4 a& |3 i3 h% \$ V" f
};
5 H+ J y( j' Y" i: Y; \+ V" A- p. |! B& _* H+ z
static struct gpio_led da850_evm_tl_leds[] = {
! B( N# u! g _. ?: Z9 y7 H) o {% ~! m2 s! d$ M! B" A# c- P* g: z# w
.active_low = 0,$ k7 g! ? u* W3 ?' d, |& d
.gpio = DA850_USER_LED0,5 w5 I8 b2 e" C
.name = "user_led0",; | i5 Y0 ~) h- j" d. |% a$ I: V
.default_trigger = "default-on",! d+ c: T+ V: C8 _# q. D
},
1 m$ ?' Z7 t3 } {9 F) ~8 a$ D4 i
.active_low = 0,5 T7 R' k/ ~% v8 x! ?; A
.gpio = DA850_USER_LED1,; Q; a; R- C# m) {* k) n) }
.name = "user_led1",
5 y/ z1 w( f/ ? .default_trigger = "default-on",
k) y0 z) Q7 J$ ^' M8 E },
, L- O' r$ ^2 o7 R {" N. C/ \6 y4 q8 h
.active_low = 0,# L2 Y8 |6 U* n% i: x O9 h4 V; k
.gpio = DA850_USER_LED2,4 K* x. P# U9 f6 R, f0 h: t4 ^
.name = "user_led2",
" P; ]/ E) j* v) K" u% {0 r4 p .default_trigger = "default-on",
. b A3 {* { J1 v8 A5 ] },
/ g0 n7 C& {( o. ~* n {
* _% n1 v' G) D, I( b .active_low = 0,
) r* H2 t8 Z: |8 L! Z .gpio = DA850_USER_LED3,, Z2 c) _# f8 b( z- L4 Q
.name = "user_led3",
, Y! W) F* @- L- b9 X& W. x8 o .default_trigger = "default-on",. m: R6 }' f2 N4 l- }
},- P' P% c# K, }. @* f
};- G$ ^6 M7 t1 \1 Q) {$ A) u; m
: m1 w, \3 b8 [ t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
3 x' R! |3 D! G; C3 P; n .leds = da850_evm_tl_leds,% S. K9 U* _2 k* {9 m4 {$ ~! q" A( _
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 I8 L, r2 U4 B H7 o
};) ^8 P9 d5 ^) S5 S& p( M
/ {1 u2 J2 J% T1 Z+ vstatic void led_dev_release(struct device *dev)! ^8 l( }7 n+ T) r$ X+ q
{5 Y& R# b8 ?+ X8 S& i
};9 M w/ o, B/ I0 I! ]1 ~
0 r+ }5 u. ]! X, X/ r3 S% ?static struct platform_device da850_evm_tl_leds_device = {
( @* K9 v3 t- B+ D+ i0 P .name = "leds-gpio",1 K0 L9 F+ U- j/ Q8 q# z. w& t
.id = 1,
. Q$ E7 O' T: A# o6 W/ Q! f- f T .dev = {" W& l5 V6 B3 T: `2 f9 k) e: R& n
.platform_data = &da850_evm_tl_leds_pdata,
# F3 e$ V! W8 |! @% ?! r4 J .release = led_dev_release,8 ^0 B) D3 q+ S2 x: ]' r+ ~
}
: N% z: o) l) E N. Z};
- v$ a, B8 J( N2 c, X, g) j# M" ^7 Q
static int __init led_platform_init(void)
p) N$ ^' }# F: F' _6 o1 _( ]5 q{* @9 \4 h* I+ j, q
int ret;
" W8 C2 i& t/ |) ~# T#if 0& d- B- O8 O9 F G- h3 T
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: m9 t- h+ b2 d5 }0 R0 A if (ret)
: k. _$ G, l8 _+ [% d2 X pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 ^- P+ e q: P3 C3 y* {
"%d\n", ret);
6 X4 q- A$ w0 E+ L$ {9 l. R Y#endif) T7 g1 J3 Z; A7 ~+ C
ret = platform_device_register(&da850_evm_tl_leds_device);
) X: f6 s5 Z# S6 |1 Y4 t if (ret)( R4 t3 {2 ^4 g6 p
pr_warning("Could not register som GPIO expander LEDS");
2 j% v8 U* d' G+ ?4 @. A else" J- w- g; }" G7 I+ _
printk(KERN_INFO "LED register sucessful!\n");( C8 |: ]: C, u4 j& b' C+ }" S
5 ^: `8 q# M3 e2 v( K return ret;
* ^; J( i! O$ l3 ?8 e/ s}
' S0 r9 H P$ L4 J" C0 Q
+ H! A: ~" @) Q3 w4 m; qstatic void __exit led_platform_exit(void)1 T" d* y D B
{
- t# a6 c1 c+ ?5 }" y! o& f platform_device_unregister(&da850_evm_tl_leds_device);
4 Z& S7 V' Z# ]& w' p( H$ T7 K& k% `& G! O$ y. h% e0 J$ A
printk(KERN_INFO "LED unregister!\n");: q; R6 K+ ?; B1 F' u6 `
}
B$ L9 y; i, ^! v- N
: g' F# [& I" o3 M" t4 M6 Cmodule_init(led_platform_init);
: H# m- Q# h5 J& Y2 ~( w8 K. s* }: kmodule_exit(led_platform_exit);
6 Q& ]& \' [* h6 A6 g" q; q% y# s3 {$ p# e; f* w' W
MODULE_DESCRIPTION("Led platform driver");
3 @' e3 O \, I7 OMODULE_AUTHOR("Tronlong");: ^, G5 s" R# h# H* \5 N; `
MODULE_LICENSE("GPL");
! F0 W6 y* s4 `8 P! M' @: f! \* L0 f4 j4 d* E
|
|