mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH 0/3 v2] Animeo IP: macb support improvement
@ 2013-09-20  5:46 Jean-Christophe PLAGNIOL-VILLARD
  2013-09-20  5:47 ` [PATCH 1/3] introduce helper to generate mac address with OUI Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-20  5:46 UTC (permalink / raw)
  To: barebox

Hi,

	v2:

	send right patch 3

	the patch serie depend on usb support patch

	The following patch series add
	 - fix reset
	 - retreive previously valid public macb's mac
	 - set local mac to macb (if none) and asix with "smf" as OUI

The following changes since commit 1877e0407fc38f3eba60a3e60b61a0982a6c006b:

  Animeo IP: add usb host support (2013-09-20 13:42:21 +0800)

are available in the git repository at:

  git://git.jcrosoft.org/barebox.git delivery/animeo_ip_eth

for you to fetch changes up to 994c17ca145407c6a0edae4caf096e4dcdde1535:

  animeo_ip: retrieve the mac from the macb and set private mac to asix (2013-09-20 13:44:30 +0800)

----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (3):
      introduce helper to generate mac address with OUI
      animeo_ip: ensure the phy is reset correctly
      animeo_ip: retrieve the mac from the macb and set private mac to asix

 arch/arm/boards/animeo_ip/init.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 include/local_mac_address.h      | 40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 112 insertions(+), 1 deletion(-)
 create mode 100644 include/local_mac_address.h

Best Regards,
J.

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

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

* [PATCH 1/3] introduce helper to generate mac address with OUI
  2013-09-20  5:46 [PATCH 0/3 v2] Animeo IP: macb support improvement Jean-Christophe PLAGNIOL-VILLARD
@ 2013-09-20  5:47 ` Jean-Christophe PLAGNIOL-VILLARD
  2013-09-20  5:47   ` [PATCH 2/3] animeo_ip: ensure the phy is reset correctly Jean-Christophe PLAGNIOL-VILLARD
                     ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-20  5:47 UTC (permalink / raw)
  To: barebox

use random mac address with fixed OUI provided

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 include/local_mac_address.h | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 include/local_mac_address.h

diff --git a/include/local_mac_address.h b/include/local_mac_address.h
new file mode 100644
index 0000000..3920334
--- /dev/null
+++ b/include/local_mac_address.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com>
+ *
+ * Under GPLv2 only
+ */
+
+#ifndef __LOCAL_MAC_ADDRESS_H__
+#define __LOCAL_MAC_ADDRESS_H__
+
+/**
+ * local_mac_address_register - use random number with fix
+ * OUI provided device to provide an Ethernet address
+ * @ethid: ethernet device id
+ * @oui: Ethernet OUI (3 bytes)
+ *
+ * Generate a local Ethernet address (MAC) that is not multicast using a 1-wire id.
+ */
+static inline int local_mac_address_register(int ethid, char * oui)
+{
+	char addr[6];
+	int nb_oui = 3;
+	int i;
+
+	if (!oui)
+		return -EINVAL;
+
+	random_ether_addr(addr);
+
+	for (i = 0; i < nb_oui; i++)
+		addr[i] = oui[i];
+
+	addr[0] &= 0xfe;	/* clear multicast bit */
+	addr[0] |= 0x02;	/* set local assignment bit (IEEE802) */
+
+	eth_register_ethaddr(ethid, addr);
+
+	return 0;
+}
+
+#endif /* __LOCAL_MAC_ADDRESS_H__ */
-- 
1.8.4.rc1


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

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

* [PATCH 2/3] animeo_ip: ensure the phy is reset correctly
  2013-09-20  5:47 ` [PATCH 1/3] introduce helper to generate mac address with OUI Jean-Christophe PLAGNIOL-VILLARD
