Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

dw: spi: add support for Amazon's Alpine spi controller

Add support for a new devicetree compatible string called
'amazon,alpine-apb-ssi', which is necessary for the Amazon Alpine spi
controller. 'amazon,alpine-dw-apb-ssi' is used in the dw spi driver if
specified in the devicetree. Otherwise, fall back to driver default
behavior, i.e. original dw IP hw driver behavior.

Signed-off-by: Talel Shenhar <talel@amazon.com>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Talel Shenhar and committed by
Mark Brown
f2d70479 d49a3036

+17
+9
drivers/spi/spi-dw-mmio.c
··· 126 126 JAGUAR2_IF_SI_OWNER_OFFSET); 127 127 } 128 128 129 + static int dw_spi_alpine_init(struct platform_device *pdev, 130 + struct dw_spi_mmio *dwsmmio) 131 + { 132 + dwsmmio->dws.cs_override = 1; 133 + 134 + return 0; 135 + } 136 + 129 137 static int dw_spi_mmio_probe(struct platform_device *pdev) 130 138 { 131 139 int (*init_func)(struct platform_device *pdev, ··· 238 230 { .compatible = "snps,dw-apb-ssi", }, 239 231 { .compatible = "mscc,ocelot-spi", .data = dw_spi_mscc_ocelot_init}, 240 232 { .compatible = "mscc,jaguar2-spi", .data = dw_spi_mscc_jaguar2_init}, 233 + { .compatible = "amazon,alpine-dw-apb-ssi", .data = dw_spi_alpine_init}, 241 234 { /* end of table */} 242 235 }; 243 236 MODULE_DEVICE_TABLE(of, dw_spi_mmio_of_match);
+6
drivers/spi/spi-dw.c
··· 144 144 145 145 if (!enable) 146 146 dw_writel(dws, DW_SPI_SER, BIT(spi->chip_select)); 147 + else if (dws->cs_override) 148 + dw_writel(dws, DW_SPI_SER, 0); 147 149 } 148 150 EXPORT_SYMBOL_GPL(dw_spi_set_cs); 149 151 ··· 465 463 dws->fifo_len = (fifo == 1) ? 0 : fifo; 466 464 dev_dbg(dev, "Detected FIFO size: %u bytes\n", dws->fifo_len); 467 465 } 466 + 467 + /* enable HW fixup for explicit CS deselect for Amazon's alpine chip */ 468 + if (dws->cs_override) 469 + dw_writel(dws, DW_SPI_CS_OVERRIDE, 0xF); 468 470 } 469 471 470 472 int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
+2
drivers/spi/spi-dw.h
··· 32 32 #define DW_SPI_IDR 0x58 33 33 #define DW_SPI_VERSION 0x5c 34 34 #define DW_SPI_DR 0x60 35 + #define DW_SPI_CS_OVERRIDE 0xf4 35 36 36 37 /* Bit fields in CTRLR0 */ 37 38 #define SPI_DFS_OFFSET 0 ··· 110 109 u32 fifo_len; /* depth of the FIFO buffer */ 111 110 u32 max_freq; /* max bus freq supported */ 112 111 112 + int cs_override; 113 113 u32 reg_io_width; /* DR I/O width in bytes */ 114 114 u16 bus_num; 115 115 u16 num_cs; /* supported slave numbers */