|
|
求大神给下面的程序做注解,请稍详细些,谢谢。' f- a" t4 g6 z4 M- a! b3 p
#include <linux/init.h>8 w6 ]" o L6 t8 {
#include <linux/module.h>8 D+ J3 T8 M4 p. M5 M( }! l& P
#include <linux/kernel.h>6 k! Q3 |2 K! @9 ~ {9 e" N- _0 P
#include <linux/types.h>
: v+ ?: ?5 {( T3 h3 z#include <linux/gpio.h>
: y7 | q" {: d% b" i#include <linux/leds.h>; W$ o% _6 H: ^: {- M
#include <linux/platform_device.h>& g+ S x5 u1 R+ e" ~8 B
/ h5 F$ C6 ^8 g% ~9 J* @( k6 o
#include <asm/mach-types.h>
+ y6 ^4 B" L$ H9 B9 e9 z#include <asm/mach/arch.h>( I2 W& k2 `# ^9 y: L4 [7 h$ {6 m( X
#include <mach/da8xx.h>0 l& U0 F( F) q; ]& Z% J
#include <mach/mux.h>0 {0 {; H% v* q4 F9 }
' Q8 [0 Z6 Q* `5 w& J0 b#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 A, [) n8 B' f. U D
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
. j! b9 y3 X* Q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); b7 I. l& Q9 P4 C
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& W( i7 r- S, p! x+ |9 }* g1 M
. A* n' y& g1 x4 S5 ~/* assign the tl som board LED-GPIOs*/
# B, g) B7 L$ B3 [static const short da850_evm_tl_user_led_pins[] = {: N9 d& h+ t3 H: P
/* These pins are definition at <mach/mux.h> file */
, x8 y6 Y. @ m DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' ?0 F# G6 v$ ?
-1% f0 I4 ~; r. T5 m. i! i
};
- ?9 X$ b* s/ @ s, f1 ~* }
m3 P7 M* D# v, w$ Ostatic struct gpio_led da850_evm_tl_leds[] = {7 C% y) V5 T( \6 G3 [, X: @# j
{0 r% h8 N$ j5 A# b
.active_low = 0,+ s! P3 C% ]1 n
.gpio = DA850_USER_LED0,* E0 l5 Z! _% |- ~
.name = "user_led0",
2 W1 s% [; B! B Z6 k .default_trigger = "default-on",
, j! W- N, m; f% H, h6 @, z: a: G7 Q: n },* {1 a- |9 J1 Y/ N: F
{1 r+ P; m) U" ?
.active_low = 0,
8 N6 T2 v7 X: H/ j- I) ? .gpio = DA850_USER_LED1,5 P8 E! S J1 [9 b6 J6 [
.name = "user_led1",8 i' C, X/ n- G: k
.default_trigger = "default-on",- a( f' I3 Z: X
},3 j6 {2 ^/ U t1 e$ `1 L4 G
{
+ X& L0 {: z6 Z7 H" | .active_low = 0,
+ x" ?, @2 u9 X# p .gpio = DA850_USER_LED2,# U# c! L" }% L
.name = "user_led2",
E) _5 W% \7 i5 |! u8 ?- o1 b .default_trigger = "default-on",$ y3 C: B! d9 f" n* b6 P9 [' ^% ]
},
7 X3 P3 ^' d; ^* q$ u {
- O4 V) k# s8 Y; \! H .active_low = 0," [5 a' D& i6 }) P
.gpio = DA850_USER_LED3,$ d, G P2 G8 f* U
.name = "user_led3",
/ n' [0 G! f; f* W .default_trigger = "default-on",3 n0 f, C$ P2 o! n
},
" h3 R/ R" H. P) c1 m( N2 X};
* \6 {3 }3 Q! ^( @$ P& I1 B8 F
) i" z ^) T- j# m' ]1 `static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 u( n( Z' d4 W6 c
.leds = da850_evm_tl_leds,+ j; b, S" B. N: `. T; q( Y3 p
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 T0 u/ C& v. d
};1 S/ E2 t; P6 M" Z. F
$ ]9 o; k0 F$ j9 C7 v! }& M* hstatic void led_dev_release(struct device *dev)0 a2 h0 O2 M. U! |( s( |1 d
{
1 y: |8 Z5 q4 M7 Y};
( t4 f5 @; [, n
3 s5 v d* z5 q) g& C4 P/ T' X7 x: {static struct platform_device da850_evm_tl_leds_device = {" P! K8 B) n8 }& I
.name = "leds-gpio",
7 J: o/ d; c5 k" @# a .id = 1,
+ H# k/ l) A' ?6 M .dev = {
+ L# Z! j8 R1 p6 ?! ~3 l. f* W .platform_data = &da850_evm_tl_leds_pdata,4 K$ K# I' @3 i8 ~1 Q& N
.release = led_dev_release,
0 o8 D# O( y' `# `: _ }% ~3 Y2 t7 K+ o/ y5 o
};
& E0 B3 W L3 X
+ O! U4 o: W M0 q% g" U& Qstatic int __init led_platform_init(void)4 B! k% T( w, G; D9 O' l9 y* y# I
{
& I- D$ d+ r; U7 y int ret;+ [" f s' f% |; |9 E0 t7 F' n1 }
#if 0
4 V: |! I/ [' z z7 a. g ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 m( `6 j; `' B% Z if (ret)
" b# i/ ~# x3 t" S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% O5 {* J8 J* g" H' f/ C @ "%d\n", ret);
9 f4 Z8 m' l: S: n1 S#endif- x" P# M/ Y# Y
ret = platform_device_register(&da850_evm_tl_leds_device); l* M3 R* t: P
if (ret)
5 {1 u% J# G5 o pr_warning("Could not register som GPIO expander LEDS");; V( c' T- n5 x! k- j
else6 _' \ V* c# l: _/ M# h
printk(KERN_INFO "LED register sucessful!\n");
( @# l6 T; M5 z b
8 K5 Z8 I5 q& U9 y# ] return ret;6 {/ V, n' Q: E# ~3 I7 m, P. t
}
6 t$ M* h ?" F
- g/ M0 [! P* F3 g7 l( X) ustatic void __exit led_platform_exit(void)
! d2 I3 k3 d% s6 {{+ u0 {8 ], j; _* c5 L
platform_device_unregister(&da850_evm_tl_leds_device);# ?. V$ |7 `' }
+ l ?7 D% ^2 P5 C7 p; W1 `
printk(KERN_INFO "LED unregister!\n");" x5 N4 @: Q! t( E' Q
}
7 \$ E: d2 r p4 b% a
' {7 }" S/ |7 ^% _) l/ H$ hmodule_init(led_platform_init);9 F3 J8 U" f' \! j9 A8 m
module_exit(led_platform_exit);! b- i& E3 i+ A3 {
: u# d% Z$ a( [& K: i
MODULE_DESCRIPTION("Led platform driver");
6 ^7 l/ ^9 ?0 L. lMODULE_AUTHOR("Tronlong");& O" K6 P8 R# j+ n
MODULE_LICENSE("GPL");5 G6 Z7 ^8 ?. q) b, n: ]
- s8 k6 t: ]) P# a
|
|