|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; w& J/ R0 M; r$ l& Q2 v# @#include <linux/init.h>
, m( B' r) P9 s( _& u% ~- k6 A3 [#include <linux/module.h>
; i9 ~7 H1 X3 m) r/ o7 D: V#include <linux/kernel.h>7 r/ s/ T1 c3 U2 J7 T. w" A( W( s
#include <linux/types.h> W- Y& g! W& k- |4 w3 y$ [
#include <linux/gpio.h>' {* l& [, m& g/ x
#include <linux/leds.h>8 W+ s! T' U& c7 U- i P7 g
#include <linux/platform_device.h>& [4 V2 G2 q* i, P; C t# z" U! h
4 n+ Q% j$ f* _2 F4 q
#include <asm/mach-types.h>1 u. R7 \ y5 {5 p( o
#include <asm/mach/arch.h>
# x+ b# Y5 n+ u+ V q. V#include <mach/da8xx.h>
4 l- K# h$ K! X+ f#include <mach/mux.h>
5 [, i7 E+ _- `$ `7 k8 E' S& v& E
, V: J3 d9 c2 Q. b9 O#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
; ?* j' t: U9 L# ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5), Y3 ~8 n2 ]! A9 T, c
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)$ B7 |# o; C) l& Y) _, |
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- {# g" s0 ^+ m& k7 Z4 d0 H( P) h1 J" s' |: q8 H( Z! I
/* assign the tl som board LED-GPIOs*/# E; H! L; ~8 }- K0 U
static const short da850_evm_tl_user_led_pins[] = {# j* W/ S' g7 z0 Q
/* These pins are definition at <mach/mux.h> file *// K- C8 i! p, X% O7 w" [3 [
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 ^: E& f) v# I% K% L -1) K* s2 P% S) G" p2 @
};
+ T6 x/ W% T+ l8 f% @3 m5 W9 G; |) Z; r1 s+ y# t% {
static struct gpio_led da850_evm_tl_leds[] = {) d& m3 R# w Z5 n
{
' }8 o2 d/ V: H- D8 z5 A/ d5 J .active_low = 0,$ X' v0 @+ ^8 c8 o! q, H, W
.gpio = DA850_USER_LED0,) O# S4 Z0 I8 g; I- I" s! [
.name = "user_led0",8 E |+ a0 W1 G& h( Q
.default_trigger = "default-on",# s8 k9 _7 ~8 X
},8 z/ Q( T, R3 }6 j! c+ y! h
{
: A& h. F: a/ [# I .active_low = 0,
4 X, H: }5 A% F* \- }4 u/ o% M% \ .gpio = DA850_USER_LED1,! b4 r }; ]7 I) }( s
.name = "user_led1",
0 j E: B: w: _# I$ T% B2 n .default_trigger = "default-on",
9 v! i `% J2 o4 m" T },) k/ |2 k0 G% M5 f8 g' _5 d& ~' \
{* k9 h$ `2 h. V. e6 M
.active_low = 0,0 f/ k% {2 d! N" s3 _+ A2 {
.gpio = DA850_USER_LED2,& ]( n Y b0 @. }+ K
.name = "user_led2",
) E; [# M, `1 j: [ .default_trigger = "default-on",' v1 u" _/ E2 ~( ~& r( s; B2 ?
},
* Y" w) Y7 U. p+ `. @* }2 }" R; p% S {
9 @4 D: E' f6 e. K$ ~ .active_low = 0,' [0 M+ L( [; i1 F" Q
.gpio = DA850_USER_LED3,6 G! c+ i& q- i8 V" D* E: H2 a
.name = "user_led3",
$ d; x. Z' o X$ J. b .default_trigger = "default-on",* u0 H+ T" S3 G& l" Z( E( i
},/ \7 Q: Q5 {3 [8 k" n- m
};1 G o6 v3 A O) z7 [
; `, H/ a* X6 y* J9 estatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 U: W. _6 K* M& J# y7 o. `
.leds = da850_evm_tl_leds,
0 J) B' v! ~% {: t+ Y4 c2 @; x" V: \ .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# q% e7 V6 B- o+ ` E
};5 {: b5 C9 e% i( _9 h. T
) ^6 T8 o8 \5 H2 ]
static void led_dev_release(struct device *dev)
, l- R5 S$ C* M) A% B6 g2 d z{
$ Q: m- x5 e4 p" X M& J8 T};/ t' \4 D% u5 x) C3 M3 y! z7 D
6 [) p/ k) C* n7 D
static struct platform_device da850_evm_tl_leds_device = {) P6 y$ c2 S7 R2 ]/ c
.name = "leds-gpio",6 P& @ E5 Z P; { M6 l7 d8 o
.id = 1,
7 o( ?5 c2 q9 o .dev = {3 L, f4 \. g4 |+ o2 y6 I$ f3 G) F2 ?
.platform_data = &da850_evm_tl_leds_pdata,
5 s9 k* b2 {/ I9 a .release = led_dev_release,. O8 S' b. O8 q9 q, g: |3 ^
}
j6 C( N) \& V% r8 R$ S+ n; w};
" Y0 C* d: O/ U/ i4 e) S( f |9 u9 L$ a$ n" H/ s
static int __init led_platform_init(void)7 [9 w% I! E" f
{) m% Q+ G& T: Y+ H
int ret;3 i& c: I' c$ u; W
#if 09 U9 c; b8 j& e( E
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% d. e6 L v* ^" b' P. w
if (ret)
! X' p; E( [. ^( k1 l0 y8 G* { pr_warning("da850_evm_tl_leds_init : User LED mux failed :": M- e# ?" s& Y% L( e0 K; ~
"%d\n", ret);
2 ?: a1 L3 U) @5 H2 c- g# D+ p#endif
! V6 W0 o* i3 n ret = platform_device_register(&da850_evm_tl_leds_device);3 a6 u4 F, z8 x! y$ L
if (ret); @# l3 f: q3 e8 k
pr_warning("Could not register som GPIO expander LEDS");9 g/ |: u0 d9 C' J4 O8 N5 p. ^
else
% U& J3 X: N4 L8 l9 B3 z( t printk(KERN_INFO "LED register sucessful!\n");: O/ {6 I4 a z( h+ T2 e3 j |
* N" N4 { l$ D' E- g return ret;
$ `, O; n6 L3 y7 R5 M, _- m}
+ F$ V }3 Y5 H8 a/ S+ F
' ~& P' E; F% C& \ v+ ]static void __exit led_platform_exit(void)
& g3 E2 P T8 T3 I5 W3 |{! c5 }: z+ w! V4 [7 |! s
platform_device_unregister(&da850_evm_tl_leds_device);
; q) ?7 h$ n/ U) a& d6 b6 ^$ H+ m4 \3 L- m0 t, y+ y* Y4 G
printk(KERN_INFO "LED unregister!\n");# s( M2 @4 h; O, g
}: v. F( `7 B; I/ P5 K i
0 p% K" V! n2 C( W* c" N
module_init(led_platform_init);& L$ T8 m s6 n5 ?
module_exit(led_platform_exit);, Q/ @# U* `# W8 L' ~+ c* V) L& {0 O
% B6 q3 Y5 n, S0 x6 G3 gMODULE_DESCRIPTION("Led platform driver");- W: w# J9 R# {: K& W, Z
MODULE_AUTHOR("Tronlong"); G2 a+ \2 V7 s9 u- K1 Y- I
MODULE_LICENSE("GPL");
) x8 B) B6 i0 K, [- U0 c3 k
. K) _/ e. i# |/ A+ c2 K* K+ I |
|