|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
`! i: h, ~; s/ I2 D* b#include <linux/init.h>
; ^- w5 T8 i: H$ p1 p3 L. o! j#include <linux/module.h>
" F7 a# m9 j5 {#include <linux/kernel.h>
% o* G! C; C8 n1 T9 [#include <linux/types.h>
% |; _4 U7 R- X+ v$ f& `3 |#include <linux/gpio.h>3 q' [) y: S/ ?/ Y# X( d4 r! u
#include <linux/leds.h>5 X* ?) z: Z2 x2 K/ x g/ C
#include <linux/platform_device.h>
& z3 F$ Q5 f, b3 s* F0 X4 ^- ?* X1 S& V) \% H6 n
#include <asm/mach-types.h>
& B. z3 R9 [. F- V. k+ m#include <asm/mach/arch.h>2 u& G# K$ O% I% c
#include <mach/da8xx.h>6 Z0 ^, u3 U8 r) y! u# O' m3 c
#include <mach/mux.h>+ E6 O( j4 H& {
1 N! p8 N7 b2 D/ N8 w. o
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
+ U7 Y. x8 ?5 r! I& _$ I) v- v: ?, H4 ?#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)7 X$ G; n G! w% i
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( T) g1 N, d# N2 U. l
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 N0 h3 L3 J3 n- n2 M* R w7 F
8 e% r7 u) @0 ~, M' W8 M7 V/* assign the tl som board LED-GPIOs*/
5 r8 g* \9 G' {; ^static const short da850_evm_tl_user_led_pins[] = {
1 m v5 h" F- H x3 w /* These pins are definition at <mach/mux.h> file */) ?! W: i5 s6 [
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 u% [* s. |* k4 Y -1! l, q, ]5 R; k/ ^) H! G
};" `0 K$ ?5 e3 j- X% S
) j; F6 v1 q4 @. K2 {$ o- b! X
static struct gpio_led da850_evm_tl_leds[] = {
- c/ I: e* |( h: n% F& X7 ~7 H {: @* f" I4 O! ?/ c- h7 b
.active_low = 0,+ I- g- w4 m; R7 R' H& }
.gpio = DA850_USER_LED0,7 l# Q! Q( k8 r( P: y) O
.name = "user_led0",5 M3 |5 B; f2 C1 Z
.default_trigger = "default-on",
, m( }1 M, h0 a# U7 u. K+ @ },6 W, O. ]9 _ O: M1 B* L
{7 p/ C& H' {( a( r2 m/ r
.active_low = 0,& i; c& u: _/ v/ E+ ^
.gpio = DA850_USER_LED1,* X( Z7 M: q4 ]
.name = "user_led1",; f3 d2 b/ R/ q" u! G& F, Q6 G
.default_trigger = "default-on",* K7 Z' U& Z# W+ ]
},- a$ K- d" v C
{
8 R5 i' Y! W5 ~8 I- K4 o .active_low = 0,
% Q5 A0 N1 _' E' E& n# C, P .gpio = DA850_USER_LED2,
8 d! c5 A, Q$ i, J5 e .name = "user_led2",
1 d/ ]& S% Q' p$ y+ @; I0 b .default_trigger = "default-on",
+ b7 M# p0 Q2 c },
7 E1 K1 q* L \- M' l {# F8 O/ s1 a5 L0 I! }
.active_low = 0,
, H9 K2 F/ ^# f$ o .gpio = DA850_USER_LED3,
/ k$ T- o. S+ G9 S; M( e3 k .name = "user_led3",
3 P4 C4 P M9 Y8 M. M .default_trigger = "default-on",! P6 t5 X: w, h, E
},* t' R/ k, W" q4 P0 R, W# m$ _
};
2 U0 \% e- E: W2 g3 I& n, |! ?! \! ~ p" E& C
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
j0 |+ `$ c3 d8 ]/ K/ B .leds = da850_evm_tl_leds,* t; {8 b; n5 a, `& B* j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),! i- s2 {) M( s; j; h0 ?* _
};6 l' c; t6 v: M$ w6 f a! V
4 V1 V+ J( S% \: Q+ i2 O
static void led_dev_release(struct device *dev)
5 e" u- E' A8 v8 j; X1 l; O2 f{+ Y$ E3 |6 I6 P* j* D
};4 E( `# f/ s* k* b' W6 B. j0 E. S
3 G7 R% I2 c( ^# V7 C& Q( Jstatic struct platform_device da850_evm_tl_leds_device = {
7 d @- O- |. c, l .name = "leds-gpio",
1 o, R. Z) P5 A, h. g; @1 x1 S .id = 1,7 q% x# o. c5 e/ m. c% t4 J6 T
.dev = {/ a0 I# S3 ?! P! U) x2 _
.platform_data = &da850_evm_tl_leds_pdata,
6 M) G5 ]# n, l* H, f+ G .release = led_dev_release,
& s$ P) t) B I9 T: L% `1 A' \ }
+ x) h- I" P4 j4 }6 b: y0 P};
9 J! D. q; W3 X5 _% }( {( e+ A' X7 e8 a! C& u
static int __init led_platform_init(void). G) {7 l+ |# m/ W; [! w6 U9 b
{" K8 K. x7 v3 K2 \
int ret;
& U4 r. D( H# G# V8 X#if 0
& C0 b; v v' ^- A Q ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 q$ e% t7 h0 S4 j1 ] if (ret)
/ g- E7 S% J* N% H: M6 Y pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" V5 l% K# D }# C "%d\n", ret);
9 G/ P% r4 ]* M: C#endif
: i8 `6 d1 } Y8 O ~* D ret = platform_device_register(&da850_evm_tl_leds_device);
6 D1 m2 c" e6 ` if (ret)
, _5 |2 }7 X8 x* ?7 V pr_warning("Could not register som GPIO expander LEDS");/ }4 m; q K; g+ c
else7 [( g$ x# G: p- k
printk(KERN_INFO "LED register sucessful!\n");
8 L; Y+ C, J# c7 S, S2 s/ I& W0 n" t2 R' H) v
return ret;
7 c: r; p8 B2 F- G* b# Q: L}
: o# k6 x Z* f& s- B% h6 m$ \! V( e
2 I+ Y+ p# v v9 vstatic void __exit led_platform_exit(void)
" {& F& A8 T: R4 K' n{
- t' K: @" F9 A" s. R! t platform_device_unregister(&da850_evm_tl_leds_device);
9 \2 ]8 \ U3 s0 A! [) g3 B. e+ I9 q# ?" i' ?
printk(KERN_INFO "LED unregister!\n");& G3 H+ i2 R% P {3 q+ p U. R
}
, i$ R( S- _' D% ^/ ~
+ {3 d& F' a7 X1 Ymodule_init(led_platform_init);3 }! n% q0 {& {+ p& ]- L. [6 ~8 E
module_exit(led_platform_exit);
, K8 c4 E+ O- b
1 Y" h4 S1 h, n* \. yMODULE_DESCRIPTION("Led platform driver");- r. E3 a5 D* o* \
MODULE_AUTHOR("Tronlong");
% ?* d8 d' \: U# q) }' wMODULE_LICENSE("GPL");+ f9 u$ \8 u! J3 s6 t* a; j3 v
* S( p) s& Z% M2 {( Y/ z
|
|