|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: G4 S8 R# N t#include <linux/init.h>
& l1 ]: z" X. j" C9 ?- D#include <linux/module.h>
& O5 K% F, F! Y. z% K, p#include <linux/kernel.h>
2 V! H$ S* U/ o& H& @6 m#include <linux/types.h>
# b. z5 U# ]) z2 L#include <linux/gpio.h>( Z: w# g7 ^+ R# t5 O
#include <linux/leds.h>8 {+ a! @+ j2 ^
#include <linux/platform_device.h>
" T5 n1 t$ d* ?0 a3 C1 E6 ^. B6 C. }3 S6 Z* S0 M& O/ o
#include <asm/mach-types.h>* ~# B: Q; S& t* E6 g$ ]( }( K6 C
#include <asm/mach/arch.h>
6 _- s0 b; S1 g! I$ N#include <mach/da8xx.h>% G5 o- x( N5 B' D( f
#include <mach/mux.h>9 q+ q9 U0 c+ ^$ s& |8 x& G
) D _! ]. ^7 D+ c) T#define DA850_USER_LED0 GPIO_TO_PIN(0, 0). V/ D: a1 W* z, |
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 ]- U9 B) K+ |- X4 w#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
% d2 A: u6 U" B5 e8 U" h# c#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
5 Z) y* K- H- A" z- Y3 O
7 A. C% Q5 c, ^( j6 {2 @/* assign the tl som board LED-GPIOs*/, l+ ^! X' g* G9 L; P7 H: k
static const short da850_evm_tl_user_led_pins[] = {0 E1 ?6 Q: ]* U0 u6 W
/* These pins are definition at <mach/mux.h> file */
+ h* G2 s# M r4 m% } a! U: z- X8 ~ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, \* E0 V6 [# _' h1 B7 F) J9 V: F) o: p
-1
" r. J9 m9 q" K0 m; T};
+ O+ n. `3 |; v$ }) z% i2 m7 S
; H+ ^7 y$ `2 Y3 \& L$ p; ystatic struct gpio_led da850_evm_tl_leds[] = {
9 j' l/ t, f X1 }* | {
" L1 S6 ~( f* X; { p# l" f .active_low = 0,
; X3 d2 W4 S. Q, z! P .gpio = DA850_USER_LED0,
3 J x+ q2 B: i. P .name = "user_led0",5 K+ E, f3 O9 S: g: e: `
.default_trigger = "default-on",
8 G7 g* S- E8 S },' N: b& o; d0 s t, A, K
{
1 q$ E, U/ h( q+ Q8 k .active_low = 0,
* H( p/ E# R" ]9 u, p4 @" l% i4 ~ .gpio = DA850_USER_LED1,
7 M3 |$ r; a X .name = "user_led1",
% w! m8 {8 \' t% u |. L6 v .default_trigger = "default-on",! T, E9 l( @1 T3 r% e1 D) A+ q/ A
},
! j! S5 i6 f( @+ c5 o8 |4 z) O {- p- H6 m; R6 d9 B3 C
.active_low = 0,
! G% B) S+ B/ y# m .gpio = DA850_USER_LED2,
% k) H1 d% [) a; ^ I .name = "user_led2",
9 t) K/ ?* c- t+ d) V* b .default_trigger = "default-on",5 |' A' M: n/ E. c) f
},$ K7 a; E% W2 ]- `$ w+ a
{5 q+ O3 x6 q+ o2 E; f! E
.active_low = 0,& a0 O' [ C/ I- ?4 t
.gpio = DA850_USER_LED3,* w6 s8 H+ z' c
.name = "user_led3",+ q; H) l# X- W% O$ r
.default_trigger = "default-on",$ n6 ? R8 k4 z* H7 u
},
/ y8 G* ]. k j. _};. P6 _9 T9 r* v# f" [: c7 f
" _( i7 E9 Y+ N6 }, c; Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# y' t. J5 S' z' v2 s .leds = da850_evm_tl_leds,
$ C) I4 h7 _. t .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 H# N' q) R3 S' B7 W9 {
};% X8 f6 ^7 Q/ g+ C& f
7 @- A9 \5 X6 S m. T1 m( e
static void led_dev_release(struct device *dev); c, i y% a" m1 U8 J, _2 G e
{
, m( q, d4 ]4 r) n8 G6 D};5 K! m ^; R* ]9 Y
* K3 }2 T* q& Q+ y# T
static struct platform_device da850_evm_tl_leds_device = {
% L% @, Z Q* b. H. R- T .name = "leds-gpio",
! A- \) y7 M* w- K+ r) |- J% m .id = 1,# ^: F% ~$ a' @0 l% T( o
.dev = {2 Z+ A# @0 m/ m+ W# Y
.platform_data = &da850_evm_tl_leds_pdata,, Z( k/ @# ]/ Q3 ^: X# {! r) {5 W0 g! Q
.release = led_dev_release,- m. @+ @3 t/ Q& m0 T( t' J
}
( q. p- _7 c; x};" p: Y/ C7 k2 b% G2 e
. y3 A; j$ P D5 o& P( h4 P$ D lstatic int __init led_platform_init(void)9 v' O! T/ Z* z& }* |
{# ~" f8 l" X5 B' i' ~
int ret;
' {3 u$ X# J, H#if 0/ K, F6 ? Q# a; ~
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: F$ t& d+ ~* J* C9 A if (ret)
. r5 M5 a3 Y" m3 { pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 y0 _1 D+ Z, a. `. a% U8 {- i "%d\n", ret);
- w O7 ]: E/ I( e# T1 Z#endif
- w3 a3 Y) B# U: X ret = platform_device_register(&da850_evm_tl_leds_device);
6 E8 W& x$ \6 _ if (ret). ?( E0 T3 {* Q- Z
pr_warning("Could not register som GPIO expander LEDS");9 a* z$ ^. Y/ G+ ^! x/ X) z2 R5 x
else. S8 ]) H% {2 o) e
printk(KERN_INFO "LED register sucessful!\n");
+ d6 u) N$ Q7 j' I1 P
% E0 c) w% L8 |- w t return ret;
4 U- [! o* r$ W7 f0 ~}6 h/ i. u4 s4 h+ @
0 K- K5 \) ~: U" s1 o; J Y# Q. j
static void __exit led_platform_exit(void). D; p+ _+ N* y
{
) J6 K: P) @* P/ Q% U8 [& A platform_device_unregister(&da850_evm_tl_leds_device);
f" a+ _8 g; L. h3 @0 I4 x/ Q, P/ ^; z! w5 Q
printk(KERN_INFO "LED unregister!\n");5 _3 h; C$ w0 G
}
- }! m2 U) t r5 ^5 O# I& u
8 ?' x& M2 n: ?3 m- F; t, ?9 X% Y Dmodule_init(led_platform_init);" [# _6 X" y" |; D/ T
module_exit(led_platform_exit);
- m' S: L+ [6 l' |" ?/ ~+ ?7 a' ^7 Y& ^6 @
MODULE_DESCRIPTION("Led platform driver");
0 B3 e D6 ]2 b Y9 ^7 F" T5 zMODULE_AUTHOR("Tronlong");1 T8 P/ a; N5 _
MODULE_LICENSE("GPL");
$ p9 d: o+ u3 m7 g. v
/ N9 V* s( V7 b- V* V |
|