|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ S! T8 K: [8 I+ H1 C" Y1 B8 \3 J#include <linux/init.h>
) x: D+ Q7 C$ F* V#include <linux/module.h>/ L) I; @7 g2 c. m, q8 e* O
#include <linux/kernel.h>* K1 ^( I! J" R3 B4 q) s7 p; }
#include <linux/types.h>
* [# R5 R. g2 w( h8 G. w7 {- W#include <linux/gpio.h>
# ]$ X% P: t, k k0 a7 O' C0 V#include <linux/leds.h>1 r, u3 Z% _4 U) v
#include <linux/platform_device.h>
8 z; x5 G! |! `9 B+ v# u" Q* \2 X/ H
#include <asm/mach-types.h># Y; H5 s; j' q$ S* s$ w! B8 i P
#include <asm/mach/arch.h>7 h. q* r: j3 V# K/ E* _
#include <mach/da8xx.h>
# F: A0 J; {$ r9 B7 X* d$ r: V#include <mach/mux.h># C! t1 |# T2 T6 K' b
) ` B; Z. G. [: n c* C
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ A0 K$ ^9 u" Y; R) t
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 L3 k7 z4 v! J# q% \2 ~#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
}/ D* X, T% T. W6 c% C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); r8 a% Q$ g8 o- P* E
! J7 D3 S6 O# g% {7 I$ M/* assign the tl som board LED-GPIOs*/
7 n3 E3 \8 _8 h. l! g" jstatic const short da850_evm_tl_user_led_pins[] = {+ b: h( T2 {" M' k3 Y2 M. v
/* These pins are definition at <mach/mux.h> file */
8 O2 h9 l% `0 q2 z2 | DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# r, E& C2 u7 y# q7 U -1' s+ V7 t( x9 ?1 |$ i5 Y N3 S
};
( P. h6 x" y+ M% p5 j, }3 I$ a" A4 Z/ e; S, H4 e. {7 \; z
static struct gpio_led da850_evm_tl_leds[] = {
; m: D- L3 o" a/ i3 R2 W {
T2 L2 [9 M" [$ k/ s .active_low = 0,
& B7 u/ Q) ?, d! | .gpio = DA850_USER_LED0,- [0 k* h: K& R# y9 Q N; |
.name = "user_led0",$ _9 U _: y& J" c2 f! k
.default_trigger = "default-on",
1 t2 n0 o# Q- k& V5 ]8 E7 G ? },
# H2 ]5 U: E. m {5 X& w1 k1 ^( G* D* B$ ]* F
.active_low = 0,
! Q- j" B- q+ O6 J2 Q .gpio = DA850_USER_LED1,
5 k/ t& S4 b+ g% g .name = "user_led1",+ I8 E, U }; f* a7 s
.default_trigger = "default-on",
7 O) L9 i% q% D* j2 M t. B },
$ ]5 A$ u* i2 [' d$ m' @ {0 m8 {" y. T6 o! `, Y) v4 v$ A
.active_low = 0,( [5 c4 H1 V' a
.gpio = DA850_USER_LED2,
1 [( H n, @- ^: v( H) h# f .name = "user_led2",
7 X/ ]- _2 _5 t/ ]5 d% a .default_trigger = "default-on",
0 F% n5 h) p. l. r: \ },8 `! |7 W* D( c7 ?" c' a/ b8 s! G
{
6 e4 Q8 L) ^& _7 L. U7 `! C8 ` .active_low = 0,
o' Y9 `1 [; K4 I/ w .gpio = DA850_USER_LED3,
1 T- c" t8 V% Z. Q3 c .name = "user_led3",
: W, {" G/ ]' M3 `- X( g/ Z6 z .default_trigger = "default-on",8 A7 t4 h# G9 T0 L! s7 e. V
},+ _6 B1 J% n' r8 C$ \2 c2 }
};
3 x: r. `3 I: I. D/ V8 g
m+ m3 S2 d! u8 q0 ~( ?static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( s6 m% r- X. d9 I E' m .leds = da850_evm_tl_leds,4 M- o G+ m0 P R1 {/ f# a
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
/ G+ e, k1 @+ p}; e8 x j& v( B) r" r/ t: U
( }. E' |3 E9 a e% xstatic void led_dev_release(struct device *dev)5 b- A5 u* a- V" Y2 x
{
# Z( x7 k3 B3 F5 a. a};% \% p0 W' R }2 J2 D
% Y, Y' F! ?" p( w% R7 L( Y. [4 qstatic struct platform_device da850_evm_tl_leds_device = {6 X( c, j7 T: c$ y- e0 \" F
.name = "leds-gpio",
1 w6 e. A& a- e; N .id = 1,
* H0 |3 L6 v7 R( p .dev = {' T8 y* P9 U: y, b
.platform_data = &da850_evm_tl_leds_pdata,, D2 W: d5 W+ |$ P
.release = led_dev_release,
8 b7 u$ T8 Z4 ?" \0 n0 Z) r) |3 p }- c5 | \5 w- w. C* B5 I1 h/ L
};) a, E! ]$ i6 t5 v
! c0 Y/ c$ V) \; J# istatic int __init led_platform_init(void)
6 g$ O) e, E$ z% q4 e/ L W6 @{+ C; r5 r4 }& ~* k: D, @+ _" L
int ret;
4 @* c, a% D. w$ W7 l8 }& n#if 0
% f6 ^+ d7 P4 `, E: v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
4 X; ~* n5 u _+ G if (ret)2 a% ^, M# I" L* x8 l* Y1 \8 J/ R% c! g
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
- E* y- g9 U& C W "%d\n", ret);
* \! F9 ]. S; ?0 J( _2 S1 x; L#endif# D9 c! a Y4 b% l% k) {' M, }
ret = platform_device_register(&da850_evm_tl_leds_device);& T* T/ k0 r+ z2 G; J
if (ret)8 D4 j( a6 ?/ O# x
pr_warning("Could not register som GPIO expander LEDS");( @5 v9 H4 m) O4 G$ o
else# f3 S7 b: G+ }3 p% P" V9 S
printk(KERN_INFO "LED register sucessful!\n");
3 y; t# y9 ?: N( ]8 @7 v7 r6 J' g" s7 A9 h
return ret;
! X) r3 P5 U) {8 ^- j2 n}
^' ]0 Y; t" @5 Y( N. A i3 B: e/ k; D
$ b. x( }" \) ~" S. l" l) p$ v7 dstatic void __exit led_platform_exit(void); ?: l2 _* r' @ M" q" z
{
, U1 d# u' r( J' y2 k- X, H platform_device_unregister(&da850_evm_tl_leds_device);
2 r7 S3 e' ^$ a! f5 Z+ Q
. `) f5 Q; K# x9 O printk(KERN_INFO "LED unregister!\n");
4 G& `5 U& a' ~. j}
8 i9 r' j4 [# Q( K5 B3 `- G; k) y! n9 l
module_init(led_platform_init);) F5 k) j& |$ N4 _* o, e
module_exit(led_platform_exit); S+ b Y. S# Q
) n0 @7 E+ t" F* Y. z) q6 S
MODULE_DESCRIPTION("Led platform driver");
& F$ {# K; |' e* _* t& [MODULE_AUTHOR("Tronlong");7 d, F6 N2 l$ S% F% k5 N
MODULE_LICENSE("GPL");
! s/ d V" @+ R6 ?4 z3 A% ?" y/ u9 U8 s: u: e ?
|
|