Skip to contentSkip to conversation

spi: spi-mem: Add driver for NXP FlexSPI controller

PATCH Superseded Yogesh Narayan Gaur 4 participants 14 messages Jan 8, 2019 – Jan 15, 2019

Subsystems (5)

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

v6 cover spi: spi-mem: Add driver for NXP FlexSPI controller

- Add driver for NXP FlexSPI host controller

FlexSPI is a flexsible SPI host controller [1], Chapter 30 page 1475,
which supports two SPI channels and up to 4 external devices.
Each channel supports Single/Dual/Quad/Octal mode data transfer (1/2/4/8 bidirectional data lines) i.e. FlexSPI acts as an interface to external devices, maximum 4, each with up to 8 bidirectional data lines.

- Tested this driver with mtd_debug(Erase/Write/Read) utility and JFFS2 filesystem mounting and booting on NXP LX2160ARDB[2] and LX2160AQDS targets. LX2160ARDB is having two NOR slave device connected on single bus A i.e. A0 and A1 (CS0 and CS1).
LX2160AQDS is having two NOR slave device connected on separate buses one flash on A0 and second on B1 i.e. (CS0 and CS3).
Verified this driver on following SPI NOR flashes:
Micron, mt35xu512aba, [Read - 1 bit mode]
Cypress, s25fl512s, [Read - 1/2/4 bit mode]

[1] https://www.nxp.com/docs/en/reference-manual/IMXRT1050RM.pdf
[2] https://patchwork.kernel.org/project/linux-arm-kernel/list/?submitter=182097

Yogesh Narayan Gaur (5):
spi: spi-mem: Add driver for NXP FlexSPI controller
dt-bindings: spi: add binding file for NXP FlexSPI controller
arm64: dts: lx2160a: add FlexSPI node property
arm64: defconfig: enable NXP FlexSPI driver
MAINTAINERS: add maintainers for the NXP FlexSPI driver

Changes for v6:
- Rebase on top of v5.0-rc1.
- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
- Updated s-b tag in all patches.
Changes for v5:
- Rebase on top of v4.20-rc2
- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
Changes for v4:
- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
- Incorporated binding file review comments.
Changes for v3:
- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
Changes for v2:
- Incorporated Boris review comments and drop below patches as per the comments.
- Patch 'spi: add slave device size in spi_device struct'
- Patch 'spi: add flags for octal I/O data transfer'
- Incorporated DTS and Binding file review comments of Shawn Guo and Rob Herring.

 .../devicetree/bindings/spi/spi-nxp-fspi.txt  |   39 +
 MAINTAINERS                                   |    7 +
 .../boot/dts/freescale/fsl-lx2160a-rdb.dts    |   22 +
 .../arm64/boot/dts/freescale/fsl-lx2160a.dtsi |   13 +
 arch/arm64/configs/defconfig                  |    1 +
 drivers/spi/Kconfig                           |   10 +
 drivers/spi/Makefile                          |    1 +
 drivers/spi/spi-nxp-fspi.c                    | 1095 +++++++++++++++++
 8 files changed, 1188 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt
 create mode 100644 drivers/spi/spi-nxp-fspi.c
Signature · 1 line
2.17.1
#1 lore raw

PATCH v6 1/5 spi: spi-mem: Add driver for NXP FlexSPI controller

- Add driver for NXP FlexSPI host controller

(0) What is the FlexSPI controller?
FlexSPI is a flexsible SPI host controller which supports two SPI channels and up to 4 external devices. Each channel supports Single/Dual/Quad/Octal mode data transfer (1/2/4/8 bidirectional data lines) i.e. FlexSPI acts as an interface to external devices, maximum 4, each with up to 8 bidirectional data lines.

It uses new SPI memory interface of the SPI framework to issue flash memory operations to up to four connected flash devices (2 buses with 2 CS each).

(1) Tested this driver with the mtd_debug and JFFS2 filesystem utility on NXP LX2160ARDB and LX2160AQDS targets.
LX2160ARDB is having two NOR slave device connected on single bus A i.e. A0 and A1 (CS0 and CS1).
LX2160AQDS is having two NOR slave device connected on separate buses one flash on A0 and second on B1 i.e. (CS0 and CS3). Verified this driver on following SPI NOR flashes:

    Micron, mt35xu512ab, [Read - 1 bit mode]
    Cypress, s25fl512s, [Read - 1/2/4 bit mode]

---
Changes for v6:
- Rebase on top of v5.0-rc1
- Updated as per Frieder review comments and perform code cleanup
- Updated _fill_txfifo/_read_rxfifo func write/read logic Changes for v5:
- Rebase on top of v4.20-rc2
- Modified fspi_readl_poll_tout() as per review comments
- Arrange header file in alphabetical order
- Removed usage of read()/write() function callback pointer
- Add support for 1 and 2 byte address length
- Change Frieder e-mail to new e-mail address
Changes for v4:
- Incorporate Boris review comments
* Use readl_poll_timeout() instead of busy looping.
* Re-define register masking as per comment.
* Drop fspi_devtype enum.
Changes for v3:
- Added endianness flag in platform specific structure instead of DTS.
- Modified nxp_fspi_read_ahb(), removed remapping code.
- Added Boris and Frieder as Author and provided reference of spi-fsl-qspi.c Changes for v2:
- Incorporated Boris review comments.
- Remove dependency of driver over connected flash device size.
- Modified the logic to select requested CS.
- Remove SPI-Octal Macros.

---
 drivers/spi/Kconfig        |   10 +
 drivers/spi/Makefile       |    1 +
 drivers/spi/spi-nxp-fspi.c | 1095 ++++++++++++++++++++++++++++++++++++
 3 files changed, 1106 insertions(+)
 create mode 100644 drivers/spi/spi-nxp-fspi.c
drivers/spi/Kconfig +10 -0
index dc67eda1788a..fc4cc7a65c33 100644
@@ -279,6 +279,16 @@ config SPI_FSL_QUADSPI
 	  This controller does not support generic SPI messages. It only
 	  supports the high-level SPI memory interface.
 
+config SPI_NXP_FLEXSPI
+	tristate "NXP Flex SPI controller"
+	depends on ARCH_LAYERSCAPE || HAS_IOMEM
+	help
+	  This enables support for the Flex SPI controller in master mode.
+	  Up to four slave devices can be connected on two buses with two
+	  chipselects each.
+	  This controller does not support generic SPI messages and only
+	  supports the high-level SPI memory interface.
+
 config SPI_GPIO
 	tristate "GPIO-based bitbanging SPI Master"
 	depends on GPIOLIB || COMPILE_TEST
drivers/spi/Makefile +1 -0
index 2a857cb9aa81..5c5af4676279 100644
@@ -64,6 +64,7 @@ obj-$(CONFIG_SPI_MXIC)			+= spi-mxic.o
 obj-$(CONFIG_SPI_MXS)			+= spi-mxs.o
 obj-$(CONFIG_SPI_NPCM_PSPI)		+= spi-npcm-pspi.o
 obj-$(CONFIG_SPI_NUC900)		+= spi-nuc900.o
+obj-$(CONFIG_SPI_NXP_FLEXSPI)		+= spi-nxp-fspi.o
 obj-$(CONFIG_SPI_OC_TINY)		+= spi-oc-tiny.o
 spi-octeon-objs				:= spi-cavium.o spi-cavium-octeon.o
 obj-$(CONFIG_SPI_OCTEON)		+= spi-octeon.o
drivers/spi/spi-nxp-fspi.c new file +1095 -0

1,095 lines not on this page · raw message

Signature · 1 line
2.17.1
#2 lore raw

Hi Yogesh,

my comments below are mainly about things I already mentioned in my review for v5 and about removing or simplifying some unnecessary or complex code.

Also as I gathered from your conversation with Boris, there's still a check for the length of the requested memory missing.

On 08.01.19 10:24, Yogesh Narayan Gaur wrote:
[...]

Quoted 19 lines
drivers/spi/spi-nxp-fspi.c new file +19 -0
+
+static bool nxp_fspi_supports_op(struct spi_mem *mem,
+				 const struct spi_mem_op *op)
+{
+	struct nxp_fspi *f = spi_controller_get_devdata(mem->spi->master);
+	int ret;
+
+	ret = nxp_fspi_check_buswidth(f, op->cmd.buswidth);
+
+	if (op->addr.nbytes)
+		ret |= nxp_fspi_check_buswidth(f, op->addr.buswidth);
+
+	if (op->dummy.nbytes)
+		ret |= nxp_fspi_check_buswidth(f, op->dummy.buswidth);
+
+	if (op->data.nbytes)
+		ret |= nxp_fspi_check_buswidth(f, op->data.buswidth);
+
+	if (ret)

drivers/spi/spi-nxp-fspi.c line 419

Quoted 10 lines
drivers/spi/spi-nxp-fspi.c new file +10 -0
+		return false;
+
+	/*
+	 * The number of instructions needed for the op, needs
+	 * to fit into a single LUT entry.
+	 */
+	if (op->addr.nbytes +
+	   (op->dummy.nbytes ? 1:0) +
+	   (op->data.nbytes ? 1:0) > 6)
+		return false;

Actually this check was only needed in the QSPI driver, as we were using
LUT_MODE and there we needed one instruction for each address byte.
Here the number of instructions will always fit into one LUT entry.

Instead of this, a check for op->addr.nbytes > 4 (as already suggested in my comments for v5) would make more sense. So we can make sure that the address length passed in is supported (between 1 and 4 bytes).

Quoted 20 lines
drivers/spi/spi-nxp-fspi.c new file +20 -0
+
+	/* Max 64 dummy clock cycles supported */
+	if (op->dummy.buswidth &&
+	    (op->dummy.nbytes * 8 / op->dummy.buswidth > 64))
+		return false;
+
+	/* Max data length, check controller limits and alignment */
+	if (op->data.dir == SPI_MEM_DATA_IN &&
+	    (op->data.nbytes > f->devtype_data->ahb_buf_size ||
+	     (op->data.nbytes > f->devtype_data->rxfifo - 4 &&
+	      !IS_ALIGNED(op->data.nbytes, 8))))
+		return false;
+
+	if (op->data.dir == SPI_MEM_DATA_OUT &&
+	    op->data.nbytes > f->devtype_data->txfifo)
+		return false;
+
+	return true;
+}
+

[...]

Quoted 26 lines
drivers/spi/spi-nxp-fspi.c new file +26 -0
+static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi)
+{
+	unsigned long rate = spi->max_speed_hz;
+	int ret;
+	uint64_t size_kb;
+
+	/*
+	 * Return, if previously selected slave device is same as current
+	 * requested slave device.
+	 */
+	if (f->selected == spi->chip_select)
+		return;
+
+	/* Reset FLSHxxCR0 registers */
+	fspi_writel(f, 0, f->iobase + FSPI_FLSHA1CR0);
+	fspi_writel(f, 0, f->iobase + FSPI_FLSHA2CR0);
+	fspi_writel(f, 0, f->iobase + FSPI_FLSHB1CR0);
+	fspi_writel(f, 0, f->iobase + FSPI_FLSHB2CR0);
+
+	/* Assign controller memory mapped space as size, KBytes, of flash. */
+	size_kb = FSPI_FLSHXCR0_SZ(f->memmap_phy_size);
+
+	switch (spi->chip_select) {
+	case 0:
+		fspi_writel(f, size_kb, f->iobase + FSPI_FLSHA1CR0);
+		break;

drivers/spi/spi-nxp-fspi.c line 634

Quoted 10 lines
drivers/spi/spi-nxp-fspi.c new file +10 -0
+	case 1:
+		fspi_writel(f, size_kb, f->iobase + FSPI_FLSHA2CR0);
+		break;
+	case 2:
+		fspi_writel(f, size_kb, f->iobase + FSPI_FLSHB1CR0);
+		break;
+	case 3:
+		fspi_writel(f, size_kb, f->iobase + FSPI_FLSHB2CR0);
+		break;
+	}

The switch statement above can be replaced by:

fspi_writel(f, size_kb, f->iobase + FSPI_FLSHA1CR0 +

	    4 * spi->chip_select);
Quoted 22 lines
drivers/spi/spi-nxp-fspi.c new file +22 -0
+
+	dev_dbg(f->dev, "Slave device [CS:%x] selected\n", spi->chip_select);
+
+	nxp_fspi_clk_disable_unprep(f);
+
+	ret = clk_set_rate(f->clk, rate);
+	if (ret)
+		return;
+
+	ret = nxp_fspi_clk_prep_enable(f);
+	if (ret)
+		return;
+
+	f->selected = spi->chip_select;
+}
+
+static void nxp_fspi_read_ahb(struct nxp_fspi *f, const struct spi_mem_op *op)
+{
+	u32 len = op->data.nbytes;
+
+	/* Read out the data directly from the AHB buffer. */
+	memcpy_fromio(op->data.buf.in, (f->ahb_addr + op->addr.val), len);

drivers/spi/spi-nxp-fspi.c line 666

Quoted 10 lines
drivers/spi/spi-nxp-fspi.c new file +10 -0
+}
+
+static void nxp_fspi_fill_txfifo(struct nxp_fspi *f,
+				 const struct spi_mem_op *op)
+{
+	void __iomem *base = f->iobase;
+	int i, j, ret;
+	int size, tmp, wm_size;
+	u32 data = 0;
+	u32 *txbuf = (u32 *) op->data.buf.out;

You can cast the u8 buffer to u32 and increment it by 1 in each cycle below, or you can just use the u8 buffer and align and increment by 8 as I did in my proposal for v5.
I still like my version better as it seems simpler and easier to understand ;)

Quoted 6 lines
drivers/spi/spi-nxp-fspi.c new file +6 -0
+
+	/* clear the TX FIFO. */
+	fspi_writel(f, FSPI_IPTXFCR_CLR, base + FSPI_IPTXFCR);
+
+	/* Default value of water mark level is 8 bytes. */
+	wm_size = 8;

drivers/spi/spi-nxp-fspi.c line 682

Quoted 10 lines
drivers/spi/spi-nxp-fspi.c new file +10 -0
+
+	size = op->data.nbytes / wm_size;
+	for (i = 0; i < size; i++) {
+		/* Wait for TXFIFO empty */
+		ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR,
+					   FSPI_INTR_IPTXWE, 0,
+					   POLL_TOUT, true);
+		WARN_ON(ret);
+
+		for (tmp = wm_size, j = 0; tmp > 0; tmp -= 4, j++)

I still think the inner loop should only be added when someone implements watermark levels other than 8. It is of no use at the moment and makes reading the code more difficult.
But if you insist on using it, please at least simplify the code.

