Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Simple PCIe FMC carrier SPEC - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Simple PCIe FMC carrier SPEC - Software
Commits
84893f26
Commit
84893f26
authored
Sep 14, 2012
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel/wr-nic-dio.c: cleanup: use a register map
parent
c09d2431
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
14 deletions
+71
-14
wr-nic-dio.c
kernel/wr-nic-dio.c
+71
-14
No files found.
kernel/wr-nic-dio.c
View file @
84893f26
...
...
@@ -24,19 +24,82 @@
#define wrn_stat 0
#endif
/* We need a clear mapping for the registers of the various bits */
struct
regmap
{
int
trig_l
;
int
trig_h
;
int
cycle
;
int
pulse
;
int
fifo_tai_l
;
int
fifo_tai_h
;
int
fifo_cycle
;
int
fifo_status
;
};
#define R(x) (offsetof(struct DIO_WB, x))
static
struct
regmap
regmap
[]
=
{
{
.
trig_l
=
R
(
TRIG0
),
.
trig_h
=
R
(
TRIGH0
),
.
cycle
=
R
(
CYC0
),
.
pulse
=
R
(
PROG0_PULSE
),
.
fifo_tai_l
=
R
(
TSF0_R0
),
.
fifo_tai_h
=
R
(
TSF0_R1
),
.
fifo_cycle
=
R
(
TSF0_R2
),
.
fifo_status
=
R
(
TSF0_CSR
),
},
{
.
trig_l
=
R
(
TRIG1
),
.
trig_h
=
R
(
TRIGH1
),
.
cycle
=
R
(
CYC1
),
.
pulse
=
R
(
PROG1_PULSE
),
.
fifo_tai_l
=
R
(
TSF1_R0
),
.
fifo_tai_h
=
R
(
TSF1_R1
),
.
fifo_cycle
=
R
(
TSF1_R2
),
.
fifo_status
=
R
(
TSF1_CSR
),
},
{
.
trig_l
=
R
(
TRIG2
),
.
trig_h
=
R
(
TRIGH2
),
.
cycle
=
R
(
CYC2
),
.
pulse
=
R
(
PROG2_PULSE
),
.
fifo_tai_l
=
R
(
TSF2_R0
),
.
fifo_tai_h
=
R
(
TSF2_R1
),
.
fifo_cycle
=
R
(
TSF2_R2
),
.
fifo_status
=
R
(
TSF2_CSR
),
},
{
.
trig_l
=
R
(
TRIG3
),
.
trig_h
=
R
(
TRIGH3
),
.
cycle
=
R
(
CYC3
),
.
pulse
=
R
(
PROG3_PULSE
),
.
fifo_tai_l
=
R
(
TSF3_R0
),
.
fifo_tai_h
=
R
(
TSF3_R1
),
.
fifo_cycle
=
R
(
TSF3_R2
),
.
fifo_status
=
R
(
TSF3_CSR
),
},
{
.
trig_l
=
R
(
TRIG4
),
.
trig_h
=
R
(
TRIGH4
),
.
cycle
=
R
(
CYC4
),
.
pulse
=
R
(
PROG4_PULSE
),
.
fifo_tai_l
=
R
(
TSF4_R0
),
.
fifo_tai_h
=
R
(
TSF4_R1
),
.
fifo_cycle
=
R
(
TSF4_R2
),
.
fifo_status
=
R
(
TSF4_CSR
),
}
};
/* FIXME: should this access use fmc_readl/writel? */
static
int
wrn_dio_cmd_pulse
(
struct
wrn_drvdata
*
drvdata
,
struct
wr_dio_cmd
*
cmd
)
{
struct
DIO_WB
__iomem
*
dio
=
drvdata
->
wrdio_base
;
void
__iomem
*
base
=
dio
;
struct
PPSG_WB
__iomem
*
ppsg
=
drvdata
->
ppsg_base
;
void
__iomem
*
p
;
struct
regmap
*
map
;
struct
timespec
*
ts
;
uint32_t
val
;
if
(
cmd
->
channel
>
4
)
return
-
EINVAL
;
/* FIXME: mask */
map
=
regmap
+
cmd
->
channel
;
/* First, put this bit as output (FIXME: plain GPIO support?) */
val
=
readl
(
&
dio
->
OUT
)
|
(
1
<<
cmd
->
channel
);
...
...
@@ -63,22 +126,16 @@ static int wrn_dio_cmd_pulse(struct wrn_drvdata *drvdata,
/* if not "now", set trig, trigh, cycles */
if
(
!
(
cmd
->
flags
&
WR_DIO_F_NOW
))
{
/* not now: set relevant registers */
p
=
&
dio
->
TRIG0
;
p
+=
(
cmd
->
channel
*
12
);
printk
(
"%i -> %p
\n
"
,
GET_HI32
(
ts
->
tv_sec
),
p
+
4
);
writel
(
GET_HI32
(
ts
->
tv_sec
),
p
+
4
);
printk
(
"%li -> %p
\n
"
,
ts
->
tv_sec
,
p
);
writel
(
ts
->
tv_sec
,
p
);
printk
(
"%li -> %p
\n
"
,
ts
->
tv_nsec
/
8
,
p
+
8
);
writel
(
ts
->
tv_nsec
/
8
,
p
+
8
);
printk
(
"%x %x %x
\n
"
,
map
->
trig_h
,
map
->
trig_l
,
map
->
cycle
);
writel
(
GET_HI32
(
ts
->
tv_sec
),
base
+
map
->
trig_h
);
writel
(
ts
->
tv_sec
,
base
+
map
->
trig_l
);
writel
(
ts
->
tv_nsec
/
8
,
base
+
map
->
cycle
);
}
/* set the width */
ts
++
;
p
=
&
dio
->
PROG0_PULSE
;
p
+=
cmd
->
channel
*
4
;
printk
(
"%li -> %p
\n
"
,
ts
->
tv_nsec
/
8
,
p
);
writel
(
ts
->
tv_nsec
/
8
,
p
);
printk
(
"%x
\n
"
,
map
->
pulse
);
writel
(
ts
->
tv_nsec
/
8
,
base
+
map
->
pulse
);
/* no loop yet (FIXME: interrupts) */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment