Skip to content

Commit 955f7ce

Browse files
geertubroonie
authored andcommitted
spi: sh-msiof: Add core support for dual-group transfers
All MSIOF variants support transferring data of multiple (2 or 4) groups. Add definitions for the register bits related to multiple groups, and enhance sh_msiof_spi_set_mode_regs() to accept a second group size. For now the second group is unused. Signed-off-by: Geert Uytterhoeven <[email protected]> Link: https://patch.msgid.link/be75e20cfcd2a6c0d73ab09e0126f902911adc69.1747401908.git.geert+renesas@glider.be Signed-off-by: Mark Brown <[email protected]>
1 parent acedbff commit 955f7ce

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

drivers/spi/spi-sh-msiof.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,15 @@ struct sh_msiof_spi_priv {
100100
/* 0=MSIOF_SYNC, 1=MSIOF_SS1, 2=MSIOF_SS2 */
101101

102102
/* SITMDR2 and SIRMDR2 */
103+
#define SIMDR2_GRP GENMASK(31, 30) /* Group Count */
103104
#define SIMDR2_BITLEN1 GENMASK(28, 24) /* Data Size (8-32 bits) */
104105
#define SIMDR2_WDLEN1 GENMASK(23, 16) /* Word Count (1-64/256 (SH, A1))) */
105106
#define SIMDR2_GRPMASK GENMASK(3, 0) /* Group Output Mask 1-4 (SH, A1) */
106107

108+
/* SITMDR3 and SIRMDR3 */
109+
#define SIMDR3_BITLEN2 GENMASK(28, 24) /* Data Size (8-32 bits) */
110+
#define SIMDR3_WDLEN2 GENMASK(23, 16) /* Word Count (1-64/256 (SH, A1))) */
111+
107112
/* SITSCR and SIRSCR */
108113
#define SISCR_BRPS GENMASK(12, 8) /* Prescaler Setting (1-32) */
109114
#define SISCR_BRDV GENMASK(2, 0) /* Baud Rate Generator's Division Ratio */
@@ -392,10 +397,11 @@ static void sh_msiof_spi_set_pin_regs(struct sh_msiof_spi_priv *p, u32 ss,
392397

393398
static void sh_msiof_spi_set_mode_regs(struct sh_msiof_spi_priv *p,
394399
const void *tx_buf, void *rx_buf,
395-
u32 bits, u32 words)
400+
u32 bits, u32 words1, u32 words2)
396401
{
397-
u32 dr2 = FIELD_PREP(SIMDR2_BITLEN1, bits - 1) |
398-
FIELD_PREP(SIMDR2_WDLEN1, words - 1);
402+
u32 dr2 = FIELD_PREP(SIMDR2_GRP, words2 ? 1 : 0) |
403+
FIELD_PREP(SIMDR2_BITLEN1, bits - 1) |
404+
FIELD_PREP(SIMDR2_WDLEN1, words1 - 1);
399405

400406
if (tx_buf || (p->ctlr->flags & SPI_CONTROLLER_MUST_TX))
401407
sh_msiof_write(p, SITMDR2, dr2);
@@ -404,6 +410,15 @@ static void sh_msiof_spi_set_mode_regs(struct sh_msiof_spi_priv *p,
404410

405411
if (rx_buf)
406412
sh_msiof_write(p, SIRMDR2, dr2);
413+
414+
if (words2) {
415+
u32 dr3 = FIELD_PREP(SIMDR3_BITLEN2, bits - 1) |
416+
FIELD_PREP(SIMDR3_WDLEN2, words2 - 1);
417+
418+
sh_msiof_write(p, SITMDR3, dr3);
419+
if (rx_buf)
420+
sh_msiof_write(p, SIRMDR3, dr3);
421+
}
407422
}
408423

409424
static void sh_msiof_reset_str(struct sh_msiof_spi_priv *p)
@@ -712,7 +727,7 @@ static int sh_msiof_spi_txrx_once(struct sh_msiof_spi_priv *p,
712727
sh_msiof_write(p, SIFCTR, 0);
713728

714729
/* setup msiof transfer mode registers */
715-
sh_msiof_spi_set_mode_regs(p, tx_buf, rx_buf, bits, words);
730+
sh_msiof_spi_set_mode_regs(p, tx_buf, rx_buf, bits, words, 0);
716731
sh_msiof_write(p, SIIER, SIIER_TEOFE | SIIER_REOFE);
717732

718733
/* write tx fifo */
@@ -812,7 +827,7 @@ static int sh_msiof_dma_once(struct sh_msiof_spi_priv *p, const void *tx,
812827
FIELD_PREP(SIFCTR_RFWM, SIFCTR_RFWM_1));
813828

814829
/* setup msiof transfer mode registers (32-bit words) */
815-
sh_msiof_spi_set_mode_regs(p, tx, rx, 32, len / 4);
830+
sh_msiof_spi_set_mode_regs(p, tx, rx, 32, len / 4, 0);
816831

817832
sh_msiof_write(p, SIIER, ier_bits);
818833

0 commit comments

Comments
 (0)