|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& I7 q, J {1 b* c5 l- W#include <linux/init.h>8 E! d/ _" s# A, t# t3 L; Z; _
#include <linux/module.h>2 A7 L ^, h6 L( w* w
#include <linux/kernel.h>4 ^ U5 x0 }5 f/ F, T' W
#include <linux/types.h>
7 ^; e& I7 d; h* k' o4 C9 l( [#include <linux/gpio.h>
7 |, R5 C* h+ A2 Z! i#include <linux/leds.h>
( z ^) X" H( B3 N! N#include <linux/platform_device.h>
( F; ]: H' Y* e' X9 Q
' i6 P4 b. T/ O: {& O( n#include <asm/mach-types.h>3 g+ J, W8 `# Q# C
#include <asm/mach/arch.h>
9 W) g9 y) w0 w* U#include <mach/da8xx.h>
, h" M+ ]" U6 u2 w3 I; O#include <mach/mux.h>
1 }. k% S% F6 ^6 P7 }; l4 Z$ D* a. R1 s5 q6 k0 m P
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
( N a+ p( _( _: M: i#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)( V5 t4 R& r$ }/ j" @" D6 K3 T
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) o9 d8 N/ E. A# e) [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
+ s* D/ f3 E) T% L3 ?* _$ v: M; g/ B
! r) S$ h7 }, h" [. x( H0 V, \/* assign the tl som board LED-GPIOs*/5 h/ w8 D8 W# \
static const short da850_evm_tl_user_led_pins[] = {
- q$ z( p4 I7 |. ~5 @) h /* These pins are definition at <mach/mux.h> file */; M0 a- G1 S3 u! B; W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
0 l9 C/ O9 Q; U; N& s: D -1
1 Q, |9 k* y4 \* N) z};8 z) P& {4 j: M1 g! `
/ e" H" v+ @# a1 L A) p1 t! pstatic struct gpio_led da850_evm_tl_leds[] = {
6 ^0 m; J$ J' l1 n4 i, a E/ j {
9 o# B8 P1 }- ^! ^7 j .active_low = 0,
. f* j2 `7 p+ P; S' ~3 j: f .gpio = DA850_USER_LED0,
7 N8 c$ @1 i+ f0 l f! B .name = "user_led0",* O2 u/ [; `$ A9 L. D
.default_trigger = "default-on",
) H# G& z9 i" k( L$ G },
" W0 R" [3 c( L {
2 A& w d8 n5 P" j9 q1 X7 A0 p. Z .active_low = 0,5 _# w5 v4 J; K0 ?! V8 w
.gpio = DA850_USER_LED1,
8 |5 m4 Y# X; l# C8 t* A .name = "user_led1",7 X/ [0 ?( ?: x. `
.default_trigger = "default-on",: s, r) U0 L: N7 a7 t6 |
},
1 l* x) n) o$ N U {
- @! p, |: _+ e6 j/ c7 | .active_low = 0,& d; y7 M* s# D) A8 k+ H; C/ Y4 ]
.gpio = DA850_USER_LED2,3 p- W. T$ c- ^& ~6 Y u9 v( F
.name = "user_led2",9 U( f4 l* C6 z+ y M
.default_trigger = "default-on",
/ J' J5 {! K$ W* K4 [" d },3 j, g( V# M- y, Q0 Y
{5 g6 g! J" [6 G+ p& q9 M
.active_low = 0, E7 X! T. w1 D
.gpio = DA850_USER_LED3,
; Y6 L: c w5 O) C .name = "user_led3",
r8 S- ^* q- z' r0 D .default_trigger = "default-on",$ Q9 t D. Z$ b, s) n( k& M
},% i+ D1 L- W- f* ~ p6 ^
};0 ]6 v2 J! ?: e
- D1 \ K/ `( U8 n3 B) Y; Vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
; q0 x" M* d, z- a6 T# ?% L( U% Z .leds = da850_evm_tl_leds,
# |0 {1 x( U6 b: ]$ O .num_leds = ARRAY_SIZE(da850_evm_tl_leds),: d+ g- r+ i4 Y2 |# L0 |2 s6 D* l
};! T3 d% d( W+ N+ E' K# h
& n5 A9 Z( n- Y
static void led_dev_release(struct device *dev)
6 l9 c, N, }; |. N/ h{$ L; h! L; P0 m0 X( C, J, T: }0 W8 m6 B
};/ {) L4 M2 m) M! D
# p: V& Q3 Q2 V$ h3 l: X- H, K3 _0 `static struct platform_device da850_evm_tl_leds_device = {
% a, n+ f5 G# R& K8 X .name = "leds-gpio",
8 V, Y$ {( s* O+ ^9 C, L" u( q4 @ .id = 1,
5 E( _1 z+ C6 @5 R( W! L6 S" i .dev = {" I! K' T* m$ p; m+ m4 C
.platform_data = &da850_evm_tl_leds_pdata,
& O r3 @# _+ i% H @+ f .release = led_dev_release,! s9 @1 e1 V9 z) R; D* b3 E8 z
}
( ?4 f+ W& }( m9 |; i- R" k};: ] `7 W5 v. J9 l8 W7 p
, b3 N+ {) L# x' @ [6 N' L4 Xstatic int __init led_platform_init(void)6 `) |# \+ G( h5 t H
{; M3 \- |- ]5 w
int ret;) ?5 j" r+ L% J) X
#if 0
. o/ u4 I! j! m" I& v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* j; A# d( c8 I, G7 ? if (ret)
$ q0 A! J" ~/ }5 ] s* J pr_warning("da850_evm_tl_leds_init : User LED mux failed :"/ Z8 A2 d2 Q- Q+ `
"%d\n", ret);
$ @- W. \) V) j/ k2 h7 T4 M#endif
% C b) A8 j0 S T ret = platform_device_register(&da850_evm_tl_leds_device);
3 u; e4 h8 L5 N: T! T if (ret)
' p3 a* E. K1 f# j4 [& Y pr_warning("Could not register som GPIO expander LEDS");0 I! p. R: a( Z, A4 f8 z
else
5 p3 ^4 [. h7 v) r- c+ n printk(KERN_INFO "LED register sucessful!\n");4 j& Y: M) E2 s% y, I( V. e
! ~9 ]7 l9 A8 }/ K0 a+ e) Q return ret;
/ p, Q& z0 a6 b$ h0 n) e}: p9 U& ?; a$ {
3 {: a% i9 Q# s
static void __exit led_platform_exit(void)
$ A# U& B* k, M9 l{
2 M: q' X0 u' g platform_device_unregister(&da850_evm_tl_leds_device);
$ O/ X/ U; C2 ]% t) L( }- |
& c( d4 f# Y, @) ^ printk(KERN_INFO "LED unregister!\n");6 m# O1 d) J5 C6 F0 S
}' ]) m0 T: S: t" i5 o6 M F
( ^6 O5 T5 O% E/ O: q* N9 L' r
module_init(led_platform_init);
. A- m9 N d% {, vmodule_exit(led_platform_exit);
J: e3 u$ ]- @; A% i' Y. y* r5 d0 y
MODULE_DESCRIPTION("Led platform driver");
1 G* ^: k. S% i/ T' E+ x# a5 hMODULE_AUTHOR("Tronlong");
2 T5 ^2 d" O, T9 rMODULE_LICENSE("GPL");
: x& b; T% h' b0 Y6 G0 s% J
& w( I a3 L+ m1 k. c* K" [ |
|