Skip to contentSkip to conversation

arm: socfpga: Add Cadence QSPI support

PATCH Superseded Stefan Roese 2 participants 5 messages Sep 22, 2014 – Sep 23, 2014 SPI

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover arm: socfpga: Add Cadence QSPI support

Hi SoCFPGA-developers!

I'm currently using Marek's latest SoCFPGA port. This works really great so far. Thank you all for this effort.

What I need additionally is SPI NOR flash support. So I talked a bit with Marek and tried to port the Cadence QSPI driver to mainline U-Boot (on-top of Marek's patch set of course). This version in these patches now compiles clean. And detecting of the SPI flash also works good. Reading also seems to be okay. Only easing and writing have some problems.

Perhaps somebody from Altera with deeper Cadence SPI controller knowledge can take a quick look at this. Could be a pretty obvious mistake that I made while copying / porting the code. Or something else thats simply missing.

Any hints are really appretiated!

BTW: I'm currently testing this on the EBV SoCrates board.

Thanks,
Stefan

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Vince Bridgers <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Pavel Machek <[email protected]>
#1 lore raw

PATCH 1/2 spi: Add Cadence QSPI driver used by SoCFPGA

This driver is copied directly from the Altera Rockerboard.org U-Boot repository. I used this git tag: ACDS14.0.1_REL_GSRD_RC2. With minimal changes to enable compilation in mainline U-Boot.

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Vince Bridgers <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Pavel Machek <[email protected]>
---
 drivers/spi/Makefile           |   1 +
 drivers/spi/cadence_qspi.c     | 355 ++++++++++++++++
 drivers/spi/cadence_qspi.h     |  73 ++++
 drivers/spi/cadence_qspi_apb.c | 900 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 1329 insertions(+)
 create mode 100644 drivers/spi/cadence_qspi.c
 create mode 100644 drivers/spi/cadence_qspi.h
 create mode 100644 drivers/spi/cadence_qspi_apb.c
drivers/spi/Makefile +1 -0
index f02c35a..4b7b566 100644
@@ -16,6 +16,7 @@ obj-$(CONFIG_ATMEL_DATAFLASH_SPI) += atmel_dataflash_spi.o
 obj-$(CONFIG_ATMEL_SPI) += atmel_spi.o
 obj-$(CONFIG_BFIN_SPI) += bfin_spi.o
 obj-$(CONFIG_BFIN_SPI6XX) += bfin_spi6xx.o
+obj-$(CONFIG_CADENCE_QSPI) += cadence_qspi.o cadence_qspi_apb.o
 obj-$(CONFIG_CF_SPI) += cf_spi.o
 obj-$(CONFIG_CF_QSPI) += cf_qspi.o
 obj-$(CONFIG_DAVINCI_SPI) += davinci_spi.o
drivers/spi/cadence_qspi.c new file +355 -0

355 lines not on this page · raw message

drivers/spi/cadence_qspi.h new file +73 -0

73 lines not on this page · raw message

drivers/spi/cadence_qspi_apb.c new file +900 -0

900 lines not on this page · raw message

Signature · 1 line
2.1.0
#2 lore raw

PATCH 2/2 arm: socfpga: Add Cadence QSPI support to config header

In reply to Stefan Roese
Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Vince Bridgers <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Pavel Machek <[email protected]>
---
 include/configs/socfpga_cyclone5_common.h | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
include/configs/socfpga_cyclone5_common.h +31 -0
index 3f8f91f..d183510 100644
@@ -142,6 +142,37 @@
 #endif
 
 /*
+ * QSPI support
+ */
+#ifdef CONFIG_CMD_SF
+#define CONFIG_CADENCE_QSPI
+#define CONFIG_CQSPI_BASE		(SOCFPGA_QSPI_ADDRESS)
+#define CONFIG_CQSPI_AHB_BASE		(SOCFPGA_QSPIDATA_ADDRESS)
+#define CONFIG_SPI_FLASH		/* SPI flash subsystem */
+#define CONFIG_SPI_FLASH_STMICRO	/* Micron/Numonyx flash */
+#define CONFIG_SPI_FLASH_SPANSION	/* Spansion flash */
+#define CONFIG_SPI_FLASH_MTD
+/* Flash device info */
+#define CONFIG_SF_DEFAULT_SPEED		(50000000)
+#define CONFIG_SF_DEFAULT_MODE		SPI_MODE_3
+#define CONFIG_SPI_FLASH_QUAD		(1)
+/* QSPI reference clock */
+#ifndef __ASSEMBLY__
+unsigned int cm_get_qspi_controller_clk_hz(void);
+#define CONFIG_CQSPI_REF_CLK		cm_get_qspi_controller_clk_hz()
+#endif
+/* QSPI page size and block size */
+#define CONFIG_CQSPI_PAGE_SIZE		(256)
+#define CONFIG_CQSPI_BLOCK_SIZE		(16)
+/* QSPI Delay timing */
+#define CONFIG_CQSPI_TSHSL_NS		(200)
+#define CONFIG_CQSPI_TSD2D_NS		(255)
+#define CONFIG_CQSPI_TCHSH_NS		(20)
+#define CONFIG_CQSPI_TSLCH_NS		(20)
+#define CONFIG_CQSPI_DECODER		(0)
+#endif	/* CONFIG_CMD_SF */
+
+/*
  * Serial Driver
  */
 #define CONFIG_SYS_NS16550
Signature · 1 line
2.1.0
#3 lore raw

cover arm: socfpga: Add Cadence QSPI support

In reply to Stefan Roese
Quoted 11 lines · ZY - sr

Hi SoCFPGA-developers!

I'm currently using Marek's latest SoCFPGA port. This works really great so far. Thank you all for this effort.

What I need additionally is SPI NOR flash support. So I talked a bit with Marek and tried to port the Cadence QSPI driver to mainline U-Boot (on-top of Marek's patch set of course). This version in these patches now compiles clean. And detecting of the SPI flash also works good. Reading also seems to be okay. Only easing and writing have some problems.

Quoted 7 lines

Perhaps somebody from Altera with deeper Cadence SPI controller knowledge can take a quick look at this. Could be a pretty obvious mistake that I made while copying / porting the code. Or something else thats simply missing.

Any hints are really appretiated!

Dear Stefan,

I can help to take a look as I was trying to upstream this code previously. But it was later on hold as the SPI driver / framework is under going some revamp. Hopefully I have some bandwidth tomorrow to start looking into Marek and your patches.

Chin Liang

Quoted 10 lines

BTW: I'm currently testing this on the EBV SoCrates board.

Thanks,
Stefan

Cc Chin Liang See <[email protected]>
Cc Dinh Nguyen <[email protected]>
Cc Vince Bridgers <[email protected]>
Cc Marek Vasut <[email protected]>
Cc Pavel Machek <[email protected]>
#4 lore raw

cover arm: socfpga: Add Cadence QSPI support

Hi Chin Liang,

Quoted 8 lines · Chin Liang See
Quoted 7 lines

Perhaps somebody from Altera with deeper Cadence SPI controller knowledge can take a quick look at this. Could be a pretty obvious mistake that I made while copying / porting the code. Or something else thats simply missing.

Any hints are really appretiated!

Quoted 6 lines

Dear Stefan,

I can help to take a look as I was trying to upstream this code previously. But it was later on hold as the SPI driver / framework is under going some revamp. Hopefully I have some bandwidth tomorrow to start looking into Marek and your patches.

Thanks! That would be great. I'll continue a bit this afternoon with this task as its a bit pressing right now. I'll let you know if I find the problem.

Thanks,
Stefan