|
|
求大神给下面的程序做注解,请稍详细些,谢谢。+ b- i8 A* C- _) K) T
#include <linux/init.h>
6 x6 z8 [: k4 F+ y#include <linux/module.h>) f# z7 N# T% v' U% Q5 [
#include <linux/kernel.h>7 P9 n$ y7 X& g ]: ^
#include <linux/types.h>
0 F h" ?' h1 y m#include <linux/gpio.h>
/ \( y- l `: D M- u% |#include <linux/leds.h>
. X% x0 f2 N: L& V; Q& L#include <linux/platform_device.h>
/ M# ~, p( Z m& N# W
$ O; J% p- e& `3 T, m" d) U$ { B#include <asm/mach-types.h>
( |' }! {, m) a" r8 B#include <asm/mach/arch.h>
, w; U$ G9 ?7 r6 B( P: L#include <mach/da8xx.h>+ ^% E: R! ], {0 i8 |
#include <mach/mux.h>
) t7 _0 ~1 Q& a
$ J5 `8 J) l9 h#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)5 {+ @; I u, [( E& `+ h! A
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" I# Y6 g3 B, ]' k8 m#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)6 _5 b2 W* ]3 B& F q$ U3 v
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)1 c; A2 F. w' E/ ]
) D N" ?! C, f3 }
/* assign the tl som board LED-GPIOs*// ~' i% I+ m+ Y" x% t, v
static const short da850_evm_tl_user_led_pins[] = {
- }, U) f. Z! r% p3 _: j+ a, a /* These pins are definition at <mach/mux.h> file */
+ Q2 p' y, C r3 B( y8 {; `6 ` DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
6 |! k% ^8 u5 G# N/ _ -1 |6 ?6 t8 I) N- W
};9 H# Z3 f0 D- C# _9 ?7 \
% m% ~) Y, T5 ]. Vstatic struct gpio_led da850_evm_tl_leds[] = {7 B3 S; f/ H% ^2 v" ?4 Z* G
{
2 D# G6 p% c: f9 F: o' [ .active_low = 0,
3 C ?7 C3 f/ w6 w .gpio = DA850_USER_LED0,, o0 J/ F Y- d3 T* Z; G9 Z
.name = "user_led0",
7 j6 k1 n+ W& M9 s .default_trigger = "default-on",
) r& y! m6 `* [" T },
6 y2 {2 U( r: | {
0 z2 J1 \+ V- z$ E .active_low = 0,& b4 ~& c6 }# @( g
.gpio = DA850_USER_LED1,( B U8 c( Z t$ y# u
.name = "user_led1",$ p- ^5 t" x4 _( E8 I& I4 ?/ |
.default_trigger = "default-on",
5 l% U+ b$ w2 n7 J) E- d% w O- y0 } },9 {& m, I7 ~, d4 i/ ^
{
) @5 ^2 H$ L; r/ N4 P .active_low = 0,
3 Q. \: r/ l* J. z+ k0 t .gpio = DA850_USER_LED2,
n. t7 X, W" \* B5 t0 |4 B .name = "user_led2",& H$ b3 u8 B- q
.default_trigger = "default-on",
) e0 V3 [: W) _5 k/ S+ ~ },' r0 f$ b- E+ D
{
- X, A6 Y! @" u/ }" G6 F .active_low = 0, ^ R$ n% o9 [
.gpio = DA850_USER_LED3,
. N* S/ C8 C* ^# Y( `% j6 |$ r+ W* f .name = "user_led3",
, ~6 b- _% R1 E' f. c: ^ .default_trigger = "default-on",
( r. J( P- i! z# D+ j; W },. P* J* }4 T. j. e# J
};
+ y* L5 I/ d) N6 n0 J9 c7 [* `
: y' c! a; v( ]4 F; ]2 [- p, h C9 istatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {% K- h' P4 M# ]: a0 n: P& R" T3 c
.leds = da850_evm_tl_leds,% a7 ], H/ Q0 ?! I& G
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 i. ~2 M# u) l8 D};
( W0 ^) w( m; |) o. w0 x9 P: c* T" R3 w9 \0 ~) u6 V
static void led_dev_release(struct device *dev)! ]: k: T7 E4 R0 S9 O9 |! f
{
: Q1 v! Q" i9 L, n};) s/ C8 k! e) W4 `; m4 J
7 [+ c% O! f3 _2 M
static struct platform_device da850_evm_tl_leds_device = {
; k, s5 z" k/ H, j% y9 B( i .name = "leds-gpio",4 r. ?! N" E# K% g9 c- P
.id = 1," F0 O% }8 o/ O& x
.dev = {% n( K. x0 y' M( t. E5 l2 s$ k% l
.platform_data = &da850_evm_tl_leds_pdata,5 k" f V- `- d3 O; r
.release = led_dev_release,1 i! d8 l0 Y5 e7 h
}7 Y& I5 O( b- H/ I1 |+ T% `
};" A! X6 m3 Z3 j
5 ]4 O% q' P8 Qstatic int __init led_platform_init(void)
$ y7 x7 Q/ S* L) M2 M" }0 D* t' Q- e{
' G- Z* u$ E1 r int ret;
+ v# r/ n3 t' M' S1 @* t" c8 t#if 0
! T, A0 _) O6 A' ` ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);1 v; Y+ K' Z7 F6 m/ I( p
if (ret); }8 N5 P) O. a- t0 K: j0 | m
pr_warning("da850_evm_tl_leds_init : User LED mux failed :", N# [, ~3 _/ a3 {, ~9 U
"%d\n", ret);
7 Y4 l6 k5 z4 c4 v#endif z1 B" B: [6 d" k: {1 I3 F1 }
ret = platform_device_register(&da850_evm_tl_leds_device);
* @. D& [! m5 y if (ret)
/ q/ u+ I+ c; Q# i( s5 L pr_warning("Could not register som GPIO expander LEDS");2 T) n/ }" G# _2 d9 ]" b
else
% E$ }1 Y# V/ v6 @1 d- c printk(KERN_INFO "LED register sucessful!\n");
; ~7 M$ u) d. ?
$ M" R& K. x+ K6 N return ret;
( {" Z f/ |4 z6 C2 I: i}, _; t# k6 T+ p# i+ |6 _
_4 P$ G& ^7 v
static void __exit led_platform_exit(void)
; G3 v: P* N# r: z1 X, V5 w{# ^4 @* o5 l. S
platform_device_unregister(&da850_evm_tl_leds_device);/ Q7 x4 [0 k7 A9 L7 T3 r, K
! s8 D. E' K1 q5 C! i printk(KERN_INFO "LED unregister!\n");7 R5 ~5 D k( x% K) j
}
3 k+ }9 K: p" v* r5 I
8 I$ s% D0 O, w8 Gmodule_init(led_platform_init);
7 k6 O5 N7 g0 a& Kmodule_exit(led_platform_exit);
5 B9 V+ z! |0 `( D3 b/ E# J
: M; `; C3 L. T7 d, CMODULE_DESCRIPTION("Led platform driver");! E& E* t; a: I \5 C
MODULE_AUTHOR("Tronlong");
- U9 I/ ]6 q' h. f1 JMODULE_LICENSE("GPL");) }) [' _0 `1 }( |: \ y# f* |( m: e
2 K8 h$ c* J9 [7 I+ t, }
|
|