What about: for (j = 0; j < (wm_size / 4); j++)

drivers/spi/spi-nxp-fspi.c line 696

Quoted 13 lines
drivers/spi/spi-nxp-fspi.c new file +13 -0
+			fspi_writel(f, *txbuf++, base + FSPI_TFDR + j * 4); > +
+		fspi_writel(f, FSPI_INTR_IPTXWE, base + FSPI_INTR);
+	}
+
+	size = op->data.nbytes % wm_size;
+	if (size) {
+		/* Wait for TXFIFO empty */
+		ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR,
+					   FSPI_INTR_IPTXWE, 0,
+					   POLL_TOUT, true);
+		WARN_ON(ret);
+
+		for (tmp = size, j = 0; tmp > 0; tmp -= 4, j++) {

Same here: for (j = 0; j < (size / 4); j++) {

Quoted 12 lines
drivers/spi/spi-nxp-fspi.c new file +12 -0
+			data = 0;
+			memcpy(&data, txbuf++, 4);
+			fspi_writel(f, data, base + FSPI_TFDR + j * 4);
+		}
+		fspi_writel(f, FSPI_INTR_IPTXWE, base + FSPI_INTR);
+	}
+}
+
+static void nxp_fspi_read_rxfifo(struct nxp_fspi *f,
+			  const struct spi_mem_op *op)
+{
+	void __iomem *base = f->iobase;

drivers/spi/spi-nxp-fspi.c line 718

Quoted 10 lines
drivers/spi/spi-nxp-fspi.c new file +10 -0
+	int i, j;
+	int size, tmp_size, wm_size, ret;
+	u32 tmp = 0;
+	u8 *buf = op->data.buf.in;
+	u32 len = op->data.nbytes;
+
+	/* Default value of water mark level is 8 bytes. */
+	wm_size = 8;
+
+	while (len > 0) {

What is this outer loop good for? Below you are first reading aligned to wm_size and then the remaining bytes. Why would you need to repeat that? It looks like the loop will always be executed only once.

drivers/spi/spi-nxp-fspi.c line 728

Quoted 10 lines
drivers/spi/spi-nxp-fspi.c new file +10 -0
+		size = len / wm_size;
+		for (i = 0; i < size; i++) {
+			/* Wait for RXFIFO available */
+			ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR,
+						   FSPI_INTR_IPRXWA, 0,
+						   POLL_TOUT, true);
+			WARN_ON(ret);
+
+			for (tmp_size = wm_size, j = 0; tmp_size > 0;
+			     tmp_size -= 4, j++, buf += 4) {

What about: for (j = 0; j < (wm_size / 4); j++, buf += 4) {

Quoted 9 lines
drivers/spi/spi-nxp-fspi.c new file +9 -0
+				tmp = fspi_readl(f, base + FSPI_RFDR + j * 4);
+				memcpy(buf, &tmp, 4);
+			}
+			/* move the FIFO pointer */
+			fspi_writel(f, FSPI_INTR_IPRXWA, base + FSPI_INTR);
+			len -= wm_size;
+		}
+
+		size = len % wm_size;

drivers/spi/spi-nxp-fspi.c line 747

Quoted 10 lines
drivers/spi/spi-nxp-fspi.c new file +10 -0
+		if (size) {
+			/* Wait for RXFIFO available */
+			ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR,
+						   FSPI_INTR_IPRXWA, 0,
+						   POLL_TOUT, true);
+			WARN_ON(ret);
+
+			for (j = 0; len > 0; len -= size, j++, buf += size) {
+				tmp = fspi_readl(f, base + FSPI_RFDR + j * 4);
+				size = len < 4 ? len : 4;

What about: size = min(len, 4);

drivers/spi/spi-nxp-fspi.c line 757

Quoted 10 lines
drivers/spi/spi-nxp-fspi.c new file +10 -0
+				memcpy(buf, &tmp, size);
+			}
+		}
+
+		/* invalid the RXFIFO */
+		fspi_writel(f, FSPI_IPRXFCR_CLR, base + FSPI_IPRXFCR);
+		/* move the FIFO pointer */
+		fspi_writel(f, FSPI_INTR_IPRXWA, base + FSPI_INTR);
+	}
+}

Thanks,
Frieder

Reviewed-by
#3 lore raw
Quoted 253 lines · On Thu, 10 Jan 2019 17:28:57 +0000 Schrempf Frieder…

Hi Yogesh,

my comments below are mainly about things I already mentioned in my review for v5 and about removing or simplifying some unnecessary or complex code.

Also as I gathered from your conversation with Boris, there's still a check for the length of the requested memory missing.

On 08.01.19 10:24, Yogesh Narayan Gaur wrote:
[...]

Quoted 19 lines
drivers/spi/spi-nxp-fspi.c new file +19 -0
+
+static bool nxp_fspi_supports_op(struct spi_mem *mem,
+				 const struct spi_mem_op *op)
+{
+	struct nxp_fspi *f = spi_controller_get_devdata(mem->spi->master);
+	int ret;
+
+	ret = nxp_fspi_check_buswidth(f, op->cmd.buswidth);
+
+	if (op->addr.nbytes)
+		ret |= nxp_fspi_check_buswidth(f, op->addr.buswidth);
+
+	if (op->dummy.nbytes)
+		ret |= nxp_fspi_check_buswidth(f, op->dummy.buswidth);
+
+	if (op->data.nbytes)
+		ret |= nxp_fspi_check_buswidth(f, op->data.buswidth);
+
+	if (ret)

drivers/spi/spi-nxp-fspi.c line 419

Quoted 10 lines
drivers/spi/spi-nxp-fspi.c new file +10 -0
+		return false;
+
+	/*
+	 * The number of instructions needed for the op, needs
+	 * to fit into a single LUT entry.
+	 */
+	if (op->addr.nbytes +
+	   (op->dummy.nbytes ? 1:0) +
+	   (op->data.nbytes ? 1:0) > 6)
+		return false;  

Actually this check was only needed in the QSPI driver, as we were using
LUT_MODE and there we needed one instruction for each address byte.
Here the number of instructions will always fit into one LUT entry.

Instead of this, a check for op->addr.nbytes > 4 (as already suggested in my comments for v5) would make more sense. So we can make sure that the address length passed in is supported (between 1 and 4 bytes).

Quoted 20 lines
drivers/spi/spi-nxp-fspi.c new file +20 -0
+
+	/* Max 64 dummy clock cycles supported */
+	if (op->dummy.buswidth &&
+	    (op->dummy.nbytes * 8 / op->dummy.buswidth > 64))
+		return false;
+
+	/* Max data length, check controller limits and alignment */
+	if (op->data.dir == SPI_MEM_DATA_IN &&
+	    (op->data.nbytes > f->devtype_data->ahb_buf_size ||
+	     (op->data.nbytes > f->devtype_data->rxfifo - 4 &&
+	      !IS_ALIGNED(op->data.nbytes, 8))))
+		return false;
+
+	if (op->data.dir == SPI_MEM_DATA_OUT &&
+	    op->data.nbytes > f->devtype_data->txfifo)
+		return false;
+
+	return true;
+}
+  

[...]

