linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] spi: bcm63xx: add BMIPS support
@ 2020-06-15  8:03 Álvaro Fernández Rojas
  2020-06-15  8:03 ` [PATCH 1/4] spi: bcm63xx-spi: add reset support Álvaro Fernández Rojas
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Álvaro Fernández Rojas @ 2020-06-15  8:03 UTC (permalink / raw)
  To: broonie, f.fainelli, bcm-kernel-feedback-list, p.zabel,
	linux-spi, linux-kernel, linux-arm-kernel
  Cc: Álvaro Fernández Rojas

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

-- 
2.27.0


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

* [PATCH 1/4] spi: bcm63xx-spi: add reset support
  2020-06-15  8:03 [PATCH 0/4] spi: bcm63xx: add BMIPS support Álvaro Fernández Rojas
@ 2020-06-15  8:03 ` Álvaro Fernández Rojas
  2020-06-15  8:12   ` Philipp Zabel
  2020-06-15  8:03 ` [PATCH 2/4] spi: bcm63xx-spi: allow building for BMIPS Álvaro Fernández Rojas
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 16+ messages in thread
From: Álvaro Fernández Rojas @ 2020-06-15  8:03 UTC (permalink / raw)
  To: broonie, f.fainelli, bcm-kernel-feedback-list, p.zabel,
	linux-spi, linux-kernel, linux-arm-kernel
  Cc: Á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.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 drivers/spi/spi-bcm63xx.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c
index 0f1b10a4ef0c..8ab04affaf7b 100644
--- a/drivers/spi/spi-bcm63xx.c
+++ b/drivers/spi/spi-bcm63xx.c
@@ -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 */
-- 
2.27.0


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

* [PATCH 2/4] spi: bcm63xx-spi: allow building for BMIPS
  2020-06-15  8:03 [PATCH 0/4] spi: bcm63xx: add BMIPS support Álvaro Fernández Rojas
  2020-06-15  8:03 ` [PATCH 1/4] spi: bcm63xx-spi: add reset support Álvaro Fernández Rojas
@ 2020-06-15  8:03 ` Álvaro Fernández Rojas
  2020-06-15  8:03 ` [PATCH 3/4] spi: bcm63xx-hsspi: add reset support Álvaro Fernández Rojas
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 16+ messages in thread
From: Álvaro Fernández Rojas @ 2020-06-15  8:03 UTC (permalink / raw)
  To: broonie, f.fainelli, bcm-kernel-feedback-list, p.zabel,
	linux-spi, linux-kernel, linux-arm-kernel
  Cc: Álvaro Fernández Rojas

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

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 drivers/spi/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 8f1f8fca79e3..a9896e388355 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -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.
 
-- 
2.27.0


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

* [PATCH 3/4] spi: bcm63xx-hsspi: add reset support
  2020-06-15  8:03 [PATCH 0/4] spi: bcm63xx: add BMIPS support Álvaro Fernández Rojas
  2020-06-15  8:03 ` [PATCH 1/4] spi: bcm63xx-spi: add reset support Álvaro Fernández Rojas
  2020-06-15  8:03 ` [PATCH 2/4] spi: bcm63xx-spi: allow building for BMIPS Álvaro Fernández Rojas
@ 2020-06-15  8:03 ` Álvaro Fernández Rojas
  2020-06-15  8:03 ` [PATCH 4/4] spi: bcm63xx-hsspi: allow building for BMIPS Álvaro Fernández Rojas
  2020-06-15  9:09 ` [PATCH v2 0/4] spi: bcm63xx: add BMIPS support Álvaro Fernández Rojas
  4 siblings, 0 replies; 16+ messages in thread
From: Álvaro Fernández Rojas @ 2020-06-15  8:03 UTC (permalink / raw)
  To: broonie, f.fainelli, bcm-kernel-feedback-list, p.zabel,
	linux-spi, linux-kernel, linux-arm-kernel
  Cc: Á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.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 drivers/spi/spi-bcm63xx-hsspi.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/spi/spi-bcm63xx-hsspi.c b/drivers/spi/spi-bcm63xx-hsspi.c
