|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* G k8 _5 s! _) ^- G
#include <linux/init.h>
4 W* f. Y9 S9 t: v+ R. _# g7 Q% `#include <linux/module.h>
0 M. k; m$ h Z5 ~#include <linux/kernel.h>* F* \1 A. A: ?. B5 K" W% y5 t
#include <linux/types.h>
: p1 ]2 `; a$ k# ?5 ^#include <linux/gpio.h>
3 k! x0 \" |# b8 M* i# L#include <linux/leds.h>
' i& l1 c. o) f) y#include <linux/platform_device.h>4 S+ O8 y N7 S' [* n, a( J
6 s# U4 S9 P) G7 U
#include <asm/mach-types.h>: x2 p/ P) Z+ }, S/ ~1 M+ P7 L; n
#include <asm/mach/arch.h>
# n% m. @. H; j, |$ _#include <mach/da8xx.h>
+ D0 Q+ Q/ A# H: q#include <mach/mux.h>. ]2 W( A( e5 W) ^; p, c2 R
. g9 H" Z, k7 O4 `7 l#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
' ^2 E. D" G, X9 p#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) m8 v! u6 O: H
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ U: ^! V* O9 H* G: i* v
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
* p7 Q- L) X4 N: m/ R6 h8 o8 I4 `) f8 _3 i( Y
/* assign the tl som board LED-GPIOs*/
! ~- U7 h1 V/ V# n, Q3 n, m6 bstatic const short da850_evm_tl_user_led_pins[] = {- p! z% \5 r4 b
/* These pins are definition at <mach/mux.h> file */
. C% w$ }" v" b4 f6 H, l DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
8 n& [2 @" K6 t5 g* c% x! \/ f) M -1
, I0 h U( i- ]: f: K. S* T, L};
# {2 w) ^2 |8 n. q8 v
9 v$ W8 _+ f3 @# `; I) qstatic struct gpio_led da850_evm_tl_leds[] = {
7 [: a/ O# n/ S. D {
5 l$ I9 @# X" _# \" {. C" @ .active_low = 0,6 n" Z. O* E8 i" \+ V4 D
.gpio = DA850_USER_LED0,) d$ D' k8 s8 J6 j' T
.name = "user_led0",
6 ?2 B7 g/ M0 B) N3 n, \+ { .default_trigger = "default-on"," F- F% `! {' h" ]* o& X
},
' N! f+ w6 H4 D% m {
# _3 \. Z/ h3 ?( q- W' Z& F7 ? .active_low = 0,9 E6 o/ u' N4 f6 g; }4 E, G
.gpio = DA850_USER_LED1,, d( A. i# y! \$ f# ^# M4 X
.name = "user_led1",' @- y/ P; r/ H1 C! l4 t
.default_trigger = "default-on",
. Y V. o+ H# U9 j, L },: h/ f5 s7 C2 j, g! L+ `* X6 J
{# v; v" ^7 f3 o" ]2 P
.active_low = 0,
) U4 q- d5 S i6 S* | .gpio = DA850_USER_LED2,
7 G( a% t- P" @$ k8 S/ D .name = "user_led2",* M7 G: w: ?1 E4 x' Y0 Y" `
.default_trigger = "default-on",$ k; ?$ o& U9 S9 }; N
},/ B# F& o: a+ Q) T6 [. A% j
{
' v- l J" R8 f- ] .active_low = 0,; P& j4 ?, T8 _, e
.gpio = DA850_USER_LED3,
# j% r+ M1 y+ p+ V .name = "user_led3",/ W9 @, l" w0 }
.default_trigger = "default-on",
! @! |! Q3 t9 N* E },
4 r6 ]! }% a" x2 y$ X# z6 k( t};" X% ^4 U+ G0 d2 r
# R2 O" r/ J' i+ ?
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# Q# p4 f1 k" B( }% z5 { .leds = da850_evm_tl_leds,) a" ~5 H3 y0 F. u2 p. F4 T
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ K( ~+ f6 _* r( Y};0 o9 ?( a- g7 p: ^9 |
& n* @. g* d) m9 B8 ^( {+ B1 f8 R' N
static void led_dev_release(struct device *dev), D( D5 Y& a1 t' t* ~
{! v9 k9 N6 V! [0 K! m) `7 |
};
( c, O8 r6 j7 l; k. a% G8 g0 m: r! o% B9 _4 c6 W2 ^
static struct platform_device da850_evm_tl_leds_device = {% f) }/ Q- S' H, o3 @4 F# Z% u
.name = "leds-gpio",! D: ? a* i+ F% Y" F
.id = 1,% i5 [ I$ e# T$ p
.dev = {
- U8 U( U9 D5 n+ S% s$ B .platform_data = &da850_evm_tl_leds_pdata,$ O* R6 Z$ X, a. p( b
.release = led_dev_release,
4 `( h/ c; a9 X+ Y7 h* o }* X9 I7 @) v. b2 g1 w( @6 O
};# F) M& ^9 z" u# r: N# Q
, G! _: W7 A7 P5 ^" [1 L9 Kstatic int __init led_platform_init(void)6 V6 d( r9 M2 X: l0 S; ~
{
) z/ k9 S. @7 X# \ int ret;
$ U; E+ B; y& h#if 05 x' r5 T8 O+ c# y- }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
% q! q. {8 F" { if (ret)9 y% Y% \- x+ H
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" }) X' ~- M$ E
"%d\n", ret);9 n" P2 @, w& E$ }, v
#endif: r; g! f: |6 _& h, q# o! k8 k; P
ret = platform_device_register(&da850_evm_tl_leds_device);
; [) E' U( `7 ]! D if (ret)
6 `" F/ w7 X3 q- A pr_warning("Could not register som GPIO expander LEDS");
& l8 W8 a+ [; `( P& Y$ P else
, y* R3 ]# [" h printk(KERN_INFO "LED register sucessful!\n");
4 q1 Q, G r j+ S( q- T3 H8 K4 i6 W/ G( o6 a- X# A$ R( r8 N
return ret;& R2 j$ N( P6 t5 o2 X8 L
}
# `- L: {0 k+ H- E9 |8 @" ?+ c
7 t" g5 G! l4 ~/ F) t, m( c, Tstatic void __exit led_platform_exit(void)
" P( q1 ] Q, e( R; n& k$ E4 N{
# c) y6 Y" n! Y3 c9 w- R) J+ ^4 Z platform_device_unregister(&da850_evm_tl_leds_device);, v- N- s/ ~1 s& Y$ z
1 B0 R$ l5 I8 m4 Q* N printk(KERN_INFO "LED unregister!\n");& p( ?' J5 F7 _- a2 t- V" T/ d
}
3 M' v5 R2 H/ \) H5 N) B' X" D, f6 C1 u
module_init(led_platform_init);
( ?+ z; t; [* B* M0 {module_exit(led_platform_exit);9 |5 I4 I2 D# I6 _
; `0 u+ T* b5 x9 T. A/ b
MODULE_DESCRIPTION("Led platform driver");
$ w- T/ X9 t6 ~3 BMODULE_AUTHOR("Tronlong");; a# x& r" C6 q6 j* {+ V: G( Y
MODULE_LICENSE("GPL");/ w6 q* V+ [# b5 S4 t) ?. a6 q5 X# D
1 o Z+ n& ]8 L E9 P# K- M5 c
|
|