Quoted 26 lines
drivers/spi/spi-nxp-fspi.c new file +26 -0
+static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi)
+{
+	unsigned long rate = spi->max_speed_hz;
+	int ret;
+	uint64_t size_kb;
+
+	/*
+	 * Return, if previously selected slave device is same as current
+	 * requested slave device.
+	 */
+	if (f->selected == spi->chip_select)
+		return;
+
+	/* Reset FLSHxxCR0 registers */
+	fspi_writel(f, 0, f->iobase + FSPI_FLSHA1CR0);
+	fspi_writel(f, 0, f->iobase + FSPI_FLSHA2CR0);
+	fspi_writel(f, 0, f->iobase + FSPI_FLSHB1CR0);
+	fspi_writel(f, 0, f->iobase + FSPI_FLSHB2CR0);
+
+	/* Assign controller memory mapped space as size, KBytes, of flash. */
+	size_kb = FSPI_FLSHXCR0_SZ(f->memmap_phy_size);
+
+	switch (spi->chip_select) {
+	case 0:
+		fspi_writel(f, size_kb, f->iobase + FSPI_FLSHA1CR0);
+		break;

drivers/spi/spi-nxp-fspi.c line 634

Quoted 10 lines
drivers/spi/spi-nxp-fspi.c new file +10 -0
+	case 1:
+		fspi_writel(f, size_kb, f->iobase + FSPI_FLSHA2CR0);
+		break;
+	case 2:
+		fspi_writel(f, size_kb, f->iobase + FSPI_FLSHB1CR0);
+		break;
+	case 3:
+		fspi_writel(f, size_kb, f->iobase + FSPI_FLSHB2CR0);
+		break;
+	}  

The switch statement above can be replaced by:

fspi_writel(f, size_kb, f->iobase + FSPI_FLSHA1CR0 +

	    4 * spi->chip_select);
Quoted 22 lines
drivers/spi/spi-nxp-fspi.c new file +22 -0
+
+	dev_dbg(f->dev, "Slave device [CS:%x] selected\n", spi->chip_select);
+
+	nxp_fspi_clk_disable_unprep(f);
+
+	ret = clk_set_rate(f->clk, rate);
+	if (ret)
+		return;
+
+	ret = nxp_fspi_clk_prep_enable(f);
+	if (ret)
+		return;
+
+	f->selected = spi->chip_select;
+}
+
+static void nxp_fspi_read_ahb(struct nxp_fspi *f, const struct spi_mem_op *op)
+{
+	u32 len = op->data.nbytes;
+
+	/* Read out the data directly from the AHB buffer. */
+	memcpy_fromio(op->data.buf.in, (f->ahb_addr + op->addr.val), len);

drivers/spi/spi-nxp-fspi.c line 666

Quoted 10 lines
drivers/spi/spi-nxp-fspi.c new file +10 -0
+}
+
+static void nxp_fspi_fill_txfifo(struct nxp_fspi *f,
+				 const struct spi_mem_op *op)
+{
+	void __iomem *base = f->iobase;
+	int i, j, ret;
+	int size, tmp, wm_size;
+	u32 data = 0;
+	u32 *txbuf = (u32 *) op->data.buf.out;  

You can cast the u8 buffer to u32 and increment it by 1 in each cycle below, or you can just use the u8 buffer and align and increment by 8 as I did in my proposal for v5.
I still like my version better as it seems simpler and easier to understand ;)

Quoted 6 lines
drivers/spi/spi-nxp-fspi.c new file +6 -0
+
+	/* clear the TX FIFO. */
+	fspi_writel(f, FSPI_IPTXFCR_CLR, base + FSPI_IPTXFCR);
+
+	/* Default value of water mark level is 8 bytes. */
+	wm_size = 8;

drivers/spi/spi-nxp-fspi.c line 682

Quoted 10 lines
drivers/spi/spi-nxp-fspi.c new file +10 -0
+
+	size = op->data.nbytes / wm_size;
+	for (i = 0; i < size; i++) {
+		/* Wait for TXFIFO empty */
+		ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR,
+					   FSPI_INTR_IPTXWE, 0,
+					   POLL_TOUT, true);
+		WARN_ON(ret);
+
+		for (tmp = wm_size, j = 0; tmp > 0; tmp -= 4, j++)  

I still think the inner loop should only be added when someone implements watermark levels other than 8. It is of no use at the moment and makes reading the code more difficult.
But if you insist on using it, please at least simplify the code.

What about: for (j = 0; j < (wm_size / 4); j++)

drivers/spi/spi-nxp-fspi.c line 696

Quoted 13 lines
drivers/spi/spi-nxp-fspi.c new file +13 -0
+			fspi_writel(f, *txbuf++, base + FSPI_TFDR + j * 4); > +
+		fspi_writel(f, FSPI_INTR_IPTXWE, base + FSPI_INTR);
+	}
+
+	size = op->data.nbytes % wm_size;
+	if (size) {
+		/* Wait for TXFIFO empty */
+		ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR,
+					   FSPI_INTR_IPTXWE, 0,
+					   POLL_TOUT, true);
+		WARN_ON(ret);
+
+		for (tmp = size, j = 0; tmp > 0; tmp -= 4, j++) {  

Same here: for (j = 0; j < (size / 4); j++) {

Quoted 12 lines
drivers/spi/spi-nxp-fspi.c new file +12 -0
+			data = 0;
+			memcpy(&data, txbuf++, 4);
+			fspi_writel(f, data, base + FSPI_TFDR + j * 4);
+		}
+		fspi_writel(f, FSPI_INTR_IPTXWE, base + FSPI_INTR);
+	}
+}
+
+static void nxp_fspi_read_rxfifo(struct nxp_fspi *f,
+			  const struct spi_mem_op *op)
+{
+	void __iomem *base = f->iobase;

drivers/spi/spi-nxp-fspi.c line 718

Quoted 10 lines
drivers/spi/spi-nxp-fspi.c new file +10 -0
+	int i, j;
+	int size, tmp_size, wm_size, ret;
+	u32 tmp = 0;
+	u8 *buf = op->data.buf.in;
+	u32 len = op->data.nbytes;
+
+	/* Default value of water mark level is 8 bytes. */
+	wm_size = 8;
+
+	while (len > 0) {  

What is this outer loop good for? Below you are first reading aligned to wm_size and then the remaining bytes. Why would you need to repeat that? It looks like the loop will always be executed only once.

drivers/spi/spi-nxp-fspi.c line 728

Quoted 10 lines
drivers/spi/spi-nxp-fspi.c new file +10 -0
+		size = len / wm_size;
+		for (i = 0; i < size; i++) {
+			/* Wait for RXFIFO available */
+			ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR,
+						   FSPI_INTR_IPRXWA, 0,
+						   POLL_TOUT, true);
+			WARN_ON(ret);
+
+			for (tmp_size = wm_size, j = 0; tmp_size > 0;
+			     tmp_size -= 4, j++, buf += 4) {  

What about: for (j = 0; j < (wm_size / 4); j++, buf += 4) {

Quoted 9 lines
drivers/spi/spi-nxp-fspi.c new file +9 -0
+				tmp = fspi_readl(f, base + FSPI_RFDR + j * 4);
+				memcpy(buf, &tmp, 4);
+			}
+			/* move the FIFO pointer */
+			fspi_writel(f, FSPI_INTR_IPRXWA, base + FSPI_INTR);
+			len -= wm_size;
+		}
+
+		size = len % wm_size;

drivers/spi/spi-nxp-fspi.c line 747

Quoted 10 lines
drivers/spi/spi-nxp-fspi.c new file +10 -0
+		if (size) {
+			/* Wait for RXFIFO available */
+			ret = fspi_readl_poll_tout(f, f->iobase + FSPI_INTR,
+						   FSPI_INTR_IPRXWA, 0,
+						   POLL_TOUT, true);
+			WARN_ON(ret);
+
+			for (j = 0; len > 0; len -= size, j++, buf += size) {
+				tmp = fspi_readl(f, base + FSPI_RFDR + j * 4);
+				size = len < 4 ? len : 4;  

What about: size = min(len, 4);

Quoted 11 lines

drivers/spi/spi-nxp-fspi.c line 757

Quoted 10 lines
drivers/spi/spi-nxp-fspi.c new file +10 -0
+				memcpy(buf, &tmp, size);
+			}
+		}
+
+		/* invalid the RXFIFO */
+		fspi_writel(f, FSPI_IPRXFCR_CLR, base + FSPI_IPRXFCR);
+		/* move the FIFO pointer */
+		fspi_writel(f, FSPI_INTR_IPRXWA, base + FSPI_INTR);
+	}
+}  

