From patchwork Thu Nov 22 10:18:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 10693861 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D3C581734 for ; Thu, 22 Nov 2018 10:18:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C51D32CA74 for ; Thu, 22 Nov 2018 10:18:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B55152CA98; Thu, 22 Nov 2018 10:18:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9A502CA74 for ; Thu, 22 Nov 2018 10:18:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394125AbeKVU46 (ORCPT ); Thu, 22 Nov 2018 15:56:58 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:42513 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394124AbeKVU46 (ORCPT ); Thu, 22 Nov 2018 15:56:58 -0500 Received: by mail-wr1-f67.google.com with SMTP id q18so8650161wrx.9 for ; Thu, 22 Nov 2018 02:18:10 -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=MMdOPeeMb0SoHhxUSHkzxI7p8nqh47pQBJGNhVOJZY8=; b=EdaqFiQiFznJwFbYOLaBit2fJU+96FBg91snKQooAG3WjmlmXr51F+A8dZWqiKBSr0 R0SUHRco83ePJ2/DS8p4qMyHXQOtVwzWTQDieER/5gedDpnXbXgjn5muIC+1J22XaVai ScnZzXJTn1JXso7Vc7B5SlTSWlqHyp/gUbSZw= 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=MMdOPeeMb0SoHhxUSHkzxI7p8nqh47pQBJGNhVOJZY8=; b=lMDh/z1XSF8z44t1eMr+/Xp8DIwOZuIgRmjivSAW0vZqmN39C2kGzzPkWIx+tSWWnc tBhNHZm7UpTWR0cgWLSgi5MsoK4KYilQOz94Jny5/kGWZYxfUqHV9/qff96uYerYESWE ZGXHGjwSA1dW9vt5MmbZVRewyFfbyx1+AaSuU1znO46a1OphrI54h26RdX/StigxoXz1 y294PwdFrAMuN3xqCjLEaB4LQghxm+5al2kNgItTkNV5pKZo4AqPSi2Wqp42hvZYJyID AP2KBu+FVe32vN4xGZSqgBmHv4Ayl9+BktegsxPnaGtvU+22D/ISTSMZqL70uEp9LX0m 1GBw== X-Gm-Message-State: AA+aEWZIWjfSFeFRkpw0IGn9zptJIw5rt3fwhg8KSv3GJZ+a4hldWtB1 J5xaM54RTgE2KT4yZT+OdURf4A== X-Google-Smtp-Source: AFSGD/We/oZA61QwxX2xWQQcQez3WkT6R28VzxOxFiFVzcpG/Sh76jDZhxCVZChFHuPue4vd57BJQQ== X-Received: by 2002:a5d:4303:: with SMTP id h3mr4714517wrq.273.1542881889488; Thu, 22 Nov 2018 02:18:09 -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 h13sm24631649wrp.61.2018.11.22.02.18.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Nov 2018 02:18:08 -0800 (PST) From: Loic Poulain To: adrian.hunter@intel.com, ulf.hansson@linaro.org Cc: linux-arm-msm@vger.kernel.org, linux-mmc@vger.kernel.org, migusa@arrowjapan.com, Loic Poulain Subject: [PATCH v2] mmc: sdhci-msm: Disable CDR function on TX Date: Thu, 22 Nov 2018 11:18:07 +0100 Message-Id: <1542881887-21296-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 X-Virus-Scanned: ClamAV using ClamSMTP 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 drivers/mmc/host/sdhci-msm.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index a28f5fe..7495854 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -260,6 +260,8 @@ struct sdhci_msm_host { const struct sdhci_msm_variant_ops *var_ops; const struct sdhci_msm_offset *offset; struct icc_path *path; + bool use_cdr; + u32 transfer_mode; }; static const struct sdhci_msm_offset *sdhci_priv_msm_offset(struct sdhci_host *host) @@ -1027,6 +1029,27 @@ static int sdhci_msm_hs400_dll_calibration(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); @@ -1044,8 +1067,14 @@ static int sdhci_msm_execute_tuning(struct mmc_host *mmc, u32 opcode) if (host->clock <= CORE_FREQ_100MHZ || !(ios.timing == MMC_TIMING_MMC_HS400 || ios.timing == MMC_TIMING_MMC_HS200 || - ios.timing == MMC_TIMING_UHS_SDR104)) + ios.timing == MMC_TIMING_UHS_SDR104)) { + 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: @@ -1527,6 +1556,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) {