|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
/ o- V+ `5 ?$ M6 O9 i# x1 T#include <linux/init.h>
6 C+ F- i9 n. G& i#include <linux/module.h>
* V* J& Q- G, e& c" \* i#include <linux/kernel.h>( L+ {! @7 g' r8 V0 ~- c. G0 t4 Q1 n
#include <linux/types.h>6 Q4 b% O: D9 d0 I
#include <linux/gpio.h>
3 l) M; i# X4 z* q+ s#include <linux/leds.h>$ O4 M4 ^9 {7 A0 w4 Z2 y6 E
#include <linux/platform_device.h>
% d( c7 X& \! d& ]" S: y6 @ o! M% B% ^2 Y' r9 K5 i
#include <asm/mach-types.h>3 u, f2 p) r" R) G& E; `
#include <asm/mach/arch.h>
9 ?* H" K0 R N. \% s; z; v- i#include <mach/da8xx.h>- w) C; }. s' n% J) N. e# e- Y
#include <mach/mux.h>' g% r- G* M+ l; |' U
}* t( a) @: u
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ u" I/ V0 w) V#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
' Q/ d D1 f& U- Q# i( b#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 i4 E% L" J N7 m4 A
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)# w" C1 C! L9 i2 \2 L* W
, s6 ?) A2 O: H/* assign the tl som board LED-GPIOs*/- p5 ?9 A* s/ Q" c: n5 \3 s
static const short da850_evm_tl_user_led_pins[] = {
5 j; G; b- J$ h( T( ~ /* These pins are definition at <mach/mux.h> file */
* S* T& H! e5 P3 E DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,) j% E' ]: i: ~& b& L# t
-1
9 W3 k$ {0 `7 _$ b$ m};/ Q$ j, U- R; ]9 f9 _, J
) e/ @. j) O6 s3 tstatic struct gpio_led da850_evm_tl_leds[] = {' I# }: ]8 T, H4 @! H2 j2 E; [7 V
{2 {9 x( h- ~* g* ]
.active_low = 0,
+ j4 m$ S2 S9 Q/ ?7 Q .gpio = DA850_USER_LED0,0 ~. {1 o- @. z; l. P
.name = "user_led0",
# o+ H" _: Y |* m0 O* X .default_trigger = "default-on",8 i+ E' Y4 S4 z
},+ K$ W5 P/ B' v, l% ~( @' _$ p" _0 @) O
{0 C5 B4 j+ S# F, }0 K
.active_low = 0,( C% E6 x8 o, `; w; s
.gpio = DA850_USER_LED1,2 X' |0 t& x' s2 H5 ~# T
.name = "user_led1",
6 t( t$ v- \2 g, _- E* H) \ .default_trigger = "default-on",; P) h) r: U! a/ X: Y. g: f% R& n3 n
},5 {) j0 D. _% z: t8 D7 l& w9 l
{
; u" x( j( ]' Z& E2 u .active_low = 0,+ |8 g( x' h, i4 \
.gpio = DA850_USER_LED2,5 C. _% l! A. c5 z
.name = "user_led2",! v4 C. E( {4 B, F
.default_trigger = "default-on",
0 W0 E- M: h2 q( t5 M: [ },
" P) N( y3 Z7 | {; b U6 Q' g6 C& s. P/ \7 I
.active_low = 0,
( d, y! s! S; C. { .gpio = DA850_USER_LED3,
3 Y' _2 q* e' s1 n- u M) H .name = "user_led3",
2 e" }# g! u- W .default_trigger = "default-on",
& p8 q$ [$ ^+ J: t+ j% p6 [# T },
9 g8 ~& o4 `9 z; f" r9 B0 R};
2 D4 v* h5 X! W, E0 E2 s& C6 B* n1 ~% \3 N0 N) i
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ D9 H+ |( B. q. E& \# z6 X
.leds = da850_evm_tl_leds,- Y+ P- p* t( @
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),6 w5 E) x9 |4 H1 \- E$ R% q
};
' X9 L5 W- X9 t) u
5 B1 Z& z6 a% E/ mstatic void led_dev_release(struct device *dev)
! Z7 V0 A' C8 R. F{# M2 C$ Q1 J8 e! o+ a; ^
};
9 r6 Y4 g6 U! C; i+ `. s1 V) @3 W3 d: ~; h' ]$ f
static struct platform_device da850_evm_tl_leds_device = {
, A5 G! x' {- m0 p% i/ ] .name = "leds-gpio",
, x2 m' H% V# D- ^8 @ .id = 1,
' O' n3 S# l& Y1 r- o' P7 C .dev = {2 D/ j0 n) I7 [& A4 W- ?
.platform_data = &da850_evm_tl_leds_pdata,
/ o3 K3 }8 ?* G6 R9 ~2 o. N/ } .release = led_dev_release,
$ I" \( t7 k2 x! Y( L9 u; ` }
+ S( I" y! G; d' p3 x7 R};
% f) e0 j- P8 j9 [& r; A$ p. C
2 C9 o4 l/ d" B, Xstatic int __init led_platform_init(void)
" o' e1 p: ]8 I8 p" ~{
: F! R2 d0 M/ r7 L" T int ret;
+ @2 B8 o& V4 c; ?, |6 Y6 c#if 09 `, W" f P8 T" k
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
' Z4 b; ~% V7 j1 G, C$ M% i% H if (ret)3 b- |6 R) @: z. m' R! `
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& q; F. `. m- P0 D6 w$ [
"%d\n", ret);, _/ v" d1 u9 B1 v
#endif" A$ @ ]! q9 r) R# z- v% A
ret = platform_device_register(&da850_evm_tl_leds_device);% D0 P6 Z0 o8 k( ~ [1 M
if (ret)
$ V8 m' _" D& S. y+ G pr_warning("Could not register som GPIO expander LEDS");
& f* r; {2 U1 q! v# `2 B5 \ else$ u, f. o* a- y/ d
printk(KERN_INFO "LED register sucessful!\n");1 u3 _0 Y$ \5 J
. S2 }" d/ f" X8 x) H5 m+ C& {, d
return ret;; i; R y1 Y9 { Y6 k2 D/ f
}2 `/ ]% ^' g7 u9 {& J
$ ]6 ?7 R& a/ {9 _2 V( e* L
static void __exit led_platform_exit(void)
* _% N3 {) E# j0 t, [0 f1 c. m{
! b8 _3 P! `$ q; E1 o platform_device_unregister(&da850_evm_tl_leds_device);4 W1 C9 ]9 j6 G8 m6 \3 r
, l$ s+ R& L C y
printk(KERN_INFO "LED unregister!\n");1 o7 f' s5 }+ X& x1 u' x% X8 C0 H( b
}8 Y5 A* e4 {, T# M; H) Q
! E% o/ [+ g( `: rmodule_init(led_platform_init);) [0 {" ^2 ?7 o; y9 v% U+ u" Z0 R
module_exit(led_platform_exit);! f, @0 w' \! T7 R3 ]5 C
: h8 S6 v z2 ]4 a/ e0 I9 q" yMODULE_DESCRIPTION("Led platform driver");
* z! m) ]6 I4 `; Y9 T9 q1 rMODULE_AUTHOR("Tronlong");
! g+ w0 {+ ?5 CMODULE_LICENSE("GPL");/ p8 E- q& r, B# k; N5 A
4 f4 Y$ C8 t6 y9 o& {# J) t. T
|
|