|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ e, K9 g$ `. B
#include <linux/init.h>7 w4 S* |: C" b; q1 N( t0 L% x1 ~
#include <linux/module.h>
, Y3 |' W' h' x#include <linux/kernel.h>
" w0 l0 X0 u- e; g7 U# H% `#include <linux/types.h>
3 h. B& K9 A( m3 P( }#include <linux/gpio.h>
F- e& T9 U8 C; h3 ~% z2 E5 u3 d#include <linux/leds.h>: D0 l: k: ^& a5 U# f
#include <linux/platform_device.h>
0 \/ |5 q. _! @2 R N2 Y$ A0 O8 }$ J; r
#include <asm/mach-types.h>; b6 n2 M9 _5 u2 Z( }
#include <asm/mach/arch.h>$ a+ _# }! O9 F" i( i/ m
#include <mach/da8xx.h>7 J' C" ]( A7 e0 W0 S- @5 n
#include <mach/mux.h>
0 ^& g" l( O- J, Y8 B R. ^
+ e) q1 W! K& U7 E7 L2 x1 t" q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ ^% e& w5 N, i' P( ^#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 F F' H- w! Q# H( h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ F( y" }& w' e6 J5 C( }! n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! s' H9 }% _! ?, F7 [' I2 L1 L" B# n0 M4 M1 ~; ?+ Z3 {
/* assign the tl som board LED-GPIOs*/
* r! k7 m% g8 f1 X3 xstatic const short da850_evm_tl_user_led_pins[] = {, r4 o' q6 `; h. X; z/ `
/* These pins are definition at <mach/mux.h> file */
* j q) X+ R' }+ @/ q9 [, v DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 ]$ r( y5 `+ L) D* |" z* m
-13 F. ], L s) C+ X! u. Y
};+ D/ k& ~* b% O8 d- B
. a' {6 m! Q n' Zstatic struct gpio_led da850_evm_tl_leds[] = {5 y* a* s) `0 k# {* y: |
{3 v' z! W8 O& l: V& L) @. J
.active_low = 0,
, {- F2 J* k( S1 N$ L .gpio = DA850_USER_LED0,
# S2 }9 m3 l/ W$ y .name = "user_led0",
$ c5 b/ w& }6 V .default_trigger = "default-on",
L, T* f- i: ~/ `* w0 K },! P9 w' A6 P! N8 V
{+ E/ [( S# q* l
.active_low = 0,
; i8 H0 T9 u# Y! x- u3 ` .gpio = DA850_USER_LED1,
1 } E; S2 E# P8 H* M# ? .name = "user_led1",
, b8 q) z4 P9 r4 p+ T+ T" y& H+ r .default_trigger = "default-on",7 H) Q4 q) D3 Z
},; Z# @8 T C9 h6 G! P1 N
{) S' X- Z8 J3 {7 R* o
.active_low = 0,
; m1 n) G7 a0 D .gpio = DA850_USER_LED2,( P9 \3 }7 N6 c
.name = "user_led2",. d8 L7 r5 T: |' y* E: w
.default_trigger = "default-on", M+ H- |8 Q; T! I
},3 O8 \& E" y/ N" y/ O
{
, \9 I& u8 m9 q! v4 K, s9 P .active_low = 0,
7 y* D* I% j" N' |* l( v! h2 h .gpio = DA850_USER_LED3,
" X* ]; M! S2 i6 d .name = "user_led3",; t5 }9 c; x0 g
.default_trigger = "default-on",/ U/ U" S1 t5 J$ S i8 a' q" a
},
- {- F, ?7 s4 v+ Y# j d8 _. o};) t1 Y: a. {, C- O& O! M
7 i: E9 c4 B a6 n- d1 a( f+ @
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) {- |' B; A/ K7 c$ d. t4 E0 g+ k
.leds = da850_evm_tl_leds,5 l; J) Z- v1 s# r# y- _
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: L# Q4 ^2 T5 j};/ U0 e4 ~6 }& s! Q
. ?& [& E9 \6 ystatic void led_dev_release(struct device *dev)
5 g Z$ r8 u( W& A$ s+ P{! W* R0 n9 H% c5 e4 f! h
};- Y; [) A, q* G$ j& s: b) R% c t
0 o+ f# \2 I$ p2 _; w6 ]6 a
static struct platform_device da850_evm_tl_leds_device = {
5 q5 R' B5 N2 @: J/ T3 j9 P .name = "leds-gpio",. b- b( x2 {2 h, s$ q/ {5 E
.id = 1,
4 z% C. }- p) K2 F .dev = {
) n* D, O* f5 w+ X .platform_data = &da850_evm_tl_leds_pdata," s+ | H0 A" T
.release = led_dev_release,6 T6 ^! W2 L0 [$ G$ g' P( I
}
/ Z- R- Z% \- l) O2 R" g! x};- _) U* n( w0 M1 }, x! X
# Z j; X% q* K) S: F9 istatic int __init led_platform_init(void)' Z1 v) s0 A5 b% b$ O: `: U
{
/ r( B' q, S7 Y$ x int ret;9 t" E+ T6 s6 ~% Z1 O
#if 0
) M' f& Z9 K6 W* q7 F! J& z+ m ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 x7 @& ?2 q; |# V& Z9 z
if (ret)
9 {0 O! {8 r% d% S6 s8 i pr_warning("da850_evm_tl_leds_init : User LED mux failed :"! x$ k! ?6 k. N- t0 T
"%d\n", ret);
& Q4 U4 V7 v7 ~" O# w#endif
, E7 C4 C! O6 W6 @. a" A1 J, ~; n& j. `! \ ret = platform_device_register(&da850_evm_tl_leds_device);
/ S9 m- b/ l0 A( _+ z/ v if (ret)" ]. V; o. Z: V0 A
pr_warning("Could not register som GPIO expander LEDS");
# ^1 w0 s- e3 b else3 ]3 U. Y3 n% p3 ?& Z+ E
printk(KERN_INFO "LED register sucessful!\n");
+ m+ a( {) r! \% z% ?4 Q
6 C4 w, f7 a2 l# F return ret;6 k8 R. z( m6 h8 i
}' `* i9 g @; j8 ]; E. N9 N( ^
+ V! d5 h1 v/ y" s- K
static void __exit led_platform_exit(void): p( U1 @2 R1 a. Z
{8 F( c! [- s2 A/ I- X9 J, k$ D o S
platform_device_unregister(&da850_evm_tl_leds_device);
, P8 u5 o6 v1 L5 ?+ | L$ X0 ^' P' _' ~. s
printk(KERN_INFO "LED unregister!\n"); b( z( I ?; `. i
}7 G8 w7 T1 O, P! N
7 p1 b3 S: F: _module_init(led_platform_init);
& }% a; O- Q& y+ \5 k- Pmodule_exit(led_platform_exit);2 }" t# [3 ?8 A6 z
7 H6 ?% p, j$ ~2 R4 c' GMODULE_DESCRIPTION("Led platform driver");1 z: Y h9 q( A$ @9 s
MODULE_AUTHOR("Tronlong");
! W. X) I' n( r+ E7 DMODULE_LICENSE("GPL");( ]; n. h& B4 Z* `1 k
8 ^1 R' N; r8 O; \
|
|