|
|
求大神给下面的程序做注解,请稍详细些,谢谢。9 I1 T. ~+ A, |& T- G% F- Y
#include <linux/init.h>
4 [9 D+ m& h8 f: w; s- L4 W#include <linux/module.h>
; o6 U5 K4 W2 V9 F8 W#include <linux/kernel.h>7 Q: T0 O) Q5 z, ~9 A
#include <linux/types.h>; [9 ^- Z! v) o0 l$ y
#include <linux/gpio.h>
" K- V# v6 e+ y! V. ]% j2 a/ E' a#include <linux/leds.h>6 ]: {+ _+ ~, \& `
#include <linux/platform_device.h>
: m9 b; V3 }1 e2 p, g8 J$ f8 E1 p6 M& C5 r0 h8 c
#include <asm/mach-types.h>* \! Q0 l; K1 q! U6 N0 j; q. j. |
#include <asm/mach/arch.h>$ P2 j( H: L7 c/ ]5 ]/ o
#include <mach/da8xx.h>
1 ]; N1 b, E9 B% E9 r1 J) x#include <mach/mux.h>0 m0 K8 d& H7 T/ H; \, Z/ ~# x
3 F E9 E6 j/ P5 b+ x, {#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
" F- e6 u% {. n; i5 O#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 ]0 F- C! K2 B& h
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1). [& a( j9 N2 I. m. x1 d
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)9 q+ y% I/ B/ c8 f3 V) Y1 h( p& l
% a9 I4 i x7 \, W) w& b
/* assign the tl som board LED-GPIOs*/" n3 ~7 l) ~3 d; X* l- o" }
static const short da850_evm_tl_user_led_pins[] = {/ \. z/ p2 X7 |/ s
/* These pins are definition at <mach/mux.h> file */
5 J$ l" q7 @# l2 h/ [5 G DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" @3 o. A( p& z$ R -1
! G- d, N+ I8 d Z" X+ f};8 }. n0 @# x) P. Y/ o
3 p9 V$ p D' K/ r: K
static struct gpio_led da850_evm_tl_leds[] = {$ ~( b( x( H. g* t7 N. s7 V: l
{, @' N! R: z m
.active_low = 0,
# E& J4 e5 a5 I% V# m; N .gpio = DA850_USER_LED0,
9 ?) c8 u. o% E/ }6 ` .name = "user_led0",
* @$ A* M/ D' I5 `& l) M& r" X .default_trigger = "default-on"," B* |' ]' J( n
},* r+ G! A5 }6 Q* m: y' H
{) S6 r, \% c- C2 B t
.active_low = 0,
; t- O0 S$ ?) M, U" K5 t( P .gpio = DA850_USER_LED1,6 Z; b) H& S$ D2 ?7 _, M2 y
.name = "user_led1",. T$ V2 C; D9 j4 {" M
.default_trigger = "default-on",
9 {! f6 j: ~5 T },
* H5 Z# X( k _; ~: B( X7 l {: F k$ T7 ^$ K: {
.active_low = 0,
$ Q& v. P8 K& s0 F/ K .gpio = DA850_USER_LED2,) A5 Q" v/ v" i
.name = "user_led2",1 J8 ?, R n( I. X. n/ |% C
.default_trigger = "default-on",
! b4 I. o* c* `3 W" h5 X! G8 |7 s },
: Z$ Z0 M% R* ~8 @ {
. B, R9 Q& N. L0 b6 k8 x5 X, b0 x .active_low = 0,
4 _. a! d2 F$ \ .gpio = DA850_USER_LED3,# I* o4 X# w' j. ?# V' J
.name = "user_led3",2 f- K2 r* y, f. D+ U3 u4 |7 q% [1 Z
.default_trigger = "default-on",
# H5 a2 e1 Z0 ^( E5 r9 l! Q: ` },, o5 ?8 P8 m' m! a$ b7 J$ [8 Z
};9 A5 c7 b! j$ f- g# M, _
5 J! z5 `! z' y5 o; U: ystatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
n0 b$ r7 C( D# X: b+ } .leds = da850_evm_tl_leds,! o: p+ U9 B( A, ?9 @+ v6 C
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 w v- A6 b/ R};# L9 b. C+ R$ r, T
' Y1 X+ U4 S2 i1 l9 K1 _static void led_dev_release(struct device *dev)- I% [. {0 Z! m$ s+ I' d1 ~
{3 k% q; ?. j0 B2 I7 X' Q
};3 t( D# k4 M- K6 z% { K
1 b& Q8 _- i$ E# c, O; n* I
static struct platform_device da850_evm_tl_leds_device = {
2 k4 R3 h/ Q4 Z% } .name = "leds-gpio",# W; y9 R) n& K+ _8 P
.id = 1,
' _* a* `- i! b8 ~ .dev = {
! b/ n7 ^2 u; `$ ` .platform_data = &da850_evm_tl_leds_pdata,( R+ d& Q5 x; P- N( Y2 t& Y
.release = led_dev_release,9 }* c9 _& ]# x3 j
}
( g; Z. R# i% p$ v" k};9 e' f& x. y j h
" F4 L6 F2 r& `3 nstatic int __init led_platform_init(void)1 B: d8 r. G& X7 ^
{* k5 j/ E- b; T6 B: |7 a8 E+ Z
int ret;
1 e$ K" y7 B2 U% B6 ]#if 0" z& W) ]; v2 E. h( G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
: ]5 c/ c& q0 d2 u if (ret)
( e2 w: D' _' q) A0 k pr_warning("da850_evm_tl_leds_init : User LED mux failed :"7 b% {4 K" X; M- x1 H
"%d\n", ret);
9 n3 v$ I! L+ i4 J; e% T#endif- _7 I- V( Z7 e. N2 o! t, `
ret = platform_device_register(&da850_evm_tl_leds_device);
: p0 o( ~; ^) j" W if (ret)
1 ^- Z$ F; D; W7 x: R6 t* m" t pr_warning("Could not register som GPIO expander LEDS"); T: c, ?/ D) i$ G
else* ^5 M! r m2 p c8 A) n$ `
printk(KERN_INFO "LED register sucessful!\n");6 \! `, x8 j! l9 T1 f/ z" `
0 e; Z. O% }9 R( Z5 O( w
return ret;' q+ W' }' P# ]3 o1 j9 `; I
}
* G% ]4 ~5 h- a" {) I8 a3 ]* G( t- V. a8 U0 L3 X
static void __exit led_platform_exit(void)1 ]! N7 s' c& E7 X
{% l9 M/ v6 }$ T
platform_device_unregister(&da850_evm_tl_leds_device);
" U& R. @: g# b* `. W1 s
9 C. n4 y( X$ R- O# Z4 Q4 l5 c$ i printk(KERN_INFO "LED unregister!\n");
4 J0 ^0 u5 `* N" _4 E" ?}
0 s# Y4 H" K# |8 ?
5 Q$ W n0 }/ q, \' e) k2 I0 ]$ a. Lmodule_init(led_platform_init);
: L4 Q5 G- ?8 fmodule_exit(led_platform_exit);
/ i. w6 N" U" h% f7 F& S3 e2 R* L: q
MODULE_DESCRIPTION("Led platform driver");# ^( T8 N* P, [
MODULE_AUTHOR("Tronlong");: c' h+ T" s! Q F
MODULE_LICENSE("GPL");
- Y' f& P' A; ^# Z6 q; G! `! d& O4 u
|
|