|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
1 [0 S' L/ p! U+ Y#include <linux/init.h>
$ c0 R8 d; R0 ~0 R2 J8 n#include <linux/module.h>
4 a9 @6 W2 I, H) q, m- p#include <linux/kernel.h>
5 o5 l$ I; T _9 w5 ?#include <linux/types.h>
5 s% N( F; X2 g2 x4 a#include <linux/gpio.h>" e/ F: C; t7 U1 B) z2 C
#include <linux/leds.h>
& @8 O4 {+ I* w0 S ?# i1 p; ]0 ?#include <linux/platform_device.h>
! ?) v- G( t! \. F( r# C" S" [0 K0 H. D
#include <asm/mach-types.h>
) M& ?/ v4 e9 R* F& @6 N#include <asm/mach/arch.h>
. i! n4 [: }7 m8 y2 E- U4 Q( v#include <mach/da8xx.h>, v+ _: s. [" U* X" {, x% ?
#include <mach/mux.h>
7 P3 u# w l/ {' ]. B, H) ?! @2 c' q. a; `% E. t1 J
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! m6 K0 B/ U" E! v; @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 g6 S: W I8 o B& A#define DA850_USER_LED2 GPIO_TO_PIN(0, 1), T5 j! R' D$ t% L" R6 U( c4 G7 e
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) E4 R# z' E7 S2 _9 J6 w
3 S, ^- `$ c% p, k
/* assign the tl som board LED-GPIOs*/
% T6 ^; t" Q+ rstatic const short da850_evm_tl_user_led_pins[] = { _1 w( w$ |, q" B# j
/* These pins are definition at <mach/mux.h> file */
' A J$ L3 ]8 U DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 A+ Q9 ~' T3 A# m) {+ }
-19 u. y1 }5 ?1 O7 ?- Q9 `
};" x. W9 o2 p/ h4 M; X
2 c& _) ~7 @( k* n$ qstatic struct gpio_led da850_evm_tl_leds[] = {
& B' | B1 e7 E' u* I {
% x3 L7 g& L7 R# {; c8 | .active_low = 0,, y0 Y) ]) x4 w# m0 F. n
.gpio = DA850_USER_LED0,8 ]* }/ G: E1 o) Q, ]
.name = "user_led0",
" @( R( s+ ?1 p$ }" z .default_trigger = "default-on",* H' i4 e3 ?+ H/ n
},
& \) a+ a4 Z$ P% C& R/ _( P {
, x, V$ C' p; d/ x8 r .active_low = 0,' Q& d- ~: B0 A4 x) A
.gpio = DA850_USER_LED1,7 V' `( {) B% Q9 W. z
.name = "user_led1",
$ F2 X1 [1 p7 I4 i/ U' t .default_trigger = "default-on",, w9 {+ Y$ V7 _7 U6 D
},
9 \8 j# F6 L4 E9 M c5 x {0 @* c: E4 W1 e5 o3 C
.active_low = 0,
9 Q/ D* C: r( ^ .gpio = DA850_USER_LED2,
( F" h) d( H C8 X# H5 N1 G .name = "user_led2",& S( a# M2 L8 z4 V3 B
.default_trigger = "default-on",
' M! D0 q" U- g8 f5 m- w& u },
: k& d Y, d1 { {
0 L# ~! S& R1 F* v( i7 ~7 ~7 @: t .active_low = 0,
9 y: H5 ^6 k- s7 h1 V .gpio = DA850_USER_LED3,
& \# L U( `6 A% b' p2 c .name = "user_led3",
- Y+ \8 C6 W# Z4 B5 N3 G2 {, I .default_trigger = "default-on",
1 D* j B, {. f" _7 i },5 J: B; D; G! }8 o' k0 d' g
};
, n; I3 N9 [. n' u& y( T8 h; X9 F/ t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# ~, q$ m6 Q4 E9 p* d# R. }& X7 W+ @ .leds = da850_evm_tl_leds,
6 A2 ~7 F' f [7 t' W .num_leds = ARRAY_SIZE(da850_evm_tl_leds),& j; J, {. W( v2 G5 V9 w+ [5 t& z6 E
};
1 i, N; v/ c* a2 Y N! [1 y: ~6 L
static void led_dev_release(struct device *dev)
3 s' k* F- p$ U3 D t{( ^1 l8 [1 w1 [8 q0 I# z' r! E/ b
};) |% Y n" ?9 V/ t
: E9 y. K/ s% J5 q/ i8 Istatic struct platform_device da850_evm_tl_leds_device = {- N0 s* o2 z* r W3 t
.name = "leds-gpio",0 J }1 O% O9 g/ z) m
.id = 1,9 w: X p c1 R( U7 R0 x! V+ f
.dev = {
- |/ z+ }% J& ?* j( z .platform_data = &da850_evm_tl_leds_pdata,& \7 u$ m4 b/ |/ [ f& B5 |( a
.release = led_dev_release,1 f4 I2 h. P% i) g
}
; A0 E7 N/ Z- F' A1 U2 B$ ~ |};/ I3 k4 T, L/ T9 D
4 U8 ^; U. q4 S' X
static int __init led_platform_init(void)$ H; `0 d* [( I. ]$ P: a- d/ y/ ?
{7 P# W- y8 h/ Q6 x
int ret;
9 L+ H; G. I1 V6 U ?" g" c#if 0, r! G! l0 r8 m! e% I( e0 o
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 x% I i- i5 ?# X/ c if (ret)% V3 @* C+ p( b2 W' ^
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( W* q* }1 f( ?- ~- T* q
"%d\n", ret);
9 o0 E; z4 T- ^% W#endif
7 B) M4 D( _9 z. ~5 @& W, W ret = platform_device_register(&da850_evm_tl_leds_device);. z0 W# r, R& l9 h; l
if (ret)
- k3 s" B+ a p* Y/ J7 f% ] pr_warning("Could not register som GPIO expander LEDS");$ e) f( f. z0 z7 l# j7 q
else% S8 P; Q8 y( K" T3 H! Y/ [$ L8 `
printk(KERN_INFO "LED register sucessful!\n");* f2 X& F$ |7 `" H, g
5 O I, B9 L8 I/ B, b$ E% U/ d$ m return ret;$ I v5 ?( q5 I6 N2 z/ O
}+ K$ w5 W, N9 S
6 M- x3 m2 D' W0 vstatic void __exit led_platform_exit(void)
# G. X: ~9 \8 A7 M{% I) F, k0 F" l5 K# j' [/ \; n! `( K- p0 E
platform_device_unregister(&da850_evm_tl_leds_device);! e! S ~+ h6 A, |6 j
3 y- r( ^+ J6 `2 w8 X1 S9 h
printk(KERN_INFO "LED unregister!\n");( k1 `1 x3 ^6 Y9 h1 I$ T- |# @7 G
}/ p4 W5 @' J5 U4 j& f
7 s0 v$ Y6 I! K' @4 c6 t N& ~module_init(led_platform_init);/ c- a* z1 }" H1 G0 t
module_exit(led_platform_exit);
+ \" R9 d, Y% g* g% k
$ R$ } n" j+ C7 BMODULE_DESCRIPTION("Led platform driver");
' b+ x' P$ ^3 Q% ?6 RMODULE_AUTHOR("Tronlong");
& m6 J0 s3 ?% A& m8 }MODULE_LICENSE("GPL");5 e* d9 ~: Z; r! K
/ X l: [- e: x/ x |
|