Once you've addressed all of Frieder's comments you can add

Regards,

Boris

#4 lore raw

Hi Boris,

Quoted 21 lines

-----Original Message-----
From: Boris Brezillon [mailto:[email protected]]
Sent: Monday, January 14, 2019 2:08 PM
To: Schrempf Frieder <[email protected]>
Cc: Yogesh Narayan Gaur <[email protected]>; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; linux-arm- [email protected]
Subject: Re: [PATCH v6 1/5] spi: spi-mem: Add driver for NXP FlexSPI controller

Quoted 6 lines · On Thu, 10 Jan 2019 17:28:57 +0000 Schrempf Frieder…

Hi Yogesh,

my comments below are mainly about things I already mentioned in my review for v5 and about removing or simplifying some unnecessary or complex code.

[...]

Quoted 6 lines
Quoted 1 line

Once you've addressed all of Frieder's comments you can add

Thanks.
I have send next version, v7, of the patch series having added code changes as per Frieder's comments. [1] Based on the feedback from Frieder, would add yours r-o-b tag.

--
Regards
Yogesh Gaur
[1] https://patchwork.ozlabs.org/project/linux-mtd/list/?series=86130

Quoted 3 lines

Regards,

Boris

#5 lore raw

PATCH v6 2/5 dt-bindings: spi: add binding file for NXP FlexSPI controller

In reply to Yogesh Narayan Gaur

Add binding file for NXP FlexSPI controller

---
Changes for v6:
- None
Changes for v5:
- None
Changes for v4:
- Incorporated Rob review comments.
Changes for v3:
- Removed node property 'big-endian'.
Changes for v2:
- Incorporated Rob review comments.

 .../devicetree/bindings/spi/spi-nxp-fspi.txt  | 39 +++++++++++++++++++
 1 file changed, 39 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt new file +39 -0
new file mode 100644
index 000000000000..2cd67eb727d4
@@ -0,0 +1,39 @@
+* NXP Flex Serial Peripheral Interface (FSPI)
+
+Required properties:
+  - compatible : Should be "nxp,lx2160a-fspi"
+  - reg :        First contains the register location and length,
+                 Second contains the memory mapping address and length
+  - reg-names :  Should contain the resource reg names:
+	         - fspi_base: configuration register address space
+                 - fspi_mmap: memory mapped address space
+  - interrupts : Should contain the interrupt for the device
+
+Required SPI slave node properties:
+  - reg :        There are two buses (A and B) with two chip selects each.
+                 This encodes to which bus and CS the flash is connected:
+                 - <0>: Bus A, CS 0
+                 - <1>: Bus A, CS 1
+                 - <2>: Bus B, CS 0
+                 - <3>: Bus B, CS 1
+
+Example showing the usage of two SPI NOR slave devices on bus A:
+
+fspi0: spi@20c0000 {
+	compatible = "nxp,lx2160a-fspi";
+	reg = <0x0 0x20c0000 0x0 0x10000>, <0x0 0x20000000 0x0 0x10000000>;
+	reg-names = "fspi_base", "fspi_mmap";
+	interrupts = <0 25 0x4>; /* Level high type */
+	clocks = <&clockgen 4 3>, <&clockgen 4 3>;
+	clock-names = "fspi_en", "fspi";
+
+	mt35xu512aba0: flash@0 {
+		reg = <0>;
+		....
+	};
+
+	mt35xu512aba1: flash@1 {
+		reg = <1>;
+		....
+	};
+};
Signature · 1 line
2.17.1
#6 lore raw

PATCH v6 3/5 arm64: dts: lx2160a: add FlexSPI node property

In reply to Yogesh Narayan Gaur

Add fspi node property for LX2160A SoC for FlexSPI driver. Property added for the FlexSPI controller and for the connected slave device for the LX2160ARDB target.
This is having two SPI-NOR flash device, mt35xu512aba, connected at CS0 and CS1.

---
Changes for v6:
- None
Changes for v5:
- None
Changes for v4:
- Incorporated Rob review comments.
Changes for v3:
- None.
Changes for v2:
- Incorporated Shawn review comments.

---
 .../boot/dts/freescale/fsl-lx2160a-rdb.dts    | 22 +++++++++++++++++++
 .../arm64/boot/dts/freescale/fsl-lx2160a.dtsi | 13 +++++++++++
 2 files changed, 35 insertions(+)
arch/arm64/boot/dts/freescale/fsl-lx2160a-rdb.dts +22 -0
index 6481e5f20e69..70658946fbbe 100644
@@ -50,6 +50,28 @@
 	status = "okay";
 };
 
+&fspi {
+	status = "okay";
+
+	mt35xu512aba0: flash@0 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "spansion,m25p80";
+		m25p,fast-read;
+		spi-max-frequency = <50000000>;
+		reg = <0>;
+	};
+
+	mt35xu512aba1: flash@1 {
+		#address-cells = <1>;
+		#size-cells = <1>;
+		compatible = "spansion,m25p80";
+		m25p,fast-read;
+		spi-max-frequency = <50000000>;
+		reg = <1>;
+	};
+};
+
 &i2c0 {
 	status = "okay";
 
arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi +13 -0
index a79f5c1ea56d..e3ff86201f73 100644
@@ -762,5 +762,18 @@
 				     <GIC_SPI 209 IRQ_TYPE_LEVEL_HIGH>;
 			dma-coherent;
 		};
+
+		fspi: spi@20c0000 {
+			compatible = "nxp,lx2160a-fspi";
+			#address-cells = <1>;
+			#size-cells = <0>;
+			reg = <0x0 0x20c0000 0x0 0x10000>,
+				<0x0 0x20000000 0x0 0x10000000>;
+			reg-names = "fspi_base", "fspi_mmap";
+			interrupts = <0 25 0x4>; /* Level high type */
+			clocks = <&clockgen 4 3>, <&clockgen 4 3>;
+			clock-names = "fspi_en", "fspi";
+			status = "disabled";
+		};
 	};
 };
Signature · 1 line
2.17.1
#7 lore raw

PATCH v6 4/5 arm64: defconfig: enable NXP FlexSPI driver

In reply to Yogesh Narayan Gaur

Enable driver support of NXP FlexSPI controller.

---
 arch/arm64/configs/defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
