|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
# A. f2 S8 p, ^3 D#include <linux/init.h>+ N" N8 t. M2 s2 Q- Q5 C
#include <linux/module.h>
g* B U; f6 ]) V" R) ^#include <linux/kernel.h>
% N; P c, R/ r7 E+ e#include <linux/types.h>& r3 F* F7 ^3 l1 \. G
#include <linux/gpio.h>3 l2 W: I: r& Y- s$ x1 x
#include <linux/leds.h>" O8 B, ^5 H" {1 K+ z, v
#include <linux/platform_device.h>" q6 s: C3 ~) W ~4 y
* u, F* N! p+ F( b#include <asm/mach-types.h>; z: }( x# C; A5 P; u: X; p0 y* `
#include <asm/mach/arch.h>$ i6 l! N! q: q6 h" T6 A0 R
#include <mach/da8xx.h>% }0 S. a& k1 |; C9 ]
#include <mach/mux.h>
4 t' ~- y9 p! F7 J8 n0 R' b( q x$ w! l& \
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
1 L- N6 W7 ]/ {7 X& X#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* H9 b4 w8 @" C& I3 M7 m#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) e! w) f0 l i#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; @1 S3 P# g5 \0 D% s! l8 f( B( I7 x" j9 F% \
/* assign the tl som board LED-GPIOs*/
/ m4 j. L4 O, J- r: lstatic const short da850_evm_tl_user_led_pins[] = {! F4 g4 a% F& |; b- S
/* These pins are definition at <mach/mux.h> file */: v& k3 Y! Y1 Z# f/ c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,1 c5 A2 @* b. I0 X! e2 s
-1
n: V, ^5 n. j5 P/ w};0 n, a5 Q% Q2 ?5 s4 X5 Y
: @- Q, }- M9 b' j, l
static struct gpio_led da850_evm_tl_leds[] = {
( f; h+ T6 d% T. S0 G$ Z {
+ |0 |; X, V/ s' u+ ~ .active_low = 0,
) N( I# q' n/ P5 C, V) B m .gpio = DA850_USER_LED0,
% P0 A; p+ P; U: ^2 h% ~& Z .name = "user_led0",
- L: l4 i. m1 s7 A5 l _. e .default_trigger = "default-on",
# d+ ^" g5 v8 k$ m },
& o Y3 H8 X$ i5 [1 i {/ u: ~) }$ ] W/ f, F0 H9 _& t
.active_low = 0,
( i) Y0 X5 [4 _ .gpio = DA850_USER_LED1,
. `# q8 b0 l1 p1 q( I: { .name = "user_led1",4 l. K) u' O8 P9 M& p* R
.default_trigger = "default-on",
8 s/ o9 Z+ k6 f6 J( w1 d; d$ ^; h6 E2 u( j },
7 p) u0 p- {, |6 m {' |' o) @& G1 z$ y
.active_low = 0,
U* P* g; g# i% ^ .gpio = DA850_USER_LED2,. K* k/ ?3 g5 Z! i
.name = "user_led2",
1 D0 U; l1 a$ u) Z .default_trigger = "default-on",
# P" [# K b+ j9 r/ J },
& |# ]* b6 Q, @8 Q& p: a {: u& }5 P. e- e/ B" X6 t! M Y* j
.active_low = 0,
. d, A" u1 ?! _0 V/ ` T .gpio = DA850_USER_LED3,) G$ H. y" h& ^) [* [
.name = "user_led3",4 r# q5 g% L7 x. \, ~& k
.default_trigger = "default-on",8 Q, r; M. q1 J! ]) V5 P' ?. }: A& X
},! b6 E# g+ w I" k( m( I2 S
};9 L. N# v3 d) C v' b6 H9 o
1 }6 \" s. `2 b! v2 T& {3 Nstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {: M5 w+ ]6 v" U8 @0 T% e1 r
.leds = da850_evm_tl_leds,+ x2 k W5 I% N8 e$ @$ M) B) S
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),8 _4 M# \0 o, B: p
};
/ T. I' x" F2 Z2 H; c$ o3 Z, N; c$ S E2 i
static void led_dev_release(struct device *dev)
) T3 {0 P3 u7 c. m2 Z+ |8 d& C{
/ K6 j4 r/ f) I* u};4 _. {* _: X) }7 l7 S( B* k& R
" I6 q- A- t; q/ Mstatic struct platform_device da850_evm_tl_leds_device = {# X6 [, |3 `% R8 n( c
.name = "leds-gpio",
0 x. c0 t7 ~% L1 L/ X) j .id = 1,2 A- }% F# A; |* f6 l X' j
.dev = {
) d' x( v2 V( a8 q3 f& I .platform_data = &da850_evm_tl_leds_pdata,
3 l, ~( e( S' R& b' x .release = led_dev_release,
! e2 }7 W6 [, p7 @ }' ~# X- W( g; p! l, u$ j
};7 G& |) W3 A. I; U5 N9 _
5 D) Y2 n! V* f" x: D4 _static int __init led_platform_init(void)
7 R n6 O' I' I# @* V, O{: }$ i* Y7 D7 g( K( n& a9 X0 \
int ret;
, V- U# L. ]' Y c, ~#if 04 b% ], ~% b8 N9 |9 G4 Q/ F
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 Y, b- S. a! t if (ret)" p, K, _% v- p6 O
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- n% z" d, D% n" h L1 v "%d\n", ret);/ N/ b7 L3 y' [) |( n
#endif- u& @& p9 Z7 m
ret = platform_device_register(&da850_evm_tl_leds_device);
8 C/ y$ R3 r1 Y Q7 b if (ret)0 G0 p- ]/ f( A& d& M' ^
pr_warning("Could not register som GPIO expander LEDS");' w2 j8 V8 [9 U S$ w3 E
else
: |3 ^9 Y, G5 x printk(KERN_INFO "LED register sucessful!\n");
3 p5 g0 o5 _# V; n$ }( ^/ A l, ~1 A/ u4 X: Q
return ret;
3 y; @6 V( ]' |: I& J* ]" o% H! u}. J2 x: }5 E% O3 |& u$ \
6 ?7 s: G2 g8 ~ S) Q
static void __exit led_platform_exit(void): i5 U! v" h! _& @5 K M1 j
{
) N! X# \6 z; l4 Y platform_device_unregister(&da850_evm_tl_leds_device);
/ y6 f. v" ]( Q; [; I Z
4 o U' b6 G5 {3 G T printk(KERN_INFO "LED unregister!\n");3 ]- O d2 x& X
}+ F. Z6 n8 S7 P" k
1 @2 n! v7 I' y7 Q+ s" `- B
module_init(led_platform_init);2 `8 i9 M# P; Z. t) G5 M- K
module_exit(led_platform_exit);
" K" S5 L% l- ]* b
( ` h& ~" s4 j2 m5 lMODULE_DESCRIPTION("Led platform driver");
$ z7 N4 J) w+ G; YMODULE_AUTHOR("Tronlong");
' f( K- ~( [, l, A$ t: S( UMODULE_LICENSE("GPL");, H+ N* [5 }+ \. G% p; ]1 C0 \
3 g7 L5 i& t: w; `! L/ c- N" j) E
|
|