Skip to contentSkip to conversation

driver/spi: fsl_qspi: Remove non-DM stuff

PATCH New Ashish Kumar 3 participants 4 messages Sep 7, 2018 – Dec 4, 2018 SPI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 driver/spi: fsl_qspi: Remove non-DM stuff

Convert fsl_qspi.c to complete DM mode.

---

Tested on LS1088ARDB(arm64).
Tested on LS1021ATWR(arm32) by Rajat
Tested on i.mx6 and i.mx7 by Ye Li

Depends on patch series:
http://patchwork.ozlabs.org/patch/935858/
http://patchwork.ozlabs.org/patch/935860/

 drivers/spi/fsl_qspi.c | 138 -----------------------------------------
 1 file changed, 138 deletions(-)
drivers/spi/fsl_qspi.c +0 -138
index 197f41f9db..1598c4f698 100644
@@ -84,7 +84,6 @@ DECLARE_GLOBAL_DATA_PTR;
 /* QSPI max chipselect signals number */
 #define FSL_QSPI_MAX_CHIPSELECT_NUM     4
 
-#ifdef CONFIG_DM_SPI
 /**
  * struct fsl_qspi_platdata - platform data for Freescale QSPI
  *
@@ -105,7 +104,6 @@ struct fsl_qspi_platdata {
 	u32 flash_num;
 	u32 num_chipselect;
 };
-#endif
 
 /**
  * struct fsl_qspi_priv - private data for Freescale QSPI
@@ -136,12 +134,6 @@ struct fsl_qspi_priv {
 	struct fsl_qspi_regs *regs;
 };
 
-#ifndef CONFIG_DM_SPI
-struct fsl_qspi {
-	struct spi_slave slave;
-	struct fsl_qspi_priv priv;
-};
-#endif
 
 static u32 qspi_read32(u32 flags, u32 *addr)
 {
@@ -869,136 +861,7 @@ void qspi_cfg_smpr(struct fsl_qspi_priv *priv, u32 clear_bits, u32 set_bits)
 	smpr_val |= set_bits;
 	qspi_write32(priv->flags, &priv->regs->smpr, smpr_val);
 }
-#ifndef CONFIG_DM_SPI
-static unsigned long spi_bases[] = {
-	QSPI0_BASE_ADDR,
-#ifdef CONFIG_MX6SX
-	QSPI1_BASE_ADDR,
-#endif
-};
-
-static unsigned long amba_bases[] = {
-	QSPI0_AMBA_BASE,
-#ifdef CONFIG_MX6SX
-	QSPI1_AMBA_BASE,
-#endif
-};
-
-static inline struct fsl_qspi *to_qspi_spi(struct spi_slave *slave)
-{
-	return container_of(slave, struct fsl_qspi, slave);
-}
-
-struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,
-		unsigned int max_hz, unsigned int mode)
-{
-	u32 mcr_val;
-	struct fsl_qspi *qspi;
-	struct fsl_qspi_regs *regs;
-	u32 total_size;
-
-	if (bus >= ARRAY_SIZE(spi_bases))
-		return NULL;
-
-	if (cs >= FSL_QSPI_FLASH_NUM)
-		return NULL;
-
-	qspi = spi_alloc_slave(struct fsl_qspi, bus, cs);
-	if (!qspi)
-		return NULL;
-
-#ifdef CONFIG_SYS_FSL_QSPI_BE
-	qspi->priv.flags |= QSPI_FLAG_REGMAP_ENDIAN_BIG;
-#endif
-
-	regs = (struct fsl_qspi_regs *)spi_bases[bus];
-	qspi->priv.regs = regs;
-	/*
-	 * According cs, use different amba_base to choose the
-	 * corresponding flash devices.
-	 *
-	 * If not, only one flash device is used even if passing
-	 * different cs using `sf probe`
-	 */
-	qspi->priv.cur_amba_base = amba_bases[bus] + cs * FSL_QSPI_FLASH_SIZE;
-
-	qspi->slave.max_write_size = TX_BUFFER_SIZE;
-
-	mcr_val = qspi_read32(qspi->priv.flags, &regs->mcr);
-
-	/* Set endianness to LE for i.mx */
-	if (IS_ENABLED(CONFIG_MX6) || IS_ENABLED(CONFIG_MX7))
-		mcr_val = QSPI_MCR_END_CFD_LE;
-
-	qspi_write32(qspi->priv.flags, &regs->mcr,
-		     QSPI_MCR_RESERVED_MASK | QSPI_MCR_MDIS_MASK |
-		     (mcr_val & QSPI_MCR_END_CFD_MASK));
-
-	qspi_cfg_smpr(&qspi->priv,
-		      ~(QSPI_SMPR_FSDLY_MASK | QSPI_SMPR_DDRSMP_MASK |
-		      QSPI_SMPR_FSPHS_MASK | QSPI_SMPR_HSENA_MASK), 0);
-
-	total_size = FSL_QSPI_FLASH_SIZE * FSL_QSPI_FLASH_NUM;
-	/*
-	 * Any read access to non-implemented addresses will provide
-	 * undefined results.
-	 *
-	 * In case single die flash devices, TOP_ADDR_MEMA2 and
-	 * TOP_ADDR_MEMB2 should be initialized/programmed to
-	 * TOP_ADDR_MEMA1 and TOP_ADDR_MEMB1 respectively - in effect,
-	 * setting the size of these devices to 0.  This would ensure
-	 * that the complete memory map is assigned to only one flash device.
-	 */
-	qspi_write32(qspi->priv.flags, &regs->sfa1ad,
-		     FSL_QSPI_FLASH_SIZE | amba_bases[bus]);
-	qspi_write32(qspi->priv.flags, &regs->sfa2ad,
-		     FSL_QSPI_FLASH_SIZE | amba_bases[bus]);
-	qspi_write32(qspi->priv.flags, &regs->sfb1ad,
-		     total_size | amba_bases[bus]);
-	qspi_write32(qspi->priv.flags, &regs->sfb2ad,
-		     total_size | amba_bases[bus]);
-
-	qspi_set_lut(&qspi->priv);
-
-#ifdef CONFIG_SYS_FSL_QSPI_AHB
-	qspi_init_ahb_read(&qspi->priv);
-#endif
-
-	qspi_module_disable(&qspi->priv, 0);
-
-	return &qspi->slave;
-}
-
-void spi_free_slave(struct spi_slave *slave)
-{
-	struct fsl_qspi *qspi = to_qspi_spi(slave);
-
-	free(qspi);
-}
 
