|
|
求大神给下面的程序做注解,请稍详细些,谢谢。& J2 e4 U# d: e
#include <linux/init.h>
% }5 u7 b( d4 g3 }#include <linux/module.h>
4 J1 P: k0 E3 ?#include <linux/kernel.h>
5 z4 _! b# j- N8 R5 R#include <linux/types.h>+ ?6 A1 B% M( a. N9 s! C& K
#include <linux/gpio.h>0 c$ G7 `% g5 P& G, i# B
#include <linux/leds.h>
E; g6 d R6 M( A! Q# G#include <linux/platform_device.h>
, k X, u% _$ n# @) Y- F5 L5 |7 b9 W# ]" g
#include <asm/mach-types.h>. w) L. [) S7 r r/ a/ |8 I' m2 Z6 N
#include <asm/mach/arch.h>$ |6 E' ]6 K1 i6 H
#include <mach/da8xx.h>
0 W! f- c4 a7 h' w+ z. F1 M#include <mach/mux.h>" X6 {. M( v+ ~
' g+ R$ i- @; J3 C' I3 l& k#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)3 G3 Q; y# i s- _8 C: y0 ]& I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)3 R! |5 b1 g% v$ @1 d: w. h `
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ k! t5 |, E7 V* [$ i' D
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)' n: f; ?( x$ m6 Q- d
% D" k& \5 s' q( m/ D
/* assign the tl som board LED-GPIOs*/2 ]% _% ^9 [! D1 t8 O3 G' S2 R8 X
static const short da850_evm_tl_user_led_pins[] = {. t+ h8 v9 l& n
/* These pins are definition at <mach/mux.h> file */1 f3 M, y. o4 s: S
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 K9 f" s& A! ~: o H& }
-11 E [6 f2 O5 c# [% R& [
};
$ G' n) x2 @ g
/ A1 w+ M6 y% @5 Xstatic struct gpio_led da850_evm_tl_leds[] = {
D6 P) r0 F2 G' h c {( _" w3 p, `' X& B j2 U. }! ]
.active_low = 0,
; S4 G3 G; L, Z2 C" D .gpio = DA850_USER_LED0,2 o! ^' V, X& q0 y
.name = "user_led0",
$ I" ]3 L% }& A d; e .default_trigger = "default-on",
& X1 J/ P1 W) u8 L! K' C },
4 D% O8 e- c( t7 T; F( w; t {# z- ]& v% l% F3 f4 D
.active_low = 0,
, Z- m6 I" C# \% t .gpio = DA850_USER_LED1,
8 U! l* a) Q. i, @ @" Q: A. r8 L .name = "user_led1",
( o* ?- @, z& b# }7 P .default_trigger = "default-on",
5 e! Q( y+ o L4 ^) p& v" X },
+ q9 W5 e$ c% q* w {
" y( R! Q1 a! Y) J8 W .active_low = 0,# O! w$ w8 B$ x6 o$ p& L5 I
.gpio = DA850_USER_LED2,
& G# M& N [4 }. A .name = "user_led2",0 O0 \3 C+ z: }0 t
.default_trigger = "default-on",
' k: i! ?' C4 C5 g$ J" l. o7 k },
/ m( F, z- a9 |! y# B R {
' ~# _5 x! [7 y4 n* V! H& R/ E .active_low = 0,$ \! Q" L7 n# g% Z
.gpio = DA850_USER_LED3,
2 U! y4 `1 F2 z. c .name = "user_led3",
: y3 c+ Q1 N8 U9 R* [, q. ] .default_trigger = "default-on",
: ~1 L1 Z& W# u },
6 N1 n! P( x7 A( f; f! V6 N};
3 `: ^6 e/ h- g
: k: r0 L4 k6 estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; P7 Z3 g, _0 a8 A" c( c7 } .leds = da850_evm_tl_leds,6 E/ k$ v. E5 g- b
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 |8 G" K/ G8 h1 [3 Z, H2 T; Z
};, a! H, P3 y0 P: ?" }
' U0 F$ f6 r, f/ M- J
static void led_dev_release(struct device *dev)
% `* J8 {1 I; \, n{
7 N6 w3 a+ J" r' _$ f0 H};6 [9 f1 g* t% H0 K" V
' ]8 {6 @7 p5 B D; w. T# U
static struct platform_device da850_evm_tl_leds_device = {% X) Z/ y- K7 W8 ]
.name = "leds-gpio",
/ B5 J. B3 \; @ .id = 1,
% i2 W: F9 y: B* A8 C. k5 n$ u/ X .dev = {8 b, p; K1 _1 A+ _9 U3 V2 f9 n4 Q3 p x+ D, M
.platform_data = &da850_evm_tl_leds_pdata,0 } U; ?( f" g9 y' j, r3 Y1 @* I* {" d
.release = led_dev_release,7 p- ~2 ?6 D: d" ?* a' m) B
}
) I9 ?% h/ q# k6 j" o" t- w};2 q, j, q1 r2 ]* q4 K3 s: G% ^
: j, j1 f# l& _ L) t' ]: D1 h$ ^static int __init led_platform_init(void)4 I: v. A+ a3 n0 k* C( c& B# s
{
! R$ \6 ]0 L2 M5 Y# _ int ret;
/ o* p. m5 d' O& { \( J#if 0
. M6 K0 J9 `* U/ h; A1 s/ R$ { ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 E( C% R1 A0 Z7 r9 n; e if (ret)# n! H, P$ l) v) K; G. d
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 F. Y }2 t5 ?* q
"%d\n", ret);0 w- @, ?! p& w: z( H" J, T
#endif
& ~6 f# b' d& X6 `2 L. n0 P ret = platform_device_register(&da850_evm_tl_leds_device);+ [6 f1 x2 t' W* t. H) [9 o
if (ret)7 k; ]5 l, |& j( Y8 \" S+ E
pr_warning("Could not register som GPIO expander LEDS");
5 |' Q% g$ ]/ u* Y; F) h else* o6 v" H, s; `% p. ?; F$ U4 Q
printk(KERN_INFO "LED register sucessful!\n");) N& \0 p5 v6 r/ t5 l
: R' Z1 c! s3 s: H, @6 O6 e* ^ return ret;. n+ R( L( a: t# ^( o9 y5 d8 {& w
}
1 o+ i" O$ L7 q7 E& S4 d; q% e0 a% y9 N+ B
static void __exit led_platform_exit(void)5 ]3 X5 R) T# g k
{! s4 a9 v5 J g" X% i. Z) j
platform_device_unregister(&da850_evm_tl_leds_device);
C3 V; Y, C1 C9 B3 c! r
8 [- c. H# f0 [" H# { printk(KERN_INFO "LED unregister!\n");* q" J, r/ ~9 F' V; n7 w
}
1 g# x8 c" u9 k1 L# R- d: d. [# N% ^7 G9 T) q6 H
module_init(led_platform_init);
+ L4 ^) h% l6 b- U% S! s$ }; bmodule_exit(led_platform_exit);6 |1 J4 J$ O6 n C5 I3 N
: q: c1 h% ?! t6 }- ~2 D
MODULE_DESCRIPTION("Led platform driver");0 t% M+ }2 X0 K; f( ~
MODULE_AUTHOR("Tronlong");
7 o1 J; ?- V8 B. t/ h7 PMODULE_LICENSE("GPL");
. b- O9 N. J; B! ?) N" d) i9 [, f
: q# Z* m1 |$ r6 m0 W# k |
|