Skip to contentSkip to conversation

spi: bcm63xx: add BMIPS support

PATCH Superseded Álvaro Fernández Rojas 4 participants 17 messages Jun 15, 2020

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover spi: bcm63xx: add BMIPS support

BCM63xx SPI and HSSPI controller are present on several BMIPS SoCs (BCM6318, BCM6328, BCM6358, BCM6362, BCM6368 and BCM63268).

Álvaro Fernández Rojas (4):
spi: bcm63xx-spi: add reset support
spi: bcm63xx-spi: allow building for BMIPS
spi: bcm63xx-hsspi: add reset support
spi: bcm63xx-hsspi: allow building for BMIPS

 drivers/spi/Kconfig             |  4 ++--
 drivers/spi/spi-bcm63xx-hsspi.c | 17 +++++++++++++++++
 drivers/spi/spi-bcm63xx.c       | 17 +++++++++++++++++
 3 files changed, 36 insertions(+), 2 deletions(-)
Signature · 1 line
2.27.0
#1 lore raw

PATCH 1/4 spi: bcm63xx-spi: add reset support

bcm63xx arch resets the SPI controller at early boot. However, bmips arch needs to perform a reset when probing the driver.

---
 drivers/spi/spi-bcm63xx.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/spi/spi-bcm63xx.c +17 -0
index 0f1b10a4ef0c..8ab04affaf7b 100644
@@ -18,6 +18,7 @@
 #include <linux/err.h>
 #include <linux/pm_runtime.h>
 #include <linux/of.h>
+#include <linux/reset.h>
 
 /* BCM 6338/6348 SPI core */
 #define SPI_6348_RSET_SIZE		64
@@ -493,6 +494,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 	struct bcm63xx_spi *bs;
 	int ret;
 	u32 num_cs = BCM63XX_SPI_MAX_CS;
+	struct reset_control *reset;
 
 	if (dev->of_node) {
 		const struct of_device_id *match;
@@ -529,6 +531,15 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 		return PTR_ERR(clk);
 	}
 
+	reset = devm_reset_control_get(dev, NULL);
+	if (IS_ERR(reset)) {
+		ret = PTR_ERR(reset);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev,
+				"failed to get reset controller: %d\n", ret);
+		return ret;
+	}
+
 	master = spi_alloc_master(dev, sizeof(*bs));
 	if (!master) {
 		dev_err(dev, "out of memory\n");
@@ -579,6 +590,12 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 	if (ret)
 		goto out_err;
 
+	ret = reset_control_reset(reset);
+	if (ret) {
+		dev_err(dev, "unable to reset device: %d\n", ret);
+		goto out_clk_disable;
+	}
+
 	bcm_spi_writeb(bs, SPI_INTR_CLEAR_ALL, SPI_INT_STATUS);
 
 	/* register and we are done */
Signature · 1 line
2.27.0
Reviewed-by on v1 1/4
#2 lore raw

Re: [PATCH 1/4] spi: bcm63xx-spi: add reset support

Hi Álvaro,

Quoted 29 lines · Álvaro Fernández Rojas

bcm63xx arch resets the SPI controller at early boot. However, bmips arch needs to perform a reset when probing the driver.

---
 drivers/spi/spi-bcm63xx.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/spi/spi-bcm63xx.c +2 -0
index 0f1b10a4ef0c..8ab04affaf7b 100644
@@ -18,6 +18,7 @@
 #include <linux/err.h>
 #include <linux/pm_runtime.h>
 #include <linux/of.h>
+#include <linux/reset.h>
 
 /* BCM 6338/6348 SPI core */
 #define SPI_6348_RSET_SIZE		64
@@ -493,6 +494,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 	struct bcm63xx_spi *bs;
 	int ret;
 	u32 num_cs = BCM63XX_SPI_MAX_CS;
+	struct reset_control *reset;
 
 	if (dev->of_node) {
 		const struct of_device_id *match;

drivers/spi/spi-bcm63xx.c static int bcm63xx_spi_probe(struct platform_device *pdev) · line 534

Quoted 4 lines
drivers/spi/spi-bcm63xx.c +1 -0
@@ -529,6 +531,15 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 		return PTR_ERR(clk);
 	}
 
+	reset = devm_reset_control_get(dev, NULL);

Please use devm_reset_control_get_exclusive(), same for patch 3. With that changed,

regards
Philipp

#3 lore raw

PATCH 2/4 spi: bcm63xx-spi: allow building for BMIPS

In reply to Álvaro Fernández Rojas

bcm63xx-spi controller is present on several BMIPS SoCs (BCM6358, BCM6362, BCM6368 and BCM63268).

---
 drivers/spi/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/Kconfig +1 -1
index 8f1f8fca79e3..a9896e388355 100644
@@ -149,7 +149,7 @@ config SPI_BCM2835AUX
 
 config SPI_BCM63XX
 	tristate "Broadcom BCM63xx SPI controller"
-	depends on BCM63XX || COMPILE_TEST
+	depends on BCM63XX || BMIPS_GENERIC || COMPILE_TEST
 	help
 	  Enable support for the SPI controller on the Broadcom BCM63xx SoCs.
 
Signature · 1 line
2.27.0
#4 lore raw

PATCH 3/4 spi: bcm63xx-hsspi: add reset support

In reply to Álvaro Fernández Rojas

bcm63xx arch resets the HSSPI controller at early boot. However, bmips arch needs to perform a reset when probing the driver.

---
 drivers/spi/spi-bcm63xx-hsspi.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/spi/spi-bcm63xx-hsspi.c +17 -0
index 6c235306c0e4..a20a0b88c23a 100644
@@ -20,6 +20,7 @@
 #include <linux/spi/spi.h>
 #include <linux/mutex.h>
 #include <linux/of.h>
+#include <linux/reset.h>
 
 #define HSSPI_GLOBAL_CTRL_REG			0x0
 #define GLOBAL_CTRL_CS_POLARITY_SHIFT		0
@@ -334,6 +335,7 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
 	struct clk *clk, *pll_clk = NULL;
 	int irq, ret;
 	u32 reg, rate, num_cs = HSSPI_SPI_MAX_CS;
+	struct reset_control *reset;
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
@@ -348,10 +350,25 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
+	reset = devm_reset_control_get(dev, NULL);
+	if (IS_ERR(reset)) {
+		ret = PTR_ERR(reset);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev,
+				"failed to get reset controller: %d\n", ret);
+		return ret;
+	}
+
 	ret = clk_prepare_enable(clk);
 	if (ret)
 		return ret;
 
