|
|
求大神给下面的程序做注解,请稍详细些,谢谢。, o; c4 c5 Z% _, w
#include <linux/init.h>
$ d' a2 g: Z) J- q+ j9 y#include <linux/module.h>6 v+ f. c, y! u$ [! G
#include <linux/kernel.h>! h7 H5 n7 } y
#include <linux/types.h>
/ P2 e. L1 D) q* c! C& Q1 o) q#include <linux/gpio.h>
, j1 \- B$ _& u5 ^#include <linux/leds.h>/ o! M# y7 x6 x# A3 {
#include <linux/platform_device.h> f6 p$ q) b8 z: P! j2 {9 y
# e2 h+ s C+ M) D#include <asm/mach-types.h>
6 z. T) Y$ i# Y$ e9 W#include <asm/mach/arch.h>
& R$ _# L! I% I# J, ~#include <mach/da8xx.h>
# J0 \6 P ~# |3 r1 ^#include <mach/mux.h>: y6 |/ a0 l# {; d
+ r, O& ^8 H5 i9 b6 W* M5 W8 j
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0) X. u; r j' y+ h2 f0 Q/ d
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
4 y! C* l$ i2 @; S#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
$ [' `4 \0 \- S% [( V. m5 `, G, }#define DA850_USER_LED3 GPIO_TO_PIN(0, 2); q2 ]! `5 t9 a3 R
3 W* X* B( S7 _$ r k9 e+ |1 e
/* assign the tl som board LED-GPIOs*/
; u1 I$ t( B2 ^3 h3 Estatic const short da850_evm_tl_user_led_pins[] = {
6 {# ~" L, b$ X( V/ } /* These pins are definition at <mach/mux.h> file */* e5 v$ ]9 T9 Y9 ^# s$ v
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5, P' u" B' w$ h# [- K3 Y; f f0 Z
-1) R" ^3 ]9 A+ f) u( y
};: |) j- W+ R M' |
6 F7 R# r1 O. n1 D& W5 |: Q# A
static struct gpio_led da850_evm_tl_leds[] = {) X/ ?# I* H4 S2 d; U
{. J7 Y; ^0 r+ P$ v4 k4 C5 ?1 r
.active_low = 0,- o: I& N. i9 a
.gpio = DA850_USER_LED0,
* P1 o ?* T# s6 j1 n+ U& q .name = "user_led0",
" I: r7 w* l1 U( K .default_trigger = "default-on",$ _2 j# \% M. L8 [4 O
},
, c! D, Y) Y5 A1 R {4 W* \' L2 z! a" u& a! @
.active_low = 0,
k7 m. V+ _, d$ l2 R R7 L .gpio = DA850_USER_LED1,* u" z( b# z9 T6 s
.name = "user_led1",( ~ G9 g7 ^2 \
.default_trigger = "default-on",
/ K; ]; `0 \% g1 p+ J! q },4 y: f1 u, H! F' S
{! S4 ~% f0 j; ?- f) ?
.active_low = 0,5 }7 ^% q# s' E
.gpio = DA850_USER_LED2,+ h/ v3 m) q' o/ l# U @+ L
.name = "user_led2",. x: B5 J" g. l
.default_trigger = "default-on",
2 p! _+ G; w1 t7 T% b9 K, m& q },
4 Z: _& z, r6 p+ U/ q: Q3 `# R {; D6 m1 F# _* D/ T3 G
.active_low = 0,
$ N- x; y X3 X$ r; Y .gpio = DA850_USER_LED3,) N( Y) c( I5 S4 B" F- f
.name = "user_led3",2 b& Z+ A, H- F C r# g
.default_trigger = "default-on",
; _0 @, }1 ] V" F9 }; e: s },8 b- W( `7 s T- ]- f
};
( d3 d5 d" V/ p2 g+ p. k1 ^8 b2 { }1 S
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! t+ u- @+ T7 [! j# k2 B
.leds = da850_evm_tl_leds,3 @: s4 g4 P6 j% J; {. i1 g
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 }- {0 D" w0 H};. {" C k. E; e1 X- L
$ s7 @4 ?- C& \" B f6 sstatic void led_dev_release(struct device *dev), o9 @9 w9 ^, [0 j! s6 U* G/ T1 n) \
{
@2 J+ C# \ M- ~};. ?4 s2 K9 \' y0 F5 I! D
7 s+ T7 N6 t" Vstatic struct platform_device da850_evm_tl_leds_device = {
! b, {. @, `8 S; M+ s .name = "leds-gpio",
) q- i; D8 O& h9 u2 W .id = 1,
, `$ ]! p1 F1 d f F .dev = {
`3 v" l1 k% _- K .platform_data = &da850_evm_tl_leds_pdata,) L- O1 e' {% g/ d. R( p3 w
.release = led_dev_release,7 s8 W1 j3 D6 J* X2 z" s7 F
}
# Y. Z. O5 I8 |% z9 r: I};
2 b, x5 [& B/ _- {* r& ^0 [" Q# }5 L$ w+ r1 L9 }0 {$ l0 c2 d% z
static int __init led_platform_init(void)
3 x9 x7 g4 g D2 Z& P& |; _{6 W. x8 ?' M ~. _$ \$ j
int ret;
; ?# Y% Z3 C& N, I+ H2 P; G#if 0
0 ?9 P7 e1 b! Y- j ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 L! u! U& Y' x. |: B2 T h% v
if (ret)
3 ]9 z+ }: w& ~6 `( V7 m pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; K1 H4 L4 W9 c3 @6 Y/ y3 g2 p; Q
"%d\n", ret);
4 K, w3 P9 @! G( M2 @#endif! v) T( y6 X) r0 l* R9 ]) G
ret = platform_device_register(&da850_evm_tl_leds_device);
' h, x/ K0 Z$ _0 ` V+ w+ q if (ret)
+ H) A# d- _7 }, \) z, n+ x pr_warning("Could not register som GPIO expander LEDS");5 v: f C* a2 G/ R4 y
else! ]$ ~6 I3 b8 X3 D
printk(KERN_INFO "LED register sucessful!\n");- F* r! f8 p1 s* O n, @$ O* f
- g0 N* `" [; h- h8 d4 [9 b
return ret;! v9 v1 J: U4 M! L" A% p9 }6 N
}
% O2 X8 v( M! d1 \5 {6 l' P6 S. i! e8 f; x
static void __exit led_platform_exit(void)
' I& S6 F2 _% t9 p{
- O7 I0 f ], y4 K" J" [, n6 `0 C platform_device_unregister(&da850_evm_tl_leds_device);. m/ h0 B; x# {) o4 g- t( l0 o
1 \9 |2 m! q) y' l+ r printk(KERN_INFO "LED unregister!\n");
0 d- O ?- u" v3 L4 U. g) U}' P# j. s m" q o( @ h: w
9 F8 Y( w7 X1 i/ ]2 q
module_init(led_platform_init);# W9 E+ H5 b( c& `" s
module_exit(led_platform_exit);
$ [ i% ~8 M' M( D) Q
4 S) L: V( z; z, P) ^MODULE_DESCRIPTION("Led platform driver");( B0 @6 Y$ `( f* G
MODULE_AUTHOR("Tronlong");8 i, X5 V _6 y C+ ]/ E
MODULE_LICENSE("GPL");
7 \# Y( n [$ E; q* N1 Z' M# \
/ u( S7 W1 l: i5 j$ P/ [ |
|