dt-bindings: spi: Qualcomm Quad SPI(QSPI) documentation
Subsystems (3)
PATCH 1/2 dt-bindings: spi: Qualcomm Quad SPI(QSPI) documentation
--- .../devicetree/bindings/spi/qcom,spi-qcom-qspi.txt | 36 ++++++++++++++++++++++ err.txt | 27 ---------------- 2 files changed, 36 insertions(+), 27 deletions(-) create mode 100644 Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt delete mode 100644 err.txt
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt new file +36 -0
@@ -0,0 +1,36 @@ +QTI [Qualcomm Technologies Inc] Quad Serial Peripheral Interface (QSPI) + +QSPI [Quad Serial Peripheral Interface] allows single dual and quad read/write +access to slaves. QTI's QSPI controller implements the QSPI protocol to interface +with slaves like NOR Flash devices. + +Required properties: +- compatible: Should contain: + "qcom,qspi-v1" +- reg: Contains the base register location and length +- interrupts: Interrupt number used by the controller. +- clocks: Contains the core and AHB clock names. +- clock-names: "core" for core clock and "iface" for AHB clock. +- spi-max-frequency: Maximum SPI core clock frequency in Hz. + +SPI slave nodes must be children of the SPI master node and can contain +properties described in Documentation/devicetree/bindings/spi/spi-bus.txt + +Example: + + qspi: qspi@7418000 { + compatible = "qcom,qspi-v1"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x7418000 0x600>; + interrupts = <0 459 0>; + clock-names = "iface", "core"; + clocks = <&clock_gcc clk_gcc_qspi_ahb_clk>, + <&clock_gcc clk_gcc_qspi_ser_clk>; + + device@0 { + compatible = "dummy_device"; + reg = <x>; /* CS for the device */ + spi-max-frequency = <f>; /* Max supported frequency of the slave (Hz) */ + }; + };
err.txt deleted +0 -27
@@ -1,27 +0,0 @@ -Skipping hidl generation -arch/arm64/Makefile:23: ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum -arch/arm64/Makefile:44: Detected assembler with broken .inst; disassembly will be unreliable - CHK include/config/kernel.release - CHK include/generated/uapi/linux/version.h - CHK include/generated/utsrelease.h - CHK include/generated/bounds.h - CHK include/generated/timeconst.h - CHK include/generated/asm-offsets.h - CALL scripts/checksyscalls.sh - CHK scripts/mod/devicetable-offsets.h - CHK include/generated/compile.h - CHK kernel/config_data.h - CC drivers/mtd/devices/m25p80.o - AR drivers/mtd/devices/built-in.o - AR drivers/mtd/built-in.o - CC drivers/spi/spi-mem.o -drivers/spi/spi-mem.c:12:23: fatal error: internals.h: No such file or directory - #include "internals.h" - ^ -compilation terminated. -make[2]: *** [drivers/spi/spi-mem.o] Error 1 -make[1]: *** [drivers/spi] Error 2 -make: *** [drivers] Error 2 - -[0;31m#### failed to build some targets (12 seconds) ####[00m -
Signature · 1 line
1.9.1
PATCH 2/2 spi: Introduce new driver for Qualcomm QuadSPI controller
New driver for Qualcomm QuadSPI(QSPI) controller that is used to communicate with slaves such flash memory devices. The QSPI controller can operate in 2 or 4 wire mode but only supports SPI Mode 0 and SPI Mode 3. The controller can also operate in Single or Dual data rate modes.
--- drivers/spi/Kconfig | 7 + drivers/spi/Makefile | 1 + drivers/spi/spi-qcom-qspi.c | 728 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 736 insertions(+) create mode 100644 drivers/spi/spi-qcom-qspi.c
drivers/spi/Kconfig +6 -0
@@ -571,6 +571,13 @@ config SPI_QCOM_GENI This driver can also be built as a module. If so, the module will be called spi-geni-qcom. +config SPI_QCOM_QSPI + tristate "QTI QPSPI controller" + depends on ARCH_QCOM + help + QSPI(Quad SPI) driver for Qualcomm QSPI controller. + config SPI_QUP tristate "Qualcomm SPI controller with QUP interface" depends on ARCH_QCOM || (ARM && COMPILE_TEST)
drivers/spi/Makefile +1 -0
@@ -113,3 +113,4 @@ obj-$(CONFIG_SPI_ZYNQMP_GQSPI) += spi-zynqmp-gqspi.o # SPI slave protocol handlers obj-$(CONFIG_SPI_SLAVE_TIME) += spi-slave-time.o obj-$(CONFIG_SPI_SLAVE_SYSTEM_CONTROL) += spi-slave-system-control.o +obj-$(CONFIG_SPI_QCOM_QSPI) += spi-qcom-qspi.o
drivers/spi/spi-qcom-qspi.c new file +728 -0
728 lines not on this page · raw message
Signature · 1 line
1.9.1
Mark Brown
maintainerRe: [PATCH 2/2] spi: Introduce new driver for Qualcomm QuadSPI controller
On Thu, Jul 05, 2018 at 03:46:42PM -0600, Girish Mahadevan wrote:
Overall this looks pretty good, but there were a few small issues (mostly cosmetic):
drivers/spi/spi-qcom-qspi.c line 425
Quoted 8 lines
drivers/spi/spi-qcom-qspi.c new file +8
-0+/* +* Ensure that the configuration goes through by reading back +* a register from the IO space. +*/ +mb (); + mstr_cfg =readl_relaxed ((ctrl->base +MSTR_CONFIG )); +pm_runtime_put_sync (ctrl->dev); +return ret;
There's no need to use _put_sync() unless you *really* need the put to go through immediately, if you don't need it then it'll just slow things down.
drivers/spi/spi-qcom-qspi.c line 448
Quoted 8 lines
drivers/spi/spi-qcom-qspi.c new file +8
-0+ wr_cnts = (rd_fifo_status &WR_CNTS_MSK ) >>WR_CNTS_SHFT ; + fifo_rdy = (rd_fifo_status &FIFO_RDY ) ? true : false; + +if (!fifo_rdy) { +dev_dbg (ctrl->dev,"%s: Spurious IRQ 0x%x" , + __func__, rd_fifo_status); +return IRQ_NONE ; + }
Please just use a normal if statement, it's easier to read.
drivers/spi/spi-qcom-qspi.c line 491
Quoted 2 lines
drivers/spi/spi-qcom-qspi.c new file +2
-0+ wr_fifo_bytes = +readl_relaxed (ctrl->base +PIO_XFER_STATUS ) >>WR_FIFO_BYTES_SHFT ;
Just use something like
+ wr_fifo_bytes = readl_relaxed(ctrl->base + PIO_XFER_STATUS)
+ >> WR_FIFO_BYTES_SHFT;
Again, more legible.
Quoted 4 lines
drivers/spi/spi-qcom-qspi.c new file +4
-0+static irqreturn_t qcom_qspi_irq (int irq,void *dev_id) +{ +u32 int_status; +struct qcom_qspi *ctrl = dev_id;
drivers/spi/spi-qcom-qspi.c line 541
Quoted 10 lines
drivers/spi/spi-qcom-qspi.c new file +10
-0+irqreturn_t ret =IRQ_HANDLED ; + + int_status =readl_relaxed (ctrl->base +MSTR_INT_STATUS ); +writel_relaxed (int_status, ctrl->base +MSTR_INT_STATUS ); + +if (int_status &WR_FIFO_EMPTY ) + ret =pio_write (ctrl); + +if (int_status &RESP_FIFO_RDY ) + ret =pio_read (ctrl);
What if both bits are set and return different statuses?
drivers/spi/spi-qcom-qspi.c line 553
Quoted 5 lines
drivers/spi/spi-qcom-qspi.c new file +5
-0+static bool qcom_qspi_supports_op (struct spi_mem *mem, +const struct spi_mem_op *op) +{ +return true; +}
So we definitely support all possible ops?
drivers/spi/spi-qcom-qspi.c line 558
Quoted 4 lines
drivers/spi/spi-qcom-qspi.c new file +4
-0+static int qcom_qspi_adjust_op_size (struct spi_mem *mem,struct spi_mem_op *op) +{ +return 0 ; +}
If this can be empty it's prboably better to fix the callers so that they don't need to provide it (looking at the code it seems that this is already the case so you can just remove it).
Re: [PATCH 2/2] spi: Introduce new driver for Qualcomm QuadSPI controller
In reply to Girish MahadevanHi Girish,
Quoted 8 lines · On Thu, 5 Jul 2018 15:46:42 -0600 Girish Mahadevan <[email protected]>…
drivers/spi/spi-qcom-qspi.c new file +8
-0+ +static int process_data (const struct spi_mem_op *op,struct qcom_qspi *ctrl) +{ +int ret; + + ctrl->xfer.dir = (op->data.dir ==SPI_MEM_DATA_IN ) ? +QSPI_READ :QSPI_WRITE ; + ctrl->xfer.mode = op->data.buswidth;
drivers/spi/spi-qcom-qspi.c line 342
Quoted 10 lines
drivers/spi/spi-qcom-qspi.c new file +10
-0+ ctrl->xfer.is_last = true; + ctrl->xfer.rem_bytes = op->data.nbytes; + +if (ctrl->xfer.dir ==QSPI_WRITE ) + ctrl->xfer.tx_buf = op->data.buf.out; +else + ctrl->xfer.rx_buf = op->data.buf.in; + ret =qcom_qspi_pio_xfer (ctrl); +if (ret) +return ret;
Looks like you are converting the spi_mem_op into several regular SPI transfers. Any good reasons for not relying on the core logic to do that? In this case, all you'd have to do is implement ->transfer_one() and be done with it.
drivers/spi/spi-qcom-qspi.c line 283
Quoted 3 lines
drivers/spi/spi-qcom-qspi.c new file +3
-0+ ret =wait_for_xfer (ctrl); +return ret; +}
Regards,
Boris
Re: [PATCH 2/2] spi: Introduce new driver for Qualcomm QuadSPI controller
In reply to Girish MahadevanHi,
Quoted 20 lines · Girish Mahadevan
New driver for Qualcomm QuadSPI(QSPI) controller that is used to communicate with slaves such flash memory devices. The QSPI controller can operate in 2 or 4 wire mode but only supports SPI Mode 0 and SPI Mode 3. The controller can also operate in Single or Dual data rate modes.
Signed-off-by Girish Mahadevan <[email protected]>--- drivers/spi/Kconfig | 7 + drivers/spi/Makefile | 1 + drivers/spi/spi-qcom-qspi.c | 728 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 736 insertions(+) create mode 100644 drivers/spi/spi-qcom-qspi.cdrivers/spi/Kconfig +0
-0@@ -571,6 +571,13 @@ config SPI_QCOM_GENI This driver can also be built as a module. If so, the module will be called spi-geni-qcom.
drivers/spi/Kconfig config SPI_QCOM_GENI · line 582
Quoted 10 lines
drivers/spi/Kconfig +6
-0+config SPI_QCOM_QSPI + tristate "QTI QPSPI controller" + depends on ARCH_QCOM + help + QSPI(Quad SPI) driver for Qualcomm QSPI controller. + config SPI_QUP tristate "Qualcomm SPI controller with QUP interface" depends on ARCH_QCOM || (ARM && COMPILE_TEST)
I tried to apply your patch and patch complained that it was malformed. In fact it is. The numbers above say that there should be 13 lines in the section above but you only have 12. Did you manually munge the patch after generating it? Please be more careful.
-Doug
Re: [PATCH 2/2] spi: Introduce new driver for Qualcomm QuadSPI controller
In reply to Girish MahadevanHi,
Quoted 11 lines · Girish Mahadevan
New driver for Qualcomm QuadSPI(QSPI) controller that is used to communicate with slaves such flash memory devices. The QSPI controller can operate in 2 or 4 wire mode but only supports SPI Mode 0 and SPI Mode 3. The controller can also operate in Single or Dual data rate modes.
Signed-off-by Girish Mahadevan <[email protected]>--- drivers/spi/Kconfig | 7 + drivers/spi/Makefile | 1 + drivers/spi/spi-qcom-qspi.c | 728 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 736 insertions(+)
I spent a few days poking at this driver and trying to see if I could get it to do anything other than crash and corrupt memory. I finally was able to do so. I've posted my diffs at:
...if it's helpful I'm happy to post a full patch here too (just let me know), but I'd just expect my patch to get squashed into the next version and it can be reviewed then.
With my patch applied my testing on sdm845 on a device that can only support dual SPI seems to work pretty well. NOTE: as I reply to this, I realized that I hadn't gone back and tried to address Mark and Boris's comments. Some of them are handled because I found the same problem that they did, but before re-posting you should definitely handle them.
-Doug
Quoting Girish Mahadevan (2018-07-05 14:46:41)
Quoted 14 lines
Signed-off-by Girish Mahadevan <[email protected]>--- .../devicetree/bindings/spi/qcom,spi-qcom-qspi.txt | 36 ++++++++++++++++++++++ err.txt | 27 ---------------- 2 files changed, 36 insertions(+), 27 deletions(-) create mode 100644 Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt delete mode 100644 err.txtDocumentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt new file +0
-0
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt line 1
Quoted 1 line
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt new file +1
-0@@ -0,0 +1,36 @@ +QTI [Qualcomm Technologies Inc] Quad Serial Peripheral Interface (QSPI)
Just write out the TLA?
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt line 4
Quoted 3 lines
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt new file +3
-0+ +QSPI [Quad Serial Peripheral Interface] allows single dual and quad read/write +access to slaves. QTI's QSPI controller implements the QSPI protocol to interface
This QSPI controller?
err.txt
Quoted 35 lines
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt new file +32
-0+with slaves like NOR Flash devices. + +Required properties: +- compatible: Should contain: + "qcom,qspi-v1" +- reg: Contains the base register location and length +- interrupts: Interrupt number used by the controller. +- clocks: Contains the core and AHB clock names. +- clock-names: "core" for core clock and "iface" for AHB clock. +- spi-max-frequency: Maximum SPI core clock frequency in Hz. + +SPI slave nodes must be children of the SPI master node and can contain +properties described in Documentation/devicetree/bindings/spi/spi-bus.txt + +Example: + + qspi: qspi@7418000 { + compatible = "qcom,qspi-v1"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x7418000 0x600>; + interrupts = <0 459 0>; + clock-names = "iface", "core"; + clocks = <&clock_gcc clk_gcc_qspi_ahb_clk>, + <&clock_gcc clk_gcc_qspi_ser_clk>; + + device@0 { + compatible = "dummy_device"; + reg = <x>; /* CS for the device */ + spi-max-frequency = <f>; /* Max supported frequency of the slave (Hz) */ + }; + };err.txt deleted +0
-0
This part of the patch shouldn't be here.
Quoted 28 lines
err.txt deleted +0
-25@@ -1,27 +0,0 @@ -Skipping hidl generation -arch/arm64/Makefile:23: ld does not support --fix-cortex-a53-843419; kernel may be susceptible to erratum -arch/arm64/Makefile:44: Detected assembler with broken .inst; disassembly will be unreliable - CHK include/config/kernel.release - CHK include/generated/uapi/linux/version.h - CHK include/generated/utsrelease.h - CHK include/generated/bounds.h - CHK include/generated/timeconst.h - CHK include/generated/asm-offsets.h - CALL scripts/checksyscalls.sh - CHK scripts/mod/devicetable-offsets.h - CHK include/generated/compile.h - CHK kernel/config_data.h - CC drivers/mtd/devices/m25p80.o - AR drivers/mtd/devices/built-in.o - AR drivers/mtd/built-in.o - CC drivers/spi/spi-mem.o -drivers/spi/spi-mem.c:12:23: fatal error: internals.h: No such file or directory - #include "internals.h" - ^ -compilation terminated. -make[2]: *** [drivers/spi/spi-mem.o] Error 1 -make[1]: *** [drivers/spi] Error 2 -make: *** [drivers] Error 2 -
Rob Herring
maintainerQuoted 14 lines · Girish Mahadevan
Signed-off-by Girish Mahadevan <[email protected]>--- .../devicetree/bindings/spi/qcom,spi-qcom-qspi.txt | 36 ++++++++++++++++++++++ err.txt | 27 ---------------- 2 files changed, 36 insertions(+), 27 deletions(-) create mode 100644 Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt delete mode 100644 err.txtDocumentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt new file +0
-0
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt line 9
Quoted 9 lines
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt new file +9
-0@@ -0,0 +1,36 @@ +QTI [Qualcomm Technologies Inc] Quad Serial Peripheral Interface (QSPI) + +QSPI [Quad Serial Peripheral Interface] allows single dual and quad read/write +access to slaves. QTI's QSPI controller implements the QSPI protocol to interface +with slaves like NOR Flash devices. + +Required properties: +- compatible: Should contain: + "qcom,qspi-v1"
Needs an SoC specific compatible string.
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt line 14
Quoted 5 lines
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt new file +5
-0+- reg: Contains the base register location and length +- interrupts: Interrupt number used by the controller. +- clocks: Contains the core and AHB clock names. +- clock-names: "core" for core clock and "iface" for AHB clock. +- spi-max-frequency: Maximum SPI core clock frequency in Hz.
This goes in the slave device nodes.
Quoted 8 lines
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt new file +8
-0+ +SPI slave nodes must be children of the SPI master node and can contain +properties described in Documentation/devicetree/bindings/spi/spi-bus.txt + +Example: + + qspi: qspi@7418000 { + compatible = "qcom,qspi-v1";
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt line 32
Quoted 10 lines
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt new file +10
-0+ #address-cells = <1>; + #size-cells = <0>; + reg = <0x7418000 0x600>; + interrupts = <0 459 0>; + clock-names = "iface", "core"; + clocks = <&clock_gcc clk_gcc_qspi_ahb_clk>, + <&clock_gcc clk_gcc_qspi_ser_clk>; + + device@0 { + compatible = "dummy_device";
Why don't you use an actual NOR flash chip here.
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt line 33
Quoted 1 line
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt new file +1
-0+ reg = <x>; /* CS for the device */
It's an example, show a CS#.
Quoted 3 lines
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt new file +3
-0+ spi-max-frequency = <f>; /* Max supported frequency of the slave (Hz) */ + }; + };
Hi,
Quoted 30 lines · Girish Mahadevan
Signed-off-by Girish Mahadevan <[email protected]>--- .../devicetree/bindings/spi/qcom,spi-qcom-qspi.txt | 36 ++++++++++++++++++++++ err.txt | 27 ---------------- 2 files changed, 36 insertions(+), 27 deletions(-) create mode 100644 Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt delete mode 100644 err.txtDocumentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt new file +16
-0@@ -0,0 +1,36 @@ +QTI [Qualcomm Technologies Inc] Quad Serial Peripheral Interface (QSPI) + +QSPI [Quad Serial Peripheral Interface] allows single dual and quad read/write +access to slaves. QTI's QSPI controller implements the QSPI protocol to interface +with slaves like NOR Flash devices. + +Required properties: +- compatible: Should contain: + "qcom,qspi-v1" +- reg: Contains the base register location and length +- interrupts: Interrupt number used by the controller. +- clocks: Contains the core and AHB clock names. +- clock-names: "core" for core clock and "iface" for AHB clock. +- spi-max-frequency: Maximum SPI core clock frequency in Hz. + +SPI slave nodes must be children of the SPI master node and can contain
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt line 26
Quoted 10 lines
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt new file +10
-0+properties described in Documentation/devicetree/bindings/spi/spi-bus.txt + +Example: + + qspi: qspi@7418000 { + compatible = "qcom,qspi-v1"; + #address-cells = <1>; + #size-cells = <0>; + reg = <0x7418000 0x600>; + interrupts = <0 459 0>;
Please use a more proper interrupts example, AKA:
interrupts = <GIC_SPI 459 IRQ_TYPE_LEVEL_HIGH>;
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt line 29
Quoted 3 lines
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt new file +3
-0+ clock-names = "iface", "core"; + clocks = <&clock_gcc clk_gcc_qspi_ahb_clk>, + <&clock_gcc clk_gcc_qspi_ser_clk>;
In upstream I believe that the clock #defines are usually in ALL CAPS. Maybe good to use that in your example. In the clock patches I'm hoping to send up for SDM845, for instance, this will be:
clocks = <&gcc GCC_QSPI_CNOC_PERIPH_AHB_CLK>,
<&gcc GCC_QSPI_CORE_CLK>;
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt line 34
Quoted 5 lines
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt new file +5
-0+ + device@0 { + compatible = "dummy_device"; + reg = <x>; /* CS for the device */ + spi-max-frequency = <f>; /* Max supported frequency of the slave (Hz) */
Since you are a Quad SPI controller, maybe you'd want your example to include how to enable that? AKA:
spi-tx-bus-width = <4>;
spi-rx-bus-width = <4>;
-Doug