u-boot/drivers/spi
Sean Anderson 58875790fd spi: dw: Add support for multiple CTRLR0 layouts
CTRLR0 can have several different layouts depending on the specific device
(dw-apb-ssi vs dwc-ssi), and specific parameters set during synthesis.
Update the driver to support three specific configurations: dw-apb-ssi with
SSI_MAX_XFER_SIZE=16, dw-apb-ssi with SSI_MAX_XFER_SIZE=32, and dwc-ssi.

dw-apb-ssi is the version of the device on Altera/Intel SoCFPGAs, MSCC
SoCs, and Canaan Kendryte K210 SoCs. This is the only version this driver
supported before this change. The register layout before version 3.23a is:

|   31 .. 16  |
| other stuff |

|   15 .. 10  | 9 .. 8 | 7 .. 6 | 5 .. 4 | 3 .. 0 |
| other stuff |  TMOD  |  MODE  |  FRF   |  DFS   |

Note that DFS (Data Frame Size) is only 4 bits, limiting transfers to data
frames of 16 bits or less.

In version 3.23a, the SSI_MAX_XFER_SIZE parameter was introduced. This
parameter defaults to 16 (resulting in the same layout as prior versions),
but may also be set to 32. To allow setting longer data frame sizes, a new
DFS_32 register was introduced:

|   31 .. 21  | 20 .. 16 |
| other stuff |  DFS_32  |

|   15 .. 10  | 9 .. 8 | 7 .. 6 | 5 .. 4 |  3 .. 0   |
| other stuff |  TMOD  |  MODE  |  FRF   | all zeros |

The old DFS field no longer controls the data frame size. To detect this
layout, we try writing 0xF to DFS. If we read back 0x0, then this device
has SSI_MAX_XFER_SIZE=32.

dwc-ssi is the version of the device on Intel Keem Bay SoCs and Canaan
Kendryte K210 SoCs. The layout of ctrlr0 is:

|   31 .. 16  |
| other stuff |

|   15 .. 12  | 11 .. 10 | 9 .. 8 | 7 .. 6 | 4 .. 0 |
| other stuff |   TMOD   |  MODE  |  FRF   | DFS_32 |

The semantics of the fields have not changed since the previous version.
However, SSI_MAX_XFER_SIZE is effectively always 32.

To support these different layouts, we model our approach on the one
which the Linux kernel has taken. During probe, the driver calls an init
function stored in driver_data. This init function is responsible for
determining the layout of CTRLR0, and supplying the update_cr0 function.

The style of and information behind this commit is based on the Linux MMIO
driver for these devices. Specific reference was made to the series adding
support for Intel Keem Bay SoCs [1].

[1] https://lore.kernel.org/linux-spi/20200505130618.554-1-wan.ahmad.zainie.wan.mohamad@intel.com/