@ 2013-09-20  5:47   ` Jean-Christophe PLAGNIOL-VILLARD
  2013-09-23  4:38     ` Jean-Christophe PLAGNIOL-VILLARD
  2013-09-20  5:47   ` [PATCH 3/3] animeo_ip: retrieve the mac from the macb and set private mac to asix Jean-Christophe PLAGNIOL-VILLARD
                     ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-20  5:47 UTC (permalink / raw)
  To: barebox

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/boards/animeo_ip/init.c | 38 +++++++++++++++++++++++++++++++++++++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/arch/arm/boards/animeo_ip/init.c b/arch/arm/boards/animeo_ip/init.c
index 5419ddb..65fc0e6 100644
--- a/arch/arm/boards/animeo_ip/init.c
+++ b/arch/arm/boards/animeo_ip/init.c
@@ -19,6 +19,7 @@
 #include <nand.h>
 #include <sizes.h>
 #include <linux/mtd/nand.h>
+#include <linux/clk.h>
 #include <mach/board.h>
 #include <mach/at91sam9_smc.h>
 #include <gpio.h>
@@ -225,12 +226,45 @@ static void animeo_ip_power_control(void)
 	animeo_export_gpio_out(AT91_PIN_PC4, "power_save");
 }
 
+static void animeo_ip_phy_reset(void)
+{
+	unsigned long rstc;
+	int i;
+	struct clk *clk = clk_get(NULL, "macb_clk");
+
+	clk_enable(clk);
+
+	for (i = AT91_PIN_PA12; i <= AT91_PIN_PA29; i++)
+		at91_set_gpio_input(i, 0);
+
+	rstc = at91_sys_read(AT91_RSTC_MR) & AT91_RSTC_ERSTL;
+
+	/* Need to reset PHY -> 500ms reset */
+	at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY |
+				     (AT91_RSTC_ERSTL & (0x0d << 8)) |
+				     AT91_RSTC_URSTEN);
+
+	at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_EXTRST);
+
+	/* Wait for end hardware reset */
+	while (!(at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_NRSTL))
+		;
+
+	/* Restore NRST value */
+	at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | (rstc) | AT91_RSTC_URSTEN);
+}
+
+static void animeo_ip_add_device_eth(void)
+{
+	animeo_ip_phy_reset();
+	at91_add_device_eth(0, &macb_pdata);
+}
+
 static int animeo_ip_devices_init(void)
 {
 	animeo_ip_detect_version();
 	animeo_ip_power_control();
 	animeo_ip_add_device_nand();
-	at91_add_device_eth(0, &macb_pdata);
 	animeo_ip_add_device_usb();
 	animeo_ip_add_device_mci();
 	animeo_ip_add_device_buttons();
@@ -250,6 +284,8 @@ static int animeo_ip_devices_init(void)
 	devfs_add_partition("nand0", SZ_256K + SZ_32K, SZ_32K, DEVFS_PARTITION_FIXED, "env_raw");
 	dev_add_bb_dev("env_raw", "env0");
 
+	animeo_ip_add_device_eth();
+
 	return 0;
 }
 
-- 
1.8.4.rc1


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

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

* [PATCH 3/3] animeo_ip: retrieve the mac from the macb and set private mac to asix
  2013-09-20  5:47 ` [PATCH 1/3] introduce helper to generate mac address with OUI Jean-Christophe PLAGNIOL-VILLARD
  2013-09-20  5:47   ` [PATCH 2/3] animeo_ip: ensure the phy is reset correctly Jean-Christophe PLAGNIOL-VILLARD
@ 2013-09-20  5:47   ` Jean-Christophe PLAGNIOL-VILLARD
  2013-09-20  7:04   ` [PATCH 1/3] introduce helper to generate mac address with OUI Sascha Hauer
  2013-09-22 18:28   ` Sascha Hauer
  3 siblings, 0 replies; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-20  5:47 UTC (permalink / raw)
  To: barebox

if the macb's mac is not a valid public mac set a private with "smf" as OUI
as the mac address might be set by the previous bootloader

set a private with "smf" as OUI for asix

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 arch/arm/boards/animeo_ip/init.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/arch/arm/boards/animeo_ip/init.c b/arch/arm/boards/animeo_ip/init.c
index 65fc0e6..4068437 100644
--- a/arch/arm/boards/animeo_ip/init.c
+++ b/arch/arm/boards/animeo_ip/init.c
@@ -27,6 +27,7 @@
 #include <mach/io.h>
 #include <mach/at91_pmc.h>
 #include <mach/at91_rstc.h>
+#include <local_mac_address.h>
 
 static bool animeo_ip_is_buco;
 static bool animeo_ip_is_io;
