|
|
求大神给下面的程序做注解,请稍详细些,谢谢。8 O1 Y9 U8 t3 W9 Y+ Q9 ~
#include <linux/init.h>
6 g% a7 S, ~, P6 | O3 y- C" r) C/ }0 k' H3 L#include <linux/module.h>
4 H3 |. o3 {; q/ z#include <linux/kernel.h>! N; s/ ?9 }: x% M
#include <linux/types.h>
6 n V6 P' T5 g0 T0 U: u# D; j! S#include <linux/gpio.h>
3 R( ^; E0 H* M4 J5 X#include <linux/leds.h>
1 P+ P% p$ z8 x3 q& T. ~; u#include <linux/platform_device.h>
" B( {8 M. f; h9 \; p3 n
+ E+ `3 P" Y7 A4 j; O#include <asm/mach-types.h>
3 d& H0 a- F5 K* g/ ~ {#include <asm/mach/arch.h>
% e4 [, O# _3 F# l4 \( t! m; t4 d#include <mach/da8xx.h>
) }, g3 y- E$ S8 z* }. g#include <mach/mux.h>* y) P* R4 B' Q8 b* d: W9 Q
- c7 ?, Y2 G. r+ D$ y f$ i% J; e#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# n. ?* k8 q/ H! X
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
/ O' q) r8 [1 M; \) B" F( I#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
( L- l# S, ]- }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& {( v9 n$ A" B9 u& {1 T
% I I3 V' c9 P0 H/* assign the tl som board LED-GPIOs*/
: H/ ^3 m3 p: d* j6 e0 k$ {static const short da850_evm_tl_user_led_pins[] = {
6 a8 e5 D6 N! z: q2 P /* These pins are definition at <mach/mux.h> file */3 R, X) T$ b0 \; z: U
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 S, ~& Z/ l' B0 e
-1
9 Q1 S6 X4 n% ?& f# J};
* J; W8 E, W! {9 h v) ]
, n" b( c% m: T4 n: rstatic struct gpio_led da850_evm_tl_leds[] = {3 {3 L _* m }( h. ^* ]0 J) i
{6 z( |8 v0 S0 R4 q8 f; n3 x
.active_low = 0,
- [/ u3 n5 e' _ .gpio = DA850_USER_LED0,
: r/ T6 X* U( E t9 b+ f .name = "user_led0",# Z$ z& D6 P* L2 g1 I" Y
.default_trigger = "default-on",
' P" G. ^7 |% e* m9 ]! R },; V: r7 ^- V# }8 Z, d! U5 H1 K
{
, |8 L/ `6 ?! a6 x; ]+ | .active_low = 0,$ z% b7 F- V+ S7 v
.gpio = DA850_USER_LED1,
# f' ]% u* k+ R& n) z) Y4 G1 ] .name = "user_led1",
! f. D% z) m$ Y .default_trigger = "default-on",- D/ ~# b, Q. |3 i
},
& |- T% M' b# x. s {% j4 t- n* ^0 v/ n( e% l2 j
.active_low = 0,
" b. D; c8 c) G3 o$ J4 e& P .gpio = DA850_USER_LED2,
, J( e+ D1 c' [8 `9 S .name = "user_led2",0 D6 i% f8 k' O" w; b
.default_trigger = "default-on",
3 |' |7 R& O. [( A0 g; B },; N. l: A) }2 q# K7 }# q
{
" D7 A7 J1 V. e! p$ O2 Q .active_low = 0,
6 b$ J' d( l9 `) o5 b3 {$ f .gpio = DA850_USER_LED3,
! _ [* |; @1 R$ V: Q .name = "user_led3",% l4 I& T" l& O; U: C
.default_trigger = "default-on",
8 t/ g% j3 h# r( ]8 |" z& u. M },8 z0 V: U# M& s4 m1 [
};* {1 W! n# `2 {/ v( k& v5 `3 e
* p3 k8 h# r _: S! b( tstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 l- ~0 E6 a! ~ k .leds = da850_evm_tl_leds,
! W* d) x: M t0 J6 o, `% T/ ]$ z .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ ?8 c2 o3 e) n2 y4 h# e
};$ Y* A2 i/ Y8 I. r
" |& `; Q* H3 a" ]/ V; O/ s @! fstatic void led_dev_release(struct device *dev)
, Z0 X( i p; A" O- A2 T8 Y% T{2 S3 O" n+ y% A1 M, q! ~
};
( g3 ?* \# P9 U, D8 t3 h7 e3 A, R. G/ _8 }' O5 m9 S( X
static struct platform_device da850_evm_tl_leds_device = {
3 J }0 H# E( a) @* L; v .name = "leds-gpio"," n5 s6 J5 U u2 w3 o' }" f" X8 r6 X+ ^
.id = 1,
6 y: J) e: d0 V9 {0 v' p4 G5 Z .dev = {& K. W, b4 C' S! H, Y
.platform_data = &da850_evm_tl_leds_pdata,
2 S- t* f9 Q1 F% K .release = led_dev_release,
" Z1 W8 r; D" h3 @$ X) V: f }
+ Y. d: |; w" K! S" `) f};& u1 [6 V" h/ U" Y; C" X8 `
0 J& m5 o7 X0 O& }3 D7 Ystatic int __init led_platform_init(void)( f# C; a9 I- _/ q3 }
{
4 F! O \' O* h$ r" q+ G) B! d2 ^) L" h int ret;
+ H2 W3 Y6 @' b# g0 q#if 0" q1 a+ ^3 O/ u6 \1 Z) h
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* w. X" B$ V( I! o/ P
if (ret)
' ] d! D# y$ a pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
2 |" I* ?: Y$ b$ S) I+ {5 Y# G "%d\n", ret);
% s3 S4 \# ^; \#endif# J6 _# B9 X. |
ret = platform_device_register(&da850_evm_tl_leds_device);- `- z. b/ f4 A. @8 n% Q& P
if (ret)3 \5 E' J6 T) |7 R
pr_warning("Could not register som GPIO expander LEDS");
- Z. h2 ^3 z3 u. j* K# J7 R, z else- E( C7 R" o7 ^8 u
printk(KERN_INFO "LED register sucessful!\n");' K. d0 v' x" t/ U6 t! {
Y3 _! |/ p( E7 N5 _
return ret;; l; ]0 `3 L* ~% ?" d, ~9 i$ @6 K
}
% r; ?8 l6 T, @* X) r; K/ | w0 s" E: l
static void __exit led_platform_exit(void)
; _, w8 e& \3 T5 k{
) }0 a1 C9 m3 J0 B! C platform_device_unregister(&da850_evm_tl_leds_device);
3 }2 Y$ |: P$ L7 W% f0 R) p# B$ ^. e: @8 j$ X
printk(KERN_INFO "LED unregister!\n");" w/ N `" @8 c& U! I3 V
}9 g7 z1 m+ K3 h
! c4 S4 p# E( t; m1 `" S" ]module_init(led_platform_init);6 `2 W4 P0 D- K; e2 |5 |2 ?5 v) t
module_exit(led_platform_exit);1 O5 @3 s6 Y! a
7 O& q9 P8 k c0 Q: f0 S4 r- X: EMODULE_DESCRIPTION("Led platform driver");' S# H4 ]0 N& V; I8 J
MODULE_AUTHOR("Tronlong");
4 E6 T* W1 a% lMODULE_LICENSE("GPL");
% p5 B* @; Z" S' b4 O! `4 Q. J) Z
0 `# Y# x& O5 ~- x% b |
|