|
|
求大神给下面的程序做注解,请稍详细些,谢谢。: ~: [/ ]* I4 U1 D
#include <linux/init.h>
' Y" g' P( [& `- Y b; @. H; `# e#include <linux/module.h>5 k$ M! e9 s- Y2 ~" F9 D
#include <linux/kernel.h>7 c( T# @/ l# W) D- y; Y* g
#include <linux/types.h>: v8 q& `/ Y4 A7 A; t
#include <linux/gpio.h>
- [$ ?% N8 K/ }( s7 ]" b9 M4 e#include <linux/leds.h>6 A6 v; h1 I: J. P2 k
#include <linux/platform_device.h>
% [ Z4 y# Q! j: p7 e/ L% Z$ w
I1 U- _3 w' s2 G( W#include <asm/mach-types.h>( }& g+ w7 ?, y# [1 R+ W5 s M0 M
#include <asm/mach/arch.h>
0 Z& g$ `5 q8 d; B9 T#include <mach/da8xx.h>
: l: Y; S9 ~9 W7 J#include <mach/mux.h>0 Y, o6 P! t" r1 K0 Z
* n: Y0 [! f' F5 W#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)4 a V0 _3 j$ { Q
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). u @; t+ V- V( a" v ?2 W
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
2 S/ R# r7 W2 r+ @; f( I" _* ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! }+ M2 Z. q6 y! u% \1 {& B, C5 ^0 G
, l) J* u/ M' d- B# k% T ~
/* assign the tl som board LED-GPIOs*/
* P6 \ p1 A4 \- m, [) }' P# K' zstatic const short da850_evm_tl_user_led_pins[] = {
# ?' r) m) r+ g, I2 g, ]; n3 p" h /* These pins are definition at <mach/mux.h> file */
J/ O: Z6 C4 F# r0 } DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 E4 K( Z: m/ p5 |% b -1" C/ k% L# h! Q6 m
};
, r( Q* i# k: K }9 C! b9 M+ J3 x; x: n7 ^$ w1 d. }2 p
static struct gpio_led da850_evm_tl_leds[] = {
' ?% ^& c$ b; D8 N {
! q7 B- P$ ~" k, V0 N8 L. k/ g .active_low = 0,
% x6 L9 y/ X" l0 ~ .gpio = DA850_USER_LED0,$ p/ s% d2 l( [! _. O! b6 m% [
.name = "user_led0",
8 ^% L" a1 E* r .default_trigger = "default-on",) l" C, @& N- r
},' M1 N8 ]8 G4 O1 \; a6 y. y! u
{- E! X7 o, r/ h7 S& @* c
.active_low = 0,. l n' D# J; v7 {% j
.gpio = DA850_USER_LED1,
. ]/ V* F H a7 @ .name = "user_led1",4 ^2 W! v* n5 {0 m
.default_trigger = "default-on",
" z. {6 Y5 i r: w) p; b, v },
4 x( O7 R9 V0 S- [, Q8 f {
, s/ x0 r3 O" w% \* p! t .active_low = 0,
* f9 b3 }* W- N .gpio = DA850_USER_LED2,
2 N8 e) N% C# s5 m5 |- | .name = "user_led2",
% Z7 d4 T, P \% e .default_trigger = "default-on",
& x4 e8 ?' s7 c' ]# r4 F9 X },
! Q0 z: Q% b3 O1 N% a9 g" x {5 H4 d, M9 D- l
.active_low = 0,, ]% O9 w# r c1 I) @# m
.gpio = DA850_USER_LED3,9 t4 {7 a6 v2 G8 @, T; q- X; C
.name = "user_led3",
0 e" ~+ j: o1 r+ h .default_trigger = "default-on",( C9 e5 ~/ S* t$ A+ A9 x! ~5 @* a
},
) _& ?2 d' |# u( w$ B" |};
, P6 Y1 ~: ^" P# h; \, }, P
2 d2 C- _! E$ I) q5 |" Vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {8 D' c# J6 @: q9 S8 t$ {" i
.leds = da850_evm_tl_leds,
4 w; V& ^) G- G! r j6 g1 q/ l .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
: n1 ^9 ?8 z) i/ Q# n0 w8 v' Q};; i9 m# }, @/ f3 G: p9 G- w' i
1 {; ~, { S) B, A) \
static void led_dev_release(struct device *dev)( s0 ~: V; |; b# C
{0 ^3 z" m0 H+ J
};# Z* k0 y" O# c' u
. B( o; Z5 P {
static struct platform_device da850_evm_tl_leds_device = { I; _9 H& h) s y5 y+ z7 ?, G- H, m% H
.name = "leds-gpio",/ H8 C8 @& J2 I+ H" D
.id = 1,& R% p9 n, N$ j$ N- h
.dev = {6 |. w- C; x( ^0 d& ]) p% r: [
.platform_data = &da850_evm_tl_leds_pdata,( M. B! ^2 [9 W) L
.release = led_dev_release,
3 z @4 Y, J0 J+ K3 W) y6 C }
3 g/ c6 A L- ^};
# ]/ d [% c2 f1 y
5 ]/ V+ @9 |. ?) gstatic int __init led_platform_init(void)' e: F; n) l& }2 ^! k$ Q8 q( o' B8 \ w
{. X( Q8 w) g* d: D( s& S
int ret;
h- @+ q5 O/ z D#if 0
1 B- m9 i# \" ]+ }* Y% R7 }# s ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 q8 ?! r7 J, g
if (ret)+ }, k4 w1 _! C/ n9 e( v& O! h
pr_warning("da850_evm_tl_leds_init : User LED mux failed :" M3 X, ~8 `; c) F$ c
"%d\n", ret);& t3 M9 F# K9 o5 M# b* x1 [6 a
#endif
$ P6 G! d- W6 t0 U7 `7 p' } ret = platform_device_register(&da850_evm_tl_leds_device);) d1 f+ m; L3 J2 {! l8 {
if (ret), k0 F4 Q, e2 f1 W$ R0 w
pr_warning("Could not register som GPIO expander LEDS");
% P: G- E5 r2 U: M9 l+ w+ | else
; F) S: c7 {6 `& Y! n3 X5 S* a4 s$ Y4 r/ F printk(KERN_INFO "LED register sucessful!\n");9 I O" @- G/ q* m; l/ x# v' o* D
4 Q+ T& j1 j0 [# K; Z/ X8 }
return ret;# _. a6 |3 v" H E8 e% D R* S7 ]
}
7 X( C0 L' [& B0 |( \. u3 J+ @$ ~# i0 ~! z1 G. [) d
static void __exit led_platform_exit(void)9 V P, V! J, `$ ~7 t, Y/ U3 [
{
+ n# \; {. B: ]+ x. Q9 k, d! w platform_device_unregister(&da850_evm_tl_leds_device);
4 |1 J) b5 d+ B5 Y1 P5 k/ \3 \5 }9 U0 h# M% {' j. W
printk(KERN_INFO "LED unregister!\n");! p3 o. F/ z x1 \
}
! t4 N* k' Q0 d" E* j9 q8 J S: U$ H' h* Q x
module_init(led_platform_init);
4 u2 M3 c$ X# M3 q7 k$ _module_exit(led_platform_exit);2 c, P$ a! o& Q% h, }# R
% I! D7 V- S6 W2 j" p w0 ]9 n
MODULE_DESCRIPTION("Led platform driver");
$ O2 g3 m Q2 C2 QMODULE_AUTHOR("Tronlong");
+ i& B0 v! T5 h- K8 bMODULE_LICENSE("GPL");& j, _% Y( p. ?
/ E( |: _' d4 P g; ?% B |
|