|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( {: d* k, S6 F1 P
#include <linux/init.h>
$ b; \8 y6 s4 ^#include <linux/module.h>
. | G' `& l- }* d#include <linux/kernel.h>7 K! |6 }* p9 |& C( B4 S' g8 B
#include <linux/types.h>
9 Q9 _; @2 X |) z#include <linux/gpio.h>* V' E; Z) F5 S% |
#include <linux/leds.h>
* ?' ^" O3 ?; s. L9 j" @ W#include <linux/platform_device.h>& a5 G* f, B+ [$ ?0 m
( I% j* O) `. v4 ]
#include <asm/mach-types.h>. q* l0 E& \2 P' j
#include <asm/mach/arch.h>* X3 R6 b5 Q, {8 L. s
#include <mach/da8xx.h>
5 c- ?7 N& ~% |/ S( @#include <mach/mux.h>
) t" c( ]2 U) Z7 u# K8 u& r
$ b3 F6 p5 D% e+ x! i#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 y9 M( Q& r" F& I' }#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)) @, H* B) _+ t7 m
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)+ q ~9 h! H9 Z# s. K' @
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 I( O0 X$ h: a6 \& o) g3 |, f
2 J+ ]4 q8 ]9 A0 t2 N
/* assign the tl som board LED-GPIOs*/
0 P1 R# y# H n- ^static const short da850_evm_tl_user_led_pins[] = {
! _! F; S8 R6 y3 k/ V* u3 } /* These pins are definition at <mach/mux.h> file */
- q/ n6 l X! s5 F; L4 Z. F DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,( f3 J: W7 j( v1 i, r9 u
-13 J2 H1 a: f8 a1 b# i- C$ z
};! O/ T1 a3 x& V. F& h: C: T
7 S- J3 V0 N0 w: a( s9 I9 W# \/ O
static struct gpio_led da850_evm_tl_leds[] = {
; K$ {* ]+ Q, [ {+ r% q# `6 C0 l* R/ ~; A; ?. G
.active_low = 0,* [7 @9 t# V' W* |$ P- c# y
.gpio = DA850_USER_LED0,
4 V* i" @% w- W: ? t3 M: j .name = "user_led0",
* o0 c$ a' q& f j x .default_trigger = "default-on",' k7 c9 b: W1 n4 R* u. H
},6 F8 D9 {; X& N {, ^1 P
{
: m" e9 k$ b5 N0 E .active_low = 0,% f6 i# y- p8 {; B
.gpio = DA850_USER_LED1,
7 z" T3 r/ a+ p( M7 L0 A4 W .name = "user_led1",/ \; g7 ?- E; v9 C c- G. p. G$ @6 g
.default_trigger = "default-on",
8 R4 V* C4 {+ { },* g9 P) x& l# }$ X3 p
{
7 f; t. {* p8 y/ c' p4 R& b( a7 v .active_low = 0,
5 C4 o+ |+ g N" B b% y .gpio = DA850_USER_LED2,* n/ ~( v: A' H# ~
.name = "user_led2",
2 Q, I& Z! v h& s .default_trigger = "default-on",
9 p% \' z; \9 j },
+ n8 A+ |' j4 k {* S1 n) M' t) f# B3 G) D" `" e
.active_low = 0,, g+ h% ], u. r% C
.gpio = DA850_USER_LED3,
- [- o+ b6 G! I .name = "user_led3",
5 `- e# k; R9 o$ E .default_trigger = "default-on",
1 N2 N% ?' F+ w" \& w },
2 ~; L$ d0 k7 a2 W- g6 v}; u' E( U+ ]# `# u
7 A4 r/ W6 S1 k1 n/ T8 O2 |static struct gpio_led_platform_data da850_evm_tl_leds_pdata = { D9 Z- T5 O& b; g: K" o2 T
.leds = da850_evm_tl_leds,
: r E. }5 n; d, @, Q" I .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
" d8 Y) z6 l0 u};
1 s/ u% [" F/ Z @. `
' B& }$ D' F' v2 J) ostatic void led_dev_release(struct device *dev)- x$ L4 h, g1 d, ~9 x9 P5 I0 D
{
. T/ f0 B" q% F4 w+ v3 Z7 @};$ ~1 n% e5 o" [) M
6 o, W9 F Q- {" q6 Z
static struct platform_device da850_evm_tl_leds_device = {+ I. }2 [3 _* n$ P5 q) X
.name = "leds-gpio",, @2 ~( O! ~$ ^" H( q5 t
.id = 1,
# h1 ^7 ~- D. z3 U" o: W .dev = {9 B, @, f" o% Z8 v8 K& I8 {- E2 ?
.platform_data = &da850_evm_tl_leds_pdata,
$ ]' t; S( v; P$ e! ?5 b+ G3 G! g .release = led_dev_release,+ P1 m- D$ _: Q" y1 ^
}' ]1 X6 A# m8 I7 z
};3 N! [$ W& u4 _+ G! N
+ a5 P$ d; L3 q5 K
static int __init led_platform_init(void)* O5 D0 F% W, ], u1 B* B- `
{1 n7 p# [/ X+ v4 E! N( |6 R
int ret;+ {$ N0 g( }& G9 f8 v
#if 08 M. Z4 i7 P: h7 T" T& L ^, n. q1 }
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);( q; _6 M$ r: } E$ {, p% n
if (ret)( d% }, e" I/ }+ A9 k/ B) B! a* _9 U
pr_warning("da850_evm_tl_leds_init : User LED mux failed :", B7 M) L, \3 z) k/ K" v+ ], p1 t, ?$ |
"%d\n", ret);' i0 s9 j5 L; C+ Q
#endif
0 v; W) h$ C4 h. k7 N4 O9 Y ret = platform_device_register(&da850_evm_tl_leds_device);
6 A- K' Y( v8 f if (ret)# @* K! p+ f2 M7 \9 y% [0 j
pr_warning("Could not register som GPIO expander LEDS");
% O2 ]3 g+ W, V6 i% z, r* { else9 u$ {; f4 I B1 M% G, I% x1 h
printk(KERN_INFO "LED register sucessful!\n");+ m3 X, |7 Y, {- k
' N* U$ d O% j: P
return ret;7 |: ?* H9 t8 o( k; a: @! [4 u$ V
}+ X2 Y( q8 t- p
) t# \: m4 N: d1 K- I
static void __exit led_platform_exit(void) B, J0 U" m5 l. H
{8 L3 F2 \/ N, `2 S7 g
platform_device_unregister(&da850_evm_tl_leds_device);
" _4 h0 D4 O- X1 Z2 o6 P: y( S% J2 u f G) `5 r
printk(KERN_INFO "LED unregister!\n");* z1 ?% m5 ]+ s: J8 X
}
/ y! i6 R, Q' u. E! O* ?! y9 V, J& e" b% B) Q
' w* U' i3 T% ~" d- Lmodule_init(led_platform_init);
% e7 u7 q7 _. t, I4 U- k" `2 Qmodule_exit(led_platform_exit);/ C" d* n7 _8 A) g
1 g/ h$ {6 F' |
MODULE_DESCRIPTION("Led platform driver");# q% D R" q* _3 Q
MODULE_AUTHOR("Tronlong");
6 w$ P) W9 F0 }, _3 kMODULE_LICENSE("GPL");1 g; I" o3 C$ [# I. m1 g
+ i8 Y! b: \& e. f. f7 M' f
|
|