|
求大神给下面的程序做注解,请稍详细些,谢谢。" q9 ]4 |- [/ {/ H! P) h
#include <linux/init.h>
. Q2 K( |9 N8 c0 q# N% Z#include <linux/module.h>
3 G" r' Z* ^2 n#include <linux/kernel.h>
* W6 o) Y7 y3 s# h+ E#include <linux/types.h>
- u+ B: X; c7 `7 X0 z* O% i#include <linux/gpio.h>
9 r7 w+ }; b% A0 O( ~#include <linux/leds.h>4 h: |9 h H( C0 f" Z( C- |; I
#include <linux/platform_device.h>
; ?. i; b) I1 t \' @& A
) D5 F7 Y7 l# q) |9 E$ W$ w#include <asm/mach-types.h>
0 E! `& h: `2 k) }: M#include <asm/mach/arch.h>
7 E m& X6 m; W; w#include <mach/da8xx.h>
/ y, Q8 |9 X1 [. C7 y% |( C) V#include <mach/mux.h>. R) Q9 k6 h. A/ C+ x; |+ t, J
% y) |* c& O; Q+ P+ b) L#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 E4 Q3 ?7 m |5 k) u p8 I
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); Q# N L# k3 f& Y7 Y
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) S K3 l6 ]" U1 K9 k
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ M1 E9 J7 f% } T9 r2 p& i3 Z/ F1 J+ j; X% l4 }
/* assign the tl som board LED-GPIOs*/+ a6 w, ]) `- _* @9 t v7 Z( [( K
static const short da850_evm_tl_user_led_pins[] = {
9 `& C7 L p) n5 y /* These pins are definition at <mach/mux.h> file */
' x! |! S8 K1 P8 K) Q# I DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 S+ y! @2 i0 X# C/ F e+ i -1
0 ~2 ~& l: _1 i# q5 T+ Y+ }};
. a& U' \( C( f- Q; D6 M$ Z$ y8 p; v) B! K) F+ r
static struct gpio_led da850_evm_tl_leds[] = {$ G+ _; Q5 f+ G8 `$ N
{
- [: e4 }. V: A; E; [- T# m .active_low = 0,2 }% D6 Q+ V9 y$ Y6 D$ O& A3 L( K- e* h
.gpio = DA850_USER_LED0,
+ y# z7 c7 `/ F) E .name = "user_led0",
, A6 g7 a! G; e! C .default_trigger = "default-on",! \8 B& }* f/ Q1 v" m
},, c, o, r& n2 V$ r5 `
{( u$ `* M( a {0 l! a
.active_low = 0,, H z' d8 W6 `& h3 c. D
.gpio = DA850_USER_LED1,
0 n( ]7 I( } N i .name = "user_led1",
3 Z5 ]; j5 ] e2 G4 ?( r .default_trigger = "default-on",9 W; p8 E$ D) u
},
8 k: m+ U' a! ^' v+ x {
$ \& ?3 }) X( ^6 ]& t6 Y$ k- m .active_low = 0,) I: d/ T9 `5 `4 q& C
.gpio = DA850_USER_LED2,
: P3 Z: X- `/ e8 I. Q .name = "user_led2",* e* }- J4 Q1 g$ j" ?0 e2 S
.default_trigger = "default-on",
2 H4 Y' p( ~0 r },
1 p" t# k. M, y. N3 }! ^: C A! Z! K {" Q+ h# [) B0 J6 u: ~
.active_low = 0,1 b8 M. ?+ o/ I/ _5 o7 ?+ s
.gpio = DA850_USER_LED3,
6 p/ W5 r; D2 ? .name = "user_led3",
a0 [8 O5 T. a. y7 t0 l .default_trigger = "default-on",
1 e, H4 x' E2 p },
# I) `3 G1 g; h' y};6 ]6 l9 {5 d2 e) r& i( n
3 x X: D" T& }$ Vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 A# J4 ^/ ?9 e& W3 x .leds = da850_evm_tl_leds,
: L, Y" P7 a" l# u$ b .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ n- G! Y7 O) [! ?3 w
};
. I( e/ R% V5 C+ S( J$ b
- {" q3 Y1 v" Q* Z! H9 A8 vstatic void led_dev_release(struct device *dev)
- Q, L6 G9 P0 T+ N( S6 d{
) [$ H- k( V1 }5 s9 B};8 c- B: R" |6 M) p, F8 m, H
) q3 p$ J# U/ g6 Q: s& N8 `2 c
static struct platform_device da850_evm_tl_leds_device = {4 U" U. f+ R. C) _8 L
.name = "leds-gpio",0 Z0 u8 Z+ k- }7 y2 o. E
.id = 1,
6 v8 K0 \/ J2 O. ^% t .dev = {+ \: C0 H% a; X- m
.platform_data = &da850_evm_tl_leds_pdata,
8 g+ T' F4 h# g& B8 ^" _ .release = led_dev_release,
& M: o8 d% t( l# j }
6 f" f7 P3 H1 G};6 g d- d- x. A" o+ v
) S! U' V) U1 j& Q# W" }( b) ustatic int __init led_platform_init(void)
: B( p7 m* V' n+ \" q2 Y' b5 q{
# F. k0 P! N m/ J; G1 b int ret;
/ [- n% [) j9 g u#if 0
1 Z9 ^/ V+ ~0 S4 Y4 O" h7 a ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- J" X( e% p M5 h. h' s# C
if (ret)
! X. ` j( D, q5 r4 L& s6 ? pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 X+ J- f. l8 `. Z6 E "%d\n", ret);
) T+ a! j( g+ p8 e S/ ? f0 v#endif
8 C5 v& D% i6 U ret = platform_device_register(&da850_evm_tl_leds_device);& O2 G, }6 S E$ J" t$ t3 n
if (ret), c$ C: d* L* F& e! h
pr_warning("Could not register som GPIO expander LEDS");) E7 y9 V+ N# A8 K: n
else* Z" P& O/ q; a5 C$ G2 O
printk(KERN_INFO "LED register sucessful!\n");
: Z. ~8 Y: w, u4 @4 |' o9 z9 U- \) G0 t8 a4 ?) e4 A1 r8 K
return ret;" q/ c9 d" g( M6 y* b6 P
}1 O7 B4 I; x2 Q" U; ~; K2 Z
7 Z8 @8 |/ V5 C3 l
static void __exit led_platform_exit(void)( k8 O" \( Q- a
{
& F( T$ d4 m" e' m F$ @# t platform_device_unregister(&da850_evm_tl_leds_device);
: I0 e, D6 R5 o+ n0 r/ z9 R W5 }# @
printk(KERN_INFO "LED unregister!\n");
: }" F5 O, {1 ~1 g) ^. g2 H1 y}& p) y- K) i5 A5 m+ q
$ ^+ ?) [' X# b3 ]9 P& Fmodule_init(led_platform_init);5 h- I1 A9 N3 c8 u1 c
module_exit(led_platform_exit);
3 v8 ]1 X) o' O) T* Z1 x L! ]# x; w" B7 Y2 J3 |: h
MODULE_DESCRIPTION("Led platform driver");7 a( j: \- b' b5 k0 Z+ }9 |
MODULE_AUTHOR("Tronlong");
6 W$ d4 P, ~* i3 y* ~# L0 ^# [MODULE_LICENSE("GPL");
! T. j. R2 r; X- L7 p% P0 c/ ~' z$ s) B! o6 [
|
|