Skip to contentSkip to conversation

spi: dw: add reset control

PATCH Superseded Dinh Nguyen 3 participants 5 messages May 21, 2020

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 spi: dw: add reset control

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

---
 drivers/spi/spi-dw-mmio.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/spi/spi-dw-mmio.c +9 -0
index 384a3ab6dc2d..5c813e15ed89 100644
@@ -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
@@ -145,6 +147,10 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
 	if (!dwsmmio)
 		return -ENOMEM;
 
+	dwsmmio->rstc = devm_reset_control_get_exclusive(&pdev->dev, "spi");
+	if (!IS_ERR(dwsmmio->rstc))
+		reset_control_deassert(dwsmmio->rstc);
+
 	dws = &dwsmmio->dws;
 
 	/* Get basic io resource and map it */
@@ -220,6 +226,9 @@ static int dw_spi_mmio_remove(struct platform_device *pdev)
 	clk_disable_unprepare(dwsmmio->pclk);
 	clk_disable_unprepare(dwsmmio->clk);
 
+	if (dwsmmio->rstc)
+		reset_control_assert(dwsmmio->rstc);
+
 	return 0;
 }
 
Signature · 1 line
2.17.1
#1 lore raw

PATCH 2/2 dt-bindings: snps,dw-apb-ssi: add optional reset property

Add optional reset property.

---
 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt +2 -0
index 3ed08ee9feba..e01c557a9876 100644
@@ -37,5 +37,7 @@ Example:
 		num-cs = <2>;
 		cs-gpios = <&gpio0 13 0>,
 			   <&gpio0 14 0>;
+		resets = <&rst SPIM0_RST>;
+		reset-names = "spi";
 	};
 
Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH 2/2] dt-bindings: snps,dw-apb-ssi: add optional reset property

Quoted 12 lines · Dinh Nguyen

Add optional reset property.

---
 Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt +0 -0
index 3ed08ee9feba..e01c557a9876 100644

Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt Example: · line 41

Quoted 5 lines
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt +2 -0
@@ -37,5 +37,7 @@ Example:
 		num-cs = <2>;
 		cs-gpios = <&gpio0 13 0>,
 			   <&gpio0 14 0>;
+		resets = <&rst SPIM0_RST>;
+		reset-names = "spi";

This only adds the example, it doesn't add anything to the actual binding documentation.

maintainer
#3 lore raw
In reply to Dinh Nguyen
Quoted 5 lines · Dinh Nguyen

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

Is the From: correct here?

Also adding everyone else who's got patches in flight for this driver right now.

Quoted 25 lines
---
 drivers/spi/spi-dw-mmio.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/spi/spi-dw-mmio.c +2 -0
index 384a3ab6dc2d..5c813e15ed89 100644
@@ -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

drivers/spi/spi-dw-mmio.c static int dw_spi_mmio_probe(struct platform_device *pdev) · line 156

Quoted 10 lines
drivers/spi/spi-dw-mmio.c +4 -0
@@ -145,6 +147,10 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
 	if (!dwsmmio)
 		return -ENOMEM;
 
+	dwsmmio->rstc = devm_reset_control_get_exclusive(&pdev->dev, "spi");
+	if (!IS_ERR(dwsmmio->rstc))
+		reset_control_deassert(dwsmmio->rstc);
+
 	dws = &dwsmmio->dws;
 
 	/* Get basic io resource and map it */

Should we also undo the reset in error paths from probe()? It's not the end of the world if we don't but...

Quoted 13 lines
drivers/spi/spi-dw-mmio.c +3 -0
@@ -220,6 +226,9 @@ static int dw_spi_mmio_remove(struct platform_device *pdev)
 	clk_disable_unprepare(dwsmmio->pclk);
 	clk_disable_unprepare(dwsmmio->clk);
 
+	if (dwsmmio->rstc)
+		reset_control_assert(dwsmmio->rstc);
+
 	return 0;
 }
 
Signature · 1 line
2.17.1
#4 lore raw
Quoted 35 lines · Mark Brown
Quoted 5 lines · Dinh Nguyen

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

Is the From: correct here?

Also adding everyone else who's got patches in flight for this driver right now.

Quoted 23 lines
---
 drivers/spi/spi-dw-mmio.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/spi/spi-dw-mmio.c +2 -0
index 384a3ab6dc2d..5c813e15ed89 100644
@@ -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;
 };
 
Quoted 7 lines

drivers/spi/spi-dw-mmio.c static int dw_spi_mmio_probe(struct platform_device *pdev) · line 151

Quoted 7 lines
drivers/spi/spi-dw-mmio.c +1 -0
 #define MSCC_CPU_SYSTEM_CTRL_GENERAL_CTRL	0x24
@@ -145,6 +147,10 @@ static int dw_spi_mmio_probe(struct platform_device *pdev)
 	if (!dwsmmio)
 		return -ENOMEM;
 
 
+	dwsmmio->rstc = devm_reset_control_get_exclusive(&pdev->dev, "spi");

It would be better to use the optional-version of the reset getter:
devm_reset_control_get_optional_exclusive(), since for instance our DW APB SSI doesn't have a dedicated reset line.

Note also that you don't need to check the rstc for being NULL. It's null if the reset line is optional and isn't provided.

If we get to have this patch applied, then DT binding shall be also updated... Though we haven't got it reviewed yet.(

-Sergey

Quoted 23 lines
Quoted 6 lines
drivers/spi/spi-dw-mmio.c +3 -0
+	if (!IS_ERR(dwsmmio->rstc))
+		reset_control_deassert(dwsmmio->rstc);
+
 	dws = &dwsmmio->dws;
 

/* Get basic io resource and map it */

Should we also undo the reset in error paths from probe()? It's not the end of the world if we don't but...

Quoted 13 lines
drivers/spi/spi-dw-mmio.c +3 -0
@@ -220,6 +226,9 @@ static int dw_spi_mmio_remove(struct platform_device *pdev)
 	clk_disable_unprepare(dwsmmio->pclk);
 	clk_disable_unprepare(dwsmmio->clk);
 
+	if (dwsmmio->rstc)
+		reset_control_assert(dwsmmio->rstc);
+
 	return 0;
 }
 
Signature · 1 line
2.17.1