RE: [PATCH] net: stmmac: Read user ID muliple times if needed.

2019-10-02 Thread Hans Andersson
We assert / de-assert the reset line, but the CPU is too fast and the IP is 
still 
in reset when we later try to read user ID / Synopsys ID. Another option would
be to add a delay after we reset.

-Original Message-
From: Jose Abreu  
Sent: den 2 oktober 2019 09:52
To: Hans Andersson ; mcoquelin.st...@gmail.com
Cc: peppe.cavall...@st.com; alexandre.tor...@st.com; da...@davemloft.net; 
net...@vger.kernel.org; linux-st...@st-md-mailman.stormreply.com; 
linux-arm-ker...@lists.infradead.org; linux-kernel@vger.kernel.org; Hans 
Andersson 
Subject: RE: [PATCH] net: stmmac: Read user ID muliple times if needed.

From: Hans Andersson 
Date: Oct/02/2019, 08:07:21 (UTC+00:00)

> When we read user ID / Synopsys ID we might still be in reset, so read 
> muliple times if needed.

We shouldn't even try to read it if IP is in reset ... 

---
Thanks,
Jose Miguel Abreu


[PATCH] net: stmmac: Read user ID muliple times if needed.

2019-10-02 Thread Hans Andersson
From: Hans Andersson 

When we read user ID / Synopsys ID we might still be in reset,
so read muliple times if needed.

Signed-off-by: Hans Andersson 
---
 drivers/net/ethernet/stmicro/stmmac/hwif.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/hwif.c 
b/drivers/net/ethernet/stmicro/stmmac/hwif.c
index 6c61b75..3347164 100644
--- a/drivers/net/ethernet/stmicro/stmmac/hwif.c
+++ b/drivers/net/ethernet/stmicro/stmmac/hwif.c
@@ -10,7 +10,16 @@
 
 static u32 stmmac_get_id(struct stmmac_priv *priv, u32 id_reg)
 {
-   u32 reg = readl(priv->ioaddr + id_reg);
+   u32 reg;
+   int i;
+
+   /* We might still be in reset when we read, */
+   /* so read multiple times if needed. */
+   for (i = 0; i < 10; i++) {
+   reg = readl(priv->ioaddr + id_reg);
+   if (reg)
+   break;
+   }
 
if (!reg) {
dev_info(priv->device, "Version ID not available\n");
-- 
2.17.1



[PATCH v2] net: phy: micrel: add Asym Pause workaround for KSZ9021

2019-09-27 Thread Hans Andersson
From: Hans Andersson 

The Micrel KSZ9031 PHY may fail to establish a link when the Asymmetric
Pause capability is set. This issue is described in a Silicon Errata
(DS8691D or DS8692D), which advises to always disable the
capability.

Micrel KSZ9021 has no errata, but has the same issue with Asymmetric Pause.
This patch apply the same workaround as the one for KSZ9031.

Fixes: 3aed3e2a143c ("net: phy: micrel: add Asym Pause workaround")
Signed-off-by: Hans Andersson 
Reviewed-by: Andrew Lunn 
---
 drivers/net/phy/micrel.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 3c8186f269f9..2fea5541c35a 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -763,6 +763,8 @@ static int ksz9031_get_features(struct phy_device *phydev)
 * Whenever the device's Asymmetric Pause capability is set to 1,
 * link-up may fail after a link-up to link-down transition.
 *
+* The Errata Sheet is for ksz9031, but ksz9021 has the same issue
+*
 * Workaround:
 * Do not enable the Asymmetric Pause capability bit.
 */
@@ -1076,6 +1078,7 @@ static struct phy_driver ksphy_driver[] = {
/* PHY_GBIT_FEATURES */
.driver_data= _type,
.probe  = kszphy_probe,
+   .get_features   = ksz9031_get_features,
.config_init= ksz9021_config_init,
.ack_interrupt  = kszphy_ack_interrupt,
.config_intr= kszphy_config_intr,
-- 
2.21.0.windows.1



[PATCH] net: phy: micrel: add Asym Pause workaround for KSZ9021

2019-09-26 Thread Hans Andersson
From: Hans Andersson 

The Micrel KSZ9031 PHY may fail to establish a link when the Asymmetric
Pause capability is set. This issue is described in a Silicon Errata
(DS8691D or DS8692D), which advises to always disable the
capability.

Micrel KSZ9021 has no errata, but has the same issue with Asymmetric Pause.
This patch apply the same workaround as the one for KSZ9031.

Signed-off-by: Hans Andersson 
---
 drivers/net/phy/micrel.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index 3c8186f..2fea554 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -763,6 +763,8 @@ static int ksz9031_get_features(struct phy_device *phydev)
 * Whenever the device's Asymmetric Pause capability is set to 1,
 * link-up may fail after a link-up to link-down transition.
 *
+* The Errata Sheet is for ksz9031, but ksz9021 has the same issue
+*
 * Workaround:
 * Do not enable the Asymmetric Pause capability bit.
 */
@@ -1076,6 +1078,7 @@ static struct phy_driver ksphy_driver[] = {
/* PHY_GBIT_FEATURES */
.driver_data= _type,
.probe  = kszphy_probe,
+   .get_features   = ksz9031_get_features,
.config_init= ksz9021_config_init,
.ack_interrupt  = kszphy_ack_interrupt,
.config_intr= kszphy_config_intr,
-- 
2.17.1