[U-Boot] da8xx: add SPI Flash support

The following patches were already sent to the Arago project, but not yet to u-boot ML to be merged into the mainline. They add support for the SPI flash. Compared to the original patches, they are only rebased on the current u-boot tree.

From: Sudhakar Rajashekhara sudhakar.raj@ti.com
Signed-off-by: Sudhakar Rajashekhara sudhakar.raj@ti.com CC: Stefano Babic sbabic@denx.de CC: Detlev Zundev dzu@denx.de CC: Ben Gardiner bengardiner@nanometrics.ca --- arch/arm/include/asm/arch-davinci/hardware.h | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/arch/arm/include/asm/arch-davinci/hardware.h b/arch/arm/include/asm/arch-davinci/hardware.h index 3520cf8..2a460b5 100644 --- a/arch/arm/include/asm/arch-davinci/hardware.h +++ b/arch/arm/include/asm/arch-davinci/hardware.h @@ -149,6 +149,7 @@ typedef volatile unsigned int * dv_reg_p; #define DAVINCI_DDR_EMIF_DATA_BASE 0xc0000000 #define DAVINCI_INTC_BASE 0xfffee000 #define DAVINCI_BOOTCFG_BASE 0x01c14000 +#define JTAG_ID_REG (DAVINCI_BOOTCFG_BASE + 0x18)
#endif /* CONFIG_SOC_DA8XX */
@@ -442,6 +443,21 @@ struct davinci_uart_ctrl_regs { #define DAVINCI_UART_PWREMU_MGMT_URRST (1 << 13) #define DAVINCI_UART_PWREMU_MGMT_UTRST (1 << 14)
+static inline int cpu_is_da830(void) +{ + unsigned int jtag_id = REG(JTAG_ID_REG); + unsigned short part_no = (jtag_id >> 12) & 0xffff; + + return ((part_no == 0xb7df) ? 1 : 0); +} +static inline int cpu_is_da850(void) +{ + unsigned int jtag_id = REG(JTAG_ID_REG); + unsigned short part_no = (jtag_id >> 12) & 0xffff; + + return ((part_no == 0xb7d1) ? 1 : 0); +} + #endif /* CONFIG_SOC_DA8XX */
#endif /* __ASM_ARCH_HARDWARE_H */

On Thu, Nov 11, 2010 at 9:38 AM, Stefano Babic sbabic@denx.de wrote:
From: Sudhakar Rajashekhara sudhakar.raj@ti.com
Signed-off-by: Sudhakar Rajashekhara sudhakar.raj@ti.com CC: Stefano Babic sbabic@denx.de CC: Detlev Zundev dzu@denx.de CC: Ben Gardiner bengardiner@nanometrics.ca
Applies cleanly to 0c0892be0d93a5a892b93739c5eb3bf692fed4ff of git://git.denx.de/u-boot.git; no checkpatch warnings.
Tested along with "[PATCH 2/2] da850: Enable SPI Flash" on da850evm with no changes to the config. SPI flash was usable as the environment and location of the u-boot image.
Tested-by: Ben Gardiner bengardiner@nanometrics.ca
Best Regards, Ben Gardiner
--- Nanometrics Inc. http://www.nanometrics.ca

The patch was already posted to the arago project, but not yet to mainline. It allows to save environment into the spi flash. Tested on LogiPD tmdxl138.
Signed-off-by: Sudhakar Rajashekhara sudhakar.raj@ti.com Signed-off-by: Stefano Babic sbabic@denx.de CC: Detlev Zundev dzu@denx.de CC: Ben Gardiner bengardiner@nanometrics.ca --- arch/arm/include/asm/arch-davinci/hardware.h | 12 ++++++++++- include/configs/da850evm.h | 28 ++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletions(-)
diff --git a/arch/arm/include/asm/arch-davinci/hardware.h b/arch/arm/include/asm/arch-davinci/hardware.h index 2a460b5..21b2076 100644 --- a/arch/arm/include/asm/arch-davinci/hardware.h +++ b/arch/arm/include/asm/arch-davinci/hardware.h @@ -133,7 +133,8 @@ typedef volatile unsigned int * dv_reg_p; #define DAVINCI_PSC1_BASE 0x01e27000 #define DAVINCI_SPI0_BASE 0x01c41000 #define DAVINCI_USB_OTG_BASE 0x01e00000 -#define DAVINCI_SPI1_BASE 0x01e12000 +#define DAVINCI_SPI1_BASE (cpu_is_da830() ? \ + 0x01e12000 : 0x01f0e000) #define DAVINCI_GPIO_BASE 0x01e26000 #define DAVINCI_EMAC_CNTRL_REGS_BASE 0x01e23000 #define DAVINCI_EMAC_WRAPPER_CNTRL_REGS_BASE 0x01e22000 @@ -364,6 +365,9 @@ struct davinci_pllc_regs { #define davinci_pllc_regs ((struct davinci_pllc_regs *)DAVINCI_PLL_CNTRL0_BASE) #define DAVINCI_PLLC_DIV_MASK 0x1f
+#define ASYNC3 get_async3_src() +#define PLL1_SYSCLK2 ((1 << 16) | 0x2) +#define DAVINCI_SPI1_CLKID (cpu_is_da830() ? 2 : ASYNC3) /* Clock IDs */ enum davinci_clk_ids { DAVINCI_SPI0_CLKID = 2, @@ -458,6 +462,12 @@ static inline int cpu_is_da850(void) return ((part_no == 0xb7d1) ? 1 : 0); }
+static inline int get_async3_src(void) +{ + return (REG(&davinci_syscfg_regs->cfgchip3) & 0x10) ? + PLL1_SYSCLK2 : 2; +} + #endif /* CONFIG_SOC_DA8XX */
#endif /* __ASM_ARCH_HARDWARE_H */ diff --git a/include/configs/da850evm.h b/include/configs/da850evm.h index 7b04be0..8e273b4 100644 --- a/include/configs/da850evm.h +++ b/include/configs/da850evm.h @@ -27,6 +27,7 @@ * Board */ #define CONFIG_DRIVER_TI_EMAC +#define CONFIG_USE_SPIFLASH
/* * SoC Configuration @@ -71,6 +72,15 @@ #define CONFIG_BAUDRATE 115200 /* Default baud rate */ #define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
+#define CONFIG_SPI +#define CONFIG_SPI_FLASH +#define CONFIG_SPI_FLASH_STMICRO +#define CONFIG_DAVINCI_SPI +#define CONFIG_SYS_SPI_BASE DAVINCI_SPI1_BASE +#define CONFIG_SYS_SPI_CLK clk_get(DAVINCI_SPI1_CLKID) +#define CONFIG_SF_DEFAULT_SPEED 30000000 +#define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED + /* * I2C Configuration */ @@ -116,6 +126,16 @@ #define CONFIG_NET_MULTI #endif
+#ifdef CONFIG_USE_SPIFLASH +#undef CONFIG_ENV_IS_IN_FLASH +#undef CONFIG_ENV_IS_IN_NAND +#define CONFIG_ENV_IS_IN_SPI_FLASH +#define CONFIG_ENV_SIZE (64 << 10) +#define CONFIG_ENV_OFFSET (256 << 10) +#define CONFIG_ENV_SECT_SIZE (64 << 10) +#define CONFIG_SYS_NO_FLASH +#endif + /* * U-Boot general configuration */ @@ -179,6 +199,14 @@ #define CONFIG_CMD_UBIFS #endif
+#ifdef CONFIG_USE_SPIFLASH +#undef CONFIG_CMD_IMLS +#undef CONFIG_CMD_FLASH +#define CONFIG_CMD_SPI +#define CONFIG_CMD_SF +#define CONFIG_CMD_SAVEENV +#endif + #if !defined(CONFIG_USE_NAND) && \ !defined(CONFIG_USE_NOR) && \ !defined(CONFIG_USE_SPIFLASH)

Hi Stefano,
The patch was already posted to the arago project, but not yet to mainline. It allows to save environment into the spi flash. Tested on LogiPD tmdxl138.
If this patch is only "transferred" by you, then please do not change the commit message so that (ideally) one can trace a commit through trees using the messages. Add such additional (transient) information below the "--" in the mail so it will not get into the repository.
Thanks! Detlev

On 11/11/2010 03:55 PM, Detlev Zundel wrote:
If this patch is only "transferred" by you, then please do not change the commit message so that (ideally) one can trace a commit through trees using the messages.
Agree, this is the case of the first patch in the patchset. However, this patch has some slight changes and it will be erroneous to think that it is exactly the same. I think the best solution is to add the original commit message to mine, and grepping for the original message will still work. I'll do in V2.
Best regards, Stefano Babic

The patch was already posted to the arago project, but not yet to mainline, with the following message:
da850: Enable SPI in configuration file
It allows to save environment into the spi flash. Tested on LogiPD tmdxl138 board.
Signed-off-by: Sudhakar Rajashekhara sudhakar.raj@ti.com Signed-off-by: Stefano Babic sbabic@denx.de CC: Detlev Zundev dzu@denx.de Tested-by: Ben Gardiner bengardiner@nanometrics.ca --- Changed since V1: - commit message contains original message from Arago project (Detlev Zundev) - protect SPI definitions with #CONFIG_USE_SPIFLASH (Ben Gardiner)
arch/arm/include/asm/arch-davinci/hardware.h | 12 +++++++++- include/configs/da850evm.h | 30 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletions(-)
diff --git a/arch/arm/include/asm/arch-davinci/hardware.h b/arch/arm/include/asm/arch-davinci/hardware.h index 2a460b5..21b2076 100644 --- a/arch/arm/include/asm/arch-davinci/hardware.h +++ b/arch/arm/include/asm/arch-davinci/hardware.h @@ -133,7 +133,8 @@ typedef volatile unsigned int * dv_reg_p; #define DAVINCI_PSC1_BASE 0x01e27000 #define DAVINCI_SPI0_BASE 0x01c41000 #define DAVINCI_USB_OTG_BASE 0x01e00000 -#define DAVINCI_SPI1_BASE 0x01e12000 +#define DAVINCI_SPI1_BASE (cpu_is_da830() ? \ + 0x01e12000 : 0x01f0e000) #define DAVINCI_GPIO_BASE 0x01e26000 #define DAVINCI_EMAC_CNTRL_REGS_BASE 0x01e23000 #define DAVINCI_EMAC_WRAPPER_CNTRL_REGS_BASE 0x01e22000 @@ -364,6 +365,9 @@ struct davinci_pllc_regs { #define davinci_pllc_regs ((struct davinci_pllc_regs *)DAVINCI_PLL_CNTRL0_BASE) #define DAVINCI_PLLC_DIV_MASK 0x1f
+#define ASYNC3 get_async3_src() +#define PLL1_SYSCLK2 ((1 << 16) | 0x2) +#define DAVINCI_SPI1_CLKID (cpu_is_da830() ? 2 : ASYNC3) /* Clock IDs */ enum davinci_clk_ids { DAVINCI_SPI0_CLKID = 2, @@ -458,6 +462,12 @@ static inline int cpu_is_da850(void) return ((part_no == 0xb7d1) ? 1 : 0); }
+static inline int get_async3_src(void) +{ + return (REG(&davinci_syscfg_regs->cfgchip3) & 0x10) ? + PLL1_SYSCLK2 : 2; +} + #endif /* CONFIG_SOC_DA8XX */
#endif /* __ASM_ARCH_HARDWARE_H */ diff --git a/include/configs/da850evm.h b/include/configs/da850evm.h index 7b04be0..80cae34 100644 --- a/include/configs/da850evm.h +++ b/include/configs/da850evm.h @@ -27,6 +27,7 @@ * Board */ #define CONFIG_DRIVER_TI_EMAC +#define CONFIG_USE_SPIFLASH
/* * SoC Configuration @@ -71,6 +72,17 @@ #define CONFIG_BAUDRATE 115200 /* Default baud rate */ #define CONFIG_SYS_BAUDRATE_TABLE { 9600, 19200, 38400, 57600, 115200 }
+#ifdef CONFIG_USE_SPIFLASH +#define CONFIG_SPI +#define CONFIG_SPI_FLASH +#define CONFIG_SPI_FLASH_STMICRO +#define CONFIG_DAVINCI_SPI +#define CONFIG_SYS_SPI_BASE DAVINCI_SPI1_BASE +#define CONFIG_SYS_SPI_CLK clk_get(DAVINCI_SPI1_CLKID) +#define CONFIG_SF_DEFAULT_SPEED 30000000 +#define CONFIG_ENV_SPI_MAX_HZ CONFIG_SF_DEFAULT_SPEED +#endif + /* * I2C Configuration */ @@ -116,6 +128,16 @@ #define CONFIG_NET_MULTI #endif
+#ifdef CONFIG_USE_SPIFLASH +#undef CONFIG_ENV_IS_IN_FLASH +#undef CONFIG_ENV_IS_IN_NAND +#define CONFIG_ENV_IS_IN_SPI_FLASH +#define CONFIG_ENV_SIZE (64 << 10) +#define CONFIG_ENV_OFFSET (256 << 10) +#define CONFIG_ENV_SECT_SIZE (64 << 10) +#define CONFIG_SYS_NO_FLASH +#endif + /* * U-Boot general configuration */ @@ -179,6 +201,14 @@ #define CONFIG_CMD_UBIFS #endif
+#ifdef CONFIG_USE_SPIFLASH +#undef CONFIG_CMD_IMLS +#undef CONFIG_CMD_FLASH +#define CONFIG_CMD_SPI +#define CONFIG_CMD_SF +#define CONFIG_CMD_SAVEENV +#endif + #if !defined(CONFIG_USE_NAND) && \ !defined(CONFIG_USE_NOR) && \ !defined(CONFIG_USE_SPIFLASH)

On Fri, Nov 12, 2010 at 11:38 AM, Stefano Babic sbabic@denx.de wrote:
The patch was already posted to the arago project, but not yet to mainline, with the following message:
da850: Enable SPI in configuration file
It allows to save environment into the spi flash. Tested on LogiPD tmdxl138 board.
Signed-off-by: Sudhakar Rajashekhara sudhakar.raj@ti.com Signed-off-by: Stefano Babic sbabic@denx.de CC: Detlev Zundev dzu@denx.de Tested-by: Ben Gardiner bengardiner@nanometrics.ca
Changed since V1: - commit message contains original message from Arago project (Detlev Zundev) - protect SPI definitions with #CONFIG_USE_SPIFLASH (Ben Gardiner)
Thanks, Stefano.
This version is still good for me.
Best Regards, Ben Gardiner
--- Nanometrics Inc. http://www.nanometrics.ca
participants (3)
-
Ben Gardiner
-
Detlev Zundel
-
Stefano Babic