|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- h4 [$ }- B% g$ \; f9 |
#include <linux/init.h>
" _8 e( L+ V6 B7 c: |3 _/ a, s#include <linux/module.h>
$ \/ C/ I: _! _9 ~" a1 P#include <linux/kernel.h>
7 q- u/ Q" V4 K5 q2 c4 p: { {#include <linux/types.h>
$ ~" S+ ?& o5 u9 {#include <linux/gpio.h>
9 K6 O3 }: X% ?8 R7 z3 M# i# s#include <linux/leds.h>3 k7 x. u7 {; R. E8 s4 L
#include <linux/platform_device.h>" @3 o% |! j* J0 o. G& d
: |: [; w+ S) c* x5 J
#include <asm/mach-types.h>
1 W: f4 ^" T! A" m/ n/ L/ k#include <asm/mach/arch.h>
5 x- u* a. j c+ v9 P#include <mach/da8xx.h>
0 j9 G. E8 U6 ~0 M#include <mach/mux.h>! {; m. w1 m, A. D) {
( p8 }$ n9 E$ l/ z- v3 I! x, p8 c#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 ?/ U. Z7 m( Q; k0 I; U' q! m
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
$ k7 q* q0 l+ i- @0 D( O+ x5 S, B( h#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)# h6 W. d$ `7 c3 r
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)! D& z3 @$ C) B/ U
4 O8 C7 K: @$ }: ~7 h/ n
/* assign the tl som board LED-GPIOs*/- {! l3 D9 V# E8 k% }; i' n
static const short da850_evm_tl_user_led_pins[] = {6 W* e% m8 M& V. p
/* These pins are definition at <mach/mux.h> file */) h j; y3 D$ W5 T4 G: p, b& D
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 E1 H$ o Y0 Y' }4 D/ h6 D -1
, l- Q t# ~+ L};
4 l" s7 C' M/ K' l
& s; m, [, ^1 H1 m2 f5 jstatic struct gpio_led da850_evm_tl_leds[] = {
% v# Z: E8 M5 ~2 d' V# C {
# h; J! T5 Q( N8 L .active_low = 0,
9 R7 }" ~% c4 ~# W .gpio = DA850_USER_LED0,
% I+ F( B. g1 f! k6 j .name = "user_led0",4 T/ E3 a5 X" Z6 i
.default_trigger = "default-on",
, O' I' H+ F; ]; Y! C& c6 A5 B },
6 O E! p. I* H3 E# X' g# k1 X {7 ]) y. D: a4 J6 F" v
.active_low = 0,
0 z- n9 e7 j! @! Y* ~) g3 x2 d .gpio = DA850_USER_LED1,
: ?* j" r# o% y ]+ c% _3 y2 Z. X* O' B .name = "user_led1",
% t. T8 [' f) d6 Q, F6 r' n .default_trigger = "default-on",
5 ]! m' [* Z: V7 F3 w* ~+ A },% @, o3 P. h9 W% Y8 m. @
{
c1 Z0 t; b( k" @: | .active_low = 0,
/ _$ T) T* U2 p7 J .gpio = DA850_USER_LED2,+ J) B( J. i- C+ H8 F& `
.name = "user_led2",& ?* A* p! H, S0 Z! L; E% ~' _6 w$ d
.default_trigger = "default-on",4 s4 q' m8 ?+ }/ h2 V
},
# U. N2 A1 l) B2 e4 J {/ ~- M; \) ~1 [8 w
.active_low = 0,
0 I7 @5 R$ u F [/ W% e* }( I .gpio = DA850_USER_LED3,( L$ @% m3 h: l& n& L1 P# b( e- L
.name = "user_led3",6 C) _$ K: o1 c$ l8 L$ P d
.default_trigger = "default-on",
. [% S U! ~+ U; P+ W4 K& U2 E },9 |8 v% ]3 u; X- i
};. W8 E9 Q% a- f( s( L
! [ `7 ]. z \, o8 fstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {1 h: Q) t! z7 m3 q2 h' ]4 y
.leds = da850_evm_tl_leds,5 m+ I# v. W/ c; p( h r2 \
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),; ?6 H) D' A. y0 k- c
};+ B- A1 [8 e# [3 h7 i
% w( K* X' P1 S2 estatic void led_dev_release(struct device *dev)) ]8 a0 C/ m7 k; l# M6 ?
{
* X. b* \: f) D/ d; s8 Y};
. z8 S. M& E) N4 O j5 v6 m( }
( O+ t% {; u+ G1 f G7 q- lstatic struct platform_device da850_evm_tl_leds_device = {4 v. W+ y( v8 v" K/ _
.name = "leds-gpio",: r/ }0 L: l, @$ B- T
.id = 1,
6 x3 c- {0 L* L" ~ .dev = {) M0 l4 Y( \6 ?, Z% q3 n" U- f! s
.platform_data = &da850_evm_tl_leds_pdata,- [3 \5 D/ h. C" N: A( N B; M" X
.release = led_dev_release,7 o$ A6 o, p1 I: F
}* o7 I6 M* [( P$ v8 i3 }
};
1 I: z- U4 b8 F) K0 A% [! t& g% A8 y/ Y0 q" w' r+ I4 x% l
static int __init led_platform_init(void)! |2 i4 k$ N3 }, L: I% `+ _
{1 s z1 p; t$ ^1 Z& Z; _3 V: u
int ret;& T! g5 b q! `/ v
#if 0* y$ C4 _$ S2 d- W
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);+ @5 F/ l; R8 ]8 I5 k2 A) H+ Y- r/ S
if (ret)
, V1 C! P" ]6 {# e, J- s pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( O$ Y% E, R _4 W% w "%d\n", ret);5 W' e3 t( W6 z( E
#endif
. T- v" }8 B/ x+ ~4 ` ret = platform_device_register(&da850_evm_tl_leds_device);% `& ]! F. W7 I _. R; j3 u6 D
if (ret)
! r, W8 m' W' c8 f pr_warning("Could not register som GPIO expander LEDS");
: W) J1 R& D) R/ E" D/ O else
4 Z4 h/ I" Q- k& p$ C) u3 V0 O printk(KERN_INFO "LED register sucessful!\n");+ w( I$ p$ e, T' ^; K' v
. j: d' k3 G: H W
return ret;
. s k4 ^5 O) p# x}7 B" @4 f# O, |- {9 B' g
% c! V9 \# G$ T/ b, B
static void __exit led_platform_exit(void)
! Y" T5 I* a: ^8 m T{ r; T+ U1 v) n
platform_device_unregister(&da850_evm_tl_leds_device);
8 d8 [ k* `9 M
3 Y- r! I1 v1 S4 z* u printk(KERN_INFO "LED unregister!\n");
( @9 t4 \; I5 d3 T1 N}$ X0 V' P1 `3 m. Y2 p8 Y2 }
9 q" \* L8 b3 x" X! X& e3 }3 Tmodule_init(led_platform_init);4 m+ g3 _3 u! T9 \5 D9 ]
module_exit(led_platform_exit);3 n6 e% ]! h2 ?6 R: F' H
1 [7 Q" N l9 Y
MODULE_DESCRIPTION("Led platform driver");8 S( R" u1 J W: b( E7 D& K6 [# S
MODULE_AUTHOR("Tronlong");: G- p5 C$ G4 t/ z, K* N) z) A
MODULE_LICENSE("GPL");$ E- Z% ^( {" F: J, {& T
& r7 p% u% [5 @: {( |8 n9 n
|
|