spi: fspi: enable fspi on imx8qxp and imx8mm
Subsystems (4)
PATCH v2 1/5 spi: fspi: enable fspi on imx8qxp and imx8mm
From: Han Xu <[email protected]>
Pull in this patch from NXP's upstream repo to
enable fspi on imx8qxp and imx8mm
---
V2: Reorder s-o-b lines to give credit in proper order.
drivers/spi/spi-nxp-fspi.c +18 -0
@@ -324,6 +324,22 @@ static const struct nxp_fspi_devtype_data lx2160a_data = { .little_endian = true, /* little-endian */ }; +static const struct nxp_fspi_devtype_data imx8mm_data = { + .rxfifo =SZ_512 ,/* (64 * 64 bits) */ + .txfifo =SZ_1K ,/* (128 * 64 bits) */ + .ahb_buf_size =SZ_2K ,/* (256 * 64 bits) */ + .quirks =0 , + .little_endian = true,/* little-endian */ +}; + +static const struct nxp_fspi_devtype_data imx8qxp_data = { + .rxfifo =SZ_512 ,/* (64 * 64 bits) */ + .txfifo =SZ_1K ,/* (128 * 64 bits) */ + .ahb_buf_size =SZ_2K ,/* (256 * 64 bits) */ + .quirks =0 , + .little_endian = true,/* little-endian */ +}; +struct nxp_fspi {void __iomem *iobase;void __iomem *ahb_addr;
@@ -1076,6 +1092,8 @@ static int nxp_fspi_resume(struct device *dev)static const struct of_device_id nxp_fspi_dt_ids[] = { { .compatible ="nxp,lx2160a-fspi" , .data = (void *)&lx2160a_data, }, + { .compatible ="nxp,imx8mm-fspi" , .data = (void *)&imx8mm_data, }, + { .compatible ="nxp,imx8qxp-fspi" , .data = (void *)&imx8qxp_data, }, {/* sentinel */ } };MODULE_DEVICE_TABLE (of, nxp_fspi_dt_ids);
Signature · 1 line
2.24.0
PATCH v2 2/5 spi: fspi: dynamically alloc AHB memory
From: Han Xu <[email protected]>
Apply patch from NXP upstream repo to
dynamically allocate AHB memory as needed.
---
V2: Reorder s-o-b lines to give credit in proper order.
drivers/spi/spi-nxp-fspi.c +34 -6
@@ -307,6 +307,7 @@#define POLL_TOUT 5000#define NXP_FSPI_MAX_CHIPSELECT 4 +#define NXP_FSPI_MIN_IOMAP SZ_4Mstruct nxp_fspi_devtype_data {unsigned int rxfifo;
@@ -345,6 +346,8 @@ struct nxp_fspi {void __iomem *ahb_addr;u32 memmap_phy;u32 memmap_phy_size; +u32 memmap_start; +u32 memmap_len;struct clk *clk, *clk_en;struct device *dev;struct completion c;
@@ -657,12 +660,35 @@ static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi) f->selected = spi->chip_select; } -static void nxp_fspi_read_ahb (struct nxp_fspi *f,const struct spi_mem_op *op) +static int nxp_fspi_read_ahb (struct nxp_fspi *f,const struct spi_mem_op *op) { +u32 start = op->addr.val;u32 len = op->data.nbytes; +/* if necessary, ioremap before AHB read */ +if ((!f->ahb_addr) || start < f->memmap_start || + start + len > f->memmap_start + f->memmap_len) { +if (f->ahb_addr) +iounmap (f->ahb_addr); + + f->memmap_start = start; + f->memmap_len = len >NXP_FSPI_MIN_IOMAP ? + len :NXP_FSPI_MIN_IOMAP ; + + f->ahb_addr =ioremap_wc (f->memmap_phy + f->memmap_start, + f->memmap_len); + +if (!f->ahb_addr) { +dev_err (f->dev,"failed to alloc memory\n" ); +return -ENOMEM ; + } + } +/* Read out the data directly from the AHB buffer. */ -memcpy_fromio (op->data.buf.in, (f->ahb_addr + op->addr.val), len); +memcpy_fromio (op->data.buf.in, + f->ahb_addr + start - f->memmap_start, len); + +return 0 ; } static void nxp_fspi_fill_txfifo(struct nxp_fspi *f,
@@ -822,7 +848,7 @@ static int nxp_fspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)*/ if (op->data.nbytes > (f->devtype_data->rxfifo -4 ) && op->data.dir ==SPI_MEM_DATA_IN ) { -nxp_fspi_read_ahb (f, op); + err =nxp_fspi_read_ahb (f, op); }else {if (op->data.nbytes && op->data.dir ==SPI_MEM_DATA_OUT )nxp_fspi_fill_txfifo (f, op);
@@ -992,9 +1018,8 @@ static int nxp_fspi_probe(struct platform_device *pdev)/* find the resources - controller memory mapped space */ res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"fspi_mmap" ); - f->ahb_addr =devm_ioremap_resource (dev, res); -if (IS_ERR (f->ahb_addr)) { - ret =PTR_ERR (f->ahb_addr); +if (IS_ERR (res)) { + ret =PTR_ERR (res); goto err_put_ctrl; }
@@ -1073,6 +1098,9 @@ static int nxp_fspi_remove(struct platform_device *pdev)mutex_destroy (&f->lock); +if (f->ahb_addr) +iounmap (f->ahb_addr); +return 0 ; }
Signature · 1 line
2.24.0
Fabio Estevam
reviewerRe: [PATCH V2 2/5] spi: fspi: dynamically alloc AHB memory
Quoted 5 lines · Adam Ford
From: Han Xu <[email protected]>
Apply patch from NXP upstream repo to
dynamically allocate AHB memory as needed.
The commit log could be improved here. What is the motivation for doing this?
drivers/spi/spi-nxp-fspi.c static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi) · line 682
Quoted 2 lines
drivers/spi/spi-nxp-fspi.c +2
-0+if (!f->ahb_addr) { +dev_err (f->dev,"failed to alloc memory\n" );
There is no need for this error message as the MM core will take care of it.
Re: [PATCH V2 2/5] spi: fspi: dynamically alloc AHB memory
Quoted 9 lines · Fabio Estevam
Quoted 5 lines · Adam Ford
From: Han Xu <[email protected]>
Apply patch from NXP upstream repo to
dynamically allocate AHB memory as needed.The commit log could be improved here. What is the motivation for doing this?
My motivation is to get the flexspi on the i.MX8MM to work, and I did a list of the patches applied on the NXP branch to see what was applied on top of their 4.19 kernel and this patch series generated from that list. Most of the NXP commits are one-line commits, and I don't know the motivation for what's happening. NXP did it, and I know it works on the Flexspi driver.
Maybe Han Xu can comment, since it's really his patch.
adam
Quoted 5 lines
drivers/spi/spi-nxp-fspi.c static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi) · line 682
Quoted 3 lines
drivers/spi/spi-nxp-fspi.c +2
-0+if (!f->ahb_addr) { +dev_err (f->dev,"failed to alloc memory\n" );There is no need for this error message as the MM core will take care of it.
Mark Brown
maintainerRe: [PATCH V2 2/5] spi: fspi: dynamically alloc AHB memory
Quoted 6 lines · Adam Ford
My motivation is to get the flexspi on the i.MX8MM to work, and I did a list of the patches applied on the NXP branch to see what was applied on top of their 4.19 kernel and this patch series generated from that list. Most of the NXP commits are one-line commits, and I don't know the motivation for what's happening. NXP did it, and I know it works on the Flexspi driver.
Adding new compatibles and so on seems fine but the patches making random changes without explanation like the one for octal mode I just replied to are more worrying, do they work with older versions of the IP or in all use cases for example? I'd suggest cutting the initial patch series down to the bare minimum needed to get things working and then building on top of that if that's not already been done.
Re: [PATCH V2 2/5] spi: fspi: dynamically alloc AHB memory
Quoted 10 lines · Mark Brown
Quoted 6 lines · Adam Ford
My motivation is to get the flexspi on the i.MX8MM to work, and I did a list of the patches applied on the NXP branch to see what was applied on top of their 4.19 kernel and this patch series generated from that list. Most of the NXP commits are one-line commits, and I don't know the motivation for what's happening. NXP did it, and I know it works on the Flexspi driver.
Quoted 6 lines
Adding new compatibles and so on seems fine but the patches making random changes without explanation like the one for octal mode I just replied to are more worrying, do they work with older versions of the IP or in all use cases for example? I'd suggest cutting the initial patch series down to the bare minimum needed to get things working and then building on top of that if that's not already been done.
The original author was copied on the initial commit. I literally generated the patch from NXP's branch, added my notes, and pushed them to the mailing lists after testing them on the the Linux master
branch. I am a bit disappointed that NXP's author hasn't responded
to any of the comments or feedback. NXP knows their hardware and better understands the details as to what is happening and why. In any case, I'll try to scale the patch series back to just enough to get it working on the i.MX8M Mini. I'll expand a bit on the commit message based on what I've learned about the various in-implemented quirks and send a V2 series.
adam
Mark Brown
maintainerRe: [PATCH V2 2/5] spi: fspi: dynamically alloc AHB memory
Quoted 5 lines · Adam Ford
The original author was copied on the initial commit. I literally generated the patch from NXP's branch, added my notes, and pushed them to the mailing lists after testing them on the the Linux master
branch. I am a bit disappointed that NXP's author hasn't responded
to any of the comments or feedback. NXP knows their hardware and
Bear in mind that it's been the spring festival and there's been quite a bit of delay in getting back to work in China resulting from coronavirus stuff so hopefully it's just a delay in replying.
Han Xu
maintainerRE: [EXT] Re: [PATCH V2 2/5] spi: fspi: dynamically alloc AHB memory
Quoted 26 lines
-----Original Message-----
From: Mark Brown <[email protected]>
Sent: Thursday, February 13, 2020 12:46 PM
To: Adam Ford <[email protected]>
Cc: Fabio Estevam <[email protected]>; linux-spi <[email protected]>; Han Xu <[email protected]>; Yogesh Gaur <[email protected]>; Ashish Kumar <[email protected]>; Rob Herring <[email protected]>; Mark Rutland <[email protected]>; Shawn Guo <[email protected]>; Sascha Hauer <[email protected]>; Pengutronix Kernel Team <[email protected]>; dl-linux-imx <[email protected]>; open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS
<[email protected]>; linux-kernel <[email protected]>; moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE <linux-arm- [email protected]>
Subject: [EXT] Re: [PATCH V2 2/5] spi: fspi: dynamically alloc AHB memoryQuoted 5 lines · Adam Ford
The original author was copied on the initial commit. I literally generated the patch from NXP's branch, added my notes, and pushed them to the mailing lists after testing them on the the Linux master
branch. I am a bit disappointed that NXP's author hasn't responded
to any of the comments or feedback. NXP knows their hardware and
Quoted 3 lines
Bear in mind that it's been the spring festival and there's been quite a bit of delay in getting back to work in China resulting from coronavirus stuff so hopefully it's just a delay in replying.
The FSPI is a shared IP with other NXP BU. We are debugging an issue may related to this patch. I will resend the patch set after the root cause found.
PATCH v2 3/5 spi: spi-nxp-fspi: Enable the Octal Mode in MCR0
In reply to Adam FordFrom: Han Xu <[email protected]>
Apply patch from NXP upstream repo to
Enable the octal combination mode in MCR0
---
V2: Reorder s-o-b lines to give credit in proper order.
drivers/spi/spi-nxp-fspi.c +3 -2
@@ -913,8 +913,9 @@ static int nxp_fspi_default_setup(struct nxp_fspi *f)fspi_writel (f,FSPI_DLLBCR_OVRDEN , base +FSPI_DLLBCR );/* enable module */ -fspi_writel (f,FSPI_MCR0_AHB_TIMEOUT (0xFF ) |FSPI_MCR0_IP_TIMEOUT (0xFF ), - base +FSPI_MCR0 ); +fspi_writel (f,FSPI_MCR0_AHB_TIMEOUT (0xFF ) | +FSPI_MCR0_IP_TIMEOUT (0xFF ) | (u32 )FSPI_MCR0_OCTCOMB_EN , + base +FSPI_MCR0 );/* * Disable same device enable bit and configure all slave devices
Signature · 1 line
2.24.0
Mark Brown
maintainerRe: [PATCH V2 3/5] spi: spi-nxp-fspi: Enable the Octal Mode in MCR0
Quoted 4 lines · Adam Ford
From: Han Xu <[email protected]>
Apply patch from NXP upstream repo to
Enable the octal combination mode in MCR0
Why?
PATCH v2 4/5 dt-bindings: spi: spi-nxp-fspi: Add support for imx8mm, imx8qxp
In reply to Adam FordAdd support for nxp,imx8qxp-fspi and nxp,imx8mm-fspi do the bindings document.
---
V2: No change
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt +3 -0
@@ -2,6 +2,9 @@ Required properties: - compatible : Should be "nxp,lx2160a-fspi" + "nxp,imx8qxp-fspi" + "nxp,imx8mm-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:
Signature · 1 line
2.24.0
Rob Herring
maintainerRe: [PATCH V2 4/5] dt-bindings: spi: spi-nxp-fspi: Add support for imx8mm, imx8qxp
Quoted 1 line · Adam Ford
Add support for nxp,imx8qxp-fspi and nxp,imx8mm-fspi do the bindings
s/do/to/
Quoted 11 lines
document.
Signed-off-by Adam Ford <[email protected]>---
V2: No changeDocumentation/devicetree/bindings/spi/spi-nxp-fspi.txt +0
-0
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt line 6
Quoted 5 lines
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt +2
-0@@ -2,6 +2,9 @@ Required properties: - compatible : Should be "nxp,lx2160a-fspi" + "nxp,imx8qxp-fspi" + "nxp,imx8mm-fspi"
All 3 are different and no compatibility?
Quoted 7 lines
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt +1
-0+ - reg : First contains the register location and length, Second contains the memory mapping address and length - reg-names : Should contain the resource reg names:Signature · 1 line
2.24.0
Re: [PATCH V2 4/5] dt-bindings: spi: spi-nxp-fspi: Add support for imx8mm, imx8qxp
Quoted 5 lines · Rob Herring
Quoted 1 line · Adam Ford
Add support for nxp,imx8qxp-fspi and nxp,imx8mm-fspi do the bindings
s/do/to/
Oops. Thanks for catching that.
Quoted 13 lines
Quoted 13 lines
document.
Signed-off-by Adam Ford <[email protected]>---
V2: No changeDocumentation/devicetree/bindings/spi/spi-nxp-fspi.txt +0
-0@@ -2,6 +2,9 @@
Quoted 6 lines
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt line 6
Quoted 4 lines
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt +2
-0Required properties: - compatible : Should be "nxp,lx2160a-fspi" + "nxp,imx8qxp-fspi" + "nxp,imx8mm-fspi"All 3 are different and no compatibility?
This was all based on a series from NXP's repo where they have some data tables all associated to the various compatible entries, and they created a place holder for quirks. Based on an older NXP repo, it seems like there might be some quirks associated to the different families, but the newer repo where I got this patch series didn't implement them, however, it's possible the quirks may enhance functionality later. If that's true, I think this is the best solution for future enhancements without having to change the compatibility names down the road. Maybe someone from NXP can comment? I am just trying to help push things upstream so we can support QSPI flash. I would prefer to keep them separate for now, because we might have these improvements later. However, I'll do what you request. Do you want me to drop the additional compatible flags and just use the original, or create a new one that's a bit more generic?
adam
adam
Quoted 8 lines
Quoted 8 lines
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt +1
-1+ - reg : First contains the register location and length, Second contains the memory mapping address and length - reg-names : Should contain the resource reg names: --2.24.0
Rob Herring
maintainerRe: [PATCH V2 4/5] dt-bindings: spi: spi-nxp-fspi: Add support for imx8mm, imx8qxp
Quoted 30 lines · Adam Ford
Quoted 5 lines · Rob Herring
Quoted 1 line · Adam Ford
Add support for nxp,imx8qxp-fspi and nxp,imx8mm-fspi do the bindings
s/do/to/
Oops. Thanks for catching that.
Quoted 13 lines
Quoted 13 lines
document.
Signed-off-by Adam Ford <[email protected]>---
V2: No changeDocumentation/devicetree/bindings/spi/spi-nxp-fspi.txt +0
-0@@ -2,6 +2,9 @@Quoted 6 lines
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt line 6
Quoted 4 lines
Documentation/devicetree/bindings/spi/spi-nxp-fspi.txt +2
-0Required properties: - compatible : Should be "nxp,lx2160a-fspi" + "nxp,imx8qxp-fspi" + "nxp,imx8mm-fspi"All 3 are different and no compatibility?
Quoted 14 lines
This was all based on a series from NXP's repo where they have some data tables all associated to the various compatible entries, and they created a place holder for quirks. Based on an older NXP repo, it seems like there might be some quirks associated to the different families, but the newer repo where I got this patch series didn't implement them, however, it's possible the quirks may enhance functionality later. If that's true, I think this is the best solution for future enhancements without having to change the compatibility names down the road. Maybe someone from NXP can comment? I am just trying to help push things upstream so we can support QSPI flash. I would prefer to keep them separate for now, because we might have these improvements later. However, I'll do what you request. Do you want me to drop the additional compatible flags and just use the original, or create a new one that's a bit more generic?
Neither.
If you already know that they have differences, then as-is is fine.
If they are believed to be 'the same', then you do:
compatible = "nxp,imx8qxp-fspi", "nxp,imx8mm-fspi";
assuming i.MX8MM was the first version.
This allows a MX8QXP to work without OS changes if the driver already supports the previous chip. And if any quirks are found, then the OS can handle them without a DT change.
Rob
PATCH v2 5/5 arm64: dts: enable fspi in imx8mm dts
In reply to Adam FordPull in upstream patch from NXP repo to:
enable fspi in imx8mm DT file
---
V2: Reorder s-o-b lines to give credit in proper order.
arch/arm64/boot/dts/freescale/imx8mm.dtsi +15 -1
@@ -558,7 +558,21 @@ aips3: bus@30800000 { compatible = "simple-bus"; #address-cells = <1>; #size-cells = <1>; - ranges = <0x30800000 0x30800000 0x400000>; + ranges = <0x30800000 0x30800000 0x400000>, + <0x8000000 0x8000000 0x10000000>; + + flexspi: spi@30bb0000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "nxp,imx8mm-fspi"; + reg = <0x30bb0000 0x10000>, <0x8000000 0x10000000>; + reg-names = "fspi_base", "fspi_mmap"; + interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk IMX8MM_CLK_QSPI_ROOT>, + <&clk IMX8MM_CLK_QSPI_ROOT>; + clock-names = "fspi", "fspi_en"; + status = "disabled"; + }; ecspi1: spi@30820000 { compatible = "fsl,imx8mm-ecspi", "fsl,imx51-ecspi";
Signature · 1 line
2.24.0
Re: [PATCH V2 5/5] arm64: dts: enable fspi in imx8mm dts
Quoted 13 lines · Adam Ford
Pull in upstream patch from NXP repo to:
enable fspi in imx8mm DT fileSigned-off-by Han Xu <[email protected]>Signed-off-by Adam Ford <[email protected]>---
V2: Reorder s-o-b lines to give credit in proper order.arch/arm64/boot/dts/freescale/imx8mm.dtsi +0
-0
arch/arm64/boot/dts/freescale/imx8mm.dtsi aips3: bus@30800000 { · line 564
Quoted 8 lines
arch/arm64/boot/dts/freescale/imx8mm.dtsi +4
-1@@ -558,7 +558,21 @@ aips3: bus@30800000 { compatible = "simple-bus"; #address-cells = <1>; #size-cells = <1>; - ranges = <0x30800000 0x30800000 0x400000>; + ranges = <0x30800000 0x30800000 0x400000>, + <0x8000000 0x8000000 0x10000000>; + + flexspi: spi@30bb0000 {
Keep the node sort in unit-address.
Shawn
Quoted 17 lines
arch/arm64/boot/dts/freescale/imx8mm.dtsi +11
-0+ #address-cells = <1>; + #size-cells = <0>; + compatible = "nxp,imx8mm-fspi"; + reg = <0x30bb0000 0x10000>, <0x8000000 0x10000000>; + reg-names = "fspi_base", "fspi_mmap"; + interrupts = <GIC_SPI 107 IRQ_TYPE_LEVEL_HIGH>; + clocks = <&clk IMX8MM_CLK_QSPI_ROOT>, + <&clk IMX8MM_CLK_QSPI_ROOT>; + clock-names = "fspi", "fspi_en"; + status = "disabled"; + }; ecspi1: spi@30820000 { compatible = "fsl,imx8mm-ecspi", "fsl,imx51-ecspi";Signature · 1 line
2.24.0