All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/2] Fix networking on DM365EVM
@ 2010-04-21  8:27 andreas.gaer at baslerweb.com
  2010-04-21  8:27 ` [U-Boot] [PATCH 1/2] Davinci: Fixed wrong EMAC_MDIO_PHY_MASK andreas.gaer at baslerweb.com
  2010-04-21  8:27 ` [U-Boot] [PATCH 2/2] Davinci: Move config of MAC address to board setup andreas.gaer at baslerweb.com
  0 siblings, 2 replies; 5+ messages in thread
From: andreas.gaer at baslerweb.com @ 2010-04-21  8:27 UTC (permalink / raw)
  To: u-boot

From: Andreas Gaeer <Andreas.Gaer@baslerweb.com>

Network did not work on my DM365EVM because of a wrong PHY mask and 
wrong initialization of the MAC address when ethaddr was not already
present in the environment.

The first patch fixes the mask definition, the second moves MAC address
init to a proper place in the board setup.

Andreas Gaeer (2):
  Davinci: Fixed wrong EMAC_MDIO_PHY_MASK
  Davinci: Move config of MAC address to board setup

 arch/arm/include/asm/arch-davinci/emac_defs.h |    2 +-
 arch/arm/lib/board.c                          |   11 -----------
 board/davinci/common/misc.c                   |   16 ++++++++++++++++
 board/davinci/common/misc.h                   |    1 +
 board/davinci/da830evm/da830evm.c             |    8 +++-----
 board/davinci/dm365evm/dm365evm.c             |   10 +++++++++-
 board/davinci/dvevm/dvevm.c                   |    5 +++++
 board/davinci/sffsdr/sffsdr.c                 |    5 +++++
 board/davinci/sonata/sonata.c                 |    5 +++++
 drivers/net/davinci_emac.c                    |    3 +++
 10 files changed, 48 insertions(+), 18 deletions(-)

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

* [U-Boot] [PATCH 1/2] Davinci: Fixed wrong EMAC_MDIO_PHY_MASK
  2010-04-21  8:27 [U-Boot] [PATCH 0/2] Fix networking on DM365EVM andreas.gaer at baslerweb.com
@ 2010-04-21  8:27 ` andreas.gaer at baslerweb.com
  2010-04-21  8:27 ` [U-Boot] [PATCH 2/2] Davinci: Move config of MAC address to board setup andreas.gaer at baslerweb.com
  1 sibling, 0 replies; 5+ messages in thread
From: andreas.gaer at baslerweb.com @ 2010-04-21  8:27 UTC (permalink / raw)
  To: u-boot

From: Andreas Gaeer <Andreas.Gaer@baslerweb.com>

Signed-off-by: Andreas Gaeer <Andreas.Gaer@baslerweb.com>
---
 arch/arm/include/asm/arch-davinci/emac_defs.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/include/asm/arch-davinci/emac_defs.h b/arch/arm/include/asm/arch-davinci/emac_defs.h
index b0ec8f5..baee6aa 100644
--- a/arch/arm/include/asm/arch-davinci/emac_defs.h
+++ b/arch/arm/include/asm/arch-davinci/emac_defs.h
@@ -86,7 +86,7 @@
 
 /* PHY mask - set only those phy number bits where phy is/can be connected */
 #define EMAC_MDIO_PHY_NUM           1
-#define EMAC_MDIO_PHY_MASK          (1 << EMAC_MDIO_PHY_NUM)
+#define EMAC_MDIO_PHY_MASK          ((1 << EMAC_MDIO_PHY_NUM)-1)
 
 /* Ethernet Min/Max packet size */
 #define EMAC_MIN_ETHERNET_PKT_SIZE	60
-- 
1.7.0.3

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

