Skip to contentSkip to conversation

da850evm: add board specific functions

PATCH New manjunath.hadli at ti.com 2 participants 7 messages Oct 11, 2011 – Dec 5, 2011

lore
Share & tools
lore
#0 lore raw

v3 cover da850evm: add board specific functions

From: Manjunath Hadli <[email protected]>

There are two boards AM18x and L138 both of which are based on da850 SOC. AM18x boards have mac address stored in I2C EEPROM and they have spi flash manufactured by WINBOND. L138 boards store mac address in SPI flash and they have SPI flash manufactured by ST Microelectronics.Due to these differences, instead of one config file, two config files are introduced to manage configs specific to board types.

Changes from previous revision v2:
1. Changed "da850" to "da850evm" in cover letter and subsequent patches.
2. Dropped cache disabling patch as suggested by Laurence

Manjunath Hadli (5):
da850evm: add new config file for AM18x
da850evm: rename config file to represent OMAP-L138
da850evm: pass board revision info to kernel
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 |   73 +++++++++++-
 boards.cfg                        |    3 +-
 include/configs/da850_am18xevm.h  |  252 +++++++++++++++++++++++++++++++++++++
 include/configs/da850_l138evm.h   |  249 ++++++++++++++++++++++++++++++++++++
 include/configs/da850evm.h        |  249 ------------------------------------
 5 files changed, 575 insertions(+), 251 deletions(-)
 create mode 100644 include/configs/da850_am18xevm.h
 create mode 100644 include/configs/da850_l138evm.h
 delete mode 100644 include/configs/da850evm.h
#1 lore raw

PATCH v3 1/5 da850evm: add new config file for AM18x

From: Manjunath Hadli <[email protected]>

add new configuration file da850_am18xevm.h for AM18x boards which are based on da850 SOC. AM18x has WINBOND spi flash which is indicated in the config file. And make appropriate changes in board.cfg for building.

---
 boards.cfg                       |    1 +
 include/configs/da850_am18xevm.h |  245 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 246 insertions(+), 0 deletions(-)
 create mode 100644 include/configs/da850_am18xevm.h
boards.cfg +1 -0
index b1be62e..2f581c9 100644
@@ -116,6 +116,7 @@ pm9263                       arm         arm926ejs   pm9263              ronetix
 pm9g45                       arm         arm926ejs   pm9g45              ronetix        at91        pm9g45:AT91SAM9G45
 da830evm                     arm         arm926ejs   da8xxevm            davinci        davinci
 da850evm                     arm         arm926ejs   da8xxevm            davinci        davinci
+da850_am18xevm               arm         arm926ejs   da8xxevm            davinci        davinci
 hawkboard                    arm         arm926ejs   da8xxevm            davinci        davinci
 hawkboard_nand               arm         arm926ejs   da8xxevm            davinci        davinci     hawkboard:NAND_U_BOOT
 hawkboard_uart               arm         arm926ejs   da8xxevm            davinci        davinci     hawkboard:UART_U_BOOT
include/configs/da850_am18xevm.h new file +245 -0

245 lines not on this page · raw message

Signature · 1 line
1.6.2.4
#2 lore raw

PATCH v3 2/5 da850evm: rename config file to represent OMAP-L138

In reply to manjunath.hadli at ti.com

From: Manjunath Hadli <[email protected]>

rename config file da850evm.h as da850_l138evm.h to represent omap l138 board based on da850 SOC. L138 boards dont have WINBOND SPI flash, corresponding config is removed. Appropriate changes are made in boards.cfg for building.

---
 boards.cfg                      |    2 +-
 include/configs/da850_l138evm.h |  248 ++++++++++++++++++++++++++++++++++++++
 include/configs/da850evm.h      |  249 ---------------------------------------
 3 files changed, 249 insertions(+), 250 deletions(-)
 create mode 100644 include/configs/da850_l138evm.h
 delete mode 100644 include/configs/da850evm.h
boards.cfg +1 -1
index 2f581c9..ff71b67 100644
@@ -115,7 +115,7 @@ pm9261                       arm         arm926ejs   pm9261              ronetix
 pm9263                       arm         arm926ejs   pm9263              ronetix        at91        pm9263:AT91SAM9263
 pm9g45                       arm         arm926ejs   pm9g45              ronetix        at91        pm9g45:AT91SAM9G45
 da830evm                     arm         arm926ejs   da8xxevm            davinci        davinci
-da850evm                     arm         arm926ejs   da8xxevm            davinci        davinci
+da850_l138evm                arm         arm926ejs   da8xxevm            davinci        davinci
 da850_am18xevm               arm         arm926ejs   da8xxevm            davinci        davinci
 hawkboard                    arm         arm926ejs   da8xxevm            davinci        davinci
 hawkboard_nand               arm         arm926ejs   da8xxevm            davinci        davinci     hawkboard:NAND_U_BOOT
include/configs/da850_l138evm.h new file +248 -0

248 lines not on this page · raw message

include/configs/da850evm.h deleted +0 -249

249 lines not on this page · raw message

Signature · 1 line
1.6.2.4
#3 lore raw

PATCH v3 2/5 da850evm: rename config file to represent OMAP-L138

Quoted 8 lines · Hadli

From: Manjunath Hadli <[email protected]>

rename config file da850evm.h as da850_l138evm.h to represent omap l138 board based on da850 SOC. L138 boards dont have WINBOND SPI flash, corresponding config is removed. Appropriate changes are made in boards.cfg for building.

Sorry for the late reply. I see that in the new config all of the CONFIG_SPI and related options still exist. Please update, thanks.

Signature · 1 line
Tom
#4 lore raw

PATCH v3 3/5 da850evm: pass board revision info to kernel

In reply to manjunath.hadli at ti.com