@@ -254,8 +255,42 @@ static void animeo_ip_phy_reset(void)
 	at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | (rstc) | AT91_RSTC_URSTEN);
 }
 
+#define MACB_SA1B	0x0098
+#define MACB_SA1T	0x009c
+
+static int animeo_ip_get_macb_ethaddr(u8 *addr)
+{
+	u32 top, bottom;
+	void __iomem *base = IOMEM(AT91SAM9260_BASE_EMAC);
+
+	bottom = readl(base + MACB_SA1B);
+	top = readl(base + MACB_SA1T);
+	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;
+
+	/* valid and not private */
+	if (is_valid_ether_addr(addr) && !(addr[0] & 0x02))
+		return 0;
+
+	return -EINVAL;
+}
+
 static void animeo_ip_add_device_eth(void)
 {
+	u8 enetaddr[6];
+
+	if (!animeo_ip_get_macb_ethaddr(enetaddr))
+		eth_register_ethaddr(0, enetaddr);
+	else
+		local_mac_address_register(0, "smf");
+
+	/* for usb asix */
+	local_mac_address_register(1, "smf");
+
 	animeo_ip_phy_reset();
 	at91_add_device_eth(0, &macb_pdata);
 }
-- 
1.8.4.rc1


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

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

* Re: [PATCH 1/3] introduce helper to generate mac address with OUI
  2013-09-20  5:47 ` [PATCH 1/3] introduce helper to generate mac address with OUI Jean-Christophe PLAGNIOL-VILLARD
  2013-09-20  5:47   ` [PATCH 2/3] animeo_ip: ensure the phy is reset correctly Jean-Christophe PLAGNIOL-VILLARD
  2013-09-20  5:47   ` [PATCH 3/3] animeo_ip: retrieve the mac from the macb and set private mac to asix Jean-Christophe PLAGNIOL-VILLARD
@ 2013-09-20  7:04   ` Sascha Hauer
  2013-09-20  7:44     ` Jean-Christophe PLAGNIOL-VILLARD
  2013-09-22 18:28   ` Sascha Hauer
  3 siblings, 1 reply; 10+ messages in thread
From: Sascha Hauer @ 2013-09-20  7:04 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Fri, Sep 20, 2013 at 07:47:43AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> use random mac address with fixed OUI provided
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  include/local_mac_address.h | 40 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
>  create mode 100644 include/local_mac_address.h
> 
> diff --git a/include/local_mac_address.h b/include/local_mac_address.h
> new file mode 100644
> index 0000000..3920334
> --- /dev/null
> +++ b/include/local_mac_address.h
> @@ -0,0 +1,40 @@
> +/*
> + * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com>
> + *
> + * Under GPLv2 only
> + */
> +
> +#ifndef __LOCAL_MAC_ADDRESS_H__
> +#define __LOCAL_MAC_ADDRESS_H__
> +
> +/**
> + * local_mac_address_register - use random number with fix
> + * OUI provided device to provide an Ethernet address
> + * @ethid: ethernet device id
> + * @oui: Ethernet OUI (3 bytes)
> + *
> + * Generate a local Ethernet address (MAC) that is not multicast using a 1-wire id.
> + */
> +static inline int local_mac_address_register(int ethid, char * oui)
> +{
> +	char addr[6];
> +	int nb_oui = 3;
> +	int i;
> +
> +	if (!oui)
> +		return -EINVAL;
> +
> +	random_ether_addr(addr);
> +
> +	for (i = 0; i < nb_oui; i++)
> +		addr[i] = oui[i];

Shouldn't you rather use bytes 1-3 instead of 0-2?

> +
> +	addr[0] &= 0xfe;	/* clear multicast bit */
> +	addr[0] |= 0x02;	/* set local assignment bit (IEEE802) */

Otherwise the 'smf' you pass in becomes 'qmf' here.

Sascha

-- 
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] 10+ messages in thread

