|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
* ~% t6 x5 {( ]/ g6 @0 D: U# ]* F#include <linux/init.h>8 \% o7 }) h% @0 C
#include <linux/module.h>
+ N5 p: `3 B8 f8 K* Q3 R#include <linux/kernel.h>7 r) d7 t; u0 _/ x, u q
#include <linux/types.h>
/ K% s, c; R& W8 q! N4 W#include <linux/gpio.h>
2 H5 e# |9 q# R: Q. l8 w#include <linux/leds.h>
9 C# k9 ?4 q9 O. z#include <linux/platform_device.h>
( E% M3 n* x* K" t- g
" S' }7 ?# E+ w; h: W2 ? J2 k# s" @#include <asm/mach-types.h>
# F/ g- t$ I4 ~. Q6 r; t#include <asm/mach/arch.h>3 ^9 ~' d" f8 l4 P# L8 E
#include <mach/da8xx.h>
7 C- F2 P5 L5 Q#include <mach/mux.h>4 U! N7 G. p9 Q) B* |* ^9 n0 ?0 i" {
; A: A. h |) \, _
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
) E m5 s5 @. k c#define DA850_USER_LED1 GPIO_TO_PIN(0, 5). t" Q( F0 A7 g* G% ]
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 r/ T4 a1 v1 y% j" x% L# e#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)) C' _5 w5 s. I+ O
; p1 [8 q) w! D8 o5 J |/* assign the tl som board LED-GPIOs*/
e& d3 Z8 o: M+ M/ Kstatic const short da850_evm_tl_user_led_pins[] = {
+ D: n) E; J$ w: } /* These pins are definition at <mach/mux.h> file */
8 I7 N1 `2 [6 r+ d DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,' v4 R5 K( c8 m0 t
-1
N) G& I# ~8 G! I$ z7 }3 Z# b};: `% b) y! Y; E, F2 j
1 J- \3 Y. m3 i) v) K
static struct gpio_led da850_evm_tl_leds[] = {5 s# a, Q+ J7 V+ b1 {. S1 P5 H% E
{
]5 N3 Z! B5 @ .active_low = 0,
8 n3 `/ j' {- d6 _ .gpio = DA850_USER_LED0,- p+ a) H5 W+ M6 d) v l
.name = "user_led0",* A) Z" o" \0 u; j
.default_trigger = "default-on",
- n9 h' N5 C' w7 ^ },
0 {2 D; n8 M) S# o" g8 q {' h; K6 i& `" [1 }7 j+ Q7 h
.active_low = 0,
' P1 f1 }/ Y5 M" y5 @ .gpio = DA850_USER_LED1,$ G- Z, R3 s9 X$ O* D( M, a6 L+ `
.name = "user_led1",( p7 m$ D% v4 l. m0 y0 t
.default_trigger = "default-on",1 ~' i7 b- ^/ G9 x" a& p; Q
},6 G. [6 ]% {$ |! r
{ Q) o3 t3 c! J$ p
.active_low = 0,
: e4 y& o, y1 u+ C7 g .gpio = DA850_USER_LED2,
3 Q8 Z! b _0 A% L$ v. g2 g; p) ` .name = "user_led2",( C' d' Y0 \; W! h) S: |
.default_trigger = "default-on",$ }$ [: N* I' _
},* F$ X! V; g& I5 }0 R" _" I8 @3 d
{ j; g, p$ o. D @2 L/ |: N
.active_low = 0,- n; U5 `# ?6 T0 G$ g0 ~3 B
.gpio = DA850_USER_LED3,: n' y% j0 O5 u% a3 s9 \, d
.name = "user_led3",
) u" z m; h; Z% ?7 i) Y .default_trigger = "default-on",
+ b9 ^* `" Z1 J% \1 W, J2 t },
# f1 C# ?* s4 v! i0 T};
7 a0 H9 j( [# C" i( c( M) H/ ]+ u6 L" d, ?4 F. O5 }) }
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
* t' J4 K: T2 K, m$ A .leds = da850_evm_tl_leds,
# y" a4 i; h7 O: M .num_leds = ARRAY_SIZE(da850_evm_tl_leds),+ M0 u* V- v( g/ Q7 e
};# v s3 |1 w( d: g( s, l7 [
6 ^6 x! W' u; I
static void led_dev_release(struct device *dev)3 l i3 n- B! w$ A: z7 y
{" |9 B- d9 S }' v: l( c
};; f* m9 m$ D- o( s8 M( [% q
7 U$ _0 o+ p( m
static struct platform_device da850_evm_tl_leds_device = {* e3 I3 W! b' {$ d: \; }
.name = "leds-gpio",0 ^$ r6 H1 f& p# [* E) H
.id = 1,) p0 `# w8 a7 {9 W" D) S. X
.dev = {- B) t; H: c5 m- B5 S6 K; N
.platform_data = &da850_evm_tl_leds_pdata,2 A1 L. o4 @( }# B2 s2 Y' S
.release = led_dev_release,4 D( m( b" _0 \# M
}0 y. V: ~% r2 H2 e3 |% F' X
};) ~; W# T7 p4 q, l0 `! M ~
" x! x& w0 `5 Y0 s2 \
static int __init led_platform_init(void); K, Q" {( j; l" |, U& h
{1 @6 Y m! X8 `/ x8 h* S
int ret;/ I0 z+ j2 J$ l* g w2 t& u* |
#if 0
1 v t" q: f4 \+ `+ j ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
* T- b3 W* Y) N! F8 S- I if (ret)
7 J2 n8 @/ z' N9 E. g7 {" ` pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 i! h( k. a/ A "%d\n", ret);
; l, M, j T. I#endif
# V$ w4 R9 U6 b1 G9 s0 C+ I ret = platform_device_register(&da850_evm_tl_leds_device);
0 l6 U: b ] U8 O if (ret)
2 t; M4 ~) u3 A [3 a pr_warning("Could not register som GPIO expander LEDS");4 @/ n; |7 E7 E& Y
else/ {# E& u$ }5 e. {2 [
printk(KERN_INFO "LED register sucessful!\n");
1 Z6 G$ w% M) p- e# o$ G( U! u
( ?# ], \& r/ n+ j$ i; A. } return ret;
# T" [; M$ e2 P* ~- G# |9 P}5 G, v% r9 t! t
0 n" u- ?4 L& E+ b% |
static void __exit led_platform_exit(void), S) W3 V' W* {2 X) O& o" S9 ]
{+ L& n5 N( A. L* F
platform_device_unregister(&da850_evm_tl_leds_device);" A. t+ ]% K/ l4 R8 D1 s/ u
( U/ U, P& Y9 X* s
printk(KERN_INFO "LED unregister!\n");
6 U+ Y2 g) E) q# H}5 P& z; M) c3 d; P" l u1 F' X
9 m5 A" a7 e& O! p4 A, p) N
module_init(led_platform_init);4 {. o$ K4 N( c9 k1 O, c9 I; |
module_exit(led_platform_exit);) X$ P) k) K j5 C& d; `- c
+ w. @0 Y8 E1 v6 XMODULE_DESCRIPTION("Led platform driver");
& T f: r0 {8 J& X- mMODULE_AUTHOR("Tronlong"); w ?4 @3 q D6 h; J$ T) U
MODULE_LICENSE("GPL");
$ d- ~+ B5 e3 w9 f) s1 b
5 E, n+ X4 q# A5 H/ E9 a6 U6 x |
|