Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion hw/opentitan/ot_spi_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ typedef struct {
QEMUTimer *irq_timer; /* Timer to resume processing after a READBUF_* IRQ */
bool loop; /* Keep reading the buffer if end is reached */
bool watermark; /* Read watermark hit, used as flip-flop */
bool new_cmd; /* New command has been pushed in current SPI transaction */
} SpiDeviceFlash;

typedef struct {
Expand Down Expand Up @@ -811,7 +812,7 @@ static void ot_spi_device_release_cs(OtSPIDeviceState *s)
bool update_irq = false;
switch (ot_spi_device_get_mode(s)) {
case CTRL_MODE_FLASH:
if (!fifo8_is_empty(&f->cmd_fifo)) {
if (!fifo8_is_empty(&f->cmd_fifo) && f->new_cmd) {
s->spi_regs[R_INTR_STATE] |= INTR_UPLOAD_CMDFIFO_NOT_EMPTY_MASK;
update_irq = true;
}
Expand Down Expand Up @@ -858,6 +859,8 @@ static void ot_spi_device_release_cs(OtSPIDeviceState *s)
break;
}

f->new_cmd = false;

if (update_irq) {
ot_spi_device_update_irqs(s);
}
Expand Down Expand Up @@ -930,6 +933,7 @@ static void ot_spi_device_flash_decode_command(OtSPIDeviceState *s, uint8_t cmd)
}
trace_ot_spi_device_flash_upload(f->slot, f->cmd_info, set_busy);
fifo8_push(&f->cmd_fifo, COMMAND_OPCODE(f->cmd_info));
f->new_cmd = true;
}
}

Expand Down Expand Up @@ -2120,6 +2124,7 @@ static void ot_spi_device_reset(DeviceState *dev)

ot_spi_device_release_cs(s);
f->watermark = false;
f->new_cmd = false;
s->spi_regs[R_CONTROL] = 0x10u;
s->spi_regs[R_STATUS] = 0x60u;
s->spi_regs[R_JEDEC_CC] = 0x7fu;
Expand Down
Loading