* Re: [PATCH 1/3] introduce helper to generate mac address with OUI
  2013-09-20  7:04   ` [PATCH 1/3] introduce helper to generate mac address with OUI Sascha Hauer
@ 2013-09-20  7:44     ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-20  7:44 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

On 09:04 Fri 20 Sep     , Sascha Hauer wrote:
> On Fri, Sep 20, 2013 at 07:47:43AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > use random mac address with fixed OUI provided
> > 
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> > ---
> >  include/local_mac_address.h | 40 ++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 40 insertions(+)
> >  create mode 100644 include/local_mac_address.h
> > 
> > diff --git a/include/local_mac_address.h b/include/local_mac_address.h
> > new file mode 100644
> > index 0000000..3920334
> > --- /dev/null
> > +++ b/include/local_mac_address.h
> > @@ -0,0 +1,40 @@
> > +/*
> > + * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com>
> > + *
> > + * Under GPLv2 only
> > + */
> > +
> > +#ifndef __LOCAL_MAC_ADDRESS_H__
> > +#define __LOCAL_MAC_ADDRESS_H__
> > +
> > +/**
> > + * local_mac_address_register - use random number with fix
> > + * OUI provided device to provide an Ethernet address
> > + * @ethid: ethernet device id
> > + * @oui: Ethernet OUI (3 bytes)
> > + *
> > + * Generate a local Ethernet address (MAC) that is not multicast using a 1-wire id.
> > + */
> > +static inline int local_mac_address_register(int ethid, char * oui)
> > +{
> > +	char addr[6];
> > +	int nb_oui = 3;
> > +	int i;
> > +
> > +	if (!oui)
> > +		return -EINVAL;
> > +
> > +	random_ether_addr(addr);
> > +
> > +	for (i = 0; i < nb_oui; i++)
> > +		addr[i] = oui[i];
> 
> Shouldn't you rather use bytes 1-3 instead of 0-2?
> 
> > +
> > +	addr[0] &= 0xfe;	/* clear multicast bit */
> > +	addr[0] |= 0x02;	/* set local assignment bit (IEEE802) */
> 
> Otherwise the 'smf' you pass in becomes 'qmf' here.
yes it's righth and the same way when you use the 1-wire version

so can we keep it as is

Best Regards,
J.
> 
> Sascha
> 
> -- 
> 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] 10+ messages in thread

* Re: [PATCH 1/3] introduce helper to generate mac address with OUI
  2013-09-20  5:47 ` [PATCH 1/3] introduce helper to generate mac address with OUI Jean-Christophe PLAGNIOL-VILLARD
                     ` (2 preceding siblings ...)
  2013-09-20  7:04   ` [PATCH 1/3] introduce helper to generate mac address with OUI Sascha Hauer
@ 2013-09-22 18:28   ` Sascha Hauer
  3 siblings, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2013-09-22 18:28 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Fri, Sep 20, 2013 at 07:47:43AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> use random mac address with fixed OUI provided
> 
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  include/local_mac_address.h | 40 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 40 insertions(+)
>  create mode 100644 include/local_mac_address.h
> 
> diff --git a/include/local_mac_address.h b/include/local_mac_address.h
> new file mode 100644
> index 0000000..3920334
> --- /dev/null
> +++ b/include/local_mac_address.h
> @@ -0,0 +1,40 @@
> +/*
> + * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com>
> + *
> + * Under GPLv2 only
> + */
> +
> +#ifndef __LOCAL_MAC_ADDRESS_H__
> +#define __LOCAL_MAC_ADDRESS_H__
> +

This file needs a include <net.h>. Added while applying.

Sascha

> +/**
> + * local_mac_address_register - use random number with fix
> + * OUI provided device to provide an Ethernet address
> + * @ethid: ethernet device id
> + * @oui: Ethernet OUI (3 bytes)
> + *
> + * Generate a local Ethernet address (MAC) that is not multicast using a 1-wire id.
> + */
> +static inline int local_mac_address_register(int ethid, char * oui)
> +{
> +	char addr[6];
> +	int nb_oui = 3;
> +	int i;
> +
> +	if (!oui)
> +		return -EINVAL;
> +
> +	random_ether_addr(addr);
> +
> +	for (i = 0; i < nb_oui; i++)
> +		addr[i] = oui[i];
> +
> +	addr[0] &= 0xfe;	/* clear multicast bit */
> +	addr[0] |= 0x02;	/* set local assignment bit (IEEE802) */
> +
> +	eth_register_ethaddr(ethid, addr);
> +
> +	return 0;
> +}
> +
> +#endif /* __LOCAL_MAC_ADDRESS_H__ */
> -- 
> 1.8.4.rc1
> 
> 
> _______________________________________________
> 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] 10+ messages in thread

* Re: [PATCH 2/3] animeo_ip: ensure the phy is reset correctly
  2013-09-20  5:47   ` [PATCH 2/3] animeo_ip: ensure the phy is reset correctly Jean-Christophe PLAGNIOL-VILLARD
