|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 x6 e. E2 s, B$ \' M3 z R# S' U#include <linux/init.h>
2 G0 { n c \( b7 J#include <linux/module.h>
- l/ ^4 F# o* I3 M8 |! Z8 \#include <linux/kernel.h>
' ?. H( k9 u6 T4 O. H- N#include <linux/types.h>
9 B% M2 q7 m! i9 ^/ F#include <linux/gpio.h>% }- z" o8 @. C3 A7 K4 V0 F, \& \: a
#include <linux/leds.h>' @7 h4 c+ q, X6 Q7 w% Z
#include <linux/platform_device.h>. C" F# s# N. j
% o# k/ [ ]' M/ M
#include <asm/mach-types.h>1 }9 V( M8 r2 o# S
#include <asm/mach/arch.h>
3 X- d9 H+ `7 e7 T( i" e; g#include <mach/da8xx.h>
+ W' h7 f. N) [#include <mach/mux.h>; k; [6 h! e! h1 r/ M5 @- H
( ?9 @2 y7 P1 \% ]#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)! r; j4 w. r# @) Y A4 n, x0 U- N. W0 M/ s
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 Q2 K$ x6 e; h' S7 y/ o1 x
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
" X8 I0 r: }3 N# |6 n' x#define DA850_USER_LED3 GPIO_TO_PIN(0, 2) d" t1 n7 J: ^) E
- p+ j$ D, U4 n: R$ v/* assign the tl som board LED-GPIOs*/% v+ u/ n; g; C9 W$ D$ d1 |* ?
static const short da850_evm_tl_user_led_pins[] = {+ X! j1 T( k0 g- H1 {' M0 _; A& k
/* These pins are definition at <mach/mux.h> file */
! P+ _! d0 N* n m. E2 X1 V DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
# Y) I% |" X2 M; G -1
' s( \. D8 w* ]( [5 C5 j};) w9 K2 \8 K5 p* Z. Y H4 I
/ D) n! O0 t6 w5 B7 o9 K$ xstatic struct gpio_led da850_evm_tl_leds[] = {
0 Z; z# L; W' _- l$ L {" K- i3 S8 U: S; }. z, E
.active_low = 0,
3 c; t7 @5 s5 i .gpio = DA850_USER_LED0,
Z6 W" L B* ] \, x .name = "user_led0",
' T! X5 ~1 j* o' T. S, e6 \ .default_trigger = "default-on",6 Q* B- _& X9 a5 V) F+ g
},( b; w3 `* {0 X% R
{" e& ~/ W2 I( {3 f" @' M% Q# ~
.active_low = 0,
% L3 j0 x7 _4 r8 B' A" u9 P' n' s .gpio = DA850_USER_LED1,
* L5 o& b4 h- q9 U0 n0 ?0 f .name = "user_led1",
+ ]' Y. |. t, N .default_trigger = "default-on",
9 d+ }$ q+ r) I& l/ s9 m% z X },. @* I2 q6 I4 o5 \
{
/ l. X; `& _; Q. I. {7 d .active_low = 0,
: U9 X! m# n, A! V .gpio = DA850_USER_LED2,
& p$ V4 \3 T" c. O- K% z .name = "user_led2",: b5 f5 W6 t1 [
.default_trigger = "default-on",
( a$ `: d+ I7 U% w },6 y+ j2 @7 T( h/ v I: `- ]
{$ }. n" Q+ h5 D {# _
.active_low = 0,8 g1 E& q& i, u& i
.gpio = DA850_USER_LED3,' G9 |! t( p. G
.name = "user_led3",
$ j$ b. H3 K/ C2 K5 x .default_trigger = "default-on",
2 _2 Z* t7 U* z' f, v; s3 W' t( \ },1 E1 f: G8 b! u9 B; m$ {6 r; w
};
* y# O! b* i/ q, L/ E# a; V2 T1 Z4 \1 @8 F8 P
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 S* h9 h" m! ^
.leds = da850_evm_tl_leds,5 f9 |; M/ w2 ^. [7 g
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. p% O4 M2 h/ M$ u$ u};9 M0 K0 y3 ~/ K# X
w- z# L' C; c' _3 F0 M: @
static void led_dev_release(struct device *dev)/ Z, N0 P8 z, G5 L; }- r' B
{" v1 W9 S/ ?& \+ r4 I
};
1 {5 `& ]4 o8 N7 j4 [+ l! M$ R4 \$ s
static struct platform_device da850_evm_tl_leds_device = {& M* A9 m* W3 a5 f4 b% U0 \
.name = "leds-gpio",7 d- N: G; [; O, ]' P
.id = 1, I0 y- H" ^) [1 E0 h
.dev = {# z# e8 J% r, p/ [7 n @7 ^
.platform_data = &da850_evm_tl_leds_pdata,, U( Y, \: |6 i/ E& d v
.release = led_dev_release,0 T/ G3 J. }' K+ T
}
2 Z3 l" f, e6 ~+ K5 k2 g' j1 ~# h+ y, H) O- E};
]8 A2 Z5 L. K- W, n8 G$ U. c* H
! f$ ]- e" U2 L, ]static int __init led_platform_init(void)4 H$ {2 y2 }) O/ W6 ^" E
{
0 D& Q$ n; x& {% X" t) ~' A4 | int ret;
2 A' _5 C( Q: l6 z7 J#if 0' S3 D. Z- s+ G
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);' s, d5 c T, h; Y4 @3 q
if (ret)
; o# X0 L% |: C pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- C( K0 _ g- Q5 M
"%d\n", ret);" ^/ V9 {! A& I6 v# m$ p8 @& s
#endif/ r1 x, f! v# E+ ~4 r' r
ret = platform_device_register(&da850_evm_tl_leds_device);
* O; a+ `1 T4 D5 L" c: Z( O' U8 k# e if (ret)
: J( i ~! O) C pr_warning("Could not register som GPIO expander LEDS");
2 s& |( @+ q5 W8 t h1 ] else' X' I6 A$ N% G2 N& `* c
printk(KERN_INFO "LED register sucessful!\n");2 e4 ]! l, S5 l6 E( O
( D, C* X! Y. r+ v7 l3 ~ return ret;
. ]) k2 E8 f) R% G6 e}( l8 t+ }, \$ a" s8 s
6 c# B0 _4 T+ _static void __exit led_platform_exit(void)
7 y! G) z! r' J9 V{
1 e" q* s: T. P7 f- P platform_device_unregister(&da850_evm_tl_leds_device);) }% h2 S2 y$ y" R2 v0 P0 j& L4 w) t
) U* B/ c1 W ]( q
printk(KERN_INFO "LED unregister!\n");- O: ?6 Y3 q3 n6 B, o/ \! D" j( e- l
}
! `3 d4 k: A- j% u5 b F" B* o; {& `2 F& P I( T) x
module_init(led_platform_init);8 Z2 ~0 |8 u: a. s9 ~
module_exit(led_platform_exit);
% v7 x" f) K7 {, e
* V4 A( p0 F ]! }MODULE_DESCRIPTION("Led platform driver");& H2 p/ D% \, Y0 v4 J9 g/ W+ K
MODULE_AUTHOR("Tronlong");
& R0 P* M- G" I! A, oMODULE_LICENSE("GPL");1 ^$ l) p- ` l" `
, [4 _1 [. k) ?9 s O4 r
|
|