linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv2 1/2] spi: dw: add reset control
@ 2020-05-26 15:12 Dinh Nguyen
  2020-05-26 15:12 ` [PATCHv2 2/2] dt-bindings: snps,dw-apb-ssi: add optional reset property Dinh Nguyen
  2020-05-26 15:21 ` [PATCHv2 1/2] spi: dw: add reset control Andy Shevchenko
  0 siblings, 2 replies; 3+ messages in thread
From: Dinh Nguyen @ 2020-05-26 15:12 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>
---
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..07e015b6d03d 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)) {
+		if (PTR_ERR(dwsmmio->rstc) == -EPROBE_DEFER)
+			return PTR_ERR(dwsmmio->rstc);
+	}
+	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] 3+ messages in thread

* [PATCHv2 2/2] dt-bindings: snps,dw-apb-ssi: add optional reset property
  2020-05-26 15:12 [PATCHv2 1/2] spi: dw: add reset control Dinh Nguyen
@ 2020-05-26 15:12 ` Dinh Nguyen
  2020-05-26 15:21 ` [PATCHv2 1/2] spi: dw: add reset control Andy Shevchenko
  1 sibling, 0 replies; 3+ messages in thread
From: Dinh Nguyen @ 2020-05-26 15:12 UTC (permalink / raw)
  To: linux-kernel
  Cc: dinguyen, devicetree, broonie, robh+dt, linux-spi, Sergey.Semin,
	fancer.lancer, andriy.shevchenko, lars.povlsen

Add optional reset property.

Signed-off-by: Dinh Nguyen <dinguyen@kernel.org>
---
v2: actually document the "resets" and "reset-names" optional properties
---
 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt b/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt
index 3ed08ee9feba..c679778612f3 100644
--- a/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt
+++ b/Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt
@@ -22,6 +22,9 @@ Optional properties:
 - num-cs : The number of chipselects. If omitted, this will default to 4.
 - reg-io-width : The I/O register width (in bytes) implemented by this
   device.  Supported values are 2 or 4 (the default).
+- resets : contains an entry for each entry in reset-names.
+	   See ../reset/reset.txt for details.
+- reset-names : must contain "spi"
 
 Child nodes as per the generic SPI binding.
 
@@ -37,5 +40,7 @@ Example:
 		num-cs = <2>;
 		cs-gpios = <&gpio0 13 0>,
 			   <&gpio0 14 0>;
+		resets = <&rst SPIM0_RST>;
+		reset-names = "spi";
 	};
 
-- 
2.17.1


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

* Re: [PATCHv2 1/2] spi: dw: add reset control
  2020-05-26 15:12 [PATCHv2 1/2] spi: dw: add reset control Dinh Nguyen
  2020-05-26 15:12 ` [PATCHv2 2/2] dt-bindings: snps,dw-apb-ssi: add optional reset property Dinh Nguyen
@ 2020-05-26 15:21 ` Andy Shevchenko
  1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2020-05-26 15:21 UTC (permalink / raw)
  To: Dinh Nguyen
  Cc: linux-kernel, devicetree, broonie, robh+dt, linux-spi,
	Sergey.Semin, fancer.lancer, lars.povlsen, Liang Jin J

On Tue, May 26, 2020 at 10:12:17AM -0500, Dinh Nguyen wrote:
> Add mechanism to get the reset control and deassert it in order to bring
> the IP out of reset.

...

>  	struct clk     *clk;
>  	struct clk     *pclk;
>  	void           *priv;
> +	struct reset_control	*rstc;

I think either you make it one space or you align all the rest members
accordingly. I would rather go with former.

...

> +	/* find an optional reset controller */
> +	dwsmmio->rstc = devm_reset_control_get_optional_exclusive(&pdev->dev, "spi");
> +	if (IS_ERR(dwsmmio->rstc)) {

> +		if (PTR_ERR(dwsmmio->rstc) == -EPROBE_DEFER)
> +			return PTR_ERR(dwsmmio->rstc);

If it's other type of errors when reset control, we ignore them...

Why?!

> +	}

-- 
With Best Regards,
Andy Shevchenko



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

end of thread, other threads:[~2020-05-26 15:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-26 15:12 [PATCHv2 1/2] spi: dw: add reset control Dinh Nguyen
2020-05-26 15:12 ` [PATCHv2 2/2] dt-bindings: snps,dw-apb-ssi: add optional reset property Dinh Nguyen
2020-05-26 15:21 ` [PATCHv2 1/2] spi: dw: add reset control Andy Shevchenko

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).