|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
; a/ F9 a9 F9 V: V1 z#include <linux/init.h>
8 D4 A; P6 f8 S. l0 z$ X#include <linux/module.h>
8 G c/ n- h) z6 T& h. D @#include <linux/kernel.h>! ^0 G' K1 N8 F! T7 ^; ^- P6 o
#include <linux/types.h>/ Z: N5 r1 i& m4 ?7 \8 B( _: d
#include <linux/gpio.h>
, x5 \; e9 Q3 f9 S9 E4 p#include <linux/leds.h>
" C1 R T2 F T$ A/ M' q, P#include <linux/platform_device.h>' s$ Q( r$ k& D( _0 G( |( S
, q% G5 f T0 p
#include <asm/mach-types.h>) \7 P3 J- d+ n
#include <asm/mach/arch.h>
. R* _" T* J9 z- h$ C* E8 l; U#include <mach/da8xx.h>
3 w% l% e2 v2 H- L1 L#include <mach/mux.h>& ?5 }" y2 f' b; M
) T5 X$ G* B% j6 ^: a#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)/ r& A- U# d0 A a* i) Y/ Y$ g
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 I/ [, N& _0 W) p#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
5 U- d) C. c* G. L( Z% L& [ I* v#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)/ g5 T! V! n5 ^* B# \. ]
( _- N1 O) F/ ^" h- i7 N/* assign the tl som board LED-GPIOs*/
. I C" X' \& G& {0 i- j5 ~static const short da850_evm_tl_user_led_pins[] = {
5 {" Q0 T- P) x- S+ [# U /* These pins are definition at <mach/mux.h> file */- O9 ~, W% n3 F/ g: b$ d% n4 b) E6 a
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 X1 N+ m9 U" m' t& u0 Y -1( U. M7 _, L- [
};
2 a1 t* H% t8 h3 v; \6 ^
. J" }2 w% a' |. ?- R( ~static struct gpio_led da850_evm_tl_leds[] = {6 n2 Y/ O4 p% _5 U7 F7 O) l
{, K0 c' V* J' F0 U, V
.active_low = 0,8 q6 j2 W: T& c. x% p
.gpio = DA850_USER_LED0,
8 E- l4 C- B6 G. g4 d! \ .name = "user_led0",
# C1 H, H: I; j1 U0 x" M .default_trigger = "default-on",0 Q% v' i. v, ]! @% s
},7 O6 v: |4 n+ p9 _2 Y$ u
{6 [. I8 Q1 ~5 l- E& p- }
.active_low = 0,
$ s" D0 @9 S: h% H7 N- O .gpio = DA850_USER_LED1,
~$ d) M3 H: Y .name = "user_led1",) L q3 [: S( V8 |3 [* E
.default_trigger = "default-on",4 k4 P# Y: S# @; i
},' q0 l( G; e4 m; _8 q& P* W1 p
{' a. ]# a5 f$ f) I1 d, S, o
.active_low = 0,
2 d& A/ B* K: m5 D. c. K .gpio = DA850_USER_LED2,! `: E9 l* U0 H: y l% m+ e
.name = "user_led2",
3 w$ I% d+ p L, R; X( |# e3 G .default_trigger = "default-on",
% @ V; q7 D3 T2 \) a3 M& o },
# t2 `) z0 q: ? {8 ?& x$ Q( S5 V9 j$ T% p1 ]
.active_low = 0,4 V; j: P& l5 {
.gpio = DA850_USER_LED3,5 w% ~8 N8 ~' k& D8 H, b
.name = "user_led3",) a; O; ~% b8 \: |6 s& d
.default_trigger = "default-on",2 m& L" X* H. d! X
},
' R/ l# a2 G. G5 X; [};* a' Q! | n7 @
7 c6 O4 s; L" g! r3 g1 `* D! F/ g& D4 v2 Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* \3 d: K# X7 n1 D ~5 f
.leds = da850_evm_tl_leds,
7 E3 D( @3 s3 }; k7 m) u* x2 E! k- Z+ } .num_leds = ARRAY_SIZE(da850_evm_tl_leds),4 W0 k3 _ j" b. [9 i+ `5 }% F
};% Y/ `% h- r; |& R& x
+ [- |3 c; R& R* w g; D/ `static void led_dev_release(struct device *dev)
, p3 d4 }; w8 x( {' a{
- n% `5 i9 {5 b. w};0 b$ c$ q0 i- X9 Y2 R
5 L% G+ t+ z* d5 G
static struct platform_device da850_evm_tl_leds_device = {
) r$ C+ w. A9 W .name = "leds-gpio",
) Y$ N6 O& r. P6 W- y* b .id = 1,$ T& u5 O. x0 @ N
.dev = {' S! N( `- U+ o' X
.platform_data = &da850_evm_tl_leds_pdata,; v% V1 G! A9 V. |
.release = led_dev_release,
1 [3 H7 p% @ O$ Z }5 O" p, m5 y, Z, m; F
};' x" f: {( Z' k% }8 V1 L2 ^
+ f) r7 @% B( Z2 Fstatic int __init led_platform_init(void)5 d; y7 p; z1 F' U
{
, i5 M7 E7 O+ N* L int ret;% _9 ?8 x* h! l' \2 e* N
#if 02 z% u1 K; i+ a& k' w* m
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ h& t' j+ D/ f# M' ~" p7 G+ z
if (ret)( V( C8 U' p( o' _# i8 d3 N! Y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; s& r5 i J2 y$ s! T "%d\n", ret);& t% B; d' |2 O5 s1 z9 P# Y
#endif7 S. H' `% S, N* g9 H4 y) }
ret = platform_device_register(&da850_evm_tl_leds_device);0 K3 Q& i: s' g3 N
if (ret)( e0 i2 s) ^" o; |2 D4 Y3 K. h
pr_warning("Could not register som GPIO expander LEDS");
& M5 V, j1 Y' U) I" d# f& { else. C* K7 Y3 X% L5 n$ N- y
printk(KERN_INFO "LED register sucessful!\n"); a- J) s [: [/ Z, f5 u
1 }. Q- V' k! ]) i; W8 W return ret;
3 n* k! k: L& c7 v. A3 A+ [}
9 P7 h7 `, @2 e3 K0 L9 K6 x1 ~8 |; R; d' [' u& {
static void __exit led_platform_exit(void): r0 W/ @- J6 {
{
- K5 j) ?% T- G% n- Z: M9 H5 F platform_device_unregister(&da850_evm_tl_leds_device);
/ b5 S* [/ I3 U2 n5 @! v5 c' O# a% W# g F; G" s3 h
printk(KERN_INFO "LED unregister!\n");
& }% Z5 P7 Q; T q}
% m/ C8 t+ d1 T- ~" }
* |* a" d7 @; t5 Nmodule_init(led_platform_init);
, _2 D5 z: u7 p. r: Dmodule_exit(led_platform_exit); }3 w8 v. a/ ^8 N; p/ y
, f* n) a2 }& R4 E
MODULE_DESCRIPTION("Led platform driver");8 ]" }1 z3 u+ E
MODULE_AUTHOR("Tronlong");
" s9 C' _. w& E% tMODULE_LICENSE("GPL");$ c* b# f, M9 Q0 T1 a! Y8 P7 L
/ R& G1 i% u# ~4 \4 a
|
|