|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: }* I8 R1 W' B/ p#include <linux/init.h>
* J; s, |2 u( J7 ?/ O#include <linux/module.h>
+ q: m! z n- G#include <linux/kernel.h>5 i9 c/ e( d I' }& d: d2 S
#include <linux/types.h>
4 t4 `3 D8 s- Y% b+ ?: C7 Q5 ~8 T( w#include <linux/gpio.h>
+ c8 c( ~) E! s5 _3 m. K#include <linux/leds.h>( y5 l% _5 i9 U1 F/ E
#include <linux/platform_device.h>
9 C! u4 U2 ^ ]6 l* b. t3 e
/ U. A! H z% t#include <asm/mach-types.h>' n4 R" `7 D1 e/ V A4 u4 }
#include <asm/mach/arch.h>: L: k% ~5 H3 d, M4 x( d
#include <mach/da8xx.h>
) }, s) ^3 ^! ?9 \1 f7 Y" \' W/ b0 F#include <mach/mux.h>
9 X; S- x8 K/ l) L5 {5 [
% s2 ]7 L3 }6 U$ e' v1 v* C+ \% |#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 J; ^9 H" [$ A/ i$ p2 G* O#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% k& C4 V1 A }( Q5 ]- H5 j- ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, `8 O& m3 d, L/ u#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! h. Q9 C3 I2 Q3 E9 U, A3 L' U: h4 A7 F) R# B. j
/* assign the tl som board LED-GPIOs*/
" Z# R/ Z# c* a% k( \static const short da850_evm_tl_user_led_pins[] = {/ L' ~+ [& d" J3 v
/* These pins are definition at <mach/mux.h> file */
4 d" I: d9 @0 D1 p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, \9 u1 h/ E) F5 F! K$ ]! u; t# ~ -19 I; d$ j1 S/ M$ W6 X/ Z
};
; s; P* y q" u" d" J# z/ {% I1 R$ p' w- N# y
static struct gpio_led da850_evm_tl_leds[] = {
8 J& w) U" D: A) n* D( [ {1 }6 G7 W7 q# V& G
.active_low = 0,$ H ]" q. B, P( ?0 E
.gpio = DA850_USER_LED0,' w- S+ t# a: w
.name = "user_led0",
/ c/ Q: ^- P& R4 C .default_trigger = "default-on",
, S1 d) E- u8 e4 @2 _$ l, i },
5 _8 o0 v) i; ] {
4 Z1 _7 M$ M% J+ {& `; B2 D5 L .active_low = 0,
: Q, b9 \$ H) x$ U$ u .gpio = DA850_USER_LED1,
$ S/ f6 Q/ a0 O" D .name = "user_led1",
% e1 ~' d5 u1 n# o2 v/ h9 @ .default_trigger = "default-on",
) X' n. U, U7 U: g0 h },% Y& e- o E- o; ^ v
{$ l, u$ y8 N+ ]/ I
.active_low = 0,( C+ I' v- d" p
.gpio = DA850_USER_LED2,6 A" c! a ^. Q" G& c* y5 Y8 A
.name = "user_led2",
2 [1 s7 d) E+ z9 r2 e# w, a .default_trigger = "default-on",+ }" a" R/ G- S( |# d2 { Y
},: A) G% I+ y5 `* B" [
{3 b& {" C5 a0 ]3 {5 [
.active_low = 0, H7 h( U. r f
.gpio = DA850_USER_LED3,
# {, n0 x) s/ U5 |3 A7 t" C1 R .name = "user_led3",
7 ^7 O' _. g6 H m. S G .default_trigger = "default-on",2 c6 D5 K) r0 m* P1 S
},8 h: C: d! N Q9 m1 e% L
};0 A9 ]+ x: r& Q8 H9 ^( s0 h9 p: O
R& r8 U* J+ k0 hstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
$ q9 p3 c: g/ C; @: V3 h .leds = da850_evm_tl_leds, }+ E/ f( Z- j& t5 |" c
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 V8 B3 D; Y; X2 b
};
2 y0 G$ W, E" \2 Y3 R$ X# h8 k7 n+ l' ]/ _7 I' n6 d/ s) V% x
static void led_dev_release(struct device *dev)( Y. n5 x% L" T0 D% \
{* g3 `! @8 w* r! o+ ~) R
};
8 b" h' s" L2 d+ h# X3 ~% L, h1 V8 q5 X n
static struct platform_device da850_evm_tl_leds_device = {& N# K# X. j3 h% ^9 E! o
.name = "leds-gpio",
- ?/ d2 |( }3 e& h6 C .id = 1,4 p- H9 H t& D. o+ C
.dev = {8 {/ u8 u; m* V9 r1 M. T
.platform_data = &da850_evm_tl_leds_pdata,4 V2 b9 o3 e- W+ Q4 ?$ h
.release = led_dev_release,
) ~/ ]/ j( o5 ^6 ^ }: n# }& |8 Q4 e) d/ F
};
8 }9 `( F- p1 y4 ]. Z$ i! v2 k* {8 ]' ?; j
static int __init led_platform_init(void)
( Q/ q% P& t. ?9 e3 Q0 H: C{! b. r1 C: Z5 \% e8 \% _ m% H6 b3 L
int ret;
) H6 B) T" V6 ?4 ?7 O4 R+ _#if 0
% I# m5 d6 w h$ f ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- W! m! n0 A5 D. S
if (ret)
+ K9 c, [. \# o8 c5 |5 V, U pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ A# }' e6 Z x1 i$ G! o "%d\n", ret);
% n/ ?( S; D, Q$ _# V1 j#endif
! X K. F- [/ G. L7 I ret = platform_device_register(&da850_evm_tl_leds_device);
) Q1 n# _2 t: u5 A% i6 U, p2 g. _ if (ret)
) G1 L, }( w; K pr_warning("Could not register som GPIO expander LEDS");" K2 Z7 j- S" B% d% f7 Y. }
else
0 @& {! G: R" r3 ?6 r- Q printk(KERN_INFO "LED register sucessful!\n");
$ ]: W6 B7 {* n3 J% e8 P/ c( w" I. n, U: Y
1 j* |- N( }6 L& p6 r3 I return ret;6 w+ a2 _4 N. T; ? k% [; g% A T
}
/ R/ s) j* R+ `. {% K5 S" l' J7 Q
static void __exit led_platform_exit(void)* {( Q, \! ?% h' @
{+ O" N) B3 D- h' h8 k9 N
platform_device_unregister(&da850_evm_tl_leds_device);
* r/ o5 o3 r9 P$ O
8 W, K8 o0 a1 @$ G% w printk(KERN_INFO "LED unregister!\n");
" z( G! r! D. r H+ t}- {0 e6 d) Q G! U% d
/ L8 y& ~& A" H) g+ G
module_init(led_platform_init);: G% W# x- l7 |& r$ s8 ^
module_exit(led_platform_exit);
- m( \" U8 X: j# t+ Y# v
5 a5 I. x) K; B3 [2 R- f+ @- tMODULE_DESCRIPTION("Led platform driver");6 D, N# y& ?( B! o$ B
MODULE_AUTHOR("Tronlong");+ P# C3 y" Z9 s( o" Z, R
MODULE_LICENSE("GPL");$ I: h5 G8 i% P3 G8 A
% {' b# j P/ o
|
|