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

Commit d54cd815 authored by Ritesh Harjani's avatar Ritesh Harjani Committed by Veerabhadrarao Badiganti
Browse files

mmc: mmc: Don't send CMD13 after switch command while switching speed modes



Do not send CMD13 after sending switch command for HS, HS_DDR,
HS200 and HS400 modes. It seems that below problem can occur -
1. After sending switch CMD6, card will switch to mentioned bus speed
mode.
2. At this moment the controller will be in different bus speed mode,
unless the timing of the controller is switched to match with that of
card.

During this time, if CMD13 follows CMD6 to switch the bus speed
mode in card. Then it may cause timeouts or other errors because
of mismatch in timing of controller and card.

Thus send CMD13 to see the status once both controller and card are
switched to same timings.

Change-Id: If796c8cfce2cbdc1bce460460e3276886ae1be0c
Signed-off-by: default avatarRitesh Harjani <riteshh@codeaurora.org>
Signed-off-by: default avatarVeerabhadrarao Badiganti <vbadigan@codeaurora.org>
parent 3e6c67db
Loading
Loading
Loading
Loading
+37 −9
Original line number Diff line number Diff line
@@ -1046,9 +1046,11 @@ static int mmc_select_hs(struct mmc_card *card)
	err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
			   EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS,
			   card->ext_csd.generic_cmd6_time,
			   true, true, true);
	if (!err)
			   true, false, true);
	if (!err) {
		mmc_set_timing(card->host, MMC_TIMING_MMC_HS);
		err = mmc_switch_status(card, false);
	}

	return err;
}
@@ -1072,10 +1074,11 @@ static int mmc_select_hs_ddr(struct mmc_card *card)
	ext_csd_bits = (bus_width == MMC_BUS_WIDTH_8) ?
		EXT_CSD_DDR_BUS_WIDTH_8 : EXT_CSD_DDR_BUS_WIDTH_4;

	err = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
	err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
			EXT_CSD_BUS_WIDTH,
			ext_csd_bits,
			card->ext_csd.generic_cmd6_time);
			card->ext_csd.generic_cmd6_time,
			true, false, false);
	if (err) {
		pr_warn("%s: switch to bus width %d ddr failed\n",
			mmc_hostname(host), 1 << bus_width);
@@ -1118,8 +1121,10 @@ static int mmc_select_hs_ddr(struct mmc_card *card)
	if (err)
		err = __mmc_set_signal_voltage(host, MMC_SIGNAL_VOLTAGE_330);

	if (!err)
	if (!err) {
		mmc_set_timing(host, MMC_TIMING_MMC_DDR52);
		err = mmc_switch_status(card, false);
	}

	return err;
}
@@ -1163,7 +1168,7 @@ static int mmc_select_hs400(struct mmc_card *card)
	err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
			   EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS,
			   card->ext_csd.generic_cmd6_time,
			   true, true, true);
			   true, false, true);
	if (err) {
		pr_warn("%s: switch to high-speed from hs200 failed, err:%d\n",
			mmc_hostname(host), err);
@@ -1173,6 +1178,10 @@ static int mmc_select_hs400(struct mmc_card *card)
	mmc_set_timing(card->host, MMC_TIMING_MMC_HS);
	mmc_set_bus_speed(card);

	err = mmc_switch_status(card, false);
	if (err)
		goto out_err;

	val = EXT_CSD_DDR_BUS_WIDTH_8;
	if (card->ext_csd.strobe_support) {
		err = mmc_select_bus_width(card);
@@ -1193,7 +1202,7 @@ static int mmc_select_hs400(struct mmc_card *card)
	err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
			   EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS400,
			   card->ext_csd.generic_cmd6_time,
			   true, true, true);
			   true, false, true);
	if (err) {
		pr_warn("%s: switch to hs400 failed, err:%d\n",
			 mmc_hostname(host), err);
@@ -1219,6 +1228,17 @@ static int mmc_select_hs400(struct mmc_card *card)
				mmc_hostname(host));
	}

	/*
	 * Sending of CMD13 should be done after the host calibration
	 * for enhanced_strobe or HS400 mode is completed.
	 * Otherwise may see CMD13 timeouts or CRC errors.
	 */
	err = mmc_switch_status(card, false);

out_err:
	if (err)
		pr_err("%s: %s failed, error %d\n", mmc_hostname(card->host),
				__func__, err);
	return err;
}

@@ -1253,9 +1273,17 @@ static int mmc_select_hs200(struct mmc_card *card)
		err = __mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
				   EXT_CSD_HS_TIMING, EXT_CSD_TIMING_HS200,
				   card->ext_csd.generic_cmd6_time,
				   true, true, true);
		if (!err)
				   true, false, true);
		if (!err) {
			mmc_set_timing(host, MMC_TIMING_MMC_HS200);
			/*
			 * Since after switching to hs200, crc errors might
			 * occur for commands send before tuning.
			 * So ignore crc error for cmd13.
			 */
			err = mmc_switch_status(card, true);

		}
	}
err:
	return err;