|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ t& t( o" @& h# Q" k2 W1 D#include <linux/init.h>
/ W3 i4 `5 z2 c; w1 f#include <linux/module.h>
* L9 v0 T2 S, M. k$ `; l" L% e#include <linux/kernel.h>
& d# ?3 ~' v) k7 b, h6 v$ D6 [3 x4 o#include <linux/types.h>
, \( x0 W* {# y& s# {) J. P; K#include <linux/gpio.h>9 x, N. J3 e5 Q
#include <linux/leds.h>0 X: d! Q6 g! n1 b5 {
#include <linux/platform_device.h>
7 o: S; X1 E2 o6 x/ w- u8 N% `$ k; [# s2 s6 `6 _
#include <asm/mach-types.h>/ r; g+ L1 t T9 L: g' a
#include <asm/mach/arch.h>& Q5 X3 s; I7 K9 W5 }2 } P
#include <mach/da8xx.h>
* h9 D3 b9 M7 l! d# J; K A/ R#include <mach/mux.h>0 Y6 E) k3 b! |6 J+ V" \
# I5 _* L, N5 x9 y5 U( `- `#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 G4 `; a# V$ m0 k) W* w#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 ~1 G2 ~. g) y2 |# s% b: |
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 J7 R$ H+ o0 o( W9 n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; O: X9 O9 P5 q0 b/ \' ]+ m$ j/ t- \1 o; S
/* assign the tl som board LED-GPIOs*/
, g7 _5 P( O* p1 y5 K7 W* Gstatic const short da850_evm_tl_user_led_pins[] = {
4 C/ \$ z+ k- T3 E( F8 w /* These pins are definition at <mach/mux.h> file */$ z( x% A7 ]7 T3 P
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 r' H# j1 y& q( M3 _
-1/ V. W9 u4 |. x/ K# B
};
+ S7 T; c- R3 E- u. e1 k) G$ j, W. @) u: j
static struct gpio_led da850_evm_tl_leds[] = {. ~, S" C9 I/ _) k. T9 I% b [
{" i3 Z. U4 P9 d L, O/ `# o) c* K
.active_low = 0,
6 p; V% _/ {! h* r8 I .gpio = DA850_USER_LED0,, j" h5 \# A$ K! [4 S1 |
.name = "user_led0",* N9 @: y1 n- j' V1 c2 X
.default_trigger = "default-on",
8 [' L5 i$ _0 P" u. ^$ Y },4 ~7 q. Y, A" N5 F' E5 _, H
{, C) j8 U5 m6 Q; @$ j6 N% G, Q
.active_low = 0,# z7 A) G: ?% i4 n- l/ [2 _: f
.gpio = DA850_USER_LED1,3 O% L0 c9 H. {1 s3 m! i
.name = "user_led1",% C9 \% e$ @" _" H4 X
.default_trigger = "default-on",1 k+ v5 w+ E' T o4 n, R( {
},
2 ]9 d( w! q2 f' o6 ~' `( m {5 A8 _' v6 I9 r4 C, _
.active_low = 0,
3 _% S! t% L+ H8 U+ w .gpio = DA850_USER_LED2,. V8 s; [3 K+ R6 m8 X
.name = "user_led2",
8 O/ u, D; J% j( v) n1 V .default_trigger = "default-on",7 C8 H" c) Z& j/ w: I$ Z
},) o7 F+ J7 O) p% E
{& i1 f2 m( ^" b5 ^4 P
.active_low = 0,3 [, R b" O/ o+ u6 c
.gpio = DA850_USER_LED3,& }: O. {: A& N- e$ ]# D
.name = "user_led3",
T; ?3 C7 w& f, c! T+ F5 H .default_trigger = "default-on",
, \0 ?# W. }1 f! |7 J9 v% C },( E" ]6 c, x, J! V% ~, c3 b
};
7 d, r2 s% M! N2 x8 y* m8 \6 o. P
% c" l k- O/ M6 r! D4 gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- K$ Z) ?" J) `' M0 } .leds = da850_evm_tl_leds,
' y" L1 W3 n8 H8 i6 @+ C# A .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# [/ x" [. ]) x, E% s2 u
};6 M4 [( c. Q: x* g) j6 o
) e y; j1 [% `" Dstatic void led_dev_release(struct device *dev)2 r4 {& K$ y1 C4 x/ f) X$ Z
{! T/ o& k1 |( L6 p+ r
};
( g% m1 j5 z% L4 M z6 Y1 }/ G# K! e1 W
static struct platform_device da850_evm_tl_leds_device = {0 v5 Z. V9 `( Q" L, X9 B: K
.name = "leds-gpio",9 W, A* g% G; l# U: c' e7 X
.id = 1,
+ e6 A$ Z! ?# I8 F: f$ N8 W .dev = {
* i3 ^0 M) f% w8 j- i% T3 W4 H7 ~' W' N .platform_data = &da850_evm_tl_leds_pdata,2 P; C7 V* V# Y
.release = led_dev_release,1 N' s" O7 R2 ^' _6 k1 z
}
0 u N& j2 _2 o1 z};
) J; e* w4 S) U3 N; A: `! a
" k# a) h5 ]0 e0 m6 K$ p: Rstatic int __init led_platform_init(void)
8 V& ]3 S q5 Q/ L{0 v4 [4 X7 ~+ y( J% W
int ret;& ~" ~! l* f' E5 V7 N* f
#if 0! M" `! w( ?4 A) x& Z
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 O0 H# R( O4 T3 S5 O+ O7 ?4 D
if (ret)
- X" v1 k2 c) K: G5 v pr_warning("da850_evm_tl_leds_init : User LED mux failed :"+ Y' Z# |5 a( z5 O1 V. N& `
"%d\n", ret);
8 O6 z& D' S( e1 I#endif
& ~( o# C& u7 N* A9 W7 m7 O ret = platform_device_register(&da850_evm_tl_leds_device);
) Z, U: _% Z: ?8 T( X V/ G: \ if (ret)
i1 o8 _% ?. d0 @" k pr_warning("Could not register som GPIO expander LEDS");* Y. @( \8 m9 C5 J4 i1 p
else
1 E q2 B: H) L0 p6 f, _* t printk(KERN_INFO "LED register sucessful!\n");2 @2 b7 \+ Q! ~- M
8 N( G9 t! ]5 H( t( R
return ret;7 e9 e, `3 C; Y$ I
}) A2 m( E; W8 a$ i3 ]4 `
! e7 [% y8 \, q; _static void __exit led_platform_exit(void)0 ?5 V) q( g( I: f- ~
{4 D2 G+ l U0 i& \
platform_device_unregister(&da850_evm_tl_leds_device);
G( Y t. p o) p- m7 [3 R. {% h2 d; D' c2 o
printk(KERN_INFO "LED unregister!\n");
+ ~, w& L5 _0 b}
7 C) u* `# H" L2 T; d
- i* q' v: H& ?: ?9 [/ nmodule_init(led_platform_init);
0 E! V, Q2 w6 R5 o+ f7 G+ m3 Rmodule_exit(led_platform_exit);
' N! m' V+ |4 a/ w$ e" I
8 }5 \, S, }( C4 F% C' ?MODULE_DESCRIPTION("Led platform driver");
7 G" e6 U; X/ Y* a9 K9 @$ NMODULE_AUTHOR("Tronlong");
k H$ W' g8 q% OMODULE_LICENSE("GPL");4 \" X% r+ @6 X$ @
+ s. q5 _7 B+ Q! A1 p" q |
|