|
|
求大神给下面的程序做注解,请稍详细些,谢谢。" Q3 H$ q8 h; \
#include <linux/init.h>
; t$ `: e' R8 m9 a' }# G#include <linux/module.h>/ ]+ N0 G; K3 T" j0 |8 B$ J
#include <linux/kernel.h>9 h+ X+ j9 d, Y& z/ L2 F
#include <linux/types.h>
) M/ D6 c* l7 Q8 @5 t#include <linux/gpio.h>3 Z) n+ K# \2 K' c+ s2 t5 d }* Z
#include <linux/leds.h>) P% {4 U& U! ?6 O2 s
#include <linux/platform_device.h>
( F8 Q, F5 M7 E8 ]+ V! A+ B5 H% |! x b) H( T/ b
#include <asm/mach-types.h>
0 l/ y6 n3 p) b1 l#include <asm/mach/arch.h>5 P" M G5 P- L2 z; e" \
#include <mach/da8xx.h>
: v' [: O% u7 w#include <mach/mux.h>
, E* j! F" g+ l0 _/ ?* q0 z7 \* V4 ? s- w' u
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)" J* I& g' b% k t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 B9 o% ]9 @" z0 H& S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 X7 }6 I8 n) g5 e2 k: `#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( n% ]. G* K K z+ z3 m8 a8 _% @3 R) \: w! `3 T
/* assign the tl som board LED-GPIOs*/8 L- T+ i4 b: U8 V
static const short da850_evm_tl_user_led_pins[] = {
' @3 C0 f% y9 N! ]$ T% u /* These pins are definition at <mach/mux.h> file */& X$ x. H9 K }( K, }. ^: P! G( y7 l7 b
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,4 v+ u' b+ Q8 u! n. }( _$ {
-1) j! R8 ~2 j6 ^ n
};
4 N* q! r- S. O1 D+ W
0 b5 j- I' e" y" `+ Xstatic struct gpio_led da850_evm_tl_leds[] = {
: m' l6 r4 t) [' }. L# w [ {
0 g! D2 [8 a. E% ~ .active_low = 0,4 }" @& l0 W& U
.gpio = DA850_USER_LED0,
) Z9 N7 `" |" w6 B .name = "user_led0",
3 A+ m' s+ C6 Q! Y: @2 J5 } .default_trigger = "default-on",
# i: \4 w# }+ H, Q" D5 q },
* C t0 B# R9 U7 h8 L2 l3 \ {( x; V' h" O0 R ~
.active_low = 0,
( W% [/ e) o: S$ l8 t; J S .gpio = DA850_USER_LED1,. u- c+ U" S# w9 @6 [! L
.name = "user_led1",4 d* h# m! w: C, o0 H+ @# T. c
.default_trigger = "default-on",2 e* D- T% T: U+ n) b+ A
},9 S3 ~( C8 M7 U$ n( i3 D
{
- ]' p% L6 W7 f' {0 c .active_low = 0,
* ^2 s! \- _/ J* S. W0 E .gpio = DA850_USER_LED2,
2 g4 w1 O3 `& H6 ?+ I5 n8 x; S .name = "user_led2",
( F, h' e0 M# a3 J+ A$ o; z .default_trigger = "default-on",. g& J8 h, r: j- s @/ a
},$ D* O. q, Q& @* s/ L. u
{* R9 \1 H6 U% V( A7 o. L8 x
.active_low = 0,- R' X0 Z" x9 g
.gpio = DA850_USER_LED3,
( o! K. V0 T2 O e* a3 O$ U .name = "user_led3",
( N, n0 }& a* p .default_trigger = "default-on",& ]. K5 n4 w% c7 ^3 D
},3 ?) B2 K0 z9 h3 v
};( p# q8 [- Y: c- B
! r% P% z; D9 g- s9 N8 }1 l
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 K* w- \! e0 K) J9 i' L
.leds = da850_evm_tl_leds,- B/ l5 F! [4 O3 D# k
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
0 E% Z1 V1 s9 L/ l; A7 k" a};
' A! s$ ?# ? @3 C" D
: Z' W* \2 ]% A( y* `- Rstatic void led_dev_release(struct device *dev)
' i) U" @6 T8 e' P2 W{; u5 V5 d$ F$ m; ?/ j$ y# d
};. x- U4 E2 x' I& C% }! J
' j; K! y" t, P0 }; lstatic struct platform_device da850_evm_tl_leds_device = {! T) _7 |) L+ Y+ v
.name = "leds-gpio",
4 X* M+ H" d6 d5 P0 w' ]& Y .id = 1,; U( v% W4 e5 y: q
.dev = {' y) y- M! @: y$ V" Q
.platform_data = &da850_evm_tl_leds_pdata,9 M i, W1 R8 q
.release = led_dev_release,2 C4 {5 `+ l8 }8 x2 L
}
6 |/ Z( Q% _6 r};
. A, @* X# F3 A9 c# s
i9 l% q5 M9 S6 i& |static int __init led_platform_init(void)
+ m* f. c, D5 R& F8 ^( w{
3 v$ r) ]' l' G( P: d+ W int ret;" E2 Y; ?2 ]" U) D1 C- _+ |
#if 0$ ^- d" j; U5 ^' z3 d
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' E7 @) I7 H4 G1 i0 A
if (ret)
6 |, b5 T3 q; U! d8 S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; R9 p+ N$ A% \! x/ Z; n
"%d\n", ret);; y8 W# x5 {& C! c7 Z+ S
#endif( V2 i0 B3 F. e- {1 [# G
ret = platform_device_register(&da850_evm_tl_leds_device);! n( T+ Y! I" G1 p6 g* i. k
if (ret)$ W/ J1 A5 r( _& L
pr_warning("Could not register som GPIO expander LEDS");
5 y F$ d: w" U: ?. }2 E else; T, B4 z: f. i; J/ ?
printk(KERN_INFO "LED register sucessful!\n");
+ m6 I7 \/ V) ^# f9 @9 A; I2 V# z: l- j6 Q% q3 y
return ret;# G% O5 r0 _6 m' p0 }# L
}
& g$ n+ a+ c2 E C! {+ _2 M6 p& |; y
static void __exit led_platform_exit(void)
+ n3 H" A/ @3 g' l' f- f6 A{
v; |( u) A; F' Z+ D( p# U/ p0 d platform_device_unregister(&da850_evm_tl_leds_device);
: q! w, v0 n: V, s
3 @6 n- m5 [' j: _. ]9 K printk(KERN_INFO "LED unregister!\n");' S! t9 K$ ~; L3 y5 [% C
}
5 R) ]. \7 ]& y$ K6 t) ]- r4 J) U! A0 g' y' c1 B
module_init(led_platform_init);' d, Z: W+ u4 Z% |$ R
module_exit(led_platform_exit);2 S! E }6 c6 `4 ]/ O
6 a7 |4 b! d4 k4 _+ ?$ Z! S5 mMODULE_DESCRIPTION("Led platform driver");
3 j- f4 M# Z \% \0 i, yMODULE_AUTHOR("Tronlong");
7 f% `9 l& k. DMODULE_LICENSE("GPL");
8 y6 V: Z7 |8 }% H
1 [* N$ C% Y) N9 K3 n |
|