index 3ef443cfbab6..fe7f35824a79 100644
@@ -362,6 +362,7 @@ CONFIG_SPI_ROCKCHIP=y
 CONFIG_SPI_QUP=y
 CONFIG_SPI_S3C64XX=y
 CONFIG_SPI_SPIDEV=m
+CONFIG_SPI_NXP_FLEXSPI=y
 CONFIG_SPMI=y
 CONFIG_PINCTRL_SINGLE=y
 CONFIG_PINCTRL_MAX77620=y
Signature · 1 line
2.17.1
#8 lore raw

PATCH v6 5/5 MAINTAINERS: add maintainers for the NXP FlexSPI driver

In reply to Yogesh Narayan Gaur

Add maintainers for the NXP FlexSPI driver

---
Changes for v6:
- None
Changes for v5:
- Add maintainers for binding file
Changes for v4:
- None
Changes for v3:
- None
Changes for v2:
- None

---
 MAINTAINERS | 7 +++++++
 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
index 8b6c0d454d7e..c393b590e56d 100644
@@ -10927,6 +10927,13 @@ F:	lib/objagg.c
 F:	lib/test_objagg.c
 F:	include/linux/objagg.h
 
+NXP FSPI DRIVER
+M:	Yogesh Gaur <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	drivers/spi/spi-nxp-fspi.c
+F:	Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt
+
 OBJTOOL
 M:	Josh Poimboeuf <[email protected]>
 M:	Peter Zijlstra <[email protected]>
Signature · 1 line
2.17.1
#9 lore raw
In reply to Yogesh Narayan Gaur
Quoted 28 lines · Yogesh Narayan Gaur

- Add driver for NXP FlexSPI host controller

FlexSPI is a flexsible SPI host controller [1], Chapter 30 page 1475,
which supports two SPI channels and up to 4 external devices.
Each channel supports Single/Dual/Quad/Octal mode data transfer (1/2/4/8 bidirectional data lines) i.e. FlexSPI acts as an interface to external devices, maximum 4, each with up to 8 bidirectional data lines.

- Tested this driver with mtd_debug(Erase/Write/Read) utility and JFFS2 filesystem mounting and booting on NXP LX2160ARDB[2] and LX2160AQDS targets. LX2160ARDB is having two NOR slave device connected on single bus A i.e. A0 and A1 (CS0 and CS1).
LX2160AQDS is having two NOR slave device connected on separate buses one flash on A0 and second on B1 i.e. (CS0 and CS3).
Verified this driver on following SPI NOR flashes:

    Micron, mt35xu512aba, [Read - 1 bit mode]
    Cypress, s25fl512s, [Read - 1/2/4 bit mode]

[1] https://www.nxp.com/docs/en/reference-manual/IMXRT1050RM.pdf
[2] https://patchwork.kernel.org/project/linux-arm-kernel/list/?submitter=182097

Yogesh Narayan Gaur (5):
spi: spi-mem: Add driver for NXP FlexSPI controller
dt-bindings: spi: add binding file for NXP FlexSPI controller
arm64: dts: lx2160a: add FlexSPI node property
arm64: defconfig: enable NXP FlexSPI driver
MAINTAINERS: add maintainers for the NXP FlexSPI driver

Quoted 2 lines

Changes for v6:
- Rebase on top of v5.0-rc1.

Your patches don't apply to v5.0-rc1. It seems like you have instead rebased onto the for-5.1 or for-next branch of the SPI tree. I guess this is okay, but you should have pointed that out correctly here.

Quoted 32 lines

- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
- Updated s-b tag in all patches.
Changes for v5:
- Rebase on top of v4.20-rc2
- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
Changes for v4:
- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
- Incorporated binding file review comments.
Changes for v3:
- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
Changes for v2:
- Incorporated Boris review comments and drop below patches as per the comments.
- Patch 'spi: add slave device size in spi_device struct'
- Patch 'spi: add flags for octal I/O data transfer'
- Incorporated DTS and Binding file review comments of Shawn Guo and Rob Herring.

  .../devicetree/bindings/spi/spi-nxp-fspi.txt  |   39 +
  MAINTAINERS                                   |    7 +
  .../boot/dts/freescale/fsl-lx2160a-rdb.dts    |   22 +
  .../arm64/boot/dts/freescale/fsl-lx2160a.dtsi |   13 +
  arch/arm64/configs/defconfig                  |    1 +
  drivers/spi/Kconfig                           |   10 +
  drivers/spi/Makefile                          |    1 +
  drivers/spi/spi-nxp-fspi.c                    | 1095 +++++++++++++++++
  8 files changed, 1188 insertions(+)

create mode 100644 Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt create mode 100644 drivers/spi/spi-nxp-fspi.c

#10 lore raw

Hi Schrempf,

Quoted 31 lines · Yogesh Narayan Gaur
Quoted 30 lines

- Add driver for NXP FlexSPI host controller

FlexSPI is a flexsible SPI host controller [1], Chapter 30 page
1475, which supports two SPI channels and up to 4 external devices.
Each channel supports Single/Dual/Quad/Octal mode data transfer
(1/2/4/8 bidirectional data lines) i.e. FlexSPI acts as an interface to external devices, maximum 4, each with up to 8 bidirectional data lines.

- Tested this driver with mtd_debug(Erase/Write/Read) utility and JFFS2 filesystem mounting and booting on NXP LX2160ARDB[2] and LX2160AQDS targets. LX2160ARDB is having two NOR slave device connected on single bus A i.e. A0 and A1 (CS0 and CS1). LX2160AQDS is having two NOR slave device connected on separate
buses one flash on A0 and second on B1 i.e. (CS0 and CS3).
Verified this driver on following SPI NOR flashes:

    Micron, mt35xu512aba, [Read - 1 bit mode]
    Cypress, s25fl512s, [Read - 1/2/4 bit mode]

[1] https://www.nxp.com/docs/en/reference-manual/IMXRT1050RM.pdf
[2]
https://patchwork.kernel.org/project/linux-arm-kernel/list/?submitter=182097

Yogesh Narayan Gaur (5):
spi: spi-mem: Add driver for NXP FlexSPI controller
dt-bindings: spi: add binding file for NXP FlexSPI controller
arm64: dts: lx2160a: add FlexSPI node property
arm64: defconfig: enable NXP FlexSPI driver
MAINTAINERS: add maintainers for the NXP FlexSPI driver

Quoted 6 lines
Quoted 2 lines

Changes for v6:
- Rebase on top of v5.0-rc1.

Your patches don't apply to v5.0-rc1. It seems like you have instead rebased onto the for-5.1 or for-next branch of the SPI tree. I guess this is okay, but you should have pointed that out correctly here.

If I may ask for a few (1-2) days, so I can test this code on vf610 NXP SoC.

As fair as I remember there were some issues when I tested it a few months back.

Quoted 35 lines
Quoted 31 lines

- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
- Updated s-b tag in all patches.
Changes for v5:
- Rebase on top of v4.20-rc2
- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
Changes for v4:
- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
- Incorporated binding file review comments.
Changes for v3:
- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
Changes for v2:
- Incorporated Boris review comments and drop below patches as per the comments.
- Patch 'spi: add slave device size in spi_device struct'
- Patch 'spi: add flags for octal I/O data transfer'
- Incorporated DTS and Binding file review comments of Shawn Guo and Rob Herring.

  .../devicetree/bindings/spi/spi-nxp-fspi.txt  |   39 +
  MAINTAINERS                                   |    7 +
  .../boot/dts/freescale/fsl-lx2160a-rdb.dts    |   22 +
  .../arm64/boot/dts/freescale/fsl-lx2160a.dtsi |   13 +
  arch/arm64/configs/defconfig                  |    1 +
  drivers/spi/Kconfig                           |   10 +
  drivers/spi/Makefile                          |    1 +
  drivers/spi/spi-nxp-fspi.c                    | 1095
