|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, S9 `7 z' ~6 [9 S+ U) o6 N
#include <linux/init.h>
7 O& ^3 I! ~* c8 v' L% Y#include <linux/module.h>
% y& H, M3 i) i3 r3 W#include <linux/kernel.h>
8 z" w) y$ {* U4 u$ I- c& {7 l#include <linux/types.h>$ O/ G' c. e7 ~7 L* h
#include <linux/gpio.h>5 }7 ?2 H4 w7 }+ T* G4 g5 u
#include <linux/leds.h>
3 m* l: W" _4 y$ U7 ~& ~#include <linux/platform_device.h>
0 W5 Y# L [% |* x: E4 s
1 O+ |9 p) L# L; Q. r: C/ Y" t9 i#include <asm/mach-types.h>* l. j3 h3 P4 J7 g& ^- L( ^& X
#include <asm/mach/arch.h>: I" C& h) c) {; \; l3 u
#include <mach/da8xx.h>7 }" A: ]$ I+ B3 J$ E2 O
#include <mach/mux.h>8 { d$ a& h; l+ C9 C3 ^
9 N3 n+ a; X$ r4 p% s#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% Z; F( _ x+ g) Y. t' o/ B! S
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)% o, N& L$ k! E: ?
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" d; T, P1 v9 G' y" O4 P#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 g1 O" {$ R/ M9 N
( {$ M& r L' a( m4 d: H4 s( H/* assign the tl som board LED-GPIOs*/ H! T1 X1 x, n0 }
static const short da850_evm_tl_user_led_pins[] = {4 ?) V" R y9 Z- g( I/ q" R) ^
/* These pins are definition at <mach/mux.h> file */
4 B! l. M2 i3 q% \( Z* [2 s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ X* O; M- @7 G+ L8 q9 r2 F& n- s
-16 y' s/ _* i0 @6 l
};
' p' G! r. } O( w- H6 V: v5 I
$ ~6 b5 z0 f9 w! I' D2 }4 O; pstatic struct gpio_led da850_evm_tl_leds[] = {
$ U1 w% f' m- r- v/ ?* Z0 G {( h7 f% `1 y- F4 ^2 H2 i
.active_low = 0,
" s9 d: f0 m! y) z& B# _ .gpio = DA850_USER_LED0,
) S* r3 [6 C0 q7 x- z( Z; I' p .name = "user_led0",. y5 z1 {4 v h- n. G4 t! z
.default_trigger = "default-on",/ S. n; R. y4 [. @) Z$ ~
},% h$ S( d1 K8 t! f# h( e2 V
{
) H7 B# C5 A5 i) ^8 j$ S3 W .active_low = 0,
5 q7 U/ \* D$ H0 @9 f) p0 Q4 [; v .gpio = DA850_USER_LED1,$ c) m, ~# }- M5 \% l/ S9 n
.name = "user_led1",/ @/ B$ I2 S* o& }" G7 }* k7 r
.default_trigger = "default-on",. x8 M% W8 K& m+ `/ ?9 K# E
},
+ z% {6 w9 g. c% J. u+ p2 a. b7 o {7 L8 j+ G, j3 o* L/ A
.active_low = 0,
r; {* E @+ g7 b9 U .gpio = DA850_USER_LED2,2 j2 a# F. M/ h, s
.name = "user_led2",
8 S8 l/ a: a2 u3 Y' c8 L .default_trigger = "default-on",; Q$ @3 ]1 \0 K5 H, G( z
},3 O6 U( h; n6 @1 }4 ?% A% ~/ [# P& I
{
. d; Y5 Y1 Q, @/ S4 @ .active_low = 0,
9 h. G5 v2 k/ i5 Z- h .gpio = DA850_USER_LED3,
9 \ h2 a- k+ X' Y .name = "user_led3",
$ ?0 p, B. l) \% L) A .default_trigger = "default-on",
5 O7 ~9 D, p( o5 K! S },$ r$ z, F$ x/ S
};
' ^3 ]" G2 T" A3 @: ~0 F& S# V! \0 `: _
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' e. j6 p- w" `0 C& h( w6 S .leds = da850_evm_tl_leds,4 w5 |) I1 d+ f: a0 C1 C
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 U9 O5 T0 P% O p5 z& O; n
};: N: A! m( D0 B( M3 K0 J6 \- d) _' X
1 K2 D7 |( G- c istatic void led_dev_release(struct device *dev)
3 }# ?; d2 \6 T B% _{
, a* A$ C/ M& K1 I};# r& j& B2 F& ]
3 F$ n2 x, s) F3 J" L5 N
static struct platform_device da850_evm_tl_leds_device = {7 W$ s! A/ B0 T' P3 L
.name = "leds-gpio",' \) b& ~3 A& Z' d
.id = 1,
0 _" s7 P8 a- R$ f4 @/ H .dev = {) G. u; {# K% H$ P/ l7 ?8 e/ y
.platform_data = &da850_evm_tl_leds_pdata,. C7 K3 P7 g+ b% @+ b2 m
.release = led_dev_release,) @; a$ @* E9 _# T, }
}4 o1 x& [/ ?1 N: ]
};, x) T- |- g2 X; e. [, V+ E) R
# s1 J. J" _! l* H
static int __init led_platform_init(void)
2 |" u; N6 n, P5 I: ]* n$ c* f& G{
% N0 K9 K) Z& l int ret;
" R" @( [( {' D! J9 }/ K#if 0
$ u6 p- }. I/ G8 w z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 _3 F; }" [, R if (ret). ]7 A0 F. B' e# u4 i2 t
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"% I) A, c5 v2 Q+ P
"%d\n", ret);
# q3 n) Y. D/ }#endif
5 [9 U+ l: Z- {8 s; ~ ret = platform_device_register(&da850_evm_tl_leds_device);5 Z6 I7 \0 O* _2 E% E
if (ret)4 f; n9 h1 u8 d0 Y4 K9 w
pr_warning("Could not register som GPIO expander LEDS");( _$ g4 ]- x" N5 T& k7 L6 S
else5 {5 [, F4 ~, G3 r: |9 [
printk(KERN_INFO "LED register sucessful!\n");, ?* U. k' Z( r# k
1 r6 F! @: p7 A6 a' d6 s5 f/ L3 P0 V
return ret;9 G7 w" m1 }9 A, Z$ w
}
0 U: s+ e" a3 W$ }; I
# T$ k1 k- y& b% N! f/ D$ Sstatic void __exit led_platform_exit(void)2 ~$ ^6 h* i% ^
{( i9 J4 l0 ^ l6 m: @! p5 g
platform_device_unregister(&da850_evm_tl_leds_device);
C- ]8 o# z+ z* T) Z1 B+ l. e! h1 [% Q. i! H
printk(KERN_INFO "LED unregister!\n");
+ H( z0 P0 S. r% `}
7 ?! Q. x% [/ J6 r
, b4 h2 n% N3 G7 Y8 J# B2 h1 Nmodule_init(led_platform_init);: V4 C4 I4 O1 c
module_exit(led_platform_exit);3 f3 O- r$ t# e
9 |2 t6 `/ E0 \2 U
MODULE_DESCRIPTION("Led platform driver");
$ d6 u; m7 s" {7 I9 F/ `MODULE_AUTHOR("Tronlong");2 V" o- i5 V1 T+ B+ l/ ^
MODULE_LICENSE("GPL");
" j% ?* T1 ?& q: E! W
0 t- Y1 k3 I; i+ d |
|