|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 }2 o7 d* y0 t/ c1 T
#include <linux/init.h>
+ x) E! d9 D- p/ L#include <linux/module.h>
( B; i% |# d8 O7 l H2 h#include <linux/kernel.h>
. a& @& I' K4 l+ C9 n# l4 W#include <linux/types.h>
' q) O Y0 r, k+ L#include <linux/gpio.h>
: w( F$ V4 {3 B6 w# J9 V. {! z0 @% }#include <linux/leds.h>
; v! k( S2 W! q: j" X#include <linux/platform_device.h>3 I* v# X- t+ u% ] _% H' s' k
1 w8 I+ f. D# B% }
#include <asm/mach-types.h>
- g! \; I2 M7 B#include <asm/mach/arch.h>, N( F# D8 }( n L+ s. m
#include <mach/da8xx.h>
+ f9 S& Y, G; P4 z. a#include <mach/mux.h>4 H; i- F( D. o& F8 t9 E2 w) U' J
; q4 b; G) X2 W! M
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- Y4 s, B& t8 E% v6 x#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 B- H& ~9 T' ?$ _- U
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- N, ^+ U' I2 c2 F$ V
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ m- w) j, |/ d' N
# q8 [& A! A \2 l# z+ X4 B
/* assign the tl som board LED-GPIOs*/
1 r) Q: Q) q( s8 `static const short da850_evm_tl_user_led_pins[] = {- \( A* b) i% A# m
/* These pins are definition at <mach/mux.h> file *// o2 R+ c6 f0 F9 ?9 j) ]% c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! X6 ^% g" @1 F7 }# a( Z) N1 d# z% V -1
0 T7 l( `$ C& e( [% ?: g};
/ _1 q) y' x6 N. z- S* p+ t8 X" J8 I9 V1 w1 d+ `/ t7 [
static struct gpio_led da850_evm_tl_leds[] = {% M1 N1 U! c6 Q( d* V( z/ E% m
{- X! X( ?2 @) c. |
.active_low = 0,) `: b# W2 a. W/ z9 P: p, D! Z
.gpio = DA850_USER_LED0,7 ]4 z( G* B; b
.name = "user_led0",6 v; m5 {" l% t
.default_trigger = "default-on"," L7 A. k* \/ x E9 l) q6 u/ [
},
$ P* R9 o' M2 {- J7 ` {
0 V) ~4 J( a* b6 P" J .active_low = 0,
5 r& v% P' Z: u6 i/ s. }* m H .gpio = DA850_USER_LED1,& w0 f0 k& t3 `4 g) ]
.name = "user_led1",0 `8 ~7 M( L+ l& ~1 I1 a0 ]# b* p+ Q5 r
.default_trigger = "default-on",
! F% R+ ~& h" J d k. a& N },
% V$ }% @: M2 R2 X+ X( v {; \6 p' L1 I" |" } W. X) K$ l; X
.active_low = 0,
/ l2 a( ^' W5 d .gpio = DA850_USER_LED2,
+ b. S" x3 h) ^2 w .name = "user_led2",+ J" F& M) R: O; E* V. Y, [
.default_trigger = "default-on",1 o9 _ N0 j% r G
},) o4 o0 q- N1 d: a2 p
{
1 U+ [- r) ^+ \ .active_low = 0,' J* c6 x7 @) g* h& H
.gpio = DA850_USER_LED3,% k. {- Q0 E5 T' x
.name = "user_led3",
7 W$ B, ]' g4 g .default_trigger = "default-on",; R) [4 L) {5 U/ p+ n% O% A6 N Y
},
3 O9 k, {0 F/ P' u$ ~; ]};
1 g9 |5 ^% k( R" k. d& o* L: [7 o3 l$ \: Y' m0 `
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 b8 q3 o& t7 h4 u7 f
.leds = da850_evm_tl_leds,
6 Q; _6 _- m9 q2 J .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 w* j, u+ _, C7 O+ U};
. R0 v7 ~! P' k. e P& g) d( ^1 \& Q; M, Z5 q4 n8 I+ J
static void led_dev_release(struct device *dev)
1 Z9 g) r+ J% X4 B {0 b4 D{$ @9 K0 Z$ Q* Y+ P0 F# L* w/ l
};
2 T8 ]- n$ V5 z, e& L* Y8 d1 \
; v2 t; U- I; C; J! nstatic struct platform_device da850_evm_tl_leds_device = {
6 b% J% a2 x' W+ i2 f .name = "leds-gpio",
$ e2 Z, ~5 u- {( U( E# `( B .id = 1,
5 [! ~+ a7 T" V .dev = {" ]7 k; u4 L2 W) j$ R; L) n' ^
.platform_data = &da850_evm_tl_leds_pdata,
) i' N8 Z1 J0 O! A. w7 c" V .release = led_dev_release,8 J5 h$ ?7 [: Z! B9 j
}# u, k& u" K6 B% A& D. j' y9 f
};, `+ x7 w8 [9 b, ^/ f
; J3 S+ ]. g, T8 @9 O+ xstatic int __init led_platform_init(void)
( W. O$ K7 `, D3 b$ K- y{- U. O! v3 h( @. x% k2 i
int ret;! y. M1 J$ y4 r& @% P
#if 0
# r+ h, e' h* ~; ~: D ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);5 c# y& C! V: P4 Z# E/ S) J1 w
if (ret)
8 b0 N8 C% t5 g5 N5 o pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 H9 A. I* J3 X, { "%d\n", ret);
4 d+ X- d$ ]3 i#endif S4 Z: { z: D+ U
ret = platform_device_register(&da850_evm_tl_leds_device);
6 e" R2 B0 T Q0 L+ d3 E if (ret)1 p. F0 k% `: {5 ~1 z* [7 g
pr_warning("Could not register som GPIO expander LEDS");
O! F6 n8 r# u; y0 | else" G, Z, j5 ^1 p; r1 _! ~$ Z ]
printk(KERN_INFO "LED register sucessful!\n");
2 F5 T/ [; H: E9 b9 ^
2 c1 E( J: p# R4 x return ret;0 w4 p @% i) _& {0 r' o) l
}
: M+ f9 d: i4 s) @) K$ { z5 [
( e* q% K6 {, N* L! l- e5 l7 i+ f$ ?static void __exit led_platform_exit(void)' D! A# m# ?' k$ \
{
8 Q" O0 o8 s. _0 m+ ? platform_device_unregister(&da850_evm_tl_leds_device);
$ I9 z/ X( i' N# F, I
3 s S, C+ b% {3 h printk(KERN_INFO "LED unregister!\n");
9 G2 K. ^# M8 S}* p; v0 i3 ]1 N: L, q
) G" A* v9 n9 w: v8 Z3 \0 e
module_init(led_platform_init);, u9 `. N1 {# s' N+ u1 U. Z. F
module_exit(led_platform_exit);
1 q0 t6 r. I) `( B# x- ]7 f, m$ [& d
MODULE_DESCRIPTION("Led platform driver");
0 h/ w9 Z% S6 r% f4 }MODULE_AUTHOR("Tronlong");
& d9 _0 j. a5 }MODULE_LICENSE("GPL");& z: w! i7 B# d; g" {7 u! Q! R
. t7 L# r+ t; G1 U1 \. ]& i
|
|