Quoted 4 lines

+++++++++++++++++ 8 files changed, 1188 insertions(+)
create mode 100644
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt create mode 100644 drivers/spi/spi-nxp-fspi.c

Quoted 3 lines

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [email protected]

#11 lore raw

Hi Lukasz,

Quoted 40 lines · Lukasz Majewski

Hi Schrempf,

Quoted 31 lines · Yogesh Narayan Gaur
Quoted 30 lines

- Add driver for NXP FlexSPI host controller

FlexSPI is a flexsible SPI host controller [1], Chapter 30 page
1475, which supports two SPI channels and up to 4 external devices.
Each channel supports Single/Dual/Quad/Octal mode data transfer
(1/2/4/8 bidirectional data lines) i.e. FlexSPI acts as an interface to external devices, maximum 4, each with up to 8 bidirectional data lines.

- Tested this driver with mtd_debug(Erase/Write/Read) utility and JFFS2 filesystem mounting and booting on NXP LX2160ARDB[2] and LX2160AQDS targets. LX2160ARDB is having two NOR slave device connected on single bus A i.e. A0 and A1 (CS0 and CS1). LX2160AQDS is having two NOR slave device connected on separate
buses one flash on A0 and second on B1 i.e. (CS0 and CS3).
Verified this driver on following SPI NOR flashes:

     Micron, mt35xu512aba, [Read - 1 bit mode]
     Cypress, s25fl512s, [Read - 1/2/4 bit mode]

[1] https://www.nxp.com/docs/en/reference-manual/IMXRT1050RM.pdf
[2]
https://patchwork.kernel.org/project/linux-arm-kernel/list/?submitter=182097

Yogesh Narayan Gaur (5):
spi: spi-mem: Add driver for NXP FlexSPI controller
dt-bindings: spi: add binding file for NXP FlexSPI controller
arm64: dts: lx2160a: add FlexSPI node property
arm64: defconfig: enable NXP FlexSPI driver
MAINTAINERS: add maintainers for the NXP FlexSPI driver

Quoted 6 lines
Quoted 2 lines

Changes for v6:
- Rebase on top of v5.0-rc1.

Your patches don't apply to v5.0-rc1. It seems like you have instead rebased onto the for-5.1 or for-next branch of the SPI tree. I guess this is okay, but you should have pointed that out correctly here.

Quoted 5 lines

If I may ask for a few (1-2) days, so I can test this code on vf610 NXP SoC.

As fair as I remember there were some issues when I tested it a few months back.

You're probably mixing that up. This series is about the FlexSPI controller in the Layerscape SOCs.

The QuadSPI driver is already in linux-next to be merged in 5.1 [1]. The issues with vf610 existed in the old SPI-NOR driver and probably still exist in the new SPI driver. You are welcome to test the new driver and come up with some fixes.

Sooner or later, there will probably also be other changes coming up, such as implementation of the dirmap API.

Thanks,
Frieder

[1]:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/spi?h=next-20190109&id=84d043185dbe0d1b4f6db575bd91c834d37e2f78

Quoted 53 lines
Quoted 36 lines
Quoted 32 lines

- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
- Updated s-b tag in all patches.
Changes for v5:
- Rebase on top of v4.20-rc2
- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
Changes for v4:
- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
- Incorporated binding file review comments.
Changes for v3:
- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
Changes for v2:
- Incorporated Boris review comments and drop below patches as per the comments.
- Patch 'spi: add slave device size in spi_device struct'
- Patch 'spi: add flags for octal I/O data transfer'
- Incorporated DTS and Binding file review comments of Shawn Guo and Rob Herring.

   .../devicetree/bindings/spi/spi-nxp-fspi.txt  |   39 +
   MAINTAINERS                                   |    7 +
   .../boot/dts/freescale/fsl-lx2160a-rdb.dts    |   22 +
   .../arm64/boot/dts/freescale/fsl-lx2160a.dtsi |   13 +
   arch/arm64/configs/defconfig                  |    1 +
   drivers/spi/Kconfig                           |   10 +
   drivers/spi/Makefile                          |    1 +
   drivers/spi/spi-nxp-fspi.c                    | 1095
Quoted 4 lines

+++++++++++++++++ 8 files changed, 1188 insertions(+)
create mode 100644
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt create mode 100644 drivers/spi/spi-nxp-fspi.c

Quoted 3 lines

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [email protected]

#12 lore raw

Hi Frieder,

Quoted 44 lines

Hi Lukasz,

Quoted 41 lines · Lukasz Majewski

Hi Schrempf,

Quoted 38 lines · Yogesh Narayan Gaur
Quoted 30 lines

- Add driver for NXP FlexSPI host controller

FlexSPI is a flexsible SPI host controller [1], Chapter 30 page
1475, which supports two SPI channels and up to 4 external devices. Each channel supports Single/Dual/Quad/Octal mode data transfer (1/2/4/8 bidirectional data lines) i.e. FlexSPI acts as an interface to external devices, maximum 4, each with up to 8 bidirectional data lines.

- Tested this driver with mtd_debug(Erase/Write/Read) utility and JFFS2 filesystem mounting and booting on NXP LX2160ARDB[2] and LX2160AQDS targets. LX2160ARDB is having two NOR slave device connected on single bus A i.e. A0 and A1 (CS0 and CS1). LX2160AQDS is having two NOR slave device connected on separate
buses one flash on A0 and second on B1 i.e. (CS0 and CS3).
Verified this driver on following SPI NOR flashes:

     Micron, mt35xu512aba, [Read - 1 bit mode]
     Cypress, s25fl512s, [Read - 1/2/4 bit mode]

[1] https://www.nxp.com/docs/en/reference-manual/IMXRT1050RM.pdf
[2]
https://patchwork.kernel.org/project/linux-arm-kernel/list/?submitter=182097

Yogesh Narayan Gaur (5):
spi: spi-mem: Add driver for NXP FlexSPI controller
dt-bindings: spi: add binding file for NXP FlexSPI controller
arm64: dts: lx2160a: add FlexSPI node property
arm64: defconfig: enable NXP FlexSPI driver
MAINTAINERS: add maintainers for the NXP FlexSPI driver

Quoted 2 lines

Changes for v6:
- Rebase on top of v5.0-rc1.

Your patches don't apply to v5.0-rc1. It seems like you have instead rebased onto the for-5.1 or for-next branch of the SPI tree. I guess this is okay, but you should have pointed that out correctly here.

Quoted 8 lines
Quoted 5 lines

If I may ask for a few (1-2) days, so I can test this code on vf610 NXP SoC.

As fair as I remember there were some issues when I tested it a few months back.

You're probably mixing that up. This series is about the FlexSPI controller in the Layerscape SOCs.

Thanks for the explanation - I've indeed mixed up things a bit :-).

I was of course thinking about the QuadSPI driver - as in [1].

Quoted 5 lines

