|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 z/ W( h s" i6 E8 o) w
#include <linux/init.h>
+ C1 N; l q% i+ w1 x+ u#include <linux/module.h>: X0 V8 S2 o5 \" q9 T2 R
#include <linux/kernel.h>
; V! b; z% [; K% h+ P6 \1 p ?4 N#include <linux/types.h>
9 Z6 J0 J+ k: U5 b#include <linux/gpio.h>' _7 c# `! s( J0 O8 L' ~
#include <linux/leds.h>
$ |" j5 N; ]) L' E" c; p6 {1 T) y#include <linux/platform_device.h>* J8 }$ P1 l( _+ I) _6 I( }2 W
, c* h- s- |2 E; v4 a9 S4 F1 V) W#include <asm/mach-types.h>8 D0 T' o! B9 l8 `$ g
#include <asm/mach/arch.h>
& K: n8 z- F5 q7 U# |! L- L/ K( N#include <mach/da8xx.h>: M& D5 S" r2 s
#include <mach/mux.h>
- [6 h. d3 g- u2 g" E1 Y. J
- |* {( \: {% k3 x#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 t' T) z2 {' t4 n" G
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 L2 n' S5 Z5 a( _#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 \% J8 Z2 U S: _! \#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. N: o/ w) k$ ]( k ?
8 |5 t' x# P) }- q. i/* assign the tl som board LED-GPIOs*/" r/ z* ^& K3 S; ^7 j
static const short da850_evm_tl_user_led_pins[] = {. X) H( x; g/ h" q1 \5 c6 Y
/* These pins are definition at <mach/mux.h> file */
5 d% Z7 y, L' m$ ~1 A* z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," [& s& F9 D3 J( B
-15 O+ O1 u) j" v0 Z' A) x: f
};5 L7 B! p8 R/ }8 O9 s' @ Z$ v
/ V2 p0 d+ v2 ^/ g& |& o5 e6 {
static struct gpio_led da850_evm_tl_leds[] = {
; Z2 `9 \/ g1 @9 a9 o6 w+ y% @! t {0 U- {! ?- L) g
.active_low = 0,8 G: C6 o) A( L2 [0 n
.gpio = DA850_USER_LED0,
6 A" Y) I! }. G2 E: w9 m .name = "user_led0",
7 i4 L/ l7 {1 _8 A! e. N' N .default_trigger = "default-on",* N1 }# X) Q' @' J0 s
},9 w4 r+ J. c2 b4 X7 |4 r0 h
{
) W4 Z; A' [( q .active_low = 0,4 e! S8 h+ Z+ E% ]# m& y
.gpio = DA850_USER_LED1,0 q1 Q1 K$ D d0 u/ I
.name = "user_led1",
% r, N% e; @% i. J* ? .default_trigger = "default-on",( H2 J3 m9 u7 A
},2 {8 J$ |8 g& ]; ?4 s
{) Y6 \3 l7 r( m2 w* P# _
.active_low = 0," K' D# E+ w9 Z7 l3 ?$ E4 \
.gpio = DA850_USER_LED2,' j( P) B/ U' z$ C9 Y @' _
.name = "user_led2",' {& M& @1 ~" W& M! ^/ P, U
.default_trigger = "default-on",
3 p# g# ^: \' P$ \7 \ },( ^* C# K8 h0 P' ^( l
{+ |: _8 _2 \0 h# z E3 E+ S
.active_low = 0,. W& r; b- f* o$ i# _
.gpio = DA850_USER_LED3,
8 y; t& ^& ^. A0 ~+ r" U# p3 V .name = "user_led3",( y7 u' d) c c, V3 H& Y, v4 X
.default_trigger = "default-on",, P$ K- ~) [0 r$ x8 K2 [3 z
},
$ a) X9 A4 z0 T3 E3 V};
4 N$ m. F- w9 p* E, f# Y5 G
3 s, y8 P/ ^ d' Z7 \$ s5 Nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ B1 l! Z, |1 N
.leds = da850_evm_tl_leds,! J* ], u+ v: u) Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 W1 |2 l @5 ^5 }8 e0 `
};
6 O% `' f" `3 s6 Z& L& ^5 v; ]8 W' P4 ?
static void led_dev_release(struct device *dev)
, s- u& v- ]1 t$ Q# k{& i# V3 x0 A% H$ S' k; ]. {
};1 _& A" V+ r4 d. `# s0 r% K& t
( Q' R# E+ e4 u |8 _
static struct platform_device da850_evm_tl_leds_device = {
; r' X$ f5 {* u a- C, }6 g .name = "leds-gpio",
{( p& X( ]% }* Q .id = 1,
$ F% I2 y7 u9 n0 k .dev = {5 k( _( y8 T) w& Y( a! }) U! i+ `
.platform_data = &da850_evm_tl_leds_pdata,# S% W V& |2 B0 ^
.release = led_dev_release,5 R9 @& Z8 F0 j. f6 g& l" |
}/ | g) t# N1 ?: x- f' _) p
};
; ~/ o' f" T7 Y
* f% d$ k0 d+ N5 estatic int __init led_platform_init(void)
' S# S1 v4 r. T+ }6 P, G{1 J l$ f+ g# L7 I4 F3 G' @
int ret;' B U6 W3 r* R! x" U* G
#if 0
/ }" ^7 V: \ @9 n+ Y9 I/ Q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! r0 {+ |: ?/ v% `& T if (ret)
# K% C* s+ Y4 V+ K5 @+ U1 k; \" @6 g pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' B9 K- f* e# Z0 N! k "%d\n", ret);
0 O( N. |8 }# k) G& Q/ H#endif4 H) @3 W- [0 d
ret = platform_device_register(&da850_evm_tl_leds_device);
/ E5 T& a" v8 f/ ~6 _ if (ret)
, O1 e$ O7 e% R pr_warning("Could not register som GPIO expander LEDS");
% ^1 l5 g2 k. |! E/ I7 p# B else# {' k* S- Y! V( d
printk(KERN_INFO "LED register sucessful!\n");
& a% y1 w }- u+ ?, m; W- N5 Q% F( I2 K. s
return ret;, o1 s( i0 |0 {, |4 _
}
0 z2 S3 s0 }! p f/ F1 R( b* [$ O
4 f7 \0 I2 G+ R, ] A+ y8 I& astatic void __exit led_platform_exit(void)
# f" `) Z* k. t7 E+ x1 f" j+ G{! V) D0 A. P1 g5 g' c. {$ n
platform_device_unregister(&da850_evm_tl_leds_device);
" Q/ h W. ~3 h1 g) q0 \+ f( l' s Z# t( s% ?6 U
printk(KERN_INFO "LED unregister!\n");
- R+ |6 q( U* ]8 b, o}3 Y$ G* y0 Q* I8 v- {) Q/ X$ ?
1 T/ O) r# r/ }; f! b% y
module_init(led_platform_init);8 ] H* f( }2 v3 Q
module_exit(led_platform_exit);4 j- _2 P G+ A% D
$ W3 [) M# ~7 b0 b9 i& I" E
MODULE_DESCRIPTION("Led platform driver");
# W$ n! I* P& D& Z( U- }MODULE_AUTHOR("Tronlong");
3 h( o& A; O; h3 b4 E% G6 A- ?! eMODULE_LICENSE("GPL");
8 g: r; [2 E8 E* V0 i' m) [8 x. l# f
|
|