|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
& A" ~. W+ G9 m#include <linux/init.h>
$ E7 M5 [2 r3 C#include <linux/module.h>$ r% K/ v3 T) {# i" ~, g6 p2 P
#include <linux/kernel.h>
* t- t/ t5 y6 k- C#include <linux/types.h>
7 X$ f5 _( l5 {$ P* P7 T#include <linux/gpio.h>
$ g: k; \% z$ p" \8 \: {& q; P( f#include <linux/leds.h>! `9 K# Q; K# K/ _" E1 t0 c' S' L
#include <linux/platform_device.h>2 r* U* R; t3 j/ ^
9 l* s6 Q: X i& f) `* y0 G, {- f#include <asm/mach-types.h>1 Q, \/ m* O! T) Z& A+ @" \7 V
#include <asm/mach/arch.h>
" K- j+ n) `. B+ ]#include <mach/da8xx.h>
- [) b# W* _% }- S) Z% o#include <mach/mux.h>
s. m7 J' X5 C. U# k
f2 E& e9 g: j R4 H4 t#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- m" ^' p: P. z( \% d' G
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
, N9 k3 A+ ?0 M- }4 h m7 T1 k#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. v, X/ z5 |8 z, h, q#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
" E# \, |. Y0 X5 G: p( Z: A& t2 y! _! g& k
/* assign the tl som board LED-GPIOs*/
) t& H: B. g7 \$ X7 k0 hstatic const short da850_evm_tl_user_led_pins[] = {- R( Y u3 k5 V( a
/* These pins are definition at <mach/mux.h> file */9 c: W( u) A8 A% ] c
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
5 k4 N8 d$ O* T -1
. \3 q9 U. U, M( [};6 F- z, Q6 h# q9 T; G+ ? P9 I& ~
9 ?! U3 J! D! E3 F# B" `5 r; O
static struct gpio_led da850_evm_tl_leds[] = {, s# {8 G' [5 L0 D
{$ S5 i7 x3 N0 V! u! B+ ^
.active_low = 0,* R9 b0 A+ O1 @* z8 k' q" C
.gpio = DA850_USER_LED0,$ B; M7 R3 x/ B& g
.name = "user_led0",
2 ` O2 y6 L) ^3 Y& G- ]7 I .default_trigger = "default-on",
) K; E' _) u, O9 A- u* `2 B },
$ @! I5 C( N. {% W7 C' g {
u2 F( \+ @: ?7 B. x$ U .active_low = 0,4 j+ _5 R4 D1 H8 w. M5 I5 j
.gpio = DA850_USER_LED1,
8 e; m n9 U1 d) W- O) v# N: B .name = "user_led1",5 T. w7 i- O( n+ h; `: e
.default_trigger = "default-on", }' x$ J2 Z4 q
},
7 {! {' a, { R. ~. h6 ~2 p7 n" W, y {
* a* [+ X4 j }& u* b0 N( r( O# R; G( ` .active_low = 0,* v+ t1 K; L# \) N
.gpio = DA850_USER_LED2,7 p5 Z/ u0 I5 F0 b5 p! ~! T6 X
.name = "user_led2",
9 s v) H: N% I- s* Y3 i& n .default_trigger = "default-on",
# M9 \6 x$ r, }+ `4 O% n4 J( V- x: g% _ },) ~' ^: k4 m1 k8 e R. x5 T
{
% K" G0 {* a7 ^' J7 z .active_low = 0,
' U9 I. E5 D9 q, h, w' {8 ^ .gpio = DA850_USER_LED3,5 A& ~- Q; L3 a6 f& u# h
.name = "user_led3",
& m- D/ L7 {: T9 `; u0 O .default_trigger = "default-on",
- v D/ e- h: ^ k },) o; B; e. e4 ^$ m8 @( r
};9 o4 R% b& F2 i3 r' m# }
8 |& n/ s% u: I& {3 b( E0 D4 Cstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {- X) x) e+ f2 G
.leds = da850_evm_tl_leds,, d( g/ w3 p: C" }! ?' l0 `/ X) y" X
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),- K6 n( J8 A4 R' f& e% e
};) S' s% k0 D; N9 `$ `4 t
4 J% n. K: b" m. j
static void led_dev_release(struct device *dev)
: D# C+ i" a) G2 T- R! h. X' @; l+ n{
d: [& J: d. \! E* |& G% f% A};% ^. H( ?4 ~4 X) A
* X! v' l `, Pstatic struct platform_device da850_evm_tl_leds_device = {! z B+ Z& n9 u
.name = "leds-gpio",6 v5 l1 J* D5 s4 }
.id = 1,4 c1 m( ?' o& j' r2 N* |" R' E
.dev = {
- ]7 U) \& K- s- S7 ?" G* a( o .platform_data = &da850_evm_tl_leds_pdata,* [* A9 y+ x% X$ p+ r: @5 V$ ^
.release = led_dev_release,. [3 A% s( u7 J0 r# x0 m! J
}
0 Z9 d& `/ n1 k};
$ h. f3 C3 x& P0 ~& {8 b3 K; l& x6 l) O
static int __init led_platform_init(void)
1 Z$ x. l1 J) Z. B{ n) z$ V5 |+ i3 K9 l& j
int ret;
% P2 o3 ?+ k2 N. Z+ b3 n#if 0
) d5 N9 S# T) I3 _# W, u ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);, _' W/ y# o' \5 w- n6 n/ {% `
if (ret)/ k W, r9 ^% j( ?
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 ^. C& r0 ~0 `1 V5 _ "%d\n", ret);
; ]9 [+ H5 a/ n) F8 }2 R3 |#endif9 e* z# D9 W/ P/ b
ret = platform_device_register(&da850_evm_tl_leds_device);2 p0 Q2 X. y, L7 ?8 |- I
if (ret)5 }9 y7 G/ f1 H% V+ g# o
pr_warning("Could not register som GPIO expander LEDS");
3 Y6 N1 P% V' D1 B$ Q else$ ?3 q$ F$ b' Y" D; L' N
printk(KERN_INFO "LED register sucessful!\n");
& C+ q1 v5 s% `0 ~& j( k; R
9 {: g9 D F& R. X1 W, ~6 M return ret;
$ S- Q, D- E$ @7 s}' K4 ?# \- Q U' K" Y6 l
; K" Y4 y T( Q. G. O0 j7 Fstatic void __exit led_platform_exit(void)
) w: H. r( {6 h) \ B* L{ O# r8 z0 W5 m' L* e
platform_device_unregister(&da850_evm_tl_leds_device); k) o% ~( ?+ `$ S3 W
/ r) N6 O/ b( _, P, g" B+ f1 @8 j
printk(KERN_INFO "LED unregister!\n");
8 s6 Y) D& [9 s1 F% U% p* T1 p}- K. F3 d! e F: L5 [$ \2 f, d
: Q+ s; W% @1 P0 ?+ cmodule_init(led_platform_init);
- Z: ^1 ~) p9 u& x+ s) Imodule_exit(led_platform_exit);1 w' u& I. I, o* `) D
E) i1 x" l6 l" }; R, sMODULE_DESCRIPTION("Led platform driver");
: B' I3 o( @; O( t% G2 r yMODULE_AUTHOR("Tronlong");
7 d( u# l- Y& eMODULE_LICENSE("GPL");
$ e) Y2 [$ S/ @1 H; F$ k0 \+ z# ~( C* i0 m( S% @# L
|
|