Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Simple PCIe FMC carrier SPEC
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
50
Issues
50
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
Commits
7839a6aa
Commit
7839a6aa
authored
Aug 30, 2019
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw:drv:spi: re-organize for code reduction
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
c67d3081
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
56 deletions
+38
-56
spi-ocores.c
software/kernel/spi-ocores.c
+38
-56
No files found.
software/kernel/spi-ocores.c
View file @
7839a6aa
...
...
@@ -51,8 +51,8 @@ struct spi_ocores {
const
void
*
cur_tx_buf
;
void
*
cur_rx_buf
;
unsigned
int
cur_len
;
void
(
*
cur_tx_push
)(
struct
spi_ocores
*
sp
);
void
(
*
cur_rx_pop
)(
struct
spi_ocores
*
sp
);
size_t
(
*
cur_tx_push
)(
struct
spi_ocores
*
sp
);
size_t
(
*
cur_rx_pop
)(
struct
spi_ocores
*
sp
);
/* Register Access functions */
uint32_t
(
*
read
)(
struct
spi_ocores
*
sp
,
unsigned
int
reg
);
...
...
@@ -194,67 +194,52 @@ static uint8_t spi_ocores_hw_xfer_bits_per_word(struct spi_ocores *sp)
return
nbits
;
}
static
void
spi_ocores_hw_xfer_tx_push8
(
struct
spi_ocores
*
sp
)
static
size_t
spi_ocores_hw_xfer_tx_push8
(
struct
spi_ocores
*
sp
)
{
uint8_t
data
;
if
(
!
sp
->
cur_tx_buf
)
return
;
data
=
((
uint8_t
*
)
sp
->
cur_tx_buf
)[
0
];
spi_ocores_tx_set
(
sp
,
0
,
data
);
sp
->
cur_tx_buf
+=
1
;
return
sizeof
(
data
)
;
}
static
void
spi_ocores_hw_xfer_tx_push16
(
struct
spi_ocores
*
sp
)
static
size_t
spi_ocores_hw_xfer_tx_push16
(
struct
spi_ocores
*
sp
)
{
uint16_t
data
;
if
(
!
sp
->
cur_tx_buf
)
return
;
data
=
((
uint16_t
*
)
sp
->
cur_tx_buf
)[
0
];
spi_ocores_tx_set
(
sp
,
0
,
__cpu_to_be16
(
data
));
sp
->
cur_tx_buf
+=
2
;
return
sizeof
(
data
)
;
}
static
void
spi_ocores_hw_xfer_tx_push32
(
struct
spi_ocores
*
sp
)
static
size_t
spi_ocores_hw_xfer_tx_push32
(
struct
spi_ocores
*
sp
)
{
uint32_t
data
;
if
(
!
sp
->
cur_tx_buf
)
return
;
data
=
((
uint32_t
*
)
sp
->
cur_tx_buf
)[
0
];
spi_ocores_tx_set
(
sp
,
0
,
__cpu_to_be32
(
data
));
sp
->
cur_tx_buf
+=
4
;
return
sizeof
(
data
)
;
}
static
void
spi_ocores_hw_xfer_tx_push64
(
struct
spi_ocores
*
sp
)
static
size_t
spi_ocores_hw_xfer_tx_push64
(
struct
spi_ocores
*
sp
)
{
uint64_t
data
;
if
(
!
sp
->
cur_tx_buf
)
return
;
data
=
__cpu_to_be64
(
*
((
uint64_t
*
)
sp
->
cur_tx_buf
));
spi_ocores_tx_set
(
sp
,
0
,
data
&
0xFFFFFFFF
);
data
>>=
32
;
spi_ocores_tx_set
(
sp
,
1
,
data
&
0xFFFFFFFF
);
sp
->
cur_tx_buf
+=
8
;
return
sizeof
(
data
)
;
}
static
void
spi_ocores_hw_xfer_tx_push128
(
struct
spi_ocores
*
sp
)
static
size_t
spi_ocores_hw_xfer_tx_push128
(
struct
spi_ocores
*
sp
)
{
uint64_t
data
;
if
(
!
sp
->
cur_tx_buf
)
return
;
data
=
__cpu_to_be64
(((
uint64_t
*
)
sp
->
cur_tx_buf
)[
0
]);
spi_ocores_tx_set
(
sp
,
2
,
data
&
0xFFFFFFFF
);
data
>>=
32
;
...
...
@@ -265,75 +250,66 @@ static void spi_ocores_hw_xfer_tx_push128(struct spi_ocores *sp)
data
>>=
32
;
spi_ocores_tx_set
(
sp
,
1
,
data
&
0xFFFFFFFF
);
sp
->
cur_tx_buf
+=
16
;
return
sizeof
(
data
)
*
2
;
}
static
void
spi_ocores_hw_xfer_tx_push
(
struct
spi_ocores
*
sp
)
static
size_t
spi_ocores_hw_xfer_tx_push
(
struct
spi_ocores
*
sp
)
{
sp
->
cur_tx_push
(
sp
);
size_t
len
=
0
;
if
(
sp
->
cur_tx_buf
)
len
=
sp
->
cur_tx_push
(
sp
);
sp
->
cur_tx_buf
+=
len
;
return
len
;
}
static
void
spi_ocores_hw_xfer_rx_pop8
(
struct
spi_ocores
*
sp
)
static
size_t
spi_ocores_hw_xfer_rx_pop8
(
struct
spi_ocores
*
sp
)
{
uint8_t
data
;
if
(
!
sp
->
cur_rx_buf
)
return
;
data
=
spi_ocores_rx_get
(
sp
,
0
)
&
0x000000FF
;
((
uint8_t
*
)
sp
->
cur_rx_buf
)[
0
]
=
data
;
sp
->
cur_rx_buf
+=
1
;
return
sizeof
(
data
)
;
}
static
void
spi_ocores_hw_xfer_rx_pop16
(
struct
spi_ocores
*
sp
)
static
size_t
spi_ocores_hw_xfer_rx_pop16
(
struct
spi_ocores
*
sp
)
{
uint16_t
data
;
if
(
!
sp
->
cur_rx_buf
)
return
;
data
=
spi_ocores_rx_get
(
sp
,
0
)
&
0x0000FFFF
;
((
uint16_t
*
)
sp
->
cur_rx_buf
)[
0
]
=
__be16_to_cpu
(
data
);
sp
->
cur_rx_buf
+=
2
;
return
sizeof
(
data
)
;
}
static
void
spi_ocores_hw_xfer_rx_pop32
(
struct
spi_ocores
*
sp
)
static
size_t
spi_ocores_hw_xfer_rx_pop32
(
struct
spi_ocores
*
sp
)
{
uint32_t
data
;
if
(
!
sp
->
cur_rx_buf
)
return
;
data
=
spi_ocores_rx_get
(
sp
,
0
)
&
0xFFFFFFFF
;
((
uint32_t
*
)
sp
->
cur_rx_buf
)[
0
]
=
__be32_to_cpu
(
data
);
sp
->
cur_rx_buf
+=
4
;
return
sizeof
(
data
)
;
}
static
void
spi_ocores_hw_xfer_rx_pop64
(
struct
spi_ocores
*
sp
)
static
size_t
spi_ocores_hw_xfer_rx_pop64
(
struct
spi_ocores
*
sp
)
{
uint64_t
data
;
if
(
!
sp
->
cur_rx_buf
)
return
;
data
=
spi_ocores_rx_get
(
sp
,
1
)
&
0xFFFFFFFF
;
data
<<=
32
;
data
|=
spi_ocores_rx_get
(
sp
,
0
)
&
0xFFFFFFFF
;
((
uint64_t
*
)
sp
->
cur_rx_buf
)[
0
]
=
__be64_to_cpu
(
data
);
sp
->
cur_rx_buf
+=
8
;
return
sizeof
(
data
)
;
}
static
void
spi_ocores_hw_xfer_rx_pop128
(
struct
spi_ocores
*
sp
)
static
size_t
spi_ocores_hw_xfer_rx_pop128
(
struct
spi_ocores
*
sp
)
{
uint64_t
data
;
if
(
!
sp
->
cur_rx_buf
)
return
;
data
=
spi_ocores_rx_get
(
sp
,
3
)
&
0xFFFFFFFF
;
data
<<=
32
;
data
|=
spi_ocores_rx_get
(
sp
,
2
)
&
0xFFFFFFFF
;
...
...
@@ -344,20 +320,26 @@ static void spi_ocores_hw_xfer_rx_pop128(struct spi_ocores *sp)
data
|=
spi_ocores_rx_get
(
sp
,
0
)
&
0xFFFFFFFF
;
((
uint64_t
*
)
sp
->
cur_rx_buf
)[
0
]
=
__be64_to_cpu
(
data
);
sp
->
cur_rx_buf
+=
16
;
return
sizeof
(
data
)
*
2
;
}
static
void
spi_ocores_hw_xfer_rx_pop
(
struct
spi_ocores
*
sp
)
static
size_t
spi_ocores_hw_xfer_rx_pop
(
struct
spi_ocores
*
sp
)
{
size_t
len
=
0
;
uint8_t
nbits
;
sp
->
cur_rx_pop
(
sp
);
/*
* When we read is because a complete HW transfer is over, so we
* can safely decrease the counter of pending bytes
*/
nbits
=
spi_ocores_hw_xfer_bits_per_word
(
sp
);
sp
->
cur_len
-=
(
nbits
/
8
);
/* FIXME not working for !pow2 */
if
(
sp
->
cur_rx_buf
)
len
=
sp
->
cur_rx_pop
(
sp
);
sp
->
cur_rx_buf
+=
len
;
return
len
;
}
static
void
spi_ocores_hw_xfer_start
(
struct
spi_ocores
*
sp
)
...
...
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