public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/4] net: dsa: Add Vitesse VSC73xx parallel mode
@ 2019-07-03 17:19 Pawel Dembicki
  2019-07-03 17:19 ` [PATCH v2 1/4] net: dsa: Change DT bindings for Vitesse VSC73xx switches Pawel Dembicki
                   ` (4 more replies)
  0 siblings, 5 replies; 15+ messages in thread
From: Pawel Dembicki @ 2019-07-03 17:19 UTC (permalink / raw)
  Cc: Pawel Dembicki, linus.walleij, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, David S. Miller, Rob Herring, Mark Rutland,
	netdev, devicetree, linux-kernel

Main goal of this patch series is to add support for parallel bus in
Vitesse VSC73xx switches. Existing driver supports only SPI mode.

Second change is needed for devices in unmanaged state.

V2:
- drop changes in compatible strings
- make changes less invasive
- drop mutex in platform part and move mutex from core to spi part
- fix indentation 
- fix devm_ioremap_resource result check
- add cover letter 

Pawel Dembicki (4):
  net: dsa: Change DT bindings for Vitesse VSC73xx switches
  net: dsa: vsc73xx: Split vsc73xx driver
  net: dsa: vsc73xx: add support for parallel mode
  net: dsa: vsc73xx: Assert reset if iCPU is enabled

 .../bindings/net/dsa/vitesse,vsc73xx.txt      |  57 ++++-
 drivers/net/dsa/Kconfig                       |  19 +-
 drivers/net/dsa/Makefile                      |   4 +-
 ...tesse-vsc73xx.c => vitesse-vsc73xx-core.c} | 206 +++---------------
 drivers/net/dsa/vitesse-vsc73xx-platform.c    | 160 ++++++++++++++
 drivers/net/dsa/vitesse-vsc73xx-spi.c         | 203 +++++++++++++++++
 drivers/net/dsa/vitesse-vsc73xx.h             |  29 +++
 7 files changed, 493 insertions(+), 185 deletions(-)
 rename drivers/net/dsa/{vitesse-vsc73xx.c => vitesse-vsc73xx-core.c} (90%)
 create mode 100644 drivers/net/dsa/vitesse-vsc73xx-platform.c
 create mode 100644 drivers/net/dsa/vitesse-vsc73xx-spi.c
 create mode 100644 drivers/net/dsa/vitesse-vsc73xx.h

-- 
2.20.1


