dt-bindings: spi: Qualcomm Quad SPI(QSPI) documentation
Subsystems (3)
PATCH v6 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 v6:
- None
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
@@ -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
PATCH v6 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.
---
Changes in v6:
- Fixed IRQ error logging accessibility
- Minor cleanup suggested by Doug
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
@@ -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
@@ -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
Re: [PATCH v6 2/2] spi: Introduce new driver for Qualcomm QuadSPI controller
Hi,
drivers/spi/spi-qcom-qspi.c line 103
Quoted 11 lines · Ryan Case
drivers/spi/spi-qcom-qspi.c new file +11
-0+#define RD_FIFO_STATUS 0x002c +#define FIFO_EMPTY BIT(11) +#define WR_CNTS_MSK 0x7f0 +#define WR_CNTS_SHFT 4 +#define RDY_64BYTE BIT(3) +#define RDY_32BYTE BIT(2) +#define RDY_16BYTE BIT(1) +#define FIFO_RDY BIT(0) + +#define RD_FIFO_CFG 0x0028 +#define CONTINUOUS_MODE BIT(0)
You missed the above when re-sorting. The section for 0x0028 should be above the section for 0x002c.
IMO there's been enough spins of this patch and it's a pretty minor change. Mark: maybe you'd be OK with applying the current patch and either fixing up the sort order as you apply or letting us know to post a followup patch? ...or if you'd like a v7 then please yell.
Quoted 21 lines
drivers/spi/spi-qcom-qspi.c new file +21
-0+static int __maybe_unused qcom_qspi_suspend (struct device *dev) +{ +struct spi_master *master =dev_get_drvdata (dev); +int ret; + + ret =spi_master_suspend (master); +if (ret) +return ret; + + ret =pm_runtime_force_suspend (dev); +if (ret) +spi_master_resume (master); + +return ret; +} + +static int __maybe_unused qcom_qspi_resume (struct device *dev) +{ +struct spi_master *master =dev_get_drvdata (dev); +int ret; +
drivers/spi/spi-qcom-qspi.c line 555
Quoted 10 lines
drivers/spi/spi-qcom-qspi.c new file +10
-0+ ret =pm_runtime_force_resume (dev); +if (ret) +return ret; + + ret =spi_master_resume (master); +if (ret) +pm_runtime_force_suspend (dev); + +return ret; +}
As per my new understanding (now that I've been educated by Rafael)
[1] possibly the error handling here could be revamped to handle the case where suspend() may be called again after a failed resume(). I'd rather not block this patch based on that discussion though, so this feels like something to address by a follow-up patch. Thus:
[1] https://lkml.kernel.org/r/CAJZ5v0hSohUZvJcVcQzy_DdSyPVppOABk0HELsa3dpvf12LMPQ@mail.gmail.com
Re: [PATCH v6 2/2] spi: Introduce new driver for Qualcomm QuadSPI controller
In reply to Ryan CaseQuoting Ryan Case (2018-10-02 14:47:08)
Quoted 10 lines
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.
Signed-off-by Girish Mahadevan <[email protected]>Signed-off-by Ryan Case <[email protected]>---
One nitpick below. Looks better now, thanks!
Quoted 17 lines
drivers/spi/spi-qcom-qspi.c new file +11
-0@@ -0,0 +1,581 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright (c) 2017-2018, The Linux foundation. All rights reserved. + +#include <linux/clk.h> +#include <linux/interrupt.h> +#include <linux/io.h> +#include <linux/module.h> +#include <linux/of.h> +#include <linux/of_platform.h> +#include <linux/pm_runtime.h> +#include <linux/spi/spi.h>
[...]
Quoted 14 lines
drivers/spi/spi-qcom-qspi.c new file +14
-0+ +struct qspi_xfer { +union { +const void *tx_buf; +void *rx_buf; + }; +unsigned int rem_bytes; +unsigned int buswidth; +enum qspi_dir dir; +bool is_last; +}; + +enum qspi_clocks { +QSPI_CLK_CORE ,
drivers/spi/spi-qcom-qspi.c line 142
Quoted 10 lines
drivers/spi/spi-qcom-qspi.c new file +10
-0+QSPI_CLK_IFACE , +QSPI_NUM_CLKS +}; + +struct qcom_qspi { +void __iomem *base; +struct device *dev; +struct clk_bulk_data clks[QSPI_NUM_CLKS ]; +struct qspi_xfer xfer; +/* Lock to protect data accessed by IRQs */
Nitpick: What data? Registers? The SPI core can't do it?
Quoted 2 lines
drivers/spi/spi-qcom-qspi.c new file +2
-0+spinlock_t lock; +};
Mark Brown
maintainerApplied "spi: Introduce new driver for Qualcomm QuadSPI controller" to the spi tree
In reply to Ryan CaseThe patch
spi: Introduce new driver for Qualcomm QuadSPI controller
has been applied to the spi tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Quoted 1 line
From
04000dc6f7e3ce24677f2895ea41746ed29a4498Mon Sep 17 00:00:00 2001
From: Girish Mahadevan <[email protected]>
Date: Tue, 2 Oct 2018 14:47:08 -0700
Subject: [PATCH] spi: Introduce new driver for Qualcomm QuadSPI controller
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.
--- 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
@@ -520,6 +520,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
@@ -74,6 +74,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.rc2