|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: P% J4 X: o0 @. f
#include <linux/init.h>
# p& D- w* C0 V#include <linux/module.h>
% c5 i! ?" R: e1 p% P#include <linux/kernel.h>
! O& U+ u( O' |: q$ u8 O8 ]" ?#include <linux/types.h> c4 h* U/ w( }6 r$ H
#include <linux/gpio.h>& V' M% j I* N; ?$ r. f
#include <linux/leds.h>" r+ d* w: W4 f" p
#include <linux/platform_device.h>
" w+ D' l" x$ U' ^5 r Z- N2 r8 ?6 t+ K; c) k& x# F& Q
#include <asm/mach-types.h>
/ k* e0 p& x# U( L#include <asm/mach/arch.h>3 q! T9 \8 v# r# |# P0 y
#include <mach/da8xx.h>; v4 X3 t8 }; D* I
#include <mach/mux.h>
6 n6 V# x8 _- x4 ^3 F# B. }+ I3 R9 L# Y" Q& V$ h: f
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 t; A4 X- ]7 [, a. X) o6 m#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; I, h# `( n" J; g' o$ ]* ]0 m" m#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 d5 S, [. _6 h5 f
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
. ~ G: r; N8 q s" V: Z; R0 t5 i: M! X m4 y* ^. A) O
/* assign the tl som board LED-GPIOs*/
1 {9 B6 \ {4 \! W0 ?static const short da850_evm_tl_user_led_pins[] = {' \% ~" T7 W& ?! M B
/* These pins are definition at <mach/mux.h> file */- h# a; ]- Q7 e/ y$ j9 B: A- g
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,3 a3 L7 U% `3 S- I" a$ }0 g
-1, U p# Y% ~3 j. B$ U2 b3 J/ d
};
1 |8 w* b6 `) f6 N% P4 G7 p! j& o5 p+ G: b* O! v5 O+ Y
static struct gpio_led da850_evm_tl_leds[] = {
$ v2 _$ e* v: H9 o- c. U {4 `4 ]/ u. }9 }& C6 \- y0 R
.active_low = 0,! a6 ?* s8 g3 a: T
.gpio = DA850_USER_LED0,
- \0 D; j& a( k r( _ .name = "user_led0",
8 B- V2 X7 q0 v% n1 C) Q .default_trigger = "default-on",9 y9 R5 [" g. h. p. {
},+ B% O2 u5 ]+ m6 Z& x
{ l. K" A) }; F: f6 @
.active_low = 0,
6 }( x% r) m; w8 A/ c% H .gpio = DA850_USER_LED1,
2 |) p! z8 z" [3 k: _ .name = "user_led1",
* A* U. G3 l- m; j }' V" N5 U0 X .default_trigger = "default-on",3 }, D$ M- _, A; q1 D1 ~! ?
},
) L" I; q$ I; x/ l4 w {
; I, @# E q% K* Y .active_low = 0,9 X5 O& q6 V: v8 Z6 u3 r. H
.gpio = DA850_USER_LED2, T. h$ I( i' W! C9 u" u# \) K
.name = "user_led2",( y2 y9 Y4 ~6 ^# P" g3 s
.default_trigger = "default-on",$ h' o- w9 J7 \6 ]" c6 J7 z# C
},
: @$ g2 F: \( {2 z1 e. N( d' E x; s {
9 Y4 l* L+ q$ C5 _( i6 M5 f v1 i2 d .active_low = 0,; U/ V0 ]# @6 ^0 O4 r
.gpio = DA850_USER_LED3,9 |% S: r* K0 N8 o' E, A8 ~ g; u
.name = "user_led3",1 n0 [0 I; }- B
.default_trigger = "default-on",
# X7 ]. W I1 `- R, R5 P6 X9 G& N },4 n6 p6 |1 d) Y/ u1 ?
};
' i- P0 e7 U! l; H% t
" n! H4 y# C1 t3 k% [4 A8 m9 D1 Gstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
! F6 Y s# `; q- J; E! H, m .leds = da850_evm_tl_leds,
N# n* e3 t# B4 o# Z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),/ X& l# `2 i7 g3 D; r( ~
};
2 J8 k& Q- j- M; `, u9 A) k
! t6 K0 p, x- T+ _1 @& t! r4 S/ ostatic void led_dev_release(struct device *dev)# {. P( [% l9 B2 @. a
{
0 L- G+ i4 U' M. `$ W};
0 y! G3 ?( O5 `9 A- f H9 e
6 `, U/ |; X1 c% I8 i- Tstatic struct platform_device da850_evm_tl_leds_device = {
' A% ~+ \/ p; i; Y .name = "leds-gpio",
4 H1 [$ N7 b3 @- n9 N .id = 1,
* h/ g2 v7 ^1 e! u5 _% X .dev = {, p, r# _, ~2 Z8 t5 _+ Y5 v
.platform_data = &da850_evm_tl_leds_pdata,$ ~$ X5 A! i# ?. D5 M# J& g6 P
.release = led_dev_release,
! d3 T; J; l2 u }* c9 c. R1 n. l' F3 B& s5 K
};' P2 D! K- d% O, D
' I) r/ h: R! L# m# j
static int __init led_platform_init(void); x N0 F! X m+ f2 a3 ]
{
9 c$ u& Q: m d! n( l3 G* W int ret;- i7 C9 \+ ^3 B, l/ x8 ^) _
#if 0: D/ i. K- _# T& E; ~- H6 w
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' I1 i9 A" E5 w7 J7 i/ y if (ret): \, e! i& s0 T# P; `* E& E+ T
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 n- t" K: X8 ?- |$ ^
"%d\n", ret);
5 [; [* z% n" R; ^ ^1 \. n# |; }#endif
' u& Z; v2 R9 D. L2 S ret = platform_device_register(&da850_evm_tl_leds_device);6 C3 W* c. ?: D' ?5 I* M3 f
if (ret)
& G' D. O2 ^' j1 D W pr_warning("Could not register som GPIO expander LEDS");
& S. f. D0 p. O5 ~( ^ else* z# M! B# c4 a
printk(KERN_INFO "LED register sucessful!\n");) K7 S0 q4 ~/ ]
6 s6 E/ b( N$ J- J
return ret;
7 U5 E) s! ^/ j7 o m+ j}: m- k3 g! |$ b& t& t
4 L! c* B. @! e. f4 M/ L! B. F
static void __exit led_platform_exit(void)5 P: Z) k" _# Q2 _' t) n, Y
{
$ J: B# ` d; e9 v% N' a4 I platform_device_unregister(&da850_evm_tl_leds_device);
2 S6 R3 Y1 h4 w; C; e* M7 o, J3 t* d0 o
printk(KERN_INFO "LED unregister!\n");* l* J3 K( x* l; r$ s! a- u; g
}5 a1 j$ H7 [# D' q1 [" {
: X0 [, K, z) h8 B& ?, V' U/ smodule_init(led_platform_init);
- ^2 `9 N+ t3 t4 r$ lmodule_exit(led_platform_exit);
5 ~$ h6 l$ U7 C9 K. T3 E9 H0 Q( V& [& @" b* I7 T W
MODULE_DESCRIPTION("Led platform driver");1 W9 O* B+ S9 x/ m9 C8 z8 V
MODULE_AUTHOR("Tronlong"); ~0 ~6 d* R7 O. {: D7 L4 K- T/ A
MODULE_LICENSE("GPL");
6 p/ H8 E8 N" f7 s4 W" i3 B: T; x0 U' V6 X7 n6 ^+ y
|
|