|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 B8 y5 B, N% P#include <linux/init.h>7 }" |% r% }9 W' Z9 d3 G' c' n5 }; B
#include <linux/module.h>
! @5 o% d D T1 ~% h0 w#include <linux/kernel.h>5 |7 d& q6 n+ ~# @0 x5 _: d9 U5 z
#include <linux/types.h>% R0 j! W& a- l ? Q3 w5 u& v
#include <linux/gpio.h>
5 J6 @9 S$ Z8 A, b#include <linux/leds.h>
4 r8 F* {8 a& u" h#include <linux/platform_device.h>- ^7 G0 Q( r/ }! @6 u- ~
0 ~! e% D$ B. o% E# s/ p#include <asm/mach-types.h>
/ g4 d+ h$ Y& l7 l- S#include <asm/mach/arch.h> ]) C% B4 h9 S9 O9 f) n
#include <mach/da8xx.h>
9 w$ y+ M) r m! w, ~#include <mach/mux.h>) C6 e2 P) K% z" J
9 S1 g( C! f4 D4 `( Z/ U#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
! C, v$ u+ t- [5 F! z* A0 q#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
* q5 Q# `; T/ `1 W: ]#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, u( I9 u9 s! n6 k#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)* L1 a/ |9 l8 l( t
4 P, ], T" G8 P: r0 X
/* assign the tl som board LED-GPIOs*/, v1 U9 D! `3 |6 H/ l" D, l
static const short da850_evm_tl_user_led_pins[] = {
) m. o. Z) w0 E; } /* These pins are definition at <mach/mux.h> file */, |7 R# {7 i" ^! h2 v$ W, b
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! b- r+ ^, K& h3 K; r -1
' [2 A; x+ m- }, p* N};+ s) u% L0 ^1 r7 I! |
) d$ R* |6 ?( e, a8 R3 M% dstatic struct gpio_led da850_evm_tl_leds[] = {. O% C3 H# ^) O, @8 y9 J# U+ T
{
f+ j1 v- |" ?5 d( K) t .active_low = 0,5 T5 b' ~9 m* B4 B8 L
.gpio = DA850_USER_LED0,8 p9 {' a' U8 d5 Q& @ |
.name = "user_led0",
2 a1 P: K% V9 s! U6 G! o) e. q .default_trigger = "default-on",
Q# l( Y* ^3 \- _0 b },
- B/ d* n7 k ]5 e& [& D; h9 Y {
4 p4 ]4 T' A7 r) S& T3 d7 q .active_low = 0,
. a; O5 s+ y, s1 G .gpio = DA850_USER_LED1,1 A/ {; j" U+ o, ]7 O6 O$ t
.name = "user_led1",
3 \$ Y% ~, b# z3 E$ A# {6 P4 i8 ] .default_trigger = "default-on",
9 _5 ^) H9 }/ \6 m },0 K" K% j! C X- \
{! j+ ] |7 K! S* G* }; T+ x* l
.active_low = 0,
, M8 j2 ], j M$ {& `+ N; u, L$ {, j' ? .gpio = DA850_USER_LED2,7 t' Q, B1 ^$ K1 c" L
.name = "user_led2",
' [; B) D) p, Q8 Q/ _9 T, C .default_trigger = "default-on",
/ N8 K4 ]1 W4 |: l, g5 Q4 h },
( c4 a: A0 x9 B* T {5 n9 V' s- k3 P
.active_low = 0,+ O5 @0 ~9 J/ A. H. b/ M
.gpio = DA850_USER_LED3,! `& ^. I# J- ^+ h) z* \
.name = "user_led3",
; ?3 \$ d- T) F8 o8 l+ z/ @ .default_trigger = "default-on",
+ ~, b$ C# `6 g2 E- f },7 L" }1 }$ F; i' C6 w( t* Y
};
0 t3 }* F [6 U% @3 W: O y0 G& T0 @* A! Q
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {$ o/ ?2 c. Z9 C# k6 F
.leds = da850_evm_tl_leds,
" P$ |- M8 G5 `. b) ~ L .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 Z" o( P: l: C) {2 I/ g. F};; A5 O* I n0 D: v3 N+ B/ d
, i C) u/ R/ c0 f8 cstatic void led_dev_release(struct device *dev)3 b7 z5 p- E% H x6 K: K9 `6 u6 h
{& `% j1 P! p3 [6 E# C
};
1 {5 w& {6 S0 g# S+ c+ W+ m; n) T! O! ^* a3 R" v
static struct platform_device da850_evm_tl_leds_device = {& j- e* \6 n' k1 k) ^% _
.name = "leds-gpio",
% |& H1 ~1 M7 p* `# r' K .id = 1,2 T, t$ s) Z$ H+ ]) Z2 C
.dev = {
9 [1 ~/ R: E8 N; v* R3 c2 W .platform_data = &da850_evm_tl_leds_pdata,
# Y# [/ X7 F7 ^+ f .release = led_dev_release,3 v- N h8 d7 y6 v) V/ I& D
}- N4 X1 c3 y% N) v. Z
};
: H4 k5 B. g) z8 {
1 V/ K+ s0 i4 K8 wstatic int __init led_platform_init(void), v( u8 E/ C/ s4 S
{
' i1 N5 a O) ~/ N9 W- y int ret;& C+ ?" V$ N( _" O, q$ Z' t
#if 0
, n0 ^: S& |5 H9 A2 P# }% @ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
3 c3 d" m1 x1 ~ if (ret)
2 b% Q; `! ~* E& C) u3 j) t pr_warning("da850_evm_tl_leds_init : User LED mux failed :", K; r8 @1 R% S. N( f* f* i
"%d\n", ret);
, }2 j' b# i; k* d9 O" c#endif
8 N) p5 ]( W, W v9 T ret = platform_device_register(&da850_evm_tl_leds_device);
8 [. I1 \5 }- i* J# q: X if (ret)$ b" k9 W0 M* e$ E/ M: m1 g& x; u
pr_warning("Could not register som GPIO expander LEDS");
7 O/ B- [2 |" x% _, c else/ S" P* P: [6 V8 r* `+ Q1 Q
printk(KERN_INFO "LED register sucessful!\n");$ D. C T8 Z( |6 k& L! R1 n
, g; e/ r( u% w C$ e! t return ret;5 N: X. @( o- Z2 @
}+ o+ e- p; j0 S6 Z
, s; s! q% r, p: r! C6 v0 Estatic void __exit led_platform_exit(void)0 Y& o8 r; k3 K) b. d4 X7 M
{
M5 W ?. {# F2 D/ F platform_device_unregister(&da850_evm_tl_leds_device);
3 q0 d4 H/ f( E. I u
6 T) l. ~( n7 y. z6 {) [) n printk(KERN_INFO "LED unregister!\n");
2 _1 s( m+ s+ Y, O9 d. O, [& {}: W# A- Z+ A' ]+ J% S4 a: S% [: p9 f8 O. _
3 I e8 V; [; |" l- _
module_init(led_platform_init);
; C( Y5 n% p" {# A$ ~; c( w" B0 Gmodule_exit(led_platform_exit);
$ F/ A; t9 T# N7 u* K, h
8 o0 y# ~0 ~; P% z$ ~5 k% a, yMODULE_DESCRIPTION("Led platform driver");. c8 N+ \- P" r' j
MODULE_AUTHOR("Tronlong");6 I8 i- \) O3 E2 Z' x; H/ j h. @
MODULE_LICENSE("GPL");* H& w0 s; z6 J( B0 h' Q2 I& U n+ A
2 I8 n9 H! E. u7 }' N! \4 V |
|