|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
3 J# ?) s* e% I, [% V& y#include <linux/init.h>
- O( e# D0 X* Y8 Q7 I; d#include <linux/module.h>( Z8 z/ a( S4 T+ e$ j: l
#include <linux/kernel.h>4 }2 e6 H: o1 l2 S O% h( p
#include <linux/types.h>
8 }0 [! z* }7 B [#include <linux/gpio.h>( x; Y! E1 p2 ~& H5 `' I8 W
#include <linux/leds.h>
0 c$ ?! ]5 t, o' s#include <linux/platform_device.h>
9 \6 Q) o. Z# t+ g: h3 z& e/ Y# z0 \; l. I5 r( J& Q( N
#include <asm/mach-types.h>
1 D) y# O T2 k8 K# l1 t#include <asm/mach/arch.h>
" B( X7 l: I# i#include <mach/da8xx.h>
0 p/ W% _8 G% u( Z6 f) q. p7 X, S#include <mach/mux.h>
% l9 x, M1 N* A
# c7 o. K- x8 _ h1 }#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 g& R' s; r2 c2 Q$ w1 z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 D& d. v$ O2 y" M#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# l( k( Y, N( Q: ]+ s" J
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). c9 u8 E. M! w5 h$ f' H
+ l& C* q7 `3 ^: g/* assign the tl som board LED-GPIOs*/
/ y# c$ n% _5 u8 ]6 Q4 Cstatic const short da850_evm_tl_user_led_pins[] = {
# I4 ^9 o+ J( o- u+ g: } /* These pins are definition at <mach/mux.h> file */
- F) e# i8 r$ f DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,+ c' M- i4 c0 D) a9 ~( W' u' s
-1
0 G6 z% g: a0 p8 e% r" h};4 I/ H2 @! |# f. E; Y8 _; c9 w) m _
b- C+ v$ q% S. a
static struct gpio_led da850_evm_tl_leds[] = {) ~( ?- p( y& t7 N; m3 X
{
8 H O4 b" N/ Z# Z u4 l2 [' | .active_low = 0,2 M' R# ^7 L; l7 J# l
.gpio = DA850_USER_LED0,, q- T5 _$ H8 H+ p8 z3 h D8 W
.name = "user_led0",1 D/ h' @) S6 e5 ^/ W7 C
.default_trigger = "default-on",& W3 |: c, X J8 `
},
( g7 q$ R( v6 q$ h/ ` {0 ?8 B9 p) g7 `# d# f* N
.active_low = 0,
5 y6 N& K4 L0 ~+ x" w4 l0 X$ C .gpio = DA850_USER_LED1,
1 j1 G. H+ y# [8 @, Z .name = "user_led1",& z) P+ l; U0 l3 O' P) B) |
.default_trigger = "default-on",
* ^2 I/ H5 D! u4 c! w5 T. u4 A }," I& E9 g& R1 B# w. R( [1 g
{' R# D9 q1 V7 ^
.active_low = 0,0 |" G+ }* h* R; w- C$ b
.gpio = DA850_USER_LED2,0 d! J. A: \, ^) R/ ^
.name = "user_led2",- w. w8 X9 ~* I' ?
.default_trigger = "default-on",9 E" e2 }/ ^% e+ T. f
},
; ^+ T c, `; { g: f8 J. Y {
2 H0 N# h" g+ l .active_low = 0,
) \' b4 E5 T1 K- I" h6 Z .gpio = DA850_USER_LED3,
5 N5 }) B% Q9 ^: h .name = "user_led3",7 `7 `3 h0 e% T9 |+ l3 d
.default_trigger = "default-on",! k( x. l! D+ j4 z( B+ ^
},
* Q+ o( G Z' \" x& l1 R};
: L2 h0 O* ~5 ]: _. B8 ~) n+ x. ^; R/ K( K# [
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' R( N$ r6 a/ \" v& g/ R# ? .leds = da850_evm_tl_leds,
' D2 o" g5 Y5 S$ y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# A: M9 _" N4 m( h9 Y};
% n. v1 ]. h: z/ l$ P% J1 `- m
( O# l0 G1 G, \# q. Z$ rstatic void led_dev_release(struct device *dev)6 P L9 i: o& S% n4 w7 Z% e+ v2 L
{- N: o+ @) E0 r9 Y$ o' g8 a
};( ^% F5 f" f. X
0 b9 y: D/ B4 a. [# t9 C9 P
static struct platform_device da850_evm_tl_leds_device = {
1 g& ~2 P: f2 U% S/ N# j4 q0 | .name = "leds-gpio",/ u {! t8 c0 r% i8 e6 Z. f2 ]
.id = 1,/ N, R4 ?: ]6 T3 g f$ o
.dev = {
4 N2 i6 Y; d4 o1 s/ z5 @/ t9 S .platform_data = &da850_evm_tl_leds_pdata,) e/ r- O/ I2 P/ c# V$ T9 ]. f& q7 o
.release = led_dev_release,* _) R( q* U- x- f
}+ r! z ^/ F( t) `) E/ Y
};2 @2 b5 p- `$ g% v* u6 Z Z
& B5 n# q9 y" J% W" q7 i! z# w
static int __init led_platform_init(void)
9 c& F# \6 Q3 R. S) L( s{
4 l: z( C) [1 _* x7 L7 B" ] int ret;& u/ q" s2 y. y
#if 00 s. L; _) j: _
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& Q2 `" \6 e/ a. k if (ret)# w; Q( s% T1 c/ [: \
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ c! {: v+ O, Z- m! Y' }
"%d\n", ret);
+ u& P; b& e! r#endif; ^! j" q ^' [# ^+ N5 V& ?
ret = platform_device_register(&da850_evm_tl_leds_device);
0 f/ _& {. ^3 l+ p if (ret)
8 o0 Y. [& @) [3 k" o7 t2 | pr_warning("Could not register som GPIO expander LEDS");
* ]$ X- z+ J! x4 o! e( T else
- Q+ s* I d( D printk(KERN_INFO "LED register sucessful!\n");
, Q% g) M2 i8 s, d$ z, B( q% _/ a9 V$ |, N9 i/ W, @. v$ D% o5 I* Q* x
return ret;" k* a' R9 j n3 e/ M
}
& d, @. h/ [' C( R
( \" q$ s* p+ lstatic void __exit led_platform_exit(void). q: e# K# \# u6 _% [; Z$ \* R
{
3 I" H7 T$ G7 V platform_device_unregister(&da850_evm_tl_leds_device);
' H: T' s+ M! _
- c* B9 p5 Y$ y4 l printk(KERN_INFO "LED unregister!\n");2 [4 V# [: O* a( E1 A
}
8 f, I1 W+ V M1 J! e2 i; L0 x
+ `% ?+ ^# ^- p# _! b ?# P5 Kmodule_init(led_platform_init);
, Z3 |- S$ f J- G" |5 e5 ~module_exit(led_platform_exit);) x6 \ E; \' i u- a
% `6 _& l: a% x/ M4 wMODULE_DESCRIPTION("Led platform driver");
+ H0 j0 Y" q# o# KMODULE_AUTHOR("Tronlong");
7 s* g; N3 C) A6 GMODULE_LICENSE("GPL");
+ \4 J' g: E9 W2 O& A. i5 _: ~- a# m1 s9 \) B
|
|