|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 N: T9 k% D! @+ g Q$ X#include <linux/init.h>+ B& s' h4 {* s$ ~9 A9 }
#include <linux/module.h>6 G) E2 B4 ?9 J3 d1 m: g6 F/ C
#include <linux/kernel.h>
7 U. T4 O t4 ^+ c2 N' j. _#include <linux/types.h>
( [$ U- Q0 U5 K. O" C+ j#include <linux/gpio.h>
8 e9 n1 `2 u2 ^7 Q9 B* ?. Q#include <linux/leds.h># |6 n$ m' l0 @1 f1 i9 `# {
#include <linux/platform_device.h>& b, Y( y$ X5 m3 M( o2 [
G: N- W; t, V1 H, M) a
#include <asm/mach-types.h>1 X/ M+ z5 Q3 f5 l- n
#include <asm/mach/arch.h>
* G7 i# I# `. G/ t#include <mach/da8xx.h>6 W7 q7 v6 Y+ c" o$ T+ |7 V
#include <mach/mux.h>
$ z6 H6 ^5 `4 O7 S T9 E- p+ Q& w8 @' `% {* N# H$ U
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
0 n% Q) Y1 o# O6 [. b. l6 L#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 @: Z# u- U C% d5 \ V$ r6 r' F#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
_: i) b4 \' O+ [( U3 s% ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
! B6 ]/ a: u) ?9 z. g
. ]5 `6 d0 b9 Y5 @/* assign the tl som board LED-GPIOs*/4 Z2 T; A/ ?9 Z: b* s/ {
static const short da850_evm_tl_user_led_pins[] = {1 k; J! d0 v4 b$ {/ w& W7 y
/* These pins are definition at <mach/mux.h> file */# G4 @6 d( f; _4 d5 b! H9 I
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
; p% E- N& G. z R9 ]" k -1
5 t0 I( \+ X$ ~- i}; p; O) k5 q a& Z+ f$ o6 m
* F: ?- ~8 U" C: u
static struct gpio_led da850_evm_tl_leds[] = {
9 `! t" p N+ P {; o' Q8 Z9 a" ]3 ]- K
.active_low = 0,
$ s% c4 b F( P/ `+ [ .gpio = DA850_USER_LED0,0 W7 N T. C% \
.name = "user_led0",0 w2 P( T6 q V6 A" U s
.default_trigger = "default-on",
1 k, Q* u u: V/ S0 R m },! \" M0 B' G/ w/ u8 `
{
, ] j/ l, f* R .active_low = 0,
2 M9 Y! x' H$ A6 b* R7 Z3 X2 d7 V .gpio = DA850_USER_LED1,
! g! g) c7 D8 V2 J .name = "user_led1",
3 ^4 e4 }- R2 [6 U, i .default_trigger = "default-on",2 z7 W$ p1 Y9 v' h9 l
},
- K4 K ?* @7 ] {+ d4 g7 ?' b b, p+ @1 }# ^
.active_low = 0,
( q, v6 R Z, V; ` .gpio = DA850_USER_LED2,
1 c$ |( o& e0 ^ .name = "user_led2",
2 X) E/ Q8 W% T# K- Z& z7 g .default_trigger = "default-on",2 K5 q1 p$ w" b& L! O
},8 S, V- S+ q: V7 ~6 V+ t/ B- K' |
{
% W. D7 X9 J1 p .active_low = 0,$ v/ v( O4 G8 k+ L5 o( ?1 X6 F& I5 Y+ D
.gpio = DA850_USER_LED3,6 l& R5 \1 w6 q, f f. d: T8 U5 ^
.name = "user_led3",1 F3 }$ e7 j3 Q' Q3 [
.default_trigger = "default-on",1 M$ o7 e5 t; g9 k
},
) E0 q( s% h3 ?/ R. y8 M};6 c* X" I* S8 v" o3 f' e
' s! x/ ?; [+ z7 W9 Z' W: u# H
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
% [" q: d) R/ e% P5 H: R" H .leds = da850_evm_tl_leds,4 I/ X; A4 A4 e; k
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 g+ \: v0 G+ B4 R$ T% J};" V) j9 p3 ?1 T, |
6 c+ r/ L0 L8 F
static void led_dev_release(struct device *dev)! _! L( [) H- p: l6 z2 G+ w; o8 y
{
( x% y5 D ]7 [}; N z, b5 ~ F' n7 T: V
- L; v* f. f# I5 |" y4 jstatic struct platform_device da850_evm_tl_leds_device = {" g/ Q; Y- e* W( D7 z. q6 ?
.name = "leds-gpio",8 u L& a& w5 I b, r
.id = 1,8 R" }1 n8 T$ t* i" G: J9 k( D9 O
.dev = {4 y5 r4 W. N2 p5 }5 s# k
.platform_data = &da850_evm_tl_leds_pdata,8 [$ w+ W5 d& P4 ^4 F
.release = led_dev_release,. E, U- ^ V) x8 g5 L. p
}
, _$ z/ u: c2 E/ z- i3 e# Y0 P3 D b};
2 P8 h, S. _' T+ n7 I# H4 L" c! h& L) x
static int __init led_platform_init(void)
- V) w7 c1 D) E1 E6 W7 ~0 ~) q{" r% X* ^4 p; ?1 k( ?! x$ J
int ret;
" @9 W7 V8 i5 d#if 0
0 [! |/ @; C7 j) r0 X ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
, x: Z2 |: M @- I/ r1 y. }( d if (ret)7 c, R s h! n! p: W
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; |( p% h( f* r
"%d\n", ret);
: {! f% s; N2 h" M#endif
/ ~. @0 x+ _: K9 `1 N+ A6 q ret = platform_device_register(&da850_evm_tl_leds_device);
$ L0 S5 D$ N. T u$ ~* m if (ret)
3 r% o. a% M4 a( l& F8 _ pr_warning("Could not register som GPIO expander LEDS");* n" ~" i; n7 I' q4 v
else
' G, w; m) ?+ a! C printk(KERN_INFO "LED register sucessful!\n");
; \5 N) N; U: U- |9 S, e$ e; t* Z' H: E6 h' x/ G
return ret;* ~. _! |1 w# }) ^2 Z: |
}
# Y- y% L, ~+ O( x! }
* v5 y9 c4 A9 `# V% ^1 nstatic void __exit led_platform_exit(void)
' y. ~( A. M) w+ Q; H0 R{
6 w0 q1 G @; k) Q platform_device_unregister(&da850_evm_tl_leds_device); l0 X o" F! C
# M1 ?7 ]3 h6 x, S# Y! G printk(KERN_INFO "LED unregister!\n");5 k+ a" c! V6 O \9 n
}3 w* Y; o' l' L; J* B( r
) M, J7 v$ Q( p9 R3 }+ d6 N
module_init(led_platform_init);) L6 D0 | L# k# {- X1 o
module_exit(led_platform_exit);# o9 I3 ]2 j% X+ _" G3 v5 u
0 ^. G; e( v% j2 @2 s
MODULE_DESCRIPTION("Led platform driver");! H0 _/ U) ]& U* W3 O
MODULE_AUTHOR("Tronlong");
5 j! d5 z' Q3 u* b$ S' V6 ~MODULE_LICENSE("GPL");2 D3 P' u+ Q: n# @5 J
" |/ `5 `1 N+ E) P/ a1 j |
|