Skip to content

Commit c2cc4b7

Browse files
geertubroonie
authored andcommitted
spi: sh-msiof: SITSCR/SIRSCR bitfield conversion
Convert MSIOF Transmit and Receive Clock Select Register field accesses to use the FIELD_PREP() bitfield access macro. This gets rid of explicit shifts and custom field preparation macros. Signed-off-by: Geert Uytterhoeven <[email protected]> Link: https://patch.msgid.link/f2462c99b6ea2e45b995ab4509c2f039043da032.1747401908.git.geert+renesas@glider.be Signed-off-by: Mark Brown <[email protected]>
1 parent 386cc52 commit c2cc4b7

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

drivers/spi/spi-sh-msiof.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,14 @@ struct sh_msiof_spi_priv {
105105
#define SIMDR2_GRPMASK1 BIT(0) /* Group Output Mask 1 (SH, A1) */
106106

107107
/* SITSCR and SIRSCR */
108-
#define SISCR_BRPS_MASK GENMASK(12, 8) /* Prescaler Setting (1-32) */
109-
#define SISCR_BRPS(i) (((i) - 1) << 8)
110-
#define SISCR_BRDV_MASK GENMASK(2, 0) /* Baud Rate Generator's Division Ratio */
111-
#define SISCR_BRDV_DIV_2 0
112-
#define SISCR_BRDV_DIV_4 1
113-
#define SISCR_BRDV_DIV_8 2
114-
#define SISCR_BRDV_DIV_16 3
115-
#define SISCR_BRDV_DIV_32 4
116-
#define SISCR_BRDV_DIV_1 7
108+
#define SISCR_BRPS GENMASK(12, 8) /* Prescaler Setting (1-32) */
109+
#define SISCR_BRDV GENMASK(2, 0) /* Baud Rate Generator's Division Ratio */
110+
#define SISCR_BRDV_DIV_2 0U
111+
#define SISCR_BRDV_DIV_4 1U
112+
#define SISCR_BRDV_DIV_8 2U
113+
#define SISCR_BRDV_DIV_16 3U
114+
#define SISCR_BRDV_DIV_32 4U
115+
#define SISCR_BRDV_DIV_1 7U
117116

118117
/* SICTR */
119118
#define SICTR_TSCKIZ_MASK GENMASK(31, 30) /* Transmit Clock I/O Polarity Select */
@@ -299,7 +298,8 @@ static void sh_msiof_spi_set_clk_regs(struct sh_msiof_spi_priv *p,
299298

300299
t->effective_speed_hz = parent_rate / (brps << div_pow);
301300

302-
scr = sh_msiof_spi_div_array[div_pow] | SISCR_BRPS(brps);
301+
scr = FIELD_PREP(SISCR_BRDV, sh_msiof_spi_div_array[div_pow]) |
302+
FIELD_PREP(SISCR_BRPS, brps - 1);
303303
sh_msiof_write(p, SITSCR, scr);
304304
if (!(p->ctlr->flags & SPI_CONTROLLER_MUST_TX))
305305
sh_msiof_write(p, SIRSCR, scr);

0 commit comments

Comments
 (0)