index 6c235306c0e4..a20a0b88c23a 100644
--- a/drivers/spi/spi-bcm63xx-hsspi.c
+++ b/drivers/spi/spi-bcm63xx-hsspi.c
@@ -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");
-- 
2.27.0


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

* [PATCH 4/4] spi: bcm63xx-hsspi: allow building for BMIPS
  2020-06-15  8:03 [PATCH 0/4] spi: bcm63xx: add BMIPS support Álvaro Fernández Rojas
                   ` (2 preceding siblings ...)
  2020-06-15  8:03 ` [PATCH 3/4] spi: bcm63xx-hsspi: add reset support Álvaro Fernández Rojas
@ 2020-06-15  8:03 ` Álvaro Fernández Rojas
  2020-06-15  9:09 ` [PATCH v2 0/4] spi: bcm63xx: add BMIPS support Álvaro Fernández Rojas
  4 siblings, 0 replies; 16+ messages in thread
From: Álvaro Fernández Rojas @ 2020-06-15  8:03 UTC (permalink / raw)
  To: broonie, f.fainelli, bcm-kernel-feedback-list, p.zabel,
	linux-spi, linux-kernel, linux-arm-kernel
  Cc: Álvaro Fernández Rojas

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

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 drivers/spi/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index a9896e388355..500774fe1351 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -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.
-- 
2.27.0


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

* Re: [PATCH 1/4] spi: bcm63xx-spi: add reset support
  2020-06-15  8:03 ` [PATCH 1/4] spi: bcm63xx-spi: add reset support Álvaro Fernández Rojas
@ 2020-06-15  8:12   ` Philipp Zabel
  0 siblings, 0 replies; 16+ messages in thread
From: Philipp Zabel @ 2020-06-15  8:12 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, broonie, f.fainelli,
	bcm-kernel-feedback-list, linux-spi, linux-kernel,
	linux-arm-kernel

Hi Álvaro,

On Mon, 2020-06-15 at 10:03 +0200, Álvaro Fernández Rojas wrote:
> bcm63xx arch resets the SPI controller at early boot. However, bmips arch
> needs to perform a reset when probing the driver.
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> ---
>  drivers/spi/spi-bcm63xx.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c
> index 0f1b10a4ef0c..8ab04affaf7b 100644
> --- a/drivers/spi/spi-bcm63xx.c
> +++ b/drivers/spi/spi-bcm63xx.c
> @@ -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);

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

Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>

regards
Philipp

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

* [PATCH v2 0/4] spi: bcm63xx: add BMIPS support
  2020-06-15  8:03 [PATCH 0/4] spi: bcm63xx: add BMIPS support Álvaro Fernández Rojas
                   ` (3 preceding siblings ...)
  2020-06-15  8:03 ` [PATCH 4/4] spi: bcm63xx-hsspi: allow building for BMIPS Álvaro Fernández Rojas
@ 2020-06-15  9:09 ` Álvaro Fernández Rojas
  2020-06-15  9:09   ` [PATCH v2 1/4] spi: bcm63xx-spi: add reset support Álvaro Fernández Rojas
                     ` (5 more replies)
  4 siblings, 6 replies; 16+ messages in thread
From: Álvaro Fernández Rojas @ 2020-06-15  9:09 UTC (permalink / raw)
  To: broonie, f.fainelli, bcm-kernel-feedback-list, p.zabel,
	linux-spi, linux-kernel, linux-arm-kernel
  Cc: Á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(-)

-- 
2.27.0


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

* [PATCH v2 1/4] spi: bcm63xx-spi: add reset support
  2020-06-15  9:09 ` [PATCH v2 0/4] spi: bcm63xx: add BMIPS support Álvaro Fernández Rojas
