|
求大神给下面的程序做注解,请稍详细些,谢谢。
! c! M( e, Z$ p E9 z, x/ B#include <linux/init.h>7 M: d/ e) U+ c% K7 q- B
#include <linux/module.h>) p0 ]% p! F/ Q
#include <linux/kernel.h>
% P" F+ |. i5 U1 `7 F4 Y6 F#include <linux/types.h>. C6 ^4 |- E8 {+ y/ G) E8 D. @3 P) k
#include <linux/gpio.h>8 T% P* E: i# U3 Q
#include <linux/leds.h>2 Z$ V1 @( X' \% B# e
#include <linux/platform_device.h>. |5 O) g: ~4 m0 ^
7 X! J9 N% x; ~# U q+ n
#include <asm/mach-types.h>
: ?7 s* O3 h. y# J' F#include <asm/mach/arch.h>
; d& j: [9 F0 w% v#include <mach/da8xx.h>& H h/ H) y: _' }# _- \: u
#include <mach/mux.h>
6 X2 k* [* r% N! I7 \# o
# i6 [' p' c- P* m5 ?& h7 f2 \. l#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)7 ?6 L: N9 | H s
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
% v9 d1 ~) l6 X$ u/ R4 {2 Z* w#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
3 D# m3 l( D K' k Q3 X#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) [ N: h X+ F1 q$ m% L: d' p
L1 C |/ J+ R6 [' k/* assign the tl som board LED-GPIOs*/
( y. Y/ S6 a E4 T) istatic const short da850_evm_tl_user_led_pins[] = {8 k4 r& q( c* q4 J
/* These pins are definition at <mach/mux.h> file */! `0 r- j8 D! L5 t
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,; ` e& p# E8 |; ~
-1* s/ A. t8 r1 G' Z: e
};
- P- n5 G. a& _ w- G5 y- z" v
* z8 L% _3 f! sstatic struct gpio_led da850_evm_tl_leds[] = {
% n; M3 U! k b+ c. |" b5 p+ ` {
: P" _/ k, g. Q! a .active_low = 0,% x$ J$ B4 j) {: z& C
.gpio = DA850_USER_LED0,; D3 l/ K/ X; P
.name = "user_led0",
: X$ F. Y# E% t! Q .default_trigger = "default-on",
/ `1 H) k$ Y- @' T2 H. H' b },- F) W7 i" s0 M* h: T5 S
{ Z; `! G8 X; {- }8 F4 l
.active_low = 0,1 y$ r% \( K. Y( M! V) q# M
.gpio = DA850_USER_LED1,
( h9 C" U' T5 T5 c' O .name = "user_led1",( w1 R" o9 s) V. N6 P4 g+ j
.default_trigger = "default-on",7 S# ]) B3 E( [/ m! h# }
},1 W" `5 ?% H! s- x8 s4 ~/ _
{
( s$ c6 ~) _. z' l5 d; \- N .active_low = 0,
* _+ q- A& \! F$ |4 U2 n+ Y- O: e .gpio = DA850_USER_LED2,
8 r. m6 C& c* X# @ .name = "user_led2",
: {0 S6 x* W f .default_trigger = "default-on",
$ _8 Y& A! W( X$ l. _ },
# T6 i$ Q. u+ J2 L& f {
/ i* D/ g" X+ o2 n. g .active_low = 0,
% `" X( N2 j) d' ]% R( a- G0 h .gpio = DA850_USER_LED3,- U7 ] \8 m% V# ~! X4 ~/ m; B; d
.name = "user_led3",
7 Q7 J M2 u& C2 E: C% ] .default_trigger = "default-on",9 m/ g. B- H# L
},
7 F' Q! I7 {4 n9 b: x};
6 Q9 z6 V& t' W) E3 c" u, {( h. I' ]" y2 Y
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 r* J# u; k6 ~5 {. Y0 | .leds = da850_evm_tl_leds,3 Z( B# m' h. r8 B% P
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' r: C8 [! [' P# |7 |* P};
" L" k+ K: Q' [
Q- a; Q% f% Y+ l+ h7 X+ ystatic void led_dev_release(struct device *dev): Q/ i T5 w0 }) e5 b; e2 [8 `+ n7 k
{3 F: d; v+ j5 A% g; p# }
};
1 B3 Z8 Q9 e/ `7 b6 L+ O+ x* o) ?9 ?6 P2 r8 a
static struct platform_device da850_evm_tl_leds_device = {/ l# E" w& y' l* I" z6 G( {$ P* n
.name = "leds-gpio",
8 P5 l. h# j* Z0 y7 p5 Y .id = 1,. g5 R7 E, k( \4 [3 y- {# x
.dev = {2 H% h+ z ~8 o! Y
.platform_data = &da850_evm_tl_leds_pdata,
5 l% W5 |; Y' }4 K% k6 C# I .release = led_dev_release,7 @; L5 j, e& `$ c
}
3 O, G& S. z1 o5 F. O* ^};
/ ^ l3 \4 P2 u" P( j" _3 K' y5 h3 G+ S
static int __init led_platform_init(void)4 h3 i/ v/ R# G% m( V: h
{9 n2 m( W6 W1 f. E
int ret;
1 _* o# }3 s' U#if 0
" ~0 @' o2 v2 k( i ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
; q w0 O9 k# ^' g2 r if (ret)
! U, O9 s! c" \ Q( ? pr_warning("da850_evm_tl_leds_init : User LED mux failed :"$ G o7 P# s U3 m1 Y
"%d\n", ret);
0 }9 m: T6 t- ?#endif! i# N8 v( ?- f: [4 G: H: H; y
ret = platform_device_register(&da850_evm_tl_leds_device);
O5 U* b3 R/ C) j1 e. R- m if (ret)
3 Z( } D: M( _ pr_warning("Could not register som GPIO expander LEDS");+ [* I5 {9 I% A$ {1 a7 a/ ]8 K
else
% f, f( [- C2 n8 d* X) h printk(KERN_INFO "LED register sucessful!\n");7 D! n6 X2 Q! G/ C W( q
- M* ?, y) S6 _8 d% g return ret;9 Z! k# f0 |! `7 i: _+ X
}/ l1 S* K9 ^% f/ B, Y! A/ u
) u& A0 o+ C2 w: f+ y* w1 ]4 ~6 C
static void __exit led_platform_exit(void)
! p1 q+ K. Y9 v+ p" \{
v) G& J8 h: _7 H- W platform_device_unregister(&da850_evm_tl_leds_device);6 q0 _% j+ F: t" H# r
5 T' r, v7 {( N' \& w
printk(KERN_INFO "LED unregister!\n");$ ?+ I: g8 V o
}
) T; m w) ^* g' X0 i* u; E B; \$ ^+ O* u' T
module_init(led_platform_init);8 c1 }, t! ~4 A' s) G7 T$ c
module_exit(led_platform_exit);6 Z: W) ^, H9 N
. X+ e. j1 u- ^ PMODULE_DESCRIPTION("Led platform driver");# `! ~8 w+ x4 I5 W
MODULE_AUTHOR("Tronlong");/ ]; i M5 Q" o) q& \; {
MODULE_LICENSE("GPL");0 n% p0 c" f. D( J6 \+ V7 b
" x3 a. G3 y& Z7 W
|
|