Skip to contentSkip to conversation

da8xx: add SPI Flash support

U-Boot New Stefano Babic 3 participants 8 messages Nov 11, 2010 – Nov 12, 2010 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

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.

#1 lore raw

PATCH 1/2 da8xx: Add cpu_is_da8xx macros

From: Sudhakar Rajashekhara <[email protected]>

CC Stefano Babic <[email protected]>
CC Detlev Zundev <[email protected]>
CC Ben Gardiner <[email protected]>
---
 arch/arm/include/asm/arch-davinci/hardware.h |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
arch/arm/include/asm/arch-davinci/hardware.h +16 -0
index 3520cf8..2a460b5 100644
@@ -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 */
Signature · 1 line
1.7.1
#2 lore raw

PATCH 1/2 da8xx: Add cpu_is_da8xx macros

Quoted 6 lines · Stefano Babic

From: Sudhakar Rajashekhara <[email protected]>

CC Stefano Babic <[email protected]>
CC Detlev Zundev <[email protected]>
CC Ben Gardiner <[email protected]>

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.

Best Regards,
Ben Gardiner

---
Nanometrics Inc.
http://www.nanometrics.ca

#3 lore raw

PATCH 2/2 da850: Enable SPI Flash

In reply to Stefano Babic

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.

---
 arch/arm/include/asm/arch-davinci/hardware.h |   12 ++++++++++-
 include/configs/da850evm.h                   |   28 ++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletions(-)
arch/arm/include/asm/arch-davinci/hardware.h +11 -1
index 2a460b5..21b2076 100644
@@ -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 */
include/configs/da850evm.h +28 -0
index 7b04be0..8e273b4 100644
@@ -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)
Signature · 1 line
1.7.1
#4 lore raw

PATCH 2/2 da850: Enable SPI Flash

Hi Stefano,

Quoted 3 lines

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

Signature · 6 lines
Q: What do you get when you cross an elephant and a banana?
A: |elephant| * |banana| * sin(theta)
--
DENX Software Engineering GmbH,      MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich,  Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-40 Fax: (+49)-8142-66989-80 Email: dzu at denx.de
#5 lore raw

PATCH 2/2 da850: Enable SPI Flash

Quoted 3 lines · Detlev Zundel

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

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-0 Fax: +49-8142-66989-80  Email: office at denx.de
=====================================================================
#6 lore raw

PATCH v2 2/2 da850: Enable SPI Flash

In reply to 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.

---
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(-)
arch/arm/include/asm/arch-davinci/hardware.h +11 -1
index 2a460b5..21b2076 100644
@@ -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 */
include/configs/da850evm.h +30 -0
index 7b04be0..80cae34 100644
@@ -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)
Signature · 1 line
1.7.1
#7 lore raw

PATCH v2 2/2 da850: Enable SPI Flash

Quoted 12 lines · 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.

Quoted 6 lines

---
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