|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 K; n: B5 l7 z2 s4 f, Y
#include <linux/init.h>$ \3 b, k. o9 ?: i5 N( X+ Y- S
#include <linux/module.h>
0 [! w; Q; E: ?. T% k# @, I) _9 o#include <linux/kernel.h>' C" J0 x j0 V- C6 @
#include <linux/types.h>) V& ?* z; u. W
#include <linux/gpio.h>
/ x' V! l5 K8 }- C- I#include <linux/leds.h>
/ q! N( H& n5 w" {#include <linux/platform_device.h>7 O* t8 I/ |- w! t! q9 _1 S
4 h8 W& ]* T6 @; U. |4 |
#include <asm/mach-types.h>4 f4 m0 M) t; v/ N2 U K, ~
#include <asm/mach/arch.h>
6 X% \* R. |4 s#include <mach/da8xx.h>* _1 B4 B# Z9 ?6 d1 h; N8 F8 l6 z
#include <mach/mux.h>
# @ s/ [ x/ q% k( v1 ]) [4 y; g4 |3 b7 n' n* s& w' u' }* A
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 }0 B5 `7 O- G) l! C3 P#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
g2 t, C* O5 i9 g4 J: i) V+ H) r#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" ~0 ?+ C! v9 a* ^- P' _#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 F+ ~1 e( m1 x8 |3 ^
9 R, L- F% j0 ]' }" } U/* assign the tl som board LED-GPIOs*/% ?( f: t6 Z& e) X. L
static const short da850_evm_tl_user_led_pins[] = {
6 F0 Y1 ^- q1 \( x3 ^; \ /* These pins are definition at <mach/mux.h> file */- J/ d7 k5 W# }+ e
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 J- _+ ?+ W; _7 h, W+ A4 \
-1
4 h) h5 I8 G) p0 S! |};
! e6 ~* Y0 d: _8 r* O
0 n5 k; g/ p7 O5 | O$ ]static struct gpio_led da850_evm_tl_leds[] = {
# A0 e8 P7 u, b4 ` a {; T* Q4 d4 J5 m5 V; ]
.active_low = 0,+ I, |% T7 l6 C+ ~" a' {/ D( F% z
.gpio = DA850_USER_LED0,
3 |/ A6 l D. C9 U; g. n .name = "user_led0"," I7 |0 L4 j3 z4 \% t' a
.default_trigger = "default-on",
: R3 m, L9 S% h: \+ @ },
( b2 K, s7 m9 [ {$ B$ ~ {1 ~% r! a! d$ z
.active_low = 0,
' C# q3 D# X2 H .gpio = DA850_USER_LED1,
4 n' F" m6 W5 |. b- b/ G .name = "user_led1",+ @0 W4 @2 y* v, ]8 b4 W8 H
.default_trigger = "default-on",( g% M5 j2 R( }* Z) E( D
},
' [$ S( T1 M% X( R+ G& u1 o' @ {9 ^. d3 `+ { M+ j
.active_low = 0,0 b7 B; @$ w7 e5 o# ]
.gpio = DA850_USER_LED2,
# ?0 g5 h+ j6 k E, W2 U/ B .name = "user_led2",( v1 \3 n+ q0 W8 ` h: v% F
.default_trigger = "default-on",7 `# M1 {$ t. }4 |* J$ B* w( P
},) o5 R" b) V! ~8 _! h. @; Y
{
8 P2 s+ A0 e, ?/ U- A- O& w .active_low = 0,4 V0 P/ C1 h" @( a* o
.gpio = DA850_USER_LED3,
/ q* q7 D( W0 a& h% B }4 W .name = "user_led3",1 q& i2 o& W `: s" q& G4 a2 |
.default_trigger = "default-on",
6 H* G! F; r8 V3 | },
8 [- [6 m% J1 M8 E2 _};8 b8 |# O! i1 d7 k( i; D
( Q- F' l) `+ [) vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {. G. ~! O4 [3 L6 k- q
.leds = da850_evm_tl_leds,
3 }$ V4 m' I' ~( {# G' ] .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( Y; x2 V/ `" o1 r5 x};
" ^8 E2 k* V4 V9 E' P7 R2 s* I0 `# ]/ i: Y2 O5 Q
static void led_dev_release(struct device *dev)/ I2 K! T+ K2 t% g) |- u
{5 F8 R* f0 T- T# w6 P
};
8 C" d9 Q7 U$ C2 o7 ^4 l0 Q5 Q# T3 g2 n; `6 U4 I+ E" O2 u+ \) p
static struct platform_device da850_evm_tl_leds_device = {# M4 u2 C! i5 C1 V3 w
.name = "leds-gpio"," g+ b4 \( B9 _* ^3 x) d) Y8 G
.id = 1,
( {; \5 ? C! l) L( U7 H .dev = {+ T) l$ o' U/ t, @
.platform_data = &da850_evm_tl_leds_pdata, K n: }. Y3 \ `* J2 ~
.release = led_dev_release,
5 C! S# U0 [% L0 P }
: N" A6 J/ i4 L* [% X# K};' z+ B4 N% T# m! n3 |1 V; J" a
: H+ y4 l7 ^. \- v
static int __init led_platform_init(void)$ u3 F1 z. Z, ? V8 x
{; Z* ^/ X- P% q5 J. [
int ret;3 J9 v' I! A' c( C X
#if 0 W: Z) G/ b2 b9 Q, U; m
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
1 }6 a2 E7 f) a6 m if (ret)1 a. a7 _* [; g3 }8 d" N( @. U
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( u2 C. Y6 A" b+ l3 W2 H
"%d\n", ret);
' b* f4 z {0 E9 b2 ]+ }/ i#endif9 M/ h- B) a, y2 P# N V) k
ret = platform_device_register(&da850_evm_tl_leds_device);6 M9 R- \( b: ]- P
if (ret)2 C0 R# a1 t. T7 ?: Q( u
pr_warning("Could not register som GPIO expander LEDS");6 X' V( n3 x7 {* k- G! H) i+ `# P9 ]7 e
else
$ _4 l$ ~4 {! X: j+ C$ K4 F* W7 W% M printk(KERN_INFO "LED register sucessful!\n");: e9 d: ~/ g% h+ H, x; M
3 c& U* J. H. Q, f3 @- U5 d
return ret;% H& E1 d! I( m- A' c9 X1 V
}5 u- k7 b7 a- ?' X; D" ]
7 I) h; U c5 Q0 q$ M2 T
static void __exit led_platform_exit(void)- g4 n6 y9 ^# x, j6 e
{: M* ~, k |" W$ }+ x
platform_device_unregister(&da850_evm_tl_leds_device);
& O& W- N5 p$ D+ \5 t4 D) j- @. [: c3 d+ C6 e
printk(KERN_INFO "LED unregister!\n");2 C7 E' t; \& A6 M! t4 h+ S; j
}
4 Y d4 \% s& y+ m# r# u& ^2 z, ~0 c m" g7 I- G
module_init(led_platform_init);0 a3 o$ j9 C* p. g
module_exit(led_platform_exit);
2 f7 b9 d* E' @% ?4 Q% l7 [. S/ R6 I9 z' K) E) z% @' _ e, Q
MODULE_DESCRIPTION("Led platform driver");2 n+ G: g5 E, o" V9 b
MODULE_AUTHOR("Tronlong");
; w L% a' B9 ^5 {9 nMODULE_LICENSE("GPL");5 U7 {8 d2 x+ _, B
+ Z. Z; p: d% J/ p4 N _ |
|