linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Heiko Stuebner <heiko@sntech.de>
Cc: Rob Herring <robh+dt@kernel.org>,
	Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Ulf Hansson <ulf.hansson@linaro.org>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Michael Turquette <mturquette@baylibre.com>,
	Stephen Boyd <sboyd@kernel.org>,
	linux-clk@vger.kernel.org, linux-mmc@vger.kernel.org,
	linux-gpio@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-rockchip@lists.infradead.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel@lists.collabora.co.uk,
	Yifeng Zhao <yifeng.zhao@rock-chips.com>,
	kernel@collabora.com,
	Sebastian Reichel <sebastian.reichel@collabora.com>
Subject: [PATCHv2 09/21] mmc: sdhci-of-dwcmshc: add reset call back for rockchip Socs
Date: Wed,  4 May 2022 23:32:39 +0200	[thread overview]
Message-ID: <20220504213251.264819-10-sebastian.reichel@collabora.com> (raw)
In-Reply-To: <20220504213251.264819-1-sebastian.reichel@collabora.com>

From: Yifeng Zhao <yifeng.zhao@rock-chips.com>

The reset function build in the SDHCI will not reset the logic
circuit related to the tuning function, which may cause data
reading errors. Resetting the complete SDHCI controller through
the reset controller fixes the issue.

Signed-off-by: Yifeng Zhao <yifeng.zhao@rock-chips.com>
[rebase, use optional variant of reset getter]
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
 drivers/mmc/host/sdhci-of-dwcmshc.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c
index bac874ab0b33..3a1b5ba36405 100644
--- a/drivers/mmc/host/sdhci-of-dwcmshc.c
+++ b/drivers/mmc/host/sdhci-of-dwcmshc.c
@@ -15,6 +15,7 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/reset.h>
 #include <linux/sizes.h>
 
 #include "sdhci-pltfm.h"
@@ -63,6 +64,7 @@
 struct rk3568_priv {
 	/* Rockchip specified optional clocks */
 	struct clk_bulk_data rockchip_clks[RK3568_MAX_CLKS];
+	struct reset_control *reset;
 	u8 txclk_tapnum;
 };
 
@@ -255,6 +257,21 @@ static void dwcmshc_rk3568_set_clock(struct sdhci_host *host, unsigned int clock
 	sdhci_writel(host, extra, DWCMSHC_EMMC_DLL_STRBIN);
 }
 
