Skip to contentSkip to conversation

da830: add support to read mac addr from EEPROM

PATCH New nagabhushana.netagunte at ti.com 4 participants 4 messages Sep 30, 2011 – Oct 4, 2011

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 da830: add support to read mac addr from EEPROM

From: Nagabhushana Netagunte <[email protected]>

da830 boards have mac address stored in I2C EEPROM. This patch adds support to restore mac address from EEPROM if environment variable 'ethaddr' is not set.

---
 board/davinci/da8xxevm/da830evm.c |   20 ++++++++++++++++++++
 include/configs/da830evm.h        |    1 +
 2 files changed, 21 insertions(+), 0 deletions(-)
board/davinci/da8xxevm/da830evm.c +20 -0
index 0650653..69ed293 100644
@@ -188,6 +188,26 @@ int board_init(void)
 
 #define PHY_SW_I2C_ADDR	0x5f /* Address of PHY on i2c bus */
 
+int misc_init_r(void)
+{
+	uint8_t eeprom_enetaddr[6];
+	uint8_t val[2];
+
+	if (!eth_getenv_enetaddr("ethaddr", eeprom_enetaddr)) {
+		/* Read Ethernet MAC address from EEPROM if available. */
+		if (dvevm_read_mac_address(eeprom_enetaddr))
+			/* Set Ethernet MAC address from EEPROM */
+			davinci_sync_env_enetaddr(eeprom_enetaddr);
+	}
+
+	val[0] = 0x01;
+	val[1] = 0x23;
+
+	if (i2c_write(PHY_SW_I2C_ADDR, 0, 0, val, 2))
+		printf("Ethernet switch start failed!\n");
+
+}
+
 /*
  * Initializes on-board ethernet controllers.
  */
include/configs/da830evm.h +1 -0
index 66fdea2..a451513 100644
@@ -160,6 +160,7 @@
 /*
  * U-Boot general configuration
  */
+#define CONFIG_MISC_INIT_R
 #undef CONFIG_USE_IRQ			/* No IRQ/FIQ in U-Boot */
 #undef CONFIG_MISC_INIT_R
 #undef CONFIG_BOOTDELAY
Signature · 1 line
1.6.2.4
#1 lore raw

PATCH 1/1 da830: add support to read mac addr from EEPROM

board/davinci/da8xxevm/da830evm.c

Quoted 2 lines · On Friday, September 30, 2011 07:39:59 nagabhushana.netagunte at ti.com wrote:
board/davinci/da8xxevm/da830evm.c +0 -0

this code looks fine ...

include/configs/da830evm.h line 165

Quoted 5 lines
include/configs/da830evm.h +1 -0
 
+#define CONFIG_MISC_INIT_R
 #undef CONFIG_MISC_INIT_R

but NAK on this since i'm pretty sure this isn't doing what you're expecting -mike

#2 lore raw

PATCH 1/1 da830: add support to read mac addr from EEPROM

In reply to nagabhushana.netagunte at ti.com
Quoted 31 lines · nagabhushana.netagunte at ti.com

From: Nagabhushana Netagunte <[email protected]>

da830 boards have mac address stored in I2C EEPROM. This patch adds support to restore mac address from EEPROM if environment variable 'ethaddr' is not set.

---
 board/davinci/da8xxevm/da830evm.c |   20 ++++++++++++++++++++
 include/configs/da830evm.h        |    1 +
 2 files changed, 21 insertions(+), 0 deletions(-)
board/davinci/da8xxevm/da830evm.c +10 -0
index 0650653..69ed293 100644
@@ -188,6 +188,26 @@ int board_init(void)
 
 #define PHY_SW_I2C_ADDR	0x5f /* Address of PHY on i2c bus */
 
