From: Portia Stephens <[email protected]>
The pnv_spi model supports transaction sizes of 4 bytes however there
are no in-tree SSI peripherals that support this. Update the model to
use a 8-bit transfer function.
Signed-off-by: Portia Stephens <[email protected]>
---
hw/ssi/pnv_spi.c | 28 +++++++++++-----------------
1 file changed, 11 insertions(+), 17 deletions(-)
diff --git a/hw/ssi/pnv_spi.c b/hw/ssi/pnv_spi.c
index e2a8a710da..481798b1fa 100644
--- a/hw/ssi/pnv_spi.c
+++ b/hw/ssi/pnv_spi.c
@@ -194,32 +194,26 @@ static void spi_response(PnvSpi *s)
static void transfer(PnvSpi *s)
{
- uint32_t tx, rx, payload_len;
+ uint32_t payload_len;
uint8_t rx_byte;
payload_len = fifo8_num_used(&s->tx_fifo);
for (int offset = 0; offset < payload_len; offset += s->transfer_len) {
- tx = 0;
- for (int i = 0; i < s->transfer_len; i++) {
- if ((offset + i) >= payload_len) {
- tx <<= 8;
- } else if (!fifo8_is_empty(&s->tx_fifo)) {
- tx = (tx << 8) | fifo8_pop(&s->tx_fifo);
- } else {
- qemu_log_mask(LOG_GUEST_ERROR, "pnv_spi: TX_FIFO underflow\n");
- }
- }
- rx = ssi_transfer8(s->ssi_bus, tx);
for (int i = 0; i < s->transfer_len; i++) {
if ((offset + i) >= payload_len) {
break;
}
- rx_byte = (rx >> (8 * (s->transfer_len - 1) - i * 8)) & 0xFF;
- if (!fifo8_is_full(&s->rx_fifo)) {
- fifo8_push(&s->rx_fifo, rx_byte);
+
+ if (!fifo8_is_empty(&s->tx_fifo)) {
+ rx_byte = ssi_transfer8(s->ssi_bus, fifo8_pop(&s->tx_fifo));
+ if (!fifo8_is_full(&s->rx_fifo)) {
+ fifo8_push(&s->rx_fifo, rx_byte);
+ } else {
+ qemu_log_mask(LOG_GUEST_ERROR, "pnv_spi: RX_FIFO is full\n");
+ break;
+ }
} else {
- qemu_log_mask(LOG_GUEST_ERROR, "pnv_spi: RX_FIFO is full\n");
- break;
+ qemu_log_mask(LOG_GUEST_ERROR, "pnv_spi: TX_FIFO underflow\n");
}
}
}
--
2.43.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.