|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# H3 y2 f" E2 K$ G1 A
#include <linux/init.h>
: t# v- ^& V( ]/ b4 c4 D, y#include <linux/module.h># }5 y# a5 g8 F/ @, C
#include <linux/kernel.h>
1 m& K" L( A) X H$ \#include <linux/types.h>6 S# B; p3 ?/ T; ~( N; r+ p
#include <linux/gpio.h># v6 V8 S) j5 }
#include <linux/leds.h># M) n: x0 B8 o! q$ d3 u$ F" m, W
#include <linux/platform_device.h>
% g9 s$ K. t6 a, l: d2 e+ e' f& n
- b/ W C. L/ \* K5 g% Y#include <asm/mach-types.h>, A2 y8 d; o* k( d6 Y6 r( A! G1 f
#include <asm/mach/arch.h>
5 G5 R/ e4 Q. h" v' c) D: @#include <mach/da8xx.h>
5 q4 p/ K) d. e& G4 F% l3 |, X7 V#include <mach/mux.h>
' K2 U( W; m2 b5 J- D! R, x0 y) j; M( W, }' x7 M
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 M6 q3 y" Z& i0 Y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' d4 D( [ t- S9 v9 J#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 l, A+ U0 t- A
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
% I& D9 g( K C9 B# z, R- [: z4 }! c/ e/ W! p( I
/* assign the tl som board LED-GPIOs*/
6 T; K( `: o. Tstatic const short da850_evm_tl_user_led_pins[] = {% Y# h3 c. |0 y& n9 z: m
/* These pins are definition at <mach/mux.h> file */
. `& y Y4 s/ K; T, P DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
% f d& l' N. l -1
. s" x- O) U, c};
! |( j: d4 e: d6 K1 M9 {- O, r/ Q4 ~ d0 f7 I" L
static struct gpio_led da850_evm_tl_leds[] = {
1 D( j$ {( e1 W$ n4 |# z- P {
% }' {3 w! @1 w- J .active_low = 0,$ O: N8 p6 n) y" h2 v9 Y
.gpio = DA850_USER_LED0,+ N6 W. B% c) l6 b
.name = "user_led0",
) f/ C' F5 Q/ `+ b7 w .default_trigger = "default-on",
# ^) Z; q0 E8 F- \ },
! H2 ~. V( s! S1 V5 j {0 ~ Y: q4 X w8 _- }9 B5 L
.active_low = 0,
. ?1 x! s4 J$ _" l: y% q) o# X .gpio = DA850_USER_LED1,
( U5 j9 w# c: E' r7 | .name = "user_led1",+ H! X: v, @5 l: A# J) _ l
.default_trigger = "default-on",# G" ~1 m6 w1 T {
},
+ f7 W: z0 K0 B! c {
& j. b' [* I0 h& L2 [' m( N4 s& n .active_low = 0,8 H0 D( b% V/ k+ e5 @) K6 o
.gpio = DA850_USER_LED2,
3 T! R) W. _7 s! D .name = "user_led2",
. x% k2 X; ]" ?% | .default_trigger = "default-on",6 I) k, X; L4 X; B+ z8 r
},
" B+ n: Z9 z+ b {& s: d- H+ h" i/ t S
.active_low = 0,( }7 p" z/ T3 P2 S5 F* ^& N) S
.gpio = DA850_USER_LED3,
; N! F0 z+ X% w .name = "user_led3",( f' y: N- ]2 N0 y
.default_trigger = "default-on",
" T( g" f# J# y6 B* z9 i! G/ u2 w },# D8 X! H" L! O9 g2 n" n( {3 ~
};
( i8 U \8 a+ w( E# r3 r9 h( l L& m) Y8 W0 D D; r, Z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
4 } i; b+ |. g b .leds = da850_evm_tl_leds,6 L, w# G. Y& w5 X- a
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),* f9 z, x9 j, Y H0 C
};
% [: i5 @& q0 G7 E: A; v) n% S+ p4 [; J6 ~8 @6 {9 X- j
static void led_dev_release(struct device *dev)
5 O+ Z2 i4 l/ M% z( x6 q7 F{
7 S& U. Q# r. o6 R7 ^};' r: w5 O; \# o) B3 A& A
/ d1 Y q3 M2 D" \5 u( S4 S
static struct platform_device da850_evm_tl_leds_device = {! r4 r. J% o6 T# |9 k" F
.name = "leds-gpio",6 z( T1 `& C. W; h
.id = 1,- u# k/ x( y2 c$ g+ m1 U
.dev = {
# |( R6 W: ` M/ w" T5 [ .platform_data = &da850_evm_tl_leds_pdata,
2 x( x- O+ q3 M/ W) O; G .release = led_dev_release,$ O9 _2 N6 |% Y# m% q
}( I2 o7 W. \4 i4 P" e
};1 L' e! w) g' n$ j( |4 R7 |, V
+ f* A( ]3 z0 ^% Bstatic int __init led_platform_init(void)) B9 P0 e- v6 D
{1 H( ~6 v4 B3 V; f) b: A7 S
int ret;
) M! H- R% U5 T* }#if 0
6 c& a, s p. q" Z: D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ f9 k8 g+ a d/ R; y' ?, L1 F
if (ret)
% X9 p( i0 K+ V9 _1 y8 L& \ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
' }% w; m6 P$ @, Q& t "%d\n", ret);3 j" n2 y- E- {8 @3 }# {% Z
#endif
$ @ O8 [" M* b8 |+ Z2 T ret = platform_device_register(&da850_evm_tl_leds_device);
6 z8 M. |) a6 V& {# P. x/ @+ \ if (ret)
2 a; F8 |) T. p4 }( T pr_warning("Could not register som GPIO expander LEDS");* n+ t, H& ^" ^+ D2 R8 Q3 a5 u
else
) c- w0 E" ?- U6 M$ q/ ` printk(KERN_INFO "LED register sucessful!\n");
_5 Y1 F" M/ h& J) y! S8 H! i5 @" B* N# r4 ?3 M2 Y
return ret;
9 D+ f7 w! x J% G1 C- H} N: N4 c1 f3 z1 t- t
: u8 K9 w, n3 b3 h9 C/ L- U; W) {/ c
static void __exit led_platform_exit(void)
/ L' b2 t% g7 q7 @6 Y& i+ U{0 i$ n+ {- N8 j' L
platform_device_unregister(&da850_evm_tl_leds_device);
$ A7 D6 i- Q/ f L6 m% @' R! h' V+ D7 ~0 T I5 C
printk(KERN_INFO "LED unregister!\n");- \2 ^! H2 q( J+ i
}5 z6 g5 f6 ]( B7 @
( y8 |; Z$ r9 ^& o) ?- K$ @
module_init(led_platform_init); d" a, ?( D5 _
module_exit(led_platform_exit);8 K, d$ V3 @4 ^% B, Z+ W
9 |( b# a0 q7 [$ ?! A3 `: H
MODULE_DESCRIPTION("Led platform driver");# z8 X. |! z' D0 {, \
MODULE_AUTHOR("Tronlong");
; z9 w) u. [( S5 u$ v- yMODULE_LICENSE("GPL");0 |. a! H5 Z% c0 ^# a* C# t
0 P6 X1 B! Y1 f9 B" `
|
|