|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
- a" V" H/ c( M. n( d#include <linux/init.h>8 B( b; ?: P: @, `* k' u
#include <linux/module.h>1 {' w0 g: h1 W, W6 y
#include <linux/kernel.h>
8 _# g) m/ X0 m( w: n3 j#include <linux/types.h>
; t9 y& q2 l- J% r* N% V0 f6 p5 A#include <linux/gpio.h>, C' w% w: C! Y& J6 t
#include <linux/leds.h>3 R! L9 c4 N6 v+ i: \( o% t2 S
#include <linux/platform_device.h>6 Y, s6 @9 ?0 }% Q! m& O. o2 q0 U
0 M4 u! K4 \+ p7 _* n3 h- p# C
#include <asm/mach-types.h>
8 D* T4 F5 _& L6 ?& x. S4 T#include <asm/mach/arch.h>
8 n1 A$ i0 y \ O1 U' M#include <mach/da8xx.h>- L4 D! G4 x5 O' ?, G" l& x
#include <mach/mux.h>
& d G5 c+ y0 ]5 w# t8 L) `" m, G0 W$ q) P- S
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; |8 ^+ B- u& Z' J# w* T, v2 W#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
3 w3 L7 U. a2 w+ T, V9 Q# z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 O- x, D' k( n8 C/ x
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; f7 ^! f8 ^: P3 r5 u+ Q* z5 }7 `. L: h' l& A4 [
/* assign the tl som board LED-GPIOs*/
; @8 ^- I# m5 F. {, n3 K ystatic const short da850_evm_tl_user_led_pins[] = {7 N4 q7 |2 ?+ A4 H0 B6 D: F" T
/* These pins are definition at <mach/mux.h> file */
/ v' n/ |4 n5 y( M DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,6 C1 w# p" }' v" }
-15 T3 a0 Q8 O4 u0 w7 X4 d* h$ z/ [
};
& }, H' d! s" K8 i4 w$ e# V+ @# |$ E8 U0 S% A4 n; f! Z* E
static struct gpio_led da850_evm_tl_leds[] = {4 a- A+ u' P' _' h9 T+ T6 W
{; {8 F% M: m9 H$ B- _
.active_low = 0,$ r# }) `4 ^3 X
.gpio = DA850_USER_LED0,& q, |9 I0 E4 u; n4 {$ ?
.name = "user_led0",
) i7 I9 `. b) W9 F8 p* y .default_trigger = "default-on",
3 {! _$ |: |! f' O) O },
+ v% X5 x. H! H; @0 e# k1 z: @ {2 b2 D7 O8 D- k3 g
.active_low = 0,
, z6 k, M: v$ ?9 j .gpio = DA850_USER_LED1,
: O4 ?' L+ Y$ F4 D .name = "user_led1",
: B* g4 l2 p" y. V" {( ?) X .default_trigger = "default-on",
) W6 D! Z. \7 W6 |' J9 O7 T },
0 ~4 w! ?& t r3 T {4 T& i* q$ y: A2 l
.active_low = 0,8 j5 h2 q5 Q# h. B6 \/ O- J/ Z
.gpio = DA850_USER_LED2,+ d2 @/ h; j6 ~* g4 h* K
.name = "user_led2",
8 ?; e- V) A4 t- N4 i3 I+ ` .default_trigger = "default-on",
- t. o; s: R" j! t },8 E7 r: W, B# y2 |5 x- m
{
, G2 e I% m9 Q- { .active_low = 0,3 Y6 _2 Y) s& m) x0 q0 Y
.gpio = DA850_USER_LED3,; ~6 w) e U8 F; v2 t" B! G
.name = "user_led3",
4 a# |9 o+ Y, H .default_trigger = "default-on",
+ ^6 u/ F1 E- o },% D$ j! R3 R, b, i/ \/ l
};
8 v4 C8 G8 N" D' ?
1 c; q9 l8 u6 G( |) Q! Xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( _7 M- R. ]( @' f. q9 C0 a
.leds = da850_evm_tl_leds,
. y5 H) t9 a. x .num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 u: z/ w; ~3 _6 F% H5 o) K
};
2 v, ]$ Y# P* w s8 I
6 g( V, i W: |static void led_dev_release(struct device *dev)
) D1 Q2 U2 r% z: O; ]) M{
1 e K2 r& E1 a! z; A};8 E: `" M. x. t _- v$ @
; H& w$ m$ L; S4 h! Z
static struct platform_device da850_evm_tl_leds_device = {1 r0 C2 _, W; c- X
.name = "leds-gpio",
3 L* D' L" ?; R r8 U+ o .id = 1,
2 [; x* q7 j1 s1 S( ?! S" t .dev = {
* c c4 x5 n* S7 J .platform_data = &da850_evm_tl_leds_pdata,
3 Z* I; o( ^. W- X .release = led_dev_release,
/ c4 z4 l3 K# b0 K8 t8 [$ Z+ P }
- @" g6 V) o) D0 J# ^9 k$ c};; d* h m+ G+ E
1 {! A1 D; b7 c- r1 |0 _/ p. k
static int __init led_platform_init(void)
. N, H7 \/ W9 p- a, m{$ K8 }) _/ T3 C: [8 F
int ret;
3 e& T. ?- S$ n/ c. |( _ s, f: O#if 0
. a% f4 B! {! k ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 n7 d: A4 t3 P
if (ret)/ H( Q2 N f' _) @1 z+ ]: V
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
7 N, M* X% W$ w4 u3 n% N "%d\n", ret);
: O; {* X0 W( h0 i#endif
' F, k( c! I6 A0 s0 k+ j ret = platform_device_register(&da850_evm_tl_leds_device);6 m0 T' R& S2 Y' i0 s/ M6 p' |9 N
if (ret)1 W& U4 A h; A2 P* J
pr_warning("Could not register som GPIO expander LEDS");
( P3 _* O0 ^9 H/ u" c6 @ else2 @9 d9 p% `3 k0 n
printk(KERN_INFO "LED register sucessful!\n");
& n) l0 y7 I8 A5 R1 {$ C" w; ?' Z4 N/ T; t, x
return ret;0 ]/ d5 h' U+ [. A
}
. s. W6 S: K: j, ~
d7 D3 f, Y" C2 jstatic void __exit led_platform_exit(void)
3 r- D; _* t$ o4 o6 W{
* C& `! ]" {( l, @. X platform_device_unregister(&da850_evm_tl_leds_device);
5 [; h: ^, [' M, X, a1 a6 o1 f2 V
& n9 N: S4 ~! P9 i. `" f, ` printk(KERN_INFO "LED unregister!\n");1 ^/ f9 Q9 [) a7 s" s5 ]
}3 _7 L$ Z: R) [: B! y9 ^. t
( w' H1 N" S* gmodule_init(led_platform_init);* |. M* X8 x X/ M/ p1 T2 _8 w9 B
module_exit(led_platform_exit);" F9 Z+ q( U( @
6 V7 S( i M$ H; j
MODULE_DESCRIPTION("Led platform driver");1 Y* }4 |9 N7 W: q$ V
MODULE_AUTHOR("Tronlong");
2 R: g; z! W) ?3 ]MODULE_LICENSE("GPL");* ~5 | O6 y9 k' Y/ K# ?+ W2 x3 Z; L
; L' b* g9 m2 H" |8 x
|
|