From: Manjunath Hadli <[email protected]>

there are two boards based on da850 SOC - OMAP-L138 and AM18x. In order to differentiate between these two boards, revision id is passed to kernel via second byte of ATAG_REVISION.

---
 board/davinci/da8xxevm/da850evm.c |    6 +++++-
 include/configs/da850_am18xevm.h  |    2 +-
 2 files changed, 6 insertions(+), 2 deletions(-)
board/davinci/da8xxevm/da850evm.c +5 -1
index 46924d3..34673bf 100644
@@ -249,6 +249,8 @@ static const struct lpsc_resource lpsc[] = {
 #define CONFIG_DA850_EVM_MAX_CPU_CLK	300000000
 #endif
 
+#define REV_AM18X_EVM		0x100
+
 /*
  * get_board_rev() - setup to pass kernel board revision information
  * Returns:
@@ -274,7 +276,9 @@ u32 get_board_rev(void)
 		rev = 2;
 	else if (maxcpuclk >= 372000000)
 		rev = 1;
-
+#ifdef CONFIG_DA850_AM18X_EVM
+	rev |= REV_AM18X_EVM;
+#endif
 	return rev;
 }
 
include/configs/da850_am18xevm.h +1 -1
index 92b83ff..ee574da 100644
@@ -43,7 +43,7 @@
 #define CONFIG_SYS_HZ			1000
 #define CONFIG_SKIP_LOWLEVEL_INIT
 #define CONFIG_SYS_TEXT_BASE		0xc1080000
-
+#define CONFIG_DA850_AM18X_EVM
 /*
  * Memory Info
  */
Signature · 1 line
1.6.2.4
#5 lore raw

PATCH v3 4/5 da850evm: add support to read mac address from spi flash

In reply to manjunath.hadli at ti.com

From: Manjunath Hadli <[email protected]>

add support to read mac address from spi flash if env variable is not set. This is supported only on L138 boards based on da850 SOC. Introduced a macro CONFIG_MAC_ADDR_IN_SPIFLASH indicating where to look mac address for.

---
 board/davinci/da8xxevm/da850evm.c |   59 +++++++++++++++++++++++++++++++++++++
 include/configs/da850_l138evm.h   |    1 +
 2 files changed, 60 insertions(+), 0 deletions(-)
board/davinci/da8xxevm/da850evm.c +59 -0
index 34673bf..6aa76cb 100644
@@ -25,10 +25,13 @@
 #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/io.h>
+#include <asm/errno.h>
 #include <asm/arch/davinci_misc.h>
 #include <hwconfig.h>
 
@@ -166,6 +169,44 @@ const struct pinmux_config nor_pins[] = {
 #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;
@@ -220,7 +261,25 @@ static void dspwake(void)
 
 int misc_init_r(void)
 {
+	uchar buff[8];
+	int ret;
+
 	dspwake();
+
+#ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
+	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;
 }
 
include/configs/da850_l138evm.h +1 -0
index 347893c..929d0a4 100644
@@ -175,6 +175,7 @@
 #define CONFIG_SYS_LONGHELP
 #define CONFIG_CRC32_VERIFY
 #define CONFIG_MX_CYCLIC
+#define CONFIG_MAC_ADDR_IN_SPIFLASH
 
 /*
  * Linux Information
Signature · 1 line
1.6.2.4
#6 lore raw

PATCH v3 5/5 da850evm: read MAC address from I2C EEPROM on AM18x EVM

In reply to manjunath.hadli at ti.com

From: Manjunath Hadli <[email protected]>

The AM18x EVM contains MAC address in I2C EEPROM. Introduced a new macro CONFIG_MAC_ADDR_IN_EEPROM to where to look for mac address. This patch reads MAC address from I2C EEPROM and updates environment variable.

---
 board/davinci/da8xxevm/da850evm.c |   10 +++++++++-
 include/configs/da850_am18xevm.h  |    7 +++++++
 2 files changed, 16 insertions(+), 1 deletions(-)
board/davinci/da8xxevm/da850evm.c +9 -1
index 6aa76cb..f3e50f7 100644
@@ -261,13 +261,15 @@ static void dspwake(void)
 
 int misc_init_r(void)
 {
+	uint8_t enetaddr[8];
 	uchar buff[8];
 	int ret;
 
 	dspwake();
 
-#ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
+#if defined(CONFIG_MAC_ADDR_IN_SPIFLASH) || defined(CONFIG_MAC_ADDR_IN_EEPROM)
 	if (!eth_getenv_enetaddr("ethaddr", buff)) {
+#ifdef CONFIG_MAC_ADDR_IN_SPIFLASH
 		ret = get_mac_addr(buff);
 		if (ret != 0)
 			return -EINVAL;
@@ -278,6 +280,12 @@ int misc_init_r(void)
 		}
 
 		eth_setenv_enetaddr("ethaddr", buff);
+#else
+		/* 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;
include/configs/da850_am18xevm.h +7 -0
index ee574da..7f88424 100644
@@ -92,6 +92,12 @@
 #define CONFIG_SYS_I2C_EXPANDER_ADDR   0x20
 
 /*
+ * I2C EEPROM definitions EEPROM chip
+ */
+#define CONFIG_SYS_I2C_EEPROM_ADDR_LEN		2
+#define CONFIG_SYS_I2C_EEPROM_ADDR		0x50
+
+/*
  * Flash & Environment
  */
 #ifdef CONFIG_USE_NAND
@@ -172,6 +178,7 @@
 #define CONFIG_SYS_LONGHELP
 #define CONFIG_CRC32_VERIFY
 #define CONFIG_MX_CYCLIC
+#define CONFIG_MAC_ADDR_IN_EEPROM
 
 /*
  * Linux Information
Signature · 1 line
1.6.2.4