|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 R; q( Z! K) Q: h1 x
#include <linux/init.h>5 z1 ]0 w2 z( [, ^5 r% L" ]
#include <linux/module.h>
. j! t; k4 l9 W$ j: s#include <linux/kernel.h>
7 y) R0 B& E' k8 o6 f3 W#include <linux/types.h>4 \& N1 a/ q6 }3 q9 p
#include <linux/gpio.h>
& s5 ~1 K. e P/ x7 I' k#include <linux/leds.h>
( L: p) A/ Z! w5 l. ?/ j7 C#include <linux/platform_device.h>
; p b+ i0 h" }) D, ?2 |* e9 J3 I! A. g% P) l1 P$ \/ U0 B5 D
#include <asm/mach-types.h>
& H, d ^% B% n; A w! n ]0 c" O#include <asm/mach/arch.h>
! X( k$ Z) e" G, z5 f#include <mach/da8xx.h>
. @# U. F8 V6 g! l7 [4 O#include <mach/mux.h>
$ A9 E- V, h+ I5 p! u0 W
) B7 t3 W) l( |#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 S6 S; h* H" k' l p1 C7 r. Z. k
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: q i; y# E/ s) r$ {4 o* H#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( [ z6 \7 S& T% I; L
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)+ [+ d8 L% |. g1 L
$ n) F# [' [8 w0 @
/* assign the tl som board LED-GPIOs*/: N2 M; p a7 b/ e" N3 t# V L5 |
static const short da850_evm_tl_user_led_pins[] = {
* D1 o( h6 u2 O& z' [+ W /* These pins are definition at <mach/mux.h> file */
0 _9 s# G5 Z) E DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
, h. M6 A$ M w2 R0 S. f5 _ -1+ d; ^& c8 z" `( T3 _3 O u7 M4 w
};
$ S$ ~2 l0 @+ H; D0 [) d
4 A3 w) ?$ `: |% }4 h3 N3 Vstatic struct gpio_led da850_evm_tl_leds[] = {; j* n& O0 ?+ h& ?. u# K
{
' \7 {. }. g: }% U8 @% g .active_low = 0,( n/ ~1 i$ Z8 E2 J/ g
.gpio = DA850_USER_LED0,8 b; k* d$ }- g# e' J. M& x: K
.name = "user_led0",
! e) R' f: I1 R0 N .default_trigger = "default-on",
& b( s+ _5 }+ j F },1 l6 K' {. s6 y- C5 ]3 Y
{
0 ~; J5 @7 r" S- p; l E+ m! @ p& { t .active_low = 0,/ F- N/ P* L1 W0 ~! Y( G8 {2 i
.gpio = DA850_USER_LED1,
% _6 C5 W/ J$ ?) |7 _ }. _ .name = "user_led1",
6 e2 J* y. Q4 Q0 w* [ .default_trigger = "default-on",
% z. r& ?) _ U) k" s1 t z$ p; R },
! x4 N( X' `* R t {
9 P$ b1 X5 ^) d .active_low = 0,
/ ~! H6 o3 l* H+ P0 \2 P, g .gpio = DA850_USER_LED2," s9 r2 |7 e4 [$ n7 n( M
.name = "user_led2",
* V' s' P! f$ j1 i) { .default_trigger = "default-on",
3 Y2 ^' G: ?$ c* V* q* Z3 A },. p% k: C! z$ B- u* j# d
{# _& {8 t( [) F8 T$ b
.active_low = 0,
' _. {6 f5 r; w0 f, Y .gpio = DA850_USER_LED3,# l; d" h/ E9 {, ^
.name = "user_led3",9 _7 l; @+ ~, Z, J7 B2 d
.default_trigger = "default-on",$ f6 A! @/ V: a2 t
},9 y( v6 N8 G+ g& K
};
+ F l/ S: h: K3 f: D6 O* W' d) }
3 e: T8 |# L" A6 z$ l; o6 b4 Ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = { h6 e) X8 a8 W- P
.leds = da850_evm_tl_leds,1 o0 e- Z( g# k0 E. z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 b& v( p1 p9 F& z
};1 N' B! R$ k2 z+ L9 S, r6 B
/ H+ |2 p0 _4 s" v5 T
static void led_dev_release(struct device *dev)
. q3 B/ w: I/ a3 H1 g' Y+ M{
" g! f3 V: a* v+ b# B};$ m4 A& V3 W' Y2 b! }
: k4 f g/ q- ^" s+ ?static struct platform_device da850_evm_tl_leds_device = {( r$ `+ v$ k) N9 S. z
.name = "leds-gpio",$ n; {1 ]; R8 t8 C% M0 f p
.id = 1,
- {. A' w5 R$ V .dev = {6 u3 \$ C( K/ U. y/ w3 l; C7 B
.platform_data = &da850_evm_tl_leds_pdata,
6 n. | C/ s! k& E `/ S .release = led_dev_release,
5 `+ U# E. Y+ ] }
_- _% K T' n5 j; D};
p# w' r/ a" [0 R
( [4 u$ q' e$ C2 B7 \$ D1 A+ Xstatic int __init led_platform_init(void)$ ]) i+ O( m4 D6 o2 ~+ r
{
8 B3 P6 p( r9 p+ g- [$ d2 D int ret;* M+ M; X5 y: `) e1 h, g% ^
#if 07 f- g4 |4 G6 s6 E) c5 x
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);8 T5 Z$ P* N, b1 q
if (ret)
a0 U/ U/ R% L# u) }8 H pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- e3 B) V/ L, k1 ^' Q7 H
"%d\n", ret);) n* C0 W8 T% \! U: P V
#endif
# O1 q- y( X- O5 D: S% h ret = platform_device_register(&da850_evm_tl_leds_device);& g" L. l% E' X. r) \$ g/ {6 F! O9 k
if (ret)
* D$ W( D5 u1 l, @. K+ @ pr_warning("Could not register som GPIO expander LEDS");
( U9 K% R& I% h0 s7 O else
3 a) k" I7 o0 x+ l' P printk(KERN_INFO "LED register sucessful!\n");
0 L$ R5 m: N2 z9 {3 o) s( L l8 h* f" k! P) \
return ret;
8 o0 [9 `* P* n/ m& S z}: P% z# } X! E* y4 _; C0 W& b, H8 Q
( W/ P: l J* Sstatic void __exit led_platform_exit(void); ]! D, C! ~1 U' S2 V5 s& q
{
0 S6 i( e; n& }" d1 E" N2 W5 G platform_device_unregister(&da850_evm_tl_leds_device);' w3 W: y% ~$ I' \3 w9 ]" o4 ?
, Z6 Q! |; f+ ^0 t5 @+ o; B$ z' | printk(KERN_INFO "LED unregister!\n");& g: N0 S) q- _# }* p. K# w5 J
}( m7 E5 L) q+ O0 |' `
. Y$ {* o* y tmodule_init(led_platform_init);
9 V3 o2 k8 N+ Q8 dmodule_exit(led_platform_exit);
% x! @7 C5 e+ a' L3 w* N& S/ L5 i
! q2 Q2 T4 h5 ^) Z2 I* K- K sMODULE_DESCRIPTION("Led platform driver");" B- @( E7 u- ]9 x3 J$ y% W! w
MODULE_AUTHOR("Tronlong");0 i8 t9 S6 N9 A7 {
MODULE_LICENSE("GPL");; q1 d" c! @$ e1 T' H
3 w2 B X7 `# f( L0 }- V; u |
|