示例#1
0
/* Return 1 if idle, otherwise return 0 (busy). */
static unsigned int cadence_qspi_wait_idle(void *reg_base)
{
	unsigned int start, count = 0;
	/* timeout in unit of ms */
	unsigned int timeout = 5000;

	start = get_timer(0);
	for ( ; get_timer(start) < timeout ; ) {
		if (CQSPI_REG_IS_IDLE(reg_base))
			count++;
		else
			count = 0;
		/*
		 * Ensure the QSPI controller is in true idle state after
		 * reading back the same idle status consecutively
		 */
		if (count >= CQSPI_POLL_IDLE_RETRY)
			return 1;
	}

	/* Timeout, still in busy mode. */
	printf("QSPI: QSPI is still busy after poll for %d times.\n",
	       CQSPI_REG_RETRY);
	return 0;
}
示例#2
0
static unsigned int cqspi_wait_idle(struct cqspi_st *cqspi)
{
	void __iomem *reg_base = cqspi->iobase;

	if (wait_on_timeout(CQSPI_TIMEOUT_MS,
		CQSPI_REG_IS_IDLE(reg_base))) {
		/* Timeout, in busy mode. */
		dev_err(cqspi->dev, "QSPI is still busy after %llums timeout.\n",
			CQSPI_TIMEOUT_MS);
		return -ETIMEDOUT;
	}

	return 0;
}
/* Return 1 if idle, otherwise return 0 (busy). */
static unsigned int cadence_qspi_wait_idle(void * reg_base) {
	unsigned int count = 0;
	unsigned timeout;

	timeout = cadence_qspi_init_timeout(CQSPI_TIMEOUT_MS);
	while (cadence_qspi_check_timeout(timeout)) {
		if (CQSPI_REG_IS_IDLE(reg_base)) {
			/* Read few times in succession to ensure it does
			not transition low again */
			count++;
			if (count >= CQSPI_POLL_IDLE_RETRY)
				return 1;
		} else {
			count = 0;
		}
	}

	/* Timeout, in busy mode. */
	pr_err("QSPI: QSPI is still busy after %dms timeout.\n",
		CQSPI_TIMEOUT_MS);
	return 0;
}