@ 2020-06-15  9:09   ` Álvaro Fernández Rojas
  2020-06-15 16:26     ` Florian Fainelli
  2020-06-15  9:09   ` [PATCH v2 2/4] spi: bcm63xx-spi: allow building for BMIPS Álvaro Fernández Rojas
                     ` (4 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Álvaro Fernández Rojas @ 2020-06-15  9:09 UTC (permalink / raw)
  To: broonie, f.fainelli, bcm-kernel-feedback-list, p.zabel,
	linux-spi, linux-kernel, linux-arm-kernel
  Cc: Á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.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 v2: use devm_reset_control_get_exclusive

 drivers/spi/spi-bcm63xx.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c
index 0f1b10a4ef0c..8ab04affaf7b 100644
--- a/drivers/spi/spi-bcm63xx.c
+++ b/drivers/spi/spi-bcm63xx.c
@@ -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 */
-- 
2.27.0


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

* [PATCH v2 2/4] spi: bcm63xx-spi: allow building for BMIPS
  2020-06-15  9:09 ` [PATCH v2 0/4] spi: bcm63xx: add BMIPS support Álvaro Fernández Rojas
  2020-06-15  9:09   ` [PATCH v2 1/4] spi: bcm63xx-spi: add reset support Álvaro Fernández Rojas
@ 2020-06-15  9:09   ` Álvaro Fernández Rojas
  2020-06-15 16:26     ` Florian Fainelli
  2020-06-15  9:09   ` [PATCH v2 3/4] spi: bcm63xx-hsspi: add reset support Álvaro Fernández Rojas
                     ` (3 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Álvaro Fernández Rojas @ 2020-06-15  9:09 UTC (permalink / raw)
  To: broonie, f.fainelli, bcm-kernel-feedback-list, p.zabel,
	linux-spi, linux-kernel, linux-arm-kernel
  Cc: Álvaro Fernández Rojas

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

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v2: no changes

 drivers/spi/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 8f1f8fca79e3..a9896e388355 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -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.
 
-- 
2.27.0


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

* [PATCH v2 3/4] spi: bcm63xx-hsspi: add reset support
  2020-06-15  9:09 ` [PATCH v2 0/4] spi: bcm63xx: add BMIPS support Álvaro Fernández Rojas
  2020-06-15  9:09   ` [PATCH v2 1/4] spi: bcm63xx-spi: add reset support Álvaro Fernández Rojas
  2020-06-15  9:09   ` [PATCH v2 2/4] spi: bcm63xx-spi: allow building for BMIPS Álvaro Fernández Rojas
@ 2020-06-15  9:09   ` Álvaro Fernández Rojas
  2020-06-15  9:09   ` [PATCH v2 4/4] spi: bcm63xx-hsspi: allow building for BMIPS Álvaro Fernández Rojas
                     ` (2 subsequent siblings)
  5 siblings, 0 replies; 16+ messages in thread
From: Álvaro Fernández Rojas @ 2020-06-15  9:09 UTC (permalink / raw)
  To: broonie, f.fainelli, bcm-kernel-feedback-list, p.zabel,
	linux-spi, linux-kernel, linux-arm-kernel
  Cc: Á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.

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
---
 v2: use devm_reset_control_get_exclusive

 drivers/spi/spi-bcm63xx-hsspi.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/spi/spi-bcm63xx-hsspi.c b/drivers/spi/spi-bcm63xx-hsspi.c
index 6c235306c0e4..a20a0b88c23a 100644
--- a/drivers/spi/spi-bcm63xx-hsspi.c
+++ b/drivers/spi/spi-bcm63xx-hsspi.c
@@ -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");
-- 
2.27.0


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

* [PATCH v2 4/4] spi: bcm63xx-hsspi: allow building for BMIPS
  2020-06-15  9:09 ` [PATCH v2 0/4] spi: bcm63xx: add BMIPS support Álvaro Fernández Rojas
                     ` (2 preceding siblings ...)
  2020-06-15  9:09   ` [PATCH v2 3/4] spi: bcm63xx-hsspi: add reset support Álvaro Fernández Rojas
@ 2020-06-15  9:09   ` Álvaro Fernández Rojas
  2020-06-15 16:26     ` Florian Fainelli
  2020-06-15 11:26   ` [PATCH v2 0/4] spi: bcm63xx: add BMIPS support Mark Brown
  2020-06-15 16:27   ` Florian Fainelli
  5 siblings, 1 reply; 16+ messages in thread
From: Álvaro Fernández Rojas @ 2020-06-15  9:09 UTC (permalink / raw)
  To: broonie, f.fainelli, bcm-kernel-feedback-list, p.zabel,
	linux-spi, linux-kernel, linux-arm-kernel
  Cc: Álvaro Fernández Rojas

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

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
---
 v2: no changes

 drivers/spi/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index a9896e388355..500774fe1351 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -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.
-- 
2.27.0


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

* Re: [PATCH v2 0/4] spi: bcm63xx: add BMIPS support
  2020-06-15  9:09 ` [PATCH v2 0/4] spi: bcm63xx: add BMIPS support Álvaro Fernández Rojas
                     ` (3 preceding siblings ...)
  2020-06-15  9:09   ` [PATCH v2 4/4] spi: bcm63xx-hsspi: allow building for BMIPS Álvaro Fernández Rojas
@ 2020-06-15 11:26   ` Mark Brown
  2020-06-15 16:27   ` Florian Fainelli
  5 siblings, 0 replies; 16+ messages in thread
From: Mark Brown @ 2020-06-15 11:26 UTC (permalink / raw)
  To: Álvaro Fernández Rojas
  Cc: f.fainelli, bcm-kernel-feedback-list, p.zabel, linux-spi,
	linux-kernel, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 364 bytes --]

On Mon, Jun 15, 2020 at 11:09:39AM +0200, Álvaro Fernández Rojas wrote:
> 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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* Re: [PATCH v2 1/4] spi: bcm63xx-spi: add reset support
  2020-06-15  9:09   ` [PATCH v2 1/4] spi: bcm63xx-spi: add reset support Álvaro Fernández Rojas
@ 2020-06-15 16:26     ` Florian Fainelli
  0 siblings, 0 replies; 16+ messages in thread
From: Florian Fainelli @ 2020-06-15 16:26 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, broonie, f.fainelli,
	bcm-kernel-feedback-list, p.zabel, linux-spi, linux-kernel,
	linux-arm-kernel



On 6/15/2020 2:09 AM, Álvaro Fernández Rojas wrote:
> bcm63xx arch resets the SPI controller at early boot. However, bmips arch
> needs to perform a reset when probing the driver.
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
> Reviewed-by: Philipp Zabel <p.zabel@pengutronix.de>
> ---
>  v2: use devm_reset_control_get_exclusive
> 
>  drivers/spi/spi-bcm63xx.c | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/drivers/spi/spi-bcm63xx.c b/drivers/spi/spi-bcm63xx.c
> index 0f1b10a4ef0c..8ab04affaf7b 100644
> --- a/drivers/spi/spi-bcm63xx.c
> +++ b/drivers/spi/spi-bcm63xx.c
> @@ -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;
> +	}

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

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