@ 2013-09-23  4:38     ` Jean-Christophe PLAGNIOL-VILLARD
  2013-09-23  6:42       ` Sascha Hauer
  0 siblings, 1 reply; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-23  4:38 UTC (permalink / raw)
  To: barebox

On 07:47 Fri 20 Sep     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> ---
>  arch/arm/boards/animeo_ip/init.c | 38 +++++++++++++++++++++++++++++++++++++-
>  1 file changed, 37 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/boards/animeo_ip/init.c b/arch/arm/boards/animeo_ip/init.c
> index 5419ddb..65fc0e6 100644
> --- a/arch/arm/boards/animeo_ip/init.c
> +++ b/arch/arm/boards/animeo_ip/init.c
> @@ -19,6 +19,7 @@
>  #include <nand.h>
>  #include <sizes.h>
>  #include <linux/mtd/nand.h>
> +#include <linux/clk.h>
>  #include <mach/board.h>
>  #include <mach/at91sam9_smc.h>
>  #include <gpio.h>
> @@ -225,12 +226,45 @@ static void animeo_ip_power_control(void)
>  	animeo_export_gpio_out(AT91_PIN_PC4, "power_save");
>  }
>  
> +static void animeo_ip_phy_reset(void)
> +{
> +	unsigned long rstc;
> +	int i;
> +	struct clk *clk = clk_get(NULL, "macb_clk");
> +
> +	clk_enable(clk);
> +
> +	for (i = AT91_PIN_PA12; i <= AT91_PIN_PA29; i++)
> +		at91_set_gpio_input(i, 0);
> +
> +	rstc = at91_sys_read(AT91_RSTC_MR) & AT91_RSTC_ERSTL;
> +
> +	/* Need to reset PHY -> 500ms reset */
> +	at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY |
> +				     (AT91_RSTC_ERSTL & (0x0d << 8)) |
> +				     AT91_RSTC_URSTEN);
> +
> +	at91_sys_write(AT91_RSTC_CR, AT91_RSTC_KEY | AT91_RSTC_EXTRST);
> +
> +	/* Wait for end hardware reset */
> +	while (!(at91_sys_read(AT91_RSTC_SR) & AT91_RSTC_NRSTL))
> +		;
> +
> +	/* Restore NRST value */
> +	at91_sys_write(AT91_RSTC_MR, AT91_RSTC_KEY | (rstc) | AT91_RSTC_URSTEN);
> +}
> +
> +static void animeo_ip_add_device_eth(void)
> +{
> +	animeo_ip_phy_reset();
> +	at91_add_device_eth(0, &macb_pdata);
> +}
> +
>  static int animeo_ip_devices_init(void)
>  {
>  	animeo_ip_detect_version();
>  	animeo_ip_power_control();
>  	animeo_ip_add_device_nand();
> -	at91_add_device_eth(0, &macb_pdata);

when you merge it something go wrong this ligne remove was not applyed

can you check?

Best Regards,
J.
>  	animeo_ip_add_device_usb();
>  	animeo_ip_add_device_mci();
>  	animeo_ip_add_device_buttons();
> @@ -250,6 +284,8 @@ static int animeo_ip_devices_init(void)
>  	devfs_add_partition("nand0", SZ_256K + SZ_32K, SZ_32K, DEVFS_PARTITION_FIXED, "env_raw");
>  	dev_add_bb_dev("env_raw", "env0");
>  
> +	animeo_ip_add_device_eth();
> +
>  	return 0;
>  }
>  
> -- 
> 1.8.4.rc1
> 

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

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

* Re: [PATCH 2/3] animeo_ip: ensure the phy is reset correctly
  2013-09-23  4:38     ` Jean-Christophe PLAGNIOL-VILLARD
@ 2013-09-23  6:42       ` Sascha Hauer
  0 siblings, 0 replies; 10+ messages in thread
