|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ E2 O) ~8 [8 X. f) B/ K1 a* Q' a
#include <linux/init.h>
/ e1 A% P+ K7 V#include <linux/module.h>" n# I) E9 s4 c- @; H! I6 h# \
#include <linux/kernel.h>3 L0 d/ o& M X1 }1 }% o
#include <linux/types.h>
* E0 M; p) k% L; H9 z#include <linux/gpio.h>
6 F/ D& S/ q" ^. e#include <linux/leds.h>, R7 W2 @ j5 @$ @6 ?
#include <linux/platform_device.h>+ C; N* ?+ s# b$ y
: [+ B4 p" A' A( ~" }1 L( y
#include <asm/mach-types.h>
( a8 `/ F" H8 h' L8 C3 t$ V+ U' L#include <asm/mach/arch.h>' l& ~4 J& b9 `0 T* k7 ]3 k
#include <mach/da8xx.h>- _' N6 S$ A* p$ H6 \: U5 c9 J
#include <mach/mux.h>
( v3 k1 N7 x5 K. H' k2 S0 U
) z% f; }5 C, X0 g, o#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
/ }+ Q. o8 t/ s# k# o#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ w; G% }. s/ a8 ?- f3 V#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)3 W/ J, u: f, q7 U. m
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) V/ J7 v! R5 {5 [" l1 {, ^. }: s
6 l% S7 k; b- n7 `/* assign the tl som board LED-GPIOs*/
7 t [2 ~: b) F4 x+ v1 Cstatic const short da850_evm_tl_user_led_pins[] = {
- G! e( i- `; a) G /* These pins are definition at <mach/mux.h> file */4 }% Y6 G# L s! i, X4 N J' J
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ ^& i4 i Z: P7 a( v8 s -1, ~. _: J3 o h; ?9 h U
};" T" I/ d& C8 |& h/ _
8 {5 {. J; L2 L3 w: `
static struct gpio_led da850_evm_tl_leds[] = {
4 K6 F1 N9 I% R7 K) Q4 h4 }7 |. J {
3 N6 k9 F7 h+ }) W" m9 U! V7 \0 D. v .active_low = 0,5 a+ J! k2 }8 @6 N# X* Y1 L
.gpio = DA850_USER_LED0,0 r; K0 ?( F& N/ L4 e$ \8 Z7 |2 m- e' M
.name = "user_led0",
1 s# G3 V4 W8 l .default_trigger = "default-on",% l+ N" [# X4 D, x
},
+ B7 g8 _9 t6 ` {
/ d J' Q$ l& d8 A, z" H2 w9 x .active_low = 0,
. Y4 B$ R& b" l0 q3 F' O .gpio = DA850_USER_LED1,
& f6 K5 \$ z' ]" a0 x$ ~& U .name = "user_led1",1 C( N( n, z* k* k4 z
.default_trigger = "default-on",
a, }9 b* Q0 G* x0 z7 _ },
. }; Q0 X5 K4 q8 R$ e- m5 F {
4 Z5 |6 o# f8 p8 Z4 K" U9 C! l .active_low = 0,
4 G/ R* z" J) I5 B W .gpio = DA850_USER_LED2,
7 V0 v- D4 r7 I8 w i' o .name = "user_led2",
9 V: D- i) r7 {- P8 J .default_trigger = "default-on",
5 f6 X+ T- O1 d) U/ o& \ },1 V2 A1 _2 r* ^; w' F+ ^% t& I r
{
+ j, D7 b* \) h. X: [; x) K1 p .active_low = 0,! h0 ~/ I" p, q; U8 V; ~
.gpio = DA850_USER_LED3,
5 y1 a! f4 E' r) M .name = "user_led3",- V. `$ {+ j: q' F
.default_trigger = "default-on",
q- K7 K6 Y" F1 X( D2 }5 A7 Q/ L3 m },, z' Q, E- j6 ^# }" H$ U/ q3 R
};
" N9 w6 r2 [) `" F- i; G Y. P; ^2 l! |% s
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
' g, H9 n8 G" R' y9 T- w .leds = da850_evm_tl_leds,+ Z; L2 g0 Z& [( R, D* \" y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),. K* g4 p, b0 e# A# }! t
};9 v6 c! \1 `- E$ C9 G6 ^' F* ]
6 x$ o0 j+ I1 W( y+ |/ S$ ~5 p7 J6 F
static void led_dev_release(struct device *dev)5 s R, @3 g$ n1 }3 l3 b* ^1 N3 `
{9 d# }; W$ m# p* N
};
( {: K* c9 S- S' m6 W) x2 f5 F& T; ~* i, @3 y
static struct platform_device da850_evm_tl_leds_device = {
& w$ a/ F$ g1 L) `4 @" i1 @ .name = "leds-gpio",
3 @! {3 J0 A2 b* |2 S .id = 1,( \$ n p: C" ?: F' ^, p8 w
.dev = {
; I4 @+ U4 B5 \& x. u7 \$ a .platform_data = &da850_evm_tl_leds_pdata,/ W7 x+ ?( A) @8 k4 F3 A
.release = led_dev_release,
/ D6 q0 }+ o: l. ]$ i% L2 J* p }2 L9 n" S/ Z- n2 D6 y2 q
};1 L w) [2 u& [7 P& c( J
( O* h7 W- b+ r* Z# _4 o- {( C# y# Ystatic int __init led_platform_init(void)
3 j* R+ u% ], A{) c. t5 j0 V G5 q
int ret;0 ^; K$ m3 K! I' @
#if 0( {: }" Q; o' R# q9 D, Q5 p+ ^
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 R Y0 T/ |8 }4 _4 w! j; O3 c6 G3 d5 l
if (ret)
3 V; p+ u3 e. K pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ @% _- Q* ?- r( }2 t "%d\n", ret);
) V" T% a3 a' I6 a8 P#endif
6 P2 P8 _3 G4 a: R% f: d ret = platform_device_register(&da850_evm_tl_leds_device);9 a* j+ [$ A5 S$ N2 r9 c
if (ret)5 ~$ J2 x, W: n: _4 f* z
pr_warning("Could not register som GPIO expander LEDS");
+ i' e/ W: k; }3 O* _3 @$ W, l9 s else m# T4 h6 K3 s# _$ g0 d
printk(KERN_INFO "LED register sucessful!\n");0 b( _6 [% k2 g! m9 E$ ?. \2 X
. _4 G G& H2 t( ?9 @5 O8 ? return ret;
v: S" r. c {8 d6 Q}
$ C9 q" V# g: l8 G7 b
, l" F J0 O! F8 fstatic void __exit led_platform_exit(void)
/ P/ w2 f y- s$ f( U* b{, M: |$ O' {: g7 s% c, i+ @7 M
platform_device_unregister(&da850_evm_tl_leds_device);' j1 R, N5 Y% g
( Q2 i, J' ?7 Q# r3 C printk(KERN_INFO "LED unregister!\n");
% b |; v6 p# R7 E7 z$ s2 f}7 L) q6 a# _( ^, G ]& u$ B
) `: V/ X" w, _4 I2 ^" ?2 {
module_init(led_platform_init); v- \0 L' M) q
module_exit(led_platform_exit);
, j% n& ^4 ]- ^: \" x3 h7 \+ I% e" W" b: O2 E
MODULE_DESCRIPTION("Led platform driver");9 J/ t, i+ X# }( |# }
MODULE_AUTHOR("Tronlong");4 H1 l4 f9 O1 n# D( N
MODULE_LICENSE("GPL");
9 q- P) u# ~) u6 I8 H+ M$ u
! q0 M7 h+ Q8 W5 G& B |
|