|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
% L" V( A6 C1 `$ S#include <linux/init.h>
- `" E% E3 B& @$ K. B#include <linux/module.h>
0 m q& C( s. k& Z) j0 o. L#include <linux/kernel.h>
/ E9 [/ M+ H" C6 \. Q$ L" |#include <linux/types.h>9 I( B: `& @7 Y L) k! G- u
#include <linux/gpio.h>: I' \/ K- S* M
#include <linux/leds.h>9 `) I, o! }1 i8 e/ L
#include <linux/platform_device.h>
4 M3 ^4 ?) ?8 c. p0 H: Q1 A) Q
0 a4 `, t4 W# s! b( B' a#include <asm/mach-types.h>
: P9 Y, J, ^- I5 ?. i b4 L#include <asm/mach/arch.h>4 P4 b( X1 t6 W2 r, t- c( l" g
#include <mach/da8xx.h>6 D9 I3 a. m( [
#include <mach/mux.h>
( o0 {4 K1 ?2 h# H
{/ {+ Q8 X8 j, ?! Y9 \#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)$ n3 K9 y) \7 v3 @) ?' @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
9 p& _; e, Z! R/ Y& ?' Z) h#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 D* M( |6 {7 g" y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& J) b: X+ H+ A" c7 `
_' f& M. c9 y( r4 Y/* assign the tl som board LED-GPIOs*/& ?. c) Z" {4 Y$ L- g; g
static const short da850_evm_tl_user_led_pins[] = {
9 V& Z% i, o5 x* o+ |0 t /* These pins are definition at <mach/mux.h> file */0 ]% R+ B2 u6 v* _. j7 I' X) L7 E5 E% ^
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,# u) z/ t$ }' B, N
-11 g" X' Q4 o% X6 r
};) ^- B1 _; l+ e
& I" Q U$ W& r, I- S
static struct gpio_led da850_evm_tl_leds[] = {
. U! S* ], R8 h6 ~ {
: @# M# J! n$ Q4 A& s .active_low = 0,6 J1 z6 f1 e- a/ f& ~0 W
.gpio = DA850_USER_LED0,
% x4 O; k3 Y/ S1 I' D( ` .name = "user_led0", o. f' f0 S$ ^2 _, N. K, d
.default_trigger = "default-on",# t0 t( P0 x0 E2 a3 f
},
6 W' ^( R! X/ o+ v3 Q4 K {
; k" e7 f; A: o6 k9 K. [: [- ~ .active_low = 0,
, h$ _, d! Y" }+ B0 | .gpio = DA850_USER_LED1,3 }; ]0 ]9 z0 D
.name = "user_led1",
9 I9 Z; v0 v& s0 ^+ H .default_trigger = "default-on",. z7 W: c9 s3 E5 W$ E9 a" Y
},3 |6 B& h& }% K5 X, s& j, T
{8 j3 K, \# m) F, M5 f$ o9 T
.active_low = 0, x* t1 k k$ Z) |1 |6 a! f
.gpio = DA850_USER_LED2,: Y' i$ c/ h% T9 W: }
.name = "user_led2",
8 C5 Q. @- [* F. l% _( y .default_trigger = "default-on",& j( V3 B" q( Q
},
( I5 M, u- j: u v7 _1 K: { {
* D7 A" J. s1 x( ]3 v; [ .active_low = 0,: z3 V8 F' ^5 W# V/ g7 t1 h
.gpio = DA850_USER_LED3,
$ l: X; K4 k4 O' O: ^, ? .name = "user_led3",
( B! K, ]+ w% {0 J$ a( H7 ^- H. A .default_trigger = "default-on",9 T# ~' t( [. Q: `# M) Q7 N' t
},& g3 C" o4 N$ F' A7 r
};
( `' \" z2 n% }& `4 A& |1 _
8 N) N/ ^0 p# d- [, C8 Pstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {( U* v2 }. x( k I1 s- E
.leds = da850_evm_tl_leds,
/ Z9 [' _) z s* `& D6 o. Y .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ u+ N+ W0 ^% |4 s" D. k0 \) D# {8 \
};2 F4 a2 J7 k4 Q. r) j6 Z$ l/ ?9 p0 E
: L- {2 I7 k5 I* n, W3 K
static void led_dev_release(struct device *dev)
; N7 }! W9 ]* t* S' J3 |' d# Y+ H{
; W2 E3 C" I+ d/ M};* z2 I+ ?1 g' I! @
, `& @5 y$ o" Cstatic struct platform_device da850_evm_tl_leds_device = {
8 f5 D+ G2 t0 Y, V+ R+ p) S .name = "leds-gpio",% T0 t/ e# \9 {# m. r8 K
.id = 1,
/ j$ Z2 e! k) O! H .dev = {6 E t/ f- k: D4 O9 P6 U3 B; ]
.platform_data = &da850_evm_tl_leds_pdata,
4 p- y3 _0 _# H5 C( X. l .release = led_dev_release,8 v; Z1 ^* B( \. P/ z, S7 P
}0 k' V5 z! U; e! I, f, C
};
% Y) |% ]. c' V( n0 {1 T9 t1 A# t2 m% w. v5 _# ?0 z
static int __init led_platform_init(void)5 c4 J1 _: K# S, }7 v" x$ S( q
{/ w% i8 F( x: p6 L$ b
int ret;1 v2 o! W6 ]7 u
#if 0( C5 _" s5 G* r) k* |
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* o0 y. c! ?7 C2 u* t& p8 M3 v9 F if (ret)
. E) f+ U% B) M2 M& H' m: A pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ `) r; Y" w/ D- E9 d, \) Y "%d\n", ret);- F) u2 ?5 s/ u% C+ M
#endif
+ @1 N7 U) W4 S2 i# G ret = platform_device_register(&da850_evm_tl_leds_device);! I. u1 m: M! h# z7 r3 y0 @4 p0 w
if (ret)
1 b3 E' z0 Q8 r' Z pr_warning("Could not register som GPIO expander LEDS");
7 ?/ l+ ^4 j6 y- h else
9 _7 Y/ s$ w8 P; X5 L printk(KERN_INFO "LED register sucessful!\n");
3 a# s& q$ a6 J' B/ }/ ~: w0 h$ I/ U! X2 n" X5 ]2 _
return ret;9 X( ?+ W- A/ w& \1 S ]7 _
}
/ O# V3 T& |- C# X1 [6 Q1 g
5 |2 g* g2 H6 Lstatic void __exit led_platform_exit(void)
' _# C- i p5 X8 M7 g8 H{
) e$ V. v' J) w/ \ platform_device_unregister(&da850_evm_tl_leds_device);
( r" ?+ P$ |$ Z. b/ z
: i' T5 {# [) N5 A7 i printk(KERN_INFO "LED unregister!\n");
9 P0 U1 M5 @2 N& |# F}# u: @' H3 ?: t9 s7 E9 F
. |7 r* q% U! w
module_init(led_platform_init);; ]. {) p$ n0 D* c9 j/ y
module_exit(led_platform_exit);
$ j5 H, M8 F0 N1 Q! z) a1 _0 l' D! O o( }; c
MODULE_DESCRIPTION("Led platform driver");
+ b6 S5 V2 } UMODULE_AUTHOR("Tronlong");
4 i0 `0 O' w; fMODULE_LICENSE("GPL");
: n% l f, b* T% F* w
7 V- d8 ?1 P* v: O$ b; b |
|