|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# l f8 w3 [) o3 B' M5 K) J
#include <linux/init.h>
5 [1 [( ~& s% A#include <linux/module.h>5 i7 R) \$ _( Y: Q
#include <linux/kernel.h>
9 A" v% i8 t# L#include <linux/types.h>- y3 ?, H/ y, Z1 F' U- W' f/ m6 f
#include <linux/gpio.h>2 w8 i% ~4 s( d# _7 S
#include <linux/leds.h>; o" [# }7 L( ?. Y' z6 ]
#include <linux/platform_device.h># G4 ] s& e z, s
0 L2 |: `* p: p3 I4 ~#include <asm/mach-types.h>
$ w* y$ o E" m& r#include <asm/mach/arch.h>
% {. W9 K3 }' E4 ?" x$ z' m3 H#include <mach/da8xx.h>/ A- h+ X9 e! q. f# d
#include <mach/mux.h>
5 H# f3 y4 e7 v! \2 P/ N& Q/ \' ?& c! G0 P' M5 z3 m+ n$ I
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) g4 a7 X" ^, Q+ }7 N- U
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- J% B. |) I; H9 P
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ V$ f' {$ y4 `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& e3 @ Q8 k, ~3 Z) f/ a
* D5 m% W2 Y/ o. w. C/* assign the tl som board LED-GPIOs*/
; s/ P5 H, s# K, M" hstatic const short da850_evm_tl_user_led_pins[] = {- Z0 V( E% c }) F: Q5 s( q" D
/* These pins are definition at <mach/mux.h> file */
4 }) k `" o. K" m" B" d DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 N' x! K* {! m
-1
1 z. C8 d7 h) o! j};
$ C9 a# ?6 D' v: K7 Q7 t2 z; y3 Y1 |+ e' G8 s/ l) q
static struct gpio_led da850_evm_tl_leds[] = {
7 {9 Q* l$ z, h; k {: m- K: q0 @% v2 H* C
.active_low = 0,
' u1 ?8 P; \- r .gpio = DA850_USER_LED0,
( Z) W# B; q8 @3 D: s .name = "user_led0",
; D4 @7 {* m" @: }- v: W! h: i .default_trigger = "default-on",
% ?; D, |% H3 J },+ e3 \# e' Q+ b, p3 I! P5 c
{% ?5 F3 u$ b% s
.active_low = 0,2 q" t% k' B/ M; ~2 k& y: `
.gpio = DA850_USER_LED1,
" Y. d* j# r( H9 Z3 ~% O8 h9 p# m5 f5 u .name = "user_led1",
+ ~! p" X( d8 R! {3 S8 R .default_trigger = "default-on",
* e8 H l& T6 B },
) J7 ^, t2 [' V7 C, V' i {% G _: C/ O1 I/ f: g* ?
.active_low = 0,
7 I( V; p8 e" Q+ Z .gpio = DA850_USER_LED2,
r; T2 k0 I+ ] R* v .name = "user_led2",' I4 ]# q& [$ T$ Q$ J1 H# j; Z5 Q# j
.default_trigger = "default-on",3 _% b6 ^2 W7 Q: J( C
},
* e6 \! h, [* K! d5 T {
+ J2 |( l( b: G) j .active_low = 0,
) l' l$ r% Z* I3 G .gpio = DA850_USER_LED3,; Q5 g2 }9 H6 h6 e: M
.name = "user_led3",
0 R9 F: B/ I+ h .default_trigger = "default-on",
5 T Y5 D* ~3 u1 M" ?$ J },
2 t( @; y2 d7 t7 H1 L};
1 s( L6 t `5 B% r; M! v; b* c9 D' i* m
6 v9 A$ \, P) {3 y5 w7 b; gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 [! l' r7 |: f9 j' d .leds = da850_evm_tl_leds,5 v% a; t, @' J/ d5 A( o+ M
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 X! b0 e$ h) \
};" |8 z8 U: W: G' k) g' T8 v! J
0 C7 L. X8 p4 q1 mstatic void led_dev_release(struct device *dev)
2 s/ S; a7 H8 A' L{
! E) @1 s) D) \' L& V* B* l};) A |9 R/ h; R/ X- L" e7 z
9 T( D8 L- p& t4 K) I/ w2 bstatic struct platform_device da850_evm_tl_leds_device = {
5 f" ]' V% C9 E" @' F0 e+ p .name = "leds-gpio",
1 F. g* l/ V: r .id = 1,
- W1 b* x, A! \$ G" R .dev = {% v: x T! U" |
.platform_data = &da850_evm_tl_leds_pdata,
$ h, _- X; I" G, ~. J( ` .release = led_dev_release, ~! D( C1 q6 Z% v. s
}
( r* e. u& G g6 [* \0 {! n};' S, f3 H8 j$ V$ y8 R2 @8 |! r
8 ?$ q7 j+ X5 m0 k1 ?4 D! Astatic int __init led_platform_init(void)# H& C* L) X$ o" W( [/ O0 u
{8 m3 ] a Q3 Z( C. ?) ?
int ret;
5 ~: Z, \3 W6 f4 a( t/ k" Y#if 0
" @6 l# y8 z; S% ?$ q' z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# Q7 `1 A& }, p" k( b if (ret)1 U3 F3 u* \5 F, T8 X$ J' F
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& ?+ b1 I6 u" @ M) \
"%d\n", ret);9 Z* J% N! C z( Y1 u
#endif* f" O2 A6 Y) R
ret = platform_device_register(&da850_evm_tl_leds_device);1 p' M/ s0 F l1 R8 a9 z, @- d! f( p; ]
if (ret)
; K$ H% M* h& f% i$ G pr_warning("Could not register som GPIO expander LEDS");
/ C4 N$ j6 ]. o/ I. M else
5 E( r# g% X1 w0 T U6 o6 M printk(KERN_INFO "LED register sucessful!\n");
0 ?, ]2 {5 {5 `7 b7 t9 A
5 C$ f# K2 ~1 r" L$ v. q return ret;- T( ?( E" d! K$ E3 @; I& M. L
}
9 h+ n) \ T# u g5 x
7 P7 d( m5 \' p; u7 O9 S5 dstatic void __exit led_platform_exit(void)
( v1 {' M& P7 Y- e& z D& P{
) F) Q0 H# T' T! K1 @ platform_device_unregister(&da850_evm_tl_leds_device);9 I, Z6 Z0 ^7 s3 A# H
; M% V. g. }, u- F8 X
printk(KERN_INFO "LED unregister!\n");$ [8 j) u, c- v3 O8 ` I! Z- m6 `
}
4 `: ~4 j q2 n, X ]
! X D$ U5 x3 A& A zmodule_init(led_platform_init);
( ^4 S: t- j) I0 ?7 U+ u+ i% f" y6 Umodule_exit(led_platform_exit);
, y# m n9 D9 a& J/ E
3 D8 `% e6 V: [+ y' kMODULE_DESCRIPTION("Led platform driver");
/ N a0 ]$ Y# X" g1 r1 |# z% ]MODULE_AUTHOR("Tronlong");0 ?% E* t y* t9 C% W; A2 `! z
MODULE_LICENSE("GPL");
. O0 \5 w) D% R- c1 }% }8 m8 b. {! p# g2 Z9 L8 \1 @, l' `
|
|