|
|
求大神给下面的程序做注解,请稍详细些,谢谢。0 ?% }3 Z6 Y3 u! z, S& A6 [, [1 p2 @
#include <linux/init.h>
2 ?: ]/ U* }3 K* R#include <linux/module.h>
: ~8 v5 s: j8 B! ]#include <linux/kernel.h>5 d) m& G# R4 F1 k& t y
#include <linux/types.h>
9 ~6 W9 I$ |# _6 U$ B! h#include <linux/gpio.h>1 P& m7 u6 b; k) `; V
#include <linux/leds.h>
/ h# R: I& h6 d#include <linux/platform_device.h>
. q8 h. J! s% R% s! ~
: y6 H& `: q& Y! H#include <asm/mach-types.h>
6 r" h1 m" z2 @: _#include <asm/mach/arch.h>
2 m- ?0 r/ M4 m. ~/ S0 ~* ? H#include <mach/da8xx.h>
: L2 q& n7 ~8 Q0 k#include <mach/mux.h>
: i! j7 [# f" Z& M: Q% D7 @ g- k6 W2 ?% D |' l( j
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! a5 p& E) d$ L$ _" B$ X
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)' q& c. X: I* h8 X
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 D5 I: w/ g# S& X- r+ L& K5 y#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
2 f5 L; ~6 n1 V' G5 m5 i( s: g* T4 j5 {: D$ h8 ^6 C" e9 ~: O" d
/* assign the tl som board LED-GPIOs*/7 M! f8 k( R+ k4 X6 e, D
static const short da850_evm_tl_user_led_pins[] = {$ d" C) s! e3 _! y5 r
/* These pins are definition at <mach/mux.h> file */. f# M3 X: U9 r# H
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' E! k) O! I0 q% W! H -1
2 S. u" X* W( Q# a5 X# u# { D6 H};' O4 P5 ~; U6 b+ m! b
. w% R, d9 w# q `% C0 w" kstatic struct gpio_led da850_evm_tl_leds[] = {
, k5 p8 j' {% a: f5 K: D {+ d/ u( i; m3 T ^
.active_low = 0,% V! d, B g& p+ s- N
.gpio = DA850_USER_LED0," U& s; n1 y, u9 z5 u
.name = "user_led0",
+ q) e- x g4 L8 }' d7 D( B0 D .default_trigger = "default-on",6 _% q5 X% a% g. ~3 b) O6 e
},1 K2 ^3 p! h% D* L3 J
{
E# O* f' ^2 ^! B5 p, e) Y .active_low = 0,, i9 N7 P/ u! v O. ]* @
.gpio = DA850_USER_LED1,
$ a: _6 C- N6 x( B3 r! ?: ~ .name = "user_led1"," t0 q% G* m" Z; Z4 O: K
.default_trigger = "default-on",) K$ ^/ o0 c+ o4 l0 ~0 `3 Y
},# u C8 K# L T4 U- n, ?! o
{' U# n" M0 t. H8 T2 }3 e8 _
.active_low = 0,; R7 s4 h! q% l, e( h# R F: K8 G
.gpio = DA850_USER_LED2,
, T6 w: S2 S, N; t' j2 P/ ]3 v .name = "user_led2",
% @9 [( y2 b( P1 L .default_trigger = "default-on",; a* K( Z3 p+ g0 p6 n5 E- S5 g
},5 }# k# _) }* m, s
{: m" @" F* _& k+ m7 T8 y
.active_low = 0,
3 H! V! Z( {( d .gpio = DA850_USER_LED3,8 Y7 Y2 n6 n& ]' J l. ?
.name = "user_led3",$ R6 B$ g4 I. t
.default_trigger = "default-on",+ Y% z: T+ X* x/ I9 i
},9 P5 K& v1 u4 b, Q5 A
};: y V; r3 `, m5 c4 n8 d% O
/ ~/ c: j# x6 y. l0 Bstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {6 p6 D, `5 o+ e* w* X- ?
.leds = da850_evm_tl_leds,8 j. c' t: B9 e l
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' _3 \, m& S/ Y* L: D. H
};6 A$ q/ A( i0 l- U6 o3 C# s) n1 W8 G
. B3 x* x% A$ W% ^# M- j
static void led_dev_release(struct device *dev)
8 {9 g2 G4 M3 ^9 L{+ \! v0 I# o F! V' b: ~5 T0 g
};. [( Q& W* P9 S
: u- `8 N* h* d# k# _& astatic struct platform_device da850_evm_tl_leds_device = {. j+ m9 G0 z0 _( I2 W, H( ^, a
.name = "leds-gpio",; w0 r3 n: U% C$ B7 w
.id = 1,
F& {. N6 p! `& p .dev = {# Z# h" z7 k; `- j3 _9 Q
.platform_data = &da850_evm_tl_leds_pdata,
! q' T& s ]- D, ^2 }3 { .release = led_dev_release,
6 l- u) `' m" Z7 G, n8 g }3 o8 ~4 u5 ~0 @1 ~% |' B& T. ~$ Q
};
2 {4 A& b f" U. e8 w/ K7 F2 Q0 E5 [3 b; U! S- s' L6 A
static int __init led_platform_init(void)
. S2 @7 J3 C7 ^8 J: d ~: H{! m+ \% v; }3 D6 b" O+ J& L5 _
int ret; s: U* x! k3 c* z% N
#if 0
5 K5 L2 R) `9 R ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ H) s8 k# x& z if (ret)
+ {6 o2 b! D* @% X) P pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ M5 l1 L- c* v$ B' @ {8 a2 a "%d\n", ret);* o% o0 V- C: J. [, a/ ^
#endif
& ]- m7 d% i2 M4 T/ O& R ret = platform_device_register(&da850_evm_tl_leds_device);
: d5 M/ ^1 b( J: ` if (ret)3 D4 v7 g( U- X, u
pr_warning("Could not register som GPIO expander LEDS");) p: U3 K, F& e6 B' }% n/ [
else
( M$ [; h7 ]* D9 E% e/ A printk(KERN_INFO "LED register sucessful!\n");- D& F4 ~+ f) V7 V# U
3 G+ l; Q5 [& }/ m7 n8 @ return ret;
: K& o' S: M' d( F}- i$ {* O; Z0 C' q9 `! j
" E/ Q0 Z% a3 F$ i( {% r n
static void __exit led_platform_exit(void)
G" r5 P, @* d) K{( B, z! ~( e7 ~. y# @, ?( G* p
platform_device_unregister(&da850_evm_tl_leds_device);
3 G8 V, I: e0 r& T) o4 K4 Q
5 d/ c0 [% n8 Q* f printk(KERN_INFO "LED unregister!\n");
9 |$ O# V% h8 f" V* V W# \3 V}
c; P5 o3 R- F3 U A+ q4 ?$ B. W! T5 E- A# g" e
module_init(led_platform_init);
1 K% ]) T& O3 F3 _module_exit(led_platform_exit);% P, W3 k3 {+ `; B
, [6 j A6 Q# _/ ~4 KMODULE_DESCRIPTION("Led platform driver");
- B- L0 E% C+ K e; J3 g" Q, hMODULE_AUTHOR("Tronlong");+ i3 e7 \* m, k0 e( G1 U
MODULE_LICENSE("GPL");
1 O7 e" q# c% ]9 c" X
5 Y, \! O q* S$ c |
|