^ permalink raw reply	[flat|nested] 15+ messages in thread
* [PATCH 4/4] net: dsa: vsc73xx: Assert reset if iCPU is enabled
@ 2019-07-01 15:27 Pawel Dembicki
  2019-07-03  9:10 ` [PATCH v2 " Pawel Dembicki
  0 siblings, 1 reply; 15+ messages in thread
From: Pawel Dembicki @ 2019-07-01 15:27 UTC (permalink / raw)
  Cc: linus.walleij, paweldembicki, Andrew Lunn, Vivien Didelot,
	Florian Fainelli, David S. Miller, Rob Herring, Mark Rutland,
	netdev, devicetree, linux-kernel

Driver allow to use devices with disabled iCPU only.

Some devices have pre-initialised iCPU by bootloader.
That state make switch unmanaged. This patch force reset
if device is in unmanaged state. In the result chip lost
internal firmware from RAM and it can be managed.

Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
---
 drivers/net/dsa/vitesse-vsc73xx-core.c | 36 ++++++++++++--------------
 1 file changed, 17 insertions(+), 19 deletions(-)

diff --git a/drivers/net/dsa/vitesse-vsc73xx-core.c b/drivers/net/dsa/vitesse-vsc73xx-core.c
index 9975446cdc66..5cdf91849b5d 100644
--- a/drivers/net/dsa/vitesse-vsc73xx-core.c
+++ b/drivers/net/dsa/vitesse-vsc73xx-core.c
@@ -405,22 +405,8 @@ static int vsc73xx_detect(struct vsc73xx *vsc)
 	}
 
 	if (val == 0xffffffff) {
-		dev_info(vsc->dev, "chip seems dead, assert reset\n");
-		gpiod_set_value_cansleep(vsc->reset, 1);
-		/* Reset pulse should be 20ns minimum, according to datasheet
-		 * table 245, so 10us should be fine
-		 */
-		usleep_range(10, 100);
-		gpiod_set_value_cansleep(vsc->reset, 0);
-		/* Wait 20ms according to datasheet table 245 */
-		msleep(20);
-
-		ret = vsc->ops->read(vsc, VSC73XX_BLOCK_SYSTEM, 0,
-				   VSC73XX_ICPU_MBOX_VAL, &val);
-		if (val == 0xffffffff) {
-			dev_err(vsc->dev, "seems not to help, giving up\n");
-			return -ENODEV;
-		}
+		dev_info(vsc->dev, "chip seems dead.\n");
+		return -EAGAIN;
 	}
 
 	ret = vsc->ops->read(vsc, VSC73XX_BLOCK_SYSTEM, 0,
@@ -471,9 +457,8 @@ static int vsc73xx_detect(struct vsc73xx *vsc)
 	}
 	if (icpu_si_boot_en && !icpu_pi_en) {
 		dev_err(vsc->dev,
-			"iCPU enabled boots from SI, no external memory\n");
-		dev_err(vsc->dev, "no idea how to deal with this\n");
-		return -ENODEV;
+			"iCPU enabled boots from PI/SI, no external memory\n");
+		return -EAGAIN;
 	}
 	if (!icpu_si_boot_en && icpu_pi_en) {
 		dev_err(vsc->dev,
@@ -1147,6 +1132,19 @@ int vsc73xx_probe(struct vsc73xx *vsc)
 		msleep(20);
 
 	ret = vsc73xx_detect(vsc);
+	if (ret == -EAGAIN) {
+		dev_err(vsc->dev,
+			"Chip seams to be out of control. Assert reset and try again.\n");
+		gpiod_set_value_cansleep(vsc->reset, 1);
+		/* Reset pulse should be 20ns minimum, according to datasheet
+		 * table 245, so 10us should be fine
+		 */
+		usleep_range(10, 100);
+		gpiod_set_value_cansleep(vsc->reset, 0);
+		/* Wait 20ms according to datasheet table 245 */
+		msleep(20);
+		ret = vsc73xx_detect(vsc);
+	}
 	if (ret) {
 		dev_err(vsc->dev, "no chip found (%d)\n", ret);
 		return -ENODEV;
-- 
2.20.1


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

end of thread, other threads:[~2019-07-04 21:57 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-07-03 17:19 [PATCH v2 0/4] net: dsa: Add Vitesse VSC73xx parallel mode Pawel Dembicki
2019-07-03 17:19 ` [PATCH v2 1/4] net: dsa: Change DT bindings for Vitesse VSC73xx switches Pawel Dembicki
2019-07-04  7:05   ` Linus Walleij
2019-07-04 20:22     ` Florian Fainelli
2019-07-03 17:19 ` [PATCH v2 2/4] net: dsa: vsc73xx: Split vsc73xx driver Pawel Dembicki
2019-07-04  7:08   ` Linus Walleij
2019-07-04 20:24   ` Florian Fainelli
2019-07-03 17:19 ` [PATCH v2 3/4] net: dsa: vsc73xx: add support for parallel mode Pawel Dembicki
2019-07-04  7:16   ` Linus Walleij
2019-07-03 17:19 ` [PATCH v2 4/4] net: dsa: vsc73xx: Assert reset if iCPU is enabled Pawel Dembicki
2019-07-04  7:22   ` Linus Walleij
2019-07-04 21:57     ` Paweł Dembicki
2019-07-04 20:27   ` Florian Fainelli
2019-07-04 19:34 ` [PATCH v2 0/4] net: dsa: Add Vitesse VSC73xx parallel mode David Miller
  -- strict thread matches above, loose matches on Subject: below --
2019-07-01 15:27 [PATCH 4/4] net: dsa: vsc73xx: Assert reset if iCPU is enabled Pawel Dembicki
2019-07-03  9:10 ` [PATCH v2 " Pawel Dembicki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox