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

Commit 4457076d authored by Ritesh Harjani's avatar Ritesh Harjani
Browse files

mmc: core: cmdq helper for reset and claim host context



This patch does following-

This adds an API(mmc_cmdq_hw_reset), for RESET_ALL
of SDHCI, power cycle mmc card and
reintialize it, which enables cmdq as well(if supported).

This acquires claim_host before calling mmc_power_restore.
mmc_power_restore should be called with claim_host acquired,
since this function is required from non-claim-host context in
cmdq error handling.

Change-Id: I31c4449dead1d4ad4e10a4822cce2298ec5fb4b6
Signed-off-by: default avatarRitesh Harjani <riteshh@codeaurora.org>
parent 9edfde01
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -3529,6 +3529,7 @@ EXPORT_SYMBOL(mmc_can_reset);
static int mmc_do_hw_reset(struct mmc_host *host, int check)
{
	struct mmc_card *card = host->card;
	int ret;

	if (!host->bus_ops->power_restore)
		return -EOPNOTSUPP;
@@ -3575,9 +3576,28 @@ static int mmc_do_hw_reset(struct mmc_host *host, int check)
	mmc_set_ios(host);

	mmc_host_clk_release(host);
	mmc_claim_host(host);
	ret = host->bus_ops->power_restore(host);
	mmc_release_host(host);
	return ret;
}

/*
 * mmc_cmdq_hw_reset: Helper API for doing
 * reset_all of host and reinitializing card.
 * This must be called with mmc_claim_host
 * acquired by the caller.
 */
int mmc_cmdq_hw_reset(struct mmc_host *host)
{
	if (!host->bus_ops->power_restore)
		return -EOPNOTSUPP;

	mmc_power_cycle(host, host->ocr_avail);
	mmc_select_voltage(host, host->card->ocr);
	return host->bus_ops->power_restore(host);
}
EXPORT_SYMBOL(mmc_cmdq_hw_reset);

int mmc_hw_reset(struct mmc_host *host)
{
@@ -3855,7 +3875,9 @@ int mmc_power_restore_host(struct mmc_host *host)
	}

	mmc_power_up(host, host->card->ocr);
	mmc_claim_host(host);
	ret = host->bus_ops->power_restore(host);
	mmc_release_host(host);

	mmc_bus_put(host);

+4 −2
Original line number Diff line number Diff line
@@ -2625,6 +2625,10 @@ static int mmc_runtime_resume(struct mmc_host *host)
	return err;
}

/*
 * mmc_power_restore: Must be called with claim_host
 * acquired by the caller.
 */
static int mmc_power_restore(struct mmc_host *host)
{
	int ret;
@@ -2638,9 +2642,7 @@ static int mmc_power_restore(struct mmc_host *host)
		return ret;
	}

	mmc_claim_host(host);
	ret = mmc_init_card(host, host->card->ocr, host->card);
	mmc_release_host(host);

	ret = mmc_resume_clk_scaling(host);
	if (ret)
+1 −0
Original line number Diff line number Diff line
@@ -190,6 +190,7 @@ extern int mmc_set_blocklen(struct mmc_card *card, unsigned int blocklen);
extern int mmc_set_blockcount(struct mmc_card *card, unsigned int blockcount,
			      bool is_rel_write);
extern int mmc_hw_reset(struct mmc_host *host);
extern int mmc_cmdq_hw_reset(struct mmc_host *host);
extern int mmc_hw_reset_check(struct mmc_host *host);
extern int mmc_can_reset(struct mmc_card *card);