+int misc_init_r(void)
+{
+	uint8_t eeprom_enetaddr[6];
+	uint8_t val[2];
+
+	if (!eth_getenv_enetaddr("ethaddr", eeprom_enetaddr)) {
+		/* Read Ethernet MAC address from EEPROM if available. */
+		if (dvevm_read_mac_address(eeprom_enetaddr))
+			/* Set Ethernet MAC address from EEPROM */
+			davinci_sync_env_enetaddr(eeprom_enetaddr);

board/davinci/da8xxevm/da830evm.c int board_init(void) · line 210

Quoted 10 lines
board/davinci/da8xxevm/da830evm.c +10 -0
+	}
+
+	val[0] = 0x01;
+	val[1] = 0x23;
+
+	if (i2c_write(PHY_SW_I2C_ADDR, 0, 0, val, 2))
+		printf("Ethernet switch start failed!\n");
+
+}
+

There is already code to do this, in the same file, in board_eth_init(). Why the new code?

Nick.

Quoted 15 lines
board/davinci/da8xxevm/da830evm.c +0 -0
 /*
  * Initializes on-board ethernet controllers.
  */
include/configs/da830evm.h +1 -0
index 66fdea2..a451513 100644
@@ -160,6 +160,7 @@
 /*
  * U-Boot general configuration
  */
+#define CONFIG_MISC_INIT_R
 #undef CONFIG_USE_IRQ			/* No IRQ/FIQ in U-Boot */
 #undef CONFIG_MISC_INIT_R
 #undef CONFIG_BOOTDELAY
#3 lore raw

PATCH 1/1 da830: add support to read mac addr from EEPROM

Hi Nick,

Quoted 37 lines · Nick Thompson
Quoted 36 lines · nagabhushana.netagunte at ti.com

From: Nagabhushana Netagunte <[email protected]>

da830 boards have mac address stored in I2C EEPROM. This patch adds support to restore mac address from EEPROM if environment variable 'ethaddr' is not set.

---
 board/davinci/da8xxevm/da830evm.c |   20 ++++++++++++++++++++
 include/configs/da830evm.h        |    1 +
 2 files changed, 21 insertions(+), 0 deletions(-)
board/davinci/da8xxevm/da830evm.c +14 -0
index 0650653..69ed293 100644
@@ -188,6 +188,26 @@ int board_init(void)
 
 #define PHY_SW_I2C_ADDR	0x5f /* Address of PHY on i2c bus */
 
+int misc_init_r(void)
+{
+	uint8_t eeprom_enetaddr[6];
+	uint8_t val[2];
+
+	if (!eth_getenv_enetaddr("ethaddr", eeprom_enetaddr)) {
+		/* Read Ethernet MAC address from EEPROM if available. */
+		if (dvevm_read_mac_address(eeprom_enetaddr))
+			/* Set Ethernet MAC address from EEPROM */
+			davinci_sync_env_enetaddr(eeprom_enetaddr);
+	}
+
+	val[0] = 0x01;
+	val[1] = 0x23;
Quoted 8 lines

board/davinci/da8xxevm/da830evm.c int board_init(void) · line 210

Quoted 6 lines
board/davinci/da8xxevm/da830evm.c +6 -0
+
+	if (i2c_write(PHY_SW_I2C_ADDR, 0, 0, val, 2))
+		printf("Ethernet switch start failed!\n");
+
+}
+

There is already code to do this, in the same file, in board_eth_init(). Why the new code?

My bad. Will correct it.

Rgds,
Nag

Quoted 20 lines

Nick.

Quoted 15 lines
board/davinci/da8xxevm/da830evm.c +0 -0
 /*
  * Initializes on-board ethernet controllers.
  */
include/configs/da830evm.h +1 -0
index 66fdea2..a451513 100644
@@ -160,6 +160,7 @@
 /*
  * U-Boot general configuration
  */
+#define CONFIG_MISC_INIT_R
 #undef CONFIG_USE_IRQ			/* No IRQ/FIQ in U-Boot */
 #undef CONFIG_MISC_INIT_R
 #undef CONFIG_BOOTDELAY