The QuadSPI driver is already in linux-next to be merged in 5.1 [1]. The issues with vf610 existed in the old SPI-NOR driver and probably still exist in the new SPI driver. You are welcome to test the new driver and come up with some fixes.

I've posted some questions on NXP community, but no reply so far.

Quoted 59 lines

Sooner or later, there will probably also be other changes coming up, such as implementation of the dirmap API.

Thanks,
Frieder

[1]:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/spi?h=next-20190109&id=84d043185dbe0d1b4f6db575bd91c834d37e2f78

Quoted 49 lines
Quoted 36 lines
Quoted 32 lines

- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
- Updated s-b tag in all patches.
Changes for v5:
- Rebase on top of v4.20-rc2
- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
Changes for v4:
- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
- Incorporated binding file review comments.
Changes for v3:
- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
Changes for v2:
- Incorporated Boris review comments and drop below patches as per the comments.
- Patch 'spi: add slave device size in spi_device struct'
- Patch 'spi: add flags for octal I/O data transfer'
- Incorporated DTS and Binding file review comments of Shawn Guo and Rob Herring.

   .../devicetree/bindings/spi/spi-nxp-fspi.txt  |   39 +
   MAINTAINERS                                   |    7 +
   .../boot/dts/freescale/fsl-lx2160a-rdb.dts    |   22 +
   .../arm64/boot/dts/freescale/fsl-lx2160a.dtsi |   13 +
   arch/arm64/configs/defconfig                  |    1 +
   drivers/spi/Kconfig                           |   10 +
   drivers/spi/Makefile                          |    1 +
   drivers/spi/spi-nxp-fspi.c                    | 1095
Quoted 4 lines

+++++++++++++++++ 8 files changed, 1188 insertions(+)
create mode 100644
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt create mode 100644 drivers/spi/spi-nxp-fspi.c

Quoted 3 lines

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

Best regards,

Lukasz Majewski

--

Quoted 7 lines
Quoted 4 lines

DENX Software Engineering GmbH, Managing Director: Wolfgang
Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email:
[email protected]

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-59 Fax: (+49)-8142-66989-80 Email: [email protected]

#13 lore raw
In reply to Schrempf Frieder

Hi Frieder,

Quoted 66 lines

-----Original Message-----
From: Schrempf Frieder [mailto:[email protected]]
Sent: Wednesday, January 9, 2019 7:49 PM
To: Yogesh Narayan Gaur <[email protected]>; linux- [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; linux- [email protected]; [email protected]; linux- [email protected]
Subject: Re: [PATCH v6 0/5] spi: spi-mem: Add driver for NXP FlexSPI controller

Quoted 5 lines · Yogesh Narayan Gaur

- Add driver for NXP FlexSPI host controller

FlexSPI is a flexsible SPI host controller [1], Chapter 30 page 1475, which supports two SPI channels and up to 4 external devices. Each channel supports Single/Dual/Quad/Octal mode data transfer (1/2/4/8

bidirectional data lines)

Quoted 1 line

i.e. FlexSPI acts as an interface to external devices, maximum 4, each with up

to 8

Quoted 4 lines

bidirectional data lines.

- Tested this driver with mtd_debug(Erase/Write/Read) utility and JFFS2 filesystem mounting and booting on NXP LX2160ARDB[2] and LX2160AQDS

targets.

Quoted 11 lines

LX2160ARDB is having two NOR slave device connected on single bus A i.e. A0 and A1 (CS0 and CS1).
LX2160AQDS is having two NOR slave device connected on separate buses one flash on A0 and second on B1 i.e. (CS0 and CS3). Verified this driver on following SPI NOR flashes:

    Micron, mt35xu512aba, [Read - 1 bit mode]
    Cypress, s25fl512s, [Read - 1/2/4 bit mode]

[1]
https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww
.nxp.com%2Fdocs%2Fen%2Freference-

manual%2FIMXRT1050RM.pdf&amp;data=02%

Quoted 1 line

7C01%7Cyogeshnarayan.gaur%40nxp.com%7C791570ed6d914f922a6c08d6763 d6c96

Quoted 1 line

%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C1%7C6368264035242944

30&amp;s

Quoted 1 line

data=WTPdd1W4Tn4g6OOVeVVQylZ1Y72KUohWQ5QMxClwcgc%3D&amp;reser ved=0

Quoted 4 lines

[2]
https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fpat
chwork.kernel.org%2Fproject%2Flinux-arm-kernel%2Flist%2F%3Fsubmitter%3

D182097&amp;data=02%7C01%7Cyogeshnarayan.gaur%40nxp.com%7C791570 ed6d91

Quoted 1 line

4f922a6c08d6763d6c96%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C1% 7C6368

Quoted 1 line

26403524294430&amp;sdata=QoAN4HtiTTD6UmToVwD6CfPyWN0C9nSQTBO3 bYSXJtY%3

Quoted 9 lines

D&amp;reserved=0

Yogesh Narayan Gaur (5):
spi: spi-mem: Add driver for NXP FlexSPI controller
dt-bindings: spi: add binding file for NXP FlexSPI controller
arm64: dts: lx2160a: add FlexSPI node property
arm64: defconfig: enable NXP FlexSPI driver
MAINTAINERS: add maintainers for the NXP FlexSPI driver

Quoted 7 lines
Quoted 2 lines

Changes for v6:
- Rebase on top of v5.0-rc1.

Your patches don't apply to v5.0-rc1. It seems like you have instead rebased onto the for-5.1 or for-next branch of the SPI tree. I guess this is okay, but you should have pointed that out correctly here.

Yes, thanks for pointing out.
This patch series is based on 'for-next' branch of SPI tree repo [1].
Actually, I got confused with the Makefile content and that's why mentioned in comment as "Rebase on top of v5.0-rc1", sorry for confusion.
VERSION = 5
PATCHLEVEL = 0
SUBLEVEL = 0
EXTRAVERSION = -rc1

--
Regards
Yogesh Gaur
[1] https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git/

Quoted 16 lines
Quoted 8 lines

- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
- Updated s-b tag in all patches.
Changes for v5:
- Rebase on top of v4.20-rc2
- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
Changes for v4:

Quoted 8 lines

- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
- Incorporated binding file review comments.
Changes for v3:
- Incorporated review comments for
patch 'spi: spi-mem: Add driver for NXP FlexSPI controller'.
Changes for v2:
- Incorporated Boris review comments and drop below patches as per the

Quoted 18 lines

comments.

Quoted 3 lines

- Patch 'spi: add slave device size in spi_device struct'
- Patch 'spi: add flags for octal I/O data transfer'
- Incorporated DTS and Binding file review comments of Shawn Guo and Rob

Herring.

Quoted 13 lines
  .../devicetree/bindings/spi/spi-nxp-fspi.txt  |   39 +
  MAINTAINERS                                   |    7 +
  .../boot/dts/freescale/fsl-lx2160a-rdb.dts    |   22 +
  .../arm64/boot/dts/freescale/fsl-lx2160a.dtsi |   13 +
  arch/arm64/configs/defconfig                  |    1 +
  drivers/spi/Kconfig                           |   10 +
  drivers/spi/Makefile                          |    1 +
  drivers/spi/spi-nxp-fspi.c                    | 1095 +++++++++++++++++
  8 files changed, 1188 insertions(+)

create mode 100644 Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt create mode 100644 drivers/spi/spi-nxp-fspi.c

______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/