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: 151745 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp547116ljp; Thu, 22 Nov 2018 02:18:12 -0800 (PST) X-Google-Smtp-Source: AFSGD/UeY2MI8xUwsaLX9ORBTjVJdHnP8Qd8XX6WZD/io7KW9ND+VUys07sew0+YUzcMmB470HE9 X-Received: by 2002:a17:902:9f89:: with SMTP id g9mr10730654plq.214.1542881892633; Thu, 22 Nov 2018 02:18:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542881892; cv=none; d=google.com; s=arc-20160816; b=BoEE2/ZOBCmQ/XEgkH7HlRLofQ+QGBzuy21DF5JXO7q1qBbRgTztvLgMYR+bmQA7a5 JhCaxQkGvpZrGtXXrr0zu8qCEyfIQoZSLMR9bN29fhDqkGR7vRsDhENkft6Nwnb3TjPD v43HZv2Xb7b4xBlfBUfAvBct0DXtzStq0lOE0emsp0e95VDa0SIHFkb8oWmCHZTpVrYi Pech8xNHdDGQnB4Qk6mi8lvca8/Yn9sQSR+B9TLF4DJtl+c5ohhLj38TUELT4n4zh+zb sFmB35sUosnAyYlsHLggjzkzW/bzW/pNSXz9OUu0m4pn6yydFuS1d99xlUcgHBf8Qdbm wTxg== 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=MMdOPeeMb0SoHhxUSHkzxI7p8nqh47pQBJGNhVOJZY8=; b=WI0fM3rH8yOsDQ2QZbQk78YJG8tn4DlQtLKUStdIObCQ3uDBXTv0sa6XGh3LiLcwei IzP8Cw+7oKVgF/Q5tDNjPT6l38lYBhLf/l6Ag9oAct4ih/PFu9NXCg0UgnlxXFnfyGqY B0H2E4RuTzEeln9mghXfUSBh6CSAs5XW4/ihbXfYdopye4IEIGWXxv3QCbp/aI6W9HpU jo1d+LHIFxFkmq3mg/rekHbez2p8+RdH9oRxUe6iHxtkeK7Vf2fCuz4HO8gFKl21uEz1 3VxVuq4NOLgWAXuW7UiynbckrqiGqUvkOxrnv0fhYPPwH6QMrbakI7Q2eb34OdBihUSb DGgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EdaqFiQi; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-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 22si47411359pgl.107.2018.11.22.02.18.12; Thu, 22 Nov 2018 02:18:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-mmc-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=EdaqFiQi; spf=pass (google.com: best guess record for domain of linux-mmc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-mmc-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 S2394126AbeKVU46 (ORCPT + 5 others); Thu, 22 Nov 2018 15:56:58 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:33756 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2394125AbeKVU46 (ORCPT ); Thu, 22 Nov 2018 15:56:58 -0500 Received: by mail-wr1-f68.google.com with SMTP id c14so3035921wrr.0 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=auCyrEgeos5z55vusaspKZj+30O7/b7EHeoIZ6L/T/Xzda2khLSuA/lptUsrPSiqRm LT8zIZA6/RVYYpkSbQuHCMSJAofNd9/Vak17OHoCjZudZCwps5I+7pWj4ArVVT0umdsO ggwN279iDSD/hBG7dW4Y21bIVCYmqfWey/0jPPW0wdbUBpAIDb2PDqtrkmbeKSjHyfDt NvH7GEAXXS52E2XQCuDtGak4pLuyZ/eI3/QtqZycmZSmsai9TGYVXC/w8oJ2r2Mm3whE rB60vYm2BGyKI2azNRB+rRBaVqnMUTku1vKBerXnEih4DnNBK+ZOyu31JAgHpvPwPWcD DVEA== X-Gm-Message-State: AA+aEWa1QA2uCZCjveMvt6mCxBX3kIUYfYF7j2ouhBJEF7lganBkX1S/ 4wpyc3UVVgnZdr+mJaqh8c82Vg== 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-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@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 --- v2: reword: previous commit message was not the good version drivers/mmc/host/sdhci-msm.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) -- 2.7.4 Acked-by: Adrian Hunter 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) {