|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. B- ?& {3 e! _$ k$ j#include <linux/init.h>
) c+ ? s/ L& o; ^% U5 x- A#include <linux/module.h>
! ~$ u0 t7 k$ h$ _* I#include <linux/kernel.h>
, n" K- Y# W7 v$ o% m#include <linux/types.h>
# x/ b! @* Y. g. x. ?$ [$ m$ B#include <linux/gpio.h>
" r8 `% Y- B6 h% k: H#include <linux/leds.h>3 ]/ X! K ]1 |4 j! O( ^9 w
#include <linux/platform_device.h>
+ I# n* m7 ~4 x. V
4 b/ E, O. j% f#include <asm/mach-types.h>
; B, d% Y& D9 Q# X0 N#include <asm/mach/arch.h> i n }2 }$ F
#include <mach/da8xx.h>
& S- x) ^0 V7 u" Y2 e+ h' h#include <mach/mux.h>
' V7 J; `/ ?* {' c9 |( _6 E* D1 O4 l" Q% Y9 Y5 S* V; Q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) D; o) { g' X7 O; l+ G9 e; S
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 E7 C0 @: Q! m W# m1 T#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 l \& o9 ^8 G8 k& U# f( T#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! y3 n7 k& X3 i7 G
( W9 Y# X# C" I* S5 l0 M+ R! Z/* assign the tl som board LED-GPIOs*/ o4 e6 i+ |' Q& @' U! w0 T& L
static const short da850_evm_tl_user_led_pins[] = {
: y8 i# R1 C% j6 S% [2 T; v /* These pins are definition at <mach/mux.h> file */
* \3 n& q8 _/ Z3 K) ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 Q# B8 o. x4 q4 x
-1
4 ?$ P- F- L5 }: z% c; }. m9 q};, ^5 s5 i, O4 N
7 d& V3 h- _, A2 U5 L
static struct gpio_led da850_evm_tl_leds[] = {
# F: u/ A1 ^. G' ~! Q: V {; a& C% \1 ?6 a4 S
.active_low = 0,5 l4 V U' h% i- M0 T! V) c) g
.gpio = DA850_USER_LED0,
1 E, d) ?+ U# ?* r4 c4 _ .name = "user_led0"," s& F1 u( g& ^& J: p# @
.default_trigger = "default-on",# w- n" C/ [9 |" h. c: K& S' j5 Y
},
5 K) F7 _ G' w) [3 _8 p {! \! H; k$ z' U3 {+ l* N
.active_low = 0,4 w- |1 O- W' G, l3 R3 J
.gpio = DA850_USER_LED1,
1 }) F) B H! U* J .name = "user_led1"," M; e/ _* b- @
.default_trigger = "default-on",2 H& B' D. t; p0 u) }0 j% a2 T" ~# X
},- j* ~/ a$ P1 R n8 e m: r
{2 f1 n% B7 x2 W7 a6 [; a) m% h! n
.active_low = 0,' o) L& B9 p. ~+ \- c# G
.gpio = DA850_USER_LED2,0 [; Y h9 J6 {! Q! s0 G
.name = "user_led2",2 B" P4 U C& d% x$ s0 \, h
.default_trigger = "default-on",$ _7 `/ d. J0 m% i8 K* e6 L3 Y# B+ i
},! X- `2 u) r% s0 T" i
{, x+ N# i ?4 E7 h/ W2 W% M3 d* P
.active_low = 0,* i& W. L h, ~* _& k, \
.gpio = DA850_USER_LED3,2 ]: \ r) J. `* g, r% n
.name = "user_led3",4 |5 O( Z* {9 S4 i7 }/ j; Z1 h
.default_trigger = "default-on",
3 F' u. ~/ E$ a" Y' E7 ] },
5 s2 p" M; `2 ]5 i5 U% f, N};; E8 l6 H& u' S8 h8 @
$ Q% P f7 D; Q3 `* Ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {7 l! J& ~0 q5 t4 y# c
.leds = da850_evm_tl_leds,
' r$ f" r* ^2 N .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" ]8 Q( }. h$ R# w};( ]! r! v9 l/ `. u3 M+ V
! M. i+ T5 B' h5 T+ i; s+ rstatic void led_dev_release(struct device *dev)
, M3 g* `: v: H3 z{
' f) s1 L- K1 F};
: |5 F0 ?; @! H
; s% B7 m, s: h0 Zstatic struct platform_device da850_evm_tl_leds_device = {! k1 P+ V& ?1 L7 o7 V
.name = "leds-gpio",
- s0 {) A# R, V( Z. T8 o6 z. Y .id = 1,
' H- J& J0 Y: V& b# A .dev = {
) v4 W& p2 l7 V( C. e- { .platform_data = &da850_evm_tl_leds_pdata,8 y9 T" ?5 c! y4 F1 Y% R: u
.release = led_dev_release,4 X8 K0 R# {- H4 l8 P4 r/ G
}
. u7 R* C/ q5 B1 h5 k9 ]};7 V' l' @: c" J) G" L! y0 Z4 D
7 |( M7 n5 P- |7 ~0 }: s! [static int __init led_platform_init(void)
' [3 I- \0 X* A! x) O8 Q2 J{6 w+ g: t7 U5 H& O& |
int ret;
3 b C: }' U$ P* X8 q#if 0
4 f! f U+ O% C' N0 x/ s6 F( C5 Q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 U1 r& B6 P5 h; y! I' L2 J# n
if (ret)
3 D( C) e# X% U# A- a- n7 C pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 k& O/ M+ y! m
"%d\n", ret);
' e) N" B9 T# s( _* c' b#endif
( R P6 `: x6 }, k% T8 G ret = platform_device_register(&da850_evm_tl_leds_device);( K$ l" P1 y% o- ^0 ?3 [' n
if (ret)
; G9 m- `( v; z3 T5 Y! _6 c pr_warning("Could not register som GPIO expander LEDS"); o7 u8 _" V/ G m# w0 d5 c6 k
else+ U' o7 ]: R/ e: C1 g
printk(KERN_INFO "LED register sucessful!\n");
* o& k: D+ u* c+ a4 _# ]' k3 x; l( q0 j& F) Q$ x
return ret;6 t$ o Y* {. J R T6 _9 k0 T- |0 t
}
1 A0 D5 U( f3 j0 K9 S v1 t5 l3 s; P1 \9 }$ Z: q8 l4 c
static void __exit led_platform_exit(void)
0 i6 I6 u6 k9 R0 U{
$ x- B$ @: |4 @$ A0 s% n! m! j- U platform_device_unregister(&da850_evm_tl_leds_device);% s( q) i1 H- h3 ~
) d; `3 ^; e8 J+ ]
printk(KERN_INFO "LED unregister!\n");) h& M1 H5 n* S8 M3 d
}% a0 j, p2 N1 j% s7 v% W2 V
1 e3 P. T) w7 g; G% r
module_init(led_platform_init);
2 @* D" E. }" Rmodule_exit(led_platform_exit);9 `+ p z, ~! E: Y$ {
; O: n% K* d" S ^+ ?4 c, C7 ^* KMODULE_DESCRIPTION("Led platform driver");6 b( \$ p4 t. \! c: ~/ x
MODULE_AUTHOR("Tronlong");, F, t4 S, c2 ^7 f* ^
MODULE_LICENSE("GPL");
' s: |( l! U: N1 z! r/ t9 }5 }# R: v) u& t5 x$ I
|
|