|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
6 s( f9 G) z$ B" E& k#include <linux/init.h>
; U$ ?8 `9 M5 n$ K8 L, {#include <linux/module.h>0 x2 b+ Q( n5 X- X& A& A% U! w
#include <linux/kernel.h>9 X8 H) |' ^# ]7 ?3 E! P: u
#include <linux/types.h>. A( S+ N! E! r' r* z9 v, B1 J
#include <linux/gpio.h>
7 Z" C2 b) Z, f2 q- p#include <linux/leds.h>4 m4 c5 k2 `, ^& v. R
#include <linux/platform_device.h> P, d6 J1 u8 {5 @0 w) |) [) c
3 u2 z* b3 b9 [2 @6 g7 d; [. I#include <asm/mach-types.h> l6 s$ s) Q% ]* M
#include <asm/mach/arch.h>' B0 |$ s: k, z1 u% ~0 {
#include <mach/da8xx.h>2 r1 v G3 f$ k5 l
#include <mach/mux.h>7 U% {5 J, d7 p$ @
. n' y" u6 ]3 I$ X% w
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
8 m7 t, k4 y- V! r e& a0 ]' {, v9 T#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
+ y1 l, a8 I' L9 j) A" W#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)! W3 [% m' k9 [
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2). r, D3 r6 x8 P$ a5 Q" A( n& p
5 ]1 o# {& a! `) U
/* assign the tl som board LED-GPIOs*/
! ~& e& k' |( d$ D8 \static const short da850_evm_tl_user_led_pins[] = {
- }1 ^$ S# W5 \$ h' F+ s, m/ \% W /* These pins are definition at <mach/mux.h> file */
" X0 ^ f$ z- A- a DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% E/ P: a, ?+ ]2 a4 t# f& B
-1) H0 i7 ]' {0 M5 `
};
9 ^/ l% }7 f2 P& B, E
0 M$ _% h) C7 W9 h" Tstatic struct gpio_led da850_evm_tl_leds[] = {4 ?2 q6 B# }# t, X6 z9 G
{
* E2 R7 s; u8 _& F1 m9 |: y0 Y .active_low = 0, c6 N7 t; f3 ^$ f6 J6 t/ R
.gpio = DA850_USER_LED0,
4 \# H) I* l$ T2 M .name = "user_led0"," {1 x; ?; G" Q3 L
.default_trigger = "default-on",( H# w( W: d1 Z2 B2 }6 X
},
# I) \* B! t& G1 E/ Z {
3 ~* }6 ~& U& k+ Y" J& @$ h .active_low = 0,7 R9 d2 F% E1 @) Q2 A; U
.gpio = DA850_USER_LED1,3 y; `/ \! N% ?7 n/ K
.name = "user_led1",
- S& \6 H G( K$ n .default_trigger = "default-on",* [! s2 D8 _, u* q
},
8 |! o% P5 i0 y0 W7 ^ {
5 B" s6 ?6 @' _* I- F .active_low = 0,& l2 r5 f- f9 w4 G6 L# I0 L
.gpio = DA850_USER_LED2,
- h! ` O' I6 Q' X, ~ .name = "user_led2",4 w% g; f7 z: X, i c8 A
.default_trigger = "default-on",
3 O6 [- ]% G2 U# _3 K& x J2 h },
0 C) S1 T. B* b0 ?( i: W1 r {8 E, J- @2 f- U: ?6 `
.active_low = 0,
) r4 P7 m# h5 s% k8 _ .gpio = DA850_USER_LED3,; Y( G0 o" c4 ^
.name = "user_led3",8 k! c; H2 C, K V/ W; Y
.default_trigger = "default-on",+ o2 u) \( @0 e+ P9 h9 |$ z
},+ Q# s1 B# e4 @
};
* `# E1 `; u1 n7 |# }, A8 T; q9 J
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& ]6 T6 `1 t5 i) o
.leds = da850_evm_tl_leds,
" n6 |- O; w0 P* g3 H, q .num_leds = ARRAY_SIZE(da850_evm_tl_leds),# P: s w- B5 ?# L0 Z; z
};0 F3 R* z/ c* Q5 ~# m) b% A
+ t- @. |0 P/ _4 O1 V8 g# }
static void led_dev_release(struct device *dev)' V) C5 X; n4 G. f' K }( Y- J
{
/ K5 C8 G" I: L9 }# o};
" G. s" n6 K4 w1 [% I5 p) x
% b6 J# h, ?: W6 Kstatic struct platform_device da850_evm_tl_leds_device = {0 I6 u' m/ D6 B9 ?( H
.name = "leds-gpio",0 j- |+ g8 |0 Z9 \+ Z* u
.id = 1,
3 s5 v( H! b& I) q" J5 L .dev = {8 h& Q# I9 C' m3 s
.platform_data = &da850_evm_tl_leds_pdata,! z( S3 l1 j( G" r) D0 p0 ^( Q
.release = led_dev_release,2 g2 P5 P3 a5 d- A0 ]: S8 ]
}3 ]. f& V( U9 ?* w$ A" i8 q
};
- E! C9 q7 C& c6 l, ~% K
( u9 ]3 J ^4 t1 [8 r/ }5 a8 }$ fstatic int __init led_platform_init(void)9 o4 l7 W U& h
{/ ]9 N4 L* s& m$ `0 }
int ret;0 R; q) |8 t/ J, K8 ?9 s
#if 0/ ?+ G- q/ t: W8 ~ a; q: O9 P+ P0 N: l
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' o0 [ y) j5 u' T
if (ret)
; V7 p# H$ W# j; O1 J c4 P pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
. g$ I: a+ D1 Q8 _/ r4 M3 x "%d\n", ret);
% J) y" ^5 w- k! `$ m) n#endif
& j+ L: g4 {6 o+ i! R6 g ret = platform_device_register(&da850_evm_tl_leds_device);) N9 S2 W( u4 G9 M- @
if (ret)# Y2 I. l' v, {7 ^0 @3 z, J& \
pr_warning("Could not register som GPIO expander LEDS");- F: E; q {1 ^7 w* h
else, b; J& V3 y' b) [, @# j6 v
printk(KERN_INFO "LED register sucessful!\n");
, b5 s9 p8 b* _+ `4 g! M
4 F2 c- a g6 u% i }9 w return ret;
! k3 C. i, r; S1 x2 ?: ?- O}
Z3 w' R# e2 J4 k$ w. l# B8 A
- k2 G. h8 B4 N1 S: Vstatic void __exit led_platform_exit(void)( D4 q- }/ ~$ Y: n
{
( Z& w' b! f' [: s; u9 Q platform_device_unregister(&da850_evm_tl_leds_device);1 O% a0 b2 H* m9 B5 _! d
7 Y& X- @# X2 |7 @; d printk(KERN_INFO "LED unregister!\n");
6 M& ? f0 V ^2 m}
" e) t; G( V( j% H1 j) k g* b$ p1 S R& ^: x* U
module_init(led_platform_init);6 }- D2 b, |& T$ U
module_exit(led_platform_exit);
5 B8 F* O) U) _9 G
/ ` U, M z0 v1 _+ xMODULE_DESCRIPTION("Led platform driver");( _: f$ s( [: O6 L' c
MODULE_AUTHOR("Tronlong");9 _9 w, p9 S, h$ m* K3 t
MODULE_LICENSE("GPL");. ~ t2 ^, z' A3 ^4 b; w L5 u8 ~
. f7 v' U7 O& R+ ]$ D3 e- Y n! H |
|