|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# b2 g% L8 r. j# t#include <linux/init.h>
+ |9 A6 d c. ]: ]- R7 D0 d#include <linux/module.h>( A' \% K( z6 Z) c. Y- }
#include <linux/kernel.h>1 g3 N3 O h0 @: ?. t8 R% x
#include <linux/types.h>& B8 c U- J* }& k' q
#include <linux/gpio.h>7 W: c Y2 E3 p
#include <linux/leds.h>
* U( \- C W& L' T- g- u#include <linux/platform_device.h>
# R. M. u7 B. G( c/ N
& B5 f) a# v6 |) A/ D#include <asm/mach-types.h># D" L6 N. y! x4 ?1 L. S3 T
#include <asm/mach/arch.h>+ {- { x& @% R
#include <mach/da8xx.h>& s9 r+ _3 T# }5 W
#include <mach/mux.h>
1 s$ i; d1 ^4 |1 F, ]8 T7 a8 Q$ I% [8 C3 Y2 }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 C5 \! ]4 J6 {- N; q9 x
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* n% ]1 \$ c' ~7 D7 `#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 t5 O6 e3 z$ l* _9 d& \#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ a0 ^2 _2 r/ \0 G' l7 R
; z/ q' u3 c$ H) _: B
/* assign the tl som board LED-GPIOs*/
8 Z6 y V/ f6 \3 zstatic const short da850_evm_tl_user_led_pins[] = {
: ?( {, l) C) L' l" T$ f5 c+ ~* E /* These pins are definition at <mach/mux.h> file */3 S8 U8 K! Z# [5 J" l" I4 b
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,9 u7 s; w8 Z# U; c2 l+ _
-1( k7 U' l2 j. ?
};( L8 f& _! v: F0 R3 q
1 u5 c* Z; _# L0 C( c0 k& M! kstatic struct gpio_led da850_evm_tl_leds[] = {8 |% Y8 E) p/ [, c0 Y2 k
{
2 G4 W/ i E- i! S6 ]3 y .active_low = 0,1 v; O5 @4 u* M/ Z$ S
.gpio = DA850_USER_LED0,3 E$ J( d+ I+ _, ]# N( T' K
.name = "user_led0",# U- F7 D m, ?- K _7 |
.default_trigger = "default-on",' a! F2 f' r; m* p. i
},$ y' P7 R9 N) @) u# c+ H
{4 ?5 }# m3 S/ X, e& s3 \, u% n+ A
.active_low = 0,
[6 C( s1 b. M1 ?" W .gpio = DA850_USER_LED1,# ~0 v+ W; P, r3 q# ]
.name = "user_led1",% p& @/ G5 s& T
.default_trigger = "default-on",
9 l# z/ t- i# _" `+ V- o; @ },
( a/ h4 ~. V; p4 x {
) |% X; {* c6 v# {; C- k. I/ T0 y _ .active_low = 0,
1 |! M) D# ^1 b; {2 Q/ n D r .gpio = DA850_USER_LED2,$ ?, q$ B$ ~6 o+ Y& B
.name = "user_led2",$ m# G. t1 r9 R
.default_trigger = "default-on",% g* K7 ]6 o# T4 Q) Q7 g
},, a: a& T* L; i) q! Y
{
7 q+ I- Q( x6 w .active_low = 0,0 v: ]; {! T( l9 M
.gpio = DA850_USER_LED3,
+ A5 L& A! m' I/ a9 a .name = "user_led3",
& E0 J! }- Q X# T$ M5 a+ { .default_trigger = "default-on",
- ^+ I$ I* N% c },4 I: _& |% x' C" `' L; b
};: q4 v* l% @% N4 c; \
T* |) h! n# _1 [3 ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* B" x' Y- H5 [; f9 k .leds = da850_evm_tl_leds,3 E& y, d! w5 `( R+ ~
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),- c1 n. z7 N" S. Q& s
};
0 S, ]# {4 z' m3 D8 b0 \0 H
/ D: P5 F9 `$ Y( r& O6 cstatic void led_dev_release(struct device *dev)# U+ M# D. L4 w( ?6 N* p
{
* x& l6 m/ @ S+ G};7 {2 a) O1 p( d0 k. K
6 h) @/ ^9 k0 s* S7 V) lstatic struct platform_device da850_evm_tl_leds_device = {
5 g, C/ I- w( w0 }# F3 C .name = "leds-gpio",# u8 `1 y1 A6 _
.id = 1,
0 q3 u+ h) ^, ^& ~ .dev = {, m: h0 N* g$ ]4 X
.platform_data = &da850_evm_tl_leds_pdata,
4 T' U, e0 I* s .release = led_dev_release,8 X+ H* c* B" o" ^
}3 ]% `2 C; |, E& ~( Y
};2 ]' d* t! p' I! H0 g
( a7 X R3 p* n0 f0 Bstatic int __init led_platform_init(void)
1 [; ]: j- O& o. h) ?$ k{% Z- \2 f4 L' W; f7 J A& b" h
int ret;4 _7 o. g' u/ }, G
#if 05 Z4 k- @" o" \/ a- l
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' p: v8 Y/ O! Y5 w6 L
if (ret)
8 I- U: j( P' d; ` pr_warning("da850_evm_tl_leds_init : User LED mux failed :"6 B- e; A2 F7 K7 _- T
"%d\n", ret);" Z7 X3 p* ?3 e) Q) {+ c, r8 C
#endif- K; X/ e1 L; s3 r
ret = platform_device_register(&da850_evm_tl_leds_device);
; `- t1 e* C7 t) L F; z if (ret). }( H/ R4 `7 a6 `% W
pr_warning("Could not register som GPIO expander LEDS");
N/ _9 u4 p7 m" O7 f7 \0 ~ else& @1 V, Z6 y! |# R
printk(KERN_INFO "LED register sucessful!\n");- b& f% b. {& i2 U3 R% i( E' h
* k2 h5 L- J+ {+ [' a
return ret;9 J# G: s' J* f6 M
}
# t, B. o6 l0 `* F0 V! R9 H( X4 D
static void __exit led_platform_exit(void)5 {0 U) [/ y% p: K0 Z
{% N! g* f7 k" ^. \! K4 c
platform_device_unregister(&da850_evm_tl_leds_device);2 C+ u) q, m" @# Y
) _! K! E4 r- M* D F4 W, E; m printk(KERN_INFO "LED unregister!\n");
' S6 y* m- l+ s- | J% s! |! i& ^3 [}3 l- ~2 z' _ w8 j: k
+ u# w+ Y# X4 A
module_init(led_platform_init);
: i# ]8 S% U! L& Amodule_exit(led_platform_exit);
7 `4 `: Q- _# s! c/ @% k3 f+ H9 S: W. Y
MODULE_DESCRIPTION("Led platform driver");
: m2 R# Q7 L0 u1 F6 F8 W5 X. EMODULE_AUTHOR("Tronlong");% V! D3 ]- F. F& X, U$ H8 `5 l
MODULE_LICENSE("GPL");
2 ?' R- u/ l% G5 @8 P2 N+ a$ E7 f3 J. |8 C* q8 k) P+ X. [
|
|