|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. N7 Z- t/ x- P5 p. b q#include <linux/init.h>" e0 q( T' l2 z E" c6 J
#include <linux/module.h>
1 \, J+ a% V. r c1 I5 [ j: s$ b& N#include <linux/kernel.h>
% l9 b2 X$ n; a+ G1 B0 F/ n#include <linux/types.h>' \% ^* |/ C) t$ f+ X: a. V
#include <linux/gpio.h>
, d+ K9 M: K0 s, V#include <linux/leds.h>* a3 J/ N1 {$ M% m. D
#include <linux/platform_device.h>; U. l- `* X- U# q2 @1 x, r
" o& k9 M- ^! t#include <asm/mach-types.h>
% T5 [4 R! z6 O% t! X, n9 r0 l- v5 q& K#include <asm/mach/arch.h>2 A- c: h3 Y4 T3 |
#include <mach/da8xx.h>
3 r8 o/ ?- X/ D#include <mach/mux.h> S- g2 z" I; H, _
f" b* b, E2 ~" }# m$ d
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0); C' }; y* A5 Z8 m
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
) `5 j: x, R" v$ o#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' |4 Y" W& M: a: B8 J; ]
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
3 o0 H# i/ \ Y7 V4 [8 k7 s! k
+ K/ v; K4 N2 u' p/* assign the tl som board LED-GPIOs*/
, |, w ?+ H! ^0 F6 _$ G% I& h* Mstatic const short da850_evm_tl_user_led_pins[] = {
) ~5 {. c. l: p; z; U, l# i /* These pins are definition at <mach/mux.h> file */: |0 G+ s* f) T% i& l
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& B. e1 u5 } G8 c- \7 n' Z
-1
- M8 j! y) W- S3 i. x: J( {};
8 M- W3 d8 [2 u% l/ Q9 O* a7 @. F# T1 c& p1 @+ C: _0 y5 r
static struct gpio_led da850_evm_tl_leds[] = {
- Y7 z. f2 d( `8 T$ ?8 l9 f; \ {: g) w/ i% S- F3 O) d3 K5 e3 p
.active_low = 0,1 o$ t% _* y( f# }: C; S" S* d" G
.gpio = DA850_USER_LED0,
8 _# m7 Y) F" @9 l% h3 N+ r4 a .name = "user_led0",) B0 p! g2 ~2 z* F- O4 O
.default_trigger = "default-on",/ K$ P2 Y$ r: ]" A1 [1 T
},
6 |8 i8 G. F R- ~0 q1 ]/ K9 D8 M: X {
9 A, D& I7 t" H2 j: J4 H% Q* V .active_low = 0,6 U; i$ ~6 M7 n
.gpio = DA850_USER_LED1,
4 p/ w. H2 S1 U .name = "user_led1",6 p4 U0 K, K3 r- V. e7 d1 M+ U; W8 C' X
.default_trigger = "default-on",
, d$ |- P3 w! L; W },
; s/ Z$ ]( X: K6 O {0 a, N& Y# G' v! ^; E
.active_low = 0,
/ B( ^9 u" d+ ]( e .gpio = DA850_USER_LED2,
0 N |: `/ m2 _7 c .name = "user_led2",0 P& L6 l; W$ j
.default_trigger = "default-on",
7 P$ ~* G& G! a: @) R7 b3 d6 X8 m },
) l! G% k& n9 M: o3 h F& h' r {' Q" T1 i" T3 S9 h: K% @3 y( d
.active_low = 0,4 P% @6 C, y4 }
.gpio = DA850_USER_LED3,% N4 {" W: e9 N3 K: A6 U
.name = "user_led3",
: a3 b2 |6 ~- x: U$ P) X9 _ .default_trigger = "default-on", H" ?' O9 I R3 z+ M$ x/ Y
},/ }# ]9 F$ Z% `; {7 J8 v
};9 m& S0 D& u, ~1 V( L
7 E/ S& b; s# n6 Y4 v) k7 K2 x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: p1 ~5 T. d2 B2 q# @ .leds = da850_evm_tl_leds,
5 W5 ~/ T) Q I# O; E" C .num_leds = ARRAY_SIZE(da850_evm_tl_leds),. Y2 X; N& s8 B9 e$ P
};
6 g4 N) l$ j& D1 m7 N; ?# C0 s) r& w v' `, F5 y3 O Z8 G
static void led_dev_release(struct device *dev)
2 P/ i/ F, w. N+ W8 J! n{
6 p2 ~+ a0 i R o) L6 a4 F};
. A' L, d9 Y, E# p; f) k% W2 _, I# Q2 C# C$ e" n
static struct platform_device da850_evm_tl_leds_device = {
9 L1 r% v; _1 \& \; R' L; a .name = "leds-gpio", W4 B. Q5 G6 J
.id = 1, {* D9 t; N; K
.dev = {
# y/ z+ i& U$ I .platform_data = &da850_evm_tl_leds_pdata,- E: G, O/ `) p4 g; \+ Q; X: ?
.release = led_dev_release,% K3 i# }: M) N% P; K: k
}
0 c' j- Y, z8 ^};2 {7 T5 w6 p: ~- L" B
& v+ [- c6 D2 x+ X
static int __init led_platform_init(void)
" z3 D+ R" z! X" `0 \5 V: s( [{
" Z. ]" R! ], |, U& y$ i3 x" K int ret;1 c4 s9 b4 c$ O- R( \& S
#if 00 D X7 x7 \' u! e( r
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
( t% c! @' T7 W if (ret); E( E( ]0 T* u B2 M) p
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; G$ p/ O |5 w; B: {+ j& B
"%d\n", ret);) X' M; p. b; Q8 E, w7 F
#endif
7 W6 O7 {! p* B ret = platform_device_register(&da850_evm_tl_leds_device);
7 Z6 F6 y2 R$ ?- }) |5 A- `5 f if (ret)
3 k$ a6 M4 p! F5 m pr_warning("Could not register som GPIO expander LEDS");2 L9 i% T" u* Q0 S
else. V$ `( `* X: Z" h5 }+ z
printk(KERN_INFO "LED register sucessful!\n");" y) y: q! ]& {
?5 v) e( h" N+ d4 ~9 h3 } return ret;
9 W, R0 s6 h0 ?3 [6 Y* l}: h7 \' H/ h. c
8 u! ^2 }/ q% i6 }static void __exit led_platform_exit(void). U F/ R, t9 \' c6 _2 a. J
{
0 t# k" ]) K3 w platform_device_unregister(&da850_evm_tl_leds_device);2 A3 d0 `6 `& n
J* J% y; l4 n* K k printk(KERN_INFO "LED unregister!\n");
* o- m1 S2 p' Z8 n}
q$ y# z4 L8 l7 _9 Z6 z4 T: M2 e8 y* ]0 P7 y9 M
module_init(led_platform_init);7 @" o# p% A+ p5 m' F# S
module_exit(led_platform_exit);4 U, z" w5 p) f% K
# K+ q) X) b0 {- L
MODULE_DESCRIPTION("Led platform driver");* r" o; g8 T) P: e
MODULE_AUTHOR("Tronlong");
$ Z% f2 t0 |7 v) R7 I+ h2 \$ z7 y. FMODULE_LICENSE("GPL");
) [$ q1 r5 t& c8 C3 C! V* s: D7 b" H# o! ~4 M. V0 P9 e6 a
|
|