|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 c8 C: Z8 W) F; @5 h+ W" }. I4 v#include <linux/init.h>
+ k8 \. W3 j% y, p#include <linux/module.h>0 p% ]# z* Z1 E1 k
#include <linux/kernel.h>5 Q3 o1 b! @ _1 [ ]" f
#include <linux/types.h>4 z7 G! ~0 \) j+ O& Z) b: ]
#include <linux/gpio.h>
Z* c2 i# k+ v5 {( j' z, c, v#include <linux/leds.h>$ V; V$ y& h G" a5 n3 ^8 v
#include <linux/platform_device.h>4 f$ Y0 o$ k/ Z0 \) c* J \1 x
* i7 w) ^4 @" N6 @
#include <asm/mach-types.h>
# s7 ~( l+ Z6 @0 T#include <asm/mach/arch.h>2 o* T9 d {; Y- W6 Q4 W
#include <mach/da8xx.h>
) Y1 z5 v' R; D+ m+ e+ Z#include <mach/mux.h>8 W( e+ U7 \2 R
( _9 j% S$ R' c+ N8 r#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# {9 z! L- k( s" K: V
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
! n7 L# d6 M( v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 d5 y1 a8 m/ B#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)7 x! @# \% e: j( H, k0 F) u
& Z1 V3 E+ B8 V1 d9 G) F; d
/* assign the tl som board LED-GPIOs*/6 _% t. E* t2 q) G, e( p
static const short da850_evm_tl_user_led_pins[] = {
2 p, m1 m( z5 Q; G /* These pins are definition at <mach/mux.h> file */
5 }# r, f% Y+ @& f7 w DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,* ?( r+ ]+ q. h5 s
-18 r6 h* C7 N" G- l, E" g
};
$ w% ^# h0 }: j) K$ `" [* G1 E# Z5 h
static struct gpio_led da850_evm_tl_leds[] = {( R7 F$ c2 X) p0 A/ K0 T- a
{% v# z7 j, h. f( G, j
.active_low = 0,& F& d% Q" M! T
.gpio = DA850_USER_LED0,
|6 R' j& f$ ?% I! B& F2 Y .name = "user_led0",
9 |$ d7 p; J' F. W4 E! U .default_trigger = "default-on",
1 W" C( j$ |+ J8 z },; n: h2 ?1 c/ }3 J6 n
{" l/ D9 @# f) z- G0 K" P' q5 W! l+ Q
.active_low = 0,+ q4 `( } S. W- l
.gpio = DA850_USER_LED1,
8 R+ e: U- J+ V5 D, Y1 ? .name = "user_led1",
4 ]9 Z3 Z1 _1 K7 k" H .default_trigger = "default-on",3 \/ ?- d! `1 Y8 d7 x7 }3 Y" x k
},8 z) o) o- U( b
{5 G( Z9 N. \3 |: i
.active_low = 0,
" w- J |. h8 L4 K% O .gpio = DA850_USER_LED2,9 g: m1 ]& J5 P0 W* w
.name = "user_led2",
" ~* {+ Z% U8 u) }& |7 y, G6 j/ S .default_trigger = "default-on",
7 w! T) W/ {! T% @( W& Y0 C% y },
/ V. l- J0 Z+ |. g {
8 z) U( j8 Y$ S2 @* Z3 u$ x4 W .active_low = 0,
0 }0 g7 h7 J) K% H/ X0 [ .gpio = DA850_USER_LED3,
( _& g0 U: D8 ?) b; X H5 C" X .name = "user_led3",& p* Y% w+ w; V' \/ [: V! k
.default_trigger = "default-on",
( I T% I* M# P. \ },
. r* M0 |8 x' w: [) Y};
, m+ o4 R5 f8 S
/ H ?& s6 a; X9 ~, V) W; ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {& T/ H3 v2 \* n
.leds = da850_evm_tl_leds,
5 p/ E. R# w, I3 r .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
- J8 _; g3 K0 X% d};: d4 f4 b9 T' H3 ?
% ~2 P0 X: N' T+ E& M& Sstatic void led_dev_release(struct device *dev)) }' y0 o, o: L6 Y4 p" F0 z
{
: D- V; W/ D- ]9 n( C};
. z. x5 e' L! c+ a$ O6 i- _# l3 P
static struct platform_device da850_evm_tl_leds_device = {* h' z0 v( p' c* N5 v) K) }* N7 v
.name = "leds-gpio",
9 }* J; u# J) L3 B' Y! @- @2 \, l1 u .id = 1,
7 ~) J: N8 [) k f% z) L .dev = {/ z2 x" I( Y. K4 s: b- o3 x
.platform_data = &da850_evm_tl_leds_pdata,1 g% _5 v B/ W
.release = led_dev_release,5 Q: x, u- }5 ?( B
}
; v, w+ l9 q, M) {};2 Y/ W7 U2 j5 U" |1 x1 m
) |8 n1 ^2 o' S3 z) C ystatic int __init led_platform_init(void)3 F; s- |& j5 Y) c
{
4 r8 S0 F$ c. @: G" @& f int ret;
2 i3 e5 g$ D. }: O#if 0( _2 ~; ?3 K) D/ D
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 G9 Z2 B- `8 J* o1 Q) ^
if (ret)
9 i3 A/ D1 M3 Q* ^ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"& H- H( O8 Z: G
"%d\n", ret);( G: l8 @' S2 e3 _: L3 m# B
#endif
7 y8 Q% e' K, m5 S H c! h0 _ ret = platform_device_register(&da850_evm_tl_leds_device);% ]7 y: s' Q% Y; f# e
if (ret)& [* K, S0 J# {9 w, b! O
pr_warning("Could not register som GPIO expander LEDS");9 f9 I0 l: T# n, n1 F' Y
else
; S# }0 x: w0 ?/ c# M+ s printk(KERN_INFO "LED register sucessful!\n");
/ e2 }, ~$ P" E- f) D5 a+ N: H# B: v& ~5 e% [, R; u! l- f4 B# D$ {9 P
return ret;4 _% U) l# |7 |2 O( O: n# p2 \! ^
}* U+ J; ?$ m1 U0 N3 G
$ i; C3 L1 Y5 M1 F# y
static void __exit led_platform_exit(void)1 \0 t% T& D# Z) s7 s8 j, I$ R
{7 L5 @6 c' X+ A# l# k. x
platform_device_unregister(&da850_evm_tl_leds_device);: G3 H# S# @6 a3 B) i! E
4 v/ C% E8 a$ P; K1 B3 [
printk(KERN_INFO "LED unregister!\n");
1 q; E: C* f& _. p5 R: r0 K}
. Z' x5 M/ q# G7 k1 ?5 W0 z5 w) B" b3 D3 B! ]
module_init(led_platform_init);
, N; G, X, O. p! d- h( }3 W! G/ t& Smodule_exit(led_platform_exit);2 L, Q8 w7 W/ f: ^5 |5 {* m9 R
9 Q6 j8 Y' C7 x) U% b- V3 Q
MODULE_DESCRIPTION("Led platform driver");/ ?( G+ N/ r* S
MODULE_AUTHOR("Tronlong");) L* m! \% s0 j: n
MODULE_LICENSE("GPL");: O D M3 @9 v# N- W8 Z
: u; s; b8 {7 U }! Y# a5 p' `. I
|
|