From patchwork Thu Nov 22 10:01:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 10693767 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 AED561734 for ; Thu, 22 Nov 2018 10:01:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FFB72C9A4 for ; Thu, 22 Nov 2018 10:01:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 945582C9D8; Thu, 22 Nov 2018 10:01:06 +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 0BF5C2C999 for ; Thu, 22 Nov 2018 10:01:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390006AbeKVUjt (ORCPT ); Thu, 22 Nov 2018 15:39:49 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:35016 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731622AbeKVUjt (ORCPT ); Thu, 22 Nov 2018 15:39:49 -0500 Received: by mail-wm1-f66.google.com with SMTP id c126so8455103wmh.0 for ; Thu, 22 Nov 2018 02:01:03 -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=G/6c5XaB7ndUUHv/xjTQ365uz2vFLVJDGriphJ8ub+c=; b=QzHZmBWIjRTqk2toLJHuIMPkEhXNU7CERMh+gsdvd/9p63maaqnB79O0b3+/eTWBqN 1lrWNITrl+sMlAAzNJ5Rlez2peQIG8R8AZt43b9M/5nVJZUOqYAyXXwBa43zmhqFKDBb 98/6itp+2aikJ4tPpgG5xAZcpjB/dOEBkVQSw= 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=G/6c5XaB7ndUUHv/xjTQ365uz2vFLVJDGriphJ8ub+c=; b=l81XVnZWjVmlYNu3Ynx9YiPAzXtqPAqiYhnmk3vj2LhIOjNH2Tb/FmSwKZx9tQ8IlO w7NMpDfrfu66wMvs4gH34ilgSph9VUWJxTyKPR/39UNkieY9Z1NA+NnusssL2BMck74d o6gJ9QDLSAhVjpI9XntC7PXsrZRzWRXEOrFwPJ0pFCBIJ8SNiSD+ZS8Le6+CZIM1j9TR ZI5Ux9avN4cJAd8frJK2foUXQOmklyVtLQm02u0F6skN6KXOA9iWKv0uLR/O2L67sY// FR17F7xIsQQgK98Wanh9bWYiUUq/7zSDBvDKVGT+sOJFiDW0a+FMZwR0GhI+DxX5ODDL cSyA== X-Gm-Message-State: AA+aEWaldmFMba5wy9LY5dpicLyC2CJaRofnfLCH17rUBhjfg92KB5vX R57kS8ueMUWLsIH2Z0XmgsM9Xw== X-Google-Smtp-Source: AJdET5cuiTPqt/3TI9NHW48lYQdNZfauG6y1btP4uEgDwQBynHNcYVIpB9OyCvIqLdT6STP4PYgVhw== X-Received: by 2002:a1c:170e:: with SMTP id 14mr8908196wmx.113.1542880863100; Thu, 22 Nov 2018 02:01:03 -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 q2sm31492932wru.56.2018.11.22.02.01.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 22 Nov 2018 02:01:02 -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] mmc: sdhci-msm: Disable CDR function on TX Date: Thu, 22 Nov 2018 11:01:01 +0100 Message-Id: <1542880861-20515-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 enable during DLL configuration. However according to the APQ8016 reference manual, this function must be disabled during TX and tuning phase. Goal being to prevent CDR to use TX timings for phase adjustement (requested fo RX) and avoid the mechanism to interfere during tuning challenges. This patch enable/disable CDR according to the transfer configured 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 --- 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) {