Skip to content

Commit 329ca3e

Browse files
LeSpockybroonie
authored andcommitted
spi: atmel-quadspi: Avoid overwriting delay register settings
Previously the MR and SCR registers were just set with the supposedly required values, from cached register values (cached reg content initialized to zero). All parts fixed here did not consider the current register (cache) content, which would make future support of cs_setup, cs_hold, and cs_inactive impossible. Setting SCBR in atmel_qspi_setup() erases a possible DLYBS setting from atmel_qspi_set_cs_timing(). The DLYBS setting is applied by ORing over the current setting, without resetting the bits first. All writes to MR did not consider possible settings of DLYCS and DLYBCT. Signed-off-by: Alexander Dahl <ada@thorsis.com> Fixes: f732646 ("spi: atmel-quadspi: Add support for configuring CS timing") Link: https://patch.msgid.link/20240918082744.379610-2-ada@thorsis.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent fffca26 commit 329ca3e

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

drivers/spi/atmel-quadspi.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,9 @@ static int atmel_qspi_set_cfg(struct atmel_qspi *aq,
375375
* If the QSPI controller is set in regular SPI mode, set it in
376376
* Serial Memory Mode (SMM).
377377
*/
378-
if (aq->mr != QSPI_MR_SMM) {
379-
atmel_qspi_write(QSPI_MR_SMM, aq, QSPI_MR);
380-
aq->mr = QSPI_MR_SMM;
378+
if (!(aq->mr & QSPI_MR_SMM)) {
379+
aq->mr |= QSPI_MR_SMM;
380+
atmel_qspi_write(aq->scr, aq, QSPI_MR);
381381
}
382382

383383
/* Clear pending interrupts */
@@ -501,7 +501,8 @@ static int atmel_qspi_setup(struct spi_device *spi)
501501
if (ret < 0)
502502
return ret;
503503

504-
aq->scr = QSPI_SCR_SCBR(scbr);
504+
aq->scr &= ~QSPI_SCR_SCBR_MASK;
505+
aq->scr |= QSPI_SCR_SCBR(scbr);
505506
atmel_qspi_write(aq->scr, aq, QSPI_SCR);
506507

507508
pm_runtime_mark_last_busy(ctrl->dev.parent);
@@ -534,6 +535,7 @@ static int atmel_qspi_set_cs_timing(struct spi_device *spi)
534535
if (ret < 0)
535536
return ret;
536537

538+
aq->scr &= ~QSPI_SCR_DLYBS_MASK;
537539
aq->scr |= QSPI_SCR_DLYBS(cs_setup);
538540
atmel_qspi_write(aq->scr, aq, QSPI_SCR);
539541

@@ -549,8 +551,8 @@ static void atmel_qspi_init(struct atmel_qspi *aq)
549551
atmel_qspi_write(QSPI_CR_SWRST, aq, QSPI_CR);
550552

551553
/* Set the QSPI controller by default in Serial Memory Mode */
552-
atmel_qspi_write(QSPI_MR_SMM, aq, QSPI_MR);
553-
aq->mr = QSPI_MR_SMM;
554+
aq->mr |= QSPI_MR_SMM;
555+
atmel_qspi_write(aq->mr, aq, QSPI_MR);
554556

555557
/* Enable the QSPI controller */
556558
atmel_qspi_write(QSPI_CR_QSPIEN, aq, QSPI_CR);

0 commit comments

Comments
 (0)