|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# m2 k+ P8 U1 g4 m4 p6 r
#include <linux/init.h>6 \* m9 V5 V# Y" y6 [
#include <linux/module.h>2 x* f, q" L6 Q" F4 {: r
#include <linux/kernel.h>
) d( d t* D N1 w+ }5 r @#include <linux/types.h>4 X+ L. U, u4 h7 t
#include <linux/gpio.h>9 ?3 Q1 f* D% ^5 X/ q( @2 Y2 e
#include <linux/leds.h>3 F7 z1 f* N7 E) |! ]
#include <linux/platform_device.h>4 H- e$ }0 n b) T6 y, ?% q5 K
7 c9 m7 l! b2 U; p! |6 Y$ Z
#include <asm/mach-types.h>3 _0 e# d: @: h, {
#include <asm/mach/arch.h>
$ k8 {2 v: I+ g; c# V% Y#include <mach/da8xx.h>% S1 j' N% I" W0 }2 W
#include <mach/mux.h> I& a% S. X! D: ]# F; [
1 L, j3 X6 d: T/ ~8 X7 r7 @* y3 t
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)) y, p& n$ j8 @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)* H" |) _8 l% N* Y$ Z8 W8 R
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); z# G1 d( |: V$ Y2 L. x" ^
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 R+ A/ M) w8 }5 M# V& q8 T
" H: g/ B* b: k' K1 S7 }/* assign the tl som board LED-GPIOs*/: T0 X+ p5 F+ R7 i4 U
static const short da850_evm_tl_user_led_pins[] = {2 R" r6 `9 S, G6 q; @ G
/* These pins are definition at <mach/mux.h> file */
7 Q+ n9 C( C; `0 x* ?7 ] DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 T: R2 ~, w# U @, e/ e7 {
-1) E; z# W. X0 p$ I0 Z1 `0 h
};3 L( y5 N1 q1 t. G, w2 Q
' a; ?3 F% Q2 z H& tstatic struct gpio_led da850_evm_tl_leds[] = {
W8 h. P) M( Q2 H% I2 C# p& h {, K7 o/ C! Z3 d- ~
.active_low = 0,' ?& s, G, ~9 R9 w, o5 i+ [
.gpio = DA850_USER_LED0,
$ t: X* P: y9 Y# f" s E .name = "user_led0",
! f5 Q) u5 X- o7 _6 ~1 R# o .default_trigger = "default-on",
. u3 d( M5 o# o& ^2 a: v },
& \) \- y* f" ?$ N& M' a {
- u: [/ p# Q) Y( S0 d# g H .active_low = 0,! h5 E7 s* p$ ~% C4 r
.gpio = DA850_USER_LED1,: e6 r" u% D* a! F6 H6 {9 K" h8 d5 `6 o
.name = "user_led1",+ P/ d! D# A: I- G6 R
.default_trigger = "default-on",
9 v/ E% K& E7 h) e },
. P' a6 d4 L% A. i& [( L+ ^ {% ~3 u& m+ J3 T7 s
.active_low = 0,$ g4 w: q' u$ K* }! E3 P9 e( H8 v
.gpio = DA850_USER_LED2,
d. ]! f1 v0 z) ~ .name = "user_led2",
% A7 ?% i, n( K% U$ M+ R, A .default_trigger = "default-on",0 s* V" p9 ?/ y; N- f0 ~
},
+ i5 }) J) f$ j {( @: R' u/ w, ]' z7 b7 Z
.active_low = 0,
2 f0 H- y% E x& K .gpio = DA850_USER_LED3,& s$ S" z2 d. z
.name = "user_led3",0 K$ L6 X. `" B0 G* r l: `1 z
.default_trigger = "default-on",
, E5 _$ `+ B8 m( R4 w1 K2 D& B },1 C5 ~) S. B# \/ ^1 h2 B
};3 g! o6 |" o& l" q, q
: q+ s2 q: h$ O" E1 I
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; I. a2 d, j- T8 @
.leds = da850_evm_tl_leds,
$ I5 C' h' B( l0 @: l2 b .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: u$ Z5 G l! n& S y
};7 X7 I$ ~, o- [& L! T+ a4 T
^) w6 @; j6 r% z: ~0 x/ x1 j* zstatic void led_dev_release(struct device *dev)8 L! T0 Y9 | n# x# T, m6 h8 _9 c* I
{
8 G9 d+ [) g; W$ p8 G) [};( w; S* b, S* z# k; b
+ B/ } P' r) z- X3 rstatic struct platform_device da850_evm_tl_leds_device = {
* [& j o7 D- N7 F5 c .name = "leds-gpio",+ C2 r9 a6 \- ?, a; k/ ]
.id = 1,. |. ~" T# M, t
.dev = {9 D5 y( @7 J. V, v- @: G: P( ]
.platform_data = &da850_evm_tl_leds_pdata," k/ E5 @, v$ L
.release = led_dev_release,
q% ?* p5 K7 c. ` }1 r, @2 R C8 m& R$ e: Y+ J
};0 U3 {) ]5 q, Y. n7 u8 |, ^+ L: x
; L$ ^( u* a. E5 O% kstatic int __init led_platform_init(void)
: a& G# A8 K- C% K& n0 q{
T2 |' W( y+ R- ^ int ret;
3 W2 o- H) y; q% G. K6 Z. R( H% r& y#if 0
. S: c8 x5 e' b9 k. H ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ K C) y" @. M2 n if (ret)# K9 x! K- c+ X' N4 d0 I& ?$ m
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 z. e( \4 ~$ `2 k
"%d\n", ret);
1 z+ |4 J1 _1 b#endif
3 c5 ~( K l" z5 `2 t. C; g3 i0 n ret = platform_device_register(&da850_evm_tl_leds_device);
. e; t$ c2 ?7 i# V" h U if (ret)
2 E! l2 x. d! u; N7 o( d pr_warning("Could not register som GPIO expander LEDS");
" {0 ^) N5 T+ N1 b5 R$ J1 i3 B else
: L# L2 [! S3 z& ]* _ printk(KERN_INFO "LED register sucessful!\n");
# \' T' Z* G1 Z- r3 ^, n7 f" j
+ V2 K9 O2 Z3 Q' b2 t% ~ return ret;$ m* S9 {/ b4 W. N9 {0 J+ x6 [! p
} ]2 C6 X: _ ^) n9 ^% y7 [9 y
. `7 Q7 H8 I, F, c8 c+ Mstatic void __exit led_platform_exit(void). s& [; S2 w3 v. ?: P: H
{
( \ t l$ d7 X platform_device_unregister(&da850_evm_tl_leds_device);4 f1 T' @6 F& T4 J/ Z1 h, J) i6 p( R0 h
* \+ U. v! m1 j printk(KERN_INFO "LED unregister!\n");
" \; |& O7 V" K& p R}
7 y+ h8 H3 \" N" }9 h
* B4 x6 u, b6 {$ emodule_init(led_platform_init);
8 V& \) ~# O0 l3 ]4 Lmodule_exit(led_platform_exit);
& q/ v4 l( A/ L- N4 @4 P9 V; s! ?" {+ ?) Q8 @8 I3 b1 r" S6 }
MODULE_DESCRIPTION("Led platform driver");
& D# X2 j1 \! u a1 |( X/ j5 @% rMODULE_AUTHOR("Tronlong");
2 L& R1 ]7 k2 @3 Q, u( L0 n4 RMODULE_LICENSE("GPL");+ Q* ^$ n. T0 }
+ I, a" L, K7 O P7 n5 }4 T0 N
|
|