|
|
求大神给下面的程序做注解,请稍详细些,谢谢。2 d* A; `: |) O$ m: s
#include <linux/init.h>. y+ r* _' `( U, _( p, h
#include <linux/module.h>. p" G- R" I( C
#include <linux/kernel.h>$ I: N1 l, ?7 ]) T+ o
#include <linux/types.h>
; L1 F. L. u5 g. \% O* x) X+ i#include <linux/gpio.h>" a* ]& u- l+ v3 d3 k) W+ y, W
#include <linux/leds.h>
- P1 n: b, q8 K6 v#include <linux/platform_device.h>. H/ {' e5 S' h% {8 J
% q; s. z0 s2 f" E3 s- a
#include <asm/mach-types.h>
* ]8 O1 B6 w6 d1 r5 [#include <asm/mach/arch.h>
% h9 R- q) q, l- `0 \#include <mach/da8xx.h>* Z, q b% z2 _8 K ?
#include <mach/mux.h>; q' a4 c2 C9 ?' S6 ^: @2 a
6 d. S' J, f/ n#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
: X% Q) I! _5 N#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ P( |, T2 ? p( {#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): y' C" l4 b1 q% e, b
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* x$ M5 Y; c/ J0 x7 R; }$ o3 |8 b1 d9 I1 }7 w' O) y& I; m
/* assign the tl som board LED-GPIOs*/5 ` T+ a" d W' p. y1 A
static const short da850_evm_tl_user_led_pins[] = {
$ B# \$ z) j- V" F& _ k# h' h /* These pins are definition at <mach/mux.h> file */, P7 d, m q! S+ F0 L
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 ^. O* [7 G3 Y: |3 A' k1 l* N -1! |2 M5 @" t6 i/ g% I( ?
};9 ~7 `0 J. a8 C2 [& t# z* ~2 J
7 G: Z, S9 w! W
static struct gpio_led da850_evm_tl_leds[] = {" y0 X8 G+ |7 U3 i1 p0 p
{+ {' x/ g; V% ?8 D1 F
.active_low = 0,1 s) d# h$ D7 e4 A4 y( K. A
.gpio = DA850_USER_LED0,
, G/ t0 f1 x2 z: r" H9 l/ [ .name = "user_led0",
+ ^# b4 v: p6 |. ?% R, S .default_trigger = "default-on",4 u) G) g5 N: p
},
* B6 K6 ?& |7 s- ^4 S- f {
: h3 _ o7 r, `( y1 f3 M2 { .active_low = 0,: J% z4 V* ?3 n8 C' {
.gpio = DA850_USER_LED1,
9 i/ R/ ?! @& H+ G% W7 ?. Y/ r* C .name = "user_led1",
1 [' z% w& q) S4 y9 v) c .default_trigger = "default-on",
( j. ~, T% d+ L# E },
0 k: u, M& R( z! r {
& z7 e: \% l. Q" H! x' h0 H5 E! r .active_low = 0,
; ~* V: q1 j% M& T. F* G& x .gpio = DA850_USER_LED2,
1 p* v8 x# S b( C/ z& N3 h7 Z .name = "user_led2",
N" v7 x& M. g8 ?$ Z( m/ ^ .default_trigger = "default-on",
# m4 j. t# ^' O, B },( n( f! f* N# v
{9 Y& z1 D' j) \3 g
.active_low = 0,. z/ \: Z% T) k9 W! Q
.gpio = DA850_USER_LED3,
! J- s1 F5 Q# W2 ]5 | .name = "user_led3",' E7 m# h d! q$ w) s( Y
.default_trigger = "default-on",
6 }5 d, `# S8 @, W. J* t },2 B7 [" c0 \- V9 O
};5 X; O" c3 F% j% r3 V
. N* [1 r, a' U. L6 t9 {! X1 Estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 `' r v+ m5 X, }5 S+ R
.leds = da850_evm_tl_leds,
. O9 ^2 c# F# q: A: w& h( B" u# D .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) Y( k$ X3 O2 i R};
7 A# t* k7 x: I0 J, ]( z' g+ U7 T4 _" e
static void led_dev_release(struct device *dev)
& D9 r1 u) N8 _* ~6 @6 c{% T# q \: w. E2 ?3 d1 [
};
) ~' I9 U% n. v2 a4 f) A+ X6 l5 P2 X1 [( R! l. r
static struct platform_device da850_evm_tl_leds_device = {( i7 p: I; D+ L
.name = "leds-gpio",
! d4 M% C% _+ L; E( t8 w .id = 1,4 i) C0 `2 B0 |0 h3 Q
.dev = {) N8 h8 L% R: _/ s% s
.platform_data = &da850_evm_tl_leds_pdata,6 V9 F% P+ R @5 H1 P8 @( M
.release = led_dev_release,
7 I) y5 D* c8 u* b4 N }9 h2 ?" r! J j2 H: l9 t6 S
};% \* [' K) G, x9 G7 k
, B7 L$ B: n& E
static int __init led_platform_init(void)
. [; p# G- u# c9 Z2 ? F{
- H# T: E( o/ _ int ret;
9 a2 F# n% u! Q _2 y8 v2 p' W& P#if 0
0 `$ g" E+ b+ { ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 Y+ F0 u1 u* q0 b) k0 N% K
if (ret)
n+ C4 {; E9 t, f7 E pr_warning("da850_evm_tl_leds_init : User LED mux failed :"' z& s0 t; r) r3 k% T" n' V
"%d\n", ret);; M0 i/ R5 ]( C
#endif
- ]9 k5 f# _/ G k' _8 }9 ^ ret = platform_device_register(&da850_evm_tl_leds_device);0 T2 M: u. F* k2 V
if (ret)
/ `4 L1 M- _8 ]: u& v6 a7 z pr_warning("Could not register som GPIO expander LEDS");
" e$ H0 y% B% i+ L! ^ else
2 W0 @2 Q4 U9 q. z! D4 A" S printk(KERN_INFO "LED register sucessful!\n");
* p- m, \$ [+ F4 E- u; I& a* H
3 L" R5 r# E! ^& s return ret;! B9 K" G1 N7 `
}
& q2 p6 b9 X1 p1 r% g3 k* ^1 Y$ n4 d3 a, B
static void __exit led_platform_exit(void)* j1 T. O% ~# j. S6 U
{ Q' ^9 m- L% T# W) f
platform_device_unregister(&da850_evm_tl_leds_device);; X- B1 m6 ^+ ?
! g/ a2 `+ p9 J# J ]
printk(KERN_INFO "LED unregister!\n");4 V6 b0 a7 ?) _8 O7 n& E
}/ ~' i5 ^4 t, J- y1 w5 J
7 M( h5 m. F- U N4 ]4 m \module_init(led_platform_init);0 r2 n) \% ?, Y% g; H |
module_exit(led_platform_exit);: m, d& k! c6 |! k- u
0 d5 D# D5 D2 r6 x1 G/ H
MODULE_DESCRIPTION("Led platform driver");
' |4 e$ ~* v# q* m$ sMODULE_AUTHOR("Tronlong");2 U6 }$ ]) ^5 `" Q7 w* e
MODULE_LICENSE("GPL");( ~. ^: C# [# b* q9 |8 f$ L% k* z3 o4 H
7 i) u3 K; X7 s/ J: {
|
|