[U-Boot] [PATCH 0/2] 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(-)

Signed-off-by: Andreas Bießmann andreas.devel@googlemail.com Cc: Joe Hershberger joe.hershberger@gmail.com Cc: Bo Shen voice.shen@atmel.com ---
drivers/net/macb.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-)
diff --git a/drivers/net/macb.c b/drivers/net/macb.c index 01a94a4..375c8a4 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -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;

Dear Andreas Devel,
Andreas Devel andreas.devel@googlemail.com writes:
Signed-off-by: Andreas Bießmann andreas.devel@googlemail.com Cc: Joe Hershberger joe.hershberger@gmail.com Cc: Bo Shen voice.shen@atmel.com
drivers/net/macb.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-)
applied to u-boot-atmel/master, thanks!
Best regards, Andreas Bießmann

Signed-off-by: Andreas Bießmann andreas.devel@googlemail.com Cc: Bo Shen voice.shen@atmel.com
---
board/atmel/sama5d3xek/sama5d3xek.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/board/atmel/sama5d3xek/sama5d3xek.c b/board/atmel/sama5d3xek/sama5d3xek.c index f53754b..ca4f79d 100644 --- a/board/atmel/sama5d3xek/sama5d3xek.c +++ b/board/atmel/sama5d3xek/sama5d3xek.c @@ -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; }

Dear Andreas Devel,
Andreas Devel andreas.devel@googlemail.com writes:
Signed-off-by: Andreas Bießmann andreas.devel@googlemail.com Cc: Bo Shen voice.shen@atmel.com
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

Hi Andreas,
On 09/19/2014 05:46 AM, Andreas Bießmann wrote:
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.
Tested-by: Bo Shen voice.shen@atmel.com
Thanks.
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
participants (2)
-
Andreas Bießmann
-
Bo Shen