spi: fsl_qspi: Add support for i.MX7ULP
PATCH 1/2 spi: fsl_qspi: Add support for i.MX7ULP
Add compatible string and driver data for i.MX7ULP. Meanwhile, the address set to SFA1AD/SFA2AD/SFB1AD/SFB2AD should align with 1KB, because the lowest 10 bits are reserved by the registers definition.
For i.MX7ULP which has only 128Bytes AHB buffer, must align it when setting the registers and selecting cs.
--- drivers/spi/fsl_qspi.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-)
drivers/spi/fsl_qspi.c +16 -6
@@ -231,6 +231,15 @@ static const struct fsl_qspi_devtype_data imx6ul_data = { .little_endian = true, }; +static const struct fsl_qspi_devtype_data imx7ulp_data = { + .rxfifo =SZ_64 , + .txfifo =SZ_64 , + .ahb_buf_size =SZ_128 , + .quirks =QUADSPI_QUIRK_TKT253890 |QUADSPI_QUIRK_4X_INT_CLK | +QUADSPI_QUIRK_USE_TDH_SETTING , + .little_endian = true, +}; +static const struct fsl_qspi_devtype_data ls1021a_data = { .rxfifo =SZ_128 , .txfifo =SZ_64 ,
@@ -485,7 +494,7 @@ static void fsl_qspi_select_mem(struct fsl_qspi *q, struct spi_slave *slave)static void fsl_qspi_read_ahb (struct fsl_qspi *q,const struct spi_mem_op *op) {memcpy_fromio (op->data.buf.in, - q->ahb_addr + q->selected * q->devtype_data->ahb_buf_size, + q->ahb_addr + q->selected *ALIGN (q->devtype_data->ahb_buf_size,0x400 ), op->data.nbytes); }
@@ -589,7 +598,7 @@ static int fsl_qspi_exec_op(struct spi_slave *slave, addr_offset = q->memmap_phy;qspi_writel (q, - q->selected * q->devtype_data->ahb_buf_size + addr_offset, + q->selected *ALIGN (q->devtype_data->ahb_buf_size,0x400 ) + addr_offset, base +QUADSPI_SFAR ); qspi_writel(q, qspi_readl(q, base + QUADSPI_MCR) |
@@ -695,13 +704,13 @@ static int fsl_qspi_default_setup(struct fsl_qspi *q)* We use ahb_buf_size for each chip and set SFA1AD, SFA2AD, SFB1AD, * SFB2AD accordingly. */ -qspi_writel (q, q->devtype_data->ahb_buf_size + addr_offset, +qspi_writel (q,ALIGN (q->devtype_data->ahb_buf_size,0x400 ) + addr_offset, base +QUADSPI_SFA1AD ); -qspi_writel (q, q->devtype_data->ahb_buf_size *2 + addr_offset, +qspi_writel (q,ALIGN (q->devtype_data->ahb_buf_size,0x400 ) *2 + addr_offset, base +QUADSPI_SFA2AD ); -qspi_writel (q, q->devtype_data->ahb_buf_size *3 + addr_offset, +qspi_writel (q,ALIGN (q->devtype_data->ahb_buf_size,0x400 ) *3 + addr_offset, base +QUADSPI_SFB1AD ); -qspi_writel (q, q->devtype_data->ahb_buf_size *4 + addr_offset, +qspi_writel (q,ALIGN (q->devtype_data->ahb_buf_size,0x400 ) *4 + addr_offset, base +QUADSPI_SFB2AD ); q->selected =-1 ;
@@ -799,6 +808,7 @@ static const struct udevice_id fsl_qspi_ids[] = { { .compatible = "fsl,imx6sx-qspi", .data = (ulong)&imx6sx_data, }, { .compatible = "fsl,imx6ul-qspi", .data = (ulong)&imx6ul_data, }, { .compatible = "fsl,imx7d-qspi", .data = (ulong)&imx7d_data, }, + { .compatible = "fsl,imx7ulp-qspi", .data = (ulong)&imx7ulp_data, }, { .compatible = "fsl,ls1021a-qspi", .data = (ulong)&ls1021a_data, }, { .compatible = "fsl,ls1088a-qspi", .data = (ulong)&ls1088a_data, }, { .compatible = "fsl,ls2080a-qspi", .data = (ulong)&ls2080a_data, },
Signature · 1 line
2.7.4
PATCH 2/2 spi: fsl_qspi: Support to use full AHB space on i.MX
i.MX platforms provide large AHB mapped space for QSPI, each controller has 256MB. However, current driver only maps small size (AHB buffer size) of AHB space, this implementation causes i.MX failed to boot M4 with QSPI XIP image.
Add config CONFIG_FSL_QSPI_AHB_FULL_MAP (default enabled for i.MX) to address above problem.
When the config is set:
1. Full AHB space is divided to each CS.
2. A dedicated LUT entry is used for AHB read only.
3. The MODE instruction in LUT is replaced to standard ADDR instruction
4. The address in spi_mem_op is used to SFAR and AHB read
--- drivers/spi/Kconfig | 8 ++++ drivers/spi/fsl_qspi.c | 114 ++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 98 insertions(+), 24 deletions(-)
drivers/spi/Kconfig +8 -0
@@ -149,6 +149,14 @@ config FSL_QSPI used to access the SPI NOR flash on platforms embedding this Freescale IP core. +config FSL_QSPI_AHB_FULL_MAP + bool "Use full AHB memory map space" + depends on FSL_QSPI + default y if ARCH_MX6 || ARCH_MX7 || ARCH_MX7ULP || ARCH_IMX8M + help + Enable the Freescale QSPI driver to use full AHB memory map space for + flash access. + config ICH_SPI bool "Intel ICH SPI driver" help
drivers/spi/fsl_qspi.c +90 -24
204 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH 2/2 spi: fsl_qspi: Support to use full AHB space on i.MX
Quoted 11 lines
i.MX platforms provide large AHB mapped space for QSPI, each controller has 256MB. However, current driver only maps small size (AHB buffer size) of AHB space, this implementation causes i.MX failed to boot M4 with QSPI XIP image.
Add configCONFIG_FSL_QSPI_AHB_FULL_MAP(default enabled for i.MX) to address above problem.
When the config is set:
1. Full AHB space is divided to each CS.
2. A dedicated LUT entry is used for AHB read only.
3. The MODE instruction in LUT is replaced to standard ADDR instruction
4. The address inspi_mem_opis used to SFAR and AHB read
Quoted 3 lines
Signed-off-by Ye Li <[email protected]>Reviewed-by Ashish Kumar <[email protected]>Reviewed-by Kuldeep Singh <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
Re: [PATCH 2/2] spi: fsl_qspi: Support to use full AHB space on i.MX
In reply to Ye LiHi,
Quoted 14 lines · Ye Li
i.MX platforms provide large AHB mapped space for QSPI, each controller has 256MB. However, current driver only maps small size (AHB buffer size) of AHB space, this implementation causes i.MX failed to boot M4 with QSPI XIP image.
Add config
CONFIG_FSL_QSPI_AHB_FULL_MAP(default enabled for i.MX) to address above problem.When the config is set:
1. Full AHB space is divided to each CS.
2. A dedicated LUT entry is used for AHB read only.
3. The MODE instruction in LUT is replaced to standard ADDR instruction
4. The address inspi_mem_opis used to SFAR and AHB read
Quoted 3 lines
Signed-off-by Ye Li <[email protected]>Reviewed-by Ashish Kumar <[email protected]>Reviewed-by Kuldeep Singh <[email protected]>
I know I'm very late, but I seem to have missed this back in the days when it was posted. Unfortunately there are some problems with this change.
1. The way the memory mapping of the attached flash (QSPI NOR?) is implemented here is messy. In Linux we have a dirmap API for this kind of things and it has recently been ported to U-Boot [1][2]. It would be better to use this, similar to what was done here [3].
2. This change breaks reading from the SPI NAND flash used on the Kontron SL i.MX6UL/ULL boards. The read operation returns garbage instead of the actual data on the flash. When I revert this commit or set
# CONFIG_FSL_QSPI_AHB_FULL_MAP is not set
in the defconfig, it works.
Ye, can you come up with a solution for point 1 or if not can we change the default of CONFIG_FSL_QSPI_AHB_FULL_MAP from enabled to disabled, please?
For now I will disable CONFIG_FSL_QSPI_AHB_FULL_MAP in the boards defconfig, but we should fix this globally.
What do you think?
Thanks
Frieder
[1]
https://source.denx.de/u-boot/u-boot/-/commit/f7e1de4c6a43beec438bce04571469145086efed
[2]
https://source.denx.de/u-boot/u-boot/-/commit/463cdf66632a0d67bf824cb43b6c1b41782d0765
[3]
https://source.denx.de/u-boot/u-boot/-/commit/992d02ea737895dc67246bbf7065084bb2721d6b
PATCH 1/2 spi: fsl_qspi: Add support for i.MX7ULP
In reply to Ye LiQuoted 9 lines
Add compatible string and driver data for i.MX7ULP. Meanwhile, the address set to SFA1AD/SFA2AD/SFB1AD/SFB2AD should align with 1KB, because the lowest 10 bits are reserved by the registers definition.
For i.MX7ULP which has only 128Bytes AHB buffer, must align it when setting the registers and selecting cs.Signed-off-by Ye Li <[email protected]>Reviewed-by Ashish Kumar <[email protected]>Reviewed-by Kuldeep Singh <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================