|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 H% }/ `2 X$ L. ?
#include <linux/init.h>
, _' W% d- v8 U2 ?0 P: f/ {# Y#include <linux/module.h>3 k. w3 B4 i: M; A3 O' x; |
#include <linux/kernel.h>6 i2 F+ k5 h9 b
#include <linux/types.h>" s6 e- b$ l0 {
#include <linux/gpio.h>
! @- ?2 j- m+ Y/ Q! W% |#include <linux/leds.h>
* O9 {2 y+ L9 A* V! U6 R#include <linux/platform_device.h>8 E3 x& }" V4 g5 I0 M1 }
5 D% j! Z: }9 K, ^#include <asm/mach-types.h>9 x- ^; c: a, J3 Y( `. r! r! L
#include <asm/mach/arch.h>
" e5 m5 `6 ^; c. [" q! L5 \( d3 u6 L#include <mach/da8xx.h>" Q$ j( f5 [, f+ I. [! c
#include <mach/mux.h>: v. q$ n: Z# b
( Y& w$ {$ o: l8 W# q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 I* R, K! ^" ]9 z# B' x#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) j" |, C ~+ v8 R# T/ C- s/ B#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
/ K7 i) F! ^% Z) a#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ p- `1 B; l: P5 }3 t/ _0 S6 |$ j6 D% A/ Y
/* assign the tl som board LED-GPIOs*/
# ]1 @- A' q" B# }3 C9 Q( g& fstatic const short da850_evm_tl_user_led_pins[] = {% u# {( l# D A! C3 t
/* These pins are definition at <mach/mux.h> file */
7 w# A( G3 {! z6 u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" a* z M! V# ] -1$ q5 T8 e9 N3 g
};6 |2 b4 A+ I" U3 X
7 L; C1 _! |/ xstatic struct gpio_led da850_evm_tl_leds[] = {
/ J( s5 Q: S3 n. k _- o {
4 Z6 B5 w/ N7 \/ `2 N, P" \* U .active_low = 0,
9 E3 G! }: e! Z5 S" j+ x .gpio = DA850_USER_LED0, `* P: h% X- M7 g3 p6 l& H: w
.name = "user_led0",5 [5 s9 X0 W( w, n) z! F
.default_trigger = "default-on",
" g- [3 s9 [8 L1 N1 I$ U+ F0 g }, O% |+ E3 D! z9 f
{
+ d: k$ b4 u% F/ c' l% U .active_low = 0,. P, y! S1 k' l+ v& U2 k( U- v
.gpio = DA850_USER_LED1,
& n. G3 k% a; [: e: F .name = "user_led1",
% M3 u( S3 A0 L; a9 _. ] .default_trigger = "default-on",8 ~1 l1 Z3 O) P4 R
},
0 }% x2 i+ q9 ]1 y {! t: M) ]& K6 T8 s- C% Y, s% W( m
.active_low = 0,
+ r# i! M' B) L( a# V2 a, p* E .gpio = DA850_USER_LED2,, n! |* }% O$ E! j+ l {' w
.name = "user_led2",
5 [8 Z0 v: C" C/ b3 Q; c .default_trigger = "default-on",
9 \: a8 O7 O. y! G },
/ \8 P' q8 J4 r. I {
2 A# |! x$ Q- I9 t: h8 ^$ _ m- i+ J .active_low = 0,
3 w/ i7 c% l4 o+ w$ Q .gpio = DA850_USER_LED3,- l2 ~, T$ D+ C
.name = "user_led3",) w/ s4 ?8 q7 g2 G0 @0 g6 Z- c3 t# g
.default_trigger = "default-on",
3 l6 n9 V: s9 q5 b( Z# Q H },
0 }) \- k$ A" x& j8 t3 b$ f4 I};
) `1 A- \( Y- A5 k4 `, Z T( h& }* q* U+ v9 w l6 O! D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* u: H3 y* g. ^& m" g .leds = da850_evm_tl_leds,2 Z4 o6 z0 _% r3 ?
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 V' a# B+ v/ r% p1 R6 I0 V5 @};6 C7 n5 M; V$ x F$ ]9 n
' \8 ]# f7 A+ p$ e; o0 Z. R) }6 l8 V) `( pstatic void led_dev_release(struct device *dev)
7 F& j) B! w7 T1 ?{$ m+ d( b4 U* g1 r3 Y5 [8 w( w
};6 J, Q( e" I, v
( B! v6 A3 t- q/ B/ t
static struct platform_device da850_evm_tl_leds_device = {
s1 L" b3 F; n9 Y .name = "leds-gpio",
# e: ]0 G y5 S4 W [- r) h% ^ .id = 1,
. [. B& a( \2 l2 g .dev = {) T8 W1 l. l- g4 H# u
.platform_data = &da850_evm_tl_leds_pdata,
! U6 T3 l! A2 L/ X9 b .release = led_dev_release,
1 k7 | Z; q! ~# W/ l5 a4 @ }
2 [( M( D" ]& c4 @4 i# I7 @};
& V( _3 g0 u4 t9 d9 D
6 M+ h: v) g; J* g+ ]- _" xstatic int __init led_platform_init(void)
' V2 n: d9 z4 C: f2 D{
+ {9 g. L) A& W6 ]" f+ f0 n0 G int ret;! A" d# u/ d6 F* C; Y
#if 08 h* q# q' A0 [4 e: V
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; o" ?2 m7 U$ |7 I- c if (ret)
/ m! Z& T5 u& f$ _ y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 a) T$ L! H# A3 C
"%d\n", ret);9 J$ X, _+ ^; j% x5 S
#endif& H3 [. y, b7 _' N% B
ret = platform_device_register(&da850_evm_tl_leds_device);
% K2 {6 M+ S# o" s; o9 I! w if (ret)
) E- G' C3 X/ _9 Z6 K# K) Z/ o pr_warning("Could not register som GPIO expander LEDS");/ g( w3 n4 y9 [( `* F
else
) v8 \7 Y/ ~7 {; [% [: \& v1 A/ s printk(KERN_INFO "LED register sucessful!\n");' S( _9 _6 P- Z# D4 ^& D! f
# K; F# f: i S
return ret;8 F: c3 w |% u' ]' t
}, V$ O u" [( h& ~- J$ f) A! M+ B
5 C2 k5 T& K- U* a% [& Hstatic void __exit led_platform_exit(void)" R$ _: y8 W: x
{0 E) p8 [) ?! x" Z
platform_device_unregister(&da850_evm_tl_leds_device);5 ~; M' i& m/ {) O2 E' K
5 ?; S, _3 K. v6 B- T2 t printk(KERN_INFO "LED unregister!\n");
& i) U6 O7 |4 D( i' e& m}9 e+ S9 U' z3 b
) n" n' O6 n8 p) N; N6 m+ S# gmodule_init(led_platform_init);0 t; I; n! V) G! M
module_exit(led_platform_exit);4 y" i9 z/ f+ g4 L/ q0 c9 p
4 |6 u6 Q* u' k; N3 jMODULE_DESCRIPTION("Led platform driver");
# d0 n5 o) m8 y8 K5 b) oMODULE_AUTHOR("Tronlong");' }& `' S+ [: \. `& z
MODULE_LICENSE("GPL");: ?3 O) i7 H, M
3 L7 y( W9 V/ Y4 p) U9 I# u4 i, a |
|