[U-Boot] [PATCH 0/2] 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@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(-)

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.
Signed-off-by: Manjunath Hadli manjunath.hadli@ti.com Cc: Tom Rini trini@ti.com --- board/davinci/da8xxevm/da850evm.c | 58 +++++++++++++++++++++++++++++++++++++ boards.cfg | 2 +- 2 files changed, 59 insertions(+), 1 deletions(-)
diff --git a/board/davinci/da8xxevm/da850evm.c b/board/davinci/da8xxevm/da850evm.c index 9bd3e71..dcb22cb 100644 --- a/board/davinci/da8xxevm/da850evm.c +++ b/board/davinci/da8xxevm/da850evm.c @@ -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; }
diff --git a/boards.cfg b/boards.cfg index 2f90dbf..ad6c5b8 100644 --- a/boards.cfg +++ b/boards.cfg @@ -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

On Thursday 02 February 2012 08:42:17 Manjunath Hadli wrote:
--- a/board/davinci/da8xxevm/da850evm.c +++ b/board/davinci/da8xxevm/da850evm.c
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
i don't think you should return -EINVAL here. just issue the warning and be done with it. -mike

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.
Signed-off-by: Manjunath Hadli manjunath.hadli@ti.com Cc: Tom Rini trini@ti.com --- board/davinci/da8xxevm/da850evm.c | 12 ++++++++++-- boards.cfg | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/board/davinci/da8xxevm/da850evm.c b/board/davinci/da8xxevm/da850evm.c index dcb22cb..8963243 100644 --- a/board/davinci/da8xxevm/da850evm.c +++ b/board/davinci/da8xxevm/da850evm.c @@ -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; diff --git a/boards.cfg b/boards.cfg index ad6c5b8..2e6d267 100644 --- a/boards.cfg +++ b/boards.cfg @@ -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

Dear Manjunath Hadli,
In message 1328190138-5276-3-git-send-email-manjunath.hadli@ti.com 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.
Signed-off-by: Manjunath Hadli manjunath.hadli@ti.com Cc: Tom Rini trini@ti.com
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

Wolfgang,
On Fri, Feb 03, 2012 at 03:47:47, Wolfgang Denk wrote:
Dear Manjunath Hadli,
In message 1328190138-5276-3-git-send-email-manjunath.hadli@ti.com 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.
Signed-off-by: Manjunath Hadli manjunath.hadli@ti.com Cc: Tom Rini trini@ti.com
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.
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
Best regards,
Wolfgang Denk
-- 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@denx.de Fascinating, a totally parochial attitude. -- Spock, "Metamorphosis", stardate 3219.8

Dear "Hadli, Manjunath",
In message E99FAA59F8D8D34D8A118DD37F7C8F753174CF40@DBDE01.ent.ti.com you wrote:
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 sto
re tha MAC address, and the values don;t match, a warning must be issued. e tc.
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.
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.
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

Hi, Thank you for re-submitting the patchset!
On Thu, Feb 2, 2012 at 2:42 PM, Manjunath Hadli manjunath.hadli@ti.com wrote:
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
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@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@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot

Christian,
On Thu, Feb 02, 2012 at 19:56:45, Christian Riesch wrote:
Hi, Thank you for re-submitting the patchset!
On Thu, Feb 2, 2012 at 2:42 PM, Manjunath Hadli manjunath.hadli@ti.com wrote:
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.
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
Regards, Christian
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@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@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot
participants (5)
-
Christian Riesch
-
Hadli, Manjunath
-
Manjunath Hadli
-
Mike Frysinger
-
Wolfgang Denk