|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 `8 P1 O. |1 h7 e#include <linux/init.h>% O: C6 C4 u/ c- o3 u3 W6 n4 X! V
#include <linux/module.h>$ V! v& s; s7 h9 i$ z! ?& l2 G
#include <linux/kernel.h>9 y! R: n: k: T7 S
#include <linux/types.h>5 U( i; ^, H2 O
#include <linux/gpio.h>
s/ x6 ]6 j. F# v#include <linux/leds.h>
+ n& m6 E# p% C#include <linux/platform_device.h>
4 `6 T2 _, H8 O. d+ p2 b! Q5 D* r* Q6 [$ {) G+ a8 T( d# ` U" R. d
#include <asm/mach-types.h>
9 v) {5 F$ ?, Y) S#include <asm/mach/arch.h># y! G% }0 h) R% U
#include <mach/da8xx.h>6 z5 o Z) R" B N" h
#include <mach/mux.h>: a, f- Q& Z8 L
; v1 m' q9 }9 C* ^1 F#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 K. W; ^# g: e" y( g#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ L+ C. ^5 x" t$ G#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ R" E3 B% n/ ?% r# x O" y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
( Y9 c1 p$ }( U! h9 b8 F; D; r n. J5 X
/* assign the tl som board LED-GPIOs*// B# I3 S$ i+ k' B+ S
static const short da850_evm_tl_user_led_pins[] = {
7 ^; U/ e/ N5 A Z+ S- x, W /* These pins are definition at <mach/mux.h> file */9 h, J1 X* r2 q$ @6 b9 ?. m& n. m
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! y" [2 ?( b; J, X! p
-16 T8 @0 T$ f; b- p0 @) g) x
};
5 a: P" y) `4 z* H9 p
6 s1 ]! J+ S3 F7 X0 y+ ~% estatic struct gpio_led da850_evm_tl_leds[] = {6 s' s; y j) }
{
- Z' z" N- @. C# L" P .active_low = 0,
" Y+ ~7 d7 i) Y/ L .gpio = DA850_USER_LED0,4 h- C1 A4 W- }. r/ g" t0 u
.name = "user_led0",# k" |. S% i: @6 }
.default_trigger = "default-on",% E3 A5 Z2 E% p) t
},
& h+ H5 c( F6 J% ?9 {6 d ` {2 Z" `/ ]" |6 \% g& X. G
.active_low = 0,( a, Q2 y! O: K' d3 u
.gpio = DA850_USER_LED1,6 V8 `6 I+ [7 o
.name = "user_led1",
/ k' z6 W/ N, h7 k) e& r. a o .default_trigger = "default-on",
( H5 B" N$ k0 G- V% ^0 q7 J+ p },) d8 J9 y2 ^8 P$ ]
{- I1 S- A. K) T3 \+ l; a; ^- P
.active_low = 0,1 p, n: h. S1 x y, V
.gpio = DA850_USER_LED2,% T; ?) D5 B7 H
.name = "user_led2",( j# Y% p, v' z
.default_trigger = "default-on",
5 C& ^, d' ?! R5 R },) i5 m3 k2 I2 z) E6 m# a1 \/ Z3 x# r
{3 I1 _1 x& ~+ J& O& Y
.active_low = 0,$ N3 ^& N$ L6 \. Z+ g9 O- K0 R
.gpio = DA850_USER_LED3,
- C m1 F$ q0 E1 E% H; D8 x: g( \" } .name = "user_led3",
4 f: j, W8 r$ _* U .default_trigger = "default-on",( g9 T. W4 j0 Z: Q: G, V
},2 {3 g/ f6 w0 ?7 t
};- e, ^8 P* ]; \2 `
' O) d* t$ x6 B. I, xstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! S9 M; r, o2 T# _
.leds = da850_evm_tl_leds,1 W/ d( j- l5 H, f9 U& f
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
% R1 n7 w. l0 }) Q5 G) w};
1 [+ c( k8 H& i" ~+ x
* b# R1 d& ?# m" c; Cstatic void led_dev_release(struct device *dev)
5 Y1 b9 Q+ i( x$ N% r. b3 N! L{
5 d$ D9 o* u: R. n" r1 n& z};
* k7 E u- l- Q9 s* @+ e, @/ D( w0 b5 Z5 D$ D
static struct platform_device da850_evm_tl_leds_device = {
[! `6 S j+ U5 m; e .name = "leds-gpio",4 k* ^. q8 [3 s, L( q! A$ t! W
.id = 1,& Q* H* d: [- g& `% M( N6 |2 i
.dev = {' R+ r6 H# W' f- I. d% J, _
.platform_data = &da850_evm_tl_leds_pdata,
- w. _' x$ V" n8 S, ?, z .release = led_dev_release,
/ Y$ o( \/ g$ Z: P% E9 Y }4 O, {- \7 O* D9 i( o
};+ h( o/ o8 b+ V8 h# x1 h
~/ P; g% T6 g; e7 B0 Bstatic int __init led_platform_init(void)9 ?2 D5 {2 M1 |' Z) Y) p6 k
{' b! P% v) d! v' t2 y3 m
int ret;5 h( Z1 s/ z' V9 U- P# V9 R
#if 0, o3 V/ a$ R" O) v t4 {* p; b' V
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! h4 v& A( ?& `) A6 x/ Q if (ret)
$ e" J) A' d& V9 a, H pr_warning("da850_evm_tl_leds_init : User LED mux failed :"4 L" D; y8 V; v# f9 O! P6 n
"%d\n", ret);
, Z: T# B R# _: {6 i9 `6 `#endif, `6 O, K8 }) I- }$ \
ret = platform_device_register(&da850_evm_tl_leds_device);
1 l1 f# P1 }! j if (ret)
3 r( }6 w, {' }9 d" v6 Z( Y" _! | pr_warning("Could not register som GPIO expander LEDS");
U0 h9 a2 O& R. |, C/ u9 V else
. b1 y2 y- B7 T% V1 U9 S% P printk(KERN_INFO "LED register sucessful!\n");
8 n8 X8 q* z5 A7 I, }+ t- ?+ x( g% ~, R& ], U% y; N
return ret;4 N; G( d) s, N: L
}" W! H. Y2 C/ f# A) {" b( q
: c3 T9 N8 W5 @" j* S+ s: D+ Istatic void __exit led_platform_exit(void)8 Y- I4 e$ K! l
{
% |2 m5 @5 m/ N8 s$ e. H0 b/ { platform_device_unregister(&da850_evm_tl_leds_device);( h( } i/ G' N. [5 z
9 m9 H5 k8 J" G3 X& C5 X( n$ } printk(KERN_INFO "LED unregister!\n");
2 d$ i: Q$ R! ?8 b+ E, o, N5 U}
5 E$ w# r$ m p+ ^2 E
& Y/ Y1 R" v) K5 i) Zmodule_init(led_platform_init);
: V. m: R# {' V W; F1 Vmodule_exit(led_platform_exit);
7 f" }$ w8 c- T6 d, Z c" D1 D5 z8 y$ S
MODULE_DESCRIPTION("Led platform driver");% L5 }$ g( v* [* q$ Y8 S
MODULE_AUTHOR("Tronlong");1 Z* y0 y. O" D9 P
MODULE_LICENSE("GPL");0 }+ v0 o) Y, i% F
9 s# \; z3 ^$ s2 v( l& J: C
|
|