Skip to contentSkip to conversation

spi:fsl_spi:Add compatibility for fsl-qspi and fsl-dspi modules driver

RFC PATCH New Chao Fu 2 participants 4 messages Jul 1, 2014 – Jul 7, 2014

Subsystems (3)
lore
Share & tools
lore

Chao Fu

author
#0 lore raw

RFC PATCH 1/3 spi:fsl_spi:Add compatibility for fsl-qspi and fsl-dspi modules driver

From: Chao Fu <[email protected]>

Freescale has some series of chips(e.g. vf610) contain two kinds of SPI modules, DSPI and QSPI. U-boot spi current code can't compile and enable the two modules at same time. So add fsl-spi-interface make two spi driver code work together.

Usage:(e.g.)
SPI bus defination can be find in SOC level:
SPI_BUS_FSL_QSPI0 0
SPI_BUS_FSL_DSPI1 1
SPI_BUS_FSL_DSPI2 2

SPI devices info can be find in board level:
AT45DB021 is on spi bus 1 cs 0 S25FL064 is on spi bus 2 cs 0 S25FL128S is on spi bus 0 cs 0

Before using any SPI bus and SPI flash, execute sf probe bus:cs in uboot cmdline Such as use S25FL064, sf probe 2:0.
Then sf read xxxx/ sf write xxxx can be excuted.

---
 drivers/spi/Makefile            |   1 +
 drivers/spi/fsl_qspi.c          |  33 ++---
 drivers/spi/fsl_spi_interface.c | 275 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 286 insertions(+), 23 deletions(-)
 create mode 100644 drivers/spi/fsl_spi_interface.c
drivers/spi/Makefile +1 -0
index b587308..9c5d25c 100644
@@ -40,4 +40,5 @@ obj-$(CONFIG_TEGRA114_SPI) += tegra114_spi.o
 obj-$(CONFIG_TI_QSPI) += ti_qspi.o
 obj-$(CONFIG_XILINX_SPI) += xilinx_spi.o
 obj-$(CONFIG_ZYNQ_SPI) += zynq_spi.o
+obj-$(CONFIG_FSL_SPI_INTERFACE) += fsl_spi_interface.o
 obj-$(CONFIG_FSL_QSPI) += fsl_qspi.o
drivers/spi/fsl_qspi.c +10 -23
index ba20bef..328f154 100644
@@ -51,14 +51,6 @@
 #define qspi_write32		out_be32
 #endif
 
-static unsigned long spi_bases[] = {
-	QSPI0_BASE_ADDR,
-};
-
-static unsigned long amba_bases[] = {
-	QSPI0_AMBA_BASE,
-};
-
 struct fsl_qspi {
 	struct spi_slave slave;
 	unsigned long reg_base;
@@ -67,6 +59,9 @@ struct fsl_qspi {
 	u8 cur_seqid;
 };
 
+unsigned long get_spi_bus_base(unsigned int bus);
+unsigned long get_qspi_amba_base(unsigned int bus);
+
 /* QSPI support swapping the flash read/write data
  * in hardware for LS102xA, but not for VF610 */
 static inline u32 qspi_endian_xchg(u32 data)
@@ -176,12 +171,7 @@ static void qspi_set_lut(struct fsl_qspi *qspi)
 	qspi_write32(&regs->lckcr, QSPI_LCKCR_LOCK);
 }
 
-void spi_init()
-{
-	/* do nothing */
-}
-
-struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
+struct spi_slave *qspi_setup_slave(unsigned int bus, unsigned int cs,
 		unsigned int max_hz, unsigned int mode)
 {
 	struct fsl_qspi *qspi;
@@ -189,15 +179,12 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 	u32 reg_val, smpr_val;
 	u32 total_size, seq_id;
 
-	if (bus >= ARRAY_SIZE(spi_bases))
-		return NULL;
-
 	qspi = spi_alloc_slave(struct fsl_qspi, bus, cs);
 	if (!qspi)
 		return NULL;
 
-	qspi->reg_base = spi_bases[bus];
-	qspi->amba_base = amba_bases[bus];
+	qspi->reg_base = get_spi_bus_base(bus);
+	qspi->amba_base = get_qspi_amba_base(bus);
 
 	qspi->slave.max_write_size = TX_BUFFER_SIZE;
 
@@ -232,14 +219,14 @@ struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
 	return &qspi->slave;
 }
 
