|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ _! I; w- x5 a. P7 U#include <linux/init.h>
) S9 {8 K$ A2 o/ V8 N0 a#include <linux/module.h>
! F: Y) s# O: f, M4 B, b/ c#include <linux/kernel.h>
0 S8 h4 k4 |0 U( C& [* p2 }! d% r#include <linux/types.h>
/ h! D2 V0 r( h7 ?0 O#include <linux/gpio.h>* _% c. l& E: S" R) Z
#include <linux/leds.h> B" S0 a6 s y; o# u
#include <linux/platform_device.h>9 ^0 M; m" F( \3 E) w
& s" K. {. F# E. x#include <asm/mach-types.h>! w, C5 S P. U
#include <asm/mach/arch.h>& O- k) G1 P5 L+ b& x+ z0 S
#include <mach/da8xx.h>
5 S) c4 Q. d, c; Q#include <mach/mux.h>
: U: s9 B" u5 @! k* \
- O! ^4 ]" [5 z& p3 F# J#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)0 |$ M2 G& t* w; c* _; {* M
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 P6 r6 ?" B6 F9 t" ^. ^9 a6 O
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
8 g- {7 G% e( S- l% v9 @. O#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 S5 k/ R/ b+ F& e+ [9 {4 F" q
# j5 Z" G; W& Y' B' O
/* assign the tl som board LED-GPIOs*/
5 M& E8 g9 ?9 ^static const short da850_evm_tl_user_led_pins[] = {7 A, B h: n5 w$ I2 }, q) A$ t
/* These pins are definition at <mach/mux.h> file */9 ~" |; `! e+ g) q, T1 }
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; M, [8 H7 L; _! n
-1$ \0 z1 k8 n3 W# o
};
, b. p' e3 e% w% j9 T+ s+ {9 y. ~" \' x4 m2 L. p9 ^
static struct gpio_led da850_evm_tl_leds[] = {
* \9 M9 Q$ m3 ?. b4 `$ X: S! ] {. @$ R8 M7 t% P- F- E
.active_low = 0,1 k7 I' Q) z* }7 r/ j2 O
.gpio = DA850_USER_LED0,9 V2 L/ v6 Q) Z4 F1 g
.name = "user_led0",. y* J* e) v- B7 v! P
.default_trigger = "default-on",
, J+ M* T& {6 _( w },
2 ~6 G' Q" f/ M4 F' f" n# m; f {
# z2 ~. N& X u- z .active_low = 0,
( R ^. A. @7 ?% X5 X, n; W K7 P .gpio = DA850_USER_LED1,
# ?0 T s1 z* p) I, I .name = "user_led1",* _4 |8 O$ c; S0 x+ Y% _
.default_trigger = "default-on",# }: z- C$ {$ k+ K
},) _5 \1 S9 r1 G, u
{
( U& @. c' C2 U+ a5 M% s3 Y .active_low = 0,
3 `( K! u/ N: W% i .gpio = DA850_USER_LED2,
6 n3 d" H" N; l! G; X, {# g4 g .name = "user_led2",. ~. c- i! Y- M
.default_trigger = "default-on",
* S3 M" s) g2 d, R3 K4 t },
8 p% {9 q7 n! A" M4 z- T {
) _- E k6 O; H9 l9 F .active_low = 0,
& B( B; p$ Z' D% _" ?; l. Q .gpio = DA850_USER_LED3,
( l" v# l, f. Y" N4 H .name = "user_led3",
* G3 L( b& N: I6 |8 h) T" B1 S' n5 P .default_trigger = "default-on",7 R( v. t, a, ^' n) Z
},* @3 ?: c1 s7 P9 E$ I1 x( ?: a
};$ [) Z8 o9 u4 ? v: \
3 [6 N: Y6 t6 }$ p4 k. \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 R l7 ^7 l) D2 }5 Q6 r
.leds = da850_evm_tl_leds,+ |; n: J+ [' u9 Y; j2 n
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( `4 e& _: C9 V" ~' c* m7 ?& ?};
* F1 x0 V7 u: f/ _% s4 i4 a; o) G8 f i; \1 v l$ b% q- o" ~
static void led_dev_release(struct device *dev)% _* U; X, V; _( s1 V4 h
{
2 ~* y: E! U( k! a/ u, |0 ^) ~};
6 l" \2 ]" |5 V `& P& H2 g9 ^/ S4 m, r" V/ |8 }
static struct platform_device da850_evm_tl_leds_device = {
( \0 \9 p7 Q8 K4 N' N# l" d2 v .name = "leds-gpio",
% B( m1 ]/ x7 @3 s5 U .id = 1,5 ~8 a9 Z6 F6 ]$ H& A' N2 G
.dev = {/ c8 ? p5 r5 Q! s, W
.platform_data = &da850_evm_tl_leds_pdata,3 U2 N+ {/ X m' ?& f
.release = led_dev_release,
% s: L7 p4 m5 _/ V" g }
1 E& E- [2 _( U7 \};
% q3 M; a$ g$ ^5 u; f L; C
2 ]3 B: _1 }6 T! i5 s; p# N1 Cstatic int __init led_platform_init(void): I: u; |" h* D5 ?$ Z) K5 H
{$ g7 `, E2 y1 {( \
int ret;7 K! | w! }. i$ }0 r4 ?
#if 0. A1 p/ E' D0 N# `* }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( i# }" g* D+ L! a- ] if (ret)! g% `0 I1 @+ o- l5 I
pr_warning("da850_evm_tl_leds_init : User LED mux failed :": } x( q: @) h, p. Z
"%d\n", ret);
& |* a' H8 S6 V& ]9 Y9 Q# H+ E#endif
7 ]9 w' z( P- Y$ k. b ret = platform_device_register(&da850_evm_tl_leds_device);
8 i! y$ X' L& e* `. J5 K& u, W3 ` if (ret)
' j1 w7 U/ K! m2 A pr_warning("Could not register som GPIO expander LEDS");' N3 O3 X7 \8 y
else0 k) C' Y9 P7 k
printk(KERN_INFO "LED register sucessful!\n");0 R$ l9 M8 I. y2 N% K8 H
; q. n F `1 w4 @. o5 m
return ret;3 M {! ]3 F- f" ~" u$ y
}4 h6 a9 a4 t8 t% o
1 [2 t9 G. p9 r
static void __exit led_platform_exit(void)
7 Y: l9 ]. J- o ]/ m/ @% m. V4 O{4 v9 l1 J" ?" G# Q: [; |# K# O# n2 y
platform_device_unregister(&da850_evm_tl_leds_device);/ R& L) T5 E8 Z+ B; q
3 N. g. w" Z t printk(KERN_INFO "LED unregister!\n");) a; R( h1 u9 _# R" R! l+ _4 B, q
}. o' \5 u. }. r: w5 k
( ]' \( N( \9 }4 h9 I6 imodule_init(led_platform_init);
/ L1 p) R5 k8 Fmodule_exit(led_platform_exit);3 B- l9 p9 U% Y( k0 }- ~& {* M
' s# A/ E; t! G4 ~3 J( F3 l
MODULE_DESCRIPTION("Led platform driver");% Q6 x' E6 T7 |3 Y4 s) d
MODULE_AUTHOR("Tronlong");
: a! P+ W) ]# n5 \, _MODULE_LICENSE("GPL");" Z! R: G* b& Q! F A" _1 H0 s
+ ~5 O% V( X! h) \8 r3 V* _
|
|