|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! M" q' ` q2 P. J" ~9 l#include <linux/init.h>9 E( s# K6 h# H4 L7 `5 X G5 M
#include <linux/module.h>2 p/ H! \) F4 N- ]
#include <linux/kernel.h>
0 L& X& V" A6 x1 ?0 J#include <linux/types.h>
* _" h9 I" V. ~0 \2 a+ k#include <linux/gpio.h>
# q( r, b% ~3 r. t2 c#include <linux/leds.h>
- V" {" t4 H. [# M# {#include <linux/platform_device.h>
! B1 J; S5 X8 _& H
5 U, f( F! H2 q# e#include <asm/mach-types.h>' \8 R. d3 U7 F. P
#include <asm/mach/arch.h>. T6 P, f2 D& D
#include <mach/da8xx.h>
- Q* E) [4 g5 Z- s7 _9 w#include <mach/mux.h>
3 X3 i9 N$ E+ h% b& }" c1 R8 k, B( C2 l0 f; P. R& Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
% |+ D4 G1 H" i: b+ Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" z+ X3 J _ F" p2 d% I( ^* A#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): \1 Y; S. G% s
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ ~1 r/ O7 E# Y; x. X' S: i) b
0 d3 |- Y. g- _: U
/* assign the tl som board LED-GPIOs*/( b2 p. q) Q+ t4 g7 U2 Q7 C
static const short da850_evm_tl_user_led_pins[] = {8 {3 T5 A7 O C' s% r' n
/* These pins are definition at <mach/mux.h> file */
/ p, W' M/ H6 g* W# m5 Y( L DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' z# i) W% M, h* D1 G* a -1
/ J/ s& S+ I3 B( b};
0 `, g$ [. P& w
9 F5 z# u+ ]8 ?2 s* m6 @static struct gpio_led da850_evm_tl_leds[] = {3 k9 M4 E# S/ p1 p; `* o
{" h% }/ Z x( C3 H8 U' ^
.active_low = 0,
4 r* \6 z5 O; H .gpio = DA850_USER_LED0,
9 r V5 {# w3 }! R' [4 ]; z0 ^ .name = "user_led0",9 s: P6 [9 ~+ B* e( Y
.default_trigger = "default-on",6 }) _* U& m& L T; l. `
},' L* a/ h2 Y/ B
{& @3 d7 e1 r* z- j3 G4 J
.active_low = 0,
: Z$ n5 r9 u% P9 i .gpio = DA850_USER_LED1,
, a. Z3 O' ]" z) Z9 t .name = "user_led1",
+ B4 k* _" M& \4 Q( q .default_trigger = "default-on",
$ Z' U0 c& [9 k. m: d9 K1 f. ~ },
) N; e9 V# f3 I* V7 j7 ] [ {
# M. h9 ^6 l4 [/ V6 G/ S .active_low = 0,
4 C2 a# P! f5 [: Z- m7 r .gpio = DA850_USER_LED2,% b/ Q: N4 I0 a* Z
.name = "user_led2",/ m f/ V0 L6 |9 j, w V0 L
.default_trigger = "default-on",
) k0 _9 Q0 E+ P% q0 f },- ~3 p' U/ ~0 C- r6 P
{
+ ]7 Q! h$ G6 W .active_low = 0," ~1 V: y7 c+ s3 o& x# h& n
.gpio = DA850_USER_LED3,- Y# ?2 J+ [- Y$ W' [
.name = "user_led3",+ j8 ]5 p3 } H" P4 S0 x
.default_trigger = "default-on",
% k* d3 g" o4 p% m' r) g: ?4 V& L },
4 q; E& A' i: ~, C};
8 ?3 h& v2 ]9 E( c
1 ~2 E2 n% [, D" ^+ x& {6 Pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ F0 D* U2 d1 b+ s .leds = da850_evm_tl_leds,
$ x- I3 ^6 u7 T& Z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 `0 S% n* j) m U. A2 t
};
. L- b) D! h5 R
7 @4 @) A) P: [3 U/ C4 lstatic void led_dev_release(struct device *dev)
E3 s3 l* J4 M; N7 q. m5 a{
2 r1 N: Q3 j' n* ^};
% U4 ]: v9 m: Q G, A% P- S) r; }" z# G* E
static struct platform_device da850_evm_tl_leds_device = {1 e/ K+ a5 `5 W2 O2 G+ H
.name = "leds-gpio",
0 a$ q# `7 x- J* q& e4 O0 Y9 T .id = 1,! [- f# y! l: H/ P6 e0 j
.dev = {2 h5 G$ @. ?+ v5 C# a
.platform_data = &da850_evm_tl_leds_pdata,
# @/ r9 ?: [* f% J- b, V' V .release = led_dev_release,
+ _* }: m d9 H2 n) L }
, _+ T& r0 e% s" g9 k2 i( L};
, B, y* S! v# p0 e. L- I {
$ l& h2 q7 D( o5 |$ o$ t2 L Fstatic int __init led_platform_init(void)
% X7 i0 ?' J9 w{3 i5 o6 Q/ a |/ S, {0 [0 N
int ret;: ?. O: B( E2 X" m1 Y; I( K
#if 0; z. z! J4 `/ ^& a% h
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);! k: E$ }# \6 n! ]) a4 _, v
if (ret)
9 Y3 T5 Y _+ P- q/ x2 r pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 A0 [8 B% v- C0 W( E
"%d\n", ret);, s+ N8 ?3 Z/ H7 T* Z' x' [
#endif- A* M% B* c+ W5 M8 q8 ]( V
ret = platform_device_register(&da850_evm_tl_leds_device);
% A& @( p: p9 D2 N4 H1 i4 b if (ret)5 [/ _# b0 c. y! R7 J% H3 ?
pr_warning("Could not register som GPIO expander LEDS");
5 `, m5 ~7 j& N7 c else
; H( e* ?( b$ t9 K printk(KERN_INFO "LED register sucessful!\n");+ C: Y- \8 C+ G
8 B P9 X* j4 r* j$ D
return ret;
7 |# O5 }: v# f/ i$ C}
$ s" v: h* e4 ~$ @' I
A- B3 I" d. t5 Mstatic void __exit led_platform_exit(void)
( E/ R6 u5 d: o+ a, w{7 B! l% `" v; D2 {
platform_device_unregister(&da850_evm_tl_leds_device);
$ J, E0 c% A# O/ v
_' @7 b; c0 E% F, `' g9 [- G printk(KERN_INFO "LED unregister!\n");; N+ F. b9 e1 a3 m
}
: H- k- L z3 e; e' Y* ~" o; O+ B; v/ Z) W
module_init(led_platform_init);- m1 Z% t) l6 V+ M
module_exit(led_platform_exit);
6 @. r; r, P) P
% O; Q9 p) @! p5 L( }3 J" j: ZMODULE_DESCRIPTION("Led platform driver");3 Y' u5 V( S& `
MODULE_AUTHOR("Tronlong");& P2 T, Z& n, M# P9 d+ O ]" q
MODULE_LICENSE("GPL"); d8 q9 X' _% ~! e' }" h' |* C$ e
1 c( `0 I5 Z- o$ W+ n
|
|