spi: spi-mem: Add a driver for NXP FlexSPI controller
Subsystems (6)
cover spi: spi-mem: Add a driver for NXP FlexSPI controller
- Add a 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.
FlexSPI controller is similar to the existing Freescale/NXP QuadSPI controller with advanced features.
- 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[3], [Read - 1 bit mode]
Cypress, s25fl512s, [Read - 1/2/4 bit mode]Patch 1 adds variable size in spi_device struct, to save the
size of connected slave device.
Patch 2 adds flags for octal I/O data transfer.
Support for octal flash commands and other framework changes would going to be done in different patch set.
Patch 3 adds a driver for the NXP FlexSPI controller, driver is based on
new spi-mem framework.
Patch 4 add binding file for this driver.
Patch 5 add device node property for FlexSPI driver for lx2160 SoC.
Patch 6 enables the config option.
Patch 7 add MAINTAINERS file.
[1] https://www.nxp.com/docs/en/reference-manual/IMXRT1050RM.pdf
[2] https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=9721
[3] https://patchwork.ozlabs.org/project/linux-mtd/list/?series=63445
This series adds below patches:
Yogesh Gaur (7):
spi: add slave device size in spi_device struct
spi: add flags for octal I/O data transfer
spi: spi-mem: Add a driver for NXP FlexSPI controller
dt-bindings: spi: add binding file for NXP FlexSPI driver
arm64: dts: lx2160a: add fspi node property
arm64: defconfig: enable NXP FlexSPI driver
MAINTAINERS: add maintainers for the NXP FlexSPI driver
.../devicetree/bindings/spi/spi-nxp-fspi.txt | 42 + MAINTAINERS | 6 + arch/arm64/boot/dts/freescale/fsl-lx2160a-rdb.dts | 21 + arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi | 12 + arch/arm64/configs/defconfig | 1 + drivers/mtd/devices/m25p80.c | 6 + drivers/mtd/spi-nor/spi-nor.c | 2 + drivers/spi/Kconfig | 10 + drivers/spi/Makefile | 1 + drivers/spi/spi-nxp-fspi.c | 1242 ++++++++++++++++++++ include/linux/spi/spi.h | 4 + 11 files changed, 1347 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.7.4
PATCH 1/7 spi: add slave device size in spi_device struct
Add 'size' data variable in spi_device struct. This is to save the size of the connected slave device.
After slave device scan, spi_nor_scan, size being assigned to this from MTD layer.
SFDP read is being requested before completion of spi_nor_scan() routine, thus populate device size before making read request to the SPI controller.
--- drivers/mtd/devices/m25p80.c | 6 ++++++ drivers/mtd/spi-nor/spi-nor.c | 2 ++ include/linux/spi/spi.h | 2 ++ 3 files changed, 10 insertions(+)
drivers/mtd/devices/m25p80.c +6 -0
@@ -124,6 +124,10 @@ static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len,/* convert the dummy cycles to the number of bytes */ op.dummy.nbytes = (nor->read_dummy * op.dummy.buswidth) /8 ; +/* for case of SFDP header read commands, populate spi device size */ +if (flash->spimem->spi->size ==0 ) + flash->spimem->spi->size = nor->mtd.size; +while (remaining) { op.data.nbytes = remaining <UINT_MAX ? remaining :UINT_MAX ; ret =spi_mem_adjust_op_size (flash->spimem, &op);
@@ -215,6 +219,8 @@ static int m25p_probe(struct spi_mem *spimem)if (ret)return ret; + spi->size = nor->mtd.size; +return mtd_device_register (&nor->mtd, data ? data->parts :NULL , data ? data->nr_parts :0 ); }
drivers/mtd/spi-nor/spi-nor.c +2 -0
@@ -2864,6 +2864,8 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,if (info->flags &SPI_S3AN ) nor->flags |=SNOR_F_READY_XSR_RDY ; + mtd->size = info->sector_size * info->n_sectors; +/* Parse the Serial Flash Discoverable Parameters table. */ ret =spi_nor_init_params (nor, info, ¶ms);if (ret)
include/linux/spi/spi.h +2 -0
@@ -127,6 +127,7 @@ void spi_statistics_add_transfer_stats(struct spi_statistics *stats,* for driver coldplugging, and in uevents used for hotplugging * @cs_gpio: gpio number of the chipselect line (optional, -ENOENT when * not using a GPIO line) +* @size: size of the connected slave device * * @statistics: statistics for the spi_device *
@@ -168,6 +169,7 @@ struct spi_device {void *controller_data;char modalias[SPI_NAME_SIZE ];int cs_gpio;/* chip select gpio */ +u32 size;/* size of slave device */ /* the statistics */ struct spi_statistics statistics;
Signature · 1 line
2.7.4
Re: [PATCH 1/7] spi: add slave device size in spi_device struct
Hi Yogesh,
Thanks for your patch!
Quoted 2 lines · Yogesh Gaur
Add 'size' data variable in
spi_devicestruct. This is to save the size of the connected slave device.
What is the "size" of an SPI slave device?
Quoted 2 lines
After slave device scan,
spi_nor_scan, size being assigned to this from MTD layer.
Ah, this is MTD specific?
include/linux/spi/spi.h void spi_statistics_add_transfer_stats(struct spi_statistics *stats, · line 130
Quoted 13 lines
SFDP read is being requested before completion of
spi_nor_scan()routine, thus populate device size before making read request to the SPI controller.Signed-off-by Yogesh Gaur <[email protected]>include/linux/spi/spi.h +1
-0@@ -127,6 +127,7 @@ void spi_statistics_add_transfer_stats(struct spi_statistics *stats,* for driver coldplugging, and in uevents used for hotplugging * @cs_gpio: gpio number of the chipselect line (optional, -ENOENT when * not using a GPIO line) +* @size: size of the connected slave device
Please document what is the meaning of "size".
include/linux/spi/spi.h struct spi_device { · line 175
Quoted 11 lines
include/linux/spi/spi.h +1
-0* * @statistics: statistics for the spi_device * @@ -168,6 +169,7 @@ struct spi_device {void *controller_data;char modalias[SPI_NAME_SIZE ];int cs_gpio;/* chip select gpio */ +u32 size;/* size of slave device */ /* the statistics */ struct spi_statistics statistics;
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert at linux-m68k.org
In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Re: [PATCH 1/7] spi: add slave device size in spi_device struct
In reply to Yogesh GaurHi,
Quoted 22 lines · On Fri, 31 Aug 2018 15:59:58 +0530 Yogesh Gaur wrote:
Add 'size' data variable in
spi_devicestruct. This is to save the size of the connected slave device.After slave device scan,
spi_nor_scan, size being assigned to this from MTD layer.SFDP read is being requested before completion of
spi_nor_scan()routine, thus populate device size before making read request to the SPI controller.Signed-off-by Yogesh Gaur <[email protected]>--- drivers/mtd/devices/m25p80.c | 6 ++++++ drivers/mtd/spi-nor/spi-nor.c | 2 ++ include/linux/spi/spi.h | 2 ++ 3 files changed, 10 insertions(+)drivers/mtd/devices/m25p80.c +0
-0
drivers/mtd/devices/m25p80.c static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len, · line 130
Quoted 7 lines
drivers/mtd/devices/m25p80.c +4
-0@@ -124,6 +124,10 @@ static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len,/* convert the dummy cycles to the number of bytes */ op.dummy.nbytes = (nor->read_dummy * op.dummy.buswidth) /8 ; +/* for case of SFDP header read commands, populate spi device size */ +if (flash->spimem->spi->size ==0 ) + flash->spimem->spi->size = nor->mtd.size; +
If the 'size' is an spimem specific variable it should be added to the spi_mem struct rather than the spi_device struct.
Lothar Wa?mann
RE: [PATCH 1/7] spi: add slave device size in spi_device struct
Hi Lothar,
Quoted 41 lines
-----Original Message-----
From: Lothar Wa?mann [mailto:LW at KARO-electronics.de]
Sent: Friday, August 31, 2018 5:28 PM
To: Yogesh Narayan Gaur <[email protected]>
Cc: linux-mtd at lists.infradead.org; boris.brezillon at bootlin.com; marek.vasut at gmail.com; linux-spi at vger.kernel.org;
devicetree at vger.kernel.org; mark.rutland at arm.com; robh at kernel.org; linux- kernel at vger.kernel.org; frieder.schrempf at exceet.de; computersforpeace at gmail.com; shawnguo at kernel.org; linux-arm- kernel at lists.infradead.org
Subject: Re: [PATCH 1/7] spi: add slave device size inspi_devicestructHi,
drivers/mtd/devices/m25p80.c static ssize_t m25p80_read(struct spi_nor *nor,
Quoted 22 lines · On Fri, 31 Aug 2018 15:59:58 +0530 Yogesh Gaur wrote:
Add 'size' data variable in
spi_devicestruct. This is to save the size of the connected slave device.After slave device scan,
spi_nor_scan, size being assigned to this from MTD layer.SFDP read is being requested before completion of
spi_nor_scan()routine, thus populate device size before making read request to the SPI controller.Signed-off-by Yogesh Gaur <[email protected]>--- drivers/mtd/devices/m25p80.c | 6 ++++++ drivers/mtd/spi-nor/spi-nor.c | 2 ++ include/linux/spi/spi.h | 2 ++ 3 files changed, 10 insertions(+)(quoted diff) +0
-0
b/drivers/mtd/devices/m25p80.cindex fe260cc..6c7ad86 100644drivers/mtd/devices/m25p80.c +0
-0@@ -124,6 +124,10 @@ static ssize_t m25p80_read(struct spi_nor *nor,
loff_tfrom,size_tlen,Quoted 3 lines
drivers/mtd/devices/m25p80.c +0
-0/* convert the dummy cycles to the number of bytes */ op.dummy.nbytes = (nor->read_dummy * op.dummy.buswidth) /8 ;
Quoted 6 lines
drivers/mtd/devices/m25p80.c static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len, · line 130
Quoted 4 lines
drivers/mtd/devices/m25p80.c +4
-0+/* for case of SFDP header read commands, populate spi device size */ +if (flash->spimem->spi->size ==0 ) + flash->spimem->spi->size = nor->mtd.size; +If the 'size' is an spimem specific variable it should be added to the
spi_memstruct rather than thespi_devicestruct.
Sure, would move 'size' from struct spi_device to the struct spi_mem.
--
Regards
Yogesh Gaur.
Quoted 2 lines
Lothar Wa?mann
Re: [PATCH 1/7] spi: add slave device size in spi_device struct
Hi Yogesh,
Quoted 43 lines · On Mon, 3 Sep 2018 04:47:25 +0000 Yogesh Narayan Gaur…
Hi Lothar,
Quoted 41 lines
-----Original Message-----
From: Lothar Wa?mann [mailto:LW at KARO-electronics.de]
Sent: Friday, August 31, 2018 5:28 PM
To: Yogesh Narayan Gaur <[email protected]>
Cc: linux-mtd at lists.infradead.org; boris.brezillon at bootlin.com; marek.vasut at gmail.com; linux-spi at vger.kernel.org;
devicetree at vger.kernel.org; mark.rutland at arm.com; robh at kernel.org; linux- kernel at vger.kernel.org; frieder.schrempf at exceet.de; computersforpeace at gmail.com; shawnguo at kernel.org; linux-arm- kernel at lists.infradead.org
Subject: Re: [PATCH 1/7] spi: add slave device size inspi_devicestructHi,
drivers/mtd/devices/m25p80.c static ssize_t m25p80_read(struct spi_nor *nor,
Quoted 22 lines · On Fri, 31 Aug 2018 15:59:58 +0530 Yogesh Gaur wrote:
Add 'size' data variable in
spi_devicestruct. This is to save the size of the connected slave device.After slave device scan,
spi_nor_scan, size being assigned to this from MTD layer.SFDP read is being requested before completion of
spi_nor_scan()routine, thus populate device size before making read request to the SPI controller.Signed-off-by Yogesh Gaur <[email protected]>--- drivers/mtd/devices/m25p80.c | 6 ++++++ drivers/mtd/spi-nor/spi-nor.c | 2 ++ include/linux/spi/spi.h | 2 ++ 3 files changed, 10 insertions(+)(quoted diff) +0
-0
b/drivers/mtd/devices/m25p80.cindex fe260cc..6c7ad86 100644drivers/mtd/devices/m25p80.c +0
-0@@ -124,6 +124,10 @@ static ssize_t m25p80_read(struct spi_nor *nor,
loff_tfrom,size_tlen,Quoted 3 lines
drivers/mtd/devices/m25p80.c +0
-0/* convert the dummy cycles to the number of bytes */ op.dummy.nbytes = (nor->read_dummy * op.dummy.buswidth) /8 ;
Quoted 8 lines
Quoted 6 lines
drivers/mtd/devices/m25p80.c static ssize_t m25p80_read(struct spi_nor *nor, loff_t from, size_t len, · line 130
Quoted 4 lines
drivers/mtd/devices/m25p80.c +4
-0+/* for case of SFDP header read commands, populate spi device size */ +if (flash->spimem->spi->size ==0 ) + flash->spimem->spi->size = nor->mtd.size; +If the 'size' is an spimem specific variable it should be added to the
spi_memstruct rather than thespi_devicestruct.Sure, would move 'size' from struct
spi_deviceto the structspi_mem.
Before you send a new version doing that, I'd like to understand why you need this information. Can you wait a bit so I have some time to review the driver?
Thanks,
Boris
PATCH 2/7 spi: add flags for octal I/O data transfer
In reply to Yogesh GaurAdd flags for Octal I/O data transfer
Required for the SPI controller which can do data transfer (TX/RX) on 8 data lines e.g. NXP FlexSPI controller.
SPI_TX_OCTAL: transmit with 8 wires
SPI_RX_OCTAL: receive with 8 wires
--- include/linux/spi/spi.h | 2 ++ 1 file changed, 2 insertions(+)
include/linux/spi/spi.h +2 -0
@@ -164,6 +164,8 @@ struct spi_device {#define SPI_TX_QUAD 0x200/* transmit with 4 wires */ #define SPI_RX_DUAL 0x400/* receive with 2 wires */ #define SPI_RX_QUAD 0x800/* receive with 4 wires */ +#define SPI_TX_OCTAL 0x1000/* transmit with 8 wires */ +#define SPI_RX_OCTAL 0x2000/* receive with 8 wires */ int irq;void *controller_state;void *controller_data;
Signature · 1 line
2.7.4
PATCH 3/7 spi: spi-mem: Add a driver for NXP FlexSPI controller
In reply to Yogesh Gaur- Add a 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 chips (2 buses with 2 CS each).
Chipselect for each flash can be selected as per address assigned in controller specific registers.
FlexSPI controller is similar to the existing Freescale/NXP QuadSPI controller with advanced features.
(1) The FlexSPI controller is driven by the LUT(Look-up Table) registers.
The LUT registers are a look-up-table for sequences of instructions. A valid sequence consists of four LUT registers.
Maximum 32 LUT sequences can be programmed simultaneously.
(2) The definition of the LUT register shows below:
---------------------------------------------------
| INSTR1 | PAD1 | OPRND1 | INSTR0 | PAD0 | OPRND0 |
---------------------------------------------------
There are several types of INSTRx, such as:
CMD : the SPI NOR command. ADDR : the address for the SPI NOR command. DUMMY : the dummy cycles needed by the SPI NOR command.
....
There are several types of PADx, such as:
PAD1 : use a singe I/O line. PAD2 : use two I/O lines. PAD4 : use quad I/O lines. PAD8 : use octal I/O lines.
....
(3) LUTs are being created at run-time based on the commands passed from the spi-mem framework. Thus, using single LUT index.
(4) Software triggered Flash read/write access by IP Bus.
(5) Memory mapped read access by AHB Bus.
(6) 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]- Add config option entry in 'spi-nor/Kconfig' for FlexSPI driver.
- Add entry in the 'spi-nor/Makefile'.
--- drivers/spi/Kconfig | 10 + drivers/spi/Makefile | 1 + drivers/spi/spi-nxp-fspi.c | 1242 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1253 insertions(+) create mode 100644 drivers/spi/spi-nxp-fspi.c
drivers/spi/Kconfig +10 -0
@@ -251,6 +251,16 @@ config SPI_FSL_LPSPI help This enables Freescale i.MX LPSPI controllers in master mode. +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
@@ -59,6 +59,7 @@ obj-$(CONFIG_SPI_MPC52xx) += spi-mpc52xx.o obj-$(CONFIG_SPI_MT65XX) += spi-mt65xx.o obj-$(CONFIG_SPI_MXS) += spi-mxs.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 +1242 -0
1,242 lines not on this page · raw message
Signature · 1 line
2.7.4
Hi Yogesh,
Quoted 10 lines · On Fri, 31 Aug 2018 16:00:00 +0530 Yogesh Gaur <[email protected]>…
- Add a 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.
Quoted 8 lines
It uses new SPI memory interface of the SPI framework to issue flash memory operations to up to four connected flash chips (2 buses with 2 CS each).
Chipselect for each flash can be selected as per address assigned in controller specific registers.FlexSPI controller is similar to the existing Freescale/NXP QuadSPI controller with advanced features.
Yep, I had a quick look at the code and they really look similar. Why not extending the existing driver instead of creating a new one from scratch?
Quoted 23 lines
(1) The FlexSPI controller is driven by the LUT(Look-up Table) registers.
The LUT registers are a look-up-table for sequences of instructions. A valid sequence consists of four LUT registers.
Maximum 32 LUT sequences can be programmed simultaneously.(2) The definition of the LUT register shows below:
---------------------------------------------------
| INSTR1 | PAD1 | OPRND1 | INSTR0 | PAD0 | OPRND0 |
---------------------------------------------------There are several types of INSTRx, such as:
CMD : the SPI NOR command. ADDR : the address for the SPI NOR command. DUMMY : the dummy cycles needed by the SPI NOR command.....
There are several types of PADx, such as:
PAD1 : use a singe I/O line. PAD2 : use two I/O lines. PAD4 : use quad I/O lines. PAD8 : use octal I/O lines.
Quoted 8 lines
....
(3) LUTs are being created at run-time based on the commands passed from the spi-mem framework. Thus, using single LUT index.
(4) Software triggered Flash read/write access by IP Bus.
(5) Memory mapped read access by AHB Bus.
Do we really want to have this level of details in the commit message? I mean, this is something you can document in the driver, but not here.
BTW, you might want to have a look at [1]. I think we can get rid of the ->size field you're adding if this driver implements the dirmap hooks.
Quoted 10 lines
(6) Tested this driver with the
mtd_debugand 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]
Ok, that's good to have in the commit message.
Quoted 2 lines
- Add config option entry in 'spi-nor/Kconfig' for FlexSPI driver.
But this one is useless. If you add a new driver, you have no other choice but to add a new entry in the Kconfig file.
Quoted 3 lines
- Add entry in the 'spi-nor/Makefile'.
Ditto.
Before you re-send a new version, I'd like to understand why you think you need to create a new driver, and I want you to try to implement the dirmap hook and check if you can get rid of the ->size field when doing that.
I also seem one extra benefit to having a single driver for both FlexSPI and QuadSPI IPs: you'll help Frieder debug the last remaining problems you reported on the new QuadSPI driver :-P.
Thanks,
Boris
Hi Boris,
Quoted 32 lines
-----Original Message-----
From: Boris Brezillon [mailto:boris.brezillon at bootlin.com]
Sent: Tuesday, September 4, 2018 8:29 PM
To: Yogesh Narayan Gaur <[email protected]>
Cc: linux-mtd at lists.infradead.org; marek.vasut at gmail.com; linux- spi at vger.kernel.org; devicetree at vger.kernel.org; robh at kernel.org; mark.rutland at arm.com; shawnguo at kernel.org; linux-arm- kernel at lists.infradead.org; computersforpeace at gmail.com; frieder.schrempf at exceet.de; linux-kernel at vger.kernel.org
Subject: Re: [PATCH 3/7] spi: spi-mem: Add a driver for NXP FlexSPI controllerHi Yogesh,
Quoted 16 lines · On Fri, 31 Aug 2018 16:00:00 +0530 Yogesh Gaur <[email protected]>…
- Add a 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 chips (2 buses with
2 CS each).
Chipselect for each flash can be selected as per address assigned in
controller specific registers.
Quoted 6 lines
Quoted 2 lines
FlexSPI controller is similar to the existing Freescale/NXP QuadSPI
controller with advanced features.Yep, I had a quick look at the code and they really look similar. Why not extending the existing driver instead of creating a new one from scratch?
FlexSPI is different controller not related to the QuadSPI controller in its working behavior
Both these controller are having
* Different registers name, registers address, registers functionality etc, section 30.5.2[1]
* Different programming sequence for initialization of the controller, section 30.8.1[1]
* Different programming sequence for performing Read and Write operation using IP, section 30.7.9[1] and AHB mode
* Different programming sequence for checking controller current state like busy or not
* New mechanism to program for the connected slave device i.e. flash access mode and flash memory map 30.7.4[1] and 30.7.5[1]
* New entries added for FlexSPI controller for LUT_XX mode for various commands, section 30.7.8[1]
There are few similarities between these two like LUT programming logic is same
i.e. LUT needs to be programmed in same sequence of 'INSTR PAD OPCODE', but again LUT register address and LUT command mode values are different.
Creating common driver for both FlexSPI and QuadSPI controller, would involve creation of one more layer between driver/spi/spi-xxx and the actual controller driver, this layer would going to have less functionality like doing LUT creation programming and then would re-direct calls to the respective controller driver functionality to perform desired programming sequence.
Quoted 30 lines
Quoted 30 lines
(1) The FlexSPI controller is driven by the LUT(Look-up Table) registers.
The LUT registers are a look-up-table for sequences of instructions. A valid sequence consists of four LUT registers.
Maximum 32 LUT sequences can be programmed simultaneously.(2) The definition of the LUT register shows below:
---------------------------------------------------
| INSTR1 | PAD1 | OPRND1 | INSTR0 | PAD0 | OPRND0 |
---------------------------------------------------There are several types of INSTRx, such as:
CMD : the SPI NOR command. ADDR : the address for the SPI NOR command. DUMMY : the dummy cycles needed by the SPI NOR command.....
There are several types of PADx, such as:
PAD1 : use a singe I/O line. PAD2 : use two I/O lines. PAD4 : use quad I/O lines. PAD8 : use octal I/O lines.....
(3) LUTs are being created at run-time based on the commands passed from the spi-mem framework. Thus, using single LUT index.
(4) Software triggered Flash read/write access by IP Bus.
Quoted 8 lines
Quoted 1 line
(5) Memory mapped read access by AHB Bus.
Do we really want to have this level of details in the commit message? I mean, this is something you can document in the driver, but not here.
BTW, you might want to have a look at [1]. I think we can get rid of the ->size field you're adding if this driver implements the dirmap hooks.
I need size information for the connected device to program the controller register FLSHXXCRO as Flash Chip select is determined by flash access address and Flash size setting in register FLSHXXCR0[FLSHz], section 30.7.9[1].
Link for reference of the driver implementing dirmap hooks was missing in mail, please share.
Quoted 25 lines
Quoted 10 lines
(6) Tested this driver with the
mtd_debugand 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]Ok, that's good to have in the commit message.
Quoted 2 lines
- Add config option entry in 'spi-nor/Kconfig' for FlexSPI driver.
But this one is useless. If you add a new driver, you have no other choice but to add a new entry in the
Kconfigfile.Quoted 3 lines
- Add entry in the 'spi-nor/Makefile'.
Ditto.
Quoted 7 lines
Before you re-send a new version, I'd like to understand why you think you need to create a new driver, and I want you to try to implement the dirmap hook and check if you can get rid of the ->size field when doing that.
I also seem one extra benefit to having a single driver for both FlexSPI and QuadSPI IPs: you'll help Frieder debug the last remaining problems you reported on the new QuadSPI driver :-P.
Regarding testing of the QuadSPI driver on spi-mem framework, I have already given suggestions to the Frieder and my local changes using which flash connected at CS0 and CS1 starts working for read/write/erase commands on ls1088ardb target.
Current v2 which has been shared, data operation for the slave flash device connected at CS1 is not working.
I have to make changes for the calculation of flash base address for the requested chip select and changes in address remapping the buffer in AHB read case for CS1 access to work.
[1] https://www.nxp.com/docs/en/reference-manual/IMXRT1050RM.pdf
--
Regards
Yogesh Gaur
Quoted 4 lines
Thanks,
Boris
Hi Yogesh,
Quoted 87 lines · Yogesh Narayan Gaur
Hi Boris,
Quoted 32 lines
-----Original Message-----
From: Boris Brezillon [mailto:boris.brezillon at bootlin.com]
Sent: Tuesday, September 4, 2018 8:29 PM
To: Yogesh Narayan Gaur <[email protected]>
Cc: linux-mtd at lists.infradead.org; marek.vasut at gmail.com; linux- spi at vger.kernel.org; devicetree at vger.kernel.org; robh at kernel.org; mark.rutland at arm.com; shawnguo at kernel.org; linux-arm- kernel at lists.infradead.org; computersforpeace at gmail.com; frieder.schrempf at exceet.de; linux-kernel at vger.kernel.org
Subject: Re: [PATCH 3/7] spi: spi-mem: Add a driver for NXP FlexSPI controllerHi Yogesh,
Quoted 16 lines · On Fri, 31 Aug 2018 16:00:00 +0530 Yogesh Gaur <[email protected]>…
- Add a 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 chips (2 buses with
2 CS each).
Chipselect for each flash can be selected as per address assigned in
controller specific registers.Quoted 6 lines
Quoted 2 lines
FlexSPI controller is similar to the existing Freescale/NXP QuadSPI
controller with advanced features.Yep, I had a quick look at the code and they really look similar. Why not extending the existing driver instead of creating a new one from scratch?
FlexSPI is different controller not related to the QuadSPI controller in its working behavior
Both these controller are having
* Different registers name, registers address, registers functionality etc, section 30.5.2[1]
* Different programming sequence for initialization of the controller, section 30.8.1[1]
* Different programming sequence for performing Read and Write operation using IP, section 30.7.9[1] and AHB mode
* Different programming sequence for checking controller current state like busy or not
* New mechanism to program for the connected slave device i.e. flash access mode and flash memory map 30.7.4[1] and 30.7.5[1]
* New entries added for FlexSPI controller forLUT_XXmode for various commands, section 30.7.8[1]There are few similarities between these two like LUT programming logic is same
i.e. LUT needs to be programmed in same sequence of 'INSTR PAD OPCODE', but again LUT register address and LUT command mode values are different.Creating common driver for both FlexSPI and QuadSPI controller, would involve creation of one more layer between driver/spi/spi-xxx and the actual controller driver, this layer would going to have less functionality like doing LUT creation programming and then would re-direct calls to the respective controller driver functionality to perform desired programming sequence.
Quoted 32 lines
Quoted 31 lines
(1) The FlexSPI controller is driven by the LUT(Look-up Table) registers.
The LUT registers are a look-up-table for sequences of instructions. A valid sequence consists of four LUT registers.
Maximum 32 LUT sequences can be programmed simultaneously.(2) The definition of the LUT register shows below:
---------------------------------------------------
| INSTR1 | PAD1 | OPRND1 | INSTR0 | PAD0 | OPRND0 |
---------------------------------------------------There are several types of INSTRx, such as:
CMD : the SPI NOR command. ADDR : the address for the SPI NOR command. DUMMY : the dummy cycles needed by the SPI NOR command.....
There are several types of PADx, such as:
PAD1 : use a singe I/O line. PAD2 : use two I/O lines. PAD4 : use quad I/O lines. PAD8 : use octal I/O lines.....
(3) LUTs are being created at run-time based on the commands passed from the spi-mem framework. Thus, using single LUT index.
(4) Software triggered Flash read/write access by IP Bus.
(5) Memory mapped read access by AHB Bus.
Quoted 8 lines
Quoted 6 lines
Do we really want to have this level of details in the commit message? I mean, this is something you can document in the driver, but not here.
BTW, you might want to have a look at [1]. I think we can get rid of the ->size field you're adding if this driver implements the dirmap hooks.
I need size information for the connected device to program the controller register FLSHXXCRO as Flash Chip select is determined by flash access address and Flash size setting in register FLSHXXCR0[FLSHz], section 30.7.9[1].
It's the same situation we had with the QSPI driver before. We decided to **not** pass information about flash size directly to the controller for now. That's why we currently don't support mapping the flash device in the implementation of the QSPI driver.
I think we should not start this discussion all over again for the FlexSPI driver, but stick to what we decided for QSPI.
Quoted 2 lines
Link for reference of the driver implementing dirmap hooks was missing in mail, please share.
I guess Boris meant to link to his PoC implementation of the direct mapping API [1]. When this is available we can easily add support for direct memory mappings to the QuadSPI and FlexSPI drivers.
Quoted 30 lines
Quoted 30 lines
Quoted 11 lines
(6) Tested this driver with the
mtd_debugand 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]Ok, that's good to have in the commit message.
Quoted 2 lines
- Add config option entry in 'spi-nor/Kconfig' for FlexSPI driver.
But this one is useless. If you add a new driver, you have no other choice but to add a new entry in the
Kconfigfile.Quoted 3 lines
- Add entry in the 'spi-nor/Makefile'.
Ditto.
Before you re-send a new version, I'd like to understand why you think you need to create a new driver, and I want you to try to implement the dirmap hook and check if you can get rid of the ->size field when doing that.
Quoted 8 lines
Quoted 3 lines
I also seem one extra benefit to having a single driver for both FlexSPI and QuadSPI IPs: you'll help Frieder debug the last remaining problems you reported on the new QuadSPI driver :-P.
Regarding testing of the QuadSPI driver on spi-mem framework, I have already given suggestions to the Frieder and my local changes using which flash connected at CS0 and CS1 starts working for read/write/erase commands on ls1088ardb target.
Current v2 which has been shared, data operation for the slave flash device connected at CS1 is not working.
I have to make changes for the calculation of flash base address for the requested chip select and changes in address remapping the buffer in AHB read case for CS1 access to work.
Yes you posted your changes to make the driver work for your board. The problem is, that I don't yet understand why they are needed and how they actually fix the chip select issue.
Han has pointed out the reason why ioremap() was added to the driver [2] in the first place and this seems unrelated to the CS selection issue.
Therefore Boris and I have requested more information about how the IP works and more tests from other people.
As long as we don't get more information about the questions posted before [3][4], we are kind of blocked.
[1] https://github.com/bbrezillon/linux/commits/spi-mem-dirmap
[2] http://lists.infradead.org/pipermail/linux-mtd/2018-August/083218.html
[3] http://lists.infradead.org/pipermail/linux-mtd/2018-August/083209.html
[4] http://lists.infradead.org/pipermail/linux-mtd/2018-August/083233.html
Thanks,
Frieder
Hi Frieder,
Quoted 69 lines
-----Original Message-----
From: Frieder Schrempf [mailto:frieder.schrempf at exceet.de]
Sent: Thursday, September 6, 2018 1:56 PM
To: Yogesh Narayan Gaur <[email protected]>; Boris Brezillon <[email protected]>
Cc: linux-mtd at lists.infradead.org; marek.vasut at gmail.com; linux- spi at vger.kernel.org; devicetree at vger.kernel.org; robh at kernel.org; mark.rutland at arm.com; shawnguo at kernel.org; linux-arm- kernel at lists.infradead.org; computersforpeace at gmail.com; linux- kernel at vger.kernel.org
Subject: Re: [PATCH 3/7] spi: spi-mem: Add a driver for NXP FlexSPI controllerQuoted 27 lines
Quoted 11 lines
Hi Yogesh,
Quoted 2 lines · On Fri, 31 Aug 2018 16:00:00 +0530 Yogesh Gaur <[email protected]>…
- Add a driver for NXP FlexSPI host controller
Yep, I had a quick look at the code and they really look similar. Why not extending the existing driver instead of creating a new one from scratch?
FlexSPI is different controller not related to the QuadSPI controller in its working behavior Both these controller are having
* Different registers name, registers address, registers functionality etc, section 30.5.2[1]
* Different programming sequence for initialization of the controller, section 30.8.1[1]
* Different programming sequence for performing Read and Write operation using IP, section 30.7.9[1] and AHB mode
* Different programming sequence for checking controller current state like busy or not
* New mechanism to program for the connected slave device i.e. flash access mode and flash memory map 30.7.4[1] and 30.7.5[1]
* New entries added for FlexSPI controller forLUT_XXmode for various commands, section 30.7.8[1]Quoted 2 lines
There are few similarities between these two like LUT programming logic is same i.e. LUT needs to be programmed in same sequence of 'INSTR
PAD OPCODE', but again LUT register address and LUT command mode values are different.
Quoted 2 lines
Creating common driver for both FlexSPI and QuadSPI controller, would
involve creation of one more layer between driver/spi/spi-xxx and the actual controller driver, this layer would going to have less functionality like doing LUT creation programming and then would re-direct calls to the respective controller driver functionality to perform desired programming sequence.
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
(1) The FlexSPI controller is driven by the LUT(Look-up Table) registers.
The LUT registers are a look-up-table for sequences of instructions. A valid sequence consists of four LUT registers.
Maximum 32 LUT sequences can be programmed simultaneously.Quoted 8 lines
Quoted 6 lines
Do we really want to have this level of details in the commit message? I mean, this is something you can document in the driver, but not here.
BTW, you might want to have a look at [1]. I think we can get rid of the ->size field you're adding if this driver implements the dirmap hooks.
I need size information for the connected device to program the controller
register FLSHXXCRO as Flash Chip select is determined by flash access address and Flash size setting in register FLSHXXCR0[FLSHz], section 30.7.9[1].
Quoted 8 lines
It's the same situation we had with the QSPI driver before. We decided to **not** pass information about flash size directly to the controller for now. That's why we currently don't support mapping the flash device in the implementation of the QSPI driver.
I think we should not start this discussion all over again for the FlexSPI driver, but stick to what we decided for QSPI.
There is difference between FlexSPI and QuadSPI controller functionality in detecting the current CS.
As per table-10.32[1] for QuadSPI controller, access to flash is being assigned as per the address values provided i.e. it would be CS0 if address is between TOP_ADDR_MEMXX and QSPI_AMBA_BASE and CS1 if access is in between TOP_ADDR_MEMA2 and TOP_ADDR_MEMA1.
But for case of FlexSPI controller, section 30.7.5[2], CS is being defined as per the address value lies in below range
- Flash A1 address range: 0x00000000 ~ FA1_SIZE
- Flash A2 address range: FA1_SIZE ~ (FA1_SIZE + FA2_SIZE)
- Flash B1 address range: (FA1_SIZE + FA2_SIZE) ~ (FA1_SIZE + FA2_SIZE + FB1_SIZE)
- Flash B2 address range: FA1_SIZE + FA2_SIZE + FB1_SIZE) ~ (FA1_SIZE + FA2_SIZE + FB1_SIZE + FB2_SIZE) and FAx_SIZE is determined from register FLSHxxCR0[FLASHSZ]
Thus, for QuadSPI controller we can actually go away with the flash size requirement and with the code logic which you have introduced, of using 2 * ahb_buf_size data size for TOP_ADDR_MEMXX bits in SFxxD register, things are working fine.
But for FlexSPI controller its required to have the connected slave device size to detect the current CS.
I have tried the quadspi driver logic in flexspi driver code, but it gives me failure.
Due, to this reason and requirement I have come-up with this solution of getting the connected device size and programming correct value in FLSHxxCR0[FLASHSZ] register
Quoted 8 lines
Quoted 2 lines
Link for reference of the driver implementing dirmap hooks was missing in mail,
please share.
I guess Boris meant to link to his PoC implementation of the direct mapping API [1]. When this is available we can easily add support for direct memory mappings to the QuadSPI and FlexSPI drivers.
I have checked the link, found that size value is being derived from spi_nor.mtd.size variable.
Same being performed in this patch series to detect the size of the slave device.
As per my understanding developed with Boris's code implementation, when direct mapping API interface are available then both QuadSPI and FlexSPI driver needs to be changed as per new introduced ops structure.
[1] https://www.nxp.com/docs/en/reference-manual/VFXXXRM.pdf
[2] https://www.nxp.com/docs/en/reference-manual/IMXRT1050RM.pdf
Regards,
Yogesh Gaur
Quoted 90 lines
Quoted 21 lines
Quoted 21 lines
Quoted 11 lines
(6) Tested this driver with the
mtd_debugand 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]Ok, that's good to have in the commit message.
Quoted 2 lines
- Add config option entry in 'spi-nor/Kconfig' for FlexSPI driver.
But this one is useless. If you add a new driver, you have no other choice but to add a new entry in the
Kconfigfile.Quoted 1 line
Quoted 8 lines
Quoted 8 lines
Quoted 2 lines
- Add entry in the 'spi-nor/Makefile'.
Ditto.
Before you re-send a new version, I'd like to understand why you think you need to create a new driver, and I want you to try to implement the dirmap hook and check if you can get rid of the ->size field
when doing that.
Quoted 6 lines
Quoted 4 lines
I also seem one extra benefit to having a single driver for both FlexSPI and QuadSPI IPs: you'll help Frieder debug the last remaining problems you reported on the new QuadSPI driver :-P.
Regarding testing of the QuadSPI driver on spi-mem framework, I have already
given suggestions to the Frieder and my local changes using which flash connected at CS0 and CS1 starts working for read/write/erase commands on ls1088ardb target.
Quoted 2 lines
Current v2 which has been shared, data operation for the slave flash device
connected at CS1 is not working.
Quoted 1 line
I have to make changes for the calculation of flash base address for the
requested chip select and changes in address remapping the buffer in AHB read case for CS1 access to work.
Yes you posted your changes to make the driver work for your board. The problem is, that I don't yet understand why they are needed and how they actually fix the chip select issue.
Han has pointed out the reason why
ioremap()was added to the driver [2] in the first place and this seems unrelated to the CS selection issue.Therefore Boris and I have requested more information about how the IP works and more tests from other people.
As long as we don't get more information about the questions posted before [3][4], we are kind of blocked.
[1]
https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.
com%2Fbbrezillon%2Flinux%2Fcommits%2Fspi-mem- dirmap&data=02%7C01%7Cyogeshnarayan.gaur%40nxp.com%7Ca2b9f169 9b2c41dff6f208d613d26342%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7 C0%7C636718191692315469&sdata=3QnzkYXNq53eHWcUnpzUMNILtHyA TEemtiU0O9rRUA4%3D&reserved=0
[2]
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.infr
adead.org%2Fpipermail%2Flinux-mtd%2F2018- August%2F083218.html&data=02%7C01%7Cyogeshnarayan.gaur%40nxp.c om%7Ca2b9f1699b2c41dff6f208d613d26342%7C686ea1d3bc2b4c6fa92cd99c5 c301635%7C0%7C0%7C636718191692315469&sdata=D6oroCChTr8oHFGI 9GHuTU8aQLcponHdbOw9UE2C7Og%3D&reserved=0
[3]
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.infr
adead.org%2Fpipermail%2Flinux-mtd%2F2018- August%2F083209.html&data=02%7C01%7Cyogeshnarayan.gaur%40nxp.c om%7Ca2b9f1699b2c41dff6f208d613d26342%7C686ea1d3bc2b4c6fa92cd99c5 c301635%7C0%7C0%7C636718191692325482&sdata=lKK7dxIyRGbLNeHW LjkwQ9m%2Bs9y9sI8dsZYy3BjIxlQ%3D&reserved=0
[4]
https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.infr
adead.org%2Fpipermail%2Flinux-mtd%2F2018- August%2F083233.html&data=02%7C01%7Cyogeshnarayan.gaur%40nxp.c om%7Ca2b9f1699b2c41dff6f208d613d26342%7C686ea1d3bc2b4c6fa92cd99c5 c301635%7C0%7C0%7C636718191692325482&sdata=6kieWJ7zUX2u%2FfE BiWiNEqroHoBwh1GeCOPRoHWSQ7U%3D&reserved=0Thanks,
Frieder
Quoted 105 lines · On Thu, 6 Sep 2018 11:35:13 +0000 Yogesh Narayan Gaur…
Hi Frieder,
Quoted 76 lines
-----Original Message-----
From: Frieder Schrempf [mailto:frieder.schrempf at exceet.de]
Sent: Thursday, September 6, 2018 1:56 PM
To: Yogesh Narayan Gaur <[email protected]>; Boris Brezillon <[email protected]>
Cc: linux-mtd at lists.infradead.org; marek.vasut at gmail.com; linux- spi at vger.kernel.org; devicetree at vger.kernel.org; robh at kernel.org; mark.rutland at arm.com; shawnguo at kernel.org; linux-arm- kernel at lists.infradead.org; computersforpeace at gmail.com; linux- kernel at vger.kernel.org
Subject: Re: [PATCH 3/7] spi: spi-mem: Add a driver for NXP FlexSPI controllerQuoted 28 lines
Quoted 11 lines
Hi Yogesh,
Quoted 2 lines · On Fri, 31 Aug 2018 16:00:00 +0530 Yogesh Gaur <[email protected]>…
- Add a driver for NXP FlexSPI host controller
Yep, I had a quick look at the code and they really look similar. Why not extending the existing driver instead of creating a new one from scratch?
FlexSPI is different controller not related to the QuadSPI controller in its working behavior Both these controller are having
* Different registers name, registers address, registers functionality etc, section 30.5.2[1]
* Different programming sequence for initialization of the controller, section 30.8.1[1]
* Different programming sequence for performing Read and Write operation using IP, section 30.7.9[1] and AHB mode
* Different programming sequence for checking controller current state like busy or not
* New mechanism to program for the connected slave device i.e. flash access mode and flash memory map 30.7.4[1] and 30.7.5[1]
* New entries added for FlexSPI controller forLUT_XXmode for various commands, section 30.7.8[1]Quoted 3 lines
There are few similarities between these two like LUT programming logic is same i.e. LUT needs to be programmed in same sequence of 'INSTR
PAD OPCODE', but again LUT register address and LUT command mode values are different.
Quoted 3 lines
Creating common driver for both FlexSPI and QuadSPI controller, would
involve creation of one more layer between driver/spi/spi-xxx and the actual controller driver, this layer would going to have less functionality like doing LUT creation programming and then would re-direct calls to the respective controller driver functionality to perform desired programming sequence.
Quoted 13 lines
Quoted 13 lines
Quoted 8 lines
(1) The FlexSPI controller is driven by the LUT(Look-up Table) registers.
The LUT registers are a look-up-table for sequences of
instructions. A valid sequence consists of four LUT registers.
Maximum 32 LUT sequences can be programmed simultaneously.Do we really want to have this level of details in the commit message? I mean, this is something you can document in the driver, but not here.
Quoted 6 lines
Quoted 3 lines
BTW, you might want to have a look at [1]. I think we can get rid of the ->size field you're adding if this driver implements the dirmap hooks.
I need size information for the connected device to program the controller
register FLSHXXCRO as Flash Chip select is determined by flash access address and Flash size setting in register FLSHXXCR0[FLSHz], section 30.7.9[1].
Quoted 8 lines
It's the same situation we had with the QSPI driver before. We decided to **not** pass information about flash size directly to the controller for now. That's why we currently don't support mapping the flash device in the implementation of the QSPI driver.
I think we should not start this discussion all over again for the FlexSPI driver, but stick to what we decided for QSPI.
There is difference between FlexSPI and QuadSPI controller functionality in detecting the current CS.
As per table-10.32[1] for QuadSPI controller, access to flash is being assigned as per the address values provided i.e. it would be CS0 if address is between
TOP_ADDR_MEMXXandQSPI_AMBA_BASEand CS1 if access is in betweenTOP_ADDR_MEMA2andTOP_ADDR_MEMA1.But for case of FlexSPI controller, section 30.7.5[2], CS is being defined as per the address value lies in below range
- Flash A1 address range:0x00000000~FA1_SIZE
- Flash A2 address range:FA1_SIZE~ (FA1_SIZE+FA2_SIZE)
- Flash B1 address range: (FA1_SIZE+FA2_SIZE) ~ (FA1_SIZE+FA2_SIZE+FB1_SIZE)
- Flash B2 address range:FA1_SIZE+FA2_SIZE+FB1_SIZE) ~ (FA1_SIZE
+FA2_SIZE+FB1_SIZE+FB2_SIZE) andFAx_SIZEis determined from register FLSHxxCR0[FLASHSZ]
Quoted 7 lines
Thus, for QuadSPI controller we can actually go away with the flash size requirement and with the code logic which you have introduced, of using 2 *
ahb_buf_sizedata size forTOP_ADDR_MEMXXbits in SFxxD register, things are working fine.But for FlexSPI controller its required to have the connected slave device size to detect the current CS.
I don't see why. You should be able to take an arbitrary (big enough) size at first, and only extend it on-the-fly when a dirmap request is done.
Quoted 2 lines
I have tried the quadspi driver
logic in flexspi driver code, but it gives me failure.
Can you detail a bit what's failing?
Quoted 4 lines
Due, to this
reason and requirement I have come-up with this solution of getting the connected device size and programming correct value in FLSHxxCR0[FLASHSZ] register
Alternatively, what we could do is split the memory map in 4 regions of the same size and stick to it. That works if you can define an offset to apply to the address when an access is done through the direct mapping area.
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Link for reference of the driver implementing dirmap hooks was missing in mail,
please share.
Quoted 8 lines
Quoted 4 lines
I guess Boris meant to link to his PoC implementation of the direct mapping API [1]. When this is available we can easily add support for direct memory mappings to the QuadSPI and FlexSPI drivers.
I have checked the link, found that size value is being derived from spi_nor.mtd.size variable. Same being performed in this patch series to detect the size of the slave device.
Well, yes, the result is the same, except it does not require adding a new field to spi_mem and ->attach/detach() hooks to the spi_mem_ops interface (which your implementation is lacking BTW).
Quoted 4 lines
As per my understanding
developed with Boris's code implementation, when direct mapping API interface are available then both QuadSPI and FlexSPI driver needs to be changed as per new introduced ops structure.
It's not a hard requirement, but they would definitely benefit from this extension (mainly a perf improvement).
Hi Boris,
Quoted 136 lines
-----Original Message-----
From: Boris Brezillon [mailto:boris.brezillon at bootlin.com]
Sent: Thursday, September 6, 2018 5:14 PM
To: Yogesh Narayan Gaur <[email protected]>
Cc: Frieder Schrempf <[email protected]>; linux-
mtd at lists.infradead.org; marek.vasut at gmail.com; linux-spi at vger.kernel.org; devicetree at vger.kernel.org; robh at kernel.org; mark.rutland at arm.com; shawnguo at kernel.org; linux-arm-kernel at lists.infradead.org; computersforpeace at gmail.com; linux-kernel at vger.kernel.org
Subject: Re: [PATCH 3/7] spi: spi-mem: Add a driver for NXP FlexSPI controllerQuoted 87 lines · On Thu, 6 Sep 2018 11:35:13 +0000 Yogesh Narayan Gaur…
Hi Frieder,
Quoted 76 lines
-----Original Message-----
From: Frieder Schrempf [mailto:frieder.schrempf at exceet.de]
Sent: Thursday, September 6, 2018 1:56 PM
To: Yogesh Narayan Gaur <[email protected]>; Boris Brezillon <[email protected]>
Cc: linux-mtd at lists.infradead.org; marek.vasut at gmail.com; linux- spi at vger.kernel.org; devicetree at vger.kernel.org; robh at kernel.org; mark.rutland at arm.com; shawnguo at kernel.org; linux-arm- kernel at lists.infradead.org; computersforpeace at gmail.com; linux- kernel at vger.kernel.org
Subject: Re: [PATCH 3/7] spi: spi-mem: Add a driver for NXP FlexSPI controllerQuoted 28 lines
Quoted 11 lines
Hi Yogesh,
Quoted 2 lines · On Fri, 31 Aug 2018 16:00:00 +0530 Yogesh Gaur <[email protected]>…
- Add a driver for NXP FlexSPI host controller
Yep, I had a quick look at the code and they really look similar. Why not extending the existing driver instead of creating a new one from scratch?
FlexSPI is different controller not related to the QuadSPI controller in its working behavior Both these controller are having
* Different registers name, registers address, registers functionality etc, section 30.5.2[1]
* Different programming sequence for initialization of the controller, section 30.8.1[1]
* Different programming sequence for performing Read and Write operation using IP, section 30.7.9[1] and AHB mode
* Different programming sequence for checking controller current state like busy or not
* New mechanism to program for the connected slave device i.e. flash access mode and flash memory map 30.7.4[1] and 30.7.5[1]
* New entries added for FlexSPI controller forLUT_XXmode for various commands, section 30.7.8[1]Quoted 3 lines
There are few similarities between these two like LUT programming logic is same i.e. LUT needs to be programmed in same sequence of 'INSTR
PAD OPCODE', but again LUT register address and LUT command mode values are different.
Quoted 3 lines
Creating common driver for both FlexSPI and QuadSPI controller, would
involve creation of one more layer between driver/spi/spi-xxx and the actual controller driver, this layer would going to have less functionality like doing LUT creation programming and then would re-direct calls to the respective controller driver functionality to perform desired programming sequence.
Quoted 13 lines
Quoted 13 lines
Quoted 8 lines
(1) The FlexSPI controller is driven by the LUT(Look-up Table) registers.
The LUT registers are a look-up-table for sequences of
instructions. A valid sequence consists of four LUT registers.
Maximum 32 LUT sequences can be programmed simultaneously.Do we really want to have this level of details in the commit message? I mean, this is something you can document in the driver, but not here.
Quoted 6 lines
Quoted 3 lines
BTW, you might want to have a look at [1]. I think we can get rid of the ->size field you're adding if this driver implements the dirmap hooks.
I need size information for the connected device to program the controller
register FLSHXXCRO as Flash Chip select is determined by flash access address and Flash size setting in register FLSHXXCR0[FLSHz], section 30.7.9[1].
Quoted 8 lines
It's the same situation we had with the QSPI driver before. We decided to **not** pass information about flash size directly to the controller for now. That's why we currently don't support mapping the flash device in the implementation of the QSPI driver.
I think we should not start this discussion all over again for the FlexSPI driver, but stick to what we decided for QSPI.
Quoted 6 lines
There is difference between FlexSPI and QuadSPI controller functionality in detecting the current CS.
As per table-10.32[1] for QuadSPI controller, access to flash is being assigned as per the address values provided i.e. it would be CS0 if address is between
TOP_ADDR_MEMXXandQSPI_AMBA_BASEand CS1if
Quoted 12 lines
access is in between
TOP_ADDR_MEMA2andTOP_ADDR_MEMA1.But for case of FlexSPI controller, section 30.7.5[2], CS is being defined as per the address value lies in below range
- Flash A1 address range:0x00000000~FA1_SIZE
- Flash A2 address range:FA1_SIZE~ (FA1_SIZE+FA2_SIZE)
- Flash B1 address range: (FA1_SIZE+FA2_SIZE) ~ (FA1_SIZE+FA2_SIZE
+FB1_SIZE)
- Flash B2 address range:FA1_SIZE+FA2_SIZE+FB1_SIZE) ~ (FA1_SIZE
+FA2_SIZE+FB1_SIZE+FB2_SIZE) andFAx_SIZEis determined from register FLSHxxCR0[FLASHSZ]Quoted 7 lines
Thus, for QuadSPI controller we can actually go away with the flash size requirement and with the code logic which you have introduced, of using 2 *
ahb_buf_sizedata size forTOP_ADDR_MEMXXbits in SFxxD register, things are working fine.But for FlexSPI controller its required to have the connected slave device size to detect the current CS.
I don't see why. You should be able to take an arbitrary (big enough) size at first, and only extend it on-the-fly when a dirmap request is done.
Quoted 2 lines
I have tried the quadspi driver
logic in flexspi driver code, but it gives me failure.Can you detail a bit what's failing?
Quoted 8 lines
Quoted 4 lines
Due, to this
reason and requirement I have come-up with this solution of getting the connected device size and programming correct value in FLSHxxCR0[FLASHSZ] registerAlternatively, what we could do is split the memory map in 4 regions of the same size and stick to it. That works if you can define an offset to apply to the address when an access is done through the direct mapping area.
Ok. I would try this and share the result and the failure point, if any.
Meanwhile, can you please review the rest of the driver except _select_mem() functionality and provide your feedback.
Also, as question asked for AHB RX buffer flush when using both IP and AHB mode in quadspi driver.
Same logic has been used in the FlexSPI driver as it's required to flush the AHB RX buffer after using IP mode write operation.
But, in FlexSPI, SWRESET register bit is w1c i.e. it automatically get reset to zero, after setting to 1, after 64 clock cycle. Thus, no explicitly udelay() needs to be added when doing AHB RX buffer invalidation.
Thanks
Yogesh Gaur.
Quoted 27 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Link for reference of the driver implementing dirmap hooks was missing in mail,
please share.
Quoted 8 lines
Quoted 4 lines
I guess Boris meant to link to his PoC implementation of the direct mapping API [1]. When this is available we can easily add support for direct memory mappings to the QuadSPI and FlexSPI drivers.
I have checked the link, found that size value is being derived from spi_nor.mtd.size variable. Same being performed in this patch series to detect the size of the slave device.
Well, yes, the result is the same, except it does not require adding a new field to
spi_memand ->attach/detach() hooks to thespi_mem_opsinterface (which your implementation is lacking BTW).Quoted 4 lines
As per my understanding
developed with Boris's code implementation, when direct mapping API interface are available then both QuadSPI and FlexSPI driver needs to be changed as per new introduced ops structure.It's not a hard requirement, but they would definitely benefit from this extension (mainly a perf improvement).
PATCH 4/7 dt-bindings: spi: add binding file for NXP FlexSPI driver
In reply to Yogesh GaurAdd binding file for NXP FlexSPI driver.
--- .../devicetree/bindings/spi/spi-nxp-fspi.txt | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt new file +42 -0
@@ -0,0 +1,42 @@ +* 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: iconfiguration register address space + - fspi_mmap: memory mapped address space + - interrupts : Should contain the interrupt for the device + +Optional properties: + - big-endian : See common-properties.txt. + +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: flexspi at 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"; + + flash0: mt35xu512aba at 0 { + reg = <0>; + .... + }; + + flash1: mt35xu512aba at 1 { + reg = <1>; + .... + }; +};
Signature · 1 line
2.7.4
RE: [PATCH 4/7] dt-bindings: spi: add binding file for NXP FlexSPI driver
Dear Yogesh,
Quoted 30 lines
-----Original Message-----
From: linux-kernel-owner at vger.kernel.org <linux-kernel-
owner at vger.kernel.org> On Behalf Of Yogesh Gaur
Sent: Friday, August 31, 2018 4:00 PM
To: linux-mtd at lists.infradead.org; boris.brezillon at bootlin.com; marek.vasut at gmail.com; linux-spi at vger.kernel.org;
devicetree at vger.kernel.org
Cc: robh at kernel.org; mark.rutland at arm.com; shawnguo at kernel.org; linux- arm-kernel at lists.infradead.org; computersforpeace at gmail.com; frieder.schrempf at exceet.de; linux-kernel at vger.kernel.org; Yogesh Narayan Gaur <[email protected]>
Subject: [PATCH 4/7] dt-bindings: spi: add binding file for NXP FlexSPI driverAdd binding file for NXP FlexSPI driver.
Signed-off-by Yogesh Gaur <[email protected]>--- .../devicetree/bindings/spi/spi-nxp-fspi.txt | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt new file +0
-0
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt line 6
Quoted 6 lines
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt new file +6
-0@@ -0,0 +1,42 @@ +* 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
Why are we overriding reg property. Is there any special requirement.
Can we use "reg" and "ranges" property in device tree.
Here "reg" represents controller registers and "ranges" represent the memory address of flash.
--pk
RE: [PATCH 4/7] dt-bindings: spi: add binding file for NXP FlexSPI driver
Hi Prabhakar,
Quoted 55 lines
-----Original Message-----
From: Prabhakar Kushwaha
Sent: Monday, September 3, 2018 3:24 PM
To: Yogesh Narayan Gaur <[email protected]>; linux-
mtd at lists.infradead.org; boris.brezillon at bootlin.com; marek.vasut at gmail.com; linux-spi at vger.kernel.org; devicetree at vger.kernel.org
Cc: robh at kernel.org; mark.rutland at arm.com; shawnguo at kernel.org; linux- arm-kernel at lists.infradead.org; computersforpeace at gmail.com; frieder.schrempf at exceet.de; linux-kernel at vger.kernel.org; Yogesh Narayan Gaur <[email protected]>
Subject: RE: [PATCH 4/7] dt-bindings: spi: add binding file for NXP FlexSPI driverDear Yogesh,
Quoted 31 lines
-----Original Message-----
From: linux-kernel-owner at vger.kernel.org <linux-kernel-
owner at vger.kernel.org> On Behalf Of Yogesh Gaur
Sent: Friday, August 31, 2018 4:00 PM
To: linux-mtd at lists.infradead.org; boris.brezillon at bootlin.com; marek.vasut at gmail.com; linux-spi at vger.kernel.org;
devicetree at vger.kernel.org
Cc: robh at kernel.org; mark.rutland at arm.com; shawnguo at kernel.org; linux- arm-kernel at lists.infradead.org; computersforpeace at gmail.com; frieder.schrempf at exceet.de; linux-kernel at vger.kernel.org; Yogesh Narayan Gaur <[email protected]>
Subject: [PATCH 4/7] dt-bindings: spi: add binding file for NXP FlexSPI driverAdd binding file for NXP FlexSPI driver.
Signed-off-by Yogesh Gaur <[email protected]>--- .../devicetree/bindings/spi/spi-nxp-fspi.txt | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt new file +0
-0Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt line 7
Quoted 7 lines
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt new file +7
-0@@ -0,0 +1,42 @@ +* 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 +lengthWhy are we overriding reg property. Is there any special requirement.
Quoted 3 lines
Can we use "reg" and "ranges" property in device tree.
Here "reg" represents controller registers and "ranges" represent the memory address of flash.
'reg' property is being mentioned in the file './Documentation/devicetree/bindings/spi/spi-bus.txt' No mention has been given for the 'ranges' property.
Shawn,
Please suggest, did we add different property node 'reg' for the configuration register address space and 'ranges' for memory mapped address space.
--
Regards
Yogesh Gaur
Quoted 3 lines
--pk
Re: [PATCH 4/7] dt-bindings: spi: add binding file for NXP FlexSPI driver
In reply to Prabhakar KushwahaQuoted 41 lines · On Mon, 3 Sep 2018 09:54:08 +0000 Prabhakar Kushwaha…
Dear Yogesh,
Quoted 30 lines
-----Original Message-----
From: linux-kernel-owner at vger.kernel.org <linux-kernel-
owner at vger.kernel.org> On Behalf Of Yogesh Gaur
Sent: Friday, August 31, 2018 4:00 PM
To: linux-mtd at lists.infradead.org; boris.brezillon at bootlin.com; marek.vasut at gmail.com; linux-spi at vger.kernel.org;
devicetree at vger.kernel.org
Cc: robh at kernel.org; mark.rutland at arm.com; shawnguo at kernel.org; linux- arm-kernel at lists.infradead.org; computersforpeace at gmail.com; frieder.schrempf at exceet.de; linux-kernel at vger.kernel.org; Yogesh Narayan Gaur <[email protected]>
Subject: [PATCH 4/7] dt-bindings: spi: add binding file for NXP FlexSPI driverAdd binding file for NXP FlexSPI driver.
Signed-off-by Yogesh Gaur <[email protected]>--- .../devicetree/bindings/spi/spi-nxp-fspi.txt | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt new file +0
-0Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt line 6
Quoted 6 lines
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt new file +6
-0@@ -0,0 +1,42 @@ +* 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 lengthWhy are we overriding reg property. Is there any special requirement.
Quoted 2 lines
Can we use "reg" and "ranges" property in device tree.
Here "reg" represents controller registers and "ranges" represent the memory address of flash.
No, ranges is not used for that. It's used when you need to convert from one address space to another, which is not what you're describing here. Check section 2.38 of this document [1] for more details.
[1]https://elinux.org/images/c/cf/Power_ePAPR_APPROVED_v1.1.pdf
RE: [PATCH 4/7] dt-bindings: spi: add binding file for NXP FlexSPI driver
Hi Boris,
Currently FlexSPI controller is present in ARM SoC but NXP is coming with PowerPC SoC with same FlexSPI controller.
We are trying to use same binding as defined in this patch-set(tested on ARM64 processors) for PowerPC. Unfortunately, It is showing issue when driver tries to parse 'fspi_mmap'.
We did some investigation and figured out that for ARM device trees Peripherals nodes inside 'soc' node have absolute addresses. For in general NXP's PowerPC device trees, Peripheral nodes have the relative addresses to the unit-address of the parent 'soc' node.
This creates issue for PowerPC if we follow implementation in this patch-set.
Example of device tree used for upcoming PowerPC SoC with FlexSPI controller.
soc at f8000000 {
ranges = <0x0 0x0 0xf8000000 0x4000000>;
.
fspi0: flexspi at 20c0000 {
compatible = "nxp,XXX-fspi";
reg = <0x20c0000 0x10000>, <0xC0000000 0x10000000>;
reg-names = "fspi_base", "fspi_mmap";
.
.
}}
As we can see, Final address of 'fspi_base' (0xf8000000 + 0x20c0000) falls into the parent 'soc' range(CCSR) but for 'fspi_mmap', It is outside of 'soc' range(CCSR). It creates issue when driver tries to parse 'fspi_mmap'.
As per definition of ranges, this field can't be used to solve this problem.
Please suggest how to implement the "fspi_mmap"(memory mapping address and length) in case of PowerPC.
Thanks,
Jagdish
Quoted 74 lines
-----Original Message-----
From: linux-kernel-owner at vger.kernel.org <linux-kernel- owner at vger.kernel.org> On Behalf Of Boris Brezillon
Sent: Tuesday, September 4, 2018 6:16 PM
To: Prabhakar Kushwaha <[email protected]>
Cc: Yogesh Narayan Gaur <[email protected]>; linux- mtd at lists.infradead.org; marek.vasut at gmail.com; linux- spi at vger.kernel.org; devicetree at vger.kernel.org; robh at kernel.org; mark.rutland at arm.com; shawnguo at kernel.org; linux-arm- kernel at lists.infradead.org; computersforpeace at gmail.com; frieder.schrempf at exceet.de; linux-kernel at vger.kernel.org
Subject: Re: [PATCH 4/7] dt-bindings: spi: add binding file for NXP FlexSPI driverQuoted 43 lines · On Mon, 3 Sep 2018 09:54:08 +0000 Prabhakar Kushwaha…
Dear Yogesh,
Quoted 31 lines
-----Original Message-----
From: linux-kernel-owner at vger.kernel.org <linux-kernel- owner at vger.kernel.org> On Behalf Of Yogesh Gaur
Sent: Friday, August 31, 2018 4:00 PM
To: linux-mtd at lists.infradead.org; boris.brezillon at bootlin.com; marek.vasut at gmail.com; linux-spi at vger.kernel.org; devicetree at vger.kernel.org
Cc: robh at kernel.org; mark.rutland at arm.com; shawnguo at kernel.org; linux- arm-kernel at lists.infradead.org; computersforpeace at gmail.com; frieder.schrempf at exceet.de; linux-kernel at vger.kernel.org; Yogesh Narayan Gaur <[email protected]>
Subject: [PATCH 4/7] dt-bindings: spi: add binding file for NXP FlexSPI driverAdd binding file for NXP FlexSPI driver.
Signed-off-by Yogesh Gaur <[email protected]>--- .../devicetree/bindings/spi/spi-nxp-fspi.txt | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt new file +0
-0Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt line 7
Quoted 7 lines
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt new file +7
-0@@ -0,0 +1,42 @@ +* 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 +lengthWhy are we overriding reg property. Is there any special requirement.
Quoted 2 lines
Can we use "reg" and "ranges" property in device tree. Here "reg" represents controller registers and "ranges" represent the
memory address of flash.
No, ranges is not used for that. It's used when you need to convert from one address space to another, which is not what you're describing here. Check section 2.38 of this document [1] for more details.
[1]https://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fe linux.org%2Fimages%2Fc%2Fcf%2FPower_ePAPR_APPROVED_v1.1.pdf& data=02%7C01%7Cjagdish.gediya%40nxp.com%7C5bdb57713bd4403a39e90 8d6126472a0%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7C63671 6619958727753&sdata=TB4mbWEm0opk58oPAVEOQFM0xeAFxCsqdzw 37BPuE3A%3D&reserved=0
Rob Herring
maintainerPATCH 4/7 dt-bindings: spi: add binding file for NXP FlexSPI driver
In reply to Yogesh GaurQuoted 1 line · Yogesh Gaur
Add binding file for NXP FlexSPI driver.
Bindings are for h/w, not drivers.
Quoted 28 lines
Signed-off-by Yogesh Gaur <[email protected]>--- .../devicetree/bindings/spi/spi-nxp-fspi.txt | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/spi-nxp-fspi.txtDocumentation/devicetree/bindings/spi/spi-nxp-fspi.txt new file +15
-0@@ -0,0 +1,42 @@ +* 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: iconfiguration register address space + - fspi_mmap: memory mapped address space + - interrupts : Should contain the interrupt for the device + +Optional properties: + - big-endian : See common-properties.txt. + +Required SPI slave node properties:
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt line 25
Quoted 10 lines
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt new file +10
-0+ - 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: flexspi at 20c0000 {
spi at ...
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt line 33
Quoted 8 lines
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt new file +8
-0+ 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"; + + flash0: mt35xu512aba at 0 {
flash at 0
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt line 38
Quoted 5 lines
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt new file +5
-0+ reg = <0>; + .... + }; + + flash1: mt35xu512aba at 1 {
flash at 1
Make sure to fix the dts patch too.
Quoted 7 lines
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt new file +4
-0+ reg = <1>; + .... + }; +};Signature · 1 line
2.7.4
PATCH 5/7 arm64: dts: lx2160a: add fspi node property
In reply to Yogesh GaurAdd 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.
--- arch/arm64/boot/dts/freescale/fsl-lx2160a-rdb.dts | 21 +++++++++++++++++++++ arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi | 12 ++++++++++++ 2 files changed, 33 insertions(+)
arch/arm64/boot/dts/freescale/fsl-lx2160a-rdb.dts +21 -0
@@ -32,6 +32,27 @@ status = "okay"; }; +&fspi { + status = "okay"; + flash0: mt35xu512aba at 0 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "m25p80"; + m25p,fast-read; + spi-max-frequency = <20000000>; + reg = <0>; + }; + + flash1: mt35xu512aba at 1 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "m25p80"; + m25p,fast-read; + spi-max-frequency = <20000000>; + reg = <1>; + }; +}; + &i2c0 { status = "okay"; pca9547 at 77 {
arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi +12 -0
@@ -568,5 +568,17 @@ timeout-sec = <30>; }; + fspi: flexspi at 20c0000 { + status = "disabled"; + 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"; + }; }; };
Signature · 1 line
2.7.4
Re: [PATCH 5/7] arm64: dts: lx2160a: add fspi node property
Quoted 17 lines · Yogesh 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.Signed-off-by Yogesh Gaur <[email protected]>--- arch/arm64/boot/dts/freescale/fsl-lx2160a-rdb.dts | 21 +++++++++++++++++++++ arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi | 12 ++++++++++++ 2 files changed, 33 insertions(+)arch/arm64/boot/dts/freescale/fsl-lx2160a-rdb.dts +0
-0
arch/arm64/boot/dts/freescale/fsl-lx2160a-rdb.dts line 36
Quoted 5 lines
arch/arm64/boot/dts/freescale/fsl-lx2160a-rdb.dts +2
-0@@ -32,6 +32,27 @@ status = "okay"; }; +&fspi { + status = "okay";
Have a newline between property and child node.
arch/arm64/boot/dts/freescale/fsl-lx2160a-rdb.dts line 37
Quoted 1 line
arch/arm64/boot/dts/freescale/fsl-lx2160a-rdb.dts +1
-0+ flash0: mt35xu512aba at 0 {
Generic name for node, and specific name for label.
arch/arm64/boot/dts/freescale/fsl-lx2160a-rdb.dts line 40
Quoted 3 lines
arch/arm64/boot/dts/freescale/fsl-lx2160a-rdb.dts +3
-0+ #address-cells = <1>; + #size-cells = <1>; + compatible = "m25p80";
Please take a look at bindings doc jedec,spi-nor.txt on how compatible should be written.
Quoted 23 lines
arch/arm64/boot/dts/freescale/fsl-lx2160a-rdb.dts +15
-0+ m25p,fast-read; + spi-max-frequency = <20000000>; + reg = <0>; + }; + + flash1: mt35xu512aba at 1 { + #address-cells = <1>; + #size-cells = <1>; + compatible = "m25p80"; + m25p,fast-read; + spi-max-frequency = <20000000>; + reg = <1>; + }; +}; + &i2c0 { status = "okay"; pca9547 at 77 {arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi +0
-0
arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi line 572
Quoted 5 lines
arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi +2
-0@@ -568,5 +568,17 @@ timeout-sec = <30>; }; + fspi: flexspi at 20c0000 { + status = "disabled";
We conventionally put 'status' line at the end of property list.
Shawn
Quoted 20 lines
arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi +10
-0+ 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"; + }; }; };Signature · 7 lines
2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel at lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 6/7 arm64: defconfig: enable NXP FlexSPI driver
In reply to Yogesh GaurEnable driver support of NXP FlexSPI controller.
--- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
@@ -335,6 +335,7 @@ CONFIG_SPI_QUP=y CONFIG_SPI_ROCKCHIP=y CONFIG_SPI_S3C64XX=y CONFIG_SPI_SPIDEV=m +CONFIG_SPI_NXP_FLEXSPI=y CONFIG_SPMI=y CONFIG_PINCTRL_IPQ8074=y CONFIG_PINCTRL_SINGLE=y
Signature · 1 line
2.7.4
PATCH 7/7 MAINTAINERS: add maintainers for the NXP FlexSPI driver
In reply to Yogesh GaurAdd maintainers for the NXP FlexSPI driver
--- MAINTAINERS | 6 ++++++ 1 file changed, 6 insertions(+)
MAINTAINERS +6 -0
@@ -10228,6 +10228,12 @@ L: linux-nfc at lists.01.org (moderated for non-subscribers) S: Supported F: drivers/nfc/nxp-nci +NXP FSPI DRIVER +M: Yogesh Gaur <[email protected]> +L: linux-spi at vger.kernel.org +S: Maintained +F: drivers/spi/spi-nxp-fspi.c + OBJTOOL M: Josh Poimboeuf <[email protected]> M: Peter Zijlstra <[email protected]>
Signature · 1 line
2.7.4
Hi Yogesh,
Quoted 21 lines · On Fri, 31 Aug 2018 15:59:57 +0530 Yogesh Gaur <[email protected]>…
- Add a 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.FlexSPI controller is similar to the existing Freescale/NXP QuadSPI controller with advanced features.
- 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[3], [Read - 1 bit mode] Cypress, s25fl512s, [Read - 1/2/4 bit mode]
Quoted 7 lines
Patch 1 adds variable size in
spi_devicestruct, to save the
size of connected slave device.
Patch 2 adds flags for octal I/O data transfer.
Support for octal flash commands and other framework changes would going to be done in different patch set.
Patch 3 adds a driver for the NXP FlexSPI controller, driver is based on
new spi-mem framework.
Can we please omit octa mode support for now and focus on single/dual/quad SPI support? That is, drop patch 2, and do not set the OCTAL flags in patch 3.
Regards,
Boris
Quoted 34 lines
Patch 4 add binding file for this driver.
Patch 5 add device node property for FlexSPI driver for lx2160 SoC. Patch 6 enables the config option.
Patch 7 addMAINTAINERSfile.[1] https://www.nxp.com/docs/en/reference-manual/IMXRT1050RM.pdf
[2] https://patchwork.kernel.org/project/linux-arm-kernel/list/?series=9721
[3] https://patchwork.ozlabs.org/project/linux-mtd/list/?series=63445This series adds below patches:
Yogesh Gaur (7):
spi: add slave device size inspi_devicestruct
spi: add flags for octal I/O data transfer
spi: spi-mem: Add a driver for NXP FlexSPI controller
dt-bindings: spi: add binding file for NXP FlexSPI driver
arm64: dts: lx2160a: add fspi node property
arm64: defconfig: enable NXP FlexSPI driver
MAINTAINERS: add maintainers for the NXP FlexSPI driver.../devicetree/bindings/spi/spi-nxp-fspi.txt | 42 + MAINTAINERS | 6 + arch/arm64/boot/dts/freescale/fsl-lx2160a-rdb.dts | 21 + arch/arm64/boot/dts/freescale/fsl-lx2160a.dtsi | 12 + arch/arm64/configs/defconfig | 1 + drivers/mtd/devices/m25p80.c | 6 + drivers/mtd/spi-nor/spi-nor.c | 2 + drivers/spi/Kconfig | 10 + drivers/spi/Makefile | 1 + drivers/spi/spi-nxp-fspi.c | 1242 ++++++++++++++++++++ include/linux/spi/spi.h | 4 + 11 files changed, 1347 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt create mode 100644 drivers/spi/spi-nxp-fspi.c