mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 1/1] macb: add support to read the mac address from register
@ 2013-10-03  9:45 Jean-Christophe PLAGNIOL-VILLARD
  2013-10-06 11:36 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-10-03  9:45 UTC (permalink / raw)
  To: barebox

check the 4 mac address register and return at the first valid

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 drivers/net/macb.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/net/macb.c b/drivers/net/macb.c
index b1f544b..d8523ce 100644
--- a/drivers/net/macb.c
+++ b/drivers/net/macb.c
@@ -458,9 +458,31 @@ static int macb_phy_write(struct mii_bus *bus, int addr, int reg, u16 value)
 static int macb_get_ethaddr(struct eth_device *edev, unsigned char *adr)
 {
 	struct macb_device *macb = edev->priv;
+	u32 bottom;
+	u16 top;
+	u8 addr[6];
+	int i;
 
 	dev_dbg(macb->dev, "%s\n", __func__);
 
+	/* Check all 4 address register for vaild address */
+	for (i = 0; i < 4; i++) {
+		bottom = macb_or_gem_readl(macb, SA1B + i * 8);
+		top = macb_or_gem_readl(macb, SA1T + i * 8);
+
+		addr[0] = bottom & 0xff;
+		addr[1] = (bottom >> 8) & 0xff;
+		addr[2] = (bottom >> 16) & 0xff;
+		addr[3] = (bottom >> 24) & 0xff;
+		addr[4] = top & 0xff;
+		addr[5] = (top >> 8) & 0xff;
+
+		if (is_valid_ether_addr(addr)) {
+			memcpy(adr, addr, sizeof(addr));
+			return 0;
+		}
+	}
+
 	return -1;
 }
 
-- 
1.8.4.rc3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

* Re: [PATCH 1/1] macb: add support to read the mac address from register
  2013-10-03  9:45 [PATCH 1/1] macb: add support to read the mac address from register Jean-Christophe PLAGNIOL-VILLARD
@ 2013-10-06 11:36 ` Sascha Hauer
  0 siblings, 0 replies; 2+ messages in thread
From: Sascha Hauer @ 2013-10-06 11:36 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Thu, Oct 03, 2013 at 11:45:29AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> check the 4 mac address register and return at the first valid
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>

Applied, thanks

Sascha

> ---
>  drivers/net/macb.c | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
> 
> diff --git a/drivers/net/macb.c b/drivers/net/macb.c
> index b1f544b..d8523ce 100644
> --- a/drivers/net/macb.c
> +++ b/drivers/net/macb.c
> @@ -458,9 +458,31 @@ static int macb_phy_write(struct mii_bus *bus, int addr, int reg, u16 value)
>  static int macb_get_ethaddr(struct eth_device *edev, unsigned char *adr)
>  {
>  	struct macb_device *macb = edev->priv;
> +	u32 bottom;
> +	u16 top;
> +	u8 addr[6];
> +	int i;
>  
>  	dev_dbg(macb->dev, "%s\n", __func__);
>  
> +	/* Check all 4 address register for vaild address */
> +	for (i = 0; i < 4; i++) {
> +		bottom = macb_or_gem_readl(macb, SA1B + i * 8);
> +		top = macb_or_gem_readl(macb, SA1T + i * 8);
> +
> +		addr[0] = bottom & 0xff;
> +		addr[1] = (bottom >> 8) & 0xff;
> +		addr[2] = (bottom >> 16) & 0xff;
> +		addr[3] = (bottom >> 24) & 0xff;
> +		addr[4] = top & 0xff;
> +		addr[5] = (top >> 8) & 0xff;
> +
> +		if (is_valid_ether_addr(addr)) {
> +			memcpy(adr, addr, sizeof(addr));
> +			return 0;
> +		}
> +	}
> +
>  	return -1;
>  }
>  
> -- 
> 1.8.4.rc3
> 
> 
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
> 

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

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

end of thread, other threads:[~2013-10-06 11:36 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-03  9:45 [PATCH 1/1] macb: add support to read the mac address from register Jean-Christophe PLAGNIOL-VILLARD
2013-10-06 11:36 ` Sascha Hauer

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