|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
: N! Q( Y% s3 ]. i#include <linux/init.h>
0 R$ M2 v' H6 [#include <linux/module.h>/ S" g5 Y- O4 S; m% t6 i1 C
#include <linux/kernel.h>' F8 {+ U" w: K; f: e
#include <linux/types.h>! {" s5 b1 a: \% \# b" X
#include <linux/gpio.h>+ T$ A# ~' N$ A
#include <linux/leds.h>; y+ V# n$ J# M3 n/ A3 O
#include <linux/platform_device.h>6 B* L! U1 O, B7 W! u
" i5 ^( V5 [$ z5 y
#include <asm/mach-types.h>
9 q% D. A8 N* j4 ]& V& C#include <asm/mach/arch.h>+ D" v7 U' Q* g
#include <mach/da8xx.h>
4 z: I$ ^$ }! }; j+ C* P2 M#include <mach/mux.h>
& I/ D1 L' a5 `3 @9 t( C
, z8 U* A6 F9 A& v% o1 ]# {8 z#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; L* T) X' G9 H#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 Y Y; `. B) M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 ~5 @7 A5 k+ o+ n) X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 X1 @5 A' z( L" h1 g5 O
U+ n; x, b: }! F' @. `$ i/* assign the tl som board LED-GPIOs*/
0 V2 U. `4 h9 E) m6 O' rstatic const short da850_evm_tl_user_led_pins[] = { X% j) z# v. V+ e P1 Q
/* These pins are definition at <mach/mux.h> file */
" s% i. q' S* Z# z" O+ s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; H) l( O. h: T2 b) N, } -1
- H& c3 d" I [" n7 h};) j! l0 V, V- A6 P7 N4 N
6 x9 T3 D! x8 C" xstatic struct gpio_led da850_evm_tl_leds[] = {/ I9 D* Y1 ~, h+ ^% D2 U
{ m9 v! B q5 `! a
.active_low = 0,
; _# }- [- m9 `8 J ] P .gpio = DA850_USER_LED0,4 ^$ l2 K; r, p
.name = "user_led0",
0 C0 ?, P) W! t) ]6 V9 h: C0 U .default_trigger = "default-on",- Z' g' W X/ l6 ~
},; @ F8 g- Q: h! K J& e6 _' L% q
{
@1 _; }. ?& R) p) E0 ?1 ~ .active_low = 0,! ~& q( {: i0 ^ E E
.gpio = DA850_USER_LED1,7 L5 j5 s2 O: x7 K! @
.name = "user_led1",
4 V1 Y4 E0 ]" E& f# f* [' v .default_trigger = "default-on",
' o2 m. I3 p/ H },
! ~' ~0 f$ A1 Q8 g: s6 z {
S- i( H, U* I0 R5 @ .active_low = 0,$ P$ u6 p! z8 s0 j- I% y
.gpio = DA850_USER_LED2,/ a) {8 B& e/ W3 q7 V. f! H g
.name = "user_led2",7 t2 u! b9 M v
.default_trigger = "default-on",/ k3 O I( s3 f$ |
},$ e: G4 U% ^7 x% ^" t; h7 x
{ f% P3 T, i/ _5 a, J4 n- O
.active_low = 0,( a4 M- n' p8 }# h
.gpio = DA850_USER_LED3,& _5 p1 j* d( j) K
.name = "user_led3",
7 B0 R4 i8 j* H' p+ X7 P& n8 K .default_trigger = "default-on",
9 d$ n* e3 S8 U; g3 ^ },1 Q4 L& m4 {8 f$ H0 h* U0 h! z$ b
};
5 x5 _4 d B! a7 }& H; {: R2 T! S8 c. d& k' |5 j' w
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 n4 M9 M* V' x( v7 s
.leds = da850_evm_tl_leds,
1 ^, e0 @% }6 t8 D7 n .num_leds = ARRAY_SIZE(da850_evm_tl_leds), k T: y# d- h ?
};; s3 J% w; q6 I4 f0 m* B
( o, _: N' d# m, i' c; b; W
static void led_dev_release(struct device *dev)
3 v$ @9 a" e4 L2 h) i{
# L3 y) J% f9 y) i5 f};
9 v4 O7 F; R. X
) o% }# V* ^% ]4 S: }7 q: astatic struct platform_device da850_evm_tl_leds_device = {: f5 C0 d- D5 B7 Y8 D4 E# q
.name = "leds-gpio",
( A5 w% O" f1 a+ @ ]9 @ .id = 1,3 |2 g9 I9 l: l- Q& h+ @/ t
.dev = {
$ S! e8 H: C1 Q8 I .platform_data = &da850_evm_tl_leds_pdata,
) P$ F M# A$ Z' ` Z .release = led_dev_release,% K2 i$ q. S- @- c$ F" o
}
7 f1 ?3 q3 k% Y( T7 g% K! o8 G};
- X% F6 g; w' [. g8 F+ M( W7 O
6 F: K2 s+ ^. ?* R$ v/ Ustatic int __init led_platform_init(void), `" I% X% I1 R- z4 B, D
{/ n) e' {* ]8 h) L; X
int ret;& E5 n6 I( J( ~- X5 R4 B$ Z/ ?% M
#if 0) d4 `, O+ F% }8 d) i
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' {# r" K# D2 n7 s' i. D+ C if (ret)
% ]- t. a7 j& H7 ^ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 C' h; R, ]& }2 ~5 j
"%d\n", ret);
6 ?/ ?, `) a9 |2 ?; E1 B# m- L#endif4 y# o4 H* \$ U( y5 y" u0 J
ret = platform_device_register(&da850_evm_tl_leds_device);
" o p1 O% b+ ]6 W( y! x if (ret)
+ [7 b& q/ U* q, `, W pr_warning("Could not register som GPIO expander LEDS");4 \0 ]8 }, y5 y& g' m
else, y% @# J! H* P2 T% j' X# p
printk(KERN_INFO "LED register sucessful!\n");
, a/ _8 Q! I0 h7 `6 A( W0 z
+ p5 V# H2 o& ? return ret;
. v1 F) O& |5 d1 }2 ?* E}
; |' w- t* j# ^# ~% ?% [ D& U+ T" Y: w! {$ E, ]7 ?9 `( I
static void __exit led_platform_exit(void)7 k x- x6 U0 ?3 T& o& H
{/ j7 H" O" o6 N5 v
platform_device_unregister(&da850_evm_tl_leds_device);
/ @4 A, k% h1 W/ U4 t7 C0 }9 i
2 u, @1 }8 @. p* c) c printk(KERN_INFO "LED unregister!\n");+ e, q1 k7 [2 K! T0 r6 }4 m* T
}" W: {3 ?) c! L: S6 b
$ N; ~5 q0 n1 R; G6 l. i4 n& S
module_init(led_platform_init);2 t: N5 k1 ^, i8 t
module_exit(led_platform_exit);; I( C; |/ U( q0 {1 {3 R
: q( q/ z; `: q/ UMODULE_DESCRIPTION("Led platform driver");/ S5 \4 O5 q& q3 Y
MODULE_AUTHOR("Tronlong");- w2 e. H# h6 f4 T8 g
MODULE_LICENSE("GPL");
7 a: c/ r, e0 E
! [$ z x6 n; M |
|