Add Cadence XSPI driver
PATCH v2 1/2 Add Cadence XSPI driver
Add support for Cadence XSPI controller. This driver uses SPI-MEM framework and is capable to operate with single, dual, quad and octal SPI-NOR memories. Low-level controller work mode (STIG) is utilized to communicate with flash memories.
---
Changes between initial version and v2:
- none
drivers/spi/Kconfig | 11 + drivers/spi/Makefile | 1 + drivers/spi/spi-cadence-xspi.c | 895 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 907 insertions(+) create mode 100644 drivers/spi/spi-cadence-xspi.c
drivers/spi/Kconfig +11 -0
@@ -848,6 +848,17 @@ config SPI_ZYNQMP_GQSPI help Enables Xilinx GQSPI controller driver for Zynq UltraScale+ MPSoC. +config SPI_CADENCE_XSPI + tristate "Cadence XSPI controller" + depends on (OF || COMPILE_TEST) && HAS_IOMEM + help + Enable support for the Cadence XSPI Flash controller. + + Cadence XSPI is a specialized controller for connecting an SPI + Flash over upto 8bit wide bus. Enable this option if you have a + device with a Cadence XSPI controller and want to access the + Flash as an MTD device. + # # Add new SPI master controllers in alphabetical order above this line #
drivers/spi/Makefile +1 -0
@@ -119,6 +119,7 @@ obj-$(CONFIG_SPI_XILINX) += spi-xilinx.o obj-$(CONFIG_SPI_XLP) += spi-xlp.o obj-$(CONFIG_SPI_XTENSA_XTFPGA) += spi-xtensa-xtfpga.o obj-$(CONFIG_SPI_ZYNQMP_GQSPI) += spi-zynqmp-gqspi.o +obj-$(CONFIG_SPI_CADENCE_XSPI) += spi-cadence-xspi.o # SPI slave protocol handlers obj-$(CONFIG_SPI_SLAVE_TIME) += spi-slave-time.o
drivers/spi/spi-cadence-xspi.c new file +895 -0
895 lines not on this page · raw message
Signature · 1 line
2.15.0
Mark Brown
maintainerQuoted 6 lines · Konrad Kociolek
drivers/spi/Kconfig +4
-0Enables Xilinx GQSPI controller driver for Zynq UltraScale+ MPSoC. +config SPI_CADENCE_XSPI + tristate "Cadence XSPI controller" + depends on (OF || COMPILE_TEST) && HAS_IOMEM + help
drivers/spi/Kconfig config SPI_ZYNQMP_GQSPI · line 864
Quoted 10 lines
drivers/spi/Kconfig +7
-0+ Enable support for the Cadence XSPI Flash controller. + + Cadence XSPI is a specialized controller for connecting an SPI + Flash over upto 8bit wide bus. Enable this option if you have a + device with a Cadence XSPI controller and want to access the + Flash as an MTD device. + # # Add new SPI master controllers in alphabetical order above this line #
Please keep Kconfig and Makefile alphabetically sorted as the comment in the context from the diff says. :/
drivers/spi/spi-cadence-xspi.c line 3
Quoted 6 lines
drivers/spi/spi-cadence-xspi.c new file +3
-0@@ -0,0 +1,895 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Cadence XSPI flash controller driver
Please make the entire comment a C++ so things look more intentional.
drivers/spi/spi-cadence-xspi.c line 287
Quoted 2 lines
drivers/spi/spi-cadence-xspi.c new file +2
-0+dev_info (cdns_xspi->dev, +"Running PHY training for read_dqs_delay parameter\n" );
This print is just noise, please remove it.
drivers/spi/spi-cadence-xspi.c line 607
Quoted 8 lines
drivers/spi/spi-cadence-xspi.c new file +8
-0+static int cdns_xspi_setup (struct spi_device *spi_dev) +{ +if (spi_dev->chip_select > spi_dev->master->num_chipselect) { +dev_err (&spi_dev->dev, +"%d chip-select is out of range\n" , + spi_dev->chip_select); +return -EINVAL ; + }
If this isn't already being validated by the core it should be and this function can be removed.
drivers/spi/spi-cadence-xspi.c line 621
Quoted 4 lines
drivers/spi/spi-cadence-xspi.c new file +4
-0+ irq_status =readl (cdns_xspi->iobase +CDNS_XSPI_INTR_STATUS_REG ); +if (irq_status) { +writel (irq_status, + cdns_xspi->iobase +CDNS_XSPI_INTR_STATUS_REG );
This unconditionally acknowledges everything, even things we don't understand. If the hardware is generating unexpected interrupt statuses we should probably warn.
Quoted 6 lines
drivers/spi/spi-cadence-xspi.c new file +6
-0+static void cdns_xspi_print_phy_config (struct cdns_xspi_dev *cdns_xspi) +{ +struct device *dev = cdns_xspi->dev; + +dev_info (dev,"PHY configuration\n" ); + dev_info(dev, " * xspi_dll_phy_ctrl: %08x\n",
drivers/spi/spi-cadence-xspi.c line 743
Quoted 10 lines
drivers/spi/spi-cadence-xspi.c new file +10
-0+ readl(cdns_xspi->iobase + CDNS_XSPI_DLL_PHY_CTRL)); +dev_info (dev," * phy_dq_timing: %08x\n" , +readl (cdns_xspi->auxbase +CDNS_XSPI_CCP_PHY_DQ_TIMING )); +dev_info (dev," * phy_dqs_timing: %08x\n" , +readl (cdns_xspi->auxbase +CDNS_XSPI_CCP_PHY_DQS_TIMING )); +dev_info (dev," * phy_gate_loopback_ctrl: %08x\n" , +readl (cdns_xspi->auxbase +CDNS_XSPI_CCP_PHY_GATE_LPBCK_CTRL )); +dev_info (dev," * phy_dll_slave_ctrl: %08x\n" , +readl (cdns_xspi->auxbase +CDNS_XSPI_CCP_PHY_DLL_SLAVE_CTRL )); +}
This seems pretty verbose for an individual device... If this is needed for diagnostics perhaps put it in sysfs or debugfs where it'll be accessible even if the log wraps?
drivers/spi/spi-cadence-xspi.c line 864
Quoted 2 lines
drivers/spi/spi-cadence-xspi.c new file +2
-0+err_no_mem: +dev_err (dev,"Failed to probe Cadence XSPI controller driver\n" );
Not sure this is adding anything over the individual error messages on specific failures.
drivers/spi/spi-cadence-xspi.c line 873
Quoted 5 lines
drivers/spi/spi-cadence-xspi.c new file +5
-0+#ifdef CONFIG_OF +static const struct of_device_id cdns_xspi_of_match[] = { + { + .compatible ="cdns,xspi-nor-fpga" , + },
Why -fpga?
Quoted 16 lines · Mark Brown
EXTERNAL MAIL
Quoted 11 lines · Konrad Kociolek
drivers/spi/Kconfig +9
-0Enables Xilinx GQSPI controller driver for Zynq UltraScale+ MPSoC. +config SPI_CADENCE_XSPI + tristate "Cadence XSPI controller" + depends on (OF || COMPILE_TEST) && HAS_IOMEM + help + Enable support for the Cadence XSPI Flash controller. + + Cadence XSPI is a specialized controller for connecting an SPI + Flash over upto 8bit wide bus. Enable this option if you have a + device with a Cadence XSPI controller and want to access the
Quoted 9 lines
drivers/spi/Kconfig config SPI_ZYNQMP_GQSPI · line 864
Quoted 5 lines
drivers/spi/Kconfig +2
-0+ Flash as an MTD device. + # # Add new SPI master controllers in alphabetical order above this line #Please keep
KconfigandMakefilealphabetically sorted as the comment in the context from the diff says. :/
What I see is Kconfig is first and Makefile is second file in diff, according to:
drivers/spi/Kconfig | 11 + drivers/spi/Makefile | 1 +
Is that wrong?
Quoted 62 lines
drivers/spi/spi-cadence-xspi.c line 3
Quoted 6 lines
drivers/spi/spi-cadence-xspi.c new file +3
-0@@ -0,0 +1,895 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* +* Cadence XSPI flash controller driver Please make the entire comment a C++ so things look more intentional.
drivers/spi/spi-cadence-xspi.c line 287
Quoted 2 lines
drivers/spi/spi-cadence-xspi.c new file +2
-0+dev_info (cdns_xspi->dev, +"Running PHY training for read_dqs_delay parameter\n" );This print is just noise, please remove it.
drivers/spi/spi-cadence-xspi.c line 607
Quoted 8 lines
drivers/spi/spi-cadence-xspi.c new file +8
-0+static int cdns_xspi_setup (struct spi_device *spi_dev) +{ +if (spi_dev->chip_select > spi_dev->master->num_chipselect) { +dev_err (&spi_dev->dev, +"%d chip-select is out of range\n" , + spi_dev->chip_select); +return -EINVAL ; + }If this isn't already being validated by the core it should be and this function can be removed.
drivers/spi/spi-cadence-xspi.c line 621
Quoted 4 lines
drivers/spi/spi-cadence-xspi.c new file +4
-0+ irq_status =readl (cdns_xspi->iobase +CDNS_XSPI_INTR_STATUS_REG ); +if (irq_status) { +writel (irq_status, + cdns_xspi->iobase +CDNS_XSPI_INTR_STATUS_REG );This unconditionally acknowledges everything, even things we don't understand. If the hardware is generating unexpected interrupt statuses we should probably warn.
Quoted 6 lines
drivers/spi/spi-cadence-xspi.c new file +6
-0+static void cdns_xspi_print_phy_config (struct cdns_xspi_dev *cdns_xspi) +{ +struct device *dev = cdns_xspi->dev; + +dev_info (dev,"PHY configuration\n" ); + dev_info(dev, " * xspi_dll_phy_ctrl: %08x\n",drivers/spi/spi-cadence-xspi.c line 743
Quoted 10 lines
drivers/spi/spi-cadence-xspi.c new file +10
-0+ readl(cdns_xspi->iobase + CDNS_XSPI_DLL_PHY_CTRL)); +dev_info (dev," * phy_dq_timing: %08x\n" , +readl (cdns_xspi->auxbase +CDNS_XSPI_CCP_PHY_DQ_TIMING )); +dev_info (dev," * phy_dqs_timing: %08x\n" , +readl (cdns_xspi->auxbase +CDNS_XSPI_CCP_PHY_DQS_TIMING )); +dev_info (dev," * phy_gate_loopback_ctrl: %08x\n" , +readl (cdns_xspi->auxbase +CDNS_XSPI_CCP_PHY_GATE_LPBCK_CTRL )); +dev_info (dev," * phy_dll_slave_ctrl: %08x\n" , +readl (cdns_xspi->auxbase +CDNS_XSPI_CCP_PHY_DLL_SLAVE_CTRL )); +}This seems pretty verbose for an individual device... If this is needed for diagnostics perhaps put it in sysfs or debugfs where it'll be accessible even if the log wraps?
drivers/spi/spi-cadence-xspi.c line 864
Quoted 2 lines
drivers/spi/spi-cadence-xspi.c new file +2
-0+err_no_mem: +dev_err (dev,"Failed to probe Cadence XSPI controller driver\n" );Not sure this is adding anything over the individual error messages on specific failures.
Quoted 7 lines
drivers/spi/spi-cadence-xspi.c line 873
Quoted 5 lines
drivers/spi/spi-cadence-xspi.c new file +5
-0+#ifdef CONFIG_OF +static const struct of_device_id cdns_xspi_of_match[] = { + { + .compatible ="cdns,xspi-nor-fpga" , + },Why -fpga?
This is because this driver was tested only on FPGA board. This driver was not tested for ASIC version as PHY initialization algorithm is differ.
Signature · 2 lines
-- Konrad Kociolek
Mark Brown
maintainerQuoted 4 lines · Konrad Kociolek
Quoted 1 line · Mark Brown
Quoted 1 line
# Add new SPI master controllers in alphabetical order above this line
Quoted 8 lines
Quoted 2 lines
Please keep
KconfigandMakefilealphabetically sorted as the comment in the context from the diff says. :/What I see is
Kconfigis first andMakefileis second file in diff, according to:drivers/spi/Kconfig | 11 + drivers/spi/Makefile | 1 +Is that wrong?
Please keep the *contents* of the files Kconfig and Makefile alphabetically sorted as the comment in the context from the diff says.
Quoted 11 lines
Quoted 7 lines
drivers/spi/spi-cadence-xspi.c line 873
Quoted 5 lines
drivers/spi/spi-cadence-xspi.c new file +5
-0+#ifdef CONFIG_OF +static const struct of_device_id cdns_xspi_of_match[] = { + { + .compatible ="cdns,xspi-nor-fpga" , + },Why -fpga?
This is because this driver was tested only on FPGA board. This driver was not tested for ASIC version as PHY initialization algorithm is differ.
So there will need to be a separate compatible for any silicon integrations? Will that always be the same for all silicon integrations or should we have properties for the PHY type?