Skip to contentSkip to conversation

spi: dw: add reset control

PATCH In review Dinh Nguyen 2 participants 3 messages May 29, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v4 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.

---
v4: no change
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(+)
drivers/spi/spi-dw-mmio.c +13 -0
index 0894b4c09496..a1b87d4606ba 100644
@@ -19,6 +19,7 @@
 #include <linux/acpi.h>
 #include <linux/property.h>
 #include <linux/regmap.h>
+#include <linux/reset.h>
 
 #include "spi-dw.h"
 
@@ -29,6 +30,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
@@ -224,6 +226,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);
@@ -257,6 +267,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;
 }
 
@@ -268,6 +280,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;
 }
Signature · 1 line
2.17.1
#1 lore raw

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

Add optional reset property.

---
v4: rebased to linux-next 20200529
v3: no change
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(+)
Documentation/devicetree/bindings/spi/snps,dw-apb-ssi.txt +5 -0
index 020e3168ee41..0f21407a7ea3 100644
@@ -25,6 +25,9 @@ Optional properties:
   device.  Supported values are 2 or 4 (the default).
 - dmas : Phandle + identifiers of Tx and Rx DMA channels.
 - dma-names : Contains the names of the DMA channels. Must be "tx" and "rx".
+- 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.
 
@@ -40,5 +43,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
In reply to Dinh Nguyen
Quoted 2 lines · Dinh Nguyen

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

Applied to

https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/2] spi: dw: add reset control

      commit: 7830c0ef26cb73b653c2db2f3ca7be08f44fa046
[2/2] dt-bindings: snps,dw-apb-ssi: add optional reset property
      commit: 2604d48702fe14fb3e97701269dd5e66b392b904

All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying to this mail.

Thanks,
Mark