|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- G$ ]$ ~, j% A/ L3 |#include <linux/init.h>
, o$ t* @% ~' V, j: n#include <linux/module.h>
% W8 a! Z; U! g" |+ N. M#include <linux/kernel.h>6 f- \( D1 ?# n9 k% i
#include <linux/types.h>
* R% Y! }( j! L5 b) |, r#include <linux/gpio.h>' {3 ]4 L+ E3 \% L, G( {* j Y3 V
#include <linux/leds.h>2 S) o e9 I7 O4 B" E
#include <linux/platform_device.h>$ ]: c& f8 Y2 x
, s/ Z/ h5 Q2 T- v4 d/ f# Q#include <asm/mach-types.h>
7 d7 A; W' Q" t% N: A#include <asm/mach/arch.h>
( p# B, k) V+ d R; Y. ?) V#include <mach/da8xx.h>0 ? u0 A9 o3 v+ D5 u4 l
#include <mach/mux.h>+ g3 C+ t) O* I9 I1 L
9 c( F0 P% z4 R0 U1 S5 o6 q1 E' R7 m#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)* y- ^, i" c1 Q A- m/ V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" Y% h0 l; E' {$ ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)& ?/ E g/ _$ b% D& T, s
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- r L# g, N% Z6 s( J, ]
, f8 }: r% h2 A+ \
/* assign the tl som board LED-GPIOs*/
8 @" ^0 t, y2 f: Z: g5 estatic const short da850_evm_tl_user_led_pins[] = {" a8 }) B6 X0 }5 h+ V( `- O
/* These pins are definition at <mach/mux.h> file */
& w0 N3 B& V( W DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 A: F5 }9 A9 a1 p* U7 D( E
-1$ z* b/ N7 s \5 a
};+ ?1 ]0 I. s+ }6 G2 r- s
$ H5 `7 B4 r' N6 W* x+ L p1 gstatic struct gpio_led da850_evm_tl_leds[] = {' f- @1 _( r8 {% X: ~0 e% }( `
{# G5 e; {2 t5 M) U9 M. ~4 j
.active_low = 0,3 Q8 B* u4 H6 c4 Z, G5 a) k
.gpio = DA850_USER_LED0,
) {, g. w/ |) q* Q: ]! @* [5 z .name = "user_led0",
o. }6 O& p8 H% ?: T3 j& E .default_trigger = "default-on",
+ C; m, r# r* {2 l },
% C0 D+ \, z# H9 u {3 u( p0 |) o& f1 e% o: f
.active_low = 0,
7 z% I" C) L/ B: h0 H* i* z .gpio = DA850_USER_LED1,
; y: L) y2 R0 j# G4 O- d: T .name = "user_led1",
! h5 x5 @# D& Q$ ^" a5 O .default_trigger = "default-on",
4 L: S2 e% p. e& B/ I8 e },
5 M6 f( @5 q% E7 e5 Z$ }% U {
, l {' W! s8 g$ C6 |/ m .active_low = 0,
4 x1 K" p8 |/ y; A% Y6 \ .gpio = DA850_USER_LED2, u% N5 G3 Z) D
.name = "user_led2",4 d0 R( p6 m5 C6 @& U! ]" `7 \% }
.default_trigger = "default-on",3 j" L5 i5 m: G/ G
},1 w- z3 J$ O# W7 b; v7 f
{
2 q) m+ j. U6 w- \* Y w C .active_low = 0,5 t& v ?4 n' P5 m( }8 |, L! V/ F
.gpio = DA850_USER_LED3,. N; M5 r7 N5 c1 B4 i; ?$ x
.name = "user_led3",- C9 _, D# ]4 |& {* s8 _
.default_trigger = "default-on",9 R3 ?3 g# C' M1 A
},
# d; S3 X1 Y. R8 f7 X9 B};
2 k* s5 w* p8 M& y @; S* Q7 t! d1 s2 K9 \6 E; ]
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& f1 G+ @; m5 h4 W* F' D
.leds = da850_evm_tl_leds,
, O$ P& z) S) A% P, P# t( [ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),; p* f7 D7 @( `- ?6 G
};2 F3 e$ S# r1 A7 P. x
, X+ O% H2 \# dstatic void led_dev_release(struct device *dev)
# W( A. U% m9 w: K C& t, `{* [) `/ K0 |* k6 E$ t+ ?
};! H! N7 x4 [0 S
, @$ @ U( I, b. [; l& I9 H
static struct platform_device da850_evm_tl_leds_device = {
+ P' m5 Z) P2 j- c .name = "leds-gpio",
; O9 e* K2 g K3 h- ^9 ^* S .id = 1,7 P' u" c+ y+ z/ T6 m" E/ M
.dev = {) I6 k; p$ \+ ~* W$ Y% a1 N
.platform_data = &da850_evm_tl_leds_pdata,& ?' v1 S+ w" t2 O0 X6 F. O
.release = led_dev_release,2 G+ t# d$ V& P) j; X/ _0 ~
}
! x, a( @$ E5 w};) E5 U8 N6 `" T) ~
0 X9 y2 f' m( \
static int __init led_platform_init(void)% ]4 l+ z+ @/ A5 k8 x4 @7 y; t6 i
{
+ Y; @1 d1 e( m7 I" v8 Y' d; M int ret;
/ m) h: E0 k; M t; u#if 02 @- S b; m$ h: t' a
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ B; F8 Y( }! r. t. Q3 X4 s# z
if (ret)
4 n( ?9 X; h% e. f pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
6 {5 o- b E5 B1 F2 x "%d\n", ret);
+ @+ `; \2 q& D6 j2 v! ~#endif
+ R7 f9 |4 b" [9 O' W ret = platform_device_register(&da850_evm_tl_leds_device);
# y; k" Z9 d8 K C if (ret)( S/ x3 j2 Z: `. k2 P" G
pr_warning("Could not register som GPIO expander LEDS");- f7 c: X' j' Z8 y& z5 ?. `
else
$ R9 L S# I4 D# O printk(KERN_INFO "LED register sucessful!\n");
8 x& o& E+ j/ u. U$ `% M* B" m% F# X: u) H" q; r* |& y* |
return ret;4 r9 P6 I! T; T" L) d6 I" b" F# c# b
}) s0 L( {: E3 }9 n# C; ^+ v& V
% X+ N: [( z2 P7 @) y
static void __exit led_platform_exit(void)& u8 O$ M3 G* t; W
{+ M. z6 e7 a4 e% A: R4 G g1 D! ?
platform_device_unregister(&da850_evm_tl_leds_device);
8 r; O2 s' w# g/ C) |! L: u. U' a8 R+ ?+ {: s
printk(KERN_INFO "LED unregister!\n");% C3 R, [8 n6 p( [* |0 E) i, |
}
" b5 y: I p/ b. x/ g
; w2 i. f8 P2 `9 U2 m9 Ymodule_init(led_platform_init);/ M$ W. ?4 {. O7 ?( m" H
module_exit(led_platform_exit);2 B7 m. w5 y$ m' H) H
# ?' c3 p: E5 M D$ o# T7 Y+ bMODULE_DESCRIPTION("Led platform driver");
7 w7 ?# o1 y; @0 g1 `MODULE_AUTHOR("Tronlong");
9 S1 N* |) V7 w% oMODULE_LICENSE("GPL");6 q7 e3 J* W1 |, k; j
" W* @/ E' t8 N% ~- `) i0 T) d |
|