|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 T2 ^; q( P6 e8 i6 `#include <linux/init.h>+ C9 [. I3 K! d2 f6 E
#include <linux/module.h>
Y9 b9 E+ Y6 M- r#include <linux/kernel.h>
8 a. f, W' C4 f! b: s#include <linux/types.h>1 D% I( n2 J) |/ w9 R/ o- |! F
#include <linux/gpio.h>
3 N9 P" w1 Y h9 u# M#include <linux/leds.h>
( p9 C f2 |" K9 G6 L) q#include <linux/platform_device.h>1 R; q J1 N+ }3 t
, K+ A* k$ S( n& \; S' b2 p#include <asm/mach-types.h>0 S7 m# _% e6 t4 c+ `
#include <asm/mach/arch.h>% F! a" T N( a5 \. x
#include <mach/da8xx.h>0 J* i0 N2 e4 G' U7 g* T+ n
#include <mach/mux.h> a4 Y0 ~$ K9 f; [! L% t
* F3 G" U' p4 t& h#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 k3 B" E6 \: K" L% `) ~#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* p: E) H- ^0 f! Z( Y#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)) C0 J! Z' B) g, V
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). s7 t' n- x G" g
, K% R/ t( [) ?
/* assign the tl som board LED-GPIOs*/
p# I# Z% ^/ L- ^: ]9 r$ P8 p# [' o5 {static const short da850_evm_tl_user_led_pins[] = {
. `# N: ? E2 Q4 Z" n0 f6 E! | /* These pins are definition at <mach/mux.h> file */
: Q: e4 B6 s# k9 h% b2 W7 x4 p4 } DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,5 S2 R" y: W# l7 K% j
-1; E8 o) z: c. n6 m7 Z& H) g% a
};
D" a! k$ j, M1 |% S9 O! }$ C$ k1 Y+ ^2 e
static struct gpio_led da850_evm_tl_leds[] = {# _% B/ r: F) X- R* p. L3 b
{
; n/ `( z8 x( _; c" `) {% z @) w; q .active_low = 0,
. J0 |' f0 V2 y: h) W8 d .gpio = DA850_USER_LED0,
- k- L, ]# B- `' }+ A .name = "user_led0",
H: C$ B* R/ V$ m7 n- f6 R .default_trigger = "default-on",6 l! ]9 D6 P% d% D _
},& ^5 H1 Y D ?( o/ z8 q
{' v+ {" \4 n, l' j \/ |
.active_low = 0,0 O) f! N4 S, |& F
.gpio = DA850_USER_LED1,& J2 T0 \8 `% [( J
.name = "user_led1",9 I# [. c+ _) k$ z- A2 ^2 N
.default_trigger = "default-on",, c: v$ z3 @0 _; K
},5 d/ R! Q1 X0 p
{* c) K+ X, j$ l
.active_low = 0,
1 }: L I7 p! E0 ^/ P+ \ .gpio = DA850_USER_LED2,
& G! \( t( n" C* H .name = "user_led2",6 E3 L8 t# r; k/ f, x/ Y
.default_trigger = "default-on",
$ E; n8 ~0 S6 @; j2 ]8 x+ ^ },+ C# \ P0 o: E
{' N4 ]; f1 l0 K" H, H( q6 |$ U
.active_low = 0,7 v* M7 Q6 k) F) `: x: e
.gpio = DA850_USER_LED3,9 I8 a6 w6 e) h/ }
.name = "user_led3",4 m* m7 C2 N q. N3 f1 a7 {3 b
.default_trigger = "default-on",/ S$ t( I" F2 G. V) a7 T
},
( x3 ?2 Y. ~" v8 |# f1 E; d};
. a$ X' e7 J. i9 o/ j( y: ?. f e( m1 y7 K- b% @' e# E b- H) K5 F
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 v; v. e+ T6 _% M
.leds = da850_evm_tl_leds,
8 h4 s* W# ^- [$ \8 O( t7 M .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
6 D5 ~; K4 ^- x+ x# v! ]};8 h; l3 \% b- {1 U9 S
\' c' M+ B& w* V) v8 E3 C0 U
static void led_dev_release(struct device *dev)2 G& Y! n2 X+ F% E. k% g" ]
{) H% b! H9 {8 f/ u4 A
};
' {0 K' V: D/ H, f4 X# n: B V4 ?1 a; C( u- J5 f8 U
static struct platform_device da850_evm_tl_leds_device = {
6 i6 } e5 K3 Q. z# ~5 Y7 k6 Q .name = "leds-gpio",
' y% E; c1 `5 w5 N" O$ d3 s .id = 1,! F& B5 N' m) H% d3 k. D
.dev = {
3 b+ y' h$ p, H .platform_data = &da850_evm_tl_leds_pdata,% D9 I. D0 H6 y; J) }
.release = led_dev_release,' e2 d- Q8 t/ f0 I& H ~' N
}
5 ]7 U$ k; E% _" i) P& f; _' ]};
1 X! v* w' O3 x7 b- {. y6 N
- y" [- a# Z; z+ {; p( e! A" Estatic int __init led_platform_init(void)
$ E1 ~" c5 ~& I- C; E, v{. {/ w" u$ o+ u/ u
int ret;
. K0 Y/ L# Q- C# w" F' t h9 u7 c#if 0
0 n( k1 Y( u& f* m% D& G- | ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 h$ \& A" L$ f+ t8 V
if (ret)
7 N) q; e2 w* d# C; q8 e4 @ pr_warning("da850_evm_tl_leds_init : User LED mux failed :". s5 P# G' E. M. R' U
"%d\n", ret);
/ O, K" H% [$ J% R#endif
. O0 J1 E0 g t4 L% g2 E+ P ret = platform_device_register(&da850_evm_tl_leds_device);/ A. o3 w+ f' J/ p
if (ret)! n& A K) S$ k0 u+ \1 _5 c6 ~
pr_warning("Could not register som GPIO expander LEDS");
8 C1 k. x6 @- c/ E7 v0 K else
Q/ V3 Z3 u7 _; B printk(KERN_INFO "LED register sucessful!\n");/ I5 V! P- A+ T7 {3 f) s5 n
4 n h/ v" i" I" H' X( e/ d return ret;3 T, s0 h* N) g& f' L7 X. z, A
}5 e. b* V% |3 `. V5 X+ ~5 [! ]# [
# j- u0 e$ r2 A) G# `static void __exit led_platform_exit(void)
: ]* B, ~, N# P: v+ Q7 n{8 M) S6 T0 b1 E7 N- K0 C! u4 e2 I
platform_device_unregister(&da850_evm_tl_leds_device);
1 t k6 E' g5 c
K/ Z% f/ `0 [) l printk(KERN_INFO "LED unregister!\n");5 ?/ t- N7 c, N- P. Q+ a) c
}9 ^! H6 S, g- O. C+ u$ n4 D
7 p! Q7 ^- f# ~7 C ^0 dmodule_init(led_platform_init);8 Q: y9 e) [) ~
module_exit(led_platform_exit);
+ R7 e5 v3 {8 ]( M! u$ T) m4 O3 X- n% ]$ r
MODULE_DESCRIPTION("Led platform driver");
5 r2 v1 p1 Z2 Y0 X. _- z' KMODULE_AUTHOR("Tronlong");# R6 n2 D* {" c' D( K; \
MODULE_LICENSE("GPL");7 E5 ^! H% z/ N. c
; g3 V- V3 Q; ] |
|