* Re: [PATCH v2 2/4] spi: bcm63xx-spi: allow building for BMIPS
  2020-06-15  9:09   ` [PATCH v2 2/4] spi: bcm63xx-spi: allow building for BMIPS Álvaro Fernández Rojas
@ 2020-06-15 16:26     ` Florian Fainelli
  0 siblings, 0 replies; 16+ messages in thread
From: Florian Fainelli @ 2020-06-15 16:26 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, broonie, f.fainelli,
	bcm-kernel-feedback-list, p.zabel, linux-spi, linux-kernel,
	linux-arm-kernel



On 6/15/2020 2:09 AM, Álvaro Fernández Rojas wrote:
> bcm63xx-spi controller is present on several BMIPS SoCs (BCM6358, BCM6362,
> BCM6368 and BCM63268).
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH v2 4/4] spi: bcm63xx-hsspi: allow building for BMIPS
  2020-06-15  9:09   ` [PATCH v2 4/4] spi: bcm63xx-hsspi: allow building for BMIPS Álvaro Fernández Rojas
@ 2020-06-15 16:26     ` Florian Fainelli
  0 siblings, 0 replies; 16+ messages in thread
From: Florian Fainelli @ 2020-06-15 16:26 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, broonie, f.fainelli,
	bcm-kernel-feedback-list, p.zabel, linux-spi, linux-kernel,
	linux-arm-kernel



