|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ p4 \& G- W& `% n5 `: m3 ]+ P2 a
#include <linux/init.h>
1 Y3 Y5 W o& o9 f3 j; w#include <linux/module.h>+ B$ U: H \/ [3 r5 D8 X+ x$ r7 M
#include <linux/kernel.h>
u2 L, z5 N, I( y1 o#include <linux/types.h>: b: Z, x# t8 a
#include <linux/gpio.h>. D& t& t) Q6 _3 H5 u! ]3 [, F6 J
#include <linux/leds.h>
, z7 t0 G% c& y F8 f8 f#include <linux/platform_device.h>, @ r8 m5 V6 q9 {% k' A% q2 R
4 n% p3 u8 t/ N- r9 x/ c#include <asm/mach-types.h>
+ g2 r) C4 `. F( S#include <asm/mach/arch.h>- ?! n, g- U5 u
#include <mach/da8xx.h>" _5 r' q; n. V. C0 Q
#include <mach/mux.h>2 ~% ~7 z( r. v
# y' l5 x; x4 x/ H% F#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ G" ]5 f9 h) W$ e
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 z1 V( a, }0 |6 O" k#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) M; N3 f1 [. S' t#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& M8 A' b7 h) m& i2 c
. K; k; D+ @1 W. t1 E6 P( P
/* assign the tl som board LED-GPIOs*/
- V9 m: n- \$ E0 Lstatic const short da850_evm_tl_user_led_pins[] = {/ O; S" g+ [7 {
/* These pins are definition at <mach/mux.h> file */
' T! z( L- f5 | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 B7 s; S! u! c, G+ ` -1 F* Y. s" W6 {) E
};
% P# n1 g% ~0 |5 b# S+ i0 i- R% b# \ o1 Z, m
static struct gpio_led da850_evm_tl_leds[] = {
5 d! I% r. l z/ h; m5 b {8 H7 E, _( B4 u; @! d: ?! s
.active_low = 0,% n3 J) `+ f; e# p+ _0 M9 t
.gpio = DA850_USER_LED0,6 X. L6 e4 Y5 B6 n
.name = "user_led0",
0 T5 D! M3 e: e3 f .default_trigger = "default-on",
3 z/ l- F8 ^% O; p U$ ?0 e F3 C },
4 m q9 w' c2 F {) {* a8 f p' x
.active_low = 0,
. z- V7 q/ Y0 l# x* Z .gpio = DA850_USER_LED1,; X0 r) U' @# P# k
.name = "user_led1",
0 \4 C4 Q; k4 [ .default_trigger = "default-on",
4 H1 C0 j% J6 y },: v' J# G w. J# I* }, h
{) b$ U, O" o7 D2 ^; y( c
.active_low = 0,) b2 _6 H L# i8 ~5 }( Z. v% @
.gpio = DA850_USER_LED2,
' B* [- X3 V- l# q! I .name = "user_led2",
- J( r% d: e5 I .default_trigger = "default-on",
. h$ L6 v% h& \0 W6 w( I },
% G+ M9 O3 e0 E$ }8 Q+ {# ]! v) z/ T {5 I3 [) u i+ z( q& r
.active_low = 0,: L8 U5 X; |$ m; |
.gpio = DA850_USER_LED3,+ e1 n' Z8 `6 }" E0 x% Q) w, e0 S
.name = "user_led3",
/ h+ Q8 b6 a3 O! n* z4 g .default_trigger = "default-on",
- J8 ^5 g* S5 G' F6 Q },/ w$ T( S# j; B9 ^8 a& A9 V
};
! P( e. ^" q2 Y
+ g# x$ ?0 i- x5 Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {/ A+ U' T" H9 z3 }5 D6 O
.leds = da850_evm_tl_leds,
" b( c6 @6 n. h, i/ |2 n6 V. | .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: m3 O. j& O" B+ f) H};, w% {6 q, S$ U' x2 S
# t1 L, d. d7 B. hstatic void led_dev_release(struct device *dev)5 Z* C# F% M' i2 M4 [
{
4 W i/ F S6 O N8 [};
* P4 t4 X! z% G' ]7 r
- i: A' N3 Z+ x6 T1 bstatic struct platform_device da850_evm_tl_leds_device = {# n7 E$ q. L$ g- W: i1 E# a0 H
.name = "leds-gpio",
& E, [% {: F- Y0 z' ` .id = 1,% j" b) J5 r8 n/ h- D5 ~' b- F
.dev = {0 V3 W/ }4 g% c
.platform_data = &da850_evm_tl_leds_pdata,
2 t) W- S# k; ? .release = led_dev_release,- t- F! M! ]2 K+ Q3 i% t
}
z A4 `# d( ?4 W};. C) k0 N% n# K
, \; B& G# l+ a- Ystatic int __init led_platform_init(void)
& w( \3 A: ~4 ~. B' l/ W) [, h{! f0 O) p3 @8 s
int ret;
2 k) h- M/ ?" ^$ w9 n1 b#if 0
9 g& H6 t7 w0 s' a. I' T9 n( I/ t ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);6 b' l6 Q6 a' d( b
if (ret)- U [- o9 f0 J! ^6 f6 _
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
& H! T* P A4 k7 V "%d\n", ret);
" R: _" T3 C( Z8 u#endif8 ]' a' d6 X( p$ \* c K6 x
ret = platform_device_register(&da850_evm_tl_leds_device);
! c! T3 U5 Y7 K if (ret)! `1 X7 c# z# i, G b/ Y: [
pr_warning("Could not register som GPIO expander LEDS");8 y3 R! p% J( W0 T' ^
else* C% `' G$ }$ m& a4 u6 G
printk(KERN_INFO "LED register sucessful!\n");( _" e+ ?2 [$ n" e" h+ X& y) N& h
2 O# ^% a+ }$ S1 m0 u' [3 L9 C
return ret;
8 h" B0 y- i9 p8 ^; ^' G8 s}
3 Q0 _6 e% A# M- ~, R4 z7 q6 H i6 p& P4 B( _& y/ W
static void __exit led_platform_exit(void)
$ l( X8 c8 @8 p" }. v7 X- f( q0 j{& L( ?/ c6 Y' X9 q+ H& s( r8 b
platform_device_unregister(&da850_evm_tl_leds_device);
2 ?. z$ k1 U0 H4 K6 [0 V0 b; z( U" F' E8 ^
printk(KERN_INFO "LED unregister!\n");
" @) f' Y0 T3 L5 o7 Z}
/ }( _6 M; Z3 c& l& X% o" i2 v" y$ K0 ^4 X, i
module_init(led_platform_init);
8 i1 g) r" L0 t% emodule_exit(led_platform_exit);
/ k5 e" j0 l7 B* f$ ?9 ?/ u. \: t, z! m; z1 |) _
MODULE_DESCRIPTION("Led platform driver");! S N9 _" o7 ?6 |
MODULE_AUTHOR("Tronlong");4 A0 |1 _: \5 l1 G( S
MODULE_LICENSE("GPL");
e" V# D+ z* f" ~
- r5 R5 h- K1 y4 p+ ~( b& U |
|