|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 M( f# ?+ U# i+ i$ F5 k" ^& ^1 O5 g
#include <linux/init.h>% m' K4 J! T6 h# W
#include <linux/module.h>; a0 n) v# q: V' p$ q6 h2 C [
#include <linux/kernel.h>7 V2 C8 q9 P0 _7 U+ {' M
#include <linux/types.h>
( S9 P' f2 e" v8 }4 |1 @#include <linux/gpio.h>
/ ~* {- H3 F6 r+ V0 K, u#include <linux/leds.h>
) {. d0 r+ ?% o0 p3 Z#include <linux/platform_device.h>& C1 f J" U: m( H. ^" I$ @
6 V5 |- d5 a5 Q- Q: _#include <asm/mach-types.h>
0 a X' K- N4 V) E, @. S' ^- e#include <asm/mach/arch.h>
$ t: z R. @& e9 T- v, @3 c. y9 U#include <mach/da8xx.h>* Q+ p7 v8 E$ K: G/ E8 X4 K
#include <mach/mux.h>
* I3 N4 j2 w, {7 _( x$ S! d/ A2 t# B0 U, j- t0 c' C' F' @
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) l0 C7 n- q" ]& k
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 D1 N3 o: m% z% v3 Y% M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ q, l- M8 @: H" A( s; z) S0 o
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- Z w# ?4 y, T& H& l) h
# k' R7 @, l$ G* T# `4 J7 [2 P8 t/* assign the tl som board LED-GPIOs*/7 _6 O2 ] `( e* Y
static const short da850_evm_tl_user_led_pins[] = {) T# z7 r! h) d) d. t6 J
/* These pins are definition at <mach/mux.h> file */
5 b; e8 \& k' |. S DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! p9 @ N. b1 P9 J2 a1 b; T. T -1
8 q/ I2 J {+ b. P" t0 |};
- |7 f4 c4 \5 V. ?- P$ J3 i& u# Z" O/ `9 W8 p8 w
static struct gpio_led da850_evm_tl_leds[] = {, }/ K# l `7 S' K! ?! K& {( A
{6 l- P# m' _/ K; J* C# C
.active_low = 0,
7 p1 g( K8 T0 j* [ .gpio = DA850_USER_LED0," X( O+ B2 ?9 M
.name = "user_led0",( S% k+ @( Q; X" V4 d) q
.default_trigger = "default-on",
. B7 u6 l0 h) M; ]) n },
. ^1 c' p5 N' j: g3 d- q* | {
' y) A, f$ P7 I, x+ G1 m$ { .active_low = 0,1 Z; A% T2 U: H& z3 G" Q4 P$ X5 e
.gpio = DA850_USER_LED1,
; L& G/ n% S/ U) a5 F .name = "user_led1",
8 R# t, D; f+ H .default_trigger = "default-on",
' |/ U" f- v* v5 W2 }- {5 A( O },
1 N. H9 C& W: C; ? {
' r: q4 x3 Q+ ~6 ^- x8 V. w8 x .active_low = 0,( p! W# g5 r7 b4 R4 q' Y
.gpio = DA850_USER_LED2,
! g3 W# _; O1 z+ @ .name = "user_led2",$ o6 |7 {( a5 J. i
.default_trigger = "default-on",) Z8 {5 V! C* r- _7 n( P* R
},
% h; ^* K* i6 N2 @$ k {. w. J8 Z$ t6 a
.active_low = 0,8 x7 k. U$ i7 _- l
.gpio = DA850_USER_LED3,
2 C! \7 p) u1 \1 o9 i .name = "user_led3",3 G7 h9 J; G' b
.default_trigger = "default-on",
& o$ M5 X i7 M$ b },
8 y' C0 m6 H7 b* C};
# N+ @& {$ U% O p
: x, x& f' P7 n1 Zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- o! J6 [$ E; @/ ?7 U
.leds = da850_evm_tl_leds,
4 U g0 M4 N% x5 w9 T1 ~" [ O .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
t& y; i! b5 ^( r' `! R: H};
w2 J) M$ \8 y% l3 ?# }! W0 P! C2 Z5 O$ Q3 J4 Q
static void led_dev_release(struct device *dev)$ l; X6 L- M; C1 @1 _% P! X
{9 r1 a0 `) Q1 Q; n. c
};
7 l; M6 B& h3 ?. U7 Y" _/ [9 K0 G; K2 K/ @. r( U0 u0 [- p
static struct platform_device da850_evm_tl_leds_device = {
- A2 D4 V M8 n/ ^- F .name = "leds-gpio",! m. o5 g0 d; q' v& d" q
.id = 1,
' ]! I( H1 f# o .dev = {
5 S, j9 J1 g* k' W% \ S .platform_data = &da850_evm_tl_leds_pdata,
3 N8 r: b, ] t: q! K; |) y O .release = led_dev_release,# u+ G; L8 ~6 D/ k/ y; [; J
}- ^4 ~0 }: {6 l9 y/ v- w
};
+ [% V- d( [) ]3 _7 i# D8 w: P- x9 E4 |- s0 O3 X
static int __init led_platform_init(void) j( y# t% Q- |5 g% N j8 ]
{4 X3 b T! B% U# m' N; H
int ret;
* ^( b+ ^& d0 z' E) Q$ X#if 0+ a* t" b* |+ D
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
) t5 I( m3 {. C s if (ret)
" ^4 K/ }; ]+ }/ Y- X5 t pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; b8 k. C* t3 v& v5 F5 h8 a+ j* a
"%d\n", ret);
, s5 A7 v* u5 |#endif6 S3 A* M6 k9 L- E) F
ret = platform_device_register(&da850_evm_tl_leds_device);. \( a+ J+ P# L& W
if (ret)
9 d1 m/ c4 A, f6 r pr_warning("Could not register som GPIO expander LEDS");% Y2 @1 O& w) W2 ^& @
else
1 P$ ^3 {1 Q, m3 |7 d& m4 Q/ G" c2 h printk(KERN_INFO "LED register sucessful!\n");' S7 j W! I, K% M3 {5 S" Q6 H: {
* Z0 x. h# D; D! m5 b! ` return ret;8 ~% w3 R: F7 j% ~) e8 G7 s6 x
}' a/ F" V5 F: |" f$ C5 X; J
c% r& [! [4 k; O( |6 o L
static void __exit led_platform_exit(void)
! M" v5 a* T% K) G- I{" ~! q/ C: @( \) b+ u8 {2 T
platform_device_unregister(&da850_evm_tl_leds_device);
1 Z5 V, I% t- p7 v- A
# P( o: e1 A5 Q4 }4 \3 [/ \- r0 a- c printk(KERN_INFO "LED unregister!\n");
) i8 O* w: ?) ~# j# ]- w' P} _4 Q+ y- J2 G, d0 V1 x# j: h
! t+ q7 [9 r7 l' ]& r6 B9 `
module_init(led_platform_init);' I G8 ]6 l+ {* G
module_exit(led_platform_exit);
" [, \ _0 z, G! C; y6 Q" s" x! {
0 A/ j/ F1 ~" e( ?/ e1 r* d7 yMODULE_DESCRIPTION("Led platform driver");
) K6 ^2 ~( r* k; B7 R9 N8 n: }MODULE_AUTHOR("Tronlong");8 ]0 P2 ^3 t8 j9 V; T8 i/ L% V
MODULE_LICENSE("GPL");3 o/ d5 {) x+ I6 @: w) G4 c7 K6 t
% |2 D2 Q9 d! ~" G6 J! l |
|