|
求大神给下面的程序做注解,请稍详细些,谢谢。5 R" L, k! L3 I1 b4 S0 b' s) q
#include <linux/init.h>6 U! ^' E6 C" ~' _8 u
#include <linux/module.h>
. A$ b+ d5 m7 r0 V, w- d* J8 M: k#include <linux/kernel.h>+ O% I9 F+ C7 g, q- n% L# g- K. ]7 h* X
#include <linux/types.h>
& F2 v: R/ b9 E#include <linux/gpio.h>
3 n# n+ m) w4 K R* j f# ? B#include <linux/leds.h>
2 p/ z5 B4 \3 j. B- ]#include <linux/platform_device.h>
5 D f5 H( V. `3 B# S' d" d" }' ?9 g5 R, ^
#include <asm/mach-types.h>
: _4 d3 [. `& R5 y/ ^- b" ?#include <asm/mach/arch.h>/ c P8 T* S9 I E# P/ a
#include <mach/da8xx.h>
7 \ ]$ ?: o& G/ z#include <mach/mux.h>
# o, }2 Q- G* t7 q, `! T( K/ @) n# H# G7 Q% D, I
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% Y. E; g& h. l/ o; f5 C- _: x
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& W4 ?1 r j; a- D' L7 Z* h#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)0 E2 j2 R- H; b5 R& N- e
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 `, P2 h; p/ p8 W
: @! k, w1 F5 Y+ K% A
/* assign the tl som board LED-GPIOs*/
" w8 N9 D4 W/ s$ W% Z6 u. g6 ?% X* wstatic const short da850_evm_tl_user_led_pins[] = {! W% |6 R5 f3 `) l/ }
/* These pins are definition at <mach/mux.h> file */8 a! ]% V8 s8 z# _9 b5 I& o
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,8 |' w% n' ^& {3 l9 {
-1+ N0 G7 w N6 D& t" u
};" b5 @" ~# G2 r4 S
+ r2 v" `4 f* I5 X9 q! K5 x5 c
static struct gpio_led da850_evm_tl_leds[] = {$ G1 `$ \7 i" n5 M
{4 N/ Q6 g+ F4 w. p2 h, A0 A# M
.active_low = 0,
* I. n4 y& N* b) f& K9 q .gpio = DA850_USER_LED0,
. D1 P5 D. C( V4 v+ [7 r* p .name = "user_led0",
9 `% l* i3 Y# l8 A8 N3 u) i/ U .default_trigger = "default-on",4 u; ~! z" w+ n* `/ g; Q* c' u. E
},8 N0 e2 B c D9 T* j& R0 Q
{
& F6 v6 ^# _5 H/ Y .active_low = 0,
% Y! _. q6 f9 Z5 Z% v .gpio = DA850_USER_LED1,
1 [8 F/ U2 z4 i/ n& P .name = "user_led1",
$ m7 \/ M2 M# J/ @& b .default_trigger = "default-on",
) ]$ s) o+ W5 A; p$ c/ b },
. g- E0 c! ^( h, s* J% ` {, L0 t$ i8 Z( ~( o/ M7 \
.active_low = 0,
1 K$ [0 Z$ k q4 e .gpio = DA850_USER_LED2,3 n; r' U! }+ m/ I+ |
.name = "user_led2",, m9 A# C+ x" g
.default_trigger = "default-on",; O! I; Z* m# V0 z% v6 \
},
" b8 o- e8 f7 o* d$ | {
0 M5 I$ b. j1 ^9 l7 f .active_low = 0,* I% e& [$ y7 {
.gpio = DA850_USER_LED3,
$ U- N( l3 W' ~" [) a .name = "user_led3",
9 t3 y4 `& G. W+ i. X .default_trigger = "default-on",2 H. J- X* h. E' H. p( k( O
},/ Z# \ n1 c. y3 H* v7 c( M
};1 T: r$ k- Y- y. ~: q
]- `; i) [/ \% j" W+ W$ istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
. N$ l# S C. W& M) R# v7 s) F4 i .leds = da850_evm_tl_leds, W2 g3 \8 E; c* |3 ]
.num_leds = ARRAY_SIZE(da850_evm_tl_leds)," u: G1 {# \: T \: G" b
};
" ?) D2 `' y" t6 k5 U0 j5 \" ]. `3 K% F, p& |4 h
static void led_dev_release(struct device *dev)
l2 b, {# V1 m" G5 A' F{
/ e& s. b+ s5 n2 h6 ?" t) Q" n9 g};
7 c( ^% y0 I" F/ ^) y, o( `; D+ [3 e, _. f2 Q
static struct platform_device da850_evm_tl_leds_device = {
9 w0 B% h- H# W: N* n .name = "leds-gpio",
3 ?- T1 a$ ]8 N- w .id = 1,
7 @! r6 Y+ w3 y4 c- G .dev = {
9 `* |$ G5 V4 a3 x# Z4 L .platform_data = &da850_evm_tl_leds_pdata,
% y" P$ U- [. `6 F5 d" { .release = led_dev_release,: ^. d) J- a X s0 \# |
}$ W; j) |# m$ J) h/ _; y
};" \8 T3 i% o/ c
4 `) _% x \# [3 _0 h4 Xstatic int __init led_platform_init(void): ~4 [6 T5 C% G+ ~5 w
{+ {/ e( n* u2 r$ Y
int ret;
8 ^& n& E: j, t" Y#if 0
+ N$ {* v D) N1 o6 Q ^ r" v ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
# q5 W9 M, X% {8 H5 R if (ret)' Q( M$ O1 n' @0 e+ D; n
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 n. o2 f. L1 ~ "%d\n", ret);% \3 \# e8 W7 s/ t1 t7 O/ T
#endif( e* \- g$ `9 Z5 m( R* ]% W6 [+ G
ret = platform_device_register(&da850_evm_tl_leds_device);
5 }' W6 O8 z# ~, s: |& h+ [ if (ret)3 {9 u" [' r) e: F
pr_warning("Could not register som GPIO expander LEDS");
9 b# `4 W, _3 P+ q else
0 B% D, D) \0 K" c2 I1 i. F6 ` printk(KERN_INFO "LED register sucessful!\n");
4 ]; r1 @+ }5 `9 R6 Y, I0 [3 y" q2 Q* @: C9 L! p
return ret;* U9 v/ E4 S" I1 e D% ]
}
2 J5 R! _& _+ b, S# C; o3 E: `# G3 n% S1 z4 p# I7 C0 C7 D
static void __exit led_platform_exit(void)" T* i5 K1 h" a) A
{5 D W3 r/ g# l% z" X5 B
platform_device_unregister(&da850_evm_tl_leds_device);
% y( ~! F6 a/ s* p- P% L" \# F/ T4 R% g3 B; j/ v! ~7 u1 e$ H
printk(KERN_INFO "LED unregister!\n");
2 W# W7 R1 q0 A9 u}
( ~+ W4 f1 b" S+ C1 f! \6 b3 s0 \: h* V6 Z0 ]0 ^0 Y
module_init(led_platform_init);) R& H# F/ D! X% c* Y
module_exit(led_platform_exit);) G: M9 G+ `! _ \$ W- S
, y0 O' o6 Z; L
MODULE_DESCRIPTION("Led platform driver");0 u, P$ {# ~/ Q! {" e# j
MODULE_AUTHOR("Tronlong");
% a$ k! H, m: ^3 D7 s% \MODULE_LICENSE("GPL");
3 F: k; D3 C6 F( f0 W0 ~9 J3 }
' Y) a/ p; Z5 `; Z7 |. E) s |
|