|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ }: A* h7 s7 e0 S; `" E4 h% P. `
#include <linux/init.h>
# _* P/ Q0 v& [$ K- l% A$ g1 _#include <linux/module.h>
9 l) s6 o5 R# q/ d#include <linux/kernel.h>( n% b; y, C3 g4 p! q
#include <linux/types.h>, {6 P8 a& Y4 ]5 n: \
#include <linux/gpio.h>
9 W3 J6 M( }" o# t* J#include <linux/leds.h>
! `' U$ n' ^% @/ a5 X5 z#include <linux/platform_device.h>/ Y: ?+ \* }& U2 K7 g
7 f$ X# G" E/ ]9 ~#include <asm/mach-types.h>
* Y" U. f( ~# r" }4 ~7 K- T$ E) s' p#include <asm/mach/arch.h>
' q) l2 _" C3 c% N4 L0 K# s#include <mach/da8xx.h> X0 s' V. H* R/ s* R' s( ]4 R4 f
#include <mach/mux.h>/ k7 t Y9 s, U0 `5 `' x
" e" a" b7 Z/ {
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ N; }/ }8 { z0 p- N9 h: i, O$ f
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)+ J+ X8 @2 Q! s' P' u
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
7 e: v) Y2 z1 u8 p#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 _4 ^9 W& L8 B9 \: c
" [8 ^+ E8 l' f& H2 \8 i% p0 R0 z/* assign the tl som board LED-GPIOs*/ ]( i! s0 u/ C9 c1 J1 n9 J
static const short da850_evm_tl_user_led_pins[] = {; O, L" m$ v ~; r. C( V
/* These pins are definition at <mach/mux.h> file */
3 _( W( H- _3 v7 Q% q DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," d4 X5 }5 q; t
-1
- N3 D3 j- J; V$ @$ g7 `1 @% Y};: s& ]2 S% F% s; p5 ?' c' D" b5 h
8 @; I! h* [: i c
static struct gpio_led da850_evm_tl_leds[] = {3 G% Z! z V' Y; T# m9 k
{0 U6 ~3 A6 `8 P8 |2 K8 a
.active_low = 0,
5 Y4 y/ |& D3 M% z .gpio = DA850_USER_LED0,
% m* {" V. ?: A .name = "user_led0",
3 C6 J& O! N! E8 d .default_trigger = "default-on",$ Z% d1 o: l- e$ g
},+ C* F" {* o( W) \' W( F. X& s, J
{
6 F% R- D4 I8 _2 g6 I7 e+ x) Z3 T .active_low = 0,2 R# |' x, Y& N/ o2 ]" N1 H
.gpio = DA850_USER_LED1,8 Q. S, ~7 v2 f8 p/ ]
.name = "user_led1",
% D$ N/ A5 Q- z9 T5 F- | .default_trigger = "default-on",
, w1 U6 X1 L3 S5 o- R0 S0 ` },, w* A' k$ K# D& G
{
8 }1 b6 C3 ~3 P# K% F .active_low = 0,
; {0 R! T) p& w. _8 ^4 l2 A .gpio = DA850_USER_LED2,& ?* X* P$ N( x% q Z
.name = "user_led2",1 Q6 X1 k! q+ j
.default_trigger = "default-on", R" f" B* r/ h3 O: P9 r
},
2 }' V f6 H2 }6 v/ c! r, `6 m* v; X6 M {( ]8 @8 Z: B/ y; p) i
.active_low = 0,
6 y) s* f9 x! T6 M& P) @6 L .gpio = DA850_USER_LED3,7 P0 z0 R4 b7 |# M T: Z% B. O: R
.name = "user_led3",
3 p' Y/ {# W, z1 K, g: j: ] .default_trigger = "default-on",& K D+ |) v) N0 r7 O3 e$ p1 x
},
$ { e; c+ {: x};& M+ @ V& K5 Z5 j* t2 r
9 _# u, H2 S* O s" J6 o
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {+ i+ z; T1 Y8 Z2 m
.leds = da850_evm_tl_leds,
- S, d J& D6 w. H( V .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ c0 t5 c4 @, T2 U- @7 W};# i3 n( y1 ~3 k; g. ^9 O V: o
/ u9 W: [7 H+ G5 z9 V8 i( J
static void led_dev_release(struct device *dev)& Z; S0 Z1 O/ a* Q
{/ ]* ~4 b! W$ i4 x) x
};
- \8 D) p- M" U! R7 i$ e
, u- q* ]" l! z, A4 n* Y" j3 Istatic struct platform_device da850_evm_tl_leds_device = {# }. e: }1 W, B1 b0 f
.name = "leds-gpio",
6 ^$ R/ l k5 } .id = 1,
8 Z: o& l1 b' Z1 M: e5 Q .dev = {: ]5 N6 d9 Z4 f \$ d$ p
.platform_data = &da850_evm_tl_leds_pdata,
( ^' {$ K7 \/ ^ .release = led_dev_release,
: }$ G- m! |6 \$ F0 F }$ P: P( U% W8 T* c
};
' h& ]/ T& O! N) l, R9 `! i
# k& m7 ~; c5 N! K9 A) |# u% jstatic int __init led_platform_init(void)6 q" p. M2 @9 b2 }0 j9 t
{
- W! A- D: h' [' P int ret;
( S7 M2 Q1 P- T) r: q+ X( y#if 0& I4 v& e; v2 A( K/ l: B8 [* r+ }( T
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);0 ]& m- U4 v2 O* K
if (ret)8 S7 X! u/ Q8 m/ r2 ]: c% g
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
" `2 _+ B1 b; g% P; ` "%d\n", ret);; \: h; _$ z7 [; W% o' D
#endif
2 S( m, x$ X- r& C/ W* A ret = platform_device_register(&da850_evm_tl_leds_device);& h1 `4 F1 }6 L+ A5 W: ?
if (ret)) }) c( k1 T$ ?7 d% I
pr_warning("Could not register som GPIO expander LEDS");% H3 o4 S0 ~8 S
else; x3 `; g1 d8 H, F X; | _
printk(KERN_INFO "LED register sucessful!\n");
( A5 A* U* Q7 X% n K( s% c; S* a3 p
return ret;% {1 r2 x( E; N- h
}! g. U5 v* X% L7 t" G$ M. Y: r6 r$ Z
# Z' T% l# k+ Z6 [& Nstatic void __exit led_platform_exit(void)
5 L8 h" V0 P2 [: _2 ]/ s8 l) F# y{
% [" ^$ D" k. X Q0 n- o platform_device_unregister(&da850_evm_tl_leds_device);
7 T1 F( ]- p! g: K3 a' G) s& Y9 |& R' s, e
printk(KERN_INFO "LED unregister!\n");7 O& t) c6 [; p0 J! t/ | Z% f
}
+ g4 g$ y0 D( ]! b
" X9 m+ `+ M/ X4 Tmodule_init(led_platform_init);
6 |! `# H' i3 s9 \: Pmodule_exit(led_platform_exit);+ C, i. a" s+ l/ j& N/ A* b5 Y
# o9 e' l$ {/ [7 n# J. h
MODULE_DESCRIPTION("Led platform driver");) P9 Q# K9 S3 t
MODULE_AUTHOR("Tronlong");
9 e! p7 O( B3 _$ \# M/ {MODULE_LICENSE("GPL"); Z: {5 b3 T6 _2 \1 q. v# s
% @8 T' a. ~ R+ u, Y9 l0 O5 g; R, _
|
|