+	ret = reset_control_reset(reset);
+	if (ret) {
+		dev_err(dev, "unable to reset device: %d\n", ret);
+		goto out_disable_clk;
+	}
+
 	rate = clk_get_rate(clk);
 	if (!rate) {
 		pll_clk = devm_clk_get(dev, "pll");
Signature · 1 line
2.27.0
#5 lore raw

PATCH 4/4 spi: bcm63xx-hsspi: allow building for BMIPS

In reply to Álvaro Fernández Rojas

bcm63xx-hsspi controller is present on several BMIPS SoCs (BCM6318, BCM6328, BCM6362 and BCM63268).

---
 drivers/spi/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/Kconfig +1 -1
index a9896e388355..500774fe1351 100644
@@ -155,7 +155,7 @@ config SPI_BCM63XX
 
 config SPI_BCM63XX_HSSPI
 	tristate "Broadcom BCM63XX HS SPI controller driver"
-	depends on BCM63XX || ARCH_BCM_63XX || COMPILE_TEST
+	depends on BCM63XX || BMIPS_GENERIC || ARCH_BCM_63XX || COMPILE_TEST
 	help
 	  This enables support for the High Speed SPI controller present on
 	  newer Broadcom BCM63XX SoCs.
Signature · 1 line
2.27.0
#6 lore raw

v2 cover spi: bcm63xx: add BMIPS support

In reply to Álvaro Fernández Rojas

BCM63xx SPI and HSSPI controller are present on several BMIPS SoCs (BCM6318, BCM6328, BCM6358, BCM6362, BCM6368 and BCM63268).

v2: use devm_reset_control_get_exclusive

Álvaro Fernández Rojas (4):
spi: bcm63xx-spi: add reset support
spi: bcm63xx-spi: allow building for BMIPS
spi: bcm63xx-hsspi: add reset support
spi: bcm63xx-hsspi: allow building for BMIPS

 drivers/spi/Kconfig             |  4 ++--
 drivers/spi/spi-bcm63xx-hsspi.c | 17 +++++++++++++++++
 drivers/spi/spi-bcm63xx.c       | 17 +++++++++++++++++
 3 files changed, 36 insertions(+), 2 deletions(-)
Signature · 1 line
2.27.0
#7 lore raw

PATCH v2 1/4 spi: bcm63xx-spi: add reset support

bcm63xx arch resets the SPI controller at early boot. However, bmips arch needs to perform a reset when probing the driver.

---
v2: use devm_reset_control_get_exclusive

 drivers/spi/spi-bcm63xx.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/spi/spi-bcm63xx.c +17 -0
index 0f1b10a4ef0c..8ab04affaf7b 100644
@@ -18,6 +18,7 @@
 #include <linux/err.h>
 #include <linux/pm_runtime.h>
 #include <linux/of.h>
+#include <linux/reset.h>
 
 /* BCM 6338/6348 SPI core */
 #define SPI_6348_RSET_SIZE		64
@@ -493,6 +494,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 	struct bcm63xx_spi *bs;
 	int ret;
 	u32 num_cs = BCM63XX_SPI_MAX_CS;
+	struct reset_control *reset;
 
 	if (dev->of_node) {
 		const struct of_device_id *match;
@@ -529,6 +531,15 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 		return PTR_ERR(clk);
 	}
 
+	reset = devm_reset_control_get_exclusive(dev, NULL);
+	if (IS_ERR(reset)) {
+		ret = PTR_ERR(reset);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev,
+				"failed to get reset controller: %d\n", ret);
+		return ret;
+	}
+
 	master = spi_alloc_master(dev, sizeof(*bs));
 	if (!master) {
 		dev_err(dev, "out of memory\n");
@@ -579,6 +590,12 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 	if (ret)
 		goto out_err;
 
+	ret = reset_control_reset(reset);
+	if (ret) {
+		dev_err(dev, "unable to reset device: %d\n", ret);
+		goto out_clk_disable;
+	}
+
 	bcm_spi_writeb(bs, SPI_INTR_CLEAR_ALL, SPI_INT_STATUS);
 
 	/* register and we are done */
Signature · 1 line
2.27.0
#8 lore raw

Re: [PATCH v2 1/4] spi: bcm63xx-spi: add reset support

Quoted 33 lines · Álvaro Fernández Rojas

bcm63xx arch resets the SPI controller at early boot. However, bmips arch needs to perform a reset when probing the driver.

---
v2: use devm_reset_control_get_exclusive

 drivers/spi/spi-bcm63xx.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/spi/spi-bcm63xx.c +2 -0
index 0f1b10a4ef0c..8ab04affaf7b 100644
@@ -18,6 +18,7 @@
 #include <linux/err.h>
 #include <linux/pm_runtime.h>
 #include <linux/of.h>
+#include <linux/reset.h>
 
 /* BCM 6338/6348 SPI core */
 #define SPI_6348_RSET_SIZE		64
@@ -493,6 +494,7 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 	struct bcm63xx_spi *bs;
 	int ret;
 	u32 num_cs = BCM63XX_SPI_MAX_CS;
+	struct reset_control *reset;
 
 	if (dev->of_node) {
 		const struct of_device_id *match;
@@ -529,6 +531,15 @@ static int bcm63xx_spi_probe(struct platform_device *pdev)
 		return PTR_ERR(clk);

drivers/spi/spi-bcm63xx.c static int bcm63xx_spi_probe(struct platform_device *pdev) · line 541

Quoted 10 lines
drivers/spi/spi-bcm63xx.c +8 -0
 	}
 
+	reset = devm_reset_control_get_exclusive(dev, NULL);
+	if (IS_ERR(reset)) {
+		ret = PTR_ERR(reset);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev,
+				"failed to get reset controller: %d\n", ret);
+		return ret;
+	}

