|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ j3 Q: U# f5 R: T8 P1 }6 g& Y+ c
#include <linux/init.h>
3 q+ Q n: l+ ?1 j1 U* q! S6 R#include <linux/module.h>
% q/ h, V% N- r; X7 w3 Z- i( T' ~- F#include <linux/kernel.h>+ k/ f; D+ t! `+ d( ^6 j- F
#include <linux/types.h>7 F, U3 g4 u0 [" g& _: P$ R. Y6 }
#include <linux/gpio.h>6 a7 `; p) s1 G+ y, y3 l* y, s
#include <linux/leds.h>; M8 ]+ g+ f; \9 ^9 R
#include <linux/platform_device.h>! b9 C2 f. M7 @$ [; [
) U5 s3 O8 g( j$ t2 s/ f7 N#include <asm/mach-types.h>) n' {# m" J# v6 f W g
#include <asm/mach/arch.h>2 i9 t- |: W5 j. l6 [1 r# W
#include <mach/da8xx.h>0 V) Q: T' ~ Z1 T! z
#include <mach/mux.h>& N* ~/ U1 x& f! Y! U6 v
3 o" t3 @/ m5 e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 Z7 \3 ?4 e5 D8 Y5 h8 [' i/ K) |: {
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 g; V+ h& J2 r; ]* g6 @0 O
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 ?. t. l" f* W. |
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 V& s4 v! d2 w8 H" H! T; p8 [! G. @4 g5 G) G" c% O J
/* assign the tl som board LED-GPIOs*/
! }' n: u: U* f5 q5 Fstatic const short da850_evm_tl_user_led_pins[] = {, {7 J9 C: E2 }0 ]+ k" t
/* These pins are definition at <mach/mux.h> file */
9 ^4 ]$ y3 Q' ^8 t1 w! v DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 @+ s; O! a& j1 C W, A- ~
-1
" j: c; G+ g6 O) x2 L5 h5 k% D' E0 C};& H' m, b8 }' O5 Z7 d
) }8 S6 ?* x3 I+ O. Wstatic struct gpio_led da850_evm_tl_leds[] = {
+ q, y! L' t! @1 M. i! X2 k {
4 l; L, v0 o( J& {+ y. D! E2 f .active_low = 0,
- F5 B8 a8 E- Z3 l, c% p# _ .gpio = DA850_USER_LED0,! e# N" p! [9 u& I9 q, b9 J' ]5 l
.name = "user_led0",' d: R5 T+ M) q( ^
.default_trigger = "default-on",: N4 D/ J2 D4 ~
},+ K6 V" W9 V& J
{% c8 Z4 s* s( E# \, _; E4 J9 a) L" v
.active_low = 0,
/ \* o0 r* A1 z8 d, X3 D .gpio = DA850_USER_LED1, {* g' F! M. u8 V
.name = "user_led1",2 B& G$ y/ d1 G9 l" D9 t2 P( j
.default_trigger = "default-on",6 _; Z& s4 T& T, T/ b* ~
},
8 \5 Y# Y5 c8 G: i& g4 k/ T/ f {
' H# U5 Z1 y2 h- S8 |& S" e .active_low = 0,
8 g5 n0 w* Z. O6 D: k .gpio = DA850_USER_LED2, O1 }4 O6 r) U/ E9 g$ A
.name = "user_led2",/ Y' F2 ~+ `* I4 C, s/ K
.default_trigger = "default-on",
& @$ f4 X) o4 [4 L6 X2 O% w },
3 f, l4 ?! J( B2 ` {# n9 i5 B# P( C7 }2 r: w% f0 h
.active_low = 0,6 S. w9 M K* L
.gpio = DA850_USER_LED3,
- J+ {# M3 v" R7 b3 I .name = "user_led3",
% O4 F: P7 x$ j7 a! o" Q .default_trigger = "default-on",
0 x& I6 A; |& z( U3 l },( k* a1 s: U( G i _
};" `1 U7 K/ \9 v) p
( F$ |7 n8 O0 b- U4 [
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {; ~ i% P- X- S/ W5 ^
.leds = da850_evm_tl_leds,
: Y/ `7 j1 n, X4 i1 i7 z% J" I .num_leds = ARRAY_SIZE(da850_evm_tl_leds),' S: E4 j. {& u q8 F, k
};" H% [1 N( @; y3 E+ q
: d$ W2 ^, V: Q9 ~static void led_dev_release(struct device *dev)9 ]- o0 k9 i8 A3 y. `2 _) S" g
{. H$ D6 n0 A" j7 t
};& f) M6 L( a: I. _+ y8 b
; _7 u8 I5 I, @1 wstatic struct platform_device da850_evm_tl_leds_device = {
, g# ]( y+ b( r: m0 J! f .name = "leds-gpio",
; l. f! |+ y0 g6 S. |- { .id = 1,0 v2 R3 e, }9 p( G. h+ e$ y/ J
.dev = {) o2 x: F* W! j
.platform_data = &da850_evm_tl_leds_pdata,. ?9 f3 e( Z# y6 ^
.release = led_dev_release,4 K1 ]# ]) o# i& T' x4 T- L9 B2 k
}
5 d+ n- ]3 K! H};8 b0 b4 W! n& k: X
7 E. C; z3 Q8 z
static int __init led_platform_init(void)4 o1 Q, x+ J/ U
{
! ~2 |7 ], w2 v4 k7 S int ret;/ ]$ v) C, c# _/ |/ R
#if 04 R( B; X8 G( D
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 }8 q1 j3 v7 \
if (ret), F/ z! K' t- S7 I ?
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 n! L W+ v8 w' P "%d\n", ret);
6 `, V7 k; t8 ^1 _, X#endif& L ~ X! |6 E5 Y2 B- g2 M
ret = platform_device_register(&da850_evm_tl_leds_device);2 n# ]) s- n8 M5 ^' {0 A+ w
if (ret)3 R* u8 f; _" K8 u2 |! g
pr_warning("Could not register som GPIO expander LEDS");
$ X) |& t7 w/ @& o else
0 k8 u* j% ], |/ w# e& v printk(KERN_INFO "LED register sucessful!\n");3 M8 `% d( S o8 c; w u2 ^! F
L6 S9 |/ P4 o% Q+ T4 k return ret;
, r* H/ m, a& y2 [" U) y) @ v}
4 r1 x E1 d- `8 C' I/ M) a& W* p/ W9 t% p U: q, H
static void __exit led_platform_exit(void)
* x8 P0 S1 b: V6 ~{1 |2 ]$ J5 e& G: f7 n
platform_device_unregister(&da850_evm_tl_leds_device);
' J. e }3 R- O; }6 C
) q5 Q5 s+ _+ s printk(KERN_INFO "LED unregister!\n");# H& @! C( O4 M! M- R7 F3 ?
}4 B0 i Q. S/ s: e
9 S0 U x. P2 B2 G
module_init(led_platform_init);5 m. P8 n# e- Y
module_exit(led_platform_exit);8 I% h O: e0 O7 ~
) X; r& A V. _6 V+ K
MODULE_DESCRIPTION("Led platform driver");- g/ O; F0 h: c: P# Q" w/ D1 ~8 o% _
MODULE_AUTHOR("Tronlong");
% S. d9 F E/ b0 h: \MODULE_LICENSE("GPL");
9 r" R+ T7 ^8 A$ F
: }* [/ S6 w- q( {' ^7 K |
|