|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, w$ {; H* c& C4 Z4 C
#include <linux/init.h>
7 ~9 |# F7 d; I1 J$ o#include <linux/module.h>
9 [( H, S/ r3 ~ Q+ Z#include <linux/kernel.h>8 V& G( H0 @% n# Q4 x
#include <linux/types.h>
# h6 R' x& y* {) D6 Q7 i8 [#include <linux/gpio.h>
/ G7 J$ j- h: Z' F. o4 Z( r#include <linux/leds.h>) m) o/ F5 v+ z
#include <linux/platform_device.h>6 x7 Z/ n! L" f; c: O3 v" H
. d/ S- w" w+ |* \8 i% s( q
#include <asm/mach-types.h>
7 I6 ~; W7 b4 y+ Y# X& R$ i#include <asm/mach/arch.h> L7 l" R! C* F4 }+ j6 b1 W! [
#include <mach/da8xx.h>, f g& K0 N- A3 |# I" P1 @5 {) h( B
#include <mach/mux.h>( |+ ~& | e. q8 u8 a, F
; M1 C5 z! g" w! C#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% t1 b4 a% r* ], F9 R
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) q7 t; P* Q0 I, Z4 l1 Y& S& Z#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
+ z% [* [: N& a0 o+ r6 |0 x#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( E, N6 Z5 Z" q$ u" s N& r# n) Z6 ~0 h" g
/* assign the tl som board LED-GPIOs*/
9 ~& z: \ t0 ~+ h( jstatic const short da850_evm_tl_user_led_pins[] = {
0 B- l0 b- K) [+ `. P, I, z /* These pins are definition at <mach/mux.h> file */$ H$ L* n3 p% s# b3 m# X+ I' Q
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& Q2 f5 Y7 b& q/ W4 M f) t -1
6 e" N8 [& u) ~& f ]" j. Y0 P};
( ^5 x. j8 g. x) B2 T; \' v4 c
6 h' F- @8 ]) v }$ j7 B4 vstatic struct gpio_led da850_evm_tl_leds[] = {9 Q- W4 g- w# h5 V
{* B) X9 K1 q- D
.active_low = 0,8 E: A! j. O1 K$ K$ u( d8 v( G
.gpio = DA850_USER_LED0,/ r( _& Y/ U5 @' s: {; I
.name = "user_led0",
( n% i8 q; x- k- f q( C6 D .default_trigger = "default-on",
! V3 Z! h) x; E o& k" {( k1 t },
/ a: C% e- m% F {
* a# `4 s+ `! D- ^ .active_low = 0,+ V+ }0 |7 i4 W" D
.gpio = DA850_USER_LED1,
- x4 S5 {6 m- R7 W! h5 t5 v8 V! y. N .name = "user_led1",1 l+ n4 n$ o5 F2 w8 n$ _6 t
.default_trigger = "default-on",3 L. d, X+ E5 Z7 F |6 m* X
},5 J+ j4 z1 o9 i$ e' J& ~* P) X
{
) T$ ^" }1 P: N; F% c4 | .active_low = 0,0 p- I6 E) N1 L
.gpio = DA850_USER_LED2,
+ J0 u# L. g: @ c; s A% f .name = "user_led2",7 P% b5 f6 H$ I2 Q& R4 x
.default_trigger = "default-on",
/ P; l( V5 l, z! g },2 r# L. j. Z8 X8 J7 }
{
" H" x" x1 C2 ?, |: b .active_low = 0,
; r) s+ N4 \2 l( ^ .gpio = DA850_USER_LED3,
, I# W. d" l+ [- m/ J! g" i .name = "user_led3",
' `% o( u* k/ Z .default_trigger = "default-on",5 K+ z8 _4 d0 G7 r" U# H; b2 I
},$ W) w3 D3 F) n1 t
};
: g5 }+ o1 B+ B# T. W. f- K$ s$ B0 O2 J0 X1 W6 V
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- ]/ N4 z; e! S; H' Z$ i# L8 m .leds = da850_evm_tl_leds,5 E, ^& z& p7 [
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
( I$ l8 l/ T y( y};2 Q4 e) h% q$ T
. @9 i" s# A% i- Y- mstatic void led_dev_release(struct device *dev)
4 m+ m9 Q5 {4 ?4 w/ G0 T# z3 s{
. n& k0 K [" G};
1 A( l, q# G- t6 Y( O& q5 e q- J2 J. }
static struct platform_device da850_evm_tl_leds_device = {
* ~ ~% g, `6 _: W' z, D1 o6 g0 v .name = "leds-gpio",
( V* K k3 b- |5 y/ h2 Q .id = 1,7 S, p: Y$ c; w6 A, ?: Z
.dev = {" ]9 ]; n: z4 A; D2 w) k) ?0 `+ k8 ?# L
.platform_data = &da850_evm_tl_leds_pdata,
1 N! _: h0 h8 g0 u7 n .release = led_dev_release,1 a* y6 {4 m, w& q$ I, O; i
}$ i0 Y; Z5 l8 S: o* C
};
; ?) a& ^# ^" H* F2 E& L
8 s# Q0 a+ G) C4 j& @static int __init led_platform_init(void)
% [1 r J% B% a2 t5 S{( t- X% S8 h* ~% {7 y$ {
int ret; w/ P# f! J/ {# R! g3 N
#if 0
& ^+ @: x4 h6 n: h5 o7 I ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);2 r8 y$ M2 e% ], o
if (ret)/ x4 A9 e- c0 O$ c3 D {! `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
A: p& x7 z9 K7 O! o "%d\n", ret);
& {4 L1 c3 U8 N/ I#endif
# d" H: q8 ]0 Y' K4 X ret = platform_device_register(&da850_evm_tl_leds_device);
% O5 n# u. y& d/ l& |" H if (ret)$ f$ ]* s& W1 T+ o8 |9 J0 O
pr_warning("Could not register som GPIO expander LEDS");) c/ E; r& j2 q1 C; }. t7 c
else
% V+ _9 H- W- O- W" P printk(KERN_INFO "LED register sucessful!\n");! s8 D2 u# U* j2 e
+ h) q5 L0 |! _$ t
return ret;' c! _5 v0 r; d/ t
}
* J( ]8 [7 y; @ ?
9 a; k$ B% x6 S# H% \. ^& S; {static void __exit led_platform_exit(void)5 b$ _- \% m- _5 ]+ }' q+ q8 g
{: n3 Y" M) x7 ~3 D1 l' g
platform_device_unregister(&da850_evm_tl_leds_device);
# d$ c- J5 d" x4 i+ n8 n7 X- L6 g/ S4 ?+ R% u
printk(KERN_INFO "LED unregister!\n");3 W& C( e' |# b$ t0 I0 w4 f
}0 I) Y- f. v9 p8 d9 Z0 J
$ {+ ^, n! Z% l; O
module_init(led_platform_init);' a: q& F; F1 L' l% V
module_exit(led_platform_exit);% r$ c4 F+ ^% n
; u& U! M1 e% v' g& F7 SMODULE_DESCRIPTION("Led platform driver");& w( R# k, w# F7 ^
MODULE_AUTHOR("Tronlong");
8 P1 `4 F: o" @8 r4 c5 R' U, A/ xMODULE_LICENSE("GPL");
/ h0 ]- Y1 N' A2 I# V1 i0 H% I
0 a, K* r/ W& E( R1 `5 R8 q( B |
|