Skip to contentSkip to conversation

sama5d3xek: get GMAC working

PATCH New Andreas Bießmann 2 participants 6 messages Sep 18, 2014 – Oct 10, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover sama5d3xek: get GMAC working

I had a strange behaviour for my sama5d34ek board which could sometimes not get up GMAC in U-Boot. It turned out, that we missed to initialize the PHY correctly.

Bo, could you please verify correct behaviour on 100MiB devices like sama5d31ek?

Andreas Bie?mann (2):
macb: simplify gmac initialisation
sama5d3xek: run PHY's config

 board/atmel/sama5d3xek/sama5d3xek.c |   29 ++++++++++++++++++++---------
 drivers/net/macb.c                  |   25 ++++++++-----------------
 2 files changed, 28 insertions(+), 26 deletions(-)
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH 1/2 macb: simplify gmac initialisation

---

 drivers/net/macb.c |   25 ++++++++-----------------
 1 file changed, 8 insertions(+), 17 deletions(-)
drivers/net/macb.c +8 -17
index 01a94a4..375c8a4 100644
@@ -479,31 +479,22 @@ static int macb_phy_init(struct macb_device *macb)
 	/* First check for GMAC */
 	if (macb_is_gem(macb)) {
 		lpa = macb_mdio_read(macb, MII_STAT1000);
-		if (lpa & (1 << 11)) {
-			speed = 1000;
-			duplex = 1;
-		} else {
-		       if (lpa & (1 << 10)) {
-				speed = 1000;
-				duplex = 1;
-			} else {
-				speed = 0;
-			}
-		}
 
-		if (speed == 1000) {
-			printf("%s: link up, %dMbps %s-duplex (lpa: 0x%04x)\n",
+		if (lpa & (LPA_1000FULL | LPA_1000HALF)) {
+			duplex = ((lpa & LPA_1000FULL) ? 1 : 0);
+
+			printf("%s: link up, 1000Mbps %s-duplex (lpa: 0x%04x)\n",
 			       netdev->name,
-			       speed,
 			       duplex ? "full" : "half",
 			       lpa);
 
 			ncfgr = macb_readl(macb, NCFGR);
-			ncfgr &= ~(GEM_BIT(GBE) | MACB_BIT(SPD) | MACB_BIT(FD));
-			if (speed)
-				ncfgr |= GEM_BIT(GBE);
+			ncfgr &= ~(MACB_BIT(SPD) | MACB_BIT(FD));
+			ncfgr |= GEM_BIT(GBE);
+
 			if (duplex)
 				ncfgr |= MACB_BIT(FD);
+
 			macb_writel(macb, NCFGR, ncfgr);
 
 			return 1;
Signature · 1 line
1.7.10.4
#3 lore raw

PATCH 2/2 sama5d3xek: run PHY's config

In reply to Andreas Bießmann

---

 board/atmel/sama5d3xek/sama5d3xek.c |   29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)
board/atmel/sama5d3xek/sama5d3xek.c +20 -9
index f53754b..ca4f79d 100644
@@ -17,6 +17,7 @@
 #include <lcd.h>
 #include <atmel_lcdc.h>
 #include <atmel_mci.h>
+#include <phy.h>
 #include <micrel.h>
 #include <net.h>
 #include <netdev.h>
@@ -273,15 +274,25 @@ int dram_init(void)
 
 int board_phy_config(struct phy_device *phydev)
 {
-	/* rx data delay */
-	ksz9021_phy_extended_write(phydev,
-				   MII_KSZ9021_EXT_RGMII_RX_DATA_SKEW, 0x2222);
-	/* tx data delay */
-	ksz9021_phy_extended_write(phydev,
-				   MII_KSZ9021_EXT_RGMII_TX_DATA_SKEW, 0x2222);
-	/* rx/tx clock delay */
-	ksz9021_phy_extended_write(phydev,
-				   MII_KSZ9021_EXT_RGMII_CLOCK_SKEW, 0xf2f4);
+	/* board specific timings for GMAC */
+	if (has_gmac()) {
+		/* rx data delay */
+		ksz9021_phy_extended_write(phydev,
+					   MII_KSZ9021_EXT_RGMII_RX_DATA_SKEW,
+					   0x2222);
+		/* tx data delay */
+		ksz9021_phy_extended_write(phydev,
+					   MII_KSZ9021_EXT_RGMII_TX_DATA_SKEW,
+					   0x2222);
+		/* rx/tx clock delay */
+		ksz9021_phy_extended_write(phydev,
+					   MII_KSZ9021_EXT_RGMII_CLOCK_SKEW,
+					   0xf2f4);
+	}
+
+	/* always run the PHY's config routine */
+	if (phydev->drv->config)
+		return phydev->drv->config(phydev);
 
 	return 0;
 }
Signature · 1 line
1.7.10.4
#4 lore raw

PATCH 2/2 sama5d3xek: run PHY's config

Dear Andreas Devel,

Quoted 6 lines · Andreas Devel

---

board/atmel/sama5d3xek/sama5d3xek.c | 29 ++++++++++++++++++++---------

1 file changed, 20 insertions(+), 9 deletions(-)

applied to u-boot-atmel/master, thanks!

Best regards,
Andreas Bie?mann

#5 lore raw

cover sama5d3xek: get GMAC working

In reply to Andreas Bießmann

Hi Andreas,

Quoted 7 lines · Andreas Bie?mann

I had a strange behaviour for my sama5d34ek board which could sometimes not get up GMAC in U-Boot. It turned out, that we missed to initialize the PHY correctly.

Bo, could you please verify correct behaviour on 100MiB devices like sama5d31ek?

Test OK on sama5d31ek board, you can add Tested-by tag for this patch series.

Thanks.

Quoted 9 lines

Andreas Bie?mann (2):
macb: simplify gmac initialisation
sama5d3xek: run PHY's config

  board/atmel/sama5d3xek/sama5d3xek.c |   29 ++++++++++++++++++++---------
  drivers/net/macb.c                  |   25 ++++++++-----------------
  2 files changed, 28 insertions(+), 26 deletions(-)

Best Regards,
Bo Shen