From: Sascha Hauer @ 2013-09-23  6:42 UTC (permalink / raw)
  To: Jean-Christophe PLAGNIOL-VILLARD; +Cc: barebox

On Mon, Sep 23, 2013 at 06:38:51AM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 07:47 Fri 20 Sep     , Jean-Christophe PLAGNIOL-VILLARD wrote:
> > Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
> >  	animeo_ip_power_control();
> >  	animeo_ip_add_device_nand();
> > -	at91_add_device_eth(0, &macb_pdata);
> 
> when you merge it something go wrong this ligne remove was not applyed
> 
> can you check?

Ups. Should be fixed now.

Sascha

-- 
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] 10+ messages in thread

* [PATCH 1/3] introduce helper to generate mac address with OUI
  2013-09-20  5:39 [PATCH 0/3] Animeo IP: macb support improvement Jean-Christophe PLAGNIOL-VILLARD
@ 2013-09-20  5:40 ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 10+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2013-09-20  5:40 UTC (permalink / raw)
  To: barebox

use random mac address with fixed OUI provided

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
---
 include/local_mac_address.h | 40 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)
 create mode 100644 include/local_mac_address.h

diff --git a/include/local_mac_address.h b/include/local_mac_address.h
new file mode 100644
index 0000000..3920334
--- /dev/null
+++ b/include/local_mac_address.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2012 Jean-Christophe PLAGNIOL-VILLARD <plagnio@jcrosoft.com>
+ *
+ * Under GPLv2 only
+ */
+
+#ifndef __LOCAL_MAC_ADDRESS_H__
+#define __LOCAL_MAC_ADDRESS_H__
+
+/**
+ * local_mac_address_register - use random number with fix
+ * OUI provided device to provide an Ethernet address
+ * @ethid: ethernet device id
+ * @oui: Ethernet OUI (3 bytes)
+ *
+ * Generate a local Ethernet address (MAC) that is not multicast using a 1-wire id.
+ */
+static inline int local_mac_address_register(int ethid, char * oui)
+{
+	char addr[6];
+	int nb_oui = 3;
+	int i;
+
+	if (!oui)
+		return -EINVAL;
+
+	random_ether_addr(addr);
+
+	for (i = 0; i < nb_oui; i++)
+		addr[i] = oui[i];
+
+	addr[0] &= 0xfe;	/* clear multicast bit */
+	addr[0] |= 0x02;	/* set local assignment bit (IEEE802) */
+
+	eth_register_ethaddr(ethid, addr);
+
+	return 0;
+}
+
+#endif /* __LOCAL_MAC_ADDRESS_H__ */
-- 
1.8.4.rc1


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

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

end of thread, other threads:[~2013-09-23  6:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-20  5:46 [PATCH 0/3 v2] Animeo IP: macb support improvement Jean-Christophe PLAGNIOL-VILLARD
2013-09-20  5:47 ` [PATCH 1/3] introduce helper to generate mac address with OUI Jean-Christophe PLAGNIOL-VILLARD
2013-09-20  5:47   ` [PATCH 2/3] animeo_ip: ensure the phy is reset correctly Jean-Christophe PLAGNIOL-VILLARD
2013-09-23  4:38     ` Jean-Christophe PLAGNIOL-VILLARD
2013-09-23  6:42       ` Sascha Hauer
2013-09-20  5:47   ` [PATCH 3/3] animeo_ip: retrieve the mac from the macb and set private mac to asix Jean-Christophe PLAGNIOL-VILLARD
2013-09-20  7:04   ` [PATCH 1/3] introduce helper to generate mac address with OUI Sascha Hauer
2013-09-20  7:44     ` Jean-Christophe PLAGNIOL-VILLARD
2013-09-22 18:28   ` Sascha Hauer
  -- strict thread matches above, loose matches on Subject: below --
2013-09-20  5:39 [PATCH 0/3] Animeo IP: macb support improvement Jean-Christophe PLAGNIOL-VILLARD
2013-09-20  5:40 ` [PATCH 1/3] introduce helper to generate mac address with OUI Jean-Christophe PLAGNIOL-VILLARD

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