|
|
求大神给下面的程序做注解,请稍详细些,谢谢。4 Z" w6 r: ]' w! g+ [# q) F
#include <linux/init.h>
, I ^# t( a. [#include <linux/module.h>
/ k& [8 Y; Y" U5 ]5 Y#include <linux/kernel.h>' h6 I9 h- g/ M1 h5 V
#include <linux/types.h>2 s% L9 P5 s% A5 o
#include <linux/gpio.h>
+ M" r+ |9 V, Q#include <linux/leds.h>" [% u3 O, p# z3 l6 }8 E) y* h
#include <linux/platform_device.h>5 Z+ w9 ~( [0 W: x8 {# c
: I7 S' c8 I* j# A- |
#include <asm/mach-types.h>+ C) x% P: H" _
#include <asm/mach/arch.h>- n! \ p# B* M( I) W; t
#include <mach/da8xx.h> l2 m3 m5 Y5 j
#include <mach/mux.h>
, _" m) U- ]. t7 _% g& X. I- E% t/ k+ ^) h
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)' g( n0 B5 }- d5 Y7 n
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
M3 w$ H& h7 q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)- A) I% U% T" W! d5 J1 u
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
8 {; A, t' q1 @7 {7 \' L$ j. `# X
! {7 d b/ L7 U2 {( ^/* assign the tl som board LED-GPIOs*/# u1 ~0 W7 O- j6 ~3 x: z* |
static const short da850_evm_tl_user_led_pins[] = {
! L8 d; p9 Z. ~ O, F" C1 k /* These pins are definition at <mach/mux.h> file */" L' `2 K( x2 k; N5 o2 b: i, L* r
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
" Z' Z! `; k! z/ W( q -1
0 ^$ o. f. \5 S" V2 k$ n};7 o, [2 t/ t0 y( H& C
% }" ~, E. K, L" a* r/ ]
static struct gpio_led da850_evm_tl_leds[] = {3 H1 y: k$ k: Q* D: k9 j
{
: L1 F' V9 S1 ` .active_low = 0,3 f H) s9 S, h/ ?- D
.gpio = DA850_USER_LED0,7 c1 \, V$ Z# Z: d+ ~
.name = "user_led0",
2 x0 U. V2 k3 ~6 b .default_trigger = "default-on",8 ~/ v# p) Q" V }& x3 c
},
; c8 t6 e; z1 t; t+ W0 w: U {. a0 Y, n5 h/ z, Y! h
.active_low = 0,5 n7 t! s) @& h( N+ X
.gpio = DA850_USER_LED1,8 s' r, E/ R) ~. G9 L1 e
.name = "user_led1",
/ I; g' @1 G5 f( j2 W .default_trigger = "default-on",5 s' h3 t* B. ]9 ~: i" Z
},/ a6 `- Y) Q" ^' W; c5 ~+ N: m% h
{+ p$ \; s; m$ \
.active_low = 0,
/ k' q ~% i9 @$ w' o+ M- }- o; _ .gpio = DA850_USER_LED2,, A7 W/ T/ x* L- g# H9 ]
.name = "user_led2",& s1 w! d. C; [
.default_trigger = "default-on",
1 T, \+ U2 m, V% D# n2 G# W },
) p1 R. r; D+ w! t3 `, D {
) {: h7 Q$ D# M* z3 f .active_low = 0,
( y: c y) {9 H6 f1 s; L2 H* d* e .gpio = DA850_USER_LED3,
/ o# {; T% z$ W, W4 S .name = "user_led3",6 M% ~8 r5 o/ I2 H
.default_trigger = "default-on",
) g; q, e$ b ^, Z' q7 m! N- B },
" Q6 v% h* p6 ~6 H L};
3 `. X& ?* R- X V, K; h2 X+ }; g! w* X- \
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 Q1 S8 n! G% P9 V .leds = da850_evm_tl_leds,% ^6 I, i3 q I) O: k
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),5 e; L2 K% ^7 r9 j2 W3 {" @
};/ d3 f% b0 a6 \* v
* Z3 D% W) U2 E0 C# b+ a7 qstatic void led_dev_release(struct device *dev)
$ l. ~2 b3 I+ O& u3 j{- K% t' N) B0 `3 k
};
. v1 h8 P7 R* E4 S
& `) ^# b9 N9 s& S4 p+ n! @static struct platform_device da850_evm_tl_leds_device = {
9 P0 Q! {+ g9 y; \9 K: I, t .name = "leds-gpio",
/ j" y5 z2 p& |3 V* J .id = 1,0 F! Q% V. O0 D* \7 f
.dev = {
; [, q6 F7 l+ ^. _& e .platform_data = &da850_evm_tl_leds_pdata,
! H8 {" F$ C% ~* q2 ] .release = led_dev_release,
/ t. K8 x3 f$ j+ u. j }
# q, z, I- Z6 S) M& G! }};
5 o$ K! X* Y' B* \
6 ~1 d* s% b. J2 istatic int __init led_platform_init(void)
9 R& i+ B) f/ u' _, s{% `2 r+ n. Z( l( D! @
int ret;
2 e0 m1 @; m# h1 q3 _#if 0
( b) a: u1 @- h ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! B4 e6 B1 a9 s1 U2 T! p9 p( X if (ret)# _' h* x; U1 c+ a A
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- j: [/ P3 N$ m+ C. A4 l
"%d\n", ret);' N" I9 P2 ]1 t6 D4 S6 X" T/ R
#endif
7 o3 N5 N; B5 h, K ret = platform_device_register(&da850_evm_tl_leds_device);
) y- z# ]* j+ [2 `, s; J2 ~ if (ret)4 ~0 G6 ^( H1 R: J5 j, P
pr_warning("Could not register som GPIO expander LEDS");3 {( i- a/ R5 x9 e0 u3 P
else
3 a+ R# b! g! C1 H$ Q! S ? printk(KERN_INFO "LED register sucessful!\n");
- E# A2 o* v: H1 u* k' f& J
5 L! \: G' C. _3 u8 A- L return ret;. s/ I! {" i' _( a9 j1 X
}
% m2 ?" q& K( e% W* Z+ K
* W; Q4 h1 O0 l o$ rstatic void __exit led_platform_exit(void) [) u! M8 J( o/ _5 j3 L5 P! U
{
: b b( X" k: g& g0 ?2 K platform_device_unregister(&da850_evm_tl_leds_device);6 P/ h7 E: L6 I% c! M
. V9 h5 q3 @" j9 m7 t, @2 ]" U7 \ printk(KERN_INFO "LED unregister!\n");5 H8 i- w+ d2 X |4 o. U c
}
- i' x! R- B c$ x% x3 l1 E0 {0 J$ M$ l# K4 L* n& n* N0 O
module_init(led_platform_init);
5 o6 {" w4 d2 a' X7 rmodule_exit(led_platform_exit);
4 c) H( l3 A2 w7 N1 [! Q. X0 Z( ~& @& L& z5 ?9 L' f( x; i( [
MODULE_DESCRIPTION("Led platform driver");3 f( [; ]) y/ f+ s$ y& i
MODULE_AUTHOR("Tronlong");
. M1 ]9 L Y8 t7 b6 y8 tMODULE_LICENSE("GPL");
' L, v* |% p( q: B% g5 ^; Q) A. v6 R j. P
|
|