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
24 changes: 15 additions & 9 deletions hw/opentitan/ot_spi_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -677,12 +677,6 @@ static void ot_spi_device_flash_change_state_line(
}
}

static bool ot_spi_device_flash_has_input_payload(uint32_t cmd_info)
{
return (cmd_info & CMD_INFO_PAYLOAD_EN_MASK) != 0 &&
!(cmd_info & CMD_INFO_PAYLOAD_DIR_MASK);
}

static bool ot_spi_device_flash_is_upload(const SpiDeviceFlash *f)
{
return (f->cmd_info & CMD_INFO_UPLOAD_MASK) != 0 &&
Expand Down Expand Up @@ -1296,9 +1290,13 @@ static void ot_spi_device_flash_decode_sw_command(OtSPIDeviceState *s)
} else if (f->cmd_info & CMD_INFO_DUMMY_EN_MASK) {
f->len = 1u;
FLASH_CHANGE_STATE(s, UP_DUMMY);
} else if (ot_spi_device_flash_has_input_payload(f->cmd_info)) {
} else if (ot_spi_device_flash_is_upload(f)) {
ot_spi_device_flash_init_payload(s);
} else {
/*
* Any payload sent with a non-uploaded SW command is ignored. The
* behaviour of this error case is not well specified for the hardware.
*/
s->spi_regs[R_UPLOAD_STATUS2] = 0;
}
}
Expand Down Expand Up @@ -1328,19 +1326,27 @@ static void ot_spi_device_flash_exec_sw_command(OtSPIDeviceState *s, uint8_t rx)
if (f->cmd_info & CMD_INFO_DUMMY_EN_MASK) {
f->len = 1u;
FLASH_CHANGE_STATE(s, UP_DUMMY);
} else if (ot_spi_device_flash_has_input_payload(f->cmd_info)) {
} else if (ot_spi_device_flash_is_upload(f)) {
ot_spi_device_flash_init_payload(s);
} else {
/*
* Any payload sent with a non-uploaded SW command is ignored. The
* behaviour of this error case is not well specified for the hardware.
*/
FLASH_CHANGE_STATE(s, DONE);
}
}
break;
case SPI_FLASH_UP_DUMMY:
f->pos++;
g_assert(f->pos == f->len);
if (ot_spi_device_flash_has_input_payload(f->cmd_info)) {
if (ot_spi_device_flash_is_upload(f)) {
ot_spi_device_flash_init_payload(s);
} else {
/*
* Any payload sent with a non-uploaded SW command is ignored. The
* behaviour of this error case is not well specified for the hardware.
*/
FLASH_CHANGE_STATE(s, DONE);
}
break;
Expand Down
Loading