Skip to content

Commit 3a5e762

Browse files
swilkins-raymarinebroonie
authored andcommitted
spi: microchip-core: fix init function not setting the master and motorola modes
mchp_corespi_init() reads the CONTROL register, sets the master and motorola bits, but doesn't write the value back to the register. The function also doesn't ensure the controller is disabled at the start, which may present a problem if the controller was used by an earlier boot stage as some settings (including the mode) can only be modified while the controller is disabled. Fixes: 9ac8d17 ("spi: add support for microchip fpga spi controllers") Signed-off-by: Steve Wilkins <[email protected]> Signed-off-by: Conor Dooley <[email protected]> Link: https://patch.msgid.link/20240715-designing-thus-05f7c26e1da7@wendy Signed-off-by: Mark Brown <[email protected]>
1 parent de9850b commit 3a5e762

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

drivers/spi/spi-microchip-core.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -295,17 +295,13 @@ static void mchp_corespi_init(struct spi_controller *host, struct mchp_corespi *
295295
unsigned long clk_hz;
296296
u32 control = mchp_corespi_read(spi, REG_CONTROL);
297297

298-
control |= CONTROL_MASTER;
298+
control &= ~CONTROL_ENABLE;
299+
mchp_corespi_write(spi, REG_CONTROL, control);
299300

301+
control |= CONTROL_MASTER;
300302
control &= ~CONTROL_MODE_MASK;
301303
control |= MOTOROLA_MODE;
302304

303-
mchp_corespi_set_framesize(spi, DEFAULT_FRAMESIZE);
304-
305-
/* max. possible spi clock rate is the apb clock rate */
306-
clk_hz = clk_get_rate(spi->clk);
307-
host->max_speed_hz = clk_hz;
308-
309305
/*
310306
* The controller must be configured so that it doesn't remove Chip
311307
* Select until the entire message has been transferred, even if at
@@ -314,11 +310,16 @@ static void mchp_corespi_init(struct spi_controller *host, struct mchp_corespi *
314310
* BIGFIFO mode is also enabled, which sets the fifo depth to 32 frames
315311
* for the 8 bit transfers that this driver uses.
316312
*/
317-
control = mchp_corespi_read(spi, REG_CONTROL);
318313
control |= CONTROL_SPS | CONTROL_BIGFIFO;
319314

320315
mchp_corespi_write(spi, REG_CONTROL, control);
321316

317+
mchp_corespi_set_framesize(spi, DEFAULT_FRAMESIZE);
318+
319+
/* max. possible spi clock rate is the apb clock rate */
320+
clk_hz = clk_get_rate(spi->clk);
321+
host->max_speed_hz = clk_hz;
322+
322323
mchp_corespi_enable_ints(spi);
323324

324325
/*

0 commit comments

Comments
 (0)