|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# u' A' ~" o: ?+ p) s; B
#include <linux/init.h># y3 w5 J K) }
#include <linux/module.h>& x8 _/ H) ?1 }( G5 t- v9 T
#include <linux/kernel.h>6 a. [+ j7 ]8 O3 j) S: j& i
#include <linux/types.h>
3 f, j3 \( w6 m/ p7 d#include <linux/gpio.h>+ p. k" k: r( x% k* i" y% t
#include <linux/leds.h>
8 }2 J$ I9 P1 ?( R' p' U#include <linux/platform_device.h>
0 v+ L9 n7 X& B5 M$ W1 _5 w1 H1 b/ a. V, U# f L, v- |
#include <asm/mach-types.h>
% \6 r! [7 }5 u! E. M8 i* l5 S; y#include <asm/mach/arch.h>- z2 `7 k8 N! }3 \) Z6 p
#include <mach/da8xx.h>$ M1 B1 `: c, k V
#include <mach/mux.h>
# |" U/ c5 ], U# J; Y6 {" V6 L3 q
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 d# e- z/ ` E; a( A#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)1 i5 H S+ g4 Q/ [ L4 Q4 X9 C
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)4 t k( e( {- o& H5 ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). e9 f- Y) ?8 x$ T& P
1 l( W/ _. R8 I) @6 E, I9 @2 O. f
/* assign the tl som board LED-GPIOs*/
P! H+ L9 u3 y* V/ X* H3 wstatic const short da850_evm_tl_user_led_pins[] = {
1 H, E+ B2 ~, @ c- k7 r /* These pins are definition at <mach/mux.h> file */
' U! S, J$ l# h5 i. M& e$ R: k DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 R! g) {$ G4 h9 }7 \5 C -1
6 c! P# n: X1 a8 o4 B4 f9 ?}; j) T' R) S+ v! }* T% i+ T8 i
; k- ]. ^) b3 F- |" a
static struct gpio_led da850_evm_tl_leds[] = {& C4 [# G$ @" i! D! A- M
{
( b4 B! s' G- {" }/ D! z. y. l5 M .active_low = 0,* m; h' e4 B5 G% a5 C( Q
.gpio = DA850_USER_LED0,/ Z# V4 @$ w' G& R5 d
.name = "user_led0",4 C, ~# R6 }& I L% ]' d- H$ z
.default_trigger = "default-on",
7 a1 R+ J; ?: o! H },
$ m9 ~0 Y, D% |; G- v8 x% S: f3 _1 i( F { v% ]3 z: c% v+ \/ G
.active_low = 0,! p; S- x9 p" P1 x: t$ h# m
.gpio = DA850_USER_LED1,
, S# ]% M b1 c4 [% o, v0 w# \ .name = "user_led1",- N7 O! m3 z' z( t# j G: W
.default_trigger = "default-on",4 h; G( J) ~! t. O# p
},
" t4 b9 {, d3 R {$ m& h' i- P' R* m
.active_low = 0,; X o7 ?" Z: u* a
.gpio = DA850_USER_LED2," c# L% J* b( i
.name = "user_led2",# y8 ~) |9 D0 |& R; ~
.default_trigger = "default-on",% Q- l+ l4 w8 |
},8 }7 @0 ]; D- n( E
{9 I# \+ s. y1 A) [, ]
.active_low = 0,) F% n. d& N/ ?. u' k1 }3 ?
.gpio = DA850_USER_LED3,( z! ~7 o, V9 U. x4 r& l2 f' l; ~
.name = "user_led3",( E) i) |3 d- H6 G$ z1 P
.default_trigger = "default-on",2 S* P# V4 W! E7 }2 w0 ~! E
},' O) `) Z5 V y& y% v
};
1 Y# X. }8 w* ^; d. P& v9 w
" u% u; b- N) U% k! B' H2 Y4 E1 r4 i( \static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
# K T0 s6 w) ^# u. E. a .leds = da850_evm_tl_leds,& |$ f# e4 l4 B: {; G" q: `
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) w" C" J! S. Q0 |( w* V};
7 V) P+ T0 p# V3 A( y- _* m0 h4 X% `0 M+ ]2 L2 s/ x! v
static void led_dev_release(struct device *dev)
$ T s( I4 p. v3 [* q, {{
, I8 M [" x" C6 M};
% u7 o8 @; P( X7 {; f2 w/ a
! c A6 m6 \" ^! C. ostatic struct platform_device da850_evm_tl_leds_device = {
9 q$ l5 V! `7 [+ x6 p- q .name = "leds-gpio",2 c9 g5 F) [" }
.id = 1,- N* [6 Q U$ q; u
.dev = {1 {( L P; m' R* x
.platform_data = &da850_evm_tl_leds_pdata,: h+ D2 i) X; w/ G+ I3 N
.release = led_dev_release,. X( X; @* [& |
}# O* W6 B7 E4 \; ~- F* |
};
7 J; V5 K. {% {" M5 {1 o# D6 I q3 S0 u u
static int __init led_platform_init(void)# N& N& z6 O; j' G# s
{( g- O6 \- R" s) A
int ret;
4 g8 y: x5 I$ J#if 06 [4 I S* \% I
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
- d) Q5 g& t8 k' m$ m if (ret)0 c" t) S/ X$ e% g
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ G9 }& y! T3 ^
"%d\n", ret);7 _- u. q n" ^# E
#endif, q/ s Q8 W6 V
ret = platform_device_register(&da850_evm_tl_leds_device);
O% l' ]- X) [( w O4 E if (ret)
3 A9 O1 G( O& S( Z pr_warning("Could not register som GPIO expander LEDS");. N2 f# R. e# ~% R
else
. c+ z+ U6 s3 L: V. k printk(KERN_INFO "LED register sucessful!\n");
) m' {) V, R4 J5 {) g( J. C9 a X3 S* j
return ret;
8 m/ J- F& n5 T! G8 S' a}0 V! F1 f' r' s6 [" m0 u, A
! [6 ?8 ?& w" K1 \7 X9 h( Bstatic void __exit led_platform_exit(void)9 N8 R3 q( O/ O1 X
{) z4 A* s! l9 N, @) J; @( [
platform_device_unregister(&da850_evm_tl_leds_device);) C1 u' D! B6 X& o1 {# d
. H5 N: T7 F s7 ]( y printk(KERN_INFO "LED unregister!\n");
4 ~' `# c7 |7 |% y7 G. @ g f. u}
% t1 n2 X' i$ f8 \( G
* h8 C1 m% x7 ^# p3 z( ?& b$ Fmodule_init(led_platform_init);
* G4 x: \3 g3 t. q0 |' zmodule_exit(led_platform_exit);5 ]# G |" f) z, p, W+ q
$ q b; B' R* h/ f B: D% ?3 xMODULE_DESCRIPTION("Led platform driver");9 G* g+ o4 _4 d$ j$ v+ R0 _
MODULE_AUTHOR("Tronlong");$ {$ G7 U4 `- i* @- l; V6 z
MODULE_LICENSE("GPL");
. m9 Y) J8 v) @. W# M
3 h! R5 m7 d# Y( y0 ] |
|