This should be devm_reset_control_get_exclusive_optional() for a number of reasons the first one being the most important as it reflects reality of the HW:

- not all BCM63xx platforms have a dedicated reset line for the SPI controller (like the ARM-based SoCs)

- until you also update all Device Tree sources to have a 'resets' property in their SPI controller node, this is likely going to be failing

This also applies to patch 3.

Signature · 1 line
Florian
#9 lore raw

PATCH v2 2/4 spi: bcm63xx-spi: allow building for BMIPS

In reply to Álvaro Fernández Rojas

bcm63xx-spi controller is present on several BMIPS SoCs (BCM6358, BCM6362, BCM6368 and BCM63268).

---
v2: no changes

 drivers/spi/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/Kconfig +1 -1
index 8f1f8fca79e3..a9896e388355 100644
@@ -149,7 +149,7 @@ config SPI_BCM2835AUX
 
 config SPI_BCM63XX
 	tristate "Broadcom BCM63xx SPI controller"
-	depends on BCM63XX || COMPILE_TEST
+	depends on BCM63XX || BMIPS_GENERIC || COMPILE_TEST
 	help
 	  Enable support for the SPI controller on the Broadcom BCM63xx SoCs.
 
Signature · 1 line
2.27.0
#11 lore raw

PATCH v2 3/4 spi: bcm63xx-hsspi: add reset support

In reply to Álvaro Fernández Rojas

bcm63xx arch resets the HSSPI controller at early boot. However, bmips arch needs to perform a reset when probing the driver.

---
v2: use devm_reset_control_get_exclusive

 drivers/spi/spi-bcm63xx-hsspi.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
drivers/spi/spi-bcm63xx-hsspi.c +17 -0
index 6c235306c0e4..a20a0b88c23a 100644
@@ -20,6 +20,7 @@
 #include <linux/spi/spi.h>
 #include <linux/mutex.h>
 #include <linux/of.h>
