linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pawel Dembicki <paweldembicki@gmail.com>
To: unlisted-recipients:; (no To-header on input)
Cc: paweldembicki@gmail.com, linus.walleij@linaro.org,
	Andrew Lunn <andrew@lunn.ch>,
	Vivien Didelot <vivien.didelot@gmail.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	netdev@vger.kernel.org, devicetree@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 4/4] net: dsa: vsc73xx: Assert reset if iCPU is enabled
Date: Wed,  3 Jul 2019 11:10:48 +0200	[thread overview]
Message-ID: <20190703091048.1962-1-paweldembicki@gmail.com> (raw)
In-Reply-To: <20190701152723.624-4-paweldembicki@gmail.com>

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>
---
Changes in v2:
- rebase commit after changes 1-3/4 patches

 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 10063f31d9a3..4525702faf68 100644
--- a/drivers/net/dsa/vitesse-vsc73xx-core.c
+++ b/drivers/net/dsa/vitesse-vsc73xx-core.c
@@ -417,22 +417,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 = vsc73xx_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 = vsc73xx_read(vsc, VSC73XX_BLOCK_SYSTEM, 0,
@@ -483,9 +469,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,
@@ -1158,6 +1143,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(dev, "no chip found (%d)\n", ret);
 		return -ENODEV;
-- 
2.20.1


  reply	other threads:[~2019-07-03  9:10 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-01 15:27 [PATCH 1/4] net: dsa: Change DT bindings for Vitesse VSC73xx switches Pawel Dembicki
2019-07-01 15:27 ` [PATCH 2/4] net: dsa: vsc73xx: Split vsc73xx driver Pawel Dembicki
2019-07-01 16:03   ` Andrew Lunn
2019-07-03  9:02   ` [PATCH v2 " Pawel Dembicki
2019-07-01 15:27 ` [PATCH 3/4] net: dsa: vsc73xx: add support for parallel mode Pawel Dembicki
2019-07-01 16:11   ` Andrew Lunn
2019-07-01 16:45   ` Florian Fainelli
2019-07-03  9:07   ` [PATCH v2 " Pawel Dembicki
2019-07-01 15:27 ` [PATCH 4/4] net: dsa: vsc73xx: Assert reset if iCPU is enabled Pawel Dembicki
2019-07-03  9:10   ` Pawel Dembicki [this message]
2019-07-01 15:55 ` [PATCH 1/4] net: dsa: Change DT bindings for Vitesse VSC73xx switches Andrew Lunn
2019-07-01 16:44 ` Florian Fainelli
2019-07-01 20:23   ` Linus Walleij
2019-07-03  8:57 ` [PATCH v2 " Pawel Dembicki
2019-07-03 12:41   ` Linus Walleij
2019-07-03 15:26   ` Florian Fainelli
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 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190703091048.1962-1-paweldembicki@gmail.com \
    --to=paweldembicki@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=netdev@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=vivien.didelot@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).