From patchwork Mon Aug 21 16:02:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 110572 Delivered-To: patch@linaro.org Received: by 10.182.109.195 with SMTP id hu3csp4245982obb; Mon, 21 Aug 2017 09:05:51 -0700 (PDT) X-Received: by 10.84.218.195 with SMTP id g3mr20528729plm.386.1503331551014; Mon, 21 Aug 2017 09:05:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503331551; cv=none; d=google.com; s=arc-20160816; b=jddFe7gOivQP1FcedUrsNSk8QTcjQr3UhVaFBTAEWl7OId94R+veG7VOgEEAwRI565 LMU7dnwiN4MlDNSG0nMRo9UMjpSbjGQFEE5w//sx1q5Jni2/FSdJX3bvUP7E6H4/Bxuq 1fNZo98KfC1nnPbrxez3pdLqLobCq/xg+LFd1VtFW17tf5Onh8ldeALK3Pa3hx1C29rv adivJxrr11MzMWWgwIHJeIbLOoM+PZdgWBYJjusaByb84AXjlC8mPS0i+kT+KKq4RjTt 7rf1GbQOlkpYuXm1XoiZxETlkf8+UNAuiVwK+nfoA2vxq6Y5Gs6LBt/fLYgrUaVzIK8Y xiLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=8orKs8W+Q75qYO/NcwW7xDykSq2M3fMc9q3KExqPgXw=; b=zi8uXeegNqe1PQXx+7ZK2Ah/zNk0yX0jY1bgqjhPg8CF5YndMtV89xq2nuTDO+MXxs //gFmatNS523A/8j76tmRVosDpCGZIpSVTwM4m72ZHwRfEJ3uf9UUVXJekxesoVXGhU7 xuORYgXe2uSrbisiiJhWgY9KtT7q0xvtgA+d74dGegUDdSgelLJJVVtnPF/7zowwExvO fM+oZ1nyXQT6WsKc9kCCQPFwk03K2bSLBP6IoEcWq1o0GVetl0j3hqqqf7mPOQ1s5A5P ehzdTnvq8Bu49IFw6STT07VRXh/iXutFBtpOe5mCzfg1yAdssOpuHq+NapkBAMwmXr9z +0HQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=BrY6nf2k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b14si7510865pfh.673.2017.08.21.09.05.50; Mon, 21 Aug 2017 09:05:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=BrY6nf2k; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754343AbdHUQFr (ORCPT + 26 others); Mon, 21 Aug 2017 12:05:47 -0400 Received: from mail-wr0-f171.google.com ([209.85.128.171]:35736 "EHLO mail-wr0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932219AbdHUQDQ (ORCPT ); Mon, 21 Aug 2017 12:03:16 -0400 Received: by mail-wr0-f171.google.com with SMTP id k46so28390380wre.2 for ; Mon, 21 Aug 2017 09:03:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8orKs8W+Q75qYO/NcwW7xDykSq2M3fMc9q3KExqPgXw=; b=BrY6nf2ktVZfZp7cMIvVCH57qjYSuLDcYoTSkUdpHfmwlMXCHiAr248lFt69N68DHm gvg/ccpVjP04xg/qFOBFnm/n9qhZO5/0aSpC8KbC4XoTnwad2+R5zU2QYwFUFgYdhRre aeAZpFCu6Fm7zmfAgdgvnT7mtzk5egptDDarZDJEyu12tzI9Ahfsv6hwVRvce7qNNpGL mEvZLmAf9yiA7A8mZ3IB4lugzCxTtZB5d2Iw+4tWjBK2LrvS97UvITnGnXMofcusEGIA R1TQn9aKCrCd8Tu4jFgDSNA25o9pY2COEHawa5FpT6H4cVDbBnsoIlv3RMR3fVSyRnQb RHGA== 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:in-reply-to :references; bh=8orKs8W+Q75qYO/NcwW7xDykSq2M3fMc9q3KExqPgXw=; b=ciNGeIgHCqnp/gZahXdSdouR+JvchPcTqNJOmZTMs6Kh0FB1/mz+YQFhLgI1UJmO80 jwkOe3W+a8lQl+wAtr6PRB7wEioILicV9vOfAKpyY83C/y2o75bmhrLmYXYPEnpxu8ae teR0Z2Fw5CzyA3tUthK3yDRPSvEKlqKITQ3fbCYMX2Mvo+S69y8cQVoMW43VEHkW7J63 ZZBPonieJ43slpmvisJeH8OGVmGnreqnGGkrEVUD/Nx/+bXGSi4Y4bk19Fj8j+SLDjaa iMNOd1btbKegDnGYkBt/U5gxzZiXN5gooWgSfIywWN0SraTQ3IV4i4HDhMDMeUzRMAHK BntA== X-Gm-Message-State: AHYfb5gGTyRUy1/4bA/Vva24Cd2Eex8a63wOUtpZ6NXrFh1uUy5jdsC4 XiuU5uvJ+wL9zRRP X-Received: by 10.223.146.195 with SMTP id 61mr12065813wrn.169.1503331395280; Mon, 21 Aug 2017 09:03:15 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id 63sm8120063wra.30.2017.08.21.09.03.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Aug 2017 09:03:14 -0700 (PDT) From: Jerome Brunet To: Ulf Hansson , Kevin Hilman , Carlo Caione Cc: Jerome Brunet , linux-mmc@vger.kernel.org, linux-amlogic@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 09/16] mmc: meson-gx: fix dual data rate mode frequencies Date: Mon, 21 Aug 2017 18:02:54 +0200 Message-Id: <20170821160301.21899-10-jbrunet@baylibre.com> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20170821160301.21899-1-jbrunet@baylibre.com> References: <20170821160301.21899-1-jbrunet@baylibre.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In DDR modes, meson mmc controller requires an input rate twice as fast as the output rate Fixes: 51c5d8447bd7 ("MMC: meson: initial support for GX platforms") Reviewed-by: Kevin Hilman Signed-off-by: Jerome Brunet --- drivers/mmc/host/meson-gx-mmc.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) -- 2.9.5 diff --git a/drivers/mmc/host/meson-gx-mmc.c b/drivers/mmc/host/meson-gx-mmc.c index 2f45daa5d510..0d3416dae8cf 100644 --- a/drivers/mmc/host/meson-gx-mmc.c +++ b/drivers/mmc/host/meson-gx-mmc.c @@ -262,14 +262,29 @@ static void meson_mmc_post_req(struct mmc_host *mmc, struct mmc_request *mrq, mmc_get_dma_dir(data)); } -static int meson_mmc_clk_set(struct meson_host *host, unsigned long clk_rate) +static bool meson_mmc_timing_is_ddr(struct mmc_ios *ios) +{ + if (ios->timing == MMC_TIMING_MMC_DDR52 || + ios->timing == MMC_TIMING_UHS_DDR50 || + ios->timing == MMC_TIMING_MMC_HS400) + return true; + + return false; +} + +static int meson_mmc_clk_set(struct meson_host *host, struct mmc_ios *ios) { struct mmc_host *mmc = host->mmc; + unsigned long rate = ios->clock; int ret; u32 cfg; + /* DDR modes require higher module clock */ + if (meson_mmc_timing_is_ddr(ios)) + rate <<= 1; + /* Same request - bail-out */ - if (host->req_rate == clk_rate) + if (host->req_rate == rate) return 0; /* stop clock */ @@ -278,25 +293,29 @@ static int meson_mmc_clk_set(struct meson_host *host, unsigned long clk_rate) writel(cfg, host->regs + SD_EMMC_CFG); host->req_rate = 0; - if (!clk_rate) { + if (!rate) { mmc->actual_clock = 0; /* return with clock being stopped */ return 0; } - ret = clk_set_rate(host->mmc_clk, clk_rate); + ret = clk_set_rate(host->mmc_clk, rate); if (ret) { dev_err(host->dev, "Unable to set cfg_div_clk to %lu. ret=%d\n", - clk_rate, ret); + rate, ret); return ret; } - host->req_rate = clk_rate; + host->req_rate = rate; mmc->actual_clock = clk_get_rate(host->mmc_clk); + /* We should report the real output frequency of the controller */ + if (meson_mmc_timing_is_ddr(ios)) + mmc->actual_clock >>= 1; + dev_dbg(host->dev, "clk rate: %u Hz\n", mmc->actual_clock); - if (clk_rate != mmc->actual_clock) - dev_dbg(host->dev, "requested rate was %lu\n", clk_rate); + if (ios->clock != mmc->actual_clock) + dev_dbg(host->dev, "requested rate was %u\n", ios->clock); /* (re)start clock */ cfg = readl(host->regs + SD_EMMC_CFG); @@ -490,16 +509,14 @@ static void meson_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) val |= FIELD_PREP(CFG_BUS_WIDTH_MASK, bus_width); val &= ~CFG_DDR; - if (ios->timing == MMC_TIMING_UHS_DDR50 || - ios->timing == MMC_TIMING_MMC_DDR52 || - ios->timing == MMC_TIMING_MMC_HS400) + if (meson_mmc_timing_is_ddr(ios)) val |= CFG_DDR; val &= ~CFG_CHK_DS; if (ios->timing == MMC_TIMING_MMC_HS400) val |= CFG_CHK_DS; - err = meson_mmc_clk_set(host, ios->clock); + err = meson_mmc_clk_set(host, ios); if (err) dev_err(host->dev, "Failed to set clock: %d\n,", err);