|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* o( }$ O: ~2 o% z#include <linux/init.h>* d8 K- q( x6 l5 |: w' e8 L
#include <linux/module.h>
7 K0 @0 E- E3 ]6 o5 J#include <linux/kernel.h>; m0 y' u6 {! Q" r
#include <linux/types.h>. a! ?9 L8 r. H w, z+ e3 {7 I
#include <linux/gpio.h># _; J9 @0 F! [6 j/ k
#include <linux/leds.h>/ x5 ^2 K O( q. u( Q" T1 ~$ i
#include <linux/platform_device.h>, X! l3 B" \3 k
1 P- e" B1 b3 D/ b#include <asm/mach-types.h>
# @ Y6 b& k( S r7 c( X" l' y8 T#include <asm/mach/arch.h>
5 p9 } E8 p: U& l: ^; x6 o1 o6 ]: J#include <mach/da8xx.h>
2 c+ J& d0 G3 C( B#include <mach/mux.h>+ T6 \7 }* T+ L G
" k& ]( Y- V, ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
, R: k) M/ g. S7 F#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)5 [ V7 O% B3 Q
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 t8 p7 m0 W8 b/ I2 H, ^4 W! w#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 T- B* C8 [& a) o. g2 }& E* f& m" A8 {9 N$ C7 B4 _) c3 z+ Z. U
/* assign the tl som board LED-GPIOs*/4 c; }: c& @% E6 o' y; I8 ?1 z
static const short da850_evm_tl_user_led_pins[] = {2 `* Y0 ` s$ K6 P' ^; E$ q$ r: r) `
/* These pins are definition at <mach/mux.h> file */
8 m, W0 Q6 p! z. b& y- w/ E DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 `8 x( q5 z6 y) }. K8 @
-1! P! J/ c! a. [; t) O
};# ?! F2 {8 N* Y* q
T; y' |6 v* o" N+ x2 i
static struct gpio_led da850_evm_tl_leds[] = {5 _" u/ A, J$ s% A) W: Q7 Z
{
5 r3 b" D% |: [6 L+ @5 h5 B' w% I1 c .active_low = 0,
( M. I) [/ W0 ?, L .gpio = DA850_USER_LED0,
* k2 Y7 N: W# Z6 r! r, w7 V .name = "user_led0",
# b- b) T1 z- T! W u .default_trigger = "default-on",; B* L/ u# e \0 G. D _; R
},
3 n7 u. j* u; G! A; l1 E: Q {( @; s* H G' }' e; q I. O% ~
.active_low = 0,
( R& P4 F* y* \4 v% D .gpio = DA850_USER_LED1, G) K0 j, S9 b/ Y1 T
.name = "user_led1",
: [- j" ]3 X2 y7 E ? .default_trigger = "default-on",5 X( L# r+ o0 W
},
0 G5 Q( v( J, t; ^ {
8 u4 l" Q+ p. q7 h0 ~5 i .active_low = 0,
+ Z( C; @* @4 K S; B. N .gpio = DA850_USER_LED2, h8 D6 r. d) L
.name = "user_led2",6 s, H9 @3 [" n+ A, |" E4 S& D! O+ l
.default_trigger = "default-on",+ c f7 v: }) B; r7 b
},) S/ i: c. P R2 H& j B, J5 w- l
{
+ O9 b; q4 ?! S+ z .active_low = 0,& ]* d+ O3 o/ N
.gpio = DA850_USER_LED3,6 {7 |4 Q3 N3 {' F+ x
.name = "user_led3",
- {" S1 V$ Z7 {9 a .default_trigger = "default-on",) k( y7 M) z3 a: r
},
: c. `+ E" V' W3 c};0 Q+ i" j1 G% `
. U( }1 }) R: Ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
7 S6 Z( h$ t8 \6 s6 V+ Q& L .leds = da850_evm_tl_leds,1 e4 J. }8 m3 ^& s; B: {* Z% ^& s
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 x4 f1 G6 ~* x7 B8 P
};
' i8 W9 `- a6 w" T8 L
) y. k5 a# O: _4 |# l( n2 j# g1 q' ^) P% S% gstatic void led_dev_release(struct device *dev)
3 d8 Z( E% Q. e! e( `+ C6 E* R{' H) d5 d- Q( [) [, A, w: E
};7 `# M. a% s# q. _
) b4 g4 J4 {' x& a# ustatic struct platform_device da850_evm_tl_leds_device = {
' J. B6 C" Y) b1 X .name = "leds-gpio",2 `4 }3 O6 g4 }7 F7 }4 l. \- `/ \
.id = 1,
* w: b0 ?3 u- j( V5 f) }/ R7 Q .dev = {
" ?; l( z6 y. v) `2 T .platform_data = &da850_evm_tl_leds_pdata,
: Q" A, u: n2 \% U3 A .release = led_dev_release,4 w4 v5 i6 X% \9 s: D2 r
}/ L9 E9 P; N5 X0 ]( d# {
};' ^' A7 ^, d# S* s/ K! h$ d
! V+ S1 ~! W; s- H. a) ]2 I1 ^1 Dstatic int __init led_platform_init(void)
+ j7 @8 T1 F3 W/ p1 ^{
) C( c( f6 J5 d- f( c1 ?% o, x int ret;
f1 Q2 p! U6 g8 k# q% P8 {#if 05 O) B; ^% h2 r5 ~! |
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' y6 k3 T2 L9 U% z" X& H
if (ret)( ^$ f y: D% Y) @! w [& N( a3 Z# B
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
# H8 W. F8 i* \) L& y "%d\n", ret);) G6 d$ i" q9 v2 j# `& [6 S
#endif: f& T# D4 [) U: K N
ret = platform_device_register(&da850_evm_tl_leds_device);
( e. N% `# |- Q9 K if (ret)
% S% C H9 F( W. @6 | pr_warning("Could not register som GPIO expander LEDS");
- }1 _$ z! Z& m7 Z* ~# w, O else
B' E+ i8 W6 P+ P" O printk(KERN_INFO "LED register sucessful!\n");
6 N W; a- Q* F; l5 t$ P, \* [ c' I( j8 t
return ret;6 P; ^8 N1 x2 m# \
}# ^& G4 |: T3 K" b. A( G% d% `
, u4 o8 R, ~5 P: u; ~+ c8 ~static void __exit led_platform_exit(void)
8 a8 G6 u' \6 Q{
- `$ B F3 ^( p/ ?( K. t# T. ] platform_device_unregister(&da850_evm_tl_leds_device);# Y0 q+ D* n9 t# @/ C
' K, r! V% p! T( x printk(KERN_INFO "LED unregister!\n");, M b3 _' r. ~9 I) c- N3 P
}
$ N; h& v3 a0 `) A6 m
/ w, {+ C( e5 m7 X, {6 w1 Nmodule_init(led_platform_init);0 l5 R- p% d. O0 F( G
module_exit(led_platform_exit);1 Y: F6 S; }. X4 }3 w! Z
) m7 _4 X: z1 v* mMODULE_DESCRIPTION("Led platform driver");2 R. y: v8 {, p6 g' C! I- ]$ ~7 c$ U7 q
MODULE_AUTHOR("Tronlong");5 `, n7 Q+ y# I. A+ s6 u- |
MODULE_LICENSE("GPL");
8 f# T9 w( ~( E% i; G) ^# J2 ?6 T0 L; l a: m% H6 q H
|
|