+static void rk35xx_sdhci_reset(struct sdhci_host *host, u8 mask)
+{
+	struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+	struct dwcmshc_priv *dwc_priv = sdhci_pltfm_priv(pltfm_host);
+	struct rk35xx_priv *priv = dwc_priv->priv;
+
+	if (mask & SDHCI_RESET_ALL && priv->reset) {
+		reset_control_assert(priv->reset);
+		udelay(1);
+		reset_control_deassert(priv->reset);
+	}
+
+	sdhci_reset(host, mask);
+}
+
 static const struct sdhci_ops sdhci_dwcmshc_ops = {
 	.set_clock		= sdhci_set_clock,
 	.set_bus_width		= sdhci_set_bus_width,
@@ -269,7 +286,7 @@ static const struct sdhci_ops sdhci_dwcmshc_rk3568_ops = {
 	.set_bus_width		= sdhci_set_bus_width,
 	.set_uhs_signaling	= dwcmshc_set_uhs_signaling,
 	.get_max_clock		= sdhci_pltfm_clk_get_max_clock,
-	.reset			= sdhci_reset,
+	.reset			= rk35xx_sdhci_reset,
 	.adma_write_desc	= dwcmshc_adma_write_desc,
 };
 
@@ -292,6 +309,13 @@ static int dwcmshc_rk3568_init(struct sdhci_host *host, struct dwcmshc_priv *dwc
 	int err;
 	struct rk3568_priv *priv = dwc_priv->priv;
 
+	priv->reset = devm_reset_control_array_get_optional_exclusive(mmc_dev(host->mmc));
+	if (IS_ERR(priv->reset)) {
+		err = PTR_ERR(priv->reset);
+		dev_err(mmc_dev(host->mmc), "failed to get reset control %d\n", err);
+		return err;
+	}
+
 	priv->rockchip_clks[0].id = "axi";
 	priv->rockchip_clks[1].id = "block";
 	priv->rockchip_clks[2].id = "timer";
-- 
2.35.1


  parent reply	other threads:[~2022-05-04 21:33 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-04 21:32 [PATCHv2 00/21] Basic RK3588 Support Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 01/21] dt-bindings: pinctrl: rockchip: add rk3588 Sebastian Reichel
2022-05-05 14:14   ` Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 02/21] dt-bindings: mmc: sdhci-of-dwcmhsc: Add rk3588 Sebastian Reichel
2022-05-05 14:15   ` Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 03/21] dt-binding: clock: Document rockchip,rk3588-cru bindings Sebastian Reichel
2022-05-17  0:01   ` Rob Herring
2022-05-04 21:32 ` [PATCHv2 04/21] clk: rockchip: add register offset of the cores select parent Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 05/21] clk: rockchip: add pll type for RK3588 Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 06/21] clk: rockchip: clk-cpu: add mux setting for cpu change frequency Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 07/21] clk: rockchip: add dt-binding header for rk3588 Sebastian Reichel
2022-05-17  0:03   ` Rob Herring
2022-05-04 21:32 ` [PATCHv2 08/21] clk: rockchip: Add clock controller for the RK3588 Sebastian Reichel
2022-05-04 21:32 ` Sebastian Reichel [this message]
2022-05-06  8:52   ` [PATCHv2 09/21] mmc: sdhci-of-dwcmshc: add reset call back for rockchip Socs Ulf Hansson
2022-05-06  9:18     ` Sebastian Reichel
2022-05-06 12:37       ` Ulf Hansson
2022-05-31 13:38   ` Ulf Hansson
2022-05-04 21:32 ` [PATCHv2 10/21] mmc: sdhci-of-dwcmshc: rename rk3568 to rk35xx Sebastian Reichel
2022-05-31 13:38   ` Ulf Hansson
2022-05-04 21:32 ` [PATCHv2 11/21] mmc: sdhci-of-dwcmshc: add support for rk3588 Sebastian Reichel
2022-05-31 13:38   ` Ulf Hansson
2022-05-04 21:32 ` [PATCHv2 12/21] pinctrl/rockchip: add error handling for pull/drive register getters Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 13/21] pinctrl/rockchip: add rk3588 support Sebastian Reichel
2022-05-05 13:51   ` Nicolas Frattaroli
2022-05-05 14:11     ` Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 14/21] gpio: rockchip: add support for rk3588 Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 15/21] dt-bindings: serial: snps-dw-apb-uart: Add Rockchip RK3588 Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 16/21] dt-bindings: soc: rockchip: add initial rk3588 syscon compatibles Sebastian Reichel
2022-05-17  0:04   ` Rob Herring
2022-05-04 21:32 ` [PATCHv2 17/21] dt-bindings: gpio: rockchip: add gpio-ranges Sebastian Reichel
2022-05-17  0:04   ` Rob Herring
2022-05-04 21:32 ` [PATCHv2 18/21] dt-bindings: pinctrl: rockchip: increase max amount of device functions Sebastian Reichel
2022-05-17  0:05   ` Rob Herring
2022-05-19 13:04   ` Linus Walleij
2022-05-04 21:32 ` [PATCHv2 19/21] arm64: dts: rockchip: Add rk3588s pinctrl data Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 20/21] arm64: dts: rockchip: Add base DT for rk3588 SoC Sebastian Reichel
2022-05-04 21:32 ` [PATCHv2 21/21] arm64: dts: rockchip: Add rk3588-evb1 board Sebastian Reichel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220504213251.264819-10-sebastian.reichel@collabora.com \
    --to=sebastian.reichel@collabora.com \
    --cc=adrian.hunter@intel.com \
    --cc=brgl@bgdev.pl \
    --cc=devicetree@vger.kernel.org \
    --cc=heiko@sntech.de \
    --cc=kernel@collabora.com \
    --cc=kernel@lists.collabora.co.uk \
    --cc=krzk+dt@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=mturquette@baylibre.com \
    --cc=p.zabel@pengutronix.de \
    --cc=robh+dt@kernel.org \
    --cc=sboyd@kernel.org \
    --cc=ulf.hansson@linaro.org \
    --cc=yifeng.zhao@rock-chips.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).