-void spi_free_slave(struct spi_slave *slave)
+void qspi_free_slave(struct spi_slave *slave)
 {
 	struct fsl_qspi *qspi = to_qspi_spi(slave);
 
 	free(qspi);
 }
 
-int spi_claim_bus(struct spi_slave *slave)
+int qspi_claim_bus(struct spi_slave *slave)
 {
 	return 0;
 }
@@ -436,7 +423,7 @@ static void qspi_op_se(struct fsl_qspi *qspi)
 	qspi_write32(&regs->mcr, mcr_reg);
 }
 
-int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
+int qspi_xfer(struct spi_slave *slave, unsigned int bitlen,
 		const void *dout, void *din, unsigned long flags)
 {
 	struct fsl_qspi *qspi = to_qspi_spi(slave);
@@ -476,7 +463,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
 	return 0;
 }
 
-void spi_release_bus(struct spi_slave *slave)
+void qspi_release_bus(struct spi_slave *slave)
 {
 	/* Nothing to do */
 }
drivers/spi/fsl_spi_interface.c new file +275 -0

275 lines not on this page · raw message

Signature · 1 line
1.8.4
author
#1 lore raw

RFC PATCH 2/3 arm:vf610:Add SPI bus num in SOC level for SPI compatibility

From: Chao Fu <[email protected]>

Add DSPI and QSPI bus definition in SOC level.
Sf probe command parameter bus will decide which module will work.

Add register base definition.

---
 arch/arm/include/asm/arch-vf610/imx-regs.h | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/include/asm/arch-vf610/imx-regs.h +2 -0
index bd6f680..3076975 100644
@@ -95,6 +95,8 @@
 #define FEC_QUIRK_ENET_MAC
 #define I2C_QUIRK_REG
 
+#define SPI_BUS_FSL_QSPI0                               0
+
 /* MSCM interrupt rounter */
 #define MSCM_IRSPRC_CP0_EN				1
 #define MSCM_IRSPRC_NUM					112
Signature · 1 line
1.8.4
author
#2 lore raw

RFC PATCH 3/3 arm:vf610-twr:Add fsl-spi-interface config and board info

In reply to Chao Fu

From: Chao Fu <[email protected]>

Add spi device info for vf610-twr board.
Enable fsl-spi-interface for compatibility of fsl-dspi and fsl-qspi.

---
 board/freescale/vf610twr/vf610twr.c | 24 ++++++++++++++++++++++++
 include/configs/vf610twr.h          |  2 ++
 2 files changed, 26 insertions(+)
board/freescale/vf610twr/vf610twr.c +24 -0
index 54a9f2c..356fcdc 100644
@@ -402,6 +402,30 @@ int board_phy_config(struct phy_device *phydev)
 	return 0;
 }
 
+int board_spi_find_bus(unsigned int bus, unsigned int cs)
+{
+	switch(bus) {
+		case SPI_BUS_FSL_QSPI0:
+			break;
+		default:
+			return -1;
+	}
+
+	switch(bus) {
+		case SPI_BUS_FSL_QSPI0:
+			if(cs == 0)
+				return 0;
+		default:
+			return -1;
+	}
+}
+
+void board_print_spi_device(void)
+{
+	printf("VF610-TWR spi flash info:\n");
+	printf("S25FL128S is on spi bus 0 cs 0\n");
+}
+
 int board_early_init_f(void)
 {
 	clock_init();
include/configs/vf610twr.h +2 -0
index 0342550..05e2dcc 100644
@@ -68,6 +68,8 @@
 #define CONFIG_PHYLIB
 #define CONFIG_PHY_MICREL
 
+#define CONFIG_FSL_SPI_INTERFACE
+
 /* QSPI Configs*/
 #define CONFIG_FSL_QSPI
 
Signature · 1 line
1.8.4
#3 lore raw

RFC PATCH 1/3 spi:fsl_spi:Add compatibility for fsl-qspi and fsl-dspi modules driver

In reply to Chao Fu

Hi,

Quoted 6 lines · Chao Fu

From: Chao Fu <[email protected]>

Freescale has some series of chips(e.g. vf610) contain two kinds of SPI modules, DSPI and QSPI. U-boot spi current code can't compile and enable the two modules at same time. So add fsl-spi-interface make two spi driver code work together.

We are in the process of enabling driver model for SPI and SPI flash. Work in progress is at u-boot-dm.git branch 'working'.

It probably makes sense to build on that rather than introduce new infrastructure. Please let me know what you think.

Regards,
Simon