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

Commit 9998650d authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mmc: sdhci-msm: Improvise tuning to check the card status"

parents 1cd65e76 96351266
Loading
Loading
Loading
Loading
+31 −8
Original line number Diff line number Diff line
@@ -935,6 +935,7 @@ int sdhci_msm_execute_tuning(struct sdhci_host *host, u32 opcode)
	u8 drv_type = 0;
	bool drv_type_changed = false;
	struct mmc_card *card = host->mmc->card;
	int sts_retry;

	/*
	 * Tuning is required for SDR104, HS200 and HS400 cards and
@@ -991,6 +992,7 @@ retry:
			.data = &data
		};
		struct scatterlist sg;
		struct mmc_command sts_cmd = {0};

		/* set the phase in delay line hw block */
		rc = msm_config_cm_dll_phase(host, phase);
@@ -1011,14 +1013,35 @@ retry:
		memset(data_buf, 0, size);
		mmc_wait_for_req(mmc, &mrq);

		/*
		 * wait for 146 MCLK cycles for the card to send out the data
		 * and thus move to TRANS state. As the MCLK would be minimum
		 * 200MHz when tuning is performed, we need maximum 0.73us
		 * delay. To be on safer side 1ms delay is given.
		if (card && (cmd.error || data.error)) {
			sts_cmd.opcode = MMC_SEND_STATUS;
			sts_cmd.arg = card->rca << 16;
			sts_cmd.flags = MMC_RSP_R1 | MMC_CMD_AC;
			sts_retry = 5;
			while (sts_retry) {
				mmc_wait_for_cmd(mmc, &sts_cmd, 0);

				if (sts_cmd.error ||
				   (R1_CURRENT_STATE(sts_cmd.resp[0])
				   != R1_STATE_TRAN)) {
					sts_retry--;
					/*
					 * wait for at least 146 MCLK cycles for
					 * the card to move to TRANS state. As
					 * the MCLK would be min 200MHz for
					 * tuning, we need max 0.73us delay. To
					 * be on safer side 1ms delay is given.
					 */
		if (cmd.error)
					usleep_range(1000, 1200);
					pr_debug("%s: phase %d sts cmd err %d resp 0x%x\n",
						mmc_hostname(mmc), phase,
						sts_cmd.error, sts_cmd.resp[0]);
					continue;
				}
				break;
			};
		}

		if (!cmd.error && !data.error &&
			!memcmp(data_buf, tuning_block_pattern, size)) {
			/* tuning is successful at this tuning point */
+2 −1
Original line number Diff line number Diff line
@@ -2797,7 +2797,8 @@ static void sdhci_cmd_irq(struct sdhci_host *host, u32 intmask, u32 *mask)
						    SDHCI_COMMAND));
		if (host->cmd->error == -EILSEQ &&
		    (command != MMC_SEND_TUNING_BLOCK_HS200) &&
		    (command != MMC_SEND_TUNING_BLOCK))
		    (command != MMC_SEND_TUNING_BLOCK) &&
		    (command != MMC_SEND_STATUS))
				host->flags |= SDHCI_NEEDS_RETUNING;
		tasklet_schedule(&host->finish_tasklet);
		return;