|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 O5 j1 S0 Q6 x/ f#include <linux/init.h>
1 I$ t/ g0 Q- o8 T7 w9 h% N#include <linux/module.h>+ k0 ?/ Y* V; p) h( { R o% }
#include <linux/kernel.h>% `) B6 V/ s% h2 R
#include <linux/types.h>( m. b; q8 Q2 K8 `! M
#include <linux/gpio.h>
( b ^& @; n8 H8 l8 `" {#include <linux/leds.h>6 N& K( Y% A* `
#include <linux/platform_device.h>: r; d Q/ F; a0 V( ?0 G
3 l {0 I: M7 V; ]0 r7 X
#include <asm/mach-types.h>
0 D% p( d, S$ z) r5 B; t6 j#include <asm/mach/arch.h># O! M/ B% n, b$ y6 [) u
#include <mach/da8xx.h>9 `1 z+ N! ~* ^
#include <mach/mux.h># Q& Y) b/ Y+ m; Q) k6 C
) R0 D- L& a) l3 u X$ N#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); L; r* W8 S8 U. I# u v; _
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 g* I) @/ H( D ^
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% V0 N c4 ~0 k% A9 P! y& f" H, E
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" }% L R/ F' |/ {& c& M4 K& h, e V% M p* H% n9 |0 R
/* assign the tl som board LED-GPIOs*/4 G( t! B% W3 q6 X
static const short da850_evm_tl_user_led_pins[] = {
. M4 [8 |4 x" R4 |, e2 w /* These pins are definition at <mach/mux.h> file */
/ w1 q" [! v1 F5 x DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! j1 {3 G1 Z* h8 M. ~* T, s
-1
" G+ L3 F$ E I# Q% Z, ~) Z};
/ C3 C. U4 v$ g" t/ ^' ?/ a
+ |1 }' V- {8 ^static struct gpio_led da850_evm_tl_leds[] = {
1 ~6 O4 x9 E, j0 D {; b. d2 R8 P( B' ^& j' l8 ^
.active_low = 0,( P6 Q/ O! `* @9 E# }
.gpio = DA850_USER_LED0,0 B2 a I* U0 M' U. R2 z: z; @+ Q
.name = "user_led0",% v, N# ~. j' w
.default_trigger = "default-on",
* m" U i8 t3 D% T% ?* C },
, O! L% e* s( m. W8 }/ N {
! d1 a \# J/ n7 R# t .active_low = 0,( t! y6 G% Q- f3 E5 N( b
.gpio = DA850_USER_LED1,2 |# w/ s7 i8 e0 V
.name = "user_led1",
6 l1 h) k8 |) ~ ^/ { .default_trigger = "default-on",# s% j0 s) f( z( j6 x& P
},4 P. ]8 Z% O5 v9 S0 \6 p5 a8 n
{
8 ^ t* ~& e, ]# S6 }5 E .active_low = 0,
! O* P3 M& {! R N, U: P .gpio = DA850_USER_LED2,3 u# D) H2 @3 z- Y% G O+ O* G! C* }
.name = "user_led2",
" O' m* E) _/ H1 h" r) i. a .default_trigger = "default-on",) D2 U5 x7 s$ U6 A. ^& O
},, o' p7 Y3 V0 @- W7 C
{9 Z# _, p' g3 m/ Y
.active_low = 0, A; _' x4 F* x- u- ?8 j
.gpio = DA850_USER_LED3,
6 u2 F4 s! E; ]4 J .name = "user_led3",. H% P0 E9 p: j% u( d' U" j6 D
.default_trigger = "default-on",9 a' y: ]9 z# _ C3 {3 {/ Q
},
! d e+ X3 R$ C};# v1 c) m& S, Q3 b! t) \
% w1 J; c! _! L& }6 k2 Kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( v6 V1 ]8 C# C. a& C+ n
.leds = da850_evm_tl_leds,4 |- e* q* M s. L0 {" |: o8 Q: ]
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' F# y6 k0 r# k* h2 B& u* |};
0 a) E3 e; [' [( }
0 O& f3 c, {7 [- g4 tstatic void led_dev_release(struct device *dev)
& R; |; V. M# ~% T6 `! `9 e- _{
0 @9 Q3 D* w8 O4 K3 A, ?9 v};4 I$ S* n+ b4 M! P L
$ R9 p# R2 t1 k/ x2 r7 wstatic struct platform_device da850_evm_tl_leds_device = {
$ x4 G$ w# q9 B2 O6 | .name = "leds-gpio",1 g. }; W/ A) n4 Z
.id = 1,
) ~) n$ s/ }, e2 ]) \1 R .dev = {" r. _( _" f7 N! F! y6 h
.platform_data = &da850_evm_tl_leds_pdata,
6 G( o8 K a# m! a; k3 V" Q/ N .release = led_dev_release,# I1 Y. t! B9 ^. |8 |: \
}
+ z9 a) D& W4 ^8 { W/ d/ ~};
. c+ K$ S) m4 y$ {8 h( a- h4 G' l$ F w8 k( l# Z4 r5 V* b1 e H% q
static int __init led_platform_init(void)
- v+ o- L$ |6 b ^8 L6 s- _{) W( ]+ q* a( V- }0 v5 ^' l
int ret; l- M7 J8 K; c: |
#if 02 z) u5 d" ^5 y: e! o
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* P" [! V% t( Y. V if (ret)
" j/ c# C) f$ P- w4 I pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
) ~+ @6 ]$ U" V, e# Z "%d\n", ret);
- O1 y) F5 V4 y4 j4 R1 a#endif
% g6 ]& g! L. L) }; Q0 Q/ m# L ret = platform_device_register(&da850_evm_tl_leds_device);: Y C6 \+ ~8 T0 ]) F6 _
if (ret)6 N" \( M3 `/ S: \- W
pr_warning("Could not register som GPIO expander LEDS"); Y) S! Q2 h% M5 U- \
else
: a* i0 G6 v% V- H W printk(KERN_INFO "LED register sucessful!\n");
9 J f, S& n7 `7 k# F `8 Z
+ l. i5 X4 R) G8 I" m return ret;
; k. p- ^( v. x3 B( s}
- R9 i) r7 P, D' Q3 [! J3 h' d* C
! w) r# n' D3 H4 s4 c wstatic void __exit led_platform_exit(void)7 a* E3 f, }' Y0 ^% j1 ^
{
9 C6 L7 G; f+ I& x* |& K+ b2 f platform_device_unregister(&da850_evm_tl_leds_device);
- n7 L) C4 Q3 L- k7 B2 p
& g# E# d& K- s& r9 Q+ k printk(KERN_INFO "LED unregister!\n");7 I+ ]+ D+ C! }& p
}
& g" S, u* r) C4 f7 G! [+ h7 F
* v- ] v5 L) _module_init(led_platform_init);
Q( W' V% X7 _/ K0 qmodule_exit(led_platform_exit);0 X5 g, R! ], s
# |3 E0 ]5 L7 b" p# CMODULE_DESCRIPTION("Led platform driver");
' s! I2 g& c4 W( x# R2 z4 QMODULE_AUTHOR("Tronlong");
6 Q7 q8 o0 P0 M7 f: \MODULE_LICENSE("GPL");
/ G7 l, R8 i% S# Z" s3 h% \+ n9 m- T5 T; V% r8 T( M, V8 t3 s
|
|