|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" f6 Q; m2 k* Z3 C. \3 k
#include <linux/init.h>
; j# i) M {6 `( {0 \/ I2 L#include <linux/module.h>
$ ` l3 C; O% K% l4 _ v#include <linux/kernel.h> K$ d) e3 z! b% P/ h
#include <linux/types.h>
# j2 A/ s( b5 {! z# p% m#include <linux/gpio.h>- @& D$ J! |' B5 s) N9 v4 r4 X
#include <linux/leds.h>
) {1 s1 R- O0 |#include <linux/platform_device.h>
6 N" @5 p7 _2 w! h% B i
- J. a. ?$ B# M! B& \#include <asm/mach-types.h>& ~6 X/ F7 f2 v8 V B0 ]/ U: n1 P
#include <asm/mach/arch.h>
* O% ^! q2 g/ S9 k0 J' _#include <mach/da8xx.h>: v4 @# j) T) b- z: |* M
#include <mach/mux.h>
/ v/ P" {6 z& V* g+ A7 q2 Z( u+ }" M1 K. ~- r
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 j, k8 z8 I, N0 G#define DA850_USER_LED1 GPIO_TO_PIN(0, 5) k! [8 | A, }( Z! }
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) s4 Y3 \$ u: ?# H0 b& D7 a. `0 Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)3 U% m% e8 `) ? P- n8 i$ b. z9 O
/ j6 T! p* l3 M) c, K1 |
/* assign the tl som board LED-GPIOs*/: \2 }) }( Z/ v) U& g% C5 Y: ?, {
static const short da850_evm_tl_user_led_pins[] = {; a9 V" n) R, Y+ @* t( J
/* These pins are definition at <mach/mux.h> file */
$ b! E4 q! ^8 Z: U9 Q+ q/ o DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
$ O/ |( E" W2 r# ^- q U3 n -1$ t5 m: ]- J8 R5 _) }
};
0 G+ w, |) H( Y& ` j6 X4 i6 G6 e1 T& L
static struct gpio_led da850_evm_tl_leds[] = {. r) t. G4 W1 @ w- T4 Y6 H* Z
{& {! L) D) `4 x& D
.active_low = 0, W5 l% v4 h- E) d! _
.gpio = DA850_USER_LED0,) W/ |; j* N) n
.name = "user_led0",
# D6 q0 U& K( u8 z .default_trigger = "default-on",
. ?9 X& [. ?& T' r. ~ },
. z+ `- W0 K/ z" [& Q {! _/ c4 B6 s# Q, [+ S5 a
.active_low = 0,6 B" M- {/ ~- P. T3 M$ u
.gpio = DA850_USER_LED1,$ J9 b( Y6 u9 H9 s; r
.name = "user_led1",
5 y! o6 J- L. y: [& L9 ] .default_trigger = "default-on",
( ^8 o5 {; ]+ f% H1 D% ^2 B },
3 h2 y5 w/ q# e6 ?. r; Z {/ U- r& z( U6 B
.active_low = 0,2 L( w; u% y* f& R# \0 U' m
.gpio = DA850_USER_LED2,+ G+ l7 a$ C4 F& `' Y5 b4 \6 }
.name = "user_led2",
3 q; f: b9 n9 e: `# K .default_trigger = "default-on",
+ k4 ^5 k1 u( @" ` },, F6 v( z2 l! t V$ h) t( G) T, ^
{
- W% h. \" Z, A6 ?$ S H. } .active_low = 0,5 c3 q0 }! V, L( `" V/ h
.gpio = DA850_USER_LED3,
: p3 o; ]8 K+ {, ~: b: L .name = "user_led3",
% ~7 ~& v1 B1 @5 L$ G- D .default_trigger = "default-on",
+ |9 _ L3 \0 N1 Y6 @3 [! [6 @ },
3 ?+ p) x, Q/ N- h};
: q+ u& Z" W* x$ { u) k
" n) r# p. R/ Ustatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, J( E+ [. q3 F% ^* G- G7 B .leds = da850_evm_tl_leds,
/ r* B; Y ?+ z& x: V .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 U! f0 Q' _% T. D' I( c- I};" E4 G& H Y& {. W- ?* b
6 k% z* H9 s8 k* w7 J5 u% Astatic void led_dev_release(struct device *dev)
% k3 V: g9 g+ p: Y ?7 {% z{- i0 }* Y" t% T$ j9 E) l
};
! Q6 F9 r6 F' w, C2 |) c& U: T& l$ m
static struct platform_device da850_evm_tl_leds_device = {; c5 g) |* F+ r/ L
.name = "leds-gpio",
& n& B: T" I. l5 `' a$ W. C .id = 1,; m( w7 _5 E) Y+ }' _
.dev = {& \: ]) p+ z/ a* S1 z
.platform_data = &da850_evm_tl_leds_pdata,% Y& [1 P" ], A! ^" p6 o1 }2 U, g: O
.release = led_dev_release,
' r/ e2 r" h+ r }% W: C7 h, y& @* l
};
$ x1 D# L: G/ w4 C4 m# n9 K$ y! h) a* X+ ]' ]: x- p+ @
static int __init led_platform_init(void)
) E0 V: k6 W4 ~7 B4 I* t{
1 G0 F w/ |, A& p0 _2 a4 m int ret;4 z) X. i8 x: J5 }' G I4 c
#if 0
- j0 D% i5 [# \. X ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- {0 e2 u- Z; H9 B' T" I! C7 p
if (ret)9 W" | J3 c% o! C# B* c% P6 y6 u+ t
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# D4 K3 \. h. p9 R M "%d\n", ret);8 _9 c# C/ `+ c$ V8 G4 s5 t
#endif) A. z" {" Y1 c9 L
ret = platform_device_register(&da850_evm_tl_leds_device);: s \3 H* Y* a( n0 X& ~ _" G
if (ret)
M! J. X" Y; Z9 \9 X& L, ?% @ pr_warning("Could not register som GPIO expander LEDS"); A5 j/ \) S. }2 _: M
else% M( {7 e. g% m1 X+ Y C
printk(KERN_INFO "LED register sucessful!\n");2 Y' X+ M/ V% @
. d' l5 L" C. i! J1 q" z) A
return ret;% w& T: c5 m9 K5 d9 L- ~
}
: h; h" M2 g! |! w H4 f
- y) @% T. n fstatic void __exit led_platform_exit(void)
; }- g( h; W& a! H. B$ v' u$ c6 H1 C! a{7 X8 T" I; X! ~# k4 h
platform_device_unregister(&da850_evm_tl_leds_device);5 c9 [: Y1 M' y" H. U o: l- v
3 h3 @3 e8 }8 v( i7 c
printk(KERN_INFO "LED unregister!\n");
/ Q1 [! w; w) p& f/ E; B7 U}4 B+ H5 Z6 F3 [) e# s( Y
j/ j6 x0 |; `% d+ Q
module_init(led_platform_init);( ^" w$ u/ D: D3 @, A1 V
module_exit(led_platform_exit);
4 m3 G( n/ E# `. ]8 H+ d# K8 P! v {5 s
MODULE_DESCRIPTION("Led platform driver");
z+ R2 L3 o. N- v, u, SMODULE_AUTHOR("Tronlong");$ f, _- R6 ~2 l s& g9 H
MODULE_LICENSE("GPL");! S% f2 m& P) x
2 d' {% K8 t- R+ K5 ` |
|