|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% a( \5 L- x0 p6 Y#include <linux/init.h>% u& Z5 o! I& s; [% w+ J% L# E
#include <linux/module.h>
0 b; K! _# {/ A3 n4 a#include <linux/kernel.h>
: y; ]: \3 R; a7 q- b8 r5 C- |% D#include <linux/types.h>
( v% `4 n' {# T#include <linux/gpio.h>
- o' `# ]. x$ \3 I8 q, Q#include <linux/leds.h>
/ c" }0 S4 q2 m#include <linux/platform_device.h>5 M7 K A9 b5 n& J K0 h
* Z1 o+ I+ }( G
#include <asm/mach-types.h>
) {" I) [3 ^: M3 A, {& A: D5 C, m#include <asm/mach/arch.h>
/ N/ h( W% J6 f+ R2 Q#include <mach/da8xx.h>4 C$ I) L8 M: Q' O
#include <mach/mux.h>) J4 c: |, S2 D4 {4 H: S8 x
6 h4 \9 V! k) @: k l
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 p! T4 }8 K9 A! H; K- \# U#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 [8 D" G, m2 R9 s: w
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 w7 U& [, W: C3 n, O
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ I" i. |& \9 N8 M
% r9 }8 r" p& U6 \5 j/* assign the tl som board LED-GPIOs*/) m9 H+ U: \9 D( e5 N
static const short da850_evm_tl_user_led_pins[] = {
) Z) x$ k- f! j7 M4 a4 d9 P3 X% d; m6 [ /* These pins are definition at <mach/mux.h> file */
, G4 }6 J* N) d7 q+ g4 o/ \ DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 v# A" B, N1 S -19 `0 x( Z' Z t2 k3 h& }7 `' ^
};7 x: Q! A5 r4 B5 o( r3 E) g, A
( u* c% {- g9 r1 _$ G9 V1 zstatic struct gpio_led da850_evm_tl_leds[] = {& ]+ G3 b: Q1 N/ [8 `" p
{$ g! Y* A& d7 G! }- D6 |+ \
.active_low = 0,
; u! j# B& f0 G$ u5 t .gpio = DA850_USER_LED0,3 i( c* {2 l+ F/ a3 W, j; j
.name = "user_led0",3 G, W5 Y/ d$ [# ^$ B. s5 t
.default_trigger = "default-on",7 W) }# S) a0 V" s. n
},# a' c, h p p4 K
{
+ L* z& v. S* X* | .active_low = 0,9 c# g; M- s' V8 v" R/ Y. m# W3 C
.gpio = DA850_USER_LED1,
7 s5 u0 ^5 l- c q+ @6 w* v .name = "user_led1",
0 t9 U# O4 _' ]: {7 x/ f) E5 i8 f .default_trigger = "default-on",* U% F; s+ a- C% F0 f
}," ]: I9 L* r; [0 i% @1 z- K
{8 ]1 B' Q% d* @/ w
.active_low = 0,
( S7 S- r6 |& W0 B .gpio = DA850_USER_LED2,4 M' g7 A, H% U& j" I
.name = "user_led2",
" `; {- r$ P3 p' E .default_trigger = "default-on",6 K, L2 {# w6 X. q4 a3 q- E
},
) W/ j0 H7 a! _* B {
' R4 ]9 `: _6 ?1 r1 S4 A3 ?1 h .active_low = 0,
/ g' h% i$ N1 H. ~. g) g .gpio = DA850_USER_LED3,
! C! G% G8 G+ H. f .name = "user_led3",
. M8 d, d+ c# n! X( O9 y .default_trigger = "default-on",# a* K7 Z" ~$ i! h1 X9 \9 |' _$ Q
},
/ G' A7 `2 x" B};# y. e8 Y& H8 y9 y; c; P
! H& D: w, j* d3 h# V* V3 _ l: Xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ }" {2 B' n! {' ~+ c$ ]
.leds = da850_evm_tl_leds,
c1 A% C8 R8 n' N8 x4 _, x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 [7 y) f# A% @
};
8 D2 i7 ~" H9 [$ {+ Y, Q, O0 v( S9 ?# h0 }
static void led_dev_release(struct device *dev)) I$ L- v/ ~: f/ e% @4 x
{
; @( L7 C3 _0 i( P+ }( ~};
8 s0 h8 U" s3 {3 P: y8 t3 t: Y
5 \/ Y5 O( W: b- Bstatic struct platform_device da850_evm_tl_leds_device = {5 r# a( T( h4 k) B h$ [9 V
.name = "leds-gpio",
: {; k7 E4 H# W0 E$ K3 K$ c .id = 1,) e M# d P5 N4 p: L" g
.dev = {
, [3 z2 Z% n* i% m( |5 V2 w .platform_data = &da850_evm_tl_leds_pdata,
0 h9 j/ i5 }: F. M .release = led_dev_release,
3 I3 @2 K( J5 r1 V }: K0 t% N8 |2 N7 }) U1 G
};
$ G) k* b9 J& a9 g2 ~& E" Z; h7 E7 \1 t0 R
static int __init led_platform_init(void)
1 J1 V% z% p5 x: g' W& V/ s{# T" _- N* L; F
int ret;3 ?. m/ d- k/ V6 r3 K( u
#if 0+ v+ S' r% `( Z) l" k1 W: ]3 T
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 b& W& Q3 P, a if (ret)! w8 _- R k& x, k7 C, f" W" r+ `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 r2 D2 Y5 O2 F7 w$ f
"%d\n", ret);
. L- W% K1 F! G3 ]/ k8 q9 a#endif3 j- x* C4 t3 ^8 i' t5 p
ret = platform_device_register(&da850_evm_tl_leds_device);. T+ b% w- X/ f; V
if (ret)
, u/ f5 c; G' V! c! D S5 [ pr_warning("Could not register som GPIO expander LEDS");: u% N" j& ?1 Y; v# ]% i
else+ F6 ]- j, G& C
printk(KERN_INFO "LED register sucessful!\n");
1 ~ ^. g, V+ ~8 j3 p n6 d' w$ p% X0 O
return ret;
. S8 w& W, f; U" P}
$ p" R( f" j9 e6 w& A% }& }% A/ i# E4 [
static void __exit led_platform_exit(void)0 X* {8 m1 d$ b e
{ S' V4 C" Q! x! x+ o, q+ B
platform_device_unregister(&da850_evm_tl_leds_device);
. c/ p: n$ I6 ^7 n
5 S% p) q9 ?, U) ^! i printk(KERN_INFO "LED unregister!\n");
- r" J/ n! y( }! z8 v4 I& ^1 q) \}
) `2 U e; w6 I+ o9 \0 ?8 m F1 P; B6 b
$ D& d& c1 x! I+ w' ?5 fmodule_init(led_platform_init);
1 i' e# H( i5 z }) H! umodule_exit(led_platform_exit);0 |' n7 Q0 Z* M6 A
# _- i. a2 t# l* Y a7 b
MODULE_DESCRIPTION("Led platform driver");( y* l9 N2 V3 C6 t: m- {8 l8 @
MODULE_AUTHOR("Tronlong");
* c2 O( x/ J6 E- YMODULE_LICENSE("GPL");& _+ _2 i+ q1 \8 y
9 B# j' u& l" r( d& ^
|
|