From patchwork Fri Nov 30 08:15:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 152496 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp3375511ljp; Fri, 30 Nov 2018 00:16:00 -0800 (PST) X-Google-Smtp-Source: AFSGD/W1KUCTZuL1bLD8jc3VvUeSCA7KDBLZnOHkQ1q53Hjumh7CVfcb4oSWLdauaOpnRZ4igwxl X-Received: by 2002:a65:47ca:: with SMTP id f10mr4125561pgs.166.1543565760243; Fri, 30 Nov 2018 00:16:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543565760; cv=none; d=google.com; s=arc-20160816; b=CxA8N+v2gKWRT92KYjz34q5CvbbWaXfAo0aqDyiaTJQ0pIxCYbKAh7V/rLHPMaqe4Y 8G7XgKTy2apw2RNF1wB1eb1oP+J1mJeQFt3JuUKZXHzUIxzPOec/WQ+cSTCpUH0RVU7X CsDsEf41H/b+r6UcN01votwMTlB+dLIGkwDziffDkFInJNlIuW47KiBsimRp2sfs9J0h aqGS40+DtcGWscTUowE4aENkE+795d6dVfxOQi+aVPzXEVZICO+s7JpwxuU83lYTLjHp Ql2Rc0TGLrwfcGvnr8mCIltCH76oWueyLCd5WlSEQ5oD/hhfvKzhoe8YtKRgvtwkeKHP j5Zw== 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=BOMtWRCOx9ow2bM6UA4ueBdD/Y58ZTCL1pxdToBqb1s=; b=vcS222f2Ow0yUNLSNZ8uArBGkzUG4kC+SD8VeSN6fvDvnZ4Tk534jc5egeJLcdRLKD kOdCq5Zy9ixSafkOVYgrCzxO8isZav5f5b0B6mKcztMaynInY7biY8jC5DgR7VGnFIAL 1sCPsCwWAifwVLZjczTgKNC4VkJ6hiaQkFR1eWQFG+Y0b/fMBCOtVHb+vdw/9FDwSPNA qk1Fe99RyfXD7Bb9J4o4/mDQXPDsMXWlIT6ny6nfEVrpRdoJLlW2jyyswfWB+TWmASGh WaMQgcXrP9f6VGcxuqloNstBgIfAA8ULD73XCd2xN6IsJgnFjsV24vrGcwK4sJLJcPmf vgow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b1Vgxx+v; 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 h14si4472339pgd.189.2018.11.30.00.15.59; Fri, 30 Nov 2018 00:16:00 -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=b1Vgxx+v; 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 S1726572AbeK3TY2 (ORCPT + 15 others); Fri, 30 Nov 2018 14:24:28 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:41272 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726551AbeK3TY2 (ORCPT ); Fri, 30 Nov 2018 14:24:28 -0500 Received: by mail-wr1-f67.google.com with SMTP id x10so4344556wrs.8 for ; Fri, 30 Nov 2018 00:15:57 -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=BOMtWRCOx9ow2bM6UA4ueBdD/Y58ZTCL1pxdToBqb1s=; b=b1Vgxx+vEyqg0KUVq6kyK8mcTv/i397dPZp6N3r4GDdGsP5Ktjv3oQJXBS6v8n0aNP E5qW53TxKtid4ZE78aSAMs2idoQetqX//ipbfNz5ZU+qzHoZTc3GR5+vvNg9/kym7CQq olDT+8DgLkQBYJOz6nDAW5XJX8jKjQ0Qwh7Zg= 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=BOMtWRCOx9ow2bM6UA4ueBdD/Y58ZTCL1pxdToBqb1s=; b=RthjBoJWaId3S5pOUlOcj4fbEKp5NkiyV9W/opfh5+1Mvqvp4eZhoTtZ/vTUFxulaY 8v0ta7SOJZVR5bq2SAWndiyISPtlFXjPTwEWX/d8MzUHXeY/EDz7mC6T2Q5Dct6ch86U +xY/1C4rioIXCUJQbkFGaFxHDRl2USq095GN/ST4Pi7WUxkUFM4Eg47PX1mseZVktJ0u Ps2K5F0WGT0oGmzV4s9I0wM5C9K6lj1b4q9g1DqdtipwMS3VRDgd83cLoOzLFZ1sqvLw o3wzJ60UUqtkC/K+FHX3ihSsRZEElgv3HmuDaj43/q/dkCP2Ee6VKXlCJV4fwvlfgL+v UOtQ== X-Gm-Message-State: AA+aEWZEfYIFt2KQ8uskfp2qbPbABITKwf93TuGAjtDyHjED61T+eNfA kThuJi/tCkmvHq2KkdNqTPT4jQ== X-Received: by 2002:adf:e54a:: with SMTP id z10mr3944523wrm.238.1543565757142; Fri, 30 Nov 2018 00:15:57 -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 5sm5698982wmw.8.2018.11.30.00.15.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 30 Nov 2018 00:15:56 -0800 (PST) From: Loic Poulain To: adrian.hunter@intel.com, ulf.hansson@linaro.org Cc: linux-mmc@vger.kernel.org, linux-arm-msm@vger.kernel.org, jhugo@codeaurora.org, Loic Poulain Subject: [PATCH v3] mmc: sdhci-msm: Disable CDR function on TX Date: Fri, 30 Nov 2018 09:15:55 +0100 Message-Id: <1543565755-30562-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 --- v2: reword: previous commit message was not the good version v3: rebase on upstream drivers/mmc/host/sdhci-msm.c | 44 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) -- 2.7.4 Acked-by: Georgi Djakov diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index 3cc8bfe..6f230cd 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -258,6 +258,8 @@ struct sdhci_msm_host { bool mci_removed; 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) @@ -1025,6 +1027,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); @@ -1042,8 +1065,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: @@ -1525,6 +1554,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) {