-int spi_claim_bus(struct spi_slave *slave)
-{
-	return 0;
-}
-
-void spi_release_bus(struct spi_slave *slave)
-{
-	/* Nothing to do */
-}
-
-int spi_xfer(struct spi_slave *slave, unsigned int bitlen,
-		const void *dout, void *din, unsigned long flags)
-{
-	struct fsl_qspi *qspi = to_qspi_spi(slave);
-
-	return qspi_xfer(&qspi->priv, bitlen, dout, din, flags);
-}
-
-void spi_init(void)
-{
-	/* Nothing to do */
-}
-#else
 static int fsl_qspi_child_pre_probe(struct udevice *dev)
 {
 	struct spi_slave *slave = dev_get_parent_priv(dev);
@@ -1265,4 +1128,3 @@ U_BOOT_DRIVER(fsl_qspi) = {
 	.probe	= fsl_qspi_probe,
 	.child_pre_probe = fsl_qspi_child_pre_probe,
 };
-#endif
Signature · 1 line
2.17.1
#2 lore raw

PATCH 1/1 driver/spi: fsl_qspi: Remove non-DM stuff

In reply to Ashish Kumar

Hi,

Quoted 7 lines · Ashish Kumar

Convert fsl_qspi.c to complete DM mode.

---

Quoted 7 lines

Tested on LS1088ARDB(arm64).
Tested on LS1021ATWR(arm32) by Rajat
Tested on i.mx6 and i.mx7 by Ye Li

Depends on patch series:
http://patchwork.ozlabs.org/patch/935858/
http://patchwork.ozlabs.org/patch/935860/

This patch breaks the build if you enable CONFIG_SPL_SPI_SUPPORT. I guess that SPL does not use DM for SPI.

How is the SPI support for SPL supposed to work?
Will it use DM in the future?

Thanks,
Frieder

#3 lore raw

PATCH 1/1 driver/spi: fsl_qspi: Remove non-DM stuff

Quoted 44 lines

-----Original Message-----
From: Schrempf Frieder <[email protected]>
Sent: Monday, December 3, 2018 4:49 PM
To: Ashish Kumar <[email protected]>; u-boot at lists.denx.de; jagan at openedev.com
Cc: Rajat Srivastava <[email protected]>
Subject: Re: [U-Boot] [PATCH] driver/spi: fsl_qspi: Remove non-DM stuff

Hi,

Quoted 5 lines · Ashish Kumar

Convert fsl_qspi.c to complete DM mode.

Quoted 9 lines

---

Tested on LS1088ARDB(arm64).
Tested on LS1021ATWR(arm32) by Rajat
Tested on i.mx6 and i.mx7 by Ye Li

Depends on patch series:
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatc

hwork.ozlabs.org%2Fpatch%2F935858%2F&amp;data=02%7C01%7Cashish.ku mar%4

Quoted 1 line

0nxp.com%7C208728d582b6489f20de08d6591119e0%7C686ea1d3bc2b4c6fa 92cd99c

Quoted 1 line

5c301635%7C0%7C0%7C636794327324057470&amp;sdata=AADhm3h9n9kh O3RDwtvDPS

Quoted 3 lines

dkrNUOBVaZLYCWETPZzf4%3D&amp;reserved=0
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fpatc

hwork.ozlabs.org%2Fpatch%2F935860%2F&amp;data=02%7C01%7Cashish.ku mar%4

Quoted 1 line

0nxp.com%7C208728d582b6489f20de08d6591119e0%7C686ea1d3bc2b4c6fa 92cd99c

Quoted 1 line

5c301635%7C0%7C0%7C636794327324057470&amp;sdata=UgRyuaG7n0n8 w2vLwxPAvn

Quoted 7 lines
Quoted 1 line

iaUMRsKtYod%2F2YPjjLgVg%3D&amp;reserved=0

This patch breaks the build if you enable CONFIG_SPL_SPI_SUPPORT. I guess that SPL does not use DM for SPI.

How is the SPI support for SPL supposed to work?
Will it use DM in the future?

++ Peng fan and Ye li,
Could you please help. If i.mx has SPL SPI ? As of now FSL-QSPI does not have this(SPL SPI) yet.

Regards
Ashish

Quoted 3 lines

Thanks,
Frieder