Skip to content

Commit bc4f0b1

Browse files
Demon000broonie
authored andcommitted
spi: rzv2h-rspi: add support for loopback mode
Add support for loopback mode for debugging purposes, allowing us to test the SPI controller at the maximum SPI transfer clock without being limited by external wiring. Signed-off-by: Cosmin Tanislav <cosmin-gabriel.tanislav.xa@renesas.com> Link: https://patch.msgid.link/20251119161434.595677-10-cosmin-gabriel.tanislav.xa@renesas.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 9c9bf4f commit bc4f0b1

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

drivers/spi/spi-rzv2h-rspi.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
/* Registers */
2525
#define RSPI_SPDR 0x00
2626
#define RSPI_SPCR 0x08
27+
#define RSPI_SPPCR 0x0e
2728
#define RSPI_SSLP 0x10
2829
#define RSPI_SPBR 0x11
2930
#define RSPI_SPSCR 0x13
@@ -40,6 +41,9 @@
4041
#define RSPI_SPCR_SCKASE BIT(12)
4142
#define RSPI_SPCR_SPE BIT(0)
4243

44+
/* Register SPPCR */
45+
#define RSPI_SPPCR_SPLP2 BIT(1)
46+
4347
/* Register SPBR */
4448
#define RSPI_SPBR_SPR_MIN 0
4549
#define RSPI_SPBR_SPR_PCLK_MIN 1
@@ -345,6 +349,7 @@ static int rzv2h_rspi_prepare_message(struct spi_controller *ctlr,
345349
u8 bits_per_word;
346350
u32 conf32;
347351
u16 conf16;
352+
u8 conf8;
348353

349354
/* Make sure SPCR.SPE is 0 before amending the configuration */
350355
rzv2h_rspi_spe_disable(rspi);
@@ -389,6 +394,10 @@ static int rzv2h_rspi_prepare_message(struct spi_controller *ctlr,
389394
/* Use SPCMD0 only */
390395
writeb(0x0, rspi->base + RSPI_SPSCR);
391396

397+
/* Setup loopback */
398+
conf8 = FIELD_PREP(RSPI_SPPCR_SPLP2, !!(spi->mode & SPI_LOOP));
399+
writeb(conf8, rspi->base + RSPI_SPPCR);
400+
392401
/* Setup mode */
393402
conf32 = FIELD_PREP(RSPI_SPCMD_CPOL, !!(spi->mode & SPI_CPOL));
394403
conf32 |= FIELD_PREP(RSPI_SPCMD_CPHA, !!(spi->mode & SPI_CPHA));
@@ -490,7 +499,7 @@ static int rzv2h_rspi_probe(struct platform_device *pdev)
490499
}
491500

492501
controller->mode_bits = SPI_CPHA | SPI_CPOL | SPI_CS_HIGH |
493-
SPI_LSB_FIRST;
502+
SPI_LSB_FIRST | SPI_LOOP;
494503
controller->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32);
495504
controller->prepare_message = rzv2h_rspi_prepare_message;
496505
controller->unprepare_message = rzv2h_rspi_unprepare_message;

0 commit comments

Comments
 (0)