|
|
求大神给下面的程序做注解,请稍详细些,谢谢。* O; [* T1 x% X4 i b2 z! c5 G0 A
#include <linux/init.h>
8 M7 G! n4 t/ C$ m#include <linux/module.h>
7 x* L! Q% L) q! R2 j3 O0 w+ v#include <linux/kernel.h>
0 T. k& _# R) s#include <linux/types.h>6 b- a, \1 N1 ]5 K* P* e) @
#include <linux/gpio.h>
9 w/ j# {& [9 V( T. \" A# T#include <linux/leds.h>
7 A. c2 f" \# P& w- t#include <linux/platform_device.h>" O1 x9 _! h/ Z, f% R, i6 ~
7 W; Z; Z( H1 U7 ]3 q
#include <asm/mach-types.h>
+ {5 z& ^/ ?( m" X' n#include <asm/mach/arch.h>; g- b- ?4 B, h! j
#include <mach/da8xx.h>
4 `: g3 @* Q0 a, D: R0 C#include <mach/mux.h>
$ \$ b1 M" I0 d) _+ c+ o, T8 {! f) d8 z* S1 v6 `$ {, C
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
f/ X% y4 Y; \6 j: x5 v#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)$ U9 F, y6 U4 q: e! F% ^3 J N
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 b) d7 Q. j. t/ n
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 |( C% g- ^, a9 b& b9 C8 ^
7 Z$ y! @% r# P/ r! {! s- S+ X/* assign the tl som board LED-GPIOs*/
2 Q, _. a3 h' C% U Sstatic const short da850_evm_tl_user_led_pins[] = {
) N, r$ i# u1 m& K) ^: j /* These pins are definition at <mach/mux.h> file */
) i( Z4 L% B* _. ~+ K6 A4 p DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
9 g7 u, E$ r4 _3 B0 ?' B! I% W5 T -1% t: G& T( \. F8 D
};# T2 z1 b: i$ O
: d8 a, B7 b/ _* n7 C: d, Ostatic struct gpio_led da850_evm_tl_leds[] = {' X: w) h8 J, f L, l1 N
{
4 ^# o4 h; R# s- I$ ~5 [/ e .active_low = 0,
5 i0 q* j3 \) y ~4 i- N# {2 B. f .gpio = DA850_USER_LED0,$ D# E# J2 M9 ^$ h
.name = "user_led0", H8 e% q7 O) @( r* D
.default_trigger = "default-on",3 c4 n! N( P; L. e
},
. _4 R" K6 P' x {( |4 l/ m& L$ a% _2 t9 [* S# o
.active_low = 0,
) {1 q. n+ M( O$ x% M0 H .gpio = DA850_USER_LED1,# _8 Q4 y p' }2 A0 W S
.name = "user_led1",
0 p C9 ^) I& t4 _ z. } .default_trigger = "default-on",
3 x1 v' I2 n1 e },% m9 p4 g( H: N, x; ?# ^' `8 l3 d
{0 G+ U& T% }8 ?0 x X: i/ i7 v
.active_low = 0,2 C; O5 m7 `& W# Z
.gpio = DA850_USER_LED2,
F3 p: T: l' Z .name = "user_led2",
& {9 G( W# K# f: ~/ f* ~ .default_trigger = "default-on",
h# k0 |! m9 Z) @. l- j" U: l4 | }," X: Z3 ^; P" b( Y- x
{2 q6 L2 |! \- S' q* e1 f6 I
.active_low = 0,( Z9 s2 O" V% m- j1 U: H. _
.gpio = DA850_USER_LED3,
9 u2 o- H7 R9 H; a .name = "user_led3",
/ W+ ?7 F$ r: [2 U( s1 U .default_trigger = "default-on",
6 Y$ h2 k. C K7 b- A. ^ },
* \1 S3 o3 e8 q" Y};! ^' }1 e, e, M. ?
- K) r# Z# g Z' t1 r* u
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 F8 f( n m0 [! W) \
.leds = da850_evm_tl_leds,
' a8 @$ _- d, K7 ~. }: d; E .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- n( r% {2 b" l" A) T3 W};
% r U+ P# s, y5 p* c+ C+ S
$ n8 h4 L" W* {. Z# t6 vstatic void led_dev_release(struct device *dev)' s4 I; b% Y" a
{
1 w6 U9 n2 Z+ h* A};
2 s% B% p2 L I1 V* c# b0 ]9 Z- R. w+ _7 X X( q* |& P! F9 j6 F
static struct platform_device da850_evm_tl_leds_device = {
! X$ k3 v: ?$ P7 {4 P .name = "leds-gpio",1 L0 z8 d$ z5 j4 u
.id = 1,
r$ t V; G. q+ V .dev = {. z9 S7 J( Z" r) J2 e, {6 Q0 B/ a
.platform_data = &da850_evm_tl_leds_pdata,
! }+ m S9 z+ V! h .release = led_dev_release,
) U; Q2 Q' m( u+ [0 F0 ]0 N. R }) Q; j, t0 `. }( E. ` y( o1 B
};; B/ p% ?' k+ R S8 @) U
7 r! l: A. ]# {9 m! |3 R( K4 h4 Hstatic int __init led_platform_init(void)* a3 {0 F1 G! j: C" W4 A) _
{
# x. P, ?3 p0 ?- p int ret;
|4 O! o8 @8 T5 n1 ~6 z( v k) Y#if 0, v! Q: L+ k# Z }+ n0 q0 v! j
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ N* s: p( W+ ^6 P% z* i if (ret)- q. U' Y, r9 C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
1 c( D/ s$ D: ]0 e% K "%d\n", ret);
" R+ x9 N; G% A0 J8 }/ i- L#endif
, M/ n+ |/ N4 q3 ~2 Q1 l ret = platform_device_register(&da850_evm_tl_leds_device);! U7 a# |& g# _: l
if (ret)7 S* J! } i; ^# u6 Q
pr_warning("Could not register som GPIO expander LEDS");
( Y7 A* c4 M. b else' x3 f2 J$ R# }$ Y8 l
printk(KERN_INFO "LED register sucessful!\n");1 c! Z5 w! [5 @7 s3 u
$ ], H3 r3 w% x H& _) u; ] return ret;& x6 A: M. U- T1 a( Y5 C0 x
}( u. ~7 g# m' T( O
' c! J; W3 o" y0 ~7 m, p
static void __exit led_platform_exit(void)* L! F/ @- l, ]; k9 X5 O G
{
8 ~) \ A) X5 Z platform_device_unregister(&da850_evm_tl_leds_device);9 z( T" e- y2 H+ o
( E; ]6 H& g% o0 W3 J4 Y/ K printk(KERN_INFO "LED unregister!\n");
i% m2 y' I5 Y- H; n, M}1 Z+ ?5 z! W8 @* A y# q, B e
5 z" R# N1 ~) o% D
module_init(led_platform_init);
( \+ X" t1 }" Xmodule_exit(led_platform_exit);
+ |# u6 O. m8 I+ S
4 a2 L! h; q n- a6 k) ~MODULE_DESCRIPTION("Led platform driver");
j/ f" J' U; I$ P+ L2 n( eMODULE_AUTHOR("Tronlong");3 S5 n, _/ R, B% E9 U% @
MODULE_LICENSE("GPL"); Z: j% O/ \$ e- A$ A* X
6 ]2 p% E- y8 |4 F3 R
|
|