Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1f57af66 authored by Vijay Viswanath's avatar Vijay Viswanath
Browse files

mmc: core: Add retuning to cmdq path



In cmdq mode, do tuning if required before issueing request to
controller. This is required when we are in HS200 or HS400 without
enhanced strobe mode and we had gated the clock. So after ungating the
clock, do retuning.

Change-Id: I8c506a69053022fda65d78838f09e905519f07cc
Signed-off-by: default avatarVijay Viswanath <vviswana@codeaurora.org>
parent 34f009cf
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
@@ -1170,6 +1170,46 @@ static int mmc_start_request(struct mmc_host *host, struct mmc_request *mrq)
	return 0;
}

static int mmc_cmdq_check_retune(struct mmc_host *host)
{
	bool cmdq_mode;
	int err = 0;

	if (!host->need_retune || host->doing_retune || !host->card ||
			mmc_card_hs400es(host->card) ||
			(host->ios.clock <= MMC_HIGH_DDR_MAX_DTR))
		return 0;

	cmdq_mode = mmc_card_cmdq(host->card);
	if (cmdq_mode) {
		err = mmc_cmdq_halt(host, true);
		if (err) {
			pr_err("%s: %s: failed halting queue (%d)\n",
				mmc_hostname(host), __func__, err);
			host->cmdq_ops->dumpstate(host);
			goto halt_failed;
		}
	}

	mmc_retune_hold(host);
	err = mmc_retune(host);
	mmc_retune_release(host);

	if (cmdq_mode) {
		if (mmc_cmdq_halt(host, false)) {
			pr_err("%s: %s: cmdq unhalt failed\n",
			mmc_hostname(host), __func__);
			host->cmdq_ops->dumpstate(host);
		}
	}

halt_failed:
	pr_debug("%s: %s: Retuning done err: %d\n",
				mmc_hostname(host), __func__, err);

	return err;
}

static int mmc_start_cmdq_request(struct mmc_host *host,
				   struct mmc_request *mrq)
{
@@ -1196,6 +1236,7 @@ static int mmc_start_cmdq_request(struct mmc_host *host,
	}

	mmc_host_clk_hold(host);
	mmc_cmdq_check_retune(host);
	if (likely(host->cmdq_ops->request)) {
		ret = host->cmdq_ops->request(host, mrq);
	} else {
+2 −1
Original line number Diff line number Diff line
@@ -388,7 +388,8 @@ int mmc_retune(struct mmc_host *host)
	else
		return 0;

	if (!host->need_retune || host->doing_retune || !host->card)
	if (!host->need_retune || host->doing_retune || !host->card ||
			mmc_card_hs400es(host->card))
		return 0;

	host->need_retune = 0;