Skip to contentSkip to conversation

dt-bindings: spi: Qualcomm Quad SPI(QSPI) documentation

PATCH Superseded Ryan Case 4 participants 6 messages Oct 2, 2018 – Oct 11, 2018

Subsystems (3)

v5 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Ryan Case

author
#0 lore raw

PATCH v5 1/2 dt-bindings: spi: Qualcomm Quad SPI(QSPI) documentation

From: Girish Mahadevan <[email protected]>

Bindings for Qualcomm Quad SPI used on SoCs such as sdm845.

---

Changes in v5:
- None

Changes in v4:
- Changed qspi@ to spi@ and device@ to flash@ to match Rob's review

Changes in v3:
- Added generic compatible string in addition to specific SoC

Changes in v2:
- Added commit text
- Removed invalid property
- Updated example to match sdm845 with attached spi-nor

 .../bindings/spi/qcom,spi-qcom-qspi.txt       | 36 +++++++++++++++++++
 1 file changed, 36 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt
Documentation/devicetree/bindings/spi/qcom,spi-qcom-qspi.txt new file +36 -0
new file mode 100644
index 000000000000..1d64b61f5171
@@ -0,0 +1,36 @@
+Qualcomm Quad Serial Peripheral Interface (QSPI)
+
+The QSPI controller allows SPI protocol communication in single, dual, or quad
+wire transmission modes for read/write access to slaves such as NOR flash.
+
+Required properties:
+- compatible:	An SoC specific identifier followed by "qcom,qspi-v1", such as
+		"qcom,sdm845-qspi", "qcom,qspi-v1"
+- reg:		Should contain the base register location and length.
+- interrupts:	Interrupt number used by the controller.
+- clocks:	Should contain the core and AHB clock.
+- clock-names:	Should be "core" for core clock and "iface" for AHB clock.
+
+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: spi@88df000 {
+		compatible = "qcom,sdm845-qspi", "qcom,qspi-v1";
+		reg = <0x88df000 0x600>;
+		#address-cells = <1>;
+		#size-cells = <0>;
+		interrupts = <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>;
+		clock-names = "iface", "core";
+		clocks = <&gcc GCC_QSPI_CNOC_PERIPH_AHB_CLK>,
+			 <&gcc GCC_QSPI_CORE_CLK>;
+
+		flash@0 {
+			compatible = "jedec,spi-nor";
+			reg = <0>;
+			spi-max-frequency = <25000000>;
+			spi-tx-bus-width = <2>;
+			spi-rx-bus-width = <2>;
+		};
+	};
Signature · 1 line
2.19.0.605.g01d371f741-goog
author
#1 lore raw

PATCH v5 2/2 spi: Introduce new driver for Qualcomm QuadSPI controller

From: Girish Mahadevan <[email protected]>

New driver for Qualcomm QuadSPI(QSPI) controller that is used to communicate with slaves such as flash memory devices. The QSPI controller can operate in 2 or 4 wire mode but only supports SPI Mode 0. The controller can also operate in Single or Dual data rate modes.

Fixed tabbing/spacing in defines

---

Changes in v5:
- Fixed tabbing/spacing errors in defines

Changes in v4:
- Set bus_num to -1
- Alphabetized Makefile entry
- Grouped register and associated flag defines
- Read and write transfers now use ioread32_rep and iowrite32_rep
- Added IRQ error logging
- Updated types, formatting, and other cleanup feedback from Stephen

Changes in v3:
- Corrected QPSPI typo
- Removed setup function and moved configurations to prepare_message
- Added __maybe_unused to suspend and resume functions

Changes in v2:
- Addressed formatting feedback
- Squashed bug fixes and features from Doug
- Now uses transfer_one_message instead of mem_ops
- Fixed suspend/resume
- Added spinlocks

 drivers/spi/Kconfig         |   6 +
 drivers/spi/Makefile        |   1 +
 drivers/spi/spi-qcom-qspi.c | 581 ++++++++++++++++++++++++++++++++++++
 3 files changed, 588 insertions(+)
 create mode 100644 drivers/spi/spi-qcom-qspi.c
drivers/spi/Kconfig +6 -0
index de03d67bcd2b..723d47bf281f 100644
@@ -549,6 +549,12 @@ config SPI_RSPI
 	help
 	  SPI driver for Renesas RSPI and QSPI blocks.
 
+config SPI_QCOM_QSPI
+	tristate "QTI QSPI 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
index 876f8690fc47..a71c18a146a1 100644
@@ -77,6 +77,7 @@ obj-$(CONFIG_SPI_PPC4xx)		+= spi-ppc4xx.o
 spi-pxa2xx-platform-objs		:= spi-pxa2xx.o spi-pxa2xx-dma.o
 obj-$(CONFIG_SPI_PXA2XX)		+= spi-pxa2xx-platform.o
 obj-$(CONFIG_SPI_PXA2XX_PCI)		+= spi-pxa2xx-pci.o