Signed-off-by: Sean Anderson <seanga2@gmail.com>
Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
2020-12-18 16:16:37 +05:30
..
altera_spi.c treewide: convert devfdt_get_addr() to dev_read_addr() 2020-07-25 14:46:57 -06:00
atcspi200_spi.c treewide: convert devfdt_get_addr() to dev_read_addr() 2020-07-25 14:46:57 -06:00
ath79_spi.c treewide: convert devfdt_get_addr() to dev_read_addr() 2020-07-25 14:46:57 -06:00
atmel-quadspi.c common: Drop linux/bitops.h from common header 2020-05-18 21:19:23 -04:00
atmel_spi.c treewide: convert (void *)devfdt_get_addr() to dev_read_addr_ptr() 2020-07-25 14:46:57 -06:00
atmel_spi.h spi: atmel: Remove nondm code 2020-06-11 15:14:04 +05:30
bcm63xx_hsspi.c common: Drop linux/bitops.h from common header 2020-05-18 21:19:23 -04:00
bcm63xx_spi.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
bcmstb_spi.c board: arm: Add support for Broadcom BCM7445 2018-07-10 16:55:57 -04:00
cadence_qspi.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
cadence_qspi.h spi: cadence-qspi: Add direct mode support 2020-01-27 22:27:22 +05:30
cadence_qspi_apb.c common: Drop linux/bitops.h from common header 2020-05-18 21:19:23 -04:00
cf_spi.c treewide: convert devfdt_get_addr() to dev_read_addr() 2020-07-25 14:46:57 -06:00
davinci_spi.c treewide: convert devfdt_get_addr() to dev_read_addr() 2020-07-25 14:46:57 -06:00
designware_spi.c spi: dw: Add support for multiple CTRLR0 layouts 2020-12-18 16:16:37 +05:30
exynos_spi.c treewide: convert (void *)devfdt_get_addr() to dev_read_addr_ptr() 2020-07-25 14:46:57 -06:00
fsl_dspi.c Merge https://gitlab.denx.de/u-boot/custodians/u-boot-fsl-qoriq 2020-07-27 15:18:15 -04:00
fsl_espi.c dm: spi: Convert Freescale ESPI driver to driver model 2020-06-18 21:47:08 +05:30
fsl_qspi.c spi: fsl_qspi: Include device_compat.h 2020-10-16 09:44:27 -04:00
ich.c x86: apl: Enable SPI flash in TPL with APL_SPI_FLASH_BOOT 2020-10-29 14:42:18 -06:00
ich.h common: Drop linux/bitops.h from common header 2020-05-18 21:19:23 -04:00
Kconfig spi: Add Qualcomm QUP SPI controller driver 2020-10-22 09:54:54 -04:00
kirkwood_spi.c treewide: convert (void *)devfdt_get_addr() to dev_read_addr_ptr() 2020-07-25 14:46:57 -06:00
Makefile spi: Add Qualcomm QUP SPI controller driver 2020-10-22 09:54:54 -04:00
meson_spifc.c common: Drop linux/bitops.h from common header 2020-05-18 21:19:23 -04:00
mpc8xx_spi.c common: Drop linux/delay.h from common header 2020-05-18 21:19:23 -04:00
mpc8xxx_spi.c spi: mpc8xxx_spi.c: fix cs activate/deactivate 2020-09-22 11:05:32 -04:00
mscc_bb_spi.c spi: Drop duplicate dm.h inclusion 2020-08-03 22:19:54 -04:00
mt7621_spi.c common: Drop linux/bitops.h from common header 2020-05-18 21:19:23 -04:00
mtk_snfi_spi.c treewide: convert (void *)devfdt_get_addr() to dev_read_addr_ptr() 2020-07-25 14:46:57 -06:00
mvebu_a3700_spi.c spi: mvebu_a3700_spi: add support for cs-gpios 2020-10-14 07:55:56 +02:00
mxc_spi.c treewide: convert devfdt_get_addr() to dev_read_addr() 2020-07-25 14:46:57 -06:00
mxs_spi.c drivers: avoid using aliases on drivers when OF_PLATDATA is enabled 2020-07-28 19:30:39 -06:00
nxp_fspi.c spi: nxp_fspi: Include device_compat.h 2020-10-16 09:44:27 -04:00
octeon_spi.c spi: octeon_spi: Use a fixed 100MHz input clock on Octeon TX2 2020-10-16 13:55:04 +02:00
omap3_spi.c spi: omap3_spi: Read platform data in ofdata_to_platdata() 2020-09-15 18:51:53 +05:30
pic32_spi.c common: Drop linux/bitops.h from common header 2020-05-18 21:19:23 -04:00
pl022_spi.c dm: platform_data: spi: s/pl022_spi.h/spi_pl022.h 2018-11-27 21:06:46 +05:30
renesas_rpc_spi.c spi: renesas_rpc_spi: Add R-Car Gen3 and RZ/G2 fallback compatibility string 2020-10-20 12:56:46 +02:00
rk_spi.c drivers: spi: rk_spi: Add support for RK3328 2020-07-22 20:22:03 +08:00
rk_spi.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
sandbox_spi.c dm: acpi: Enhance acpi_get_name() 2020-07-17 14:32:24 +08:00
sh_qspi.c spi: Convert CONFIG_DM_SPI* to CONFIG_$(SPL_TPL_)DM_SPI* 2020-06-29 13:34:43 -04:00
soft_spi.c spi: add support for all spi modes with soft spi 2020-07-09 20:58:06 +05:30
spi-emul-uclass.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
spi-mem-nodm.c common: Drop log.h from common header 2020-05-18 21:19:18 -04:00
spi-mem.c mtd: spi-mem: Drop dm.h header file 2020-08-03 22:19:54 -04:00
spi-qup.c spi: Add Qualcomm QUP SPI controller driver 2020-10-22 09:54:54 -04:00
spi-sifive.c mtd: spi-mem: Drop dm.h header file 2020-08-03 22:19:54 -04:00
spi-sunxi.c spi: sunxi: Fix not calling dev_err with a device 2020-09-30 08:53:45 -04:00
spi-uclass.c spi: migrate trace to dev and log macro in spi uclass 2020-12-18 16:16:36 +05:30
spi.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
stm32_qspi.c mtd: spi-mem: Drop dm.h header file 2020-08-03 22:19:54 -04:00
stm32_spi.c common: Drop linux/bitops.h from common header 2020-05-18 21:19:23 -04:00
tegra20_sflash.c treewide: convert devfdt_get_addr() to dev_read_addr() 2020-07-25 14:46:57 -06:00
tegra20_slink.c treewide: convert devfdt_get_addr() to dev_read_addr() 2020-07-25 14:46:57 -06:00
tegra114_spi.c common: Drop linux/bitops.h from common header 2020-05-18 21:19:23 -04:00
tegra210_qspi.c common: Drop linux/bitops.h from common header 2020-05-18 21:19:23 -04:00
tegra_spi.h SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
ti_qspi.c treewide: convert devfdt_get_addr() to dev_read_addr() 2020-07-25 14:46:57 -06:00
uniphier_spi.c treewide: convert devfdt_get_addr_ptr() to dev_read_addr_ptr() 2020-08-22 08:53:37 -06:00
xilinx_spi.c spi: xilinx_spi: remove unused local variable 2020-10-27 08:13:32 +01:00
zynq_qspi.c spi: zynq_qspi: Add function description 2020-10-27 08:13:33 +01:00
zynq_spi.c spi: zynq_spi: Use clk subsystem to get reference spi clk 2020-10-27 08:13:32 +01:00
zynqmp_gqspi.c spi: zynqmp_gqspi: Fix not calling dev_err with a device 2020-09-30 08:53:47 -04:00