From patchwork Tue Dec 4 12:25:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 152801 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp8006736ljp; Tue, 4 Dec 2018 04:25:38 -0800 (PST) X-Google-Smtp-Source: AFSGD/UuGZlJ4Nf8XT6BkwzR6vuspEe8BYwmUP197DDSw3lKUuscQ0EWwVF0FvTmdEGWIWHZn0a0 X-Received: by 2002:a63:62c3:: with SMTP id w186mr15562652pgb.345.1543926338046; Tue, 04 Dec 2018 04:25:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543926338; cv=none; d=google.com; s=arc-20160816; b=EspTcUHujtpOGYjAiF7ycz6wSU3HZZXhAXOFXPEml4jq2WhXjORs2EmItY5J0CNHwc o+TufsG6E/B0+uA+p4qQgN3txnFshS02MzdBkd8R3arwX4F/Y5k6yiFp+suIoBH8/ILI 9EKinG3FyewLaCb+fraW393wIlQna7fWaW5rF35vgJeS+p2D6Ftvd6Vh1WlzOofHFJnQ 5T8bBhS3jdwYrYgG8yqhOf4e704aHUWC/9abtcLLhlxzlAk+TorV0FZ5UQWBfmrOm5lH QDPCvtlnjrgjuzk/GaZnLoXn29ubbDqxEXet1iZa32qr9zcf59yH7Nate5nGHvMipeOQ D9Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=+tUz/5FTxpiGEKGc0XU8hSTxIshymm8eeCCrsQuvaWM=; b=ctFsOdK1oQBZlkZQuntvjPdDvDbs2ZY9LJ65M1tqd/aGa6KdXsagGAJLev+9RSAOk4 it7V3hjaU8fOHyi9Wd5Et45kkIojfYY0nGtRpZu7JgHtdrAJ5+S6tiEiNLyugR1bzfMT BfjlfbN/BPfbvqJ/+sYzSP5FYeikfZlgKDqjYwh96FNbat++pB5km7wAhtI3zv5QaBZp hGDcEqEVPhBISC4AHIoetctbieNrHjshVjJ9c5P6Qv5juOLFgrHpjSIRj+dve7eNg34T Rtc7xgRDTrUHH685aKfX1mZZXY/i2RasKBr1eIz1FKXAP1VTNqpyx9gM9NBcLipDdvOg +a/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WyD6SEQU; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g1si15789746pgj.34.2018.12.04.04.25.37; Tue, 04 Dec 2018 04:25:38 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WyD6SEQU; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725910AbeLDMZg (ORCPT + 15 others); Tue, 4 Dec 2018 07:25:36 -0500 Received: from mail-wm1-f68.google.com ([209.85.128.68]:38881 "EHLO mail-wm1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725902AbeLDMZg (ORCPT ); Tue, 4 Dec 2018 07:25:36 -0500 Received: by mail-wm1-f68.google.com with SMTP id m22so9144644wml.3 for ; Tue, 04 Dec 2018 04:25:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=+tUz/5FTxpiGEKGc0XU8hSTxIshymm8eeCCrsQuvaWM=; b=WyD6SEQUOa/T+flYEpCuPRZeamt00iEezrCNfA1QnqdmegS9Hlf0P9PHTh19IebPpw CFzAH65z7mVqf1U3wvzVPmzl/cmMAlZxgBjUbYDDay6yMhXYNezO/zKTJ9f16vIZiJKI m1N1Q35sI5sarZdPJL7ae5znn5Mh4BdW/xYwk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=+tUz/5FTxpiGEKGc0XU8hSTxIshymm8eeCCrsQuvaWM=; b=r/MDEdEeWQlpcn01DuBfQBYIW2Oe5Uz50NhCKgzaF9Zpsu6fmxsG+lm+q/pp0YUB+z hv6By+mPrZkWdsjRk+z/BF5My5AUdiQB/UfPv8DAq5dkyaaeid965ldyK9+nPKte8++r 3WuIPk6YEzL2ribWDuGzTiK/S6loqiaAC3zVZOIlaemwlAI5m+K9l5EaD3K5GR2GACr1 rDPEOHXCK6Dv+E6O/Pkj38B1at3BOLEF/SP6mdywUaWGOCt51QlkvItpJz14I6NtRHic tA2x8ooGf2Gr4vVVSNx9lp8viFKtb7U0PadoFx1F0ATgH4UvyTIPnlFrHjWobMlxmwr+ 0VCw== X-Gm-Message-State: AA+aEWZ1whKo2dV8qXx33IOjyd1UzAVZaU5BiIs22k81CrL/xsQWKYoX 2Qxwcn5t0U+JczPzdrXtZko5ig== X-Received: by 2002:a1c:934b:: with SMTP id v72mr8918436wmd.5.1543926334932; Tue, 04 Dec 2018 04:25:34 -0800 (PST) Received: from lpoulain-ThinkPad-T470p.home (atoulouse-654-1-394-222.w90-55.abo.wanadoo.fr. [90.55.193.222]) by smtp.gmail.com with ESMTPSA id t18sm3878891wmt.35.2018.12.04.04.25.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Dec 2018 04:25:34 -0800 (PST) From: Loic Poulain To: ulf.hansson@linaro.org, adrian.hunter@intel.com Cc: linux-mmc@vger.kernel.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, sboyd@kernel.org, georgi.djakov@linaro.org, Loic Poulain Subject: [PATCH v4] mmc: sdhci-msm: Disable CDR function on TX Date: Tue, 4 Dec 2018 13:25:32 +0100 Message-Id: <1543926332-19546-1-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The Clock Data Recovery (CDR) circuit allows to automatically adjust the RX sampling-point/phase for high frequency cards (SDR104, HS200...). CDR is automatically enabled during DLL configuration. However, according to the APQ8016 reference manual, this function must be disabled during TX and tuning phase in order to prevent any interferences during tuning challenges and unexpected phase alteration during TX transfers. This patch enables/disables CDR according to the current transfer mode. This fixes sporadic write transfer issues observed with some SDR104 and HS200 cards. Inspired by sdhci-msm downstream patch: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/432516/ Reported-by: Leonid Segal Reported-by: Manabu Igusa Signed-off-by: Loic Poulain Acked-by: Adrian Hunter Acked-by: Georgi Djakov --- v2: reword: previous commit message was not the good version v3: rebase on upstream v4: remove extra parenthis rebase on mmc next branch drivers/mmc/host/sdhci-msm.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) -- 2.7.4 diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index 4cac593..5497a71 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -260,6 +260,8 @@ struct sdhci_msm_host { bool restore_dll_config; const struct sdhci_msm_variant_ops *var_ops; const struct sdhci_msm_offset *offset; + bool use_cdr; + u32 transfer_mode; }; static const struct sdhci_msm_offset *sdhci_priv_msm_offset(struct sdhci_host *host) @@ -1069,6 +1071,27 @@ static int sdhci_msm_restore_sdr_dll_config(struct sdhci_host *host) return ret; } +static void sdhci_msm_set_cdr(struct sdhci_host *host, bool enable) +{ + const struct sdhci_msm_offset *msm_offset = sdhci_priv_msm_offset(host); + u32 config, oldconfig = readl_relaxed(host->ioaddr + + msm_offset->core_dll_config); + + config = oldconfig; + if (enable) { + config |= CORE_CDR_EN; + config &= ~CORE_CDR_EXT_EN; + } else { + config &= ~CORE_CDR_EN; + config |= CORE_CDR_EXT_EN; + } + + if (config != oldconfig) { + writel_relaxed(config, host->ioaddr + + msm_offset->core_dll_config); + } +} + static int sdhci_msm_execute_tuning(struct mmc_host *mmc, u32 opcode) { struct sdhci_host *host = mmc_priv(mmc); @@ -1079,8 +1102,14 @@ static int sdhci_msm_execute_tuning(struct mmc_host *mmc, u32 opcode) struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); struct sdhci_msm_host *msm_host = sdhci_pltfm_priv(pltfm_host); - if (!sdhci_msm_is_tuning_needed(host)) + if (!sdhci_msm_is_tuning_needed(host)) { + msm_host->use_cdr = false; + sdhci_msm_set_cdr(host, false); return 0; + } + + /* Clock-Data-Recovery used to dynamically adjust RX sampling point */ + msm_host->use_cdr = true; /* * For HS400 tuning in HS200 timing requires: @@ -1562,6 +1591,19 @@ static int __sdhci_msm_check_write(struct sdhci_host *host, u16 val, int reg) case SDHCI_POWER_CONTROL: req_type = !val ? REQ_BUS_OFF : REQ_BUS_ON; break; + case SDHCI_TRANSFER_MODE: + msm_host->transfer_mode = val; + break; + case SDHCI_COMMAND: + if (!msm_host->use_cdr) + break; + if ((msm_host->transfer_mode & SDHCI_TRNS_READ) && + SDHCI_GET_CMD(val) != MMC_SEND_TUNING_BLOCK_HS200 && + SDHCI_GET_CMD(val) != MMC_SEND_TUNING_BLOCK) + sdhci_msm_set_cdr(host, true); + else + sdhci_msm_set_cdr(host, false); + break; } if (req_type) {