Skip to content

Commit 65850e5

Browse files
swilkins-raymarinegregkh
authored andcommitted
spi: microchip-core: fix init function not setting the master and motorola modes
[ Upstream commit 3a5e762 ] 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 <steve.wilkins@raymarine.com> Signed-off-by: Conor Dooley <conor.dooley@microchip.com> Link: https://patch.msgid.link/20240715-designing-thus-05f7c26e1da7@wendy Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 263b6c2 commit 65850e5

1 file changed

Lines changed: 9 additions & 8 deletions

File tree

drivers/spi/spi-microchip-core.c

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

295-
control |= CONTROL_MASTER;
295+
control &= ~CONTROL_ENABLE;
296+
mchp_corespi_write(spi, REG_CONTROL, control);
296297

298+
control |= CONTROL_MASTER;
297299
control &= ~CONTROL_MODE_MASK;
298300
control |= MOTOROLA_MODE;
299301

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

317312
mchp_corespi_write(spi, REG_CONTROL, control);
318313

314+
mchp_corespi_set_framesize(spi, DEFAULT_FRAMESIZE);
315+
316+
/* max. possible spi clock rate is the apb clock rate */
317+
clk_hz = clk_get_rate(spi->clk);
318+
host->max_speed_hz = clk_hz;
319+
319320
mchp_corespi_enable_ints(spi);
320321

321322
/*

0 commit comments

Comments
 (0)