+obj-$(CONFIG_SPI_QCOM_QSPI)		+= spi-qcom-qspi.o
 obj-$(CONFIG_SPI_QUP)			+= spi-qup.o
 obj-$(CONFIG_SPI_ROCKCHIP)		+= spi-rockchip.o
 obj-$(CONFIG_SPI_RB4XX)			+= spi-rb4xx.o
drivers/spi/spi-qcom-qspi.c new file +581 -0

581 lines not on this page · raw message

Signature · 1 line
2.19.0.605.g01d371f741-goog
#2 lore raw

Re: [PATCH v5 2/2] spi: Introduce new driver for Qualcomm QuadSPI controller

Hi,

Quoted 1 line · Ryan Case

+#include <asm/unaligned.h>

Don't need unaligned.h any more do you?

drivers/spi/spi-qcom-qspi.c line 75

Quoted 7 lines
drivers/spi/spi-qcom-qspi.c new file +7 -0
+#define RD_FIFO_CFG            0x0028
+#define CONTINUOUS_MODE                BIT(0)
+
+#define RD_FIFO_RESET          0x0030
+#define RESET_FIFO             BIT(0)
+
+#define PIO_XFER_CFG           0x0018

nit: when you moved the bits next to the registers you reordered the registers. I would have expected 0x0018 to be above 0x0028 though. Similar 0x0014 (below) should be above 0x0018.

drivers/spi/spi-qcom-qspi.c line 116

Quoted 8 lines
drivers/spi/spi-qcom-qspi.c new file +8 -0
+#define CUR_MEM_ADDR           0x0048
+#define HW_VERSION             0x004c
+#define RD_FIFO                        0x0050
+#define SAMPLING_CLK_CFG       0x0090
+#define SAMPLING_CLK_STATUS    0x0094
+
+
+

nit: one less blank line?

Quoted 5 lines
drivers/spi/spi-qcom-qspi.c new file +5 -0
+static int qspi_buswidth_to_iomode(struct qcom_qspi *ctrl,
+                                  unsigned int buswidth)
+{
+       switch (buswidth) {
+       case 1:

drivers/spi/spi-qcom-qspi.c line 162

Quoted 10 lines
drivers/spi/spi-qcom-qspi.c new file +10 -0
+               return SDR_1BIT << MULTI_IO_MODE_SHFT;
+       case 2:
+               return SDR_2BIT << MULTI_IO_MODE_SHFT;
+       case 4:
+               return SDR_4BIT << MULTI_IO_MODE_SHFT;
+       default:
+               dev_warn_once(ctrl->dev,
+                               "Unexpected bus width: %u\n", buswidth);
+               return SDR_1BIT << MULTI_IO_MODE_SHFT;
+       }

nit: now that this function is returning something that's shifted (and so something in the format of a hardware register) it should return u32.

drivers/spi/spi-qcom-qspi.c line 401

Quoted 4 lines
drivers/spi/spi-qcom-qspi.c new file +4 -0
+       if (ctrl->xfer.dir == QSPI_WRITE) {
+               if (int_status & WR_FIFO_EMPTY)
+                       ret = pio_write(ctrl);
+       } else if (ctrl->xfer.dir == QSPI_READ) {

I'd maybe just call this "else" not "else if". "dir" can either be read or write--there are no other options.

drivers/spi/spi-qcom-qspi.c line 404

Quoted 3 lines
drivers/spi/spi-qcom-qspi.c new file +3 -0
+               if (int_status & RESP_FIFO_RDY)
+                       ret = pio_read(ctrl);
+       } else if (int_status & QSPI_ERR_IRQS) {

You can't have "else" here, especially since dir should either be WRITE or READ you'll never end up here. You should just always print errors.

Everything else looks good and as far as I can tell Stephen's previous feedback has been addressed. So mostly just nits but the one bug is that the checking for error interrupts is probably not working.

-Doug

Reviewed-by Rob Herring Reviewed-by on v5 1/2
#4 lore raw
In reply to Ryan Case

Hi,

Quoted 7 lines · Ryan Case

From: Girish Mahadevan <[email protected]>

Bindings for Qualcomm Quad SPI used on SoCs such as sdm845.

Quoted 7 lines

---

Changes in v5:
- None

Changes in v4:
- Changed qspi@ to spi@ and device@ to flash@ to match Rob's review

Rob said that with those changes you could add his reviewed by [1], so this patch should have carried:

I'd also say that usually when changes are minor you can make a judgement call and carry previous reviews. If there's any question about whether previous reviews can be carried you can mention it somewhere in your changelog. In this particular case I would have called the changes minor / non-controversial so I would have kept Stephen and my reviews when posting the new patch. In any case Stephen has already re-provided his review and you can feel free to add:

[1] https://lkml.kernel.org/r/20180927204624.GA7072@bogus

maintainer
#5 lore raw
In reply to Ryan Case
Quoted 3 lines · Ryan Case

From: Girish Mahadevan <[email protected]>

Bindings for Qualcomm Quad SPI used on SoCs such as sdm845.

Please use subject lines matching the style for the subsystem. This makes it easier for people to identify relevant patches.