|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
( n) o( q" n5 M) ?" |! e: j7 }3 T#include <linux/init.h>
8 s# q6 Q- Z8 }+ {" Y3 y#include <linux/module.h>3 m& l- n; ^1 c' v) \
#include <linux/kernel.h>6 g5 X1 K& V1 ?, h
#include <linux/types.h>) Y L1 G/ ~2 e! r
#include <linux/gpio.h>
- N; W) a q }5 j- N) ^7 W6 i#include <linux/leds.h>
) H7 f- v, k2 R) W$ \+ x; p5 ~#include <linux/platform_device.h>( G3 L) R4 x" `: B* k
' A& J2 V k- J. D6 x#include <asm/mach-types.h>
. X( Y W! ^9 Z#include <asm/mach/arch.h>- U# p0 p* ?$ s0 W0 Q. Z# y
#include <mach/da8xx.h># `4 k/ k& A/ i" H2 R
#include <mach/mux.h>
n6 s. q/ o* `' `& ] E5 _7 j3 x/ W. d4 _, h$ N; j) }
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
# ? A7 g' C4 O/ r1 S#define DA850_USER_LED1 GPIO_TO_PIN(0, 5); B3 n' a; o# ~/ [
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
0 c+ c& B, ^. ]2 n$ r. w/ q% K8 O+ r#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
6 V: V- l3 X$ M; g& N$ Z% ]9 L4 ]0 x8 `8 s
/* assign the tl som board LED-GPIOs*/" [3 c D* }/ A
static const short da850_evm_tl_user_led_pins[] = {
/ u% c% _( c: ?7 n* i0 C /* These pins are definition at <mach/mux.h> file *// t; A7 ]8 y8 }. ~5 R
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,7 P, _# m- U3 {7 P1 D# c
-1
6 K, m- J G8 ?" q! [6 v};7 [* `3 p* ?$ w7 L
% i6 ?9 x1 F2 b; t h* a
static struct gpio_led da850_evm_tl_leds[] = {
; E8 o) m; k% V7 o4 j {) K" f0 k; U+ _- t
.active_low = 0,! B h1 V/ V; B N
.gpio = DA850_USER_LED0,% N4 @ M8 g& n8 \$ g; P( T8 z
.name = "user_led0",
6 u) |+ [: j4 l) `6 i# c7 i0 C .default_trigger = "default-on",( x' i: P1 y* Z2 Q- Z
},
: j5 X/ M/ t7 U9 r {$ h3 W) @. j/ U9 q: n' U1 a
.active_low = 0,
# T2 ^, L' N9 b) I' [/ C2 d: a/ E! w .gpio = DA850_USER_LED1,
( b( k; ?& s0 Y+ l" m .name = "user_led1",
0 Q+ Q- B' i0 V7 C- b# E .default_trigger = "default-on",; H: u$ {& I, J4 f- k( s" `2 n
},
7 g6 D* h! V" J7 }) z {8 y5 `2 S* F" R i1 ] ^7 ]
.active_low = 0,; L1 ~9 z5 [; W* ^, z5 O2 u
.gpio = DA850_USER_LED2,( |- K( T. i2 b. W' c- n. E, N# m$ P
.name = "user_led2",4 Q8 K3 o" f+ C; g, w1 }
.default_trigger = "default-on",/ u9 ?' e. S' }9 S7 F0 f! @# u
},
0 V C2 J1 u* x* ~) A8 }3 i0 D {7 |8 q3 u9 q3 p9 Z
.active_low = 0,( Y. i, J3 x$ {
.gpio = DA850_USER_LED3,
$ r, D& t0 x* r( w .name = "user_led3",5 M: `, {, C; d4 T0 N x2 i0 V
.default_trigger = "default-on",- s2 i8 H! J }
},3 ^& ?" i- Y' }( F. d( m
};
' o" A& R. s7 h" k. F$ a+ T' F5 F. c ^ z2 i. p4 X
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 O" ^. h! U2 `. [# x c! k
.leds = da850_evm_tl_leds,
8 q5 o( E8 s' z m8 D, f .num_leds = ARRAY_SIZE(da850_evm_tl_leds),! t' w% s5 J0 k* r+ K6 ^$ K" o6 |
};
' K; s* ]: d; i8 S2 @- i( A* `
0 G ~! C" {& a l0 n. nstatic void led_dev_release(struct device *dev)
; g2 ^& r7 w" v/ g( p8 q{
' ]/ U7 U' o/ H% b! A* z' h};5 a: I$ |+ D- U/ T7 t, [
3 e7 ]+ p* W# ~6 g6 w
static struct platform_device da850_evm_tl_leds_device = {
2 D& U7 U6 s1 u* O) F/ z$ ^ .name = "leds-gpio",, u& h8 H, L8 ?; L5 N: V
.id = 1,, ]+ a, E6 u7 m) l8 _0 A" K/ {
.dev = {& S' l0 n; \- u3 V4 V+ x. Z
.platform_data = &da850_evm_tl_leds_pdata,9 k6 b! g/ @6 G/ N
.release = led_dev_release,6 i' R8 `* _6 c- h
}& [! J, R5 i& t, t. x! C
};
- l9 I- |/ d* B# c" q2 G6 _( F) I% |- x2 ?5 a' n& U' K% B
static int __init led_platform_init(void)
& o4 t( L% H: O{, |1 F# C9 _+ Y4 `; G" @0 x' |
int ret;7 c! X [5 L' ?6 k+ |. v6 z7 F
#if 0+ ~* u( R, S8 K% W7 V/ Z+ j
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
. Z' @5 T- g, u! w$ G& \, w if (ret)& l- i% O4 H$ C9 Z
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"* o' w [, E2 R! }: ?# `
"%d\n", ret);
/ x3 d# Z, s Z#endif C9 z1 ]/ {) F3 D# e$ B; v
ret = platform_device_register(&da850_evm_tl_leds_device);
6 W6 j. u ^9 B7 U) p1 }& q+ G if (ret)
0 [0 }2 [% e3 |, o pr_warning("Could not register som GPIO expander LEDS");, S |6 d( F' r2 U% Z4 {
else% a3 p/ z- u& i& e# X. u4 @: O: ~. v
printk(KERN_INFO "LED register sucessful!\n");6 G6 O$ M5 s# h8 p, ?
! G0 M F3 N% V9 p6 e3 R U% ?# ?
return ret;
# g3 E* y. T7 k}
. ?8 I3 ?6 X/ j
9 u: [8 ^" ^7 Estatic void __exit led_platform_exit(void)
" D8 Z% P+ b8 I5 j& j+ Q7 Z{" e2 k: r: w5 ~% x6 i* B
platform_device_unregister(&da850_evm_tl_leds_device);
& t7 w: m+ n: f3 V# q7 M L! b* K v2 n& {- k, @* J7 e; n
printk(KERN_INFO "LED unregister!\n");
/ C( P3 ~) d5 w/ n2 X# ?6 S2 h}# a& Q8 B3 H2 L
' _. l3 R: f2 W+ _1 i% ?2 X2 C& Hmodule_init(led_platform_init);9 l9 a0 g! H% f0 i
module_exit(led_platform_exit);5 m7 R+ Y! M2 o/ i1 r- ]
$ }% a! w8 Y6 t6 V1 B
MODULE_DESCRIPTION("Led platform driver");1 d- z; n+ G5 Z5 [6 a; A; d
MODULE_AUTHOR("Tronlong");
2 s7 W* n$ `' N HMODULE_LICENSE("GPL");' O9 n3 }. h- `% g$ C+ a8 a; h( W
7 G% d: H0 o* d8 j' ~
|
|