spi: cadence-quadpsi: Add support for the Cadence QSPI controller
Subsystems (2)
v9 cover spi: cadence-quadpsi: Add support for the Cadence QSPI controller
Add support for the Cadence QSPI controller. This controller is present in the Intel Lightning Mountain(LGM) SoCs, Altera and TI SoCs. This driver has been tested on the Intel LGM SoCs.
This driver does not support generic SPI and also the implementation only supports spi-mem interface to replace the existing driver in mtd/spi-nor/cadence-quadspi.c, the existing driver only support SPI-NOR flash memory.
Thanks a lot!!! Vignesh for the review, suggestion to optimize the patch. Tested with mx25u12835f on LGM platform.
changes from v8:
-- remove the depends MTD macro
-- comment into C++ style
-- remove spaces and tabs where not applicable.
-- align the macro string as same as existing one. -- replace QUAD to op->data.buswidth variable.
-- add CQSPI_NEEDS_ADDR_SWAP instead of soc_selection variable
changes from v7:
-- remove addr_buf kept like as original
-- drop bus-num, chipselect variable
-- add soc_selection varible to differetiate the features -- replace dev->ddev in dma function
-- add seperate function to handle the 24bit slave device address
translation for lgm soc
-- correct sentence seems incomplete in Kconfig
-- add cqspi->soc_selection check to keep the original TI platform
working code.
changes from v6:
-- Add the Signed-off-by Vignesh in commit message
-- bus_num, num_chipselect added to avoid the garbage bus number
during the probe and spi_register.
-- master mode bits updated
-- address sequence is different from TI and Intel SoC Ip handling
so modified as per Intel and differentiating by use_dac_mode variable.
-- dummy cycles also different b/w two platforms, so keeping separate check -- checkpatch errors which are intentional left as is for better readability
changes from v5:
-- kbuild test robot warnings fixed
-- Add Reported-By: Dan Carpenter <[email protected]>
changes from v4:
-- kbuild test robot warnings fixed
-- Add Reborted-by: tag
changes from v3:spi-cadence-quadspi.c
-- static to all functions wrt to local to the file.
-- Prefix cqspi_ and make the function static
-- cmd_ops, data_ops and dummy_ops dropped
-- addr_ops kept since it is required for address calculation.
-- devm_ used for supported functions , removed legacy API's
-- removed "indirect" name from functions
-- replaced by master->mode_bits = SPI_RX_QUAD | SPI_TX_DUAL | SPI_RX_DUAL | SPI_RX_OCTAL;
as per Vignesh susggestion
-- removed free functions since devm_ handles automatically.
-- dropped all unused Macros
YAML file update:
-- cadence,qspi.yaml file name replace by cdns,qspi-nor.yaml
-- compatible string updated as per Vignesh suggestion
-- for single entry, removed descriptions
-- removed optional parameters
Build Result:
linux$ make DT_SCHEMA_FILES=Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml dt_binding_check
CHKDT Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml
SCHEMA Documentation/devicetree/bindings/processed-schema.yaml
DTC Documentation/devicetree/bindings/spi/cdns,qspi-nor.example.dt.yaml
CHECK Documentation/devicetree/bindings/spi/cdns,qspi-nor.example.dt.yamlRamuthevar Vadivel Murugan (2):
dt-bindings: spi: Add schema for Cadence QSPI Controller driver
spi: cadence-quadpsi: Add support for the Cadence QSPI controller
.../devicetree/bindings/spi/cdns,qspi-nor.yaml | 147 ++ drivers/spi/Kconfig | 8 + drivers/spi/Makefile | 1 + drivers/spi/spi-cadence-quadspi.c | 1508 ++++++++++++++++++++ 4 files changed, 1664 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml create mode 100644 drivers/spi/spi-cadence-quadspi.c
Signature · 1 line
2.11.0
PATCH v9 1/2 dt-bindings: spi: Add schema for Cadence QSPI Controller driver
From: Ramuthevar Vadivel Murugan <vadivel.muruganx.ramuthevar-VuQAYsv1563Yd54FQh9/[email protected]>
Add dt-bindings documentation for Cadence-QSPI controller to support spi based flash memories.
--- .../devicetree/bindings/spi/cdns,qspi-nor.yaml | 147 +++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml
Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml new file +147 -0
@@ -0,0 +1,147 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/spi/cdns,qspi-nor.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Cadence QSPI Flash Controller support + +maintainers: + - Ramuthevar Vadivel Murugan <vadivel.muruganx.ramuthevar-VuQAYsv1563Yd54FQh9/[email protected]> + +allOf: + - $ref: "spi-controller.yaml#" + +description: | + Binding Documentation for Cadence QSPI controller,This controller is + present in the Intel LGM, Altera SoCFPGA and TI SoCs and this driver + has been tested On Intel's LGM SoC. + + - compatible : should be one of the following: + Generic default - "cdns,qspi-nor". + For TI 66AK2G SoC - "ti,k2g-qspi", "cdns,qspi-nor". + For TI AM654 SoC - "ti,am654-ospi", "cdns,qspi-nor". + For Intel LGM SoC - "intel,lgm-qspi", "cdns,qspi-nor". + +properties: + compatible: + oneOf: + - items: + - enum: + - ti,k2g-qspi + - const: cdns,qspi-nor + + - items: + - enum: + - ti,am654-ospi + - const: cdns,qspi-nor + + - items: + - enum: + - intel,lgm-qspi + - const: cdns,qspi-nor + + - items: + - const: cdns,qspi-nor + + reg: + maxItems: 2 + + interrupts: + maxItems: 1 + + clocks: + maxItems: 1 + + cdns,fifo-depth: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Size of the data FIFO in words. + + cdns,fifo-width: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Bus width of the data FIFO in bytes. + + cdns,trigger-address: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + 32-bit indirect AHB trigger address. + + cdns,rclk-en: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Flag to indicate that QSPI return clock is used to latch the read data + rather than the QSPI clock. Make sure that QSPI return clock is populated + on the board before using this property. + +# subnode's properties +patternProperties: + "^.*@[0-9a-fA-F]+$": + type: object + description: + flash device uses the subnodes below defined properties. + + cdns,read-delay: + $ref: /schemas/types.yaml#/definitions/uint32 + description: + Delay for read capture logic, in clock cycles. + + cdns,tshsl-ns: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Delay in nanoseconds for the length that the master mode chip select + outputs are de-asserted between transactions. + + cdns,tsd2d-ns: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Delay in nanoseconds between one chip select being de-activated + and the activation of another. + + cdns,tchsh-ns: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Delay in nanoseconds between last bit of current transaction and + deasserting the device chip select (qspi_n_ss_out). + + cdns,tslch-ns: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Delay in nanoseconds between setting qspi_n_ss_out low and + first bit transfer. + +required: + - compatible + - reg + - interrupts + - clocks + - cdns,fifo-depth + - cdns,fifo-width + - cdns,trigger-address + +examples: + - | + qspi: spi@ff705000 { + compatible = "cdns,qspi-nor"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0xff705000 0x1000>, + <0xffa00000 0x1000>; + interrupts = <0 151 4>; + clocks = <&qspi_clk>; + cdns,fifo-depth = <128>; + cdns,fifo-width = <4>; + cdns,trigger-address = <0x00000000>; + + flash0: n25q00@0 { + compatible = "jedec,spi-nor"; + reg = <0x0>; + cdns,read-delay = <4>; + cdns,tshsl-ns = <50>; + cdns,tsd2d-ns = <50>; + cdns,tchsh-ns = <4>; + cdns,tslch-ns = <4>; + }; + }; +
Signature · 1 line
2.11.0
Mark Brown
maintainerRe: [PATCH v9 1/2] dt-bindings: spi: Add schema for Cadence QSPI Controller driver
Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml line 24
Quoted 5 lines · Ramuthevar,Vadivel MuruganX
Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml new file +5
-0+ - compatible : should be one of the following: + Generic default - "cdns,qspi-nor". + For TI 66AK2G SoC - "ti,k2g-qspi", "cdns,qspi-nor". + For TI AM654 SoC - "ti,am654-ospi", "cdns,qspi-nor". + For Intel LGM SoC - "intel,lgm-qspi", "cdns,qspi-nor".
There are already existing bindings for several of these compatibles, we should not be adding a second binding for something which already has a binding but rather continuing to use the same binding. This is the whole point of documenting a binding that's separate to the implementation.
PATCH v9 2/2 spi: cadence-quadpsi: Add support for the Cadence QSPI controller
In reply to Ramuthevar,Vadivel MuruganXFrom: Ramuthevar Vadivel Murugan <[email protected]>
Add support for the Cadence QSPI controller. This controller is present in the Intel Lightning Mountain(LGM) SoCs, Altera and TI SoCs. This driver has been tested on the Intel LGM SoCs.
This driver does not support generic SPI and also the implementation only supports spi-mem interface to replace the existing driver in mtd/spi-nor/cadence-quadspi.c, the existing driver only support SPI-NOR flash memory.
--- drivers/spi/Kconfig | 8 + drivers/spi/Makefile | 1 + drivers/spi/spi-cadence-quadspi.c | 1508 +++++++++++++++++++++++++++++++++++++ 3 files changed, 1517 insertions(+) create mode 100644 drivers/spi/spi-cadence-quadspi.c
drivers/spi/Kconfig +8 -0
@@ -193,6 +193,14 @@ config SPI_CADENCE This selects the Cadence SPI controller master driver used by Xilinx Zynq and ZynqMP. +config SPI_CADENCE_QUADSPI + tristate "Cadence Quad SPI controller" + depends on OF && (ARM || ARM64 || COMPILE_TEST || X86) + help + Cadence QSPI is a specialized controller for connecting an SPI + Flash over 1/2/4/8-bit wide bus. This enables support for the Octal + and Quad SPI variants of Cadence QSPI IP. + config SPI_CLPS711X tristate "CLPS711X host SPI controller" depends on ARCH_CLPS711X || COMPILE_TEST
drivers/spi/Makefile +1 -0
@@ -29,6 +29,7 @@ obj-$(CONFIG_SPI_BCM_QSPI) += spi-iproc-qspi.o spi-brcmstb-qspi.o spi-bcm-qspi. obj-$(CONFIG_SPI_BITBANG) += spi-bitbang.o obj-$(CONFIG_SPI_BUTTERFLY) += spi-butterfly.o obj-$(CONFIG_SPI_CADENCE) += spi-cadence.o +obj-$(CONFIG_SPI_CADENCE_QUADSPI) += spi-cadence-quadspi.o obj-$(CONFIG_SPI_CLPS711X) += spi-clps711x.o obj-$(CONFIG_SPI_COLDFIRE_QSPI) += spi-coldfire-qspi.o obj-$(CONFIG_SPI_DAVINCI) += spi-davinci.o
drivers/spi/spi-cadence-quadspi.c new file +1508 -0
1,508 lines not on this page · raw message
Signature · 1 line
2.11.0
Mark Brown
maintainerQuoted 8 lines · Ramuthevar,Vadivel MuruganX
drivers/spi/spi-cadence-quadspi.c new file +8
-0+static irqreturn_t cqspi_irq_handler (int this_irq,void *dev) +{ +struct cqspi_st *cqspi = dev; +unsigned int irq_status; + +/* Read interrupt status */ + irq_status =readl (cqspi->iobase +CQSPI_REG_IRQSTATUS ); +
drivers/spi/spi-cadence-quadspi.c line 287
Quoted 10 lines
drivers/spi/spi-cadence-quadspi.c new file +10
-0+/* Clear interrupt */ +writel (irq_status, cqspi->iobase +CQSPI_REG_IRQSTATUS ); + + irq_status &=CQSPI_IRQ_MASK_RD |CQSPI_IRQ_MASK_WR ; + +if (irq_status) +complete (&cqspi->transfer_complete); + +return IRQ_HANDLED ; +}
This will unconditionally handle the interrupt regardless of if the hardware was actually flagging an interrupt which will break shared interrupts and the fault handling code in genirq.
drivers/spi/spi-cadence-quadspi.c line 304
Quoted 4 lines
drivers/spi/spi-cadence-quadspi.c new file +4
-0+ tmpbufsize = op->addr.nbytes + op->dummy.nbytes; + tmpbuf =kzalloc (tmpbufsize,GFP_KERNEL |GFP_DMA ); +if (!tmpbuf) +return -ENOMEM ;
I'm not clear where tmpbuf gets freed or passed out of this function?
drivers/spi/spi-cadence-quadspi.c line 310
Quoted 6 lines
drivers/spi/spi-cadence-quadspi.c new file +6
-0+ +if (op->addr.nbytes) { +for (i =0 ; i < op->addr.nbytes; i++) + tmpbuf[i] = op->addr.val >> (8 * (op->addr.nbytes - i -1 )); + + addr_buf = tmpbuf;
We assign tmpbuf to addr_buf here but addr_buf just gets read from so it's not via that AFAICT.
Review
Quoted 2 lines
(quoted diff) +2
-0+ } + /* Invalid address return zero. */
Missing blank line.
Quoted 7 lines
drivers/spi/spi-cadence-quadspi.c new file +7
-0+static void cqspi_chipselect (struct cqspi_flash_pdata *f_pdata) +{ +struct cqspi_st *cqspi = f_pdata->cqspi; +void __iomem *reg_base = cqspi->iobase; +unsigned int chip_select = f_pdata->cs; +unsigned int reg; +
drivers/spi/spi-cadence-quadspi.c line 787
Quoted 10 lines
drivers/spi/spi-cadence-quadspi.c new file +10
-0+ reg =readl (reg_base +CQSPI_REG_CONFIG ); + reg &= ~CQSPI_REG_CONFIG_DECODE_MASK ; + +/* Convert CS if without decoder. +* CS0 to 4b'1110 +* CS1 to 4b'1101 +* CS2 to 4b'1011 +* CS3 to 4b'0111 +*/ + chip_select =0xF & ~(1 << chip_select);
This says "if without decoder" but there's no conditionals here, what if we do have a decoder?
Quoted 5 lines
drivers/spi/spi-cadence-quadspi.c new file +5
-0+ cqspi->master_ref_clk_hz =clk_get_rate (cqspi->clk); + ddata =of_device_get_match_data (dev); +if (ddata) { +if (ddata->quirks &CQSPI_NEEDS_WR_DELAY ) + cqspi->wr_delay = 5 * DIV_ROUND_UP(NSEC_PER_SEC,
drivers/spi/spi-cadence-quadspi.c line 1364
Quoted 10 lines
drivers/spi/spi-cadence-quadspi.c new file +10
-0+ cqspi->master_ref_clk_hz); +if (ddata->hwcaps_mask &CQSPI_SUPPORTS_OCTAL ) + master->mode_bits |=SPI_RX_OCTAL ; +if (!(ddata->quirks &CQSPI_DISABLE_DAC_MODE )) + cqspi->use_dac_mode = true; +if (ddata->quirks &CQSPI_NEEDS_ADDR_SWAP ) { + master->bus_num =0 ; + master->num_chipselect =2 ; + } + }
Given that the driver appears to unconditionally dereference match data in other places I'd expect this to return an error if there's none, otherwise we'll oops in those other code paths later on.
drivers/spi/spi-cadence-quadspi.c line 1371
Quoted 6 lines
drivers/spi/spi-cadence-quadspi.c new file +6
-0+ ret =devm_request_irq (dev, irq, cqspi_irq_handler,0 , + pdev->name, cqspi); +if (ret) { +dev_err (dev,"Cannot request IRQ.\n" ); + goto probe_reset_failed; + }
Are you sure that it's safe to use devm_request_irq() - what happens if the interrupt fires in the process of removing the device?
Hi Mark,
Thank you for the review comments, response in inline.
Quoted 15 lines · Mark Brown
Quoted 13 lines · Ramuthevar,Vadivel MuruganX
drivers/spi/spi-cadence-quadspi.c new file +13
-0+static irqreturn_t cqspi_irq_handler (int this_irq,void *dev) +{ +struct cqspi_st *cqspi = dev; +unsigned int irq_status; + +/* Read interrupt status */ + irq_status =readl (cqspi->iobase +CQSPI_REG_IRQSTATUS ); + +/* Clear interrupt */ +writel (irq_status, cqspi->iobase +CQSPI_REG_IRQSTATUS ); + + irq_status &=CQSPI_IRQ_MASK_RD |CQSPI_IRQ_MASK_WR ; +
Quoted 8 lines
drivers/spi/spi-cadence-quadspi.c line 287
Quoted 5 lines
drivers/spi/spi-cadence-quadspi.c new file +5
-0+if (irq_status) +complete (&cqspi->transfer_complete); + +return IRQ_HANDLED ; +}This will unconditionally handle the interrupt regardless of if the hardware was actually flagging an interrupt which will break shared interrupts and the fault handling code in genirq.
Yes, you're correct, it doesn't check unconditionally, will update the
INT flag in the INT_STATUS register after successful completion of read/write operation. but in this case it is dedicated to qspi-interrupt,not shared with any other HW/SW interrupts.
Quoted 5 lines
drivers/spi/spi-cadence-quadspi.c line 304
Quoted 4 lines
drivers/spi/spi-cadence-quadspi.c new file +4
-0+ tmpbufsize = op->addr.nbytes + op->dummy.nbytes; + tmpbuf =kzalloc (tmpbufsize,GFP_KERNEL |GFP_DMA ); +if (!tmpbuf) +return -ENOMEM ;I'm not clear where tmpbuf gets freed or passed out of this function?
Agreed!, will fix it.
Quoted 8 lines
drivers/spi/spi-cadence-quadspi.c line 310
Quoted 6 lines
drivers/spi/spi-cadence-quadspi.c new file +6
-0+ +if (op->addr.nbytes) { +for (i =0 ; i < op->addr.nbytes; i++) + tmpbuf[i] = op->addr.val >> (8 * (op->addr.nbytes - i -1 )); + + addr_buf = tmpbuf;We assign tmpbuf to
addr_bufhere butaddr_bufjust gets read from so it's not via that AFAICT.
Agreed, will fix it.
Quoted 3 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ } + /* Invalid address return zero. */Missing blank line.
Noted.
Quoted 11 lines
Quoted 11 lines
drivers/spi/spi-cadence-quadspi.c new file +11
-0+static void cqspi_chipselect (struct cqspi_flash_pdata *f_pdata) +{ +struct cqspi_st *cqspi = f_pdata->cqspi; +void __iomem *reg_base = cqspi->iobase; +unsigned int chip_select = f_pdata->cs; +unsigned int reg; + + reg =readl (reg_base +CQSPI_REG_CONFIG ); + reg &= ~CQSPI_REG_CONFIG_DECODE_MASK ; + +/* Convert CS if without decoder.
Quoted 8 lines
drivers/spi/spi-cadence-quadspi.c line 787
Quoted 6 lines
drivers/spi/spi-cadence-quadspi.c new file +6
-0+* CS0 to 4b'1110 +* CS1 to 4b'1101 +* CS2 to 4b'1011 +* CS3 to 4b'0111 +*/ + chip_select =0xF & ~(1 << chip_select);This says "if without decoder" but there's no conditionals here, what if we do have a decoder?
Good catch, will add the check in the next patch, the below check to be added. if (cqspi->is_decoded_cs) {
reg |= CQSPI_REG_CONFIG_DECODE_MASK;
} else {
reg &= ~CQSPI_REG_CONFIG_DECODE_MASK;
Quoted 10 lines
Quoted 10 lines
drivers/spi/spi-cadence-quadspi.c new file +10
-0+ cqspi->master_ref_clk_hz =clk_get_rate (cqspi->clk); + ddata =of_device_get_match_data (dev); +if (ddata) { +if (ddata->quirks &CQSPI_NEEDS_WR_DELAY ) + cqspi->wr_delay =5 *DIV_ROUND_UP (NSEC_PER_SEC , + cqspi->master_ref_clk_hz); +if (ddata->hwcaps_mask &CQSPI_SUPPORTS_OCTAL ) + master->mode_bits |=SPI_RX_OCTAL ; +if (!(ddata->quirks &CQSPI_DISABLE_DAC_MODE )) + cqspi->use_dac_mode = true;
Quoted 8 lines
drivers/spi/spi-cadence-quadspi.c line 1364
Quoted 5 lines
drivers/spi/spi-cadence-quadspi.c new file +5
-0+if (ddata->quirks &CQSPI_NEEDS_ADDR_SWAP ) { + master->bus_num =0 ; + master->num_chipselect =2 ; + } + }Given that the driver appears to unconditionally dereference match data in other places I'd expect this to return an error if there's none, otherwise we'll oops in those other code paths later on.
Noted, will double check is there any impact if there is no data provided. also will add the error check if return an error.
Quoted 7 lines
drivers/spi/spi-cadence-quadspi.c line 1371
Quoted 6 lines
drivers/spi/spi-cadence-quadspi.c new file +6
-0+ ret =devm_request_irq (dev, irq, cqspi_irq_handler,0 , + pdev->name, cqspi); +if (ret) { +dev_err (dev,"Cannot request IRQ.\n" ); + goto probe_reset_failed; + }Are you sure that it's safe to use
devm_request_irq()
Yes, I'm sure that it's safe to use devm_request_irq().
Quoted 2 lines
- what happens if
the interrupt fires in the process of removing the device?
This is not external interrupt which is coming from the device, its inbuilt to QSPI controller which has 2 Registers 1) INT_STATUS_REG 2) INT_MASK_REG. It fires an interrupt and updating INT flag bit in the interrupt status register once reached read/write completion state then irq_handler is called, there we are clearing the INT_FLAG bit by masking of RD/WR flag in INT_MASK register.
Regards
Vadivel
Mark Brown
maintainerQuoted 11 lines · Vadivel MuruganX
Quoted 3 lines · Mark Brown
This will unconditionally handle the interrupt regardless of if the hardware was actually flagging an interrupt which will break shared interrupts and the fault handling code in genirq.
Yes, you're correct, it doesn't check unconditionally, will update the INT flag in the
INT_STATUSregister after successful completion of read/write operation.
but in this case it is dedicated to qspi-interrupt,not shared with any other HW/SW interrupts.
Currently, on the system you're looking at. Given that this is already a widely reused IP there's no guarantee that this will always be the case, and like I say even without sharing it also defeats the fault handling code.
Hi Mark,
Quoted 10 lines · Mark Brown
Quoted 9 lines · Vadivel MuruganX
Quoted 3 lines · Mark Brown
This will unconditionally handle the interrupt regardless of if the hardware was actually flagging an interrupt which will break shared interrupts and the fault handling code in genirq.
Yes, you're correct, it doesn't check unconditionally, will update the INT flag in the
INT_STATUSregister after successful completion of read/write operation.
but in this case it is dedicated to qspi-interrupt,not shared with any other HW/SW interrupts.
Quoted 4 lines
Currently, on the system you're looking at. Given that this is already a widely reused IP there's no guarantee that this will always be the case, and like I say even without sharing it also defeats the fault handling code.
Got it, Thanks! a lot
will take care of it, even though it is not present in the system current, to avoid future conflicts. Flagging and check to be added to avoid if the interrupt raises from shared devices.
Regards
Vadivel
Quoted 4 lines · Ramuthevar,Vadivel MuruganX
Add support for the Cadence QSPI controller. This controller is present in the Intel Lightning Mountain(LGM) SoCs, Altera and TI SoCs. This driver has been tested on the Intel LGM SoCs.
This is v9 and still, none of the altera maintainers are on CC? How will it be ensured that this doesn't break altera if it is merged?
Regards,
Simon
Quoted 86 lines
This driver does not support generic SPI and also the implementation only supports spi-mem interface to replace the existing driver in
mtd/spi-nor/cadence-quadspi.c, the existing driver only support SPI-NOR flash memory.Thanks a lot!!! Vignesh for the review, suggestion to optimize the patch. Tested with mx25u12835f on LGM platform.
changes from v8:
-- remove the depends MTD macro
-- comment into C++ style
-- remove spaces and tabs where not applicable.
-- align the macro string as same as existing one. -- replace QUAD toop->data.buswidthvariable.
-- addCQSPI_NEEDS_ADDR_SWAPinstead ofsoc_selectionvariablechanges from v7:
-- removeaddr_bufkept like as original
-- drop bus-num, chipselect variable
-- addsoc_selectionvarible to differetiate the features -- replacedev->ddevin dma function
-- add seperate function to handle the 24bit slave device address
translation for lgm soc
-- correct sentence seems incomplete inKconfig
-- addcqspi->soc_selectioncheck to keep the original TI platform
working code.changes from v6:
-- Add the Signed-off-by Vignesh in commit message
--bus_num,num_chipselectadded to avoid the garbage bus number
during the probe andspi_register.
-- master mode bits updated
-- address sequence is different from TI and Intel SoC Ip handling
so modified as per Intel and differentiating byuse_dac_modevariable.
-- dummy cycles also different b/w two platforms, so keeping separate check -- checkpatch errors which are intentional left as is for better readabilitychanges from v5:
-- kbuild test robot warnings fixed
-- Add Reported-By: Dan Carpenter <[email protected]>changes from v4:
-- kbuild test robot warnings fixed
-- Add Reborted-by: tagchanges from v3:
spi-cadence-quadspi.c
-- static to all functions wrt to local to the file.
-- Prefixcqspi_and make the function static
--cmd_ops,data_opsanddummy_opsdropped
--addr_opskept since it is required for address calculation.
--devm_used for supported functions , removed legacy API's
-- removed "indirect" name from functions
-- replaced bymaster->mode_bits=SPI_RX_QUAD|SPI_TX_DUAL|SPI_RX_DUAL|SPI_RX_OCTAL;
as per Vignesh susggestion
-- removed free functions sincedevm_handles automatically.
-- dropped all unused MacrosYAML file update:
-- cadence,qspi.yaml file name replace by cdns,qspi-nor.yaml
-- compatible string updated as per Vignesh suggestion
-- for single entry, removed descriptions
-- removed optional parameters
Build Result:
linux$ make DT_SCHEMA_FILES=Documentation/devicetree/bindings/spi/cdns,qspi-nor.yamldt_binding_checkCHKDT Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml SCHEMA Documentation/devicetree/bindings/processed-schema.yaml DTC Documentation/devicetree/bindings/spi/cdns,qspi-nor.example.dt.yaml CHECK Documentation/devicetree/bindings/spi/cdns,qspi-nor.example.dt.yamlRamuthevar Vadivel Murugan (2):
dt-bindings: spi: Add schema for Cadence QSPI Controller driver
spi: cadence-quadpsi: Add support for the Cadence QSPI controller.../devicetree/bindings/spi/cdns,qspi-nor.yaml | 147 ++ drivers/spi/Kconfig | 8 + drivers/spi/Makefile | 1 + drivers/spi/spi-cadence-quadspi.c | 1508 ++++++++++++++++++++ 4 files changed, 1664 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml create mode 100644 drivers/spi/spi-cadence-quadspi.c--
2.11.0
Mark Brown
maintainerQuoted 9 lines · Simon Goldschmidt
Quoted 3 lines · Ramuthevar,Vadivel MuruganX
Add support for the Cadence QSPI controller. This controller is present in the Intel Lightning Mountain(LGM) SoCs, Altera and TI SoCs. This driver has been tested on the Intel LGM SoCs.
This is v9 and still, none of the altera maintainers are on CC? How will it be ensured that this doesn't break altera if it is merged?
Given that this is a new driver I'd be very surprised if it broke other users? I can imagine it might not work for them and it would definitely be much better to get their review but it shouldn't be any worse than the current lack of support.
Quoted 9 lines · Mark Brown
Quoted 6 lines · Simon Goldschmidt
Quoted 3 lines · Ramuthevar,Vadivel MuruganX
Add support for the Cadence QSPI controller. This controller is present in the Intel Lightning Mountain(LGM) SoCs, Altera and TI SoCs. This driver has been tested on the Intel LGM SoCs.
Quoted 7 lines
Quoted 2 lines
This is v9 and still, none of the altera maintainers are on CC? How will it be ensured that this doesn't break altera if it is merged?
Given that this is a new driver I'd be very surprised if it broke other users? I can imagine it might not work for them and it would definitely be much better to get their review but it shouldn't be any worse than the current lack of support.
It is a new driver, but the hardware it supports is not currently unsupported. Both Vadivel and Vignesh have stated that this driver merely moves the existing generic spi driver to the spi-mem interface and should replace the existing driver.
So please correct me if I'm wrong, but to me it seems like if this driver won't work on altera, and after merging it the currently working driver will be removed, altera will be broken.
Regards,
Simon
Mark Brown
maintainerQuoted 3 lines · Simon Goldschmidt
So please correct me if I'm wrong, but to me it seems like if this driver won't work on altera, and after merging it the currently working driver will be removed, altera will be broken.
I'm not seeing anything in the driver that removes whatever the current support is? Unless it's just adding a duplicate driver for the same compatible strings which is obviously a bad idea but at least means that unless people enable the driver there's no risk of it colliding with the existing one.
Quoted 7 lines · Mark Brown
Quoted 3 lines · Simon Goldschmidt
So please correct me if I'm wrong, but to me it seems like if this driver won't work on altera, and after merging it the currently working driver will be removed, altera will be broken.
Quoted 5 lines
I'm not seeing anything in the driver that removes whatever the current support is? Unless it's just adding a duplicate driver for the same compatible strings which is obviously a bad idea but at least means that unless people enable the driver there's no risk of it colliding with the existing one.
It does add a duplicate driver for the same compatible strings. The current working driver is in 'drivers/mtd/spi-nor/cadence-quadspi.c'.
In fact, the compatible string "cdns,qspi-nor" copied from the old driver to this new driver is *only* used for altera. TI has its own compatible string, the new Intel platform adds its own as well.
As long as that one doesn't get removed, I have nothing against this driver here. I'm only concerned that this will get forgotten. And given that I added altera guys to the loop in one of the previous versions, I just was surprised they aren't on CC in this version.
I'm not familiar with whom to CC for Linux drivers, so sorry for the noise if I'm overreacting here, just tell me.
Regards,
Simon
Mark Brown
maintainerQuoted 8 lines · Simon Goldschmidt
Quoted 5 lines · Mark Brown
I'm not seeing anything in the driver that removes whatever the current support is? Unless it's just adding a duplicate driver for the same compatible strings which is obviously a bad idea but at least means that unless people enable the driver there's no risk of it colliding with the existing one.
Quoted 6 lines
It does add a duplicate driver for the same compatible strings. The current working driver is in '
drivers/mtd/spi-nor/cadence-quadspi.c'.In fact, the compatible string "cdns,qspi-nor" copied from the old driver to this new driver is *only* used for altera. TI has its own compatible string, the new Intel platform adds its own as well.
Oh, that's not good - it's adding a completely new binding for the same compatibles which isn't OK. We can transition to a new driver using the same binding but we should be keeping the old binding. If we're moving the binding document around and/or transitioning to YAML that needs to be done explicitly rather than adding a new document for the same compatible.
Quoted 4 lines
As long as that one doesn't get removed, I have nothing against this driver here. I'm only concerned that this will get forgotten. And given that I added altera guys to the loop in one of the previous versions, I just was surprised they aren't on CC in this version.
Yes, like I say it'd be much better to get their review.
Hi Mark,
Quoted 6 lines · Mark Brown
Quoted 5 lines · Simon Goldschmidt
Quoted 3 lines · Ramuthevar,Vadivel MuruganX
Add support for the Cadence QSPI controller. This controller is present in the Intel Lightning Mountain(LGM) SoCs, Altera and TI SoCs. This driver has been tested on the Intel LGM SoCs.
Quoted 6 lines
Quoted 2 lines
This is v9 and still, none of the altera maintainers are on CC? How will it be ensured that this doesn't break altera if it is merged?
Given that this is a new driver I'd be very surprised if it broke other users? I can imagine it might not work for them and it would definitely be much better to get their review but it shouldn't be any worse than the current lack of support.
Thanks for the clarification, Please kindly see the below discussion b/w Vignesh and Dinh in the earlier mail chain.
[Vignesh] The legacy driver under drivers/mtd/spi-nor will be removed as we cannot support both SPI NOR and SPI NAND with single driver if its under spi-nor. New driver should be functionally equivalent to existing one. So I suggest you test this driver on legcay SoCFPGA products.
[Dinh] I don't have the original patch series, but will monitor going forward. As long as the new driver does not break legacy SoCFPGA products that use the cadence-quadspi driver then it should be ok.
Regards
vadivel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Mark Brown
maintainerQuoted 7 lines · Vadivel MuruganX
Quoted 4 lines · Mark Brown
Given that this is a new driver I'd be very surprised if it broke other users? I can imagine it might not work for them and it would definitely be much better to get their review but it shouldn't be any worse than the current lack of support.
Quoted 5 lines
*[Vignesh]* The legacy driver under
drivers/mtd/spi-norwill be removed as we cannot
support both SPI NOR and SPI NAND with single driver if its under spi-nor. New driver should be functionally equivalent to existing one. So I suggest you test this driver on legcay SoCFPGA products.
You're not actually removing the driver here, you're adding another driver for the same thing.
Hi Vadivel,
Quoted 8 lines · Mark Brown
Quoted 6 lines · Vadivel MuruganX
Quoted 4 lines · Mark Brown
Given that this is a new driver I'd be very surprised if it broke other users? I can imagine it might not work for them and it would definitely be much better to get their review but it shouldn't be any worse than the current lack of support.
Quoted 9 lines
Quoted 5 lines
*[Vignesh]* The legacy driver under
drivers/mtd/spi-norwill be removed as we cannot
support both SPI NOR and SPI NAND with single driver if its under spi-nor. New driver should be functionally equivalent to existing one. So I suggest you test this driver on legcay SoCFPGA products.You're not actually removing the driver here, you're adding another driver for the same thing.
I agree with Mark here.
I realized that you are using same CONFIG option as the old one to build this driver. This causes new driver to fail to probe as old driver would bind to the node instead (both drivers will be built into the kernel and both drivers have same compatible).
So, you should remove the old driver. Could you also include patches removing old driver? New driver and bindings are anyways backward compatible with existing one
Signature · 2 lines
Regards Vignesh
Hi Vignesh,
Quoted 19 lines · Vignesh Raghavendra
Hi Vadivel,
Quoted 6 lines · Mark Brown
Quoted 5 lines · Vadivel MuruganX
Quoted 4 lines · Mark Brown
Given that this is a new driver I'd be very surprised if it broke other users? I can imagine it might not work for them and it would definitely be much better to get their review but it shouldn't be any worse than the current lack of support.
Quoted 8 lines
Quoted 5 lines
*[Vignesh]* The legacy driver under
drivers/mtd/spi-norwill be removed as we cannot
support both SPI NOR and SPI NAND with single driver if its under spi-nor. New driver should be functionally equivalent to existing one. So I suggest you test this driver on legcay SoCFPGA products.You're not actually removing the driver here, you're adding another driver for the same thing.
I agree with Mark here.
Quoted 8 lines
I realized that you are using same CONFIG option as the old one to build this driver. This causes new driver to fail to probe as old driver would bind to the node instead (both drivers will be built into the kernel and both drivers have same compatible).
So, you should remove the old driver. Could you also include patches removing old driver? New driver and bindings are anyways backward compatible with existing one
Sure , will remove the existing driver and sending single patch, Thanks!
Regards
Vadivel
Hi Simon,
Quoted 7 lines · Simon Goldschmidt
Quoted 3 lines · Ramuthevar,Vadivel MuruganX
Add support for the Cadence QSPI controller. This controller is present in the Intel Lightning Mountain(LGM) SoCs, Altera and TI SoCs. This driver has been tested on the Intel LGM SoCs.
This is v9 and still, none of the altera maintainers are on CC? How will it be ensured that this doesn't break altera if it is merged?
Thanks for reminded me, sorry, next send time will add them in CC.
Regards
Vadivel
Quoted 4 lines
Regards,
Simon