/* Check whether a transfer complete for PIO operation in the Cadence controller has finished. */
static int cdns_pio_transfer_complete(uintptr_t base_address, uint8_t thread)
/* Check whether a transfer complete for PIO operation in the Cadence controller has finished. */
static int cdns_pio_transfer_complete(uintptr_t base_address, uint8_t thread)
{
	uint32_t status;
	status = WAIT_FOR(((cdns_nand_get_thrd_status(base_address, thread)) != 0), IDLE_TIME_OUT,
			  k_msleep(1));
	if (status == 0) {
		LOG_ERR("Timed out waiting for thread status response");
		return -ETIMEDOUT;
	}
	if ((status & (BIT(F_CSTAT_COMP)))) {
		if ((status & (BIT(F_CSTAT_FAIL)))) {
			LOG_ERR("Cadence status operation failed %s", __func__);
			return -EIO;
		}
	} else {
		LOG_ERR("Cadence status complete failed %s", __func__);
		return -EIO;
	}
	return 0;
}