|
|
求大神给下面的程序做注解,请稍详细些,谢谢。1 Y' R7 o$ i: z& h/ f% V
#include <linux/init.h>- |$ g$ M- v7 _8 V0 K3 T- u5 Y) ?
#include <linux/module.h># W$ }" l ~: \. m* d
#include <linux/kernel.h>
" F- M% R" } Y# c9 k#include <linux/types.h>
7 P& m: s. H7 _) X2 g0 F#include <linux/gpio.h>7 ^6 U+ I% w) X% d+ Y" G$ f
#include <linux/leds.h>
2 g) i' ]2 R* m" U# v! c#include <linux/platform_device.h>; d4 f* i9 Z7 [' q7 \
- a9 |4 ?. i6 O' Q3 l
#include <asm/mach-types.h>
" a; v9 H, i1 q! A1 o3 y#include <asm/mach/arch.h>' |) z: D9 k* E& t" g
#include <mach/da8xx.h>, w, H& b) C/ v" h ?8 o) L( K$ |* b; w
#include <mach/mux.h>
, U8 T" Z: M: V* h+ F
# r* U! R# _& q/ L8 D$ ?#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
9 d. a4 a/ t" i" `# j#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
6 o9 l- |* G+ p( q#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)( x7 }# p8 f: Y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& z3 ~- |, w& Y7 |* O
4 p7 o/ k" X8 Y X( J" s/* assign the tl som board LED-GPIOs*/
, s- ]2 K$ c! ?static const short da850_evm_tl_user_led_pins[] = {
1 z8 [: Y% d; T0 F8 ~ /* These pins are definition at <mach/mux.h> file */# ?8 `3 F! J4 b# l' j/ ?) N$ N5 {$ i' v: t
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
1 g/ I8 K( A7 v0 v5 A2 [& E% H -18 ]6 ~; x; T6 V$ B" r6 b
};
+ V. L% b' F1 D9 r6 V7 g- e
7 {/ f J/ ~6 b5 I6 U# Z& `static struct gpio_led da850_evm_tl_leds[] = {4 z) I9 A: R# r
{" q* A+ P$ v G* w
.active_low = 0,
9 W: Y1 F: b' |% V .gpio = DA850_USER_LED0,
3 c1 K- ~8 r; [5 h5 D1 P& w .name = "user_led0",
! P! y7 f9 y- v+ H- U .default_trigger = "default-on",
2 M/ a0 w6 }0 ] @* f },
3 i, o1 ?5 G& ^. m' | {8 `2 K1 V) ~/ m) C' ?6 @* {
.active_low = 0,
9 W3 Z6 p7 \' U5 l$ p .gpio = DA850_USER_LED1,
3 p: ?; |2 c$ Q3 U+ I$ {8 G/ b) K .name = "user_led1",- C b& I E" g6 n. w
.default_trigger = "default-on",1 \+ k M6 R8 `6 N/ \( J# g! t" ?1 `
},( o! j: z) ^6 h( b4 b5 z
{
" |& l. @) k$ F .active_low = 0,, o- L" d5 ? q4 ]& O4 ?- ^0 d
.gpio = DA850_USER_LED2,, S7 `& R5 h5 o
.name = "user_led2",/ L9 d4 g: d: z3 r. @4 {
.default_trigger = "default-on",+ j0 c6 Z) p, j) t- e# h% L! t# f
},
7 j# C9 H0 e8 ^( n E; l& s {
' a9 |* [% o, h7 p .active_low = 0,; x8 _4 J& K6 p- J% i6 o
.gpio = DA850_USER_LED3,1 n" V9 y9 N" q5 b' o$ v: W& k( L+ ]8 U6 e
.name = "user_led3",+ N6 v7 R% r9 P4 ]# T' {
.default_trigger = "default-on"," i+ L4 I; N# i* D# x# p+ k+ A3 ?
},
. I7 T% r2 M9 N- v7 C# z7 B8 H# C6 T. T};
) v3 Z4 }+ w2 J" H& ?
9 Q0 w$ A% W+ z X* ?' p& C5 dstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
) h+ _% X1 d1 M: W- |2 Y6 {9 @ .leds = da850_evm_tl_leds," l( [# s/ c+ K( {3 o4 E' A3 O7 q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
; @4 G* F5 z) ]1 |0 Z4 s5 g};
; ^" H' B1 C! B, C; i- r( |6 W) x; [' W1 B9 b
static void led_dev_release(struct device *dev)6 F9 F5 ]# h( {% L2 a- I
{
; [0 G7 f3 i. ~9 K- Z2 S};8 o/ ~( h4 R. g' O; b
) e- n8 V8 `: P& }& H" p
static struct platform_device da850_evm_tl_leds_device = {
- H; Y7 J+ q- Z4 U .name = "leds-gpio",
/ `7 D0 u- N+ q- x .id = 1,
+ \$ q: t4 ]$ x; V4 y .dev = {
: ?( K+ n# g J% N( D .platform_data = &da850_evm_tl_leds_pdata,
( @0 N3 w5 L: f. P d% } .release = led_dev_release,
6 b0 y- h) B, ^, a. Y6 \4 i }
3 S+ N5 B; W1 `2 O" C};
0 b* s2 T& T/ o2 P& \5 M2 D. s
7 B" X$ ]: w7 o D! G% X$ Ostatic int __init led_platform_init(void)
8 ^. u( ~% q. |$ L0 q{7 P+ N( _4 q l
int ret;& K( O& C9 T' H2 V7 h
#if 0
W+ U; ~& N$ g: F P ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
9 F: e) g/ v( _7 s if (ret) [5 l R h1 t7 K5 k0 i
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
+ U' A# U3 M& C "%d\n", ret);: |( A" G- e3 h: r. r6 B
#endif
5 B# @$ p7 t% d1 d. }+ l ret = platform_device_register(&da850_evm_tl_leds_device);
% z& d/ c' U; v/ i" ^( ?. h' @ if (ret)
4 f2 G* D% p! `; o a% F3 D pr_warning("Could not register som GPIO expander LEDS");
* l' Y, x$ u5 c5 @: F1 m else
$ c1 Y2 }5 \% j% R4 s printk(KERN_INFO "LED register sucessful!\n");
" |2 z* p. V- ^. l! J. s$ t5 v3 v7 h3 z$ p9 U7 c) }! a
return ret;2 P# x3 v7 ^+ ] f8 S
}
, u* y0 w2 `3 t! C& b, S% p
7 H4 Q, f7 A# J6 H* |% Estatic void __exit led_platform_exit(void)& J% m( v: l* K* |# U9 E( Q. C) }
{
! h6 T! ]9 \0 k; ^/ V4 K. d platform_device_unregister(&da850_evm_tl_leds_device);
/ o6 ~$ m' S* w1 J
3 G, h( F) r' C7 t9 p printk(KERN_INFO "LED unregister!\n");$ Y! n m% r" D* z9 r
}( S8 q" C, ~5 S, P3 p3 ]
5 z5 M) [$ t" C3 tmodule_init(led_platform_init);
. v' I& Y( f% `( V, q+ J, O& {module_exit(led_platform_exit);1 C. @4 p; ^1 x6 ?* N
2 p) c4 E- J6 D' ]MODULE_DESCRIPTION("Led platform driver");
y* |* C" B: x' X3 @$ K* b" G! vMODULE_AUTHOR("Tronlong");
4 c4 m I' U6 o6 o; |MODULE_LICENSE("GPL");1 [; h* O! V+ u5 F7 {# I
6 X& \! b$ G1 N. T; i
|
|