|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 D; l+ h( `$ t; y" F: I0 E#include <linux/init.h>
7 K E3 `* _) u1 r' F( M0 R#include <linux/module.h>
: r# o) h" u j1 @#include <linux/kernel.h>! U* f1 k& H. \3 G: e/ O4 `6 d% n
#include <linux/types.h>
; ]# H# M' }: b% i: c N) v6 S#include <linux/gpio.h>% @6 |8 ?- a; T5 b
#include <linux/leds.h>
1 }8 m+ [( K5 ~5 w# \#include <linux/platform_device.h>% W2 b3 V7 ^& h; t0 f$ l
! b6 I3 O$ n% g* K+ P
#include <asm/mach-types.h>: o# `; X& Z) A2 U, W: B4 D/ M4 K. I" s( E- J
#include <asm/mach/arch.h>' X6 _; }. R# b% G* P
#include <mach/da8xx.h>
: r* z. x3 Y! ^ A, b/ u3 C#include <mach/mux.h>" t0 v, d# H. x, q
( e6 V2 O; G* a$ Q+ W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ k6 x$ z) x) b8 ?#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: @. z( Z8 m3 V- [#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
9 [' X2 o _; S2 |#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, |3 O7 ]( N, M3 N2 e
, v8 _, M8 e* U) z5 c! G) _, M/* assign the tl som board LED-GPIOs*/
8 c. U7 K, ~4 w2 H" Xstatic const short da850_evm_tl_user_led_pins[] = {& x; O: H% z- w% O3 y" v/ u+ R
/* These pins are definition at <mach/mux.h> file */$ t5 X2 M+ A) I; ]3 e% P0 W
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' b3 P0 ^' j Y -17 t, f K3 F+ o8 N$ g1 F! q
};
$ I7 @4 o1 p; R3 @2 ?1 P
& M5 l) H: {. C+ U" Z$ u" B% \8 pstatic struct gpio_led da850_evm_tl_leds[] = {, Z6 d3 e& ?6 ?# |, w1 T
{
+ [( k9 B8 {$ D- l .active_low = 0,% \9 @0 p; K: P" }( y
.gpio = DA850_USER_LED0,+ Q2 r8 c+ h7 x1 `
.name = "user_led0", _' e, w8 S+ o
.default_trigger = "default-on",% ]3 X Q8 e0 J1 {6 t6 m
},3 u' L- B6 C* i9 u% }
{ z2 u) J+ [0 \4 C% Y
.active_low = 0,
9 f& K% y( M8 h( F; c! Z4 h" m .gpio = DA850_USER_LED1,4 \3 p4 H8 ]+ z4 p3 R$ Z! B
.name = "user_led1",3 l* l) J. h6 y2 s- a
.default_trigger = "default-on",% v$ {6 e* J8 v% n; F6 G5 u- c
},
) D0 H" j3 E' }9 m: {# C {1 c' S& `7 y2 Y3 s1 H
.active_low = 0,' b% l6 u2 t& m5 ?& @8 K& {+ B
.gpio = DA850_USER_LED2,
, z S( K# L' V .name = "user_led2",
+ }9 h. Y$ [1 t6 L5 `0 t- a% g .default_trigger = "default-on",* J! l k8 f$ m6 T$ W
},
]+ Q% I$ o. v4 G {
8 F+ A( t5 P; L' _9 I9 a! Z! y .active_low = 0,8 p4 @) m$ Y2 b- x7 D% y; O
.gpio = DA850_USER_LED3,* B# k4 s+ L" a8 X. M1 G
.name = "user_led3",
3 V' H+ T+ w0 R( ] .default_trigger = "default-on",; x; b# `8 G& ^( I8 @6 z1 Q" m0 |
},7 y( d7 P* `: z+ I% b
};
# }) X* d. J" D( K- z6 I, S; g5 U: v1 h4 J/ B& X
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 K! @9 s' ?1 f+ p* [& s+ M' R
.leds = da850_evm_tl_leds,4 }+ V7 p- F ?+ R
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 H5 H2 Z7 d% X
};
" T; j% o! a8 n' }
( T. y+ V: Y; G$ Pstatic void led_dev_release(struct device *dev)
( q. f5 g" d* T& ]{
3 H: s0 g9 t( K6 J* w};
; `2 b/ _6 L1 R. ?6 }7 k
7 \5 p; }/ T( S$ E% lstatic struct platform_device da850_evm_tl_leds_device = {
1 t- K6 _$ n0 @& Y& s; _; g+ [2 z .name = "leds-gpio",$ [! X6 Q; R% c) t- E' E9 o) Q2 T
.id = 1,
/ d, n; X" V* M. E: Y) ^& I, H" b .dev = {' ]# }9 { w+ E5 ^4 n1 S) C
.platform_data = &da850_evm_tl_leds_pdata,
/ ?. K2 w3 X/ f: T2 ~$ i7 t .release = led_dev_release,
( U' M- m! F" J j }6 }$ G! q. R) F; k+ C2 I* d) H
};# Z* \2 Q0 i1 `2 f9 G! w! \$ E
+ J f, v. H2 a! }, Q( H5 r1 T! `
static int __init led_platform_init(void)
( Z/ f# R' y4 v' T6 \- b{
& @" G" ~7 j/ V8 ~- O int ret;
& [8 i0 F0 ^3 y$ i9 O, j#if 0
M% S% L2 ?3 _& |/ F6 u- V ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 L2 p; s! h* y$ r5 k
if (ret)3 Y& b4 q# Y+ ` F( q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"0 u1 x9 h, O$ U7 C2 f7 Z" `+ K: t
"%d\n", ret);
! M' ~! W% z9 @9 h% `( }$ z#endif l* B& v4 d k, ]& }6 n# @
ret = platform_device_register(&da850_evm_tl_leds_device);3 H( A) o @( O, g9 K/ \' K
if (ret)
7 g" H/ D9 [( [- m }) E$ R pr_warning("Could not register som GPIO expander LEDS");
. Z" p1 J w+ @' I8 d; w else$ T% G% h5 t" Y
printk(KERN_INFO "LED register sucessful!\n");
0 M) M! o* a, T0 a/ m, t1 H
0 ]* @5 l8 q( g# p return ret;
; v5 Y6 b! L% A9 o2 R. n/ ?4 S) s! n}
* P: W8 i& b u# j; g2 y& p) C
+ [" O6 ]$ `. M% H+ b: f% Zstatic void __exit led_platform_exit(void)
/ `/ O: O8 ]$ Q' ]# l. L# E5 K{
' j1 F' ~3 U) G1 {0 n6 x: x platform_device_unregister(&da850_evm_tl_leds_device);
, H* P, z6 g2 d
9 U8 e, ~6 W( h+ P printk(KERN_INFO "LED unregister!\n");( D/ L6 S% h. m$ m
}9 O, B, i2 w- e# G
, a9 l, X n' O% kmodule_init(led_platform_init);
5 D1 g' R" b. r* Gmodule_exit(led_platform_exit);
5 R1 m! U1 C! l! R1 r0 }: \, d ]1 L6 Y
MODULE_DESCRIPTION("Led platform driver");
+ o9 U2 H6 l4 J/ n; Y. pMODULE_AUTHOR("Tronlong");
4 Y3 L* H1 ?$ P, a6 s7 E. C4 }MODULE_LICENSE("GPL");; _% ~0 w2 L$ f: m
6 p8 R/ L. O, S6 o% K& z
|
|