|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ @# |" E0 Z1 c$ K7 U
#include <linux/init.h>
8 B- k' H: n/ d ^& b* @#include <linux/module.h>
' R# E1 F- W: o) n0 `. Z6 `' l, Q3 K7 F8 t* d#include <linux/kernel.h>8 z" @' m/ @$ Y; V! X# O) o- u% L
#include <linux/types.h>
) w- g- x( x0 C: a4 a1 T6 h+ V/ x( ?#include <linux/gpio.h>
) S- C( F; V' f) Y* r1 b! R- n#include <linux/leds.h>
6 V2 V" a' e1 A4 D. W#include <linux/platform_device.h>
/ @0 b# `5 \+ V1 D- i) G7 A6 y2 G/ u
#include <asm/mach-types.h>
& n& b! U F% B#include <asm/mach/arch.h>
b# d, O$ n% y& Q; O& P) ~#include <mach/da8xx.h>
& _, h. ?4 w$ e( l#include <mach/mux.h>& o5 f0 t' w6 F/ G
1 i I' O5 q H% a#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). @2 D$ ^! r, ?' s8 ^
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# g( m% o& K" H: N0 c& h! Y$ x#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 S+ I1 R2 L, w' d# F8 M: h+ O& y2 c
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ M) w" o9 w2 S) H3 m7 ]# p/ Z3 ?8 S0 r
/* assign the tl som board LED-GPIOs*/: g% g3 q1 i0 [* o6 N
static const short da850_evm_tl_user_led_pins[] = {
8 W& t) I5 X' D% h! |* r# P /* These pins are definition at <mach/mux.h> file */
. x( H" q1 O) g4 P' d/ X1 v DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 N8 \- u7 n* W; t& R M -1' T# T; e$ } [3 w5 R
};
- x5 a9 U# x" F" l1 w: R0 f
/ V( L, T* L. ]3 k6 p4 Dstatic struct gpio_led da850_evm_tl_leds[] = {. p3 h p! |$ C- l9 ]+ J; {, S
{
2 X( Y! ~5 k1 O .active_low = 0,
- O, c- E$ ]. O .gpio = DA850_USER_LED0,
4 A! O) h: L0 P8 u3 X .name = "user_led0",
+ }0 }' a. _# e5 i5 V N. M .default_trigger = "default-on"," q4 Q2 ?! G* l4 z+ c( E
},; p9 K( l7 t% j4 z$ [2 S
{/ v6 G8 b- q) i4 a
.active_low = 0,
" ]9 T! k7 c+ M8 F& h1 n. y- ~ .gpio = DA850_USER_LED1,. y9 t* Z9 L, d3 ?9 T
.name = "user_led1",
6 m/ G" U2 V8 \' {: s .default_trigger = "default-on",
) K& _5 b' }( v& E& O& Q5 Q },
$ ]0 ~: E* k1 f {4 J' t& \3 u D; a0 i* M
.active_low = 0,) s8 C% K1 G1 Y1 _7 @
.gpio = DA850_USER_LED2,
- ]% _9 y: \* O) d8 t% \* v0 S .name = "user_led2",
4 {9 c( x2 E5 ?1 G' H4 [5 x4 e% e .default_trigger = "default-on",
$ h5 c- x2 R6 r* g- \1 V" O- D },
+ U, H" h/ K/ ?$ v# ?4 o6 o3 Q {/ }! U4 B+ W/ C x- @5 V
.active_low = 0,
" ~/ O0 C% q/ k .gpio = DA850_USER_LED3,4 @9 D; q6 m3 U' |+ f
.name = "user_led3",, B; r4 _$ R# U$ b
.default_trigger = "default-on",' c' A, L1 h7 H7 g
},2 r( H3 L) T4 w) Q
};
1 F c' V9 W5 g! \* _" T" b! J% Y1 U7 `# d/ O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
2 c3 b$ r! D1 \* p& Z$ h: N$ p, Y: N .leds = da850_evm_tl_leds,
3 }! E7 O9 z. p+ |2 i3 X .num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 `' m: ]: c* Z) Z: j/ i
};
4 ~5 r4 O! {! F4 D) `- I% ]/ C) ?! j/ E* Q1 p; p b. h
static void led_dev_release(struct device *dev)- i; Z" b# P) V- H6 h
{
, x/ o J* e# I) U7 }" k0 g |};1 h* t* |' O1 B2 e5 |
% c1 k }# d3 A, M2 |- Pstatic struct platform_device da850_evm_tl_leds_device = {
0 y0 q9 L- [7 \- W) O .name = "leds-gpio",
0 h/ ]8 C0 M" a! J0 R' G$ l0 O .id = 1,
- b% j( H" L& A6 y8 e4 O0 A: q1 Q .dev = {% R" |- ]- j; W! R
.platform_data = &da850_evm_tl_leds_pdata,
2 z |5 C( G. j$ t .release = led_dev_release,
$ T9 t$ ]& ?& r; n" B* R }; ~; X! z9 r& D9 \$ \
};
d* w# b4 }! X- e: f; O
4 x: D4 i- [9 d0 b$ O6 H' rstatic int __init led_platform_init(void)8 y( ~% P7 T! I' B: Z8 q8 p F3 U
{' }4 }$ D8 p0 q q. R4 D( v% b# ~' L" e
int ret;
5 G8 E5 J9 l' c0 d6 t#if 0
' a4 ^0 n1 @- W, F2 I ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);7 Q! e( d9 ~- s G* F$ O
if (ret)' j, U5 [2 g$ H: r3 {6 `. p) e
pr_warning("da850_evm_tl_leds_init : User LED mux failed :" _4 w/ p: p% `/ d$ E- y p9 w; k
"%d\n", ret);, Z) Q/ c! V1 z- m6 l2 P( R1 n0 o+ A
#endif/ s1 ~$ I4 I5 V0 c4 t$ k: r
ret = platform_device_register(&da850_evm_tl_leds_device);" R) l* x# ?0 I' x5 P& r2 S$ d \
if (ret)
) c6 Y L5 p" I& L. j8 ^ pr_warning("Could not register som GPIO expander LEDS");
/ a% n: X$ \7 I# y( |3 u6 T- v else
1 Y1 H' [5 Z7 \( U) {. B printk(KERN_INFO "LED register sucessful!\n");% i& d! g! H# B: N
; S0 \: B- ~: D
return ret;
. Q# f. E9 ~# A7 R8 P0 H+ k1 [5 Y}) n: b( Y3 @4 u: V- U
. E9 d6 [! j1 U% g" d Estatic void __exit led_platform_exit(void), j8 a3 |! e D. R
{
: g* k& q: E3 n* ^% P" H& K platform_device_unregister(&da850_evm_tl_leds_device);$ H* k1 E# s* M8 W$ r
1 S. ?: |, R' }5 i+ A: c printk(KERN_INFO "LED unregister!\n");
* k# @: v6 \9 m' ?% Q4 f6 x}
9 U4 q, E* t. I
2 T; I) s0 K" n& z" f) B8 rmodule_init(led_platform_init);
5 G* e7 u: s: f0 J- C" Smodule_exit(led_platform_exit);4 b3 H- O! A0 T! |6 }
1 V [3 ~1 j' P' Y/ n+ w
MODULE_DESCRIPTION("Led platform driver");; U8 C/ F) s! i+ w4 x4 f
MODULE_AUTHOR("Tronlong");
8 x+ ]1 f* K- E2 R) R/ L9 ]MODULE_LICENSE("GPL");2 x2 D) p7 T. g _
W, O3 r& l4 o' d
|
|