+#include <linux/reset.h>
 
 #define HSSPI_GLOBAL_CTRL_REG			0x0
 #define GLOBAL_CTRL_CS_POLARITY_SHIFT		0
@@ -334,6 +335,7 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
 	struct clk *clk, *pll_clk = NULL;
 	int irq, ret;
 	u32 reg, rate, num_cs = HSSPI_SPI_MAX_CS;
+	struct reset_control *reset;
 
 	irq = platform_get_irq(pdev, 0);
 	if (irq < 0)
@@ -348,10 +350,25 @@ static int bcm63xx_hsspi_probe(struct platform_device *pdev)
 	if (IS_ERR(clk))
 		return PTR_ERR(clk);
 
+	reset = devm_reset_control_get_exclusive(dev, NULL);
+	if (IS_ERR(reset)) {
+		ret = PTR_ERR(reset);
+		if (ret != -EPROBE_DEFER)
+			dev_err(dev,
+				"failed to get reset controller: %d\n", ret);
+		return ret;
+	}
+
 	ret = clk_prepare_enable(clk);
 	if (ret)
 		return ret;
 
+	ret = reset_control_reset(reset);
+	if (ret) {
+		dev_err(dev, "unable to reset device: %d\n", ret);
+		goto out_disable_clk;
+	}
+
 	rate = clk_get_rate(clk);
 	if (!rate) {
 		pll_clk = devm_clk_get(dev, "pll");
Signature · 1 line
2.27.0
#12 lore raw

PATCH v2 4/4 spi: bcm63xx-hsspi: allow building for BMIPS

In reply to Álvaro Fernández Rojas

bcm63xx-hsspi controller is present on several BMIPS SoCs (BCM6318, BCM6328, BCM6362 and BCM63268).

---
v2: no changes

 drivers/spi/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/Kconfig +1 -1
index a9896e388355..500774fe1351 100644
@@ -155,7 +155,7 @@ config SPI_BCM63XX
 
 config SPI_BCM63XX_HSSPI
 	tristate "Broadcom BCM63XX HS SPI controller driver"
-	depends on BCM63XX || ARCH_BCM_63XX || COMPILE_TEST
+	depends on BCM63XX || BMIPS_GENERIC || ARCH_BCM_63XX || COMPILE_TEST
 	help
 	  This enables support for the High Speed SPI controller present on
 	  newer Broadcom BCM63XX SoCs.
Signature · 1 line
2.27.0
maintainer
#14 lore raw
In reply to Álvaro Fernández Rojas
Quoted 2 lines · Álvaro Fernández Rojas

BCM63xx SPI and HSSPI controller are present on several BMIPS SoCs (BCM6318, BCM6328, BCM6358, BCM6362, BCM6368 and BCM63268).

Please don't send new versions of patches in reply to old ones, it makes it hard to keep track of what's going on and can bury things back in a mailbox.

#15 lore raw
In reply to Álvaro Fernández Rojas

Hi Alvaro,

Quoted 4 lines · Álvaro Fernández Rojas

BCM63xx SPI and HSSPI controller are present on several BMIPS SoCs (BCM6318, BCM6328, BCM6358, BCM6362, BCM6368 and BCM63268).

v2: use devm_reset_control_get_exclusive

We would also need to write a binding document for these two controllers, as they appear to be missing, and this would document the reset property.

I also believe that you should be making this property optional since not all SoCs do have a dedicated reset controller line for SPI/HSSPI (if at all).

Thank you!

Signature · 1 line
Florian
maintainer
#16 lore raw
In reply to Álvaro Fernández Rojas
Quoted 5 lines · Álvaro Fernández Rojas

BCM63xx SPI and HSSPI controller are present on several BMIPS SoCs (BCM6318, BCM6328, BCM6358, BCM6362, BCM6368 and BCM63268).

v2: use devm_reset_control_get_exclusive

Quoted 7 lines

Álvaro Fernández Rojas (4):
spi: bcm63xx-spi: add reset support
spi: bcm63xx-spi: allow building for BMIPS
spi: bcm63xx-hsspi: add reset support
spi: bcm63xx-hsspi: allow building for BMIPS

[...]

Applied to

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

Thanks!

[1/4] spi: bcm63xx-spi: add reset support
(no commit info)
[2/4] spi: bcm63xx-spi: allow building for BMIPS

      commit: 3a521450ff218ddac9b2c15fcd2bcadab56ff79d
[3/4] spi: bcm63xx-hsspi: add reset support
      (no commit info)
[4/4] spi: bcm63xx-hsspi: allow building for BMIPS
      commit: ba2137f3dbce5e530eba0c67d37a758b42eb26f8

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

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel