Skip to contentSkip to conversation

spi: cadence-quadpsi: Add support for the Cadence QSPI controller

PATCH Superseded Ramuthevar,Vadivel MuruganX 3 participants 17 messages Dec 30, 2019 – Jan 27, 2020

Subsystems (2)

v6 of 12 Superseded Latest is v12 →

lore
Share & tools
lore
#0 lore raw

v6 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.

Thank you Vignesh for the valuable review comments and guidance, sorry for the delay since waitting for the merge window to rebase and send it now by one-shot.

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.yaml

Ramuthevar 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                  | 1175 ++++++++++++++++++++
 drivers/spi/spi-cadence-quadspi.h                  |  245 ++++
 5 files changed, 1576 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/cdns,qspi-nor.yaml
 create mode 100644 drivers/spi/spi-cadence-quadspi.c
 create mode 100644 drivers/spi/spi-cadence-quadspi.h

base-commit: c52db0e2f5ec0e5e196fe0045621dcb0141bf90f

Signature · 1 line
2.11.0
#1 lore raw

PATCH v6 1/2 dt-bindings: spi: Add schema for Cadence QSPI Controller driver

From: Ramuthevar Vadivel Murugan <[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
new file mode 100644
index 000000000000..1a4d6e8d0d0b
@@ -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 <[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
#2 lore raw

PATCH v6 2/2 spi: cadence-quadpsi: Add support for the Cadence QSPI controller

In reply to Ramuthevar,Vadivel MuruganX

From: 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 | 1175 +++++++++++++++++++++++++++++++++++++
 drivers/spi/spi-cadence-quadspi.h |  245 ++++++++
 4 files changed, 1429 insertions(+)
 create mode 100644 drivers/spi/spi-cadence-quadspi.c
 create mode 100644 drivers/spi/spi-cadence-quadspi.h
drivers/spi/Kconfig +8 -0
index 870f7797b56b..6d48a89737a4 100644
@@ -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)
+	depends on MTD || MTD_SPI_NOR || MTD_SPI_NAND
+	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 Quad SPI
+
 config SPI_CLPS711X
 	tristate "CLPS711X host SPI controller"
 	depends on ARCH_CLPS711X || COMPILE_TEST
drivers/spi/Makefile +1 -0
index bb49c9e6d0a0..288f5fa903fe 100644
@@ -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 +1175 -0

1,175 lines not on this page · raw message

drivers/spi/spi-cadence-quadspi.h new file +245 -0

245 lines not on this page · raw message

base-commit: c52db0e2f5ec0e5e196fe0045621dcb0141bf90f
prerequisite-patch-id: 553ba277661550aec79275c44f87b1ad4829db9b

Signature · 1 line
2.11.0
#3 lore raw

Hi,

On 30/12/19 1:11 pm, Ramuthevar,Vadivel MuruganX wrote:
[...]

Quoted 17 lines
drivers/spi/spi-cadence-quadspi.c new file +17 -0
+static u32 cqspi_cmd2addr(const unsigned char *addr_buf, u32 addr_width)
+{
+	unsigned int addr = 0;
+	int i;
+
+	/* Invalid address return zero. */
+	if (addr_width > 4)
+		return 0;
+
+	for (i = 0; i < addr_width; i++) {
+		addr = addr << 8;
+		addr |= addr_buf[i];
+	}
+
+	return addr;
+}
+

[...]

Quoted 4 lines
drivers/spi/spi-cadence-quadspi.c new file +4 -0
+static int cqspi_apb_read_setup(struct struct_cqspi *cqspi,
+				const struct spi_mem_op *op,
+				const u8 *addrbuf)
+{

drivers/spi/spi-cadence-quadspi.c line 345

Quoted 10 lines
drivers/spi/spi-cadence-quadspi.c new file +10 -0
+	void __iomem *reg_base = cqspi->iobase;
+	size_t addrlen = op->addr.nbytes;
+	size_t dummy_bytes = op->dummy.nbytes;
+	unsigned int addr_value, dummy_clk, reg;
+
+	if (addrlen) {
+		addr_value = cqspi_cmd2addr(&addrbuf[0], addrlen);
+		writel(addr_value, reg_base + CQSPI_REG_INDIRECTRDSTARTADDR);
+	}
+

Why do you need to swap the address bytes to SPI bus order? You are writing to a controller register that accepts 24 bit or 32 bit address.

drivers/spi/spi-cadence-quadspi.c line 349

Quoted 4 lines
drivers/spi/spi-cadence-quadspi.c new file +4 -0
+	reg = op->cmd.opcode << CQSPI_REG_RD_INSTR_OPCODE_LSB;
+	reg |= (op->data.buswidth & CQSPI_REG_RD_INSTR_TYPE_DATA_MASK) <<
+		CQSPI_REG_RD_INSTR_TYPE_DATA_LSB;
+

This is wrong... op->data.buswidth's range is 1 to 8 whereas CQSPI_REG_RD_INSTR_TYPE range is 0 to 3. I wonder whether you tested dual/quad mode with this driver?

I am still unable to get this series to work on my platform. Will continue to debug...

Signature · 2 lines
Regards
Vignesh
#4 lore raw

Hi,

Thank you for the review comments.

Quoted 22 lines · Vignesh Raghavendra

Hi,

On 30/12/19 1:11 pm, Ramuthevar,Vadivel MuruganX wrote:
[...]

Quoted 17 lines
drivers/spi/spi-cadence-quadspi.c new file +17 -0
+static u32 cqspi_cmd2addr(const unsigned char *addr_buf, u32 addr_width)
+{
+	unsigned int addr = 0;
+	int i;
+
+	/* Invalid address return zero. */
+	if (addr_width > 4)
+		return 0;
+
+	for (i = 0; i < addr_width; i++) {
+		addr = addr << 8;
+		addr |= addr_buf[i];
+	}
+
+	return addr;
+}
+

[...]

Quoted 15 lines
Quoted 4 lines
drivers/spi/spi-cadence-quadspi.c new file +4 -0
+static int cqspi_apb_read_setup(struct struct_cqspi *cqspi,
+				const struct spi_mem_op *op,
+				const u8 *addrbuf)
+{

drivers/spi/spi-cadence-quadspi.c line 345

Quoted 10 lines
drivers/spi/spi-cadence-quadspi.c new file +10 -0
+	void __iomem *reg_base = cqspi->iobase;
+	size_t addrlen = op->addr.nbytes;
+	size_t dummy_bytes = op->dummy.nbytes;
+	unsigned int addr_value, dummy_clk, reg;
+
+	if (addrlen) {
+		addr_value = cqspi_cmd2addr(&addrbuf[0], addrlen);
+		writel(addr_value, reg_base + CQSPI_REG_INDIRECTRDSTARTADDR);
+	}
+

Why do you need to swap the address bytes to SPI bus order?

Yes , you are right to align with spi bus order swap is done .

Quoted 2 lines

You are
writing to a controller register that accepts 24 bit or 32 bit address.

32bit address.

Quoted 7 lines

drivers/spi/spi-cadence-quadspi.c line 349

Quoted 4 lines
drivers/spi/spi-cadence-quadspi.c new file +4 -0
+	reg = op->cmd.opcode << CQSPI_REG_RD_INSTR_OPCODE_LSB;
+	reg |= (op->data.buswidth & CQSPI_REG_RD_INSTR_TYPE_DATA_MASK) <<
+		CQSPI_REG_RD_INSTR_TYPE_DATA_LSB;
+

This is wrong... op->data.buswidth's range is 1 to 8 whereas CQSPI_REG_RD_INSTR_TYPE range is 0 to 3. I wonder whether you tested dual/quad mode with this driver?

Yes I have tested with Quad mode since Cadence-IP supports dual/quad on my platform, used to validate before sending the patch that's  standard procedure here.
please let me know if you have any further queries.

---
Best Regards
Vadivel

Quoted 3 lines

I am still unable to get this series to work on my platform. Will continue to debug...

#5 lore raw
Quoted 43 lines · Vadivel MuruganX

Hi,

Thank you for the review comments.

Quoted 23 lines · Vignesh Raghavendra

Hi,

On 30/12/19 1:11 pm, Ramuthevar,Vadivel MuruganX wrote:
[...]

Quoted 18 lines

+static u32 cqspi_cmd2addr(const unsigned char *addr_buf, u32 addr_width)

drivers/spi/spi-cadence-quadspi.c new file +16 -0
+{
+    unsigned int addr = 0;
+    int i;
+
+    /* Invalid address return zero. */
+    if (addr_width > 4)
+        return 0;
+
+    for (i = 0; i < addr_width; i++) {
+        addr = addr << 8;
+        addr |= addr_buf[i];
+    }
+
+    return addr;
+}
+

[...]

Quoted 15 lines
Quoted 4 lines
drivers/spi/spi-cadence-quadspi.c new file +4 -0
+static int cqspi_apb_read_setup(struct struct_cqspi *cqspi,
+                const struct spi_mem_op *op,
+                const u8 *addrbuf)
+{

drivers/spi/spi-cadence-quadspi.c line 345

Quoted 10 lines
drivers/spi/spi-cadence-quadspi.c new file +10 -0
+    void __iomem *reg_base = cqspi->iobase;
+    size_t addrlen = op->addr.nbytes;
+    size_t dummy_bytes = op->dummy.nbytes;
+    unsigned int addr_value, dummy_clk, reg;
+
+    if (addrlen) {
+        addr_value = cqspi_cmd2addr(&addrbuf[0], addrlen);
+        writel(addr_value, reg_base + CQSPI_REG_INDIRECTRDSTARTADDR);
+    }
+

Why do you need to swap the address bytes to SPI bus order?

Quoted 4 lines

Yes , you are right to align with spi bus order swap is done .

Quoted 2 lines

  You are
writing to a controller register that accepts 24 bit or 32 bit address.

32bit address.

There is no need to swap the address bytes. The current driver (drivers/mtd/spi-nor/cadence-quadspi.c) does not swap the address to SPI bus order, why does the new driver required to do so?

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines

+    reg = op->cmd.opcode << CQSPI_REG_RD_INSTR_OPCODE_LSB; +    reg |= (op->data.buswidth & CQSPI_REG_RD_INSTR_TYPE_DATA_MASK) << +        CQSPI_REG_RD_INSTR_TYPE_DATA_LSB;
+

Quoted 8 lines
Quoted 3 lines

This is wrong... op->data.buswidth's range is 1 to 8 whereas CQSPI_REG_RD_INSTR_TYPE range is 0 to 3. I wonder whether you tested dual/quad mode with this driver?

Yes I have tested with Quad mode since Cadence-IP supports dual/quad on my platform, used to validate
before sending the patch that's  standard procedure here. please let me know if you have any further queries.

Then I have no idea how it works on your platform.. What you are programming above overflows the assigned bit fields for bus width, right?

Quoted 6 lines

---
Best Regards
Vadivel

Quoted 3 lines

I am still unable to get this series to work on my platform. Will continue to debug...

Signature · 2 lines
Regards
Vignesh
#6 lore raw

Hi,

Quoted 45 lines · Vignesh Raghavendra
Quoted 43 lines · Vadivel MuruganX

Hi,

Thank you for the review comments.

Quoted 38 lines · Vignesh Raghavendra

Hi,

On 30/12/19 1:11 pm, Ramuthevar,Vadivel MuruganX wrote:
[...]

Quoted 18 lines

+static u32 cqspi_cmd2addr(const unsigned char *addr_buf, u32 addr_width)

drivers/spi/spi-cadence-quadspi.c new file +16 -0
+{
+    unsigned int addr = 0;
+    int i;
+
+    /* Invalid address return zero. */
+    if (addr_width > 4)
+        return 0;
+
+    for (i = 0; i < addr_width; i++) {
+        addr = addr << 8;
+        addr |= addr_buf[i];
+    }
+
+    return addr;
+}
+

[...]

Quoted 4 lines
drivers/spi/spi-cadence-quadspi.c new file +4 -0
+static int cqspi_apb_read_setup(struct struct_cqspi *cqspi,
+                const struct spi_mem_op *op,
+                const u8 *addrbuf)
+{

drivers/spi/spi-cadence-quadspi.c line 345

Quoted 10 lines
drivers/spi/spi-cadence-quadspi.c new file +10 -0
+    void __iomem *reg_base = cqspi->iobase;
+    size_t addrlen = op->addr.nbytes;
+    size_t dummy_bytes = op->dummy.nbytes;
+    unsigned int addr_value, dummy_clk, reg;
+
+    if (addrlen) {
+        addr_value = cqspi_cmd2addr(&addrbuf[0], addrlen);
+        writel(addr_value, reg_base + CQSPI_REG_INDIRECTRDSTARTADDR);
+    }
+

Why do you need to swap the address bytes to SPI bus order?

Quoted 7 lines
Quoted 4 lines

Yes , you are right to align with spi bus order swap is done .

Quoted 2 lines

  You are
writing to a controller register that accepts 24 bit or 32 bit address.

32bit address.

There is no need to swap the address bytes. The current driver (drivers/mtd/spi-nor/cadence-quadspi.c) does not swap the address to SPI bus order, why does the new driver required to do so?

Thanks! for clarification, actually we are not swapping , just Converting address buffer into word format (MSB first).

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines

+    reg = op->cmd.opcode << CQSPI_REG_RD_INSTR_OPCODE_LSB; +    reg |= (op->data.buswidth & CQSPI_REG_RD_INSTR_TYPE_DATA_MASK) << +        CQSPI_REG_RD_INSTR_TYPE_DATA_LSB;
+

This is wrong... op->data.buswidth's range is 1 to 8 whereas CQSPI_REG_RD_INSTR_TYPE range is 0 to 3. I wonder whether you tested dual/quad mode with this driver?

Quoted 6 lines
Quoted 5 lines

Yes I have tested with Quad mode since Cadence-IP supports dual/quad on my platform, used to validate
before sending the patch that's  standard procedure here. please let me know if you have any further queries.

Then I have no idea how it works on your platform..

while testing on my platform I have hardcoded to 4 instead of 8, for me it is working fine. should be handled properly for OCTAL mode once your changes are ready

Quoted 2 lines

What you are
programming above overflows the assigned bit fields for bus width, right?

yes, overflow should be handled
once started working on your platform with your changes, I will squash and send it back. Thanks for your time.

Regards
Vadivel

Quoted 6 lines
Quoted 6 lines

---
Best Regards
Vadivel

Quoted 3 lines

I am still unable to get this series to work on my platform. Will continue to debug...

#7 lore raw
In reply to Ramuthevar,Vadivel MuruganX

Hi,
[...]

Quoted 15 lines · Ramuthevar,Vadivel MuruganX
drivers/spi/spi-cadence-quadspi.c new file +15 -0
+static int cqspi_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct struct_cqspi *cqspi;
+	struct spi_master *master;
+	struct reset_control *rstc, *rstc_ocp;
+	const struct cqspi_driver_platdata *ddata;
+	struct cqspi_platform_data *pdata = NULL;
+	struct resource *res = NULL;
+	int ret;
+
+	master = spi_alloc_master(&pdev->dev, sizeof(*cqspi));
+	if (!master) {
+		dev_err(&pdev->dev, "spi_alloc_master failed\n");
+		return -ENOMEM;

drivers/spi/spi-cadence-quadspi.c line 1003

Quoted 10 lines
drivers/spi/spi-cadence-quadspi.c new file +10 -0
+	}
+	master->mode_bits = SPI_RX_QUAD | SPI_TX_DUAL | SPI_RX_DUAL |
+				SPI_RX_OCTAL;
+	master->setup = cqspi_setup;
+	master->mem_ops = &cqspi_mem_ops;
+	master->dev.of_node = pdev->dev.of_node;
+	cqspi = spi_master_get_devdata(master);
+	cqspi->pdev = pdev;
+
+	pdata = devm_kmalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);

devm_kzalloc()?

drivers/spi/spi-cadence-quadspi.c line 1010

Quoted 7 lines
drivers/spi/spi-cadence-quadspi.c new file +7 -0
+	if (!pdata)
+		return -ENOMEM;
+
+	pdev->dev.platform_data = pdata;
+
+	/* Obtain QSPI clock. */
+	cqspi->clk = devm_clk_get(&pdev->dev, "qspi");

clock-name of "qspi" is not mandatory as per DT binding and current DT files don't have clock-names property. This therefore cause probe to fail. This should remain:

	cqspi->clk = devm_clk_get(&pdev->dev, "NULL");
Quoted 72 lines
drivers/spi/spi-cadence-quadspi.c new file +72 -0
+	if (IS_ERR(cqspi->clk)) {
+		dev_err(&pdev->dev, "cannot get qspi clk\n");
+		return PTR_ERR(cqspi->clk);
+	}
+	pdata->master_ref_clk_hz = clk_get_rate(cqspi->clk);
+
+	ret = clk_prepare_enable(cqspi->clk);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to enable qspi clock: %d\n", ret);
+		return ret;
+	}
+
+	/* Obtain configuration from OF. */
+	ret = cqspi_of_get_pdata(pdev);
+	if (ret) {
+		dev_err(&pdev->dev, "Get platform data failed.\n");
+		return -ENODEV;
+	}
+
+	cqspi->res = res;
+	/* Obtain and remap controller address. */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	cqspi->iobase = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(cqspi->iobase)) {
+		dev_err(dev, "Cannot remap controller address.\n");
+		return PTR_ERR(cqspi->iobase);
+	}
+
+	/* Obtain and remap AHB address. */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	cqspi->qspi_ahb_virt = devm_ioremap_resource(dev, res);
+	if (IS_ERR(cqspi->qspi_ahb_virt)) {
+		dev_err(dev, "Cannot remap AHB address.\n");
+		return PTR_ERR(cqspi->qspi_ahb_virt);
+	}
+	cqspi->ahbbase = res;
+	cqspi->ahb_size = resource_size(res);
+
+	/* Obtain QSPI reset control */
+	rstc = devm_reset_control_get_optional_exclusive(dev, "qspi");
+	if (IS_ERR(rstc)) {
+		dev_err(dev, "Cannot get QSPI reset.\n");
+		return PTR_ERR(rstc);
+	}
+
+	rstc_ocp = devm_reset_control_get_optional_exclusive(dev, "qspi-ocp");
+	if (IS_ERR(rstc_ocp)) {
+		dev_err(dev, "Cannot get QSPI OCP reset.\n");
+		return PTR_ERR(rstc_ocp);
+	}
+
+	reset_control_assert(rstc);
+	reset_control_deassert(rstc);
+
+	reset_control_assert(rstc_ocp);
+	reset_control_deassert(rstc_ocp);
+
+	ddata  = of_device_get_match_data(dev);
+	if (ddata && (ddata->quirks & CQSPI_NEEDS_WR_DELAY))
+		cqspi->wr_delay = 5 * DIV_ROUND_UP(NSEC_PER_SEC,
+						   pdata->master_ref_clk_hz);
+
+	if (ddata && (ddata->quirks & CQSPI_DISABLE_DAC_MODE))
+		cqspi->use_dac_mode = false;
+
+	init_completion(&cqspi->transfer_complete);
+
+	/* Obtain IRQ line. */
+	cqspi->irq = platform_get_irq(pdev, 0);
+	if (cqspi->irq < 0) {
+		dev_err(dev, "platform_get_irq failed.\n");
+		ret = -ENXIO;

drivers/spi/spi-cadence-quadspi.c line 1092

Quoted 10 lines
drivers/spi/spi-cadence-quadspi.c new file +10 -0
+	}
+	ret = devm_request_irq(dev, cqspi->irq, cqspi_irq_handler, 0,
+			       pdev->name, cqspi);
+	if (ret) {
+		dev_err(dev, "request_irq failed.\n");
+		goto out_clk_disable;
+	}
+
+	master->bus_num = pdata->bus_num;
+	master->num_chipselect = pdata->num_chipselect;

Where is pdata->bus_num and pdata->num_chipselect initialized? This causes devm_spi_register_master() to fail randomly as num_chipselect may be 0.

Quoted 21 lines
drivers/spi/spi-cadence-quadspi.c new file +21 -0
+	mutex_init(&cqspi->lock);
+	platform_set_drvdata(pdev, master);
+	cqspi_controller_init(cqspi);
+	cqspi->current_cs = -1;
+
+	ret = devm_spi_register_master(dev, master);
+	if (ret) {
+		dev_err(&pdev->dev, "devm_spi_register_master failed.\n");
+		goto err_of;
+	}
+
+	return 0;
+
+out_clk_disable:
+	clk_disable_unprepare(cqspi->clk);
+err_of:
+	spi_master_put(master);
+	dev_err(&pdev->dev, "Cadence QSPI controller probe failed\n");
+	return ret;
+}
+
Signature · 2 lines
Regards
Vignesh
#8 lore raw

Hi,

Thank you for the review  comments and your time.

Quoted 21 lines · Vignesh Raghavendra

Hi,
[...]

Quoted 18 lines · Ramuthevar,Vadivel MuruganX
drivers/spi/spi-cadence-quadspi.c new file +18 -0
+static int cqspi_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct struct_cqspi *cqspi;
+	struct spi_master *master;
+	struct reset_control *rstc, *rstc_ocp;
+	const struct cqspi_driver_platdata *ddata;
+	struct cqspi_platform_data *pdata = NULL;
+	struct resource *res = NULL;
+	int ret;
+
+	master = spi_alloc_master(&pdev->dev, sizeof(*cqspi));
+	if (!master) {
+		dev_err(&pdev->dev, "spi_alloc_master failed\n");
+		return -ENOMEM;
+	}
+	master->mode_bits = SPI_RX_QUAD | SPI_TX_DUAL | SPI_RX_DUAL |
+				SPI_RX_OCTAL;
Quoted 8 lines

drivers/spi/spi-cadence-quadspi.c line 1003

Quoted 7 lines
drivers/spi/spi-cadence-quadspi.c new file +7 -0
+	master->setup = cqspi_setup;
+	master->mem_ops = &cqspi_mem_ops;
+	master->dev.of_node = pdev->dev.of_node;
+	cqspi = spi_master_get_devdata(master);
+	cqspi->pdev = pdev;
+
+	pdata = devm_kmalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);

devm_kzalloc()?

Noted, will fix it.

Quoted 11 lines

drivers/spi/spi-cadence-quadspi.c line 1010

Quoted 7 lines
drivers/spi/spi-cadence-quadspi.c new file +7 -0
+	if (!pdata)
+		return -ENOMEM;
+
+	pdev->dev.platform_data = pdata;
+
+	/* Obtain QSPI clock. */
+	cqspi->clk = devm_clk_get(&pdev->dev, "qspi");

clock-name of "qspi" is not mandatory as per DT binding and current DT files don't have clock-names property. This therefore cause probe to fail. This should remain:

Quoted 1 line
	cqspi->clk = devm_clk_get(&pdev->dev, "NULL");

sure , I will add NULL instead of "qspi"

Quoted 77 lines
Quoted 77 lines
drivers/spi/spi-cadence-quadspi.c new file +77 -0
+	if (IS_ERR(cqspi->clk)) {
+		dev_err(&pdev->dev, "cannot get qspi clk\n");
+		return PTR_ERR(cqspi->clk);
+	}
+	pdata->master_ref_clk_hz = clk_get_rate(cqspi->clk);
+
+	ret = clk_prepare_enable(cqspi->clk);
+	if (ret < 0) {
+		dev_err(&pdev->dev, "failed to enable qspi clock: %d\n", ret);
+		return ret;
+	}
+
+	/* Obtain configuration from OF. */
+	ret = cqspi_of_get_pdata(pdev);
+	if (ret) {
+		dev_err(&pdev->dev, "Get platform data failed.\n");
+		return -ENODEV;
+	}
+
+	cqspi->res = res;
+	/* Obtain and remap controller address. */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	cqspi->iobase = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(cqspi->iobase)) {
+		dev_err(dev, "Cannot remap controller address.\n");
+		return PTR_ERR(cqspi->iobase);
+	}
+
+	/* Obtain and remap AHB address. */
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	cqspi->qspi_ahb_virt = devm_ioremap_resource(dev, res);
+	if (IS_ERR(cqspi->qspi_ahb_virt)) {
+		dev_err(dev, "Cannot remap AHB address.\n");
+		return PTR_ERR(cqspi->qspi_ahb_virt);
+	}
+	cqspi->ahbbase = res;
+	cqspi->ahb_size = resource_size(res);
+
+	/* Obtain QSPI reset control */
+	rstc = devm_reset_control_get_optional_exclusive(dev, "qspi");
+	if (IS_ERR(rstc)) {
+		dev_err(dev, "Cannot get QSPI reset.\n");
+		return PTR_ERR(rstc);
+	}
+
+	rstc_ocp = devm_reset_control_get_optional_exclusive(dev, "qspi-ocp");
+	if (IS_ERR(rstc_ocp)) {
+		dev_err(dev, "Cannot get QSPI OCP reset.\n");
+		return PTR_ERR(rstc_ocp);
+	}
+
+	reset_control_assert(rstc);
+	reset_control_deassert(rstc);
+
+	reset_control_assert(rstc_ocp);
+	reset_control_deassert(rstc_ocp);
+
+	ddata  = of_device_get_match_data(dev);
+	if (ddata && (ddata->quirks & CQSPI_NEEDS_WR_DELAY))
+		cqspi->wr_delay = 5 * DIV_ROUND_UP(NSEC_PER_SEC,
+						   pdata->master_ref_clk_hz);
+
+	if (ddata && (ddata->quirks & CQSPI_DISABLE_DAC_MODE))
+		cqspi->use_dac_mode = false;
+
+	init_completion(&cqspi->transfer_complete);
+
+	/* Obtain IRQ line. */
+	cqspi->irq = platform_get_irq(pdev, 0);
+	if (cqspi->irq < 0) {
+		dev_err(dev, "platform_get_irq failed.\n");
+		ret = -ENXIO;
+	}
+	ret = devm_request_irq(dev, cqspi->irq, cqspi_irq_handler, 0,
+			       pdev->name, cqspi);
+	if (ret) {
+		dev_err(dev, "request_irq failed.\n");
Quoted 8 lines

drivers/spi/spi-cadence-quadspi.c line 1092

Quoted 5 lines
drivers/spi/spi-cadence-quadspi.c new file +5 -0
+		goto out_clk_disable;
+	}
+
+	master->bus_num = pdata->bus_num;
+	master->num_chipselect = pdata->num_chipselect;

Where is pdata->bus_num and pdata->num_chipselect initialized? This causes devm_spi_register_master() to fail randomly as num_chipselect may be 0.

Agreed!, I also observed the issue after sending the patches , will fix it in the next patch-set. Regards
Vadivel

Quoted 21 lines
Quoted 21 lines
drivers/spi/spi-cadence-quadspi.c new file +21 -0
+	mutex_init(&cqspi->lock);
+	platform_set_drvdata(pdev, master);
+	cqspi_controller_init(cqspi);
+	cqspi->current_cs = -1;
+
+	ret = devm_spi_register_master(dev, master);
+	if (ret) {
+		dev_err(&pdev->dev, "devm_spi_register_master failed.\n");
+		goto err_of;
+	}
+
+	return 0;
+
+out_clk_disable:
+	clk_disable_unprepare(cqspi->clk);
+err_of:
+	spi_master_put(master);
+	dev_err(&pdev->dev, "Cadence QSPI controller probe failed\n");
+	return ret;
+}
+
#9 lore raw
In reply to Ramuthevar,Vadivel MuruganX

Hi,

Quoted 9 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 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.

I am finally able to get spi-mem based cadence-quaspi driver working on TI platforms with DMA and DAC mode. I have also incorporated changes to disable DAC and autopolling for your intel SoC:

https://github.com/r-vignesh/linux/commits/qspi

(Top two patches are of interest)

I have tested both DAC and INDAC mode with s25fl flash and everything seems to be fine. Could you re test the driver on your SoC? Feel free to fold it into your series if everything works.

Regards
Vignesh

#10 lore raw

Hi,

Quoted 14 lines · Vignesh Raghavendra

Hi,

Quoted 9 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 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.

Quoted 3 lines

I am finally able to get spi-mem based cadence-quaspi driver working on TI platforms with DMA and DAC mode. I have also incorporated changes to disable DAC and autopolling for your intel SoC:

Thanks! a lot for the confirmation, with your changes it is working on TI platform.

Quoted 7 lines

https://github.com/r-vignesh/linux/commits/qspi

(Top two patches are of interest)

I have tested both DAC and INDAC mode with s25fl flash and everything seems to be fine. Could you re test the driver on your SoC? Feel free to fold it into your series if everything works.

sure, I will test on Intel SoC with your changes .

Regards
Vadivel

Quoted 5 lines

Regards
Vignesh

#11 lore raw

Hi,

Quoted 17 lines · Vadivel MuruganX

Hi,

Quoted 14 lines · Vignesh Raghavendra

Hi,

Quoted 9 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 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.

Quoted 12 lines
Quoted 3 lines

I am finally able to get spi-mem based cadence-quaspi driver working on TI platforms with DMA and DAC mode. I have also incorporated changes to disable DAC and autopolling for your intel SoC:

Thanks! a lot for the confirmation, with your changes it is working on TI platform.

Quoted 6 lines

https://github.com/r-vignesh/linux/commits/qspi

(Top two patches are of interest)

I have tested both DAC and INDAC mode with s25fl flash and everything seems to be fine. Could you re test the driver on your SoC?

while re-testing QSPI_NOR/NAND both didn't work, after few changes from patchV6 followed by your changes,

now QSPI-NOR started working,  soon will be sending updated patch version which includes your changes as well as my changes

without affecting both the platforms(TI and Intel).

BTW,  Have you tested QSPI-NAND on your platform ? with our patches.

Thanks! for your review and support.

Regards
Vadivel

Quoted 11 lines
Quoted 2 lines

Feel free to
fold it into your series if everything works.

sure, I will test on Intel SoC with your changes .

Regards
Vadivel

Quoted 5 lines

Regards
Vignesh

#12 lore raw
Quoted 37 lines · Vadivel MuruganX

Hi,

Quoted 17 lines · Vadivel MuruganX

Hi,

Quoted 14 lines · Vignesh Raghavendra

Hi,

Quoted 9 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 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.

Quoted 13 lines
Quoted 3 lines

I am finally able to get spi-mem based cadence-quaspi driver working on TI platforms with DMA and DAC mode. I have also incorporated changes to disable DAC and autopolling for your intel SoC:

Thanks! a lot for the confirmation, with your changes it is working on TI platform.

Quoted 6 lines

https://github.com/r-vignesh/linux/commits/qspi

(Top two patches are of interest)

I have tested both DAC and INDAC mode with s25fl flash and everything seems to be fine. Could you re test the driver on your SoC?

while re-testing QSPI_NOR/NAND both didn't work, after few changes from patchV6 followed by your changes,

Quoted 6 lines

now QSPI-NOR started working,  soon will be sending updated patch version which includes your changes as well as my changes

without affecting both the platforms(TI and Intel).

BTW,  Have you tested QSPI-NAND on your platform ? with our patches.

No, I don't have a platform with QSPI-NAND.

Regards
Vignesh

#13 lore raw
In reply to Vignesh Raghavendra

Hi Vignesh,

Quoted 40 lines

-----Original Message-----
From: [email protected] <linux-kernel- [email protected]> On Behalf Of Vignesh Raghavendra
Sent: Wednesday, January 15, 2020 11:43 AM
To: Ramuthevar,Vadivel MuruganX <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v6 0/2] spi: cadence-quadpsi: Add support for the Cadence QSPI controller

Caution: EXT Email

Hi,

Quoted 9 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 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.

I am finally able to get spi-mem based cadence-quaspi driver working on TI platforms with DMA and DAC mode. I have also incorporated changes to disable DAC and autopolling for your intel SoC:

https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.co
m%2Fr- vignesh%2Flinux%2Fcommits%2Fqspi&amp;data=02%7C01%7Ckuldeep.singh% 40nxp.com%7Ccbd14ac527ae4298a28808d7998219e6%7C686ea1d3bc2b4c6fa 92cd99c5c301635%7C0%7C0%7C637146656365872638&amp;sdata=jAR7lmry R9fdqF3e4A2dQzF0Q0fYxMvM7sNhx8lvoy0%3D&amp;reserved=0

Quoted 5 lines

(Top two patches are of interest)

I have tested both DAC and INDAC mode with s25fl flash and everything seems to be fine. Could you re test the driver on your SoC? Feel free to fold it into your series if everything works.

Is JFFS2/UBIFS a valid use case here? And were you able to test the same?
I see few issues with Spansion flashes (s25fs) in framework and couldn’t make FS utilities run. On the other hand, file systems on other flashes (ex: micron, mt25qu) are showing positive results.

Thanks
Kuldeep

Quoted 5 lines

Regards
Vignesh

#14 lore raw
Quoted 44 lines · Kuldeep Singh

Hi Vignesh,

Quoted 42 lines

-----Original Message-----
From: [email protected] <linux-kernel- [email protected]> On Behalf Of Vignesh Raghavendra
Sent: Wednesday, January 15, 2020 11:43 AM
To: Ramuthevar,Vadivel MuruganX <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v6 0/2] spi: cadence-quadpsi: Add support for the Cadence QSPI controller

Caution: EXT Email

Hi,

Quoted 9 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 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.

I am finally able to get spi-mem based cadence-quaspi driver working on TI platforms with DMA and DAC mode. I have also incorporated changes to disable DAC and autopolling for your intel SoC:

https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.co
m%2Fr- vignesh%2Flinux%2Fcommits%2Fqspi&amp;data=02%7C01%7Ckuldeep.singh% 40nxp.com%7Ccbd14ac527ae4298a28808d7998219e6%7C686ea1d3bc2b4c6fa 92cd99c5c301635%7C0%7C0%7C637146656365872638&amp;sdata=jAR7lmry R9fdqF3e4A2dQzF0Q0fYxMvM7sNhx8lvoy0%3D&amp;reserved=0

(Top two patches are of interest)

Quoted 8 lines
Quoted 3 lines

I have tested both DAC and INDAC mode with s25fl flash and everything seems to be fine. Could you re test the driver on your SoC? Feel free to fold it into your series if everything works.

Is JFFS2/UBIFS a valid use case here? And were you able to test the same?
I see few issues with Spansion flashes (s25fs) in framework and couldn’t make FS utilities run. On the other hand, file systems on other flashes (ex: micron, mt25qu) are showing positive results.

I did test with s25fl512s with UBIFS and did not see any issue. Could you try with latest linux master or linux next? There were couple of fixes in the last -rc related to spansion flashes?

[1]
https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/commit/?h=mtd/fixes&id=440b6d50254bdbd84c2a665c7f53ec69dd741a4f
[2]https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/commit/?h=mtd/fixes&id=da2ef8124f20b4ce18d1d3d24fc7b88e687e10bb

Quoted 9 lines

Thanks
Kuldeep

Quoted 5 lines

Regards
Vignesh

Signature · 2 lines
Regards
Vignesh
#15 lore raw

Hi Vignesh,

Quoted 66 lines

-----Original Message-----
From: Vignesh Raghavendra <[email protected]>
Sent: Thursday, January 23, 2020 1:17 PM
To: Kuldeep Singh <[email protected]>; Ramuthevar,Vadivel MuruganX <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: Re: [EXT] Re: [PATCH v6 0/2] spi: cadence-quadpsi: Add support for the Cadence QSPI controller

Caution: EXT Email

Quoted 39 lines · Kuldeep Singh

Hi Vignesh,

Quoted 37 lines

-----Original Message-----
From: [email protected] <linux-kernel- [email protected]> On Behalf Of Vignesh Raghavendra
Sent: Wednesday, January 15, 2020 11:43 AM
To: Ramuthevar,Vadivel MuruganX <[email protected]>; [email protected]; linux- [email protected]; [email protected]
Cc: [email protected]; [email protected]; [email protected]; [email protected]
Subject: [EXT] Re: [PATCH v6 0/2] spi: cadence-quadpsi: Add support for the Cadence QSPI controller

Caution: EXT Email

Hi,

Quoted 9 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 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.

I am finally able to get spi-mem based cadence-quaspi driver working on TI platforms with DMA and DAC mode. I have also incorporated changes to disable DAC and autopolling for your intel SoC:

https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit
hub.co
m%2Fr-

vignesh%2Flinux%2Fcommits%2Fqspi&amp;data=02%7C01%7Ckuldeep.singh%

Quoted 1 line
Quoted 1 line

40nxp.com%7Ccbd14ac527ae4298a28808d7998219e6%7C686ea1d3bc2b4c6fa

Quoted 1 line
Quoted 1 line

92cd99c5c301635%7C0%7C0%7C637146656365872638&amp;sdata=jAR7lmry

Quoted 8 lines
Quoted 7 lines

R9fdqF3e4A2dQzF0Q0fYxMvM7sNhx8lvoy0%3D&amp;reserved=0

(Top two patches are of interest)

I have tested both DAC and INDAC mode with s25fl flash and everything seems to be fine. Could you re test the driver on your SoC? Feel free to fold it into your series if everything works.

Quoted 8 lines
Quoted 2 lines

Is JFFS2/UBIFS a valid use case here? And were you able to test the same? I see few issues with Spansion flashes (s25fs) in framework and couldn’t

make FS utilities run.

Quoted 1 line

On the other hand, file systems on other flashes (ex: micron, mt25qu) are

showing positive results.

Quoted 1 line

I did test with s25fl512s with UBIFS and did not see any issue.

Thanks Vignesh for this confirmation.

Quoted 2 lines

Could you try with latest linux master or linux next? There were couple of fixes in the last -rc related to spansion flashes?

Yes, I have already applied those patches and still facing this issue.
I am testing with s25fs512s and only able to make it work on 1bit mode and that too by skipping SFDP. Basic read/write works on other modes but not FS utilities.
Could you please share any pointer to look into which direction. Thanks in advance.

Thanks
Kuldeep

Quoted 30 lines

[1]
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kerne
l.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fmtd%2Flinux.git%2Fcommit %2F%3Fh%3Dmtd%2Ffixes%26id%3D440b6d50254bdbd84c2a665c7f53ec69dd 741a4f&amp;data=02%7C01%7Ckuldeep.singh%40nxp.com%7Cee345bdf9f654 4ac9f4508d79fd863d9%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7 C637153624041330774&amp;sdata=OyKGl2jn5JDq5KCaVrxAnUh4qSynmAhS% 2FeFiOxJSKtU%3D&amp;reserved=0 [2]https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.ker nel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fmtd%2Flinux.git%2Fcomm it%2F%3Fh%3Dmtd%2Ffixes%26id%3Dda2ef8124f20b4ce18d1d3d24fc7b88e68 7e10bb&amp;data=02%7C01%7Ckuldeep.singh%40nxp.com%7Cee345bdf9f65 44ac9f4508d79fd863d9%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0% 7C637153624041330774&amp;sdata=BTRzWWY2z6nZncyktDDIdJFwYTp41S%2 Buh99QaJ60e1M%3D&amp;reserved=0

Quoted 9 lines

Thanks
Kuldeep

Quoted 5 lines

Regards
Vignesh

--
Regards
Vignesh

#16 lore raw

Hi,

Quoted 2 lines · Kuldeep Singh

Hi Vignesh,

[...]

Quoted 9 lines
Quoted 1 line

I did test with s25fl512s with UBIFS and did not see any issue.

Thanks Vignesh for this confirmation.

Quoted 2 lines

Could you try with latest linux master or linux next? There were couple of fixes in the last -rc related to spansion flashes?

Yes, I have already applied those patches and still facing this issue.
I am testing with s25fs512s and only able to make it work on 1bit mode and that too by skipping SFDP.

Hmm, why would you need to skip SFDP parsing in 1 bit mode? What actually fails when SFDP is parsed? Read/write/erase? BTW, did s25fs512s flash ever with you controller before (i.e is this a regression)?

Quoted 3 lines

Basic read/write works on other modes but not FS utilities.
Could you please share any pointer to look into which direction. Thanks in advance.

If 1 bit mode works fine, then probably flash FS in 1 bit mode and they try read only mount in quad mode. Thus try and narrow down if the issue is in read path vs write path.

Regards
Vignesh

Quoted 33 lines

Thanks
Kuldeep

Quoted 30 lines

[1]
https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kerne
l.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fmtd%2Flinux.git%2Fcommit %2F%3Fh%3Dmtd%2Ffixes%26id%3D440b6d50254bdbd84c2a665c7f53ec69dd 741a4f&amp;data=02%7C01%7Ckuldeep.singh%40nxp.com%7Cee345bdf9f654 4ac9f4508d79fd863d9%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0%7 C637153624041330774&amp;sdata=OyKGl2jn5JDq5KCaVrxAnUh4qSynmAhS% 2FeFiOxJSKtU%3D&amp;reserved=0 [2]https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.ker nel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Fmtd%2Flinux.git%2Fcomm it%2F%3Fh%3Dmtd%2Ffixes%26id%3Dda2ef8124f20b4ce18d1d3d24fc7b88e68 7e10bb&amp;data=02%7C01%7Ckuldeep.singh%40nxp.com%7Cee345bdf9f65 44ac9f4508d79fd863d9%7C686ea1d3bc2b4c6fa92cd99c5c301635%7C0%7C0% 7C637153624041330774&amp;sdata=BTRzWWY2z6nZncyktDDIdJFwYTp41S%2 Buh99QaJ60e1M%3D&amp;reserved=0

Quoted 9 lines

Thanks
Kuldeep

Quoted 5 lines

Regards
Vignesh

--
Regards
Vignesh

Signature · 2 lines
Regards
Vignesh