|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
W& m3 G/ Z+ w' z U#include <linux/init.h>
* I8 D5 C7 M- d, Q5 N* \1 w#include <linux/module.h># h3 U- A$ L* m1 ?! @
#include <linux/kernel.h>
2 o% X' G: F, e#include <linux/types.h>
! {7 L: y$ w! L#include <linux/gpio.h>
/ E1 {" r- ~ ~. t/ T#include <linux/leds.h>% S2 s, [. q2 {/ ^5 q- K9 H, h8 b
#include <linux/platform_device.h>6 E9 z7 `7 G7 D
/ G+ a1 {5 J7 N( F+ o1 W% }( E#include <asm/mach-types.h>
# _6 r1 [7 | N#include <asm/mach/arch.h>
0 ?3 S+ v1 k) G' S3 x#include <mach/da8xx.h>+ Z F) f9 E) c$ i& C+ X
#include <mach/mux.h>
}# [: A" ^; [. E7 @4 Z
1 ?/ {- k0 K( v#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ ~: q' t" B" j6 W5 f#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
n0 O4 I) x- M2 D( Q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
* c) e3 b1 `) T- C# x* \2 `) r0 C3 {#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
$ P# R* |4 \2 u5 s( y2 Z3 m7 O
7 a2 j5 a. ?+ ]- L" }/* assign the tl som board LED-GPIOs*/
, `2 Z' N0 q( z% r4 p4 T- hstatic const short da850_evm_tl_user_led_pins[] = {
1 s. x. }% \% M) V; b- J+ s' y /* These pins are definition at <mach/mux.h> file */4 K, B9 P& X- N1 i# L
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# @( L# z$ d( y3 e, P -1
% c1 t& {( g! i};, Q8 g8 q9 Z* N
7 L4 H; f7 N) G, B( `! @7 U5 \) Ystatic struct gpio_led da850_evm_tl_leds[] = {+ X5 e5 T# y! j; |; A
{
) i) q5 M* b6 q .active_low = 0,/ x+ ]5 r" U+ |+ a
.gpio = DA850_USER_LED0,
1 Q' k7 L0 S" ?0 I/ h1 Q .name = "user_led0",
5 R) b) i8 |# t# B4 D$ O .default_trigger = "default-on",
4 E$ R6 `* I h! i0 w% d6 q3 a },; b ^; ^& n& e# }5 e3 W$ e
{# k4 r1 p& Y: o- }8 @/ v
.active_low = 0,( H7 G# w$ m1 o# R
.gpio = DA850_USER_LED1,9 ]7 o5 z+ K+ l4 R3 g
.name = "user_led1",
3 s6 E) X' C: Q8 y7 g) y6 @4 c .default_trigger = "default-on",3 r6 b# o. ^5 V' f+ b) o( e
},
0 g9 x: c$ e2 L0 J# h# v {9 O4 F1 [* }( g- U7 T) j2 B" v: Q
.active_low = 0,
* C- P( }! a7 I .gpio = DA850_USER_LED2,
& M3 G- D6 |8 `2 n% ~ .name = "user_led2",
' O8 t6 n. c# o( p. i1 w ~5 g .default_trigger = "default-on",
3 L g$ n; x: W6 \! G },. Y: m/ m( |; p
{
~1 Y) N9 j& {' J7 B6 I .active_low = 0,
0 ` P! b6 t0 H- t- J4 E% K; s .gpio = DA850_USER_LED3,
0 Z$ y( @: |. K .name = "user_led3",
. B4 \7 S9 A. g* b .default_trigger = "default-on",
& X" R) P, l* g' Z+ W },$ k1 {, A9 P7 V4 Y* U a' b: h4 W
};
# X+ K8 Z6 }8 S$ y/ e3 T* A8 O: a# h3 n& m9 Y3 b5 R2 p# p
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) j' q% Q5 S2 t4 [ .leds = da850_evm_tl_leds,: x/ \& v0 M9 |6 K6 S% M3 q& Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; L( [$ O7 _+ @! h( n( l) ?% G) V$ G
};
- W5 r6 r6 @+ d! y9 j
; v" X9 ]( `1 i& N7 Kstatic void led_dev_release(struct device *dev)2 L* J0 @! _& V, U8 m
{2 c" C% `" [4 L3 J5 U5 J8 T0 E
};. V6 w9 L: O' }4 _
/ g1 L. b! D3 q* w3 {
static struct platform_device da850_evm_tl_leds_device = {" p- C6 d" M' \3 R, ]
.name = "leds-gpio",
4 x$ \& k: x% _" Z0 h8 q .id = 1,2 Q r6 d. z) g; s2 T% L( M9 p" k8 `
.dev = {
i2 ~) F$ j; b$ \ .platform_data = &da850_evm_tl_leds_pdata,6 A, n1 q( ?: n
.release = led_dev_release,$ v, Z- A2 A9 i) e
}
l/ Q4 F# V& W. T7 ?/ P};
7 E) i9 ?1 f+ Z. n3 `/ x$ N$ y/ O9 }$ F1 s
static int __init led_platform_init(void)6 e8 Y+ }* Z$ }
{9 J1 ^3 `$ D) [$ z' [/ N
int ret;/ B) J! Q# r# p8 S# L" X3 m/ y9 m
#if 0% \5 r) h' [/ P( n% F* }4 k2 s- B
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* D2 W" w% y$ {( b( b H H if (ret)* ]% |+ ?( U6 _3 ?0 K
pr_warning("da850_evm_tl_leds_init : User LED mux failed :" `% i3 I: ?$ k0 E
"%d\n", ret);. A& @) \' B0 u' b3 L3 V
#endif" {, O% y' j/ c
ret = platform_device_register(&da850_evm_tl_leds_device);/ S- E' T- B* r. o7 A% }# v
if (ret)0 M3 A! K& R! V( u
pr_warning("Could not register som GPIO expander LEDS");
5 z+ y- s6 K% U/ O" k else
8 t; y* M; n, C( _: W printk(KERN_INFO "LED register sucessful!\n");
$ W9 u6 m3 [. d+ g% W$ [1 o# c8 N( C- }
return ret;) X" }3 R2 m7 I" ?2 l! t% Q/ d4 ?1 z
}% {* A" D1 I" }& O
$ V- O) F0 `- I9 V
static void __exit led_platform_exit(void)
* R ~4 G/ O3 g0 j7 q{1 @7 O% {; H% V$ k) W$ @# V
platform_device_unregister(&da850_evm_tl_leds_device);/ N& U! F8 s9 n$ e* s8 k8 l
- r0 O, Y4 J- w1 Y1 W9 ?& k
printk(KERN_INFO "LED unregister!\n");
2 i/ N X7 ?+ i}
7 g* O! c2 B" Z/ ]4 g( f; J4 \: B, g. R1 M
module_init(led_platform_init);
# g) q+ C' n' Z, H4 vmodule_exit(led_platform_exit);, I4 F. ?/ d2 S' m* b8 T/ U
# T$ R# N8 [3 IMODULE_DESCRIPTION("Led platform driver");
; K% R) I" U( d- l' GMODULE_AUTHOR("Tronlong");3 ?: }/ w4 q8 g" F- w: `: M
MODULE_LICENSE("GPL");
4 w/ e3 _% o% r) \
" w, X1 w. ~: m) `' Y, [* t: K6 P0 T' F7 N |
|