|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
8 V" w" ~2 F$ R#include <linux/init.h>( s; K: d; L4 N) i8 V- d# e! S- f
#include <linux/module.h> e& _' W. y2 u7 u, C
#include <linux/kernel.h>
5 ]2 Q, I, g" _6 W2 Q* x#include <linux/types.h>
$ R# j' L% P* O8 I#include <linux/gpio.h>1 t5 T- `' m) i4 R
#include <linux/leds.h>
9 b+ Z( ]! N; _2 X$ k#include <linux/platform_device.h>
4 i0 h! W9 a1 n: s( s* @) j" t; {
5 _" \8 W, H6 W* s* {8 D#include <asm/mach-types.h>1 w3 k3 e* a/ K' K, M( u
#include <asm/mach/arch.h>: }4 b' b. i% I r9 K. H! f
#include <mach/da8xx.h>. s4 l1 J& D, {5 W
#include <mach/mux.h>- m& @1 V/ [, @+ p5 h3 B
! }' G- U( D6 l; y" U) Q# M#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) f* I- r. `4 I8 N& @
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
: |( ?" F* Z6 v. t+ \' U1 j#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
- M, W" A( G. @% e: D& e#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 N3 q1 E9 d' _0 {8 ^' c) l
% }6 h6 r8 E6 T) d, A
/* assign the tl som board LED-GPIOs*/6 g$ _0 O' w5 B/ l% o
static const short da850_evm_tl_user_led_pins[] = {
2 C+ Y8 \8 e6 N4 d& Y+ [3 y /* These pins are definition at <mach/mux.h> file */2 r6 r5 _7 ?* q3 o
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
/ E, x0 _/ v1 F+ p3 F& V -17 @9 P1 P" ^( E9 r
};
6 h: D- E/ z! U$ ?2 u, F
5 I7 d& n* W- G% e) F' ]static struct gpio_led da850_evm_tl_leds[] = {$ s) j) o; w0 a0 Q2 ~
{
8 ~4 n; C) G) o( W" X .active_low = 0,5 U" B" U5 b" z0 w; ?; ?2 J& v
.gpio = DA850_USER_LED0,% O2 @$ c1 o/ E; X9 T
.name = "user_led0",1 D8 O8 @5 X; T' I) \+ k' d" E" U4 }
.default_trigger = "default-on",
% M* K7 |1 p0 `# C6 P3 A3 t1 g },
5 a: i# _$ [1 B {
$ z1 |* z% W! s .active_low = 0,$ ?& v b$ ]5 |0 O
.gpio = DA850_USER_LED1,
1 }9 \5 \9 C6 Y- [8 U .name = "user_led1",) E. [# B8 g! s. N% i; J
.default_trigger = "default-on",6 T U# D& n5 L$ I
},
4 L' n: G5 e6 x- e {
# e1 c5 W( T3 ` .active_low = 0,
: d" P& |1 E6 z3 _ .gpio = DA850_USER_LED2,+ P2 ?: f H+ r* L G
.name = "user_led2",
C% B4 X. V2 }) V9 e3 V9 f8 S .default_trigger = "default-on",7 U* W" u# D( z9 e6 f7 m3 [: x
},
; z* a$ } }! Y8 U# Y6 F8 a {
6 a$ I/ V. J. G8 l .active_low = 0,3 i6 |. v: M0 Y( I' h
.gpio = DA850_USER_LED3,
2 i2 x: e' A( }; v .name = "user_led3",* f5 c& x9 ?) x7 u
.default_trigger = "default-on",
$ b: A( T0 s6 @# u& H- G },: d, R- E1 ?/ V9 {
};" {, V) P5 ?6 G& |, N
, M. n8 m% n; T+ O$ h" Q$ e7 Rstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
, W& X3 P) L( s) l, F .leds = da850_evm_tl_leds,3 A* s! O. @# z
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 F$ d L- P# t
};" m% j# [5 R, h$ v* L- I
, x9 D, I3 k! n: q; X0 hstatic void led_dev_release(struct device *dev)6 Q$ V1 R* e' g. W F# y/ F
{, i8 `5 k" ^1 B' \
};
( L- o* R D3 V7 R& t- w2 q, h+ D* o6 N" u* V0 c' n
static struct platform_device da850_evm_tl_leds_device = {
+ o: u' o) n3 v. Q# d .name = "leds-gpio",
0 G, f6 H2 y3 w, O) u .id = 1,
4 d5 P* |& m4 }, ~* `& O .dev = {
& Y# K: M3 } G7 x) a .platform_data = &da850_evm_tl_leds_pdata,
8 p9 s* y; q0 l9 _9 }: P .release = led_dev_release,' f, r$ l* g! i% y
}7 H* v! ~0 U% c6 j- |
};
0 ]9 x+ W6 P) j9 D; P' v. E* b0 U0 K- Z7 N: Z# S/ _
static int __init led_platform_init(void)% O$ S0 M! f' }- u$ ]
{' i# `! N5 V) R' E" _& B
int ret;
0 l, g. B' ^2 u* a#if 0) X: J6 O) y u' i+ X3 F+ M
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 L5 [) N! ]5 b if (ret). z' ` g* g1 r3 x
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 V: ` w9 Q9 M& P D4 [* b3 B2 b "%d\n", ret);% N, o0 _% b; ]* w% I/ E
#endif
$ a# z' F. ]; U/ N8 f, n2 b. l2 K ret = platform_device_register(&da850_evm_tl_leds_device);1 K0 J8 g& S. U- I: ?2 ~( m% q
if (ret)
9 R3 k) A- G F7 H5 J: D pr_warning("Could not register som GPIO expander LEDS");
" V" S5 h7 Z) M( P else
6 |3 R, q1 {5 K/ t, I1 ^9 D printk(KERN_INFO "LED register sucessful!\n");
8 y9 \2 ?" _3 f4 }& c
5 e+ B( ]* V9 k1 H8 _( [* P return ret;
- e8 L( } A, s" F; F}8 d% W! \8 p& w- d. @0 h5 J
4 d/ c# Y: V, D& e) m' I" |: d, U* n
static void __exit led_platform_exit(void)
4 F4 H; ]4 S' b9 L* t{
: \$ r1 Z7 j% d [6 q: F platform_device_unregister(&da850_evm_tl_leds_device);
4 d. b3 z5 @5 \& Z; P u% S' S; p. w* x7 c5 S/ N. J6 U
printk(KERN_INFO "LED unregister!\n");: v! G( e. q, _* o8 z) w {
}$ n$ {! s& `) t# n
$ {/ q3 d8 L( A: T# O+ a+ F; \
module_init(led_platform_init);1 w- b1 ~! J K5 F1 b
module_exit(led_platform_exit);
6 X9 x, D+ G# U' N4 l
3 Z3 `& n! `8 [9 TMODULE_DESCRIPTION("Led platform driver");
( e Y5 a. g# G* e4 @MODULE_AUTHOR("Tronlong");
5 E/ K3 d k6 h4 i4 K% IMODULE_LICENSE("GPL");
, \5 C& D K/ K! S- {: e" t$ A" i8 l/ I4 X8 A U
|
|