On 6/15/2020 2:09 AM, Álvaro Fernández Rojas wrote:
> bcm63xx-hsspi controller is present on several BMIPS SoCs (BCM6318, BCM6328,
> BCM6362 and BCM63268).
> 
> Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>

Acked-by: Florian Fainelli <f.fainelli@gmail.com>
-- 
Florian

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

* Re: [PATCH v2 0/4] spi: bcm63xx: add BMIPS support
  2020-06-15  9:09 ` [PATCH v2 0/4] spi: bcm63xx: add BMIPS support Álvaro Fernández Rojas
                     ` (4 preceding siblings ...)
  2020-06-15 11:26   ` [PATCH v2 0/4] spi: bcm63xx: add BMIPS support Mark Brown
@ 2020-06-15 16:27   ` Florian Fainelli
  5 siblings, 0 replies; 16+ messages in thread
From: Florian Fainelli @ 2020-06-15 16:27 UTC (permalink / raw)
  To: Álvaro Fernández Rojas, broonie, f.fainelli,
	bcm-kernel-feedback-list, p.zabel, linux-spi, linux-kernel,
	linux-arm-kernel

Hi Alvaro,

On 6/15/2020 2:09 AM, Álvaro Fernández Rojas wrote:
> 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!
-- 
Florian

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

end of thread, other threads:[~2020-06-15 16:27 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-15  8:03 [PATCH 0/4] spi: bcm63xx: add BMIPS support Álvaro Fernández Rojas
2020-06-15  8:03 ` [PATCH 1/4] spi: bcm63xx-spi: add reset support Álvaro Fernández Rojas
2020-06-15  8:12   ` Philipp Zabel
2020-06-15  8:03 ` [PATCH 2/4] spi: bcm63xx-spi: allow building for BMIPS Álvaro Fernández Rojas
2020-06-15  8:03 ` [PATCH 3/4] spi: bcm63xx-hsspi: add reset support Álvaro Fernández Rojas
2020-06-15  8:03 ` [PATCH 4/4] spi: bcm63xx-hsspi: allow building for BMIPS Álvaro Fernández Rojas
2020-06-15  9:09 ` [PATCH v2 0/4] spi: bcm63xx: add BMIPS support Álvaro Fernández Rojas
2020-06-15  9:09   ` [PATCH v2 1/4] spi: bcm63xx-spi: add reset support Álvaro Fernández Rojas
2020-06-15 16:26     ` Florian Fainelli
2020-06-15  9:09   ` [PATCH v2 2/4] spi: bcm63xx-spi: allow building for BMIPS Álvaro Fernández Rojas
2020-06-15 16:26     ` Florian Fainelli
2020-06-15  9:09   ` [PATCH v2 3/4] spi: bcm63xx-hsspi: add reset support Álvaro Fernández Rojas
2020-06-15  9:09   ` [PATCH v2 4/4] spi: bcm63xx-hsspi: allow building for BMIPS Álvaro Fernández Rojas
2020-06-15 16:26     ` Florian Fainelli
2020-06-15 11:26   ` [PATCH v2 0/4] spi: bcm63xx: add BMIPS support Mark Brown
2020-06-15 16:27   ` Florian Fainelli

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