|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- }, t: Z7 u: o#include <linux/init.h>+ l2 l5 y, n3 C# P& r k
#include <linux/module.h>+ N+ W% k5 \ V6 C
#include <linux/kernel.h>1 B7 }9 \8 ]' O9 L* L4 L% P+ l
#include <linux/types.h>) @ O9 ]9 Y- k& H4 B
#include <linux/gpio.h>
5 a8 g8 `7 [& v8 i#include <linux/leds.h>
3 g. \6 c- x9 {5 K# [7 d* p#include <linux/platform_device.h>
, M4 ]' j1 X9 l! L! M
2 Z/ t* j w5 s0 I2 v( {7 ^& }9 U#include <asm/mach-types.h>
+ d9 a, B6 g* a5 q8 b. L& ^#include <asm/mach/arch.h>, a2 E# Q7 q" x2 }
#include <mach/da8xx.h>
6 x) h6 D5 ~4 `/ K1 j' m$ N#include <mach/mux.h>
5 ?! A: }5 w2 F' }4 n! E0 _ n! z& p a( B: f
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 |/ p- n. V3 X#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)9 m, u6 x8 B; \+ F" ` z! A
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 Z+ F% l: T! h( ?
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# a ~# G: o. l; k9 W8 @
. H7 Q5 u, O/ s4 h) k0 P1 |2 v/* assign the tl som board LED-GPIOs*/
# n* c$ c3 \6 i3 B9 ustatic const short da850_evm_tl_user_led_pins[] = {% T# ^' p$ v4 p: r& A
/* These pins are definition at <mach/mux.h> file */ z$ [6 x3 X$ i6 U @6 Z8 Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
7 U8 c; W3 E. k: ^3 r. n -13 u" i5 `8 c0 W3 Z4 K' v5 h% B
};
& R4 t4 _7 F5 z0 p" i2 q% Q6 \* ~
. N6 P* L! D+ \& W% jstatic struct gpio_led da850_evm_tl_leds[] = {! i, K% ~+ K4 z e1 z9 T2 c3 L, M, B
{+ H6 _- X8 |4 I P2 z+ Y
.active_low = 0,
1 ?1 I- Z0 ~0 d0 ? .gpio = DA850_USER_LED0," I* a6 J, y# {. L% k2 y, a# l, N
.name = "user_led0",
3 |( I, X6 g ~0 R. R; \ .default_trigger = "default-on",
$ @; f) P K# I, p3 M3 f },% [# D( g: ]1 i; h
{. n3 V8 y9 ?/ } [* z; A1 {
.active_low = 0,
; a( U$ R) ?; ~. a .gpio = DA850_USER_LED1,
! L$ K' S8 h& D% t8 F: b4 r .name = "user_led1",+ s+ {, \# y6 v- k) ] J
.default_trigger = "default-on",% U% G9 B% e7 C6 A2 _" m
},$ A- \' F7 I" B
{5 w6 e6 e8 V# t. b4 n( M
.active_low = 0,
7 V4 x5 S) D; c) o7 F# T9 l .gpio = DA850_USER_LED2,
8 e! H' h' A- @ r1 q; X .name = "user_led2",
& N- o5 `: w9 A' B, q .default_trigger = "default-on",
% O+ s- i7 I) T$ M },9 d7 n9 r# s, a+ o9 ~
{' b* z$ \, {2 h' T2 _6 e( z
.active_low = 0,. x$ c" X' H8 n' K+ n! X
.gpio = DA850_USER_LED3,
3 B ~1 y1 h. k H2 U( Z3 |) E1 ? .name = "user_led3",
/ d, r9 u( E; k" n2 x1 ^ .default_trigger = "default-on",
N7 o% ]" K$ }: V) j },
: A" [& T) A( o9 A/ F( f};
6 Y, j) Y6 i' \% N9 J2 a
" I5 Z1 _& N% y: R2 x7 Pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 c: C$ n% s( w4 `) _1 ?: v
.leds = da850_evm_tl_leds,1 X6 z/ U" ?7 K+ I
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
8 v3 j; A' A4 g& I( \$ P7 }$ R4 x};& T# P3 \4 S* k4 D' d( d
- M) Z4 p1 V6 X; `; ~0 `6 Lstatic void led_dev_release(struct device *dev)- A/ ~% v# z* L: O ^2 `3 H G5 t& E
{
2 c4 o, o. Q- _8 O6 r};
* ~) p1 \, A( r/ J
+ _/ L: p! S0 fstatic struct platform_device da850_evm_tl_leds_device = {3 a4 c) h7 |- c; t
.name = "leds-gpio",
# d8 I8 Z8 K7 m/ h .id = 1,, q* K3 x( c4 s
.dev = {
4 k+ B2 z9 Y* S! @) i& R .platform_data = &da850_evm_tl_leds_pdata,
0 X+ c" f2 o0 i, U, [ .release = led_dev_release,) }3 Y" X0 x5 ^2 W* O
}
# s; B* |5 L. G5 k. ?8 z& X};
! ?0 q3 C# p% \4 V; h- ]1 A; R' S* e9 I+ g
static int __init led_platform_init(void)
) d, V5 v" k p& k6 D& G{
6 f6 R5 N* M( h! K int ret;- m1 \3 k) f8 Z7 }" A
#if 0
. O9 |: j: C( K6 \% X, M ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, z- J9 w5 B) @0 ]7 p
if (ret)
F) @" v' n7 |+ @$ o) v pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 d' O+ V7 z, z& W- G& Y
"%d\n", ret);
4 P l1 k1 C2 L#endif: p$ ?2 L0 @/ v. a- D# B
ret = platform_device_register(&da850_evm_tl_leds_device);
8 b% _7 R6 z5 [) F2 x7 b if (ret)4 V& k% E* X. K8 {; G8 V
pr_warning("Could not register som GPIO expander LEDS");
% P1 j" N7 |1 ~. X8 x else2 _$ t& `, P8 V; k/ _# u& ~
printk(KERN_INFO "LED register sucessful!\n");
6 r+ q# m: `7 j' t: n) i P4 ^' }: J- x% o
return ret;- U; m5 o& p9 k, k3 G, t+ c# T
}
) W" J3 M5 f9 |+ b' u3 |! m% H. e; W7 n9 l8 X5 ]
static void __exit led_platform_exit(void)4 J7 I( V# P* K
{! t) P) {( _4 l- x6 @1 |; A
platform_device_unregister(&da850_evm_tl_leds_device);
/ {9 V$ R! h8 e! T5 g# A8 e, w, p( J9 V9 c( n# E! ~% ~" w" b5 Z
printk(KERN_INFO "LED unregister!\n");/ g) G3 f) U7 A1 d e# ]+ H+ j* y
}
; p- }4 G/ w" N/ P; W
Y$ W) I3 p! v3 |$ rmodule_init(led_platform_init);+ z. l T/ d# k. Z
module_exit(led_platform_exit);
# _4 h- I) P) b0 _ o+ z2 Y* C. \ d
MODULE_DESCRIPTION("Led platform driver");4 ~+ R/ u! U: I5 f# {% @# m* Y9 z
MODULE_AUTHOR("Tronlong");( ~, B& W* T3 p0 A$ f- t
MODULE_LICENSE("GPL");( G- {8 t J/ a4 R; u- P" a2 I7 q1 Z
1 n& z, i* j) X: f* P5 h. ?$ e |
|