|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( s; H5 g3 [# X2 J#include <linux/init.h>9 y7 S1 U" \- ^7 @# T; O
#include <linux/module.h>! z, ~: l: N% f- `! y+ A
#include <linux/kernel.h>6 L _& s( U* ~, R' W
#include <linux/types.h> o$ }" }* v% i0 Q: d8 L2 P
#include <linux/gpio.h>
, `. T9 U8 E, F#include <linux/leds.h>
- _1 c& Y: ^8 O5 I: J; ?. U#include <linux/platform_device.h>3 Z" U. [- z% h4 H
* W6 A8 f2 S" {4 D5 U2 C# S/ r
#include <asm/mach-types.h>
. k3 t2 I3 Z% v# u) i# @( F#include <asm/mach/arch.h>: y U* F5 N0 Q, C5 {6 f' O9 p4 U
#include <mach/da8xx.h>
D! n$ f8 @3 t' T0 H4 B, b+ S#include <mach/mux.h>
: B+ ^/ ?9 V3 @, [7 t/ b! k* k: L: a
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 \0 b3 N* o$ i' A; w: c9 k" A' i#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# T& i# _5 X0 ^! Y6 n4 O
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 P9 w0 c% x" K6 D4 `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)6 m. |! Y/ y3 f+ |
6 `7 I/ M$ M& D/* assign the tl som board LED-GPIOs*/, u) ^+ `4 j7 m) P
static const short da850_evm_tl_user_led_pins[] = {6 k- w9 P& o# D1 }, g
/* These pins are definition at <mach/mux.h> file */) F2 C! L e8 I5 h, n5 g4 ]
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 F* E$ d7 V$ T- N' `- r) W2 m -1* D/ L! g1 ~. B% e7 n% E/ o' o5 W
};
6 F9 L- a, d- u x% [% w K! T$ B
static struct gpio_led da850_evm_tl_leds[] = {. f* e. n1 u% Z( R1 l% H) p
{3 M' U6 S$ g2 I0 _: v3 L+ i
.active_low = 0,5 x8 }, f; q7 x( ?
.gpio = DA850_USER_LED0,8 S- S2 F" @' O- V% w
.name = "user_led0",; ]$ v: @3 _ w4 q
.default_trigger = "default-on",
( Q @; ~5 Y7 v# L' k2 }+ p },3 {2 i$ q- F9 i. [2 \; Q O
{
5 P* `2 A, j' @; S4 y .active_low = 0,( n9 @) w h( W5 A) U4 t
.gpio = DA850_USER_LED1,6 w4 A: L! q! U: I# `4 S; V4 u
.name = "user_led1",
, o5 g4 d8 o& @6 |* J9 \, l5 Q .default_trigger = "default-on",
7 m- L8 C6 _/ ^6 m },
( T# {* K! J2 j2 H) b& ^7 x3 Q {
" q8 F) n* K* g5 b .active_low = 0,4 D$ J& [4 R" C
.gpio = DA850_USER_LED2,8 F( V/ t: C" \! G- b1 e% r! r
.name = "user_led2",
0 K }6 m' X) t/ A* o .default_trigger = "default-on",
0 a }9 o, q. w8 S3 ^1 C2 M! M1 x },+ B; _' A7 E/ }/ M1 e5 A
{
E: q2 \4 a* w; h5 n W0 I .active_low = 0,
, u2 n$ I8 R2 _# }* \3 y( R .gpio = DA850_USER_LED3,
: s! ^( m# _. t( Z2 L .name = "user_led3",, E/ t1 t) f; P: u* Z7 |3 q' y- U2 a
.default_trigger = "default-on",+ |4 `7 @1 V8 |1 X; F( P' ?
},2 U" V( N+ z& r3 }& P
};; R# c9 K9 {+ A
( z. C. ^) u. b( y9 t! J
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 N; M/ N' q! w
.leds = da850_evm_tl_leds,, D6 [( l7 `5 G# o/ g+ v$ f
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 { m L' X/ e }
}; e" c& n. M0 t4 Y* ~* R; n
0 O9 r! M y; M
static void led_dev_release(struct device *dev)3 q2 D/ q- y& Y$ A3 E/ R& X
{
2 G1 w' ?' f: B6 C& k1 s2 ] c};3 ?' q: }7 Q# Z& Q# T3 g, O
+ v" ]: z+ u# }, G0 \: Vstatic struct platform_device da850_evm_tl_leds_device = {
. L3 m) H% A* u8 m: c .name = "leds-gpio", F7 ]2 |; x/ M% A% Y4 R1 V
.id = 1,* Q4 a5 l% F0 {0 H) z9 t$ w
.dev = {
# W/ v$ ~( |; M+ i& S6 K; G .platform_data = &da850_evm_tl_leds_pdata,
% C1 D8 x* s- p U+ T .release = led_dev_release,6 c* q+ ~" |4 f6 [: ]
}. j' d- o# T0 [ Q; s
};3 ?) N6 `! H5 ?, n
+ g( x2 t5 ?/ n4 O3 z+ Q8 x6 e- L; T
static int __init led_platform_init(void)
( t( k( J" U ]& M* K% a0 a{4 n' [/ g K7 V% P* F& a, h
int ret;/ \- b5 F3 A4 ]+ {( Z1 q# g
#if 0& N& v& r( p i+ @4 z; w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. v) A6 A; N% f" t1 B5 v if (ret)# [8 R& x4 w( R5 x6 {
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 b5 r/ M2 p; e0 l: r% W8 y) T1 ? H
"%d\n", ret);4 F9 R5 N) |: H
#endif
8 P$ i# F' K* D- b- y ret = platform_device_register(&da850_evm_tl_leds_device);
- E$ P$ O9 i9 g. f# _# I if (ret)2 H+ H$ D% W9 u
pr_warning("Could not register som GPIO expander LEDS");
+ e8 v5 V/ U8 x9 S! j else( ^- ^, |& q6 l+ [5 R. f
printk(KERN_INFO "LED register sucessful!\n");$ f; ]9 {+ Q5 P+ f
2 s3 {$ o: U' A6 r* O8 X
return ret;
; t4 \! ^$ `% }3 b3 q: o! o; N}$ N3 B, F" _) ?% T, ?3 G' k& C
7 Y& D4 i4 h% A& V1 O$ X# }static void __exit led_platform_exit(void)4 q- g" @- \7 d3 X' o& m- N! \9 L1 z
{
{5 ~% J5 t# V& I platform_device_unregister(&da850_evm_tl_leds_device);
* H' Q8 q3 g) k9 g% F
% N* m n5 N: \- x printk(KERN_INFO "LED unregister!\n");
% J! x0 b( r, C2 |) k/ [}, |: i( t1 G% g" N- a* a; @7 K# ^
) c+ r% Y7 x8 Q$ O: C3 ]8 a: j! `' x
module_init(led_platform_init);$ k2 M8 W( A0 F4 W
module_exit(led_platform_exit);
) a2 _1 o- x6 c6 k# Z1 r M
4 G* }- Y! {5 z4 b# Q) JMODULE_DESCRIPTION("Led platform driver");
) q) a4 A7 L) e2 f5 _3 l" LMODULE_AUTHOR("Tronlong");
9 S' F' q5 r) i) mMODULE_LICENSE("GPL");
3 K# k5 R, f. [: p4 d/ d; {8 _2 V% }1 J
|
|