|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# ~ z- @. Z8 L3 ?7 o2 S M9 f3 r& c
#include <linux/init.h>
# u/ Y& A7 S$ l+ Z#include <linux/module.h>4 Q& M* x" C( t. |1 T: n0 R# T
#include <linux/kernel.h>" ~) w# |$ H9 c& ^8 s; c
#include <linux/types.h>) v# D" L3 @! u3 m- j6 [
#include <linux/gpio.h>
" k" a4 b+ ~: Z; H: h K' J#include <linux/leds.h>: m& g, m1 D$ c3 `0 o L
#include <linux/platform_device.h>
3 I& ?; [; `- C; [5 k3 k" C& W: R! u- J9 t2 G. V7 t
#include <asm/mach-types.h> V# { S2 R" F& l
#include <asm/mach/arch.h>( k- s: T* [* j" D# s6 w0 ]
#include <mach/da8xx.h>
s+ y3 }* _+ [#include <mach/mux.h>
0 V+ Y. |2 [. ~; ?
) E0 ]# H) N, x1 o1 c. Q#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
U; G$ R$ b! ?! r# x#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 C6 ~4 T$ g2 H; s" A5 i% W! _+ c#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
: o, `) }+ \( j" |7 n#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ P% `, e. b$ y& ~2 T5 C3 V
/ ]; y$ V' I" c$ m+ H. \& |
/* assign the tl som board LED-GPIOs*/0 N" b) k! F9 Q' ~
static const short da850_evm_tl_user_led_pins[] = {" V3 ~! r* d. O; U
/* These pins are definition at <mach/mux.h> file */& [: s0 f {$ J8 `' Z. z; a; K
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 Y8 N+ V5 r9 f. P, P. j9 [
-1
; x7 q' k# s0 d H" H! P};" Y% M: w9 W& S7 [# b
7 ~; G8 N- X I9 y' @' Z) Q8 fstatic struct gpio_led da850_evm_tl_leds[] = {5 Y# x q; P. ~0 \( i
{
5 j1 \1 i; N3 [ .active_low = 0,
) Q# g4 A9 {3 ~: y( [ .gpio = DA850_USER_LED0,
% ~* D! i& U0 D2 |+ r( g: s% Z+ g .name = "user_led0",
# N% N4 v8 y- Q' q* u6 G .default_trigger = "default-on",
' Z9 ~, o* `0 b8 m6 S },
0 @& H2 u& S- r1 L/ q3 o1 [% o {: e5 O- O) @6 V8 K
.active_low = 0,
! s/ n+ W. a0 m4 i8 r1 I .gpio = DA850_USER_LED1,' F4 Y3 b( J& g( j Q! O# \- X
.name = "user_led1",
% L6 X8 s3 o- i; S .default_trigger = "default-on",
% P- @3 \; K+ f# U# r' E },
: s' j- J! U- e% i6 t+ R" a( J {6 ^* i# e+ N4 _8 Q4 p6 L4 c4 u5 w! w
.active_low = 0,9 a9 _+ H: W) S) A) B% ^
.gpio = DA850_USER_LED2,
6 H7 I' ]( w; R" f7 }7 Q8 b+ X .name = "user_led2",
* n# q/ u. F1 a g; p& E& H .default_trigger = "default-on",; Q% o- u. `, Y/ R; @/ Z
},
4 R, s; H5 h8 C+ @, i' s {
& H. i& i5 j4 E1 m2 G .active_low = 0,8 x6 q+ V u4 c
.gpio = DA850_USER_LED3,
+ S8 e. k4 G- t2 ]+ l k .name = "user_led3",! B4 k" W' n, k, u- {" X
.default_trigger = "default-on",
9 [- _1 G3 f2 T: b- M },
/ K/ q- o3 x; [' X};
) i" J6 H7 g8 ]$ I! y' A! J! d G. y/ @% Q( h; Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {) i$ |$ h+ h3 R) j/ N$ k N
.leds = da850_evm_tl_leds,6 v# p0 \4 i6 O0 l
.num_leds = ARRAY_SIZE(da850_evm_tl_leds)," F( V; a8 L! ~( k1 T: O8 k) [# G6 Y
};
1 y" q6 x! e) c( e1 ]5 ]2 K, e: W2 u$ B
static void led_dev_release(struct device *dev)4 o' f8 ~& l6 T d' E- g; b
{: I3 H; G5 u" {! W/ b# l0 p
};
. Q: Z7 M# K( B: U, f
9 N( B5 s" T. u8 ~# L# Y8 u/ d: Lstatic struct platform_device da850_evm_tl_leds_device = {
4 f8 n# B/ ]2 Q0 o) ]4 [1 ] .name = "leds-gpio",5 j* h8 ]: d9 Z; o9 t! z. Y
.id = 1,$ q- D# \4 c0 k, |) i' \
.dev = {6 h& Y5 l. a/ X' S' e4 V+ D
.platform_data = &da850_evm_tl_leds_pdata,* J( t1 d; E! {" _
.release = led_dev_release,: o( U0 M7 _3 j, i4 f7 }
}, h) \1 X: E6 K# c
};
9 g; i& D4 \7 `% q( W+ L' h
/ {& K: u) T1 k" c9 P0 Vstatic int __init led_platform_init(void)
* v4 O0 t' n8 T5 ?1 ?1 ~{: T- k. I/ T% Z2 P8 c% }5 y
int ret;
; a" P& b& Y0 z#if 0
1 R& \! r$ c$ d4 w& j' b ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ n) i7 s1 J0 } if (ret)
, k% H& t9 O0 N' ]9 ?' ^. S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 K8 M2 ^" V+ ^! Y4 R# e
"%d\n", ret);
8 G6 e! V1 H0 W7 ]/ d! }#endif z- S& s) y6 r& ?
ret = platform_device_register(&da850_evm_tl_leds_device);
+ o( |+ y" x2 y4 B if (ret). ~6 d) l! N2 p& Y) F I
pr_warning("Could not register som GPIO expander LEDS");. L, f) t$ a; o% [# I
else2 s# J; D8 j. u) e
printk(KERN_INFO "LED register sucessful!\n");" p, [' y( ]" S
" p+ {4 t, H: \1 n1 S return ret;
" P3 J5 M. B) r4 e8 ^}$ }& S/ J9 s5 S+ f
$ ?6 j! x1 Z& I" b
static void __exit led_platform_exit(void)
% Z; x% M- s, X& y4 O0 l' s{7 O7 o$ G+ D8 f: k- R z
platform_device_unregister(&da850_evm_tl_leds_device);
1 |- l9 B) S! R& b' r5 i' N4 I0 B6 o
8 V. ^( m' q! K3 w printk(KERN_INFO "LED unregister!\n");2 E% P( g' t" O/ A& L# w% M& B# |2 R4 i
}; _- t8 i8 x( _) T! T
5 {! @) ~, }& y6 G! o9 f# o
module_init(led_platform_init);* P- j" k2 Q) Q
module_exit(led_platform_exit);- U/ a: a9 {- M! l$ {+ p" I/ ^# t) r( i
( {' g# E: ^* T7 m
MODULE_DESCRIPTION("Led platform driver");
* r% ^, g3 s( I D g1 c6 O& LMODULE_AUTHOR("Tronlong");) ?/ M1 V% t6 p7 O
MODULE_LICENSE("GPL"); e# Q* R: Z1 k0 P6 \. S
9 }+ J9 F$ T2 q- D/ h3 L
|
|