Driver for Cadence xSPI flash controller
Subsystems (2)
cover Driver for Cadence xSPI flash controller
Command processing
Driver uses STIG work mode to communicate with flash memories. In this mode, controller sends low-level instructions to memory. Each instruction is 128-bit width. There is special instruction DataSequence which carries information about data phase. Driver uses Slave DMA interface to transfer data as only this interface can be used in STIG work mode.
PHY initialization
The initialization of PHY module in Cadence XSPI controller is done by driving external pin-strap signals to controller. Next, driver runs PHY training to find optimal value of read_dqs_delay parameter. Controller checks device discovery status and if it's completed and with no error PHY training passes.
Jayshri Pawar (2):
Add support for Cadence XSPI controller
Add dt-bindings documentation for Cadence XSPI controller
.../devicetree/bindings/spi/cdns,xspi.yaml | 164 ++++ drivers/spi/Kconfig | 11 + drivers/spi/Makefile | 1 + drivers/spi/spi-cadence-xspi.c | 894 +++++++++++++++++++++ 4 files changed, 1070 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/cdns,xspi.yaml create mode 100644 drivers/spi/spi-cadence-xspi.c
Signature · 1 line
2.7.4
PATCH 1/2 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.
--- drivers/spi/Kconfig | 11 + drivers/spi/Makefile | 1 + drivers/spi/spi-cadence-xspi.c | 894 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 906 insertions(+) create mode 100644 drivers/spi/spi-cadence-xspi.c
drivers/spi/Kconfig +11 -0
@@ -212,6 +212,17 @@ config SPI_CADENCE_QUADSPI device with a Cadence QSPI controller and want to access the Flash as an MTD device. +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. + config SPI_CLPS711X tristate "CLPS711X host SPI controller" depends on ARCH_CLPS711X || COMPILE_TEST
drivers/spi/Makefile +1 -0
@@ -32,6 +32,7 @@ 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_CADENCE_XSPI) += spi-cadence-xspi.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-xspi.c new file +894 -0
894 lines not on this page · raw message
Signature · 1 line
2.7.4
kernel test robot
build botRe: [PATCH 1/2] Add support for Cadence XSPI controller
Thank you for the patch! Perhaps something to improve:
Hi Jayshri,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on spi/for-next]
[also build test WARNING on v5.10-rc7 next-20201208]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Jayshri-Pawar/Driver-for-Cadence-xSPI-flash-controller/20201209-160406 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next config: sparc-allyesconfig (attached as .config) compiler: sparc64-linux-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/5b258ff21564ca007e3b54d865c3cfb9851ed00a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jayshri-Pawar/Driver-for-Cadence-xSPI-flash-controller/20201209-160406 git checkout 5b258ff21564ca007e3b54d865c3cfb9851ed00a
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=sparc
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
In file included from arch/sparc/include/asm/io.h:5,
from include/linux/io.h:13,
from drivers/spi/spi-cadence-xspi.c:15:
drivers/spi/spi-cadence-xspi.c: In function 'cdns_xspi_send_stig_command':
>> arch/sparc/include/asm/io_64.h:179:2: warning: '*((void *)&cmd_regs+20)' is used uninitialized in this function [-Wuninitialized]
179 | __asm__ __volatile__("stwa\t%r0, [%1] %2\t/* pci_writel */"
| ^~~~~~~
drivers/spi/spi-cadence-xspi.c:521:6: note: '*((void *)&cmd_regs+20)' was declared here
521 | u32 cmd_regs[5] = {0};
| ^~~~~~~~vim +179 arch/sparc/include/asm/io_64.h
f5e706ad886b6a5 include/asm-sparc/io_64.h Sam Ravnborg 2008-07-17 174
79294d7eff89f65 arch/sparc/include/asm/io_64.h Sam Ravnborg 2014-07-20 175 #define writel writel
7c3969c3a4f3593 arch/sparc/include/asm/io_64.h Arnd Bergmann 2014-11-19 176 #define writel_relaxed writel
79294d7eff89f65 arch/sparc/include/asm/io_64.h Sam Ravnborg 2014-07-20 177 static inline void writel(u32 l, volatile void __iomem *addr)
f5e706ad886b6a5 include/asm-sparc/io_64.h Sam Ravnborg 2008-07-17 178 {
f5e706ad886b6a5 include/asm-sparc/io_64.h Sam Ravnborg 2008-07-17 @179 __asm__ __volatile__("stwa\t%r0, [%1] %2\t/* pci_writel */"
f5e706ad886b6a5 include/asm-sparc/io_64.h Sam Ravnborg 2008-07-17 180 : /* no outputs */
f5e706ad886b6a5 include/asm-sparc/io_64.h Sam Ravnborg 2008-07-17 181 : "Jr" (l), "r" (addr), "i" (ASI_PHYS_BYPASS_EC_E_L)
f5e706ad886b6a5 include/asm-sparc/io_64.h Sam Ravnborg 2008-07-17 182 : "memory");
f5e706ad886b6a5 include/asm-sparc/io_64.h Sam Ravnborg 2008-07-17 183 }
f5e706ad886b6a5 include/asm-sparc/io_64.h Sam Ravnborg 2008-07-17 184 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botRe: [PATCH 1/2] Add support for Cadence XSPI controller
In reply to Jayshri PawarThank you for the patch! Perhaps something to improve:
Hi Jayshri,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on spi/for-next]
[also build test WARNING on v5.10-rc7 next-20201209]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Jayshri-Pawar/Driver-for-Cadence-xSPI-flash-controller/20201209-160406 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next config: arm-randconfig-r006-20201210 (attached as .config) compiler: arm-linux-gnueabi-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/5b258ff21564ca007e3b54d865c3cfb9851ed00a
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jayshri-Pawar/Driver-for-Cadence-xSPI-flash-controller/20201209-160406 git checkout 5b258ff21564ca007e3b54d865c3cfb9851ed00a
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arm
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
In file included from include/linux/io.h:13,
from drivers/spi/spi-cadence-xspi.c:15:
drivers/spi/spi-cadence-xspi.c: In function 'cdns_xspi_send_stig_command':
>> arch/arm/include/asm/io.h:95:2: warning: '*((void *)&cmd_regs+20)' is used uninitialized in this function [-Wuninitialized]
95 | asm volatile("str %1, %0"
| ^~~
drivers/spi/spi-cadence-xspi.c:521:6: note: '*((void *)&cmd_regs+20)' was declared here
521 | u32 cmd_regs[5] = {0};
| ^~~~~~~~vim +95 arch/arm/include/asm/io.h
195bbcac2e5c12f Will Deacon 2012-08-24 91
84c4d3a6d438f59 Thierry Reding 2014-07-28 92 #define __raw_writel __raw_writel
195bbcac2e5c12f Will Deacon 2012-08-24 93 static inline void __raw_writel(u32 val, volatile void __iomem *addr)
195bbcac2e5c12f Will Deacon 2012-08-24 94 {
195bbcac2e5c12f Will Deacon 2012-08-24 @95 asm volatile("str %1, %0"
5bb5d66d89041b7 Peter Hurley 2015-04-13 96 : : "Qo" (*(volatile u32 __force *)addr), "r" (val));
195bbcac2e5c12f Will Deacon 2012-08-24 97 }
195bbcac2e5c12f Will Deacon 2012-08-24 98 ---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Re: [PATCH 1/2] Add support for Cadence XSPI controller
In reply to Jayshri Pawardrivers/spi/spi-cadence-xspi.c line 757
Quoted 6 lines · Jayshri Pawar
drivers/spi/spi-cadence-xspi.c new file +6
-0+ master =spi_alloc_master (dev,sizeof (*cdns_xspi)); +if (!master) { + ret = -ENOMEM ; +dev_err (dev,"Failed to allocate memory for spi_master\n" ); + goto err_no_mem; + }
Please use devm_spi_alloc_master() to simplify the probe error path. It was introduced in v5.10-rc5 with commit 5e844cc37a5c and is also available in 5.9-stable and 5.4-stable.
The memory allocater already emits an error message if it can't satisfy a request. Emitting an additional message here isn't really necessary.
drivers/spi/spi-cadence-xspi.c line 800
Quoted 7 lines
drivers/spi/spi-cadence-xspi.c new file +7
-0+ res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + cdns_xspi->iobase =devm_ioremap_resource (cdns_xspi->dev, res); +if (IS_ERR (cdns_xspi->iobase)) { + ret =PTR_ERR (cdns_xspi->iobase); +dev_err (dev,"Failed to remap controller base address\n" ); + goto err_spi_master; + }
Please use devm_platform_ioremap_resource().
Thanks,
Lukas
PATCH 2/2 Add dt-bindings documentation for Cadence XSPI controller
In reply to Jayshri PawarAdd dt-bindings documentation for Cadence XSPI controller to support SPI based flash memories.
--- .../devicetree/bindings/spi/cdns,xspi.yaml | 164 +++++++++++++++++++++ 1 file changed, 164 insertions(+) create mode 100644 Documentation/devicetree/bindings/spi/cdns,xspi.yaml
Documentation/devicetree/bindings/spi/cdns,xspi.yaml new file +164 -0
@@ -0,0 +1,164 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +# Copyright 2020 Cadence +%YAML 1.2 +--- +$id: "http://devicetree.org/schemas/spi/cdns,xspi.yaml#" +$schema: "http://devicetree.org/meta-schemas/core.yaml#" + +title: Cadence XSPI Controller + +maintainers: + - Jayshri Pawar <[email protected]> + - Konrad Kociolek <[email protected]> + +description: | + The XSPI controller allows SPI protocol communication in + single, dual, quad or octal wire transmission modes for + read/write access to slaves such as SPI-NOR flash. + +properties: + compatible: + const: cdns,xspi-nor-fpga + + reg: + items: + - description: address and lentgh of the controller register set + - description: address and lentgh of the Slave DMA data port + - description: address and lentgh of the auxiliary registers + + interrupts: + maxItems: 1 + + cdns,dqs-last-data-drop: + type: boolean + description: | + This parameter should be set when the Flash Device being used + issues data on negative edge of Flash clock and returns them with + DQS and the PHY is configured to sample data in DQS mode. + If this param is set the controller internally requests this redundant + data at the end of the transfer cleaning up the PHY FIFO. + + cdns,phy-data-select-oe-start: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Adjusts the starting point of the DQ pad output enable window. + Lower numbers pull the rising edge earlier in time and larger + numbers cause the rising edge to be delayed. Each bit changes + the output enable time by a 1/2 cycle resolution. + + cdns,phy-data-select-oe-end: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Adjusts the ending point of the DQ pad output enable window. + Lower numbers pull the falling edge earlier in time and larger + numbers cause the falling edge to be delayed. Each bit changes + the output enable time by a 1/2 cycle resolution. + + cdns,phy-dqs-select-oe-start: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Adjusts the starting point of the DQS pad output enable window. + Lower numbers pull the rising edge earlier in time and larger + numbers cause the rising edge to be delayed. Each bit changes + the output enable time by a 1/2 cycle resolution. + + cdns,phy-dqs-select-oe-end: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Adjusts the ending point of the DQS pad output enable window. + Lower numbers pull the falling edge earlier in time and larger + numbers cause the falling edge to be delayed. Each bit changes + the output enable time by a 1/2 cycle resolution. + + cdns,phy-gate-cfg-close: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Normally the gate is closing then all bits of dfi_cebar are high + or when dfi_rd_pre_post_amble and rebar_dfi are high. This parameter + allows to extend the closing of the DQS gate. Recommended zero. + + cdns,phy-gate-cfg: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Coarse adjust of gate open time. This value is the number of cycles + to delay the dfi_rddata_en signal prior to opening the gate in + full cycle increments. Decreasing this value pulls the gate earlier + in time. This field should be programmed such that the gate signal + lands in the valid DQS gate window. + + cdns,phy-rd-del-select: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Defines the read data delay. Holds the number of cycles to delay + the dfi_rddata_en signal prior to enabling the read FIFO. + After this delay, the read pointers begin incrementing the read FIFO. + + cdns,phy-clk-wr-delay: + $ref: /schemas/types.yaml#/definitions/uint32 + description: | + Controls the clk_wr delay line which adjusts the write DQ bit + timing in 1/256th steps of the clock period in normal DLL + locked mode. In bypass mode this field directly programs + the number of delay elements. + + cdns,phy-use-lpbk-dqs: + type: boolean + description: | + This parameter chooses lpbk_dqs to capture data for reads. + Instead memory DQS will be used. + + cdns,phy-use-ext-lpbk-dqs: + type: boolean + description: | + This parameter chooses external lpbk_dqs for data capture + (lpbk_dqs connected to the lpbk_dqs_IO pad). When not used + mem_rebar_pad is used for data read capture. + +required: + - compatible + - reg + - interrupts + - cdns,phy-data-select-oe-start + - cdns,phy-data-select-oe-end + - cdns,phy-dqs-select-oe-start + - cdns,phy-dqs-select-oe-end + - cdns,phy-gate-cfg-close + - cdns,phy-gate-cfg + - cdns,phy-rd-del-select + - cdns,phy-clk-wr-delay + +examples: + - | + #include <dt-bindings/interrupt-controller/irq.h> + + xspi: spi@a0010000 { + #address-cells = <1>; + #size-cells = <0>; + compatible = "cdns,xspi-nor-fpga"; + reg = <0x0 0xa0010000 0x0 0x10000>, + <0x0 0xb0000000 0x0 0x10000>, + <0x0 0xa0020000 0x0 0x10000>; + interrupts = <0 90 IRQ_TYPE_LEVEL_HIGH>; + interrupt-parent = <&gic>; + cdns,dqs-last-data-drop; + cdns,phy-data-select-oe-start = <0>; + cdns,phy-data-select-oe-end = <4>; + cdns,phy-dqs-select-oe-start = <0>; + cdns,phy-dqs-select-oe-end = <1>; + cdns,phy-gate-cfg-close = <3>; + cdns,phy-gate-cfg = <0>; + cdns,phy-rd-del-select = <5>; + cdns,phy-clk-wr-delay = <64>; + cdns,phy-use-lpbk-dqs; + cdns,phy-use-ext-lpbk-dqs; + flash@0 { + compatible = "spi-nor", "micron,mt35xu512"; + spi-max-frequency = <75000000>; + reg = <0>; + }; + flash@1 { + compatible = "spi-nor", "micron,mt35xu512"; + spi-max-frequency = <75000000>; + reg = <1>; + }; + };
Signature · 1 line
2.7.4