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

spi: s3c64xx: support loopback mode

Modern exynos SoCs can support self loopback mode via setting BIT(3) of
MODE_CFG register. Previous SoCs don't have the bit so we need to add
has_loopback field in the s3c64xx_spi_port_config. Exynos Auto v9 SoC
has the bit and it will define the field to "true".
When it is set, SPI_LOOP mode will be marked.

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Andi Shyti <andi@etezian.org>
Signed-off-by: Chanho Park <chanho61.park@samsung.com>
Link: https://lore.kernel.org/r/20220629102304.65712-2-chanho61.park@samsung.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Chanho Park and committed by
Mark Brown
ffb7bcd3 152f2494

+8
+8
drivers/spi/spi-s3c64xx.c
··· 59 59 #define S3C64XX_SPI_MODE_BUS_TSZ_HALFWORD (1<<17) 60 60 #define S3C64XX_SPI_MODE_BUS_TSZ_WORD (2<<17) 61 61 #define S3C64XX_SPI_MODE_BUS_TSZ_MASK (3<<17) 62 + #define S3C64XX_SPI_MODE_SELF_LOOPBACK (1<<3) 62 63 #define S3C64XX_SPI_MODE_RXDMA_ON (1<<2) 63 64 #define S3C64XX_SPI_MODE_TXDMA_ON (1<<1) 64 65 #define S3C64XX_SPI_MODE_4BURST (1<<0) ··· 136 135 * @clk_from_cmu: True, if the controller does not include a clock mux and 137 136 * prescaler unit. 138 137 * @clk_ioclk: True if clock is present on this device 138 + * @has_loopback: True if loopback mode can be supported 139 139 * 140 140 * The Samsung s3c64xx SPI controller are used on various Samsung SoC's but 141 141 * differ in some aspects such as the size of the fifo and spi bus clock ··· 151 149 bool high_speed; 152 150 bool clk_from_cmu; 153 151 bool clk_ioclk; 152 + bool has_loopback; 154 153 }; 155 154 156 155 /** ··· 662 659 break; 663 660 } 664 661 662 + if ((sdd->cur_mode & SPI_LOOP) && sdd->port_conf->has_loopback) 663 + val |= S3C64XX_SPI_MODE_SELF_LOOPBACK; 664 + 665 665 writel(val, regs + S3C64XX_SPI_MODE_CFG); 666 666 667 667 if (sdd->port_conf->clk_from_cmu) { ··· 1154 1148 SPI_BPW_MASK(8); 1155 1149 /* the spi->mode bits understood by this driver: */ 1156 1150 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; 1151 + if (sdd->port_conf->has_loopback) 1152 + master->mode_bits |= SPI_LOOP; 1157 1153 master->auto_runtime_pm = true; 1158 1154 if (!is_polling(sdd)) 1159 1155 master->can_dma = s3c64xx_spi_can_dma;