|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 G7 v/ x! V- y1 J7 S#include <linux/init.h>
. O7 k; P0 g# `# _4 r; X. k#include <linux/module.h>
2 Z) q ?7 q# O. D/ `! F#include <linux/kernel.h>
9 d! O- y, E, t, |5 [ A( f#include <linux/types.h>$ E% R% j+ R7 c
#include <linux/gpio.h>$ a0 V) V+ [) P {5 C1 Q0 t
#include <linux/leds.h>. m) c+ S4 H7 x
#include <linux/platform_device.h>
, _+ X& Q* P6 a) ]- d) [2 c" R# {' B& {2 |! D* |5 K1 j0 u
#include <asm/mach-types.h>
n' l d( F3 O6 L0 Y#include <asm/mach/arch.h>" e; a# v) |6 Y+ `' e4 @, E
#include <mach/da8xx.h>
7 M" x3 q. z; N#include <mach/mux.h>
3 A: Z) i8 o% |* E$ Z% Y+ [. E) @ e
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
* |- @' g8 d e- F. Q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
1 {- V J1 |2 J( R1 y3 L% O8 l#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)% i$ f j4 G' j9 Q
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* x0 N* N* i8 E/ `8 q% x
, R9 u Z) }+ C E9 a6 G
/* assign the tl som board LED-GPIOs*/5 ~+ q6 r4 r! a/ j8 T) ^% d1 n
static const short da850_evm_tl_user_led_pins[] = {/ C2 |; z6 P8 X `" L
/* These pins are definition at <mach/mux.h> file */, S) x+ \! ?6 _% E/ W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" M1 P9 g6 T( X2 h8 @0 i -1- C0 J4 Y9 U/ J
};
0 k9 F) z+ J4 \# [& u4 S* q- }; `( ^5 D5 i$ u
static struct gpio_led da850_evm_tl_leds[] = {2 T% U2 v6 C2 I9 }# J$ p/ D
{
8 J) k& G7 C$ |( ^. M .active_low = 0,
3 j/ K6 @$ C4 a4 ?& c .gpio = DA850_USER_LED0,) ]( t( w8 F0 k- _0 U( \
.name = "user_led0",# v8 y6 R2 K' a0 I! `0 v- H
.default_trigger = "default-on",% p, ]2 f2 H; ]- B, T
},
) o; [5 I5 g+ U6 x4 I {
$ l8 J3 F* w8 @. I2 l .active_low = 0,
; I, ]4 x- u$ }+ Q .gpio = DA850_USER_LED1,( L: c& b4 U4 G: z6 n
.name = "user_led1",' J( I, N$ y6 ^2 ?" t
.default_trigger = "default-on",
( R5 c6 f$ Y3 e( ~* p },6 `1 ?4 D) |, q3 q+ ~+ P8 M
{0 Q# v. v( T/ M
.active_low = 0,0 v: ?' w6 G5 T1 E# c
.gpio = DA850_USER_LED2,. A* v4 V7 K( l3 a
.name = "user_led2",
}& O0 A* G, {6 I% G# |$ [5 U .default_trigger = "default-on",
0 g/ s/ z* v: J i0 U },
6 f+ \( s1 N, `& N* [# J( B8 M {
7 ]: S& I0 r; M' Y .active_low = 0,
( H4 V V$ m* x6 {3 C( e6 ` .gpio = DA850_USER_LED3,0 }& I' B# Q9 L" p* j
.name = "user_led3",# m1 Y8 Q( J! |* l
.default_trigger = "default-on",* T9 S; @, W- k; `* G, @5 h% V& K
},
% K! _, ~# W* A};3 L# Z4 m: g$ p0 @
* y! U: Y: Q! ]9 m7 t) y3 A: s
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
5 |1 H- @2 n5 c0 R .leds = da850_evm_tl_leds,4 |: ^( h. T% D# I' B' m
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 `5 S3 E9 R/ h- C5 q
};
; u J8 [* a; S. i
% B+ c' ~+ h* B5 Y/ I4 f Jstatic void led_dev_release(struct device *dev)
- v1 Q& @7 w2 y, W6 e6 h: T{
, i6 \: I' S6 a+ x! v};
7 ^2 J3 g/ R k9 ?' E5 W9 v. [" a: ^1 P3 [6 ^2 M
static struct platform_device da850_evm_tl_leds_device = {
* Y' `# z. h5 l .name = "leds-gpio",+ T4 ?- j' g$ k
.id = 1,
# l- N6 X8 I% w- Q, k$ N .dev = {9 Y) T- F0 f/ R
.platform_data = &da850_evm_tl_leds_pdata,
4 H0 m' O+ J; a- J$ I \/ G .release = led_dev_release,/ e* K, x5 j. }
}3 D# `* o+ h3 }8 D
};
) Q* j" I- f( a! a/ h+ g% u" [ P! x
static int __init led_platform_init(void)( V) g0 X5 I4 Z) Y8 j' p& b
{
! K' T9 R& E M' x4 [ int ret;
& B, ~/ |1 h7 b#if 08 o6 L) B" z: s0 Q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);. @& O |$ K! b8 X% Z$ b
if (ret): W- X" D J% t5 w% i
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ L8 k3 ?: p' ^' y$ ?' g9 E& r: V$ f
"%d\n", ret);
! \9 H: H* G/ X% u$ O+ Q& Q5 W#endif
0 C* D3 A- E0 H: p4 M) ] ret = platform_device_register(&da850_evm_tl_leds_device);
* v5 W; j0 _: n: @& w! o" q0 f if (ret)
4 }$ r. p$ k* I3 O+ S# P" p0 l pr_warning("Could not register som GPIO expander LEDS");% I! _0 V- ]5 j, y5 z# h
else' o' J! y' S% M* b! m) V5 v
printk(KERN_INFO "LED register sucessful!\n");6 y) f/ E) Q/ y9 V
9 m/ Z6 U& p* s1 H( K+ B return ret;
. o% u+ P0 c! n; ^/ L+ T& W' t}
* h- }4 v% ^1 z+ n. T! C5 f8 n/ b. e {/ @8 c. F
static void __exit led_platform_exit(void)
/ S0 o. U5 c: s- C+ V9 z0 x- j6 a{. G5 l8 P0 J2 f8 I
platform_device_unregister(&da850_evm_tl_leds_device);
/ n* j! @# ?3 _0 s/ @' ]& S- t* f' q1 }
printk(KERN_INFO "LED unregister!\n");+ |! o+ l* n0 s' Y
}
' X) R8 y% k$ M; M; P1 H
$ q/ r. g! _1 e6 T) _8 S9 u; Lmodule_init(led_platform_init);
/ z, s: C M- p& Wmodule_exit(led_platform_exit);/ X, ?3 [: {3 ~3 U* b K" Y
/ r2 ?# ~ }% j$ l8 D8 Y
MODULE_DESCRIPTION("Led platform driver");+ `0 ?! U! ^ o
MODULE_AUTHOR("Tronlong");7 r8 A/ g" J/ R1 @- C+ c l
MODULE_LICENSE("GPL");4 g9 n. x+ [5 O6 r; o% H9 j* \4 D
- ?# T. X$ i: b4 Q
|
|