Skip to content

Commit a89103f

Browse files
Haibo Chenbroonie
authored andcommitted
spi: spi-nxp-fspi: re-config the clock rate when operation require new clock rate
Current operation contain the max_freq, so new coming operation may use new clock rate, need to re-config the clock rate to match the requirement. Fixes: 26851cf ("spi: nxp-fspi: Support per spi-mem operation frequency switches") Signed-off-by: Haibo Chen <haibo.chen@nxp.com> Link: https://patch.msgid.link/20250922-fspi-fix-v1-1-ff4315359d31@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 4f38da1 commit a89103f

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

drivers/spi/spi-nxp-fspi.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,8 @@ struct nxp_fspi {
404404
#define FSPI_NEED_INIT BIT(0)
405405
#define FSPI_DTR_MODE BIT(1)
406406
int flags;
407+
/* save the previous operation clock rate */
408+
unsigned long pre_op_rate;
407409
};
408410

409411
static inline int needs_ip_only(struct nxp_fspi *f)
@@ -780,11 +782,17 @@ static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi,
780782
uint64_t size_kb;
781783

782784
/*
783-
* Return, if previously selected target device is same as current
784-
* requested target device. Also the DTR or STR mode do not change.
785+
* Return when following condition all meet,
786+
* 1, if previously selected target device is same as current
787+
* requested target device.
788+
* 2, the DTR or STR mode do not change.
789+
* 3, previous operation max rate equals current one.
790+
*
791+
* For other case, need to re-config.
785792
*/
786793
if ((f->selected == spi_get_chipselect(spi, 0)) &&
787-
(!!(f->flags & FSPI_DTR_MODE) == op_is_dtr))
794+
(!!(f->flags & FSPI_DTR_MODE) == op_is_dtr) &&
795+
(f->pre_op_rate == op->max_freq))
788796
return;
789797

790798
/* Reset FLSHxxCR0 registers */
@@ -832,6 +840,8 @@ static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi,
832840
else
833841
nxp_fspi_dll_override(f);
834842

843+
f->pre_op_rate = op->max_freq;
844+
835845
f->selected = spi_get_chipselect(spi, 0);
836846
}
837847

0 commit comments

Comments
 (0)