|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 y% ?3 o( f; V( V: T8 q
#include <linux/init.h>+ N8 I' f( N0 T5 H% |6 n+ z7 ~
#include <linux/module.h>
8 t' l! h1 i4 A8 N( ?; P9 o#include <linux/kernel.h>1 w7 ~5 w) W- A6 v" u
#include <linux/types.h>
4 B* U9 T: b; C' h/ W#include <linux/gpio.h>! M! G3 U. I: }$ O
#include <linux/leds.h>
) A8 Q: Q5 f- Z#include <linux/platform_device.h>% s' c V" n: S0 U: c- `0 x! f
* ~: y1 R# q$ f; r* k" `, J#include <asm/mach-types.h># g0 [5 ^6 U- t9 p8 z. V
#include <asm/mach/arch.h>6 i- @7 J- i5 U+ I( x
#include <mach/da8xx.h>
1 B# v' ~! f8 H& ~! _8 K7 T1 j#include <mach/mux.h>
1 W, q# f, X+ X0 c; N' W' f: `( z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 g3 O- @. z# [; g' |+ x5 S
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
7 `: L$ ]3 i+ k#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)1 ]" X6 [7 [, @6 z- W
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)& }& B4 j6 f8 x, i9 Z6 R
# A3 j$ a7 N# L" i, E" R7 _
/* assign the tl som board LED-GPIOs*/
* ]5 p% S6 W( l! {' D# mstatic const short da850_evm_tl_user_led_pins[] = {3 x3 S5 W$ x& ?/ Y. [% ] e
/* These pins are definition at <mach/mux.h> file */) M9 }7 i7 H' e& A$ m
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
& h. v8 }8 B5 w% G- s -1+ ^3 P! T' d; h* v& ^. z# S
};
$ X& ~. n f' u `0 {( A0 w4 O: E- k7 p6 N2 K; L
static struct gpio_led da850_evm_tl_leds[] = {' X- C k, I, \6 r; d/ R
{2 T) i7 _2 j; m
.active_low = 0,0 O; ]2 B5 W S: Q, j2 b! s
.gpio = DA850_USER_LED0,) f& o/ s) Q1 C" h3 w
.name = "user_led0",
. ]: |, g0 c2 G6 v% X) j: g: f .default_trigger = "default-on",5 s: R" j4 C* f
},
0 q/ z' c' _* Q7 |7 K {
3 |( R& o$ K& ?5 k% d .active_low = 0,4 P' [! |# T; K! r
.gpio = DA850_USER_LED1,
; |: F+ Q9 M- @! @/ x* c .name = "user_led1",
( Z$ C$ H! ], U# @/ P; D .default_trigger = "default-on",
; B. F- h3 z2 S; R; V3 x },% X4 O' |" Z! }2 G& }
{
( a+ Z- z8 a/ y5 W6 W .active_low = 0,0 ]2 d9 _! q& \* S Q4 ] N
.gpio = DA850_USER_LED2,
1 N# ]# l& b- e Z, I .name = "user_led2",
5 h3 b& V- Q- e/ `) Z, E% E .default_trigger = "default-on",
2 z3 G+ O7 q0 a7 u# b },2 W; U' x7 i1 t
{! x, P% ?, y, }2 U1 U" R. o
.active_low = 0,
+ z9 P$ ?, X. X: `1 N .gpio = DA850_USER_LED3,- T# n1 {- R3 U7 u& o
.name = "user_led3",# G- Y' H6 E: ?# b8 U5 Q* O
.default_trigger = "default-on",( q* \7 d$ ~" s9 f% L4 i" U
},
6 c& R$ w7 U! {" c! X8 Y& |};: y# f" t7 ^* n" e; p. R H9 ~. X
' |/ B+ D( ~/ @7 {static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 s `4 Z- J; c7 ]- l8 w
.leds = da850_evm_tl_leds,
# h( E+ [5 C/ v# H, l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. w/ R' x4 O' s- P1 O) |};% t: h2 d& R/ Y) ~# P
T9 ?( w( d1 [static void led_dev_release(struct device *dev)
* i$ W( L- k9 I" t. v{
i- P' j- x0 N3 u};9 A6 J# u0 L1 e1 C
9 ?) L& n/ L) |! M
static struct platform_device da850_evm_tl_leds_device = {9 P& e4 z+ U# U. w9 b- r3 X- o1 h6 [* }
.name = "leds-gpio",
: H; W j' k# y) @ .id = 1,
7 g' B% `! X' @) K1 U1 f K6 a5 v5 _ .dev = {* |! z1 s+ F x" x
.platform_data = &da850_evm_tl_leds_pdata,
! T' ` \/ C h0 P' F0 G .release = led_dev_release,7 r; I0 H+ U. @* f
}5 p4 o( @: x( T: l; Y: A. U
};* u( f' \* H' p
& L- f% ?7 R, P) a9 }( T0 Xstatic int __init led_platform_init(void)* q) z0 i5 @! s
{
; x" R P6 K/ D; V0 M; a9 r& h int ret;
" Q% F2 a0 J7 w/ w1 H#if 0
. |4 s8 O, M% D( w) k, f ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ [! h' s! E- S7 |8 c, J8 R if (ret)0 h I5 b2 G4 h4 _& {
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- i7 V" Y# C& m8 V( A! y; q# S
"%d\n", ret);! L8 x% ^. c5 \) C/ g C
#endif8 i% k: h( m4 _8 Q, t+ Q9 R4 J
ret = platform_device_register(&da850_evm_tl_leds_device);
* r7 P: u$ h7 L if (ret)" F$ ^& G' c/ ?5 d! q& Q
pr_warning("Could not register som GPIO expander LEDS"); Y2 E0 n9 m4 u# `3 z9 p
else
* D. x. o1 @" @5 D" b printk(KERN_INFO "LED register sucessful!\n");
5 r/ [! r$ V/ ^$ n! O( O, F' x: B7 W+ H6 y6 a0 t0 [( }$ Q
return ret;
$ I% Q. A, ]) n. U}
' F+ S& R7 `4 M/ k
! D* k# t' [- L, ]static void __exit led_platform_exit(void): }0 v0 J# I; A( j- I( v% m
{- q" Z3 o& }; p+ Y4 c1 s
platform_device_unregister(&da850_evm_tl_leds_device);; P% C" F- v& m3 l6 g
- p M9 X+ a) y. B/ v
printk(KERN_INFO "LED unregister!\n");% r7 b) B, k; U+ y ~7 S
}
6 G! P) ^& h) A6 l: z2 g6 y7 U# R8 z' n, Z% Y: Y
module_init(led_platform_init);. H) _3 c1 X6 k, ?
module_exit(led_platform_exit);
8 G6 h* u7 h& F' w4 H) D0 \6 {6 }. K' L$ D) i4 a0 z5 J
MODULE_DESCRIPTION("Led platform driver");
% X* v2 T1 i+ ]2 }8 ~3 }$ X4 kMODULE_AUTHOR("Tronlong");1 H% S) u3 o' A0 A- m* x
MODULE_LICENSE("GPL");
5 |5 e8 J8 ~6 R" D, B _9 `% }0 o7 g: X, ?/ R, g
|
|