Skip to contentSkip to conversation

da850evm: add board specific functions

PATCH Superseded Manjunath Hadli 5 participants 9 messages Feb 2, 2012 – Feb 6, 2012

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover da850evm: add board specific functions

There are two da850 SOC based EVMs, one from Spectrum digital and other from Logic PD. Boards from Spectrum digital have mac address stored in I2C EEPROM and they have spi flash manufactured by WINBOND. Boards from Logic PD store mac address in ST Microelectronics SPI flash. This patch series adds support to read mac address from the appropriate device.

These patches have undergone a review previously, but since the tree has moved ahead Christian and Tom asked to resubmit the patches for review.
(http://www.mail-archive.com/u-boot at lists.denx.de/msg76220.html)

Manjunath Hadli (2):
da850evm: add support to read mac address from spi flash
da850evm: read mac address from I2C EEPROM on AM18x EVM

 board/davinci/da8xxevm/da850evm.c |   66 +++++++++++++++++++++++++++++++++++++
 boards.cfg                        |    4 +-
 2 files changed, 68 insertions(+), 2 deletions(-)
#1 lore raw

PATCH 1/2 da850evm: add support to read mac address from spi flash

add support to read mac address for da850/L138 evm manufactued by Logic PD which store mac address in SPI flash manufactued by ST Microelectronics. This patch adds support to read mac address from spi flash and set the mac address if it hasen't been set in environmet. Introduced a config option CONFIG_MAC_ADDR_IN_SPIFLASH indicating where to look mac address for.

---
 board/davinci/da8xxevm/da850evm.c |   58 +++++++++++++++++++++++++++++++++++++
 boards.cfg                        |    2 +-
 2 files changed, 59 insertions(+), 1 deletions(-)
board/davinci/da8xxevm/da850evm.c +58 -0
index 9bd3e71..dcb22cb 100644
@@ -25,12 +25,15 @@
 #include <i2c.h>
 #include <net.h>
 #include <netdev.h>
+#include <spi.h>
+#include <spi_flash.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/emif_defs.h>
 #include <asm/arch/emac_defs.h>
 #include <asm/arch/pinmux_defs.h>
 #include <asm/io.h>
 #include <asm/arch/davinci_misc.h>
+#include <asm/errno.h>
 #include <hwconfig.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -43,6 +46,43 @@ DECLARE_GLOBAL_DATA_PTR;
 #endif
 #endif /* CONFIG_DRIVER_TI_EMAC */
 
+#define CFG_MAC_ADDR_SPI_BUS	0
+#define CFG_MAC_ADDR_SPI_CS	0
+#define CFG_MAC_ADDR_SPI_MAX_HZ	CONFIG_SF_DEFAULT_SPEED
+#define CFG_MAC_ADDR_SPI_MODE	SPI_MODE_3
+
+#define CFG_MAC_ADDR_OFFSET	(flash->size - SZ_64K)
+
+#ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
+static int get_mac_addr(u8 *addr)
+{
+	struct spi_flash *flash;
+	int ret;
+
+	flash = spi_flash_probe(CFG_MAC_ADDR_SPI_BUS, CFG_MAC_ADDR_SPI_CS,
+			CFG_MAC_ADDR_SPI_MAX_HZ, CFG_MAC_ADDR_SPI_MODE);
+	if (!flash) {
+		printf(" Error - unable to probe SPI flash.\n");
+		ret = -1;
+		goto err_probe;
+	}
+
+	ret = spi_flash_read(flash, CFG_MAC_ADDR_OFFSET, 6, addr);
+	if (ret) {
+		printf("Error - unable to read MAC address from SPI flash.\n");
+		goto err_read;
+	}
+
+err_read:
+	/* cannot call free currently since the free function calls free() for
+	 * spi_flash structure though it is not directly allocated through
+	 * malloc()
+	 */
+err_probe:
+	return ret;
+}
+#endif
+
 void dsp_lpsc_on(unsigned domain, unsigned int id)
 {
 	dv_reg_p mdstat, mdctl, ptstat, ptcmd;
@@ -98,6 +138,24 @@ static void dspwake(void)
 int misc_init_r(void)
 {
 	dspwake();
+
+#ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
+	uchar buff[8];
+	int ret;
+
+	if (!eth_getenv_enetaddr("ethaddr", buff)) {
+		ret = get_mac_addr(buff);
+		if (ret != 0)
+			return -EINVAL;
+
+		if (!is_valid_ether_addr(buff)) {
+			printf("Invalid MAC address read.\n");
+			return -EINVAL;
+		}
+
+		eth_setenv_enetaddr("ethaddr", buff);
+	}
+#endif
 	return 0;
 }
 
boards.cfg +1 -1
index 2f90dbf..ad6c5b8 100644
@@ -121,7 +121,7 @@ pm9g45                       arm         arm926ejs   pm9g45              ronetix
 cam_enc_4xx                  arm         arm926ejs   cam_enc_4xx         ait            davinci     cam_enc_4xx
 da830evm                     arm         arm926ejs   da8xxevm            davinci        davinci
 da850_am18xxevm              arm         arm926ejs   da8xxevm            davinci        davinci     da850evm:DA850_AM18X_EVM
-da850evm                     arm         arm926ejs   da8xxevm            davinci        davinci
+da850evm                     arm         arm926ejs   da8xxevm            davinci        davinci     da850evm:MAC_ADDR_IN_SPIFLASH
 davinci_dm355evm             arm         arm926ejs   dm355evm            davinci        davinci
 davinci_dm355leopard         arm         arm926ejs   dm355leopard        davinci        davinci
 davinci_dm365evm             arm         arm926ejs   dm365evm            davinci        davinci
Signature · 1 line
1.6.2.4
#2 lore raw

PATCH 1/2 da850evm: add support to read mac address from spi flash

Quoted 14 lines · On Thursday 02 February 2012 08:42:17 Manjunath Hadli wrote:
board/davinci/da8xxevm/da850evm.c +8 -0
 
 int misc_init_r(void)
 {
 	dspwake();
+
+#ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
+	uchar buff[8];
+	int ret;
+
+	if (!eth_getenv_enetaddr("ethaddr", buff)) {
+		ret = get_mac_addr(buff);
+		if (ret != 0)

board/davinci/da8xxevm/da850evm.c static void dspwake(void) · line 158

Quoted 10 lines
board/davinci/da8xxevm/da850evm.c +10 -0
+			return -EINVAL;
+
+		if (!is_valid_ether_addr(buff)) {
+			printf("Invalid MAC address read.\n");
+			return -EINVAL;
+		}
+
+		eth_setenv_enetaddr("ethaddr", buff);
+	}
+#endif

i don't think you should return -EINVAL here. just issue the warning and be done with it.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120203/8bb956c9/attachment.pgp>

#3 lore raw

PATCH 2/2 da850evm: read mac address from I2C EEPROM on AM18x EVM

In reply to Manjunath Hadli

add support to read mac address for AM18x EVM manufactured from Spectrum digital which have mac address stored in I2C EEPROM manfactured by WINBOND. This patch reads mac address from I2C EEPROM and updates environment variable if not set. Introduced a config option CONFIG_MAC_ADDR_IN_EEPROM to where to look for the mac address.

---
 board/davinci/da8xxevm/da850evm.c |   12 ++++++++++--
 boards.cfg                        |    2 +-
 2 files changed, 11 insertions(+), 3 deletions(-)
board/davinci/da8xxevm/da850evm.c +10 -2
index dcb22cb..8963243 100644
@@ -139,11 +139,12 @@ int misc_init_r(void)
 {
 	dspwake();
 
-#ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
+#if defined(CONFIG_MAC_ADDR_IN_SPIFLASH) || defined(CONFIG_MAC_ADDR_IN_EEPROM)
 	uchar buff[8];
-	int ret;
 
 	if (!eth_getenv_enetaddr("ethaddr", buff)) {
+#ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
+		int ret;
 		ret = get_mac_addr(buff);
 		if (ret != 0)
 			return -EINVAL;
@@ -154,6 +155,13 @@ int misc_init_r(void)
 		}
 
 		eth_setenv_enetaddr("ethaddr", buff);
+#else
+		uint8_t enetaddr[8];
+		/* Read Ethernet MAC address from EEPROM */
+		if (dvevm_read_mac_address(enetaddr))
+			/* Set Ethernet MAC address from EEPROM */
+			davinci_sync_env_enetaddr(enetaddr);
+#endif
 	}
 #endif
 	return 0;
boards.cfg +1 -1
index ad6c5b8..2e6d267 100644
@@ -120,7 +120,7 @@ pm9263                       arm         arm926ejs   pm9263              ronetix
 pm9g45                       arm         arm926ejs   pm9g45              ronetix        at91        pm9g45:AT91SAM9G45
 cam_enc_4xx                  arm         arm926ejs   cam_enc_4xx         ait            davinci     cam_enc_4xx
 da830evm                     arm         arm926ejs   da8xxevm            davinci        davinci
-da850_am18xxevm              arm         arm926ejs   da8xxevm            davinci        davinci     da850evm:DA850_AM18X_EVM
+da850_am18xxevm              arm         arm926ejs   da8xxevm            davinci        davinci     da850evm:DA850_AM18X_EVM,MAC_ADDR_IN_EEPROM,SYS_I2C_EEPROM_ADDR_LEN=2,SYS_I2C_EEPROM_ADDR=0x50
 da850evm                     arm         arm926ejs   da8xxevm            davinci        davinci     da850evm:MAC_ADDR_IN_SPIFLASH
 davinci_dm355evm             arm         arm926ejs   dm355evm            davinci        davinci
 davinci_dm355leopard         arm         arm926ejs   dm355leopard        davinci        davinci
Signature · 1 line
1.6.2.4
#4 lore raw

PATCH 2/2 da850evm: read mac address from I2C EEPROM on AM18x EVM

Dear Manjunath Hadli,

Quoted 8 lines · In message <[email protected]> you wrote:

add support to read mac address for AM18x EVM manufactured from Spectrum digital which have mac address stored in I2C EEPROM manfactured by WINBOND. This patch reads mac address from I2C EEPROM and updates environment variable if not set. Introduced a config option CONFIG_MAC_ADDR_IN_EEPROM to where to look for the mac address.

NAK. This has been discussed a thousand times before, so please look it up in the archives.

The environment always has precedence. If there are several places to store tha MAC address, and the values don;t match, a warning must be issued. etc.

While you are at it, the implementation of davinci_sync_env_enetaddr() should be cleaned up as well.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Fascinating, a totally parochial attitude.
	-- Spock, "Metamorphosis", stardate 3219.8
#5 lore raw

PATCH 2/2 da850evm: read mac address from I2C EEPROM on AM18x EVM

Wolfgang,

Quoted 9 lines · Wolfgang Denk

Dear Manjunath Hadli,

Quoted 6 lines · In message <[email protected]> you wrote:

add support to read mac address for AM18x EVM manufactured from Spectrum digital which have mac address stored in I2C EEPROM manfactured by WINBOND. This patch reads mac address from I2C EEPROM and updates environment variable if not set. Introduced a config option CONFIG_MAC_ADDR_IN_EEPROM to where to look for the mac address.

Quoted 7 lines
Quoted 2 lines

NAK. This has been discussed a thousand times before, so please look it up in the archives.

The environment always has precedence. If there are several places to store tha MAC address, and the values don;t match, a warning must be issued. etc.

This is not a case where we are matching the mac address with the environment variable. If the environment variable is not set we try to get it from either spi or i2c eeprom. Since da850evm/L138 have mac address stored in spi flash and am18x in i2c eeprom, picks appropriately from the source based on the configuration file setting.

Let me know if you still don't agree. If not can suggest if the environment variable is not set.

Quoted 2 lines

While you are at it, the implementation of davinci_sync_env_enetaddr() should be cleaned up as well.

Well can you put some more light on it as what cleanup is to be done ?

Regards,
--Manju

Quoted 11 lines

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de Fascinating, a totally parochial attitude.
	-- Spock, "Metamorphosis", stardate 3219.8
#6 lore raw

PATCH 2/2 da850evm: read mac address from I2C EEPROM on AM18x EVM

Dear "Hadli, Manjunath",

Quoted 10 lines · In message <[email protected]> you…
Quoted 2 lines

NAK. This has been discussed a thousand times before, so please look it

up in the archives.

Quoted 2 lines

The environment always has precedence. If there are several places to sto

re tha MAC address, and the values don;t match, a warning must be issued. e tc.

Quoted 1 line

This is not a case where we are matching the mac address with the environment variable. If the environment variable

Yes, and this is what I complain about. It should.

Quoted 4 lines

is not set we try to get it from either spi or i2c eeprom. Since da850evm/L138 have mac address stored in spi flash and am18x in i2c eeprom, picks appropriately from the source based on the configuration file setting.

If we have multiple storage for the MAC address, we should always raise a warning if these contain different information.

Quoted 3 lines
Quoted 1 line

While you are at it, the implementation of davinci_sync_env_enetaddr() sh

ould be cleaned up as well.
Well can you put some more light on it as what cleanup is to be done ?

It should test the return code of eth_getenv_enetaddr_by_index(). It should use is_valid_ether_addr().
debug() should probably be a print(). eth_setenv_enetaddr() may also return an error code.

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You might not be as stupid as you look. This is not hard. Let's think
about this. I mean ... I'll think about this, and  you  can  join  in
when you know the words.             - Terry Pratchett, _Men at Arms_
#7 lore raw

cover da850evm: add board specific functions

In reply to Manjunath Hadli

Hi,
Thank you for re-submitting the patchset!

Quoted 6 lines · Manjunath Hadli

There are two da850 SOC based EVMs, one from Spectrum digital and other from Logic PD. Boards from Spectrum digital have mac address stored in I2C EEPROM and they have spi flash manufactured by WINBOND. Boards from Logic PD store mac address in ST Microelectronics SPI flash. This patch series adds support to read mac address from the appropriate device.

Ok, so we have two configurations, we have da850evm which is for LogicPD's OMAP-L138 SoM and for LogicPD's AM1808 SoM, and we have da850_am18xxevm which must be used for the AM1808 board from Spectrum Digital. Is that correct?

I wonder if we should change the name of the da850_am18xxevm configuration. It's quite confusing, until today I thought that the da850_am18xxevm was a configuration for LogicPD's AM1808 SoM... Are there also OMAP-L138 boards from Spectrum Digital?

Regards, Christian

Quoted 18 lines

These patches have undergone a review previously, but since the tree has moved ahead Christian and Tom asked to resubmit the patches for review.
(http://www.mail-archive.com/u-boot at lists.denx.de/msg76220.html)

Manjunath Hadli (2):
?da850evm: add support to read mac address from spi flash ?da850evm: read mac address from I2C EEPROM on AM18x EVM

?board/davinci/da8xxevm/da850evm.c | ? 66 +++++++++++++++++++++++++++++++++++++ ?boards.cfg ? ? ? ? ? ? ? ? ? ? ? ?| ? ?4 +-
?2 files changed, 68 insertions(+), 2 deletions(-)

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

#8 lore raw

cover da850evm: add board specific functions

Christian,

Quoted 4 lines · Christian Riesch

Hi,
Thank you for re-submitting the patchset!

On Thu, Feb 2, 2012 at 2:42 PM, Manjunath Hadli <[email protected]> wrote:

Quoted 8 lines
Quoted 6 lines

There are two da850 SOC based EVMs, one from Spectrum digital and other from Logic PD. Boards from Spectrum digital have mac address stored in I2C EEPROM and they have spi flash manufactured by WINBOND. Boards from Logic PD store mac address in ST Microelectronics SPI flash. This patch series adds support to read mac address from the appropriate device.

Ok, so we have two configurations, we have da850evm which is for LogicPD's OMAP-L138 SoM and for LogicPD's AM1808 SoM, and we have da850_am18xxevm which must be used for the AM1808 board from Spectrum Digital. Is that correct?

Yes.

Quoted 2 lines

I wonder if we should change the name of the da850_am18xxevm configuration. It's quite confusing, until today I thought that the da850_am18xxevm was a configuration for LogicPD's AM1808 SoM... Are there also OMAP-L138 boards from Spectrum Digital?

Spectrum Digital do not have any OMAP-L138 EVMs. They have only AM18x evms.

Regards,
--Manju

Quoted 23 lines

Regards, Christian

Quoted 19 lines

These patches have undergone a review previously, but since the tree has moved ahead Christian and Tom asked to resubmit the patches for review.
(http://www.mail-archive.com/u-boot at lists.denx.de/msg76220.html)

Manjunath Hadli (2):
?da850evm: add support to read mac address from spi flash ?da850evm: read mac address from I2C EEPROM on AM18x EVM

?board/davinci/da8xxevm/da850evm.c | ? 66
+++++++++++++++++++++++++++++++++++++
?boards.cfg ? ? ? ? ? ? ? ? ? ? ? ?| ? ?4 +- ?2 files changed, 68 insertions(+), 2 deletions(-)

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot