Add support for Microchip QSPI controller
Subsystems (3)
v3 cover Add support for Microchip QSPI controller
This patch enables the Microchip's FPGA QSPI and Polarfire SoC QSPI controller support.
Tested spi-nand (W25N01GV) and spi-nor (MT25QL256A) on Microchip's ICICLE kit. tested using both FPGA QSPI and Polarfie SoC QSPI.
changes in v3
------------
1. Added dev_err_probe() at places like probe failures
2. Split the dt-bindings one for adding coreqspi compatible and other one to add coreqspi as fallback to mpfs-qspi.
changes in v2
------------
1. Replaced spi_alloc_master() with devm_spi_alloc_master()
2. Used dev_err_probe() when devm_spi_alloc_master() fails.
3. Added shared IRQ flag in the interrupt registration.
4. Updated the dt_bindings so that there is a differentiation between FPGA QSPI IP core and hard QSPI IP core.
Naga Sureshkumar Relli (4):
spi: dt-binding: document microchip coreQSPI
spi: dt-binding: add coreqspi as a fallback for mpfs-qspi
spi: microchip-core-qspi: Add support for microchip fpga qspi
controllers
MAINTAINERS: add qspi to Polarfire SoC entry
.../bindings/spi/microchip,mpfs-spi.yaml | 15 +- MAINTAINERS | 1 + drivers/spi/Kconfig | 9 + drivers/spi/Makefile | 1 + drivers/spi/spi-microchip-core-qspi.c | 601 ++++++++++++++++++ 5 files changed, 623 insertions(+), 4 deletions(-) create mode 100644 drivers/spi/spi-microchip-core-qspi.c
Signature · 1 line
2.25.1
PATCH v3 1/4 spi: dt-binding: document microchip coreQSPI
Add microchip coreQSPI compatible string and update the title/description to reflect this addition.
--- .../devicetree/bindings/spi/microchip,mpfs-spi.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/spi/microchip,mpfs-spi.yaml +6 -1
@@ -4,7 +4,11 @@ $id: http://devicetree.org/schemas/spi/microchip,mpfs-spi.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: Microchip MPFS {Q,}SPI Controller Device Tree Bindings +title: Microchip FPGA {Q,}SPI Controllers + +description: + SPI and QSPI controllers on Microchip PolarFire SoC and the "soft"/ + fabric IP cores they are based on maintainers: - Conor Dooley <[email protected]>
@@ -17,6 +21,7 @@ properties: enum: - microchip,mpfs-spi - microchip,mpfs-qspi + - microchip,coreqspi-rtl-v2 # FPGA QSPI reg: maxItems: 1
Signature · 1 line
2.25.1
Re: [PATCH v3 1/4] spi: dt-binding: document microchip coreQSPI
Quoted 4 lines · Naga Sureshkumar Relli
Add microchip coreQSPI compatible string and update the title/description to reflect this addition.
Signed-off-by Naga Sureshkumar Relli <[email protected]>
Best regards,
Krzysztof
PATCH v3 2/4 spi: dt-binding: add coreqspi as a fallback for mpfs-qspi
In reply to Naga Sureshkumar RelliMicrochip's PolarFire SoC QSPI IP core is based on coreQSPI, so add coreqspi as a fallback to mpfs-qspi.
--- .../devicetree/bindings/spi/microchip,mpfs-spi.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/spi/microchip,mpfs-spi.yaml +6 -4
@@ -18,10 +18,12 @@ allOf: properties: compatible: - enum: - - microchip,mpfs-spi - - microchip,mpfs-qspi - - microchip,coreqspi-rtl-v2 # FPGA QSPI + oneOf: + - items: + - const: microchip,mpfs-qspi + - const: microchip,coreqspi-rtl-v2 + - const: microchip,coreqspi-rtl-v2 #FPGA QSPI + - const: microchip,mpfs-spi reg: maxItems: 1
Signature · 1 line
2.25.1
Re: [PATCH v3 2/4] spi: dt-binding: add coreqspi as a fallback for mpfs-qspi
Quoted 5 lines · Naga Sureshkumar Relli
Microchip's PolarFire SoC QSPI IP core is based on coreQSPI, so add coreqspi as a fallback to mpfs-qspi.
Signed-off-by Naga Sureshkumar Relli <[email protected]>---
Best regards,
Krzysztof
Re: [PATCH v3 2/4] spi: dt-binding: add coreqspi as a fallback for mpfs-qspi
In reply to Naga Sureshkumar RelliQuoted 6 lines · Naga Sureshkumar Relli
Documentation/devicetree/bindings/spi/microchip,mpfs-spi.yaml +0
-0@@ -18,10 +18,12 @@ allOf:
Documentation/devicetree/bindings/spi/microchip,mpfs-spi.yaml allOf: · line 24
Quoted 10 lines
Documentation/devicetree/bindings/spi/microchip,mpfs-spi.yaml +4
-4properties: compatible: - enum: - - microchip,mpfs-spi - - microchip,mpfs-qspi - - microchip,coreqspi-rtl-v2 # FPGA QSPI + oneOf: + - items: + - const: microchip,mpfs-qspi + - const: microchip,coreqspi-rtl-v2
Eh, this does not make sense after looking at your driver...
Best regards,
Krzysztof
[email protected]
maintainerRe: [PATCH v3 2/4] spi: dt-binding: add coreqspi as a fallback for mpfs-qspi
Quoted 9 lines · Krzysztof Kozlowski
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 6 lines · Naga Sureshkumar Relli
Documentation/devicetree/bindings/spi/microchip,mpfs-spi.yaml +0
-0@@ -18,10 +18,12 @@ allOf:
Quoted 12 lines
Documentation/devicetree/bindings/spi/microchip,mpfs-spi.yaml allOf: · line 24
Quoted 10 lines
Documentation/devicetree/bindings/spi/microchip,mpfs-spi.yaml +4
-4properties: compatible: - enum: - - microchip,mpfs-spi - - microchip,mpfs-qspi - - microchip,coreqspi-rtl-v2 # FPGA QSPI + oneOf: + - items: + - const: microchip,mpfs-qspi + - const: microchip,coreqspi-rtl-v2Eh, this does not make sense after looking at your driver...
What is wrong with explicitly binding the driver to both of the compatible strings? The "hard" peripheral in the SoC part of the FPGA is a superset of version 2 of the coreQSPI IP so the fallback used in the binding here makes sense to me. coreQSPI can be instantiated in the FPGA fabric and used there, so it needs a compatible of its own.
That brings me back to the original point question, why not explicitly bind the driver to both of the compatible strings it is known to work for?
Thanks,
Conor.
Re: [PATCH v3 2/4] spi: dt-binding: add coreqspi as a fallback for mpfs-qspi
Quoted 30 lines · On 05/08/2022 09:34, [email protected] wrote:
Quoted 9 lines · Krzysztof Kozlowski
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 6 lines · Naga Sureshkumar Relli
Documentation/devicetree/bindings/spi/microchip,mpfs-spi.yaml +0
-0@@ -18,10 +18,12 @@ allOf:Quoted 12 lines
Documentation/devicetree/bindings/spi/microchip,mpfs-spi.yaml allOf: · line 24
Quoted 10 lines
Documentation/devicetree/bindings/spi/microchip,mpfs-spi.yaml +4
-4properties: compatible: - enum: - - microchip,mpfs-spi - - microchip,mpfs-qspi - - microchip,coreqspi-rtl-v2 # FPGA QSPI + oneOf: + - items: + - const: microchip,mpfs-qspi + - const: microchip,coreqspi-rtl-v2Eh, this does not make sense after looking at your driver...
What is wrong with explicitly binding the driver to both of the compatible strings? The "hard" peripheral in the SoC part of the FPGA is a superset of version 2 of the coreQSPI IP so the fallback used in the binding here makes sense to me. coreQSPI can be instantiated in the FPGA fabric and used there, so it needs a compatible of its own.
Quoted 3 lines
That brings me back to the original point question, why not explicitly bind the driver to both of the compatible strings it is known to work for?
There is nothing particularly bad with matching to both of compatibles. It is valid code. There are however questions/issues with that:
1. It is redundant. I did not look too much at the driver, but none of the of_device_id entries have some driver data to differentiate, therefore - for the driver - the devices are identical. If they are identical and according to binding compatible, use less code and just one compatible.
2. Otherwise, maybe the devices are not actually fully compatible? That's the second problem. If one writes binding like that and codes it in driver differently, it looks like it was not investigated really and I ask questions...
Best regards,
Krzysztof
[email protected]
maintainerRe: [PATCH v3 2/4] spi: dt-binding: add coreqspi as a fallback for mpfs-qspi
Quoted 37 lines · Krzysztof Kozlowski
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 30 lines · On 05/08/2022 09:34, [email protected] wrote:
Quoted 9 lines · Krzysztof Kozlowski
EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
Quoted 6 lines · Naga Sureshkumar Relli
Documentation/devicetree/bindings/spi/microchip,mpfs-spi.yaml +0
-0@@ -18,10 +18,12 @@ allOf:Quoted 12 lines
Documentation/devicetree/bindings/spi/microchip,mpfs-spi.yaml allOf: · line 24
Quoted 10 lines
Documentation/devicetree/bindings/spi/microchip,mpfs-spi.yaml +4
-4properties: compatible: - enum: - - microchip,mpfs-spi - - microchip,mpfs-qspi - - microchip,coreqspi-rtl-v2 # FPGA QSPI + oneOf: + - items: + - const: microchip,mpfs-qspi + - const: microchip,coreqspi-rtl-v2Eh, this does not make sense after looking at your driver...
What is wrong with explicitly binding the driver to both of the compatible strings? The "hard" peripheral in the SoC part of the FPGA is a superset of version 2 of the coreQSPI IP so the fallback used in the binding here makes sense to me. coreQSPI can be instantiated in the FPGA fabric and used there, so it needs a compatible of its own.
Quoted 3 lines
That brings me back to the original point question, why not explicitly bind the driver to both of the compatible strings it is known to work for?
Quoted 8 lines
There is nothing particularly bad with matching to both of compatibles. It is valid code. There are however questions/issues with that:
1. It is redundant. I did not look too much at the driver, but none of the
of_device_identries have some driver data to differentiate, therefore - for the driver - the devices are identical. If they are identical and according to binding compatible, use less code and just one compatible.
Right. Then the binding is correct and the driver should only bind against "microchip,coreqspi-rtl-v2".
Quoted 8 lines
2. Otherwise, maybe the devices are not actually fully compatible? That's the second problem. If one writes binding like that and codes it in driver differently, it looks like it was not investigated really and I ask questions...
Best regards,
Krzysztof
Re: [PATCH v3 2/4] spi: dt-binding: add coreqspi as a fallback for mpfs-qspi
Quoted 8 lines · On 05/08/2022 10:44, [email protected] wrote:
Quoted 5 lines
1. It is redundant. I did not look too much at the driver, but none of the
of_device_identries have some driver data to differentiate, therefore - for the driver - the devices are identical. If they are identical and according to binding compatible, use less code and just one compatible.Right. Then the binding is correct and the driver should only bind against "microchip,coreqspi-rtl-v2".
Yes.
Best regards,
Krzysztof
Rob Herring
maintainerRe: [PATCH v3 2/4] spi: dt-binding: add coreqspi as a fallback for mpfs-qspi
In reply to Naga Sureshkumar RelliQuoted 8 lines · Naga Sureshkumar Relli
Microchip's PolarFire SoC QSPI IP core is based on coreQSPI, so add coreqspi as a fallback to mpfs-qspi.
Signed-off-by Naga Sureshkumar Relli <[email protected]>--- .../devicetree/bindings/spi/microchip,mpfs-spi.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:./Documentation/devicetree/bindings/spi/microchip,mpfs-spi.yaml:21:4: [warning] wrong indentation: expected 4 but found 3 (indentation) ./Documentation/devicetree/bindings/spi/microchip,mpfs-spi.yaml:22:5: [warning] wrong indentation: expected 5 but found 4 (indentation)
dtschema/dtc warnings/errors:
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/patch/
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:
pip3 install dtschema --upgrade
Please check and re-submit.
PATCH v3 3/4 spi: microchip-core-qspi: Add support for microchip fpga qspi controllers
In reply to Naga Sureshkumar RelliAdd a driver for Microchip FPGA QSPI controllers. This driver also supports "hard" QSPI controllers on Polarfire SoC.
--- drivers/spi/Kconfig | 9 + drivers/spi/Makefile | 1 + drivers/spi/spi-microchip-core-qspi.c | 601 ++++++++++++++++++++++++++ 3 files changed, 611 insertions(+) create mode 100644 drivers/spi/spi-microchip-core-qspi.c
drivers/spi/Kconfig +9 -0
@@ -591,6 +591,15 @@ config SPI_MICROCHIP_CORE PolarFire SoC. If built as a module, it will be called spi-microchip-core. +config SPI_MICROCHIP_CORE_QSPI + tristate "Microchip FPGA QSPI controllers" + depends on SPI_MASTER + help + This enables the QSPI driver for Microchip FPGA QSPI controllers. + Say Y or M here if you want to use the QSPI controllers on + PolarFire SoC. + If built as a module, it will be called spi-microchip-core-qspi. + config SPI_MT65XX tristate "MediaTek SPI controller" depends on ARCH_MEDIATEK || COMPILE_TEST
drivers/spi/Makefile +1 -0
@@ -73,6 +73,7 @@ obj-$(CONFIG_SPI_LP8841_RTC) += spi-lp8841-rtc.o obj-$(CONFIG_SPI_MESON_SPICC) += spi-meson-spicc.o obj-$(CONFIG_SPI_MESON_SPIFC) += spi-meson-spifc.o obj-$(CONFIG_SPI_MICROCHIP_CORE) += spi-microchip-core.o +obj-$(CONFIG_SPI_MICROCHIP_CORE_QSPI) += spi-microchip-core-qspi.o obj-$(CONFIG_SPI_MPC512x_PSC) += spi-mpc512x-psc.o obj-$(CONFIG_SPI_MPC52xx_PSC) += spi-mpc52xx-psc.o obj-$(CONFIG_SPI_MPC52xx) += spi-mpc52xx.o
drivers/spi/spi-microchip-core-qspi.c new file +601 -0
601 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v3 3/4] spi: microchip-core-qspi: Add support for microchip fpga qspi controllers
Quoted 3 lines · Naga Sureshkumar Relli
Add a driver for Microchip FPGA QSPI controllers. This driver also supports "hard" QSPI controllers on Polarfire SoC.
Thank you for your patch. There is something to discuss/improve.
drivers/spi/spi-microchip-core-qspi.c line 535
Quoted 10 lines
drivers/spi/spi-microchip-core-qspi.c new file +10
-0+ ret =clk_prepare_enable (qspi->clk); +if (ret) +return dev_err_probe (&pdev->dev, ret, +"failed to enable clock\n" ); + +init_completion (&qspi->data_completion); +mutex_init (&qspi->op_lock); + + qspi->irq =platform_get_irq (pdev,0 ); +if (qspi->irq <=0 ) {
< 0
Why did you change it to <=?
Quoted 39 lines
drivers/spi/spi-microchip-core-qspi.c new file +39
-0+ ret = qspi->irq; + goto out; + } + + ret =devm_request_irq (&pdev->dev, qspi->irq, mchp_coreqspi_isr, +IRQF_SHARED , pdev->name, qspi); +if (ret) { +dev_err (&pdev->dev,"request_irq failed %d\n" , ret); + goto out; + } + + ctlr->bits_per_word_mask =SPI_BPW_MASK (8 ); + ctlr->mem_ops = &mchp_coreqspi_mem_ops; + ctlr->setup = mchp_coreqspi_setup_op; + ctlr->mode_bits =SPI_CPOL |SPI_CPHA |SPI_RX_DUAL |SPI_RX_QUAD | +SPI_TX_DUAL |SPI_TX_QUAD ; + ctlr->dev.of_node = np; + + ret =devm_spi_register_controller (&pdev->dev, ctlr); +if (ret) { +dev_err_probe (&pdev->dev, ret, +"spi_register_controller failed\n" ); + goto out; + } + +return 0 ; + +out: +clk_disable_unprepare (qspi->clk); + +return ret; +} + +static int mchp_coreqspi_remove (struct platform_device *pdev) +{ +struct mchp_coreqspi *qspi =platform_get_drvdata (pdev); +u32 control =readl_relaxed (qspi->regs +REG_CONTROL ); + +mchp_coreqspi_disable_ints (qspi);
drivers/spi/spi-microchip-core-qspi.c line 584
Quoted 10 lines
drivers/spi/spi-microchip-core-qspi.c new file +10
-0+ control &= ~CONTROL_ENABLE ; +writel_relaxed (control, qspi->regs +REG_CONTROL ); +clk_disable_unprepare (qspi->clk); + +return 0 ; +} + +static const struct of_device_id mchp_coreqspi_of_match[] = { + { .compatible ="microchip,mpfs-qspi" }, + { .compatible ="microchip,coreqspi-rtl-v2" },
This is not what the binding is saying.
Best regards,
Krzysztof
PATCH v3 4/4 MAINTAINERS: add qspi to Polarfire SoC entry
In reply to Naga Sureshkumar RelliAdd the qspi driver to existing Polarfire SoC entry.
--- MAINTAINERS | 1 + 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
@@ -17146,6 +17146,7 @@ S: Supported F: arch/riscv/boot/dts/microchip/ F: drivers/mailbox/mailbox-mpfs.c F: drivers/soc/microchip/ +F: drivers/spi/spi-microchip-core-qspi.c F: drivers/spi/spi-microchip-core.c F: include/soc/microchip/mpfs.h
Signature · 1 line
2.25.1
Re: [PATCH v3 4/4] MAINTAINERS: add qspi to Polarfire SoC entry
Quoted 5 lines · Naga Sureshkumar Relli
Add the qspi driver to existing Polarfire SoC entry.
Signed-off-by Naga Sureshkumar Relli <[email protected]>Acked-by Conor Dooley <[email protected]>---
This should be squashed with previous patch.
Best regards,
Krzysztof
Mark Brown
maintainerRe: [PATCH v3 4/4] MAINTAINERS: add qspi to Polarfire SoC entry
Quoted 7 lines · Krzysztof Kozlowski
Quoted 4 lines · Naga Sureshkumar Relli
Add the qspi driver to existing Polarfire SoC entry.
Signed-off-by Naga Sureshkumar Relli <[email protected]>Acked-by Conor Dooley <[email protected]>This should be squashed with previous patch.
It's perfectly fine to have a separate patch for MAINTAINERS like this.
Mark Brown
maintainerRe: [PATCH v3 4/4] MAINTAINERS: add qspi to Polarfire SoC entry
In reply to Naga Sureshkumar RelliMAINTAINERS S: Supported · line 17151
Quoted 10 lines · Naga Sureshkumar Relli
Add the qspi driver to existing Polarfire SoC entry.
+++ b/MAINTAINERS
MAINTAINERS +1
-0@@ -17146,6 +17146,7 @@ S: Supported F: arch/riscv/boot/dts/microchip/ F: drivers/mailbox/mailbox-mpfs.c F: drivers/soc/microchip/ +F: drivers/spi/spi-microchip-core-qspi.c F: drivers/spi/spi-microchip-core.c F: include/soc/microchip/mpfs.h
You should also add a pattern for the DT binding here.
[email protected]
maintainerRe: [PATCH v3 4/4] MAINTAINERS: add qspi to Polarfire SoC entry
Quoted 13 lines · Mark Brown
MAINTAINERS S: Supported · line 17151
Quoted 10 lines · Naga Sureshkumar Relli
Add the qspi driver to existing Polarfire SoC entry.
+++ b/MAINTAINERS
MAINTAINERS +1
-0@@ -17146,6 +17146,7 @@ S: Supported F: arch/riscv/boot/dts/microchip/ F: drivers/mailbox/mailbox-mpfs.c F: drivers/soc/microchip/ +F: drivers/spi/spi-microchip-core-qspi.c F: drivers/spi/spi-microchip-core.c F: include/soc/microchip/mpfs.hYou should also add a pattern for the DT binding here.
All of the bindings for the platform should have entries then right? I'll send a separate patch adding all of the missing bindings. I have a deferred change to the entry that needs to be sent to Arnd anyway so I can queue the two together. Nothing to be gained by waiting until this driver lands in 6.1+ to have MAINTAINERS coverage of the bindings :)
Thanks,
Conor.
Mark Brown
maintainerRe: [PATCH v3 4/4] MAINTAINERS: add qspi to Polarfire SoC entry
Quoted 13 lines · On Fri, Aug 05, 2022 at 12:07:57PM +0000, [email protected] wrote:
Quoted 10 lines · Mark Brown
MAINTAINERS S: Supported · line 17151
Quoted 8 lines
+++ b/MAINTAINERS
MAINTAINERS +1
-0@@ -17146,6 +17146,7 @@ S: Supported F: arch/riscv/boot/dts/microchip/ F: drivers/mailbox/mailbox-mpfs.c F: drivers/soc/microchip/ +F: drivers/spi/spi-microchip-core-qspi.c F: drivers/spi/spi-microchip-core.c F: include/soc/microchip/mpfs.hYou should also add a pattern for the DT binding here.
Quoted 6 lines
All of the bindings for the platform should have entries then right? I'll send a separate patch adding all of the missing bindings. I have a deferred change to the entry that needs to be sent to Arnd anyway so I can queue the two together. Nothing to be gained by waiting until this driver lands in 6.1+ to have
MAINTAINERScoverage of the bindings :)
Yes, it's better if everything has coverage - that way the platform maintainers are more likely to see any changes that are needed for the bindings. Sending as part of a bigger patch adding the rest sounds good.
Quoted 5 lines · Naga Sureshkumar Relli
This patch enables the Microchip's FPGA QSPI and Polarfire SoC QSPI controller support.
Tested spi-nand (W25N01GV) and spi-nor (MT25QL256A) on Microchip's ICICLE kit. tested using both FPGA QSPI and Polarfie SoC QSPI.
Pending Krzysztof's requests etc:
@Valentina could you test this version please?
Thanks,
Conor.
Quoted 30 lines
changes in v3
------------
1. Addeddev_err_probe()at places like probe failures
2. Split the dt-bindings one for adding coreqspi compatible and other one to add coreqspi as fallback to mpfs-qspi.changes in v2
------------
1. Replacedspi_alloc_master()withdevm_spi_alloc_master()
2. Useddev_err_probe()whendevm_spi_alloc_master()fails.
3. Added shared IRQ flag in the interrupt registration.
4. Updated thedt_bindingsso that there is a differentiation between FPGA QSPI IP core and hard QSPI IP core.Naga Sureshkumar Relli (4):
spi: dt-binding: document microchip coreQSPI
spi: dt-binding: add coreqspi as a fallback for mpfs-qspi
spi: microchip-core-qspi: Add support for microchip fpga qspi
controllers
MAINTAINERS: add qspi to Polarfire SoC entry.../bindings/spi/microchip,mpfs-spi.yaml | 15 +- MAINTAINERS | 1 + drivers/spi/Kconfig | 9 + drivers/spi/Makefile | 1 + drivers/spi/spi-microchip-core-qspi.c | 601 ++++++++++++++++++ 5 files changed, 623 insertions(+), 4 deletions(-)create mode 100644
drivers/spi/spi-microchip-core-qspi.c