All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCHv3 1/2] spi: dw: add reset control
@ 2020-05-27 20:41 Dinh Nguyen
  2020-05-27 20:41 ` [PATCHv3 2/2] dt-bindings: snps,dw-apb-ssi: add optional reset property Dinh Nguyen
  2020-05-29 17:19 ` [PATCHv3 1/2] spi: dw: add reset control Mark Brown
  0 siblings, 2 replies; 4+ messages in thread
From: Dinh Nguyen @ 2020-05-27 20:41 UTC (permalink / raw)
  To: linux-kernel
  Cc: dinguyen, devicetree, broonie, robh+dt, linux-spi, Sergey.Semin,
	fancer.lancer, andriy.shevchenko, lars.povlsen, Liang Jin J

Add mechanism to get the reset control and deassert it in order to bring
the IP out of reset.

Signed-off-by: Liang Jin J <liang.j.jin@ericsson.com>
Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
---
v3: allow for other failures
    remove tab for rstc reset_control
v2: use _get_optional_exclusive
    put IP back into reset if there was an error in probe function
---
 drivers/spi/spi-dw-mmio.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/drivers/spi/spi-dw-mmio.c b/drivers/spi/spi-dw-mmio.c
index 384a3ab6dc2d..1e921c40d79b 100644
--- a/drivers/spi/spi-dw-mmio.c
+++ b/drivers/spi/spi-dw-mmio.c
@@ -20,6 +20,7 @@
 #include <linux/acpi.h>
 #include <linux/property.h>
 #include <linux/regmap.h>
+#include <linux/reset.h>
 
 #include "spi-dw.h"
 
@@ -30,6 +31,7 @@ struct dw_spi_mmio {
 	struct clk     *clk;
 	struct clk     *pclk;
 	void           *priv;
+	struct reset_control *rstc;
 };
 
 #define MSCC_CPU_SYSTEM_CTRL_GENERAL_CTRL	0x24
@@ -175,6 +177,14 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
 	if (ret)
 		goto out_clk;
 
+	/* find an optional reset controller */
+	dwsmmio->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, "spi");
+	if (IS_ERR(dwsmmio->rstc)) {
+		ret = PTR_ERR(dwsmmio->rstc);
+		goto out_clk;
+	}
+	reset_control_deassert(dwsmmio->rstc);
+
 	dws->bus_num = pdev->id;
 
 	dws->max_freq = clk_get_rate(dwsmmio->clk);
@@ -208,6 +218,8 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
 	clk_disable_unprepare(dwsmmio->pclk);
 out_clk:
 	clk_disable_unprepare(dwsmmio->clk);
+	reset_control_assert(dwsmmio->rstc);
+
 	return ret;
 }
 
@@ -219,6 +231,7 @@ static int dw_spi_mmio_remove(struct platform_device *pdev)
 	pm_runtime_disable(&pdev->dev);
 	clk_disable_unprepare(dwsmmio->pclk);
 	clk_disable_unprepare(dwsmmio->clk);
+	reset_control_assert(dwsmmio->rstc);
 
 	return 0;
 }
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-29 17:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-27 20:41 [PATCHv3 1/2] spi: dw: add reset control Dinh Nguyen
2020-05-27 20:41 ` [PATCHv3 2/2] dt-bindings: snps,dw-apb-ssi: add optional reset property Dinh Nguyen
2020-05-29 13:02   ` [PATCHv3 2/2] spi: dw: " Mark Brown
2020-05-29 17:19 ` [PATCHv3 1/2] spi: dw: add reset control Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.