|
|
求大神给下面的程序做注解,请稍详细些,谢谢。3 s4 h& ~" ^) W* {
#include <linux/init.h>/ l; s" Y' E" S& |: A
#include <linux/module.h>
5 M. E8 f4 [. w9 Q#include <linux/kernel.h>& g, D2 M& ^/ b
#include <linux/types.h>+ U1 ^# N- e# _4 V- y- h
#include <linux/gpio.h>9 w7 w: P+ s( L
#include <linux/leds.h>8 t3 z T7 Q6 ?9 N- T( a, e8 q. n
#include <linux/platform_device.h>
( S: d7 Y- F7 X: ^
- [) z4 k- x/ v6 Z; d#include <asm/mach-types.h> x7 v z7 `. g$ W$ D0 {/ R% t) r
#include <asm/mach/arch.h> }1 d5 [- \+ J+ ~
#include <mach/da8xx.h>
. Z# z( X8 U- c/ X3 L8 Z. r* R/ v# s#include <mach/mux.h>
4 N+ e9 O9 x+ D. Z" e3 O [) @8 K. j; H9 k
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! l c v# H# d#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)2 ], W9 M9 q- e. R+ u- @
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) }. E: b% x. ?# B7 i% C#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) c. c- p) s+ J: C; }0 v4 n
' q9 ^* K$ D1 z! r% B/* assign the tl som board LED-GPIOs*/
/ l3 w. T5 U% K) P9 F1 Wstatic const short da850_evm_tl_user_led_pins[] = {; E. f* L9 M3 J9 K! c
/* These pins are definition at <mach/mux.h> file */
# R7 V# F3 ^' ~/ z% K+ X( ] DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, e: w `! g) _& m' F' s
-1
# i, b. D5 m1 r};4 `! {" @: a" r+ Q* S/ L" y
, I& o: r' D. w$ f$ S
static struct gpio_led da850_evm_tl_leds[] = {' W! j! e. l6 \$ [" u" b
{8 D; @( R" w3 p" c7 N
.active_low = 0,( t- ? f" _6 T4 D1 V- D
.gpio = DA850_USER_LED0,3 u" q; ^3 \: B: S
.name = "user_led0",
0 w0 T, V; a8 G7 j, m/ P) c- I .default_trigger = "default-on",4 ]& z0 h0 e. E# s
},4 t1 ]; x2 m! N7 `
{
) C( a+ C% _6 a" { .active_low = 0,2 ]0 t4 j# ?4 J7 x
.gpio = DA850_USER_LED1,
# {/ z5 q; G# }4 G .name = "user_led1",4 `& {. L, `3 q7 K7 N
.default_trigger = "default-on",
3 S! Z# [2 W# |( A# | },, h# O0 ~/ n* R/ t1 y9 m. r
{% V9 k t& o, ^2 \7 g ]2 e9 {" P
.active_low = 0,3 |$ \! X/ N4 p4 V) u( |+ n- y$ h
.gpio = DA850_USER_LED2,
/ z& K! W7 [: w9 f7 J .name = "user_led2",, L) d1 \5 R* O. R z
.default_trigger = "default-on",1 @; R n" O. h4 T a# L
},
/ d! H" F$ `. p- J" i1 n {
0 w& h) F% e6 u .active_low = 0,6 V; o5 F8 M3 ^& Z- M
.gpio = DA850_USER_LED3,% N, j; q+ \1 `4 Z6 r5 k
.name = "user_led3",
1 H9 O7 z' H1 [4 b .default_trigger = "default-on",3 m9 a* i3 m6 F0 _* A! M
},
/ ~1 i; T, `. Y; S% V/ N, k7 c/ u};! u: n' \$ w# @( S
, {1 i+ {, z, {3 U9 B/ D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) w* i8 @" j/ J! w1 t& C: E .leds = da850_evm_tl_leds,& I% H b# w, y9 o0 c% c
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 L% t% w+ ]6 v
};" `; k7 m) V* }' _5 X, b: _7 Q
Y2 @& P6 i- L% ]static void led_dev_release(struct device *dev)
$ o7 |# @/ t1 A' j, P{, S3 E/ w4 I8 @4 k/ S7 L- g
};$ r+ U# y+ q! n- \4 b3 @
- }! T* d& ^! B+ Zstatic struct platform_device da850_evm_tl_leds_device = {! X& |# r0 c2 q# e3 Z2 r1 |
.name = "leds-gpio",% t! \# ^ _# [. N' l; e
.id = 1,. @* F0 R0 S K$ p0 J
.dev = {4 j; N! B; M9 c
.platform_data = &da850_evm_tl_leds_pdata,6 M5 v0 B* ?8 ]" C. W/ p8 [6 z
.release = led_dev_release,8 K' `" p6 e3 X. y
}# B7 h. }. e0 o0 M2 q, m
};2 x7 b4 v! w6 f+ l" k
0 M4 V3 F e4 |$ T
static int __init led_platform_init(void)
& n% R0 T0 E& F7 c% S{
9 O, i4 v; d! P int ret;
& k5 M* \( w+ X1 d% [5 A" M#if 0
& N5 ?6 I* S% C$ U7 d' x ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
D, Y$ o) }6 y" d0 a, ~9 k if (ret)6 S# q- x' [/ }8 Y3 K# D. g: \
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"3 p ?+ P7 Z/ G+ v7 Y* K
"%d\n", ret);
2 H7 `2 h7 t5 M# l#endif7 r& i2 f; @' x0 |# f. i
ret = platform_device_register(&da850_evm_tl_leds_device);: s7 n0 `4 j5 P b
if (ret)
- c/ j& u1 l, E3 n pr_warning("Could not register som GPIO expander LEDS");
0 t. b* r8 D' a" }$ x( j else. {) W! F7 O- k. ]* \$ }
printk(KERN_INFO "LED register sucessful!\n");: T" E" ^9 F, D9 C" f+ m
+ z: ~/ X* U1 s' s- g return ret;
: ^- a% w* S" z- i' c}
9 w% y. M5 R2 c- \/ D7 m4 V4 y, l& ?% Z
static void __exit led_platform_exit(void)+ c; S! x& [' P2 [ V2 E# E2 B! ?* ]
{
( z4 J1 t0 ]. [ platform_device_unregister(&da850_evm_tl_leds_device);, _8 `9 j! d+ L- n& v, `. l
& Z$ o0 V- a" R; h+ R# g/ m printk(KERN_INFO "LED unregister!\n");/ P0 ~; @+ s9 t0 a8 K
}
9 K$ w% ]) c8 @% q% B# J& N/ z* d9 A: K, Q
module_init(led_platform_init);5 `/ T7 Z$ ~$ b6 J$ x& c
module_exit(led_platform_exit);5 J: e* M0 b0 C- h$ H
6 p( _. W; t: n9 AMODULE_DESCRIPTION("Led platform driver");
( Y3 U7 e K9 @8 j* s$ w" _+ P; rMODULE_AUTHOR("Tronlong");
% C8 m) x6 o# e3 B: zMODULE_LICENSE("GPL");
- N6 M2 b1 }" L/ m. X h. g
2 ] l4 K1 D. I8 K9 ~& ] |
|