|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
7 `5 \- L& L5 I J1 c6 K#include <linux/init.h>
6 d4 f$ x1 [# ]" ^$ @" W2 m9 m- G#include <linux/module.h>' S- }$ U2 V6 D# i$ |) w
#include <linux/kernel.h>% \7 c6 x G8 N+ S2 o
#include <linux/types.h>
7 t; H c9 Q6 y6 ^1 q+ n" U" ?#include <linux/gpio.h>
" l! n3 K7 a- E#include <linux/leds.h>
- _# k3 H$ m- a- |& n" Y0 c#include <linux/platform_device.h>+ G0 m3 s) O+ B0 i" ~
/ M, b# M. c" o% x% y6 X7 `& P
#include <asm/mach-types.h>. v* b& @, D' d) X J1 V2 I9 y Y
#include <asm/mach/arch.h>
( y e8 X0 S' W# W$ x2 t: a#include <mach/da8xx.h>! ~- W* D# U' ^9 R% d* U
#include <mach/mux.h>9 b: t1 b" B; o0 E# x
% T1 W$ N9 e! z; C. R
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 m7 g" D0 P7 U- u3 z+ G; N& ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ q% u9 l! A. [3 t! E, |1 v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- r, f& E; Z; {. d( X#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 c7 ^% c4 {7 g' \2 O1 T z, q: B
) O* D" f; X W. n' Z4 [
/* assign the tl som board LED-GPIOs*/% c( s9 z* u+ \7 }0 A& @( h
static const short da850_evm_tl_user_led_pins[] = {1 n4 L1 D1 b+ |% Y) G# v
/* These pins are definition at <mach/mux.h> file */, p" P$ T% u# J1 G3 \ }: c' d$ Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ c# h( r# T% h- J6 { -1' \, K2 ?: O0 y4 h3 O1 |6 |' E5 R* w
};
0 }7 X: w) q4 x- _6 z* @
" L2 g! T' d1 W0 Wstatic struct gpio_led da850_evm_tl_leds[] = {$ q' S7 L' |* B9 N) V p. A1 h2 }2 f
{( ?/ {1 R4 L( @% M: c
.active_low = 0,
$ G3 D. F w' G* P# {2 T8 }3 w .gpio = DA850_USER_LED0,
_3 o* `8 T5 N$ t, c5 J3 V .name = "user_led0",
l* e4 b* H+ [9 w8 h .default_trigger = "default-on",
0 x7 |1 ]* r* y8 b8 y },' S9 k2 _" i7 n- M+ B! }; n/ I
{+ h& ?; ]. C5 G+ o, D5 M! B
.active_low = 0,
8 ~7 u4 Q' y! d .gpio = DA850_USER_LED1,
. k3 I& r% J, R7 c- s" t .name = "user_led1",
9 p% r( S6 v U8 ? .default_trigger = "default-on",
& V9 R% Y7 {! S# n0 Q },
7 ?& l: U! d4 X' Y! N( h: X6 U {" v) K7 C6 f9 C3 o- ^+ L
.active_low = 0,
7 i) p$ ~0 f* p: c7 H .gpio = DA850_USER_LED2,, g9 O; K9 ~& u) O# }8 E3 U
.name = "user_led2",
4 z3 g2 X4 f, i7 e3 c2 L7 g2 t .default_trigger = "default-on",$ _3 z( c; N( O/ B! h, k/ l4 }! ~
},( @) f, x7 E" B B
{
' k- z2 S6 R' s .active_low = 0,
/ o; t1 b/ H$ O! T; l: R .gpio = DA850_USER_LED3,9 C* |7 ]) x7 l& Z* S
.name = "user_led3",: U/ \2 m2 h( {- m
.default_trigger = "default-on",1 A( S# O; E) m9 {" K6 @0 Y
},8 z$ S4 u$ F: C" v) t4 [
};
2 r5 n9 o4 r4 r
. D% N% P6 U6 P- B. kstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- S& k6 E C$ r% i .leds = da850_evm_tl_leds,6 ^, z" \1 z2 O, q; Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 R' Z7 p5 w: |1 R; D
};3 X7 K3 F/ c* R" Z# ]: F
4 c9 P3 _" R& Z# [7 I/ L
static void led_dev_release(struct device *dev)+ @: Q" K/ Z: D, e+ R; t- _7 `
{4 G3 X1 U5 R7 n
};( f8 f9 c" k) d9 l2 a3 I
+ O) d- l b3 R: H U3 vstatic struct platform_device da850_evm_tl_leds_device = {
+ E: K+ ~) E4 ?) ?9 u .name = "leds-gpio",
1 [6 [2 r1 p7 d! k! W .id = 1,; N+ I& C2 }$ s6 j) Q J2 y/ Q% N
.dev = {
" U; T% V' Y/ r5 t8 j .platform_data = &da850_evm_tl_leds_pdata,7 E1 h" Y9 l9 b! R3 n8 Y
.release = led_dev_release,
7 K6 A. X; O+ t3 K: Y! J }! c6 D: M& \* ^/ }- c1 ^! L/ l
};
5 W% o: O6 b8 F9 v+ H* R% ?+ [& k5 i
8 f* `' x; {2 L+ B" R5 |static int __init led_platform_init(void)
+ W% |0 `5 w1 ]! ~. o0 s' u{: c& q" M: _3 S& M' h; n
int ret;1 `# f" y( t4 {& w) N
#if 0
, K ^7 i0 u H g* ?8 \ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' n% n8 y9 M# V) ? if (ret)
) j8 P+ ~; N% p" f( x# y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
4 d# E/ _( Z7 B% C$ [+ R4 D: Q "%d\n", ret);
- D- q a i. ^$ A: C6 |4 F#endif
, A! r5 N+ C# K; m ret = platform_device_register(&da850_evm_tl_leds_device);! T9 ~) X- Z; p5 A) i. Q. G8 |% S
if (ret)
& [) i7 H1 {' q' G8 h pr_warning("Could not register som GPIO expander LEDS");
9 _: t& f5 U* W+ S8 L( u else ^% I5 l2 v4 ?4 U
printk(KERN_INFO "LED register sucessful!\n");* {* e/ n' C$ {2 U' Q" \
3 S. f: d- Y0 E! |8 a
return ret;4 u% M/ f/ g. W6 `. }3 c) `
}
" x2 X6 m. m5 B9 } S8 C% T6 f+ W" g, t2 C, u' h# m
static void __exit led_platform_exit(void)
) X; ^+ y5 K% k6 c: k# L{
) I6 j$ D+ z# ]# @1 L( E) g platform_device_unregister(&da850_evm_tl_leds_device);5 G4 ^7 q$ [- l+ h( u4 x
6 t+ Q6 ~/ T4 |
printk(KERN_INFO "LED unregister!\n");% D: V+ M3 p6 {/ j3 k/ i- x
}
# D" |+ `, Q( ~& V0 w7 M; c: J
$ e+ h( X8 {5 l# X# cmodule_init(led_platform_init);, Q- m1 ?& V2 f/ Q C4 d: |8 n8 H
module_exit(led_platform_exit);
+ @4 J/ q. H6 A/ F$ z; @/ l. g# l4 r0 f( q
MODULE_DESCRIPTION("Led platform driver");
' M) Z5 v% O) F1 A& k: LMODULE_AUTHOR("Tronlong");
8 k; b' q' P# _" g9 }2 f! oMODULE_LICENSE("GPL");" K- Z6 h) g$ H" n) l
+ R8 {) E! E, i! n7 X
|
|