* [U-Boot] [PATCH 2/2] Davinci: Move config of MAC address to board setup
  2010-04-21  8:27 [U-Boot] [PATCH 0/2] Fix networking on DM365EVM andreas.gaer at baslerweb.com
  2010-04-21  8:27 ` [U-Boot] [PATCH 1/2] Davinci: Fixed wrong EMAC_MDIO_PHY_MASK andreas.gaer at baslerweb.com
@ 2010-04-21  8:27 ` andreas.gaer at baslerweb.com
  2010-04-21 17:51   ` Ben Warren
  1 sibling, 1 reply; 5+ messages in thread
From: andreas.gaer at baslerweb.com @ 2010-04-21  8:27 UTC (permalink / raw)
  To: u-boot

From: Andreas Gaeer <Andreas.Gaer@baslerweb.com>

Without this change the MAC address only gets properly set when the
ethaddr is already set in u-boot environment.

Now the board setup should do the following:
1. Put a valid ethaddr into environment (eg. by I2C EEPROM)
2. Call dv_set_mac_address() to set the address in TI EMAC driver

Signed-off-by: Andreas Gaeer <Andreas.Gaer@baslerweb.com>
---
 arch/arm/lib/board.c              |   11 -----------
 board/davinci/common/misc.c       |   16 ++++++++++++++++
 board/davinci/common/misc.h       |    1 +
 board/davinci/da830evm/da830evm.c |    8 +++-----
 board/davinci/dm365evm/dm365evm.c |   10 +++++++++-
 board/davinci/dvevm/dvevm.c       |    5 +++++
 board/davinci/sffsdr/sffsdr.c     |    5 +++++
 board/davinci/sonata/sonata.c     |    5 +++++
 drivers/net/davinci_emac.c        |    3 +++
 9 files changed, 47 insertions(+), 17 deletions(-)

diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index f5660a9..384b9e1 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -385,17 +385,6 @@ void start_armboot (void)
 	/* enable exceptions */
 	enable_interrupts ();
 
-	/* Perform network card initialisation if necessary */
-#ifdef CONFIG_DRIVER_TI_EMAC
-	/* XXX: this needs to be moved to board init */
-extern void davinci_eth_set_mac_addr (const u_int8_t *addr);
-	if (getenv ("ethaddr")) {
-		uchar enetaddr[6];
-		eth_getenv_enetaddr("ethaddr", enetaddr);
-		davinci_eth_set_mac_addr(enetaddr);
-	}
-#endif
-
 #if defined(CONFIG_DRIVER_SMC91111) || defined (CONFIG_DRIVER_LAN91C96)
 	/* XXX: this needs to be moved to board init */
 	if (getenv ("ethaddr")) {
diff --git a/board/davinci/common/misc.c b/board/davinci/common/misc.c
index 25ca326..01b1962 100644
--- a/board/davinci/common/misc.c
+++ b/board/davinci/common/misc.c
@@ -110,6 +110,22 @@ void dv_configure_mac_address(uint8_t *rom_enetaddr)
 	}
 }
 
+/* Get the MAC address from the environment and set it in the TI EMAC driver 
+ * Returns 1 when MAC could be set, 0 otherwise
+ */
+int dv_set_mac_address() {
+
+	uchar enetaddr[6];
+	if (getenv ("ethaddr")) {
+		if(eth_getenv_enetaddr("ethaddr", enetaddr)) {
+			davinci_eth_set_mac_addr(enetaddr);
+			return 1;
+		}
+	}
+	printf("Warning: Could not set MAC address!\n");
+	return 0;
+}
+
 #endif	/* DAVINCI_EMAC */
 
 /*
diff --git a/board/davinci/common/misc.h b/board/davinci/common/misc.h
index 329c369..664fca6 100644
--- a/board/davinci/common/misc.h
+++ b/board/davinci/common/misc.h
@@ -47,6 +47,7 @@ struct pinmux_resource {
 
 int dvevm_read_mac_address(uint8_t *buf);
 void dv_configure_mac_address(uint8_t *rom_enetaddr);
+int dv_set_mac_address();
 int davinci_configure_pin_mux(const struct pinmux_config *pins, int n_pins);
 int davinci_configure_pin_mux_items(const struct pinmux_resource *item,
 				    int n_items);
diff --git a/board/davinci/da830evm/da830evm.c b/board/davinci/da830evm/da830evm.c
index 6385443..aa5f6a2 100644
--- a/board/davinci/da830evm/da830evm.c
+++ b/board/davinci/da830evm/da830evm.c
@@ -207,12 +207,10 @@ int board_eth_init(bd_t *bis)
 		/* set address env if not already set */
 		dv_configure_mac_address(mac_addr);
 
-	/* read the address back from env */
-	if (!eth_getenv_enetaddr("ethaddr", mac_addr))
+	/* Set the MAC address from environment */ 
+	if(!dv_set_mac_address()) {
 		return -1;
-
-	/* provide the resulting addr to the driver */
-	davinci_eth_set_mac_addr(mac_addr);
+	}
 
 	/* enable the Ethernet switch in the 3 port PHY */
 	if (i2c_write(PHY_SW_I2C_ADDR, 0, 0,
diff --git a/board/davinci/dm365evm/dm365evm.c b/board/davinci/dm365evm/dm365evm.c
index 290eb99..579684a 100644
--- a/board/davinci/dm365evm/dm365evm.c
+++ b/board/davinci/dm365evm/dm365evm.c
@@ -70,7 +70,15 @@ int board_eth_init(bd_t *bis)
 	if (dvevm_read_mac_address(eeprom_enetaddr))
 		dv_configure_mac_address(eeprom_enetaddr);
 
-	davinci_emac_initialize();
+	/* Set the MAC address from environment */ 
+	if(!dv_set_mac_address()) {
+		return -1;
+	}
+    
+	if(davinci_emac_initialize() <= 0) {
+		printf("davinci_emac_initialize failed!\n");
+		return -1;
+	}
 
 	return 0;
 }
diff --git a/board/davinci/dvevm/dvevm.c b/board/davinci/dvevm/dvevm.c
index 98937a9..4a6e736 100644
--- a/board/davinci/dvevm/dvevm.c
+++ b/board/davinci/dvevm/dvevm.c
@@ -73,6 +73,11 @@ int misc_init_r(void)
 	if (dvevm_read_mac_address(eeprom_enetaddr))
 		dv_configure_mac_address(eeprom_enetaddr);
 
+	/* Set the MAC address from environment */ 
+	if(!dv_set_mac_address()) {
+		return -1;
+	}
+
 	i2c_read(0x39, 0x00, 1, &video_mode, 1);
 
 	setenv("videostd", ((video_mode & 0x80) ? "pal" : "ntsc"));
diff --git a/board/davinci/sffsdr/sffsdr.c b/board/davinci/sffsdr/sffsdr.c
index c24b9e1..273a42a 100644
--- a/board/davinci/sffsdr/sffsdr.c
+++ b/board/davinci/sffsdr/sffsdr.c
@@ -143,5 +143,10 @@ int misc_init_r(void)
 	if (sffsdr_read_mac_address(eeprom_enetaddr))
 		dv_configure_mac_address(eeprom_enetaddr);
 
+	/* Set the MAC address from environment */ 
+	if(!dv_set_mac_address()) {
+		return -1;
+	}
+
 	return(0);
 }
diff --git a/board/davinci/sonata/sonata.c b/board/davinci/sonata/sonata.c
index 817970a..b287acc 100644
--- a/board/davinci/sonata/sonata.c
+++ b/board/davinci/sonata/sonata.c
@@ -72,6 +72,11 @@ int misc_init_r(void)
 	if (dvevm_read_mac_address(eeprom_enetaddr))
 		dv_configure_mac_address(eeprom_enetaddr);
 
+	/* Set the MAC address from environment */ 
+	if(!dv_set_mac_address()) {
+		return -1;
+	}
+
 	return(0);
 }
 
diff --git a/drivers/net/davinci_emac.c b/drivers/net/davinci_emac.c
index 02bbb8c..21497d1 100644
--- a/drivers/net/davinci_emac.c
+++ b/drivers/net/davinci_emac.c
@@ -75,9 +75,12 @@ void davinci_eth_set_mac_addr(const u_int8_t *addr)
 {
 	int i;
 
+	debug_emac("davinci_eth_set_mac_addr(), MAC = ");
 	for (i = 0; i < sizeof (davinci_eth_mac_addr); i++) {
+		debug_emac(i ? ":%02x" : "%02x", addr[i]);
 		davinci_eth_mac_addr[i] = addr[i];
 	}
+	debug_emac("\n");
 }
 
 /* EMAC Addresses */
-- 
1.7.0.3

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

* [U-Boot] [PATCH 2/2] Davinci: Move config of MAC address to board setup
  2010-04-21  8:27 ` [U-Boot] [PATCH 2/2] Davinci: Move config of MAC address to board setup andreas.gaer at baslerweb.com
