da850: add board specific functions
v2 cover da850: add board specific functions
From: Manjunath Hadli <[email protected]>
There are two boards AM18xx and L138 both of which are based on da850 SOC. AM18xx 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 v1 patch set:
Manjunath Hadli (6):
da850: add new config file for AM18xx
da850: rename config file to represent OMAP-L138
da850: pass board revision info to kernel
da850: revert cache disable patch
corrected the commit message
da850: add support to read mac address from spi flash
Adressed Mike comments for removal of sprintf Adressed Mike comments for using is_valid_ethr_address
da850: read MAC address from I2C EEPROM on AM18xx EVM
board/davinci/da8xxevm/da850evm.c | 73 +++++++++++- boards.cfg | 3 +- include/configs/da850_am18xxevm.h | 253 +++++++++++++++++++++++++++++++++++++ include/configs/da850_l138evm.h | 246 ++++++++++++++++++++++++++++++++++++ include/configs/da850evm.h | 249 ------------------------------------ 5 files changed, 573 insertions(+), 251 deletions(-) create mode 100644 include/configs/da850_am18xxevm.h create mode 100644 include/configs/da850_l138evm.h delete mode 100644 include/configs/da850evm.h
PATCH v2 1/6 da850: add new config file for AM18xx
From: Manjunath Hadli <[email protected]>
add new configuration file da850_am18xxevm.h for AM18xx boards which are based on da850 SOC. AM18xx 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_am18xxevm.h | 245 +++++++++++++++++++++++++++++++++++++ 2 files changed, 246 insertions(+), 0 deletions(-) create mode 100644 include/configs/da850_am18xxevm.h
boards.cfg +1 -0
@@ -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_am18xxevm 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_am18xxevm.h new file +245 -0
245 lines not on this page · raw message
Signature · 1 line
1.6.2.4
PATCH v2 2/6 da850: rename config file to represent OMAP-L138
In reply to manjunath.hadli at ti.comFrom: 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
@@ -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_am18xxevm 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
PATCH v2 3/6 da850: pass board revision info to kernel
In reply to manjunath.hadli at ti.comFrom: Manjunath Hadli <[email protected]>
there are two boards based on da850 SOC - OMAP-L138 and AM18xx. 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_am18xxevm.h | 1 + 2 files changed, 6 insertions(+), 1 deletions(-)
board/davinci/da8xxevm/da850evm.c +5 -1
@@ -249,6 +249,8 @@ static const struct lpsc_resource lpsc[] = {#define CONFIG_DA850_EVM_MAX_CPU_CLK 300000000#endif +#define REV_AM18XX_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_AM18XX_EVM + rev |=REV_AM18XX_EVM ; +#endif return rev; }
include/configs/da850_am18xxevm.h +1 -0
@@ -43,6 +43,7 @@#define CONFIG_SYS_HZ 1000#define CONFIG_SKIP_LOWLEVEL_INIT #define CONFIG_SYS_TEXT_BASE 0xc1080000 +#define CONFIG_DA850_AM18XX_EVM /* * Memory Info
Signature · 1 line
1.6.2.4
PATCH v2 4/6 da850: revert cache disable patch
In reply to manjunath.hadli at ti.comFrom: Manjunath Hadli <[email protected]>
revert commit bd65d006a6088bcb857e079447d7549e2cd7054d as the disabling of cache need not be done explicitly. Subsequent patches to new cache management framework has fixed it. EMAC issue with cache coherency still exists when cahces are enabled.
--- include/configs/da850_l138evm.h | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
include/configs/da850_l138evm.h +0 -3
@@ -43,9 +43,6 @@#define CONFIG_SYS_HZ 1000#define CONFIG_SKIP_LOWLEVEL_INIT #define CONFIG_SYS_TEXT_BASE 0xc1080000 -#define CONFIG_SYS_ICACHE_OFF -#define CONFIG_SYS_DCACHE_OFF -#define CONFIG_SYS_L2CACHE_OFF /* * Memory Info
Signature · 1 line
1.6.2.4
PATCH v2 4/6 da850: revert cache disable patch
Quoted 5 lines · manjunath.hadli at ti.com
revert commit
bd65d006a6088bcb857e079447d7549e2cd7054das the disabling of cache need not be done explicitly. Subsequent patches to new cache management framework has fixed it. EMAC issue with cache coherency still exists when cahces are enabled.
Hi Manjunath,
A small thing, but I'd recommend you drop the sentence "Subsequent patches to new cache management framework has fixed it.", as it implies things were broken (true) and are now fixed (still not true).
In fact, would it be better to simply drop this patch from the patch series altogether, leaving the caches explicitly disabled, until such a time as the EMAC driver is fixed (I guess we are mainly waiting to see if anyone wants to tackle cache ops for the ARM926EJS) and the code has been verified with caches enabled?
Bye for now,
Signature · 3 lines
Laurence Withers, <[email protected]> http://www.guralp.com/ Direct tel:+447753988197 or tel:+443333408643 Software Engineer General support queries: <[email protected]> CMG-DCM CMG-EAM CMG-NAM
Hadli
PATCH v2 4/6 da850: revert cache disable patch
Laurence,
Quoted 6 lines · Laurence Withers
Quoted 4 lines · manjunath.hadli at ti.com
revert commit
bd65d006a6088bcb857e079447d7549e2cd7054das the disabling of cache need not be done explicitly. Subsequent patches to new cache management framework has fixed it.
EMAC issue with cache coherency still exists when cahces are enabled.
Quoted 6 lines
Hi Manjunath,
A small thing, but I'd recommend you drop the sentence "Subsequent patches to new cache management framework has fixed it.", as it implies things were broken (true) and are now fixed (still not true).
In fact, would it be better to simply drop this patch from the patch series altogether, leaving the caches explicitly disabled, until such a time as the EMAC driver is fixed (I guess we are mainly waiting to see if anyone wants to tackle cache ops for the ARM926EJS) and the code has been verified with caches enabled?
Sure. I am dropping this patch for now. We will tackle (or may be Yonuk) it Again soon.
Quoted 7 lines
Bye for now,
Signature · 3 lines
Laurence Withers, <[email protected]> http://www.guralp.com/ Direct tel:+447753988197 or tel:+443333408643 Software Engineer General support queries: <[email protected]> CMG-DCM CMG-EAM CMG-NAM
PATCH v2 5/6 da850: add support to read mac address from spi flash
In reply to manjunath.hadli at ti.comFrom: 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
@@ -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
@@ -172,6 +172,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
PATCH v2 5/6 da850: add support to read mac address from spi flash
Quoted 9 lines · Hadli
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_SPIFLASHindicating where to look mac address for.Signed-off-by Manjunathappa, Prakash <[email protected]>Signed-off-by Manjunath Hadli <[email protected]>
Sorry for the very late reply. gmail ate this email on me it seems.
[snip]
board/davinci/da8xxevm/da850evm.c const struct pinmux_config nor_pins[] = { · line 189
Quoted 10 lines
board/davinci/da8xxevm/da850evm.c +10
-0+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" );
Leading space in the printf.
Quoted 8 lines
board/davinci/da8xxevm/da850evm.c +8
-0+ 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;
board/davinci/da8xxevm/da850evm.c const struct pinmux_config nor_pins[] = { · line 207
Quoted 10 lines
board/davinci/da8xxevm/da850evm.c +10
-0+ } + +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; +}
We never called malloc() so it doesn't make sense to comment about not being able to call free() here. In fact, we should just do a 'return -1' after the printf here.
board/davinci/da8xxevm/da850evm.c static void dspwake(void) · line 265
Quoted 11 lines
board/davinci/da8xxevm/da850evm.c +4
-0+#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;
Potential unused variable warnings here.
Signature · 1 line
Tom
PATCH v2 6/6 da850: read MAC address from I2C EEPROM on AM18xx EVM
In reply to manjunath.hadli at ti.comFrom: Manjunath Hadli <[email protected]>
The AM18xx 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_am18xxevm.h | 7 +++++++ 2 files changed, 16 insertions(+), 1 deletions(-)
board/davinci/da8xxevm/da850evm.c +9 -1
@@ -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_am18xxevm.h +7 -0
@@ -93,6 +93,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
@@ -173,6 +179,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
v2 cover da850: add board specific functions
In reply to manjunath.hadli at ti.comQuoted 7 lines · manjunath.hadli at ti.com
There are two boards AM18xx and L138 both of which are based on da850 SOC. AM18xx 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.
Hi Manjunath,
Does this patchset touch SoC functionality, or just the board configs for the EVMs? If the latter, it might be better to change the patch subject. Otherwise it flags these patches as being relevant to anyone using the DA850 processor, which actually isn't the case from a quick read.
Bye for now,
Signature · 3 lines
Laurence Withers, <[email protected]> http://www.guralp.com/ Direct tel:+447753988197 or tel:+443333408643 Software Engineer General support queries: <[email protected]> CMG-DCM CMG-EAM CMG-NAM
Hadli
v2 cover da850: add board specific functions
Laurence,
Quoted 9 lines · Laurence Withers
Quoted 7 lines · manjunath.hadli at ti.com
There are two boards AM18xx and L138 both of which are based on da850 SOC. AM18xx 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.
Quoted 4 lines
Hi Manjunath,
Does this patchset touch SoC functionality, or just the board configs for the EVMs? If the latter, it might be better to change the patch subject. Otherwise it flags these patches as being relevant to anyone using the DA850 processor, which actually isn't the case from a quick read.
Thank you for the comment. I have changed the subject line from "da850" to "da850evm", which hopefully is more appropriate to mean boards based on da850.
Thanks and Regards,
-Manjunath
Quoted 7 lines
Bye for now,
Signature · 3 lines
Laurence Withers, <[email protected]> http://www.guralp.com/ Direct tel:+447753988197 or tel:+443333408643 Software Engineer General support queries: <[email protected]> CMG-DCM CMG-EAM CMG-NAM