Skip to content

Commit bd8d665

Browse files
geertubroonie
authored andcommitted
spi: sh-msiof: SICTR bitfield conversion
Convert MSIOF Control Register field accesses to use the FIELD_PREP() bitfield access macro. This gets rid of explicit shifts. Signed-off-by: Geert Uytterhoeven <[email protected]> Link: https://patch.msgid.link/4511c678c8fce5969eb50ffa7372d53396ff80ff.1747401908.git.geert+renesas@glider.be Signed-off-by: Mark Brown <[email protected]>
1 parent c2cc4b7 commit bd8d665

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

drivers/spi/spi-sh-msiof.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -115,18 +115,18 @@ struct sh_msiof_spi_priv {
115115
#define SISCR_BRDV_DIV_1 7U
116116

117117
/* SICTR */
118-
#define SICTR_TSCKIZ_MASK GENMASK(31, 30) /* Transmit Clock I/O Polarity Select */
118+
#define SICTR_TSCKIZ GENMASK(31, 30) /* Transmit Clock I/O Polarity Select */
119119
#define SICTR_TSCKIZ_SCK BIT(31) /* Disable SCK when TX disabled */
120-
#define SICTR_TSCKIZ_POL_SHIFT 30 /* Transmit Clock Polarity */
121-
#define SICTR_RSCKIZ_MASK GENMASK(29, 28) /* Receive Clock Polarity Select */
120+
#define SICTR_TSCKIZ_POL BIT(30) /* Transmit Clock Polarity */
121+
#define SICTR_RSCKIZ GENMASK(29, 28) /* Receive Clock Polarity Select */
122122
#define SICTR_RSCKIZ_SCK BIT(29) /* Must match CTR_TSCKIZ_SCK */
123-
#define SICTR_RSCKIZ_POL_SHIFT 28 /* Receive Clock Polarity */
124-
#define SICTR_TEDG_SHIFT 27 /* Transmit Timing (1 = falling edge) */
125-
#define SICTR_REDG_SHIFT 26 /* Receive Timing (1 = falling edge) */
126-
#define SICTR_TXDIZ_MASK GENMASK(23, 22) /* Pin Output When TX is Disabled */
127-
#define SICTR_TXDIZ_LOW (0 << 22) /* 0 */
128-
#define SICTR_TXDIZ_HIGH (1 << 22) /* 1 */
129-
#define SICTR_TXDIZ_HIZ (2 << 22) /* High-impedance */
123+
#define SICTR_RSCKIZ_POL BIT(28) /* Receive Clock Polarity */
124+
#define SICTR_TEDG BIT(27) /* Transmit Timing (1 = falling edge) */
125+
#define SICTR_REDG BIT(26) /* Receive Timing (1 = falling edge) */
126+
#define SICTR_TXDIZ GENMASK(23, 22) /* Pin Output When TX is Disabled */
127+
#define SICTR_TXDIZ_LOW 0U /* 0 */
128+
#define SICTR_TXDIZ_HIGH 1U /* 1 */
129+
#define SICTR_TXDIZ_HIZ 2U /* High-impedance */
130130
#define SICTR_TSCKE BIT(15) /* Transmit Serial Clock Output Enable */
131131
#define SICTR_TFSE BIT(14) /* Transmit Frame Sync Signal Output Enable */
132132
#define SICTR_TXE BIT(9) /* Transmit Enable */
@@ -382,14 +382,15 @@ static void sh_msiof_spi_set_pin_regs(struct sh_msiof_spi_priv *p, u32 ss,
382382
sh_msiof_write(p, SIRMDR1, tmp);
383383

384384
tmp = 0;
385-
tmp |= SICTR_TSCKIZ_SCK | cpol << SICTR_TSCKIZ_POL_SHIFT;
386-
tmp |= SICTR_RSCKIZ_SCK | cpol << SICTR_RSCKIZ_POL_SHIFT;
385+
tmp |= SICTR_TSCKIZ_SCK | FIELD_PREP(SICTR_TSCKIZ_POL, cpol);
386+
tmp |= SICTR_RSCKIZ_SCK | FIELD_PREP(SICTR_RSCKIZ_POL, cpol);
387387

388388
edge = cpol ^ !cpha;
389389

390-
tmp |= edge << SICTR_TEDG_SHIFT;
391-
tmp |= edge << SICTR_REDG_SHIFT;
392-
tmp |= tx_hi_z ? SICTR_TXDIZ_HIZ : SICTR_TXDIZ_LOW;
390+
tmp |= FIELD_PREP(SICTR_TEDG, edge);
391+
tmp |= FIELD_PREP(SICTR_REDG, edge);
392+
tmp |= FIELD_PREP(SICTR_TXDIZ,
393+
tx_hi_z ? SICTR_TXDIZ_HIZ : SICTR_TXDIZ_LOW);
393394
sh_msiof_write(p, SICTR, tmp);
394395
}
395396

0 commit comments

Comments
 (0)