@ 2010-04-21 17:51   ` Ben Warren
  2010-04-22  9:18     ` Gaer, A.
  0 siblings, 1 reply; 5+ messages in thread
From: Ben Warren @ 2010-04-21 17:51 UTC (permalink / raw)
  To: u-boot

Andreas,

On 4/21/2010 1:27 AM, andreas.gaer at baslerweb.com wrote:
> From: Andreas Gaeer<Andreas.Gaer@baslerweb.com>
>
> Without this change the MAC address only gets properly set when the
> ethaddr is already set in u-boot environment.
>    
> Now the board setup should do the following:
> 1. Put a valid ethaddr into environment (eg. by I2C EEPROM)
> 2. Call dv_set_mac_address() to set the address in TI EMAC driver
>
>    
Please read the documentation.  This is not how it's done.  The 
programming of MAC addresses is currently in flux.  I suggest you wait a 
few days and then see if changes are needed.

regards,
Ben

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

* [U-Boot] [PATCH 2/2] Davinci: Move config of MAC address to board setup
  2010-04-21 17:51   ` Ben Warren
@ 2010-04-22  9:18     ` Gaer, A.
  0 siblings, 0 replies; 5+ messages in thread
From: Gaer, A. @ 2010-04-22  9:18 UTC (permalink / raw)
  To: u-boot

Hi Ben,

> Please read the documentation.
> This is not how it's done.

Ok, thanks for the info.

After reading doc/README.enetaddr I think I understand how it's done
right. I already have reworked my patch that way. I'll wait with
re-submitting until things have settled.

Regards,
 Andreas.

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

end of thread, other threads:[~2010-04-22  9:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-04-21  8:27 [U-Boot] [PATCH 0/2] Fix networking on DM365EVM andreas.gaer at baslerweb.com
2010-04-21  8:27 ` [U-Boot] [PATCH 1/2] Davinci: Fixed wrong EMAC_MDIO_PHY_MASK andreas.gaer at baslerweb.com
2010-04-21  8:27 ` [U-Boot] [PATCH 2/2] Davinci: Move config of MAC address to board setup andreas.gaer at baslerweb.com
2010-04-21 17:51   ` Ben Warren
2010-04-22  9:18     ` Gaer, A.

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.