|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
$ i* c# m, R3 N#include <linux/init.h>
* H3 c2 Q7 C" ]! H#include <linux/module.h>8 [9 T. t6 v+ q3 _
#include <linux/kernel.h>
: l. u; C6 J* ]#include <linux/types.h># D( L8 ?$ O T: A" ~! Y
#include <linux/gpio.h>
8 s9 e0 P9 S' i) e. E/ J' [8 G) {#include <linux/leds.h>
- _6 N- l! f u) l8 Z4 |#include <linux/platform_device.h>0 t4 G) o7 d* o& t
$ L( [8 I$ v" J. a3 A, H#include <asm/mach-types.h>
8 M8 g7 m: n' n: n#include <asm/mach/arch.h>
6 S1 ^' \# O h! R. f#include <mach/da8xx.h>
8 K+ L) }, e% s) }: G! s% f8 i, {0 W/ n#include <mach/mux.h># {! T( [# W. {; @
% B* z5 Y S& |% n#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! r6 a7 ~0 x* N# Y#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)- J$ H+ G9 \2 ~6 M
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)8 u" i) b9 R7 d5 b% [7 |* ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* K$ `* H$ T/ t) R. ^
1 S$ y: @8 h* h# i1 f Y; A/* assign the tl som board LED-GPIOs*/% G- }7 `. z- `/ L
static const short da850_evm_tl_user_led_pins[] = {2 @3 I4 V: B( A' V7 e* x
/* These pins are definition at <mach/mux.h> file */% p5 p, k3 x+ t4 P9 Q* N3 \
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,/ H. _* H( v( i4 R1 P8 a
-11 O; f X/ N8 ^$ c$ z, q3 l1 v6 N
};
8 V" @' K) f V7 Q7 p! d ~4 M+ b6 w! U# ~4 I$ {4 g3 V, K; s+ j' l
static struct gpio_led da850_evm_tl_leds[] = {
9 A/ ^! ]8 m2 O' t6 ~- }0 [! s9 ^: B- r9 \ {
4 U5 I6 u$ o. m( u5 A% } .active_low = 0,7 I1 n5 {4 i9 a1 U; Q4 m d
.gpio = DA850_USER_LED0,
+ f4 f% n/ |# r4 @- A- P .name = "user_led0",
8 |+ e4 Q5 t6 k. b: Q s0 g4 t. i .default_trigger = "default-on",
7 `' Z! e4 e+ s },
/ `+ N- K% Y y) C) I {
4 H8 V* q# Q) c& K3 g .active_low = 0,
7 C# N4 X8 D2 n8 ]& f .gpio = DA850_USER_LED1," J6 j) p7 q7 ]9 k
.name = "user_led1",
6 N$ e* D$ w; G0 J/ D" T .default_trigger = "default-on",+ k6 r, u% c% |' @9 C9 F0 q; E
},
" q/ I, f: s. {0 A {
A) ?; t. k3 P8 z- e5 x9 B .active_low = 0, R! U3 e& C* N) f
.gpio = DA850_USER_LED2,7 P1 @% e; Y& s! K8 |9 l/ }
.name = "user_led2",
7 r2 w& z& b" X ?1 r- N7 C) Y .default_trigger = "default-on",
- L& Z7 F% G; l- j! q- ~$ l/ L },
& U- {/ G1 S; K) n! f* q {" {2 I! a. V" N/ }: r8 G
.active_low = 0,
; q: E# }3 o k w7 N0 a .gpio = DA850_USER_LED3,
+ B0 t8 J: Q* L3 o6 H9 D. S .name = "user_led3",! I8 `3 T4 B) {
.default_trigger = "default-on",
- p$ X; _8 W6 d) y9 P1 [& Q3 a },: n3 K# @2 O2 c4 N: m. M5 M
};0 d* c2 {" h; s. c1 H
; j' @; ^5 J2 o! h8 k$ _4 {: Vstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% B# ^% D* |/ O, K; S( m
.leds = da850_evm_tl_leds,
( h# r& _6 @/ N3 z, Z; ` .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 v; p* _ A7 c3 z+ K/ o};
, r! I9 ?- i+ \" k- i4 g0 N; J" X7 |) ?3 g7 K7 K$ y
static void led_dev_release(struct device *dev)
0 v, ^0 {4 E- j M{0 T( L! s& p. f5 ?
};1 j' D/ w/ h' Z6 V1 I# \ x8 @0 }
5 g W8 J6 w: a) X, p: x; ?2 [
static struct platform_device da850_evm_tl_leds_device = {
0 |6 Z$ M" Q2 f+ R# l .name = "leds-gpio",
* Q& x% c$ J$ k6 G7 t .id = 1,
; M* g, L' O+ w. ? .dev = {
! j; O; Y- N% E& N+ p, W6 ` .platform_data = &da850_evm_tl_leds_pdata,
0 O& Q: x9 H3 q1 d2 L .release = led_dev_release,
! d! F) s* q: K }
' B4 W; C+ p4 r% }$ r) I9 X};
: c3 v6 b1 }1 ?# P7 f, s% j4 Y/ E) z5 i5 g& {
static int __init led_platform_init(void)
1 j: |" }# ]- p{8 p$ ]7 X0 g+ x
int ret;3 s$ a' B \: L/ k
#if 0" |' k' V( F, \+ g# h+ ^: m
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);- _' p' S1 \( y( V) i/ s! T
if (ret)
) V1 p9 M/ y5 ]9 I2 ~ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"( X5 m% r' q5 W$ c* _) n9 s4 _
"%d\n", ret);- d, ^; ]1 c) |& l3 G
#endif, c0 N& N# ~% n, Y2 q0 M0 y) W
ret = platform_device_register(&da850_evm_tl_leds_device);
4 l/ }1 H5 ~6 N6 g$ _) X# B! d if (ret)
0 F3 [( P9 r) p* U0 K+ F& ? \1 i8 d v pr_warning("Could not register som GPIO expander LEDS");) n9 g' c. l2 G1 B, b
else
: V& _+ z! _3 g- p" [& n printk(KERN_INFO "LED register sucessful!\n");
$ V; o; y0 N9 _$ p0 B" m1 j) H& d* z( B( I
return ret;
7 ]) K, |) [" |( O$ t' @- e}. x1 P( C/ `/ [4 L% ?( D/ p
; S' g/ U# _* l l K# n& e9 {6 istatic void __exit led_platform_exit(void)
& @" J G$ O; E8 F{
4 u& F, K6 Q0 R5 C3 S platform_device_unregister(&da850_evm_tl_leds_device);% b, h# i) j7 @+ I$ V R8 i
9 f& i3 D# F) ^! q$ `
printk(KERN_INFO "LED unregister!\n");
# i6 R/ M( F- ~' [5 T# z5 }}
' A% b, ~+ c, u& E; W0 C
2 L8 t4 _ M2 [module_init(led_platform_init);
8 _' q# L+ M& y1 w7 ]% p# omodule_exit(led_platform_exit);5 ^7 C/ t% H5 v+ ?4 U9 O1 s
7 o" \; _5 m1 V( g% O6 JMODULE_DESCRIPTION("Led platform driver");
0 E$ {0 ]) x' K' c7 Q$ KMODULE_AUTHOR("Tronlong");1 i; D( z @: ?3 o
MODULE_LICENSE("GPL");; r4 }9 q: l" p% t
( T( \9 ]5 `9 I' C
|
|