Skip to content

Commit f43579e

Browse files
Haibo Chenbroonie
authored andcommitted
spi: spi-nxp-fspi: limit the clock rate for different sample clock source selection
For different sample clock source selection, the max frequency flexspi supported are different. For mode 0, max frequency is 66MHz. For mode 3, the max frequency is 166MHz. Refer to 3.9.9 FlexSPI timing parameters on page 65. https://www.nxp.com/docs/en/data-sheet/IMX8MNCEC.pdf Though flexspi maybe still work under higher frequency, but can't guarantee the stability. IC suggest to add this limitation on all SoCs which contain flexspi. Fixes: c07f270 ("spi: spi-nxp-fspi: add the support for sample data from DQS pad") Signed-off-by: Haibo Chen <haibo.chen@nxp.com> Link: https://patch.msgid.link/20250922-fspi-fix-v1-3-ff4315359d31@nxp.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent b93b426 commit f43579e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

drivers/spi/spi-nxp-fspi.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,8 @@ struct nxp_fspi {
406406
int flags;
407407
/* save the previous operation clock rate */
408408
unsigned long pre_op_rate;
409+
/* the max clock rate fspi output to device */
410+
unsigned long max_rate;
409411
};
410412

411413
static inline int needs_ip_only(struct nxp_fspi *f)
@@ -687,10 +689,13 @@ static void nxp_fspi_select_rx_sample_clk_source(struct nxp_fspi *f,
687689
* change the mode back to mode 0.
688690
*/
689691
reg = fspi_readl(f, f->iobase + FSPI_MCR0);
690-
if (op_is_dtr)
692+
if (op_is_dtr) {
691693
reg |= FSPI_MCR0_RXCLKSRC(3);
692-
else /*select mode 0 */
694+
f->max_rate = 166000000;
695+
} else { /*select mode 0 */
693696
reg &= ~FSPI_MCR0_RXCLKSRC(3);
697+
f->max_rate = 66000000;
698+
}
694699
fspi_writel(f, reg, f->iobase + FSPI_MCR0);
695700
}
696701

@@ -816,6 +821,7 @@ static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi,
816821
dev_dbg(f->dev, "Target device [CS:%x] selected\n", spi_get_chipselect(spi, 0));
817822

818823
nxp_fspi_select_rx_sample_clk_source(f, op_is_dtr);
824+
rate = min(f->max_rate, op->max_freq);
819825

820826
if (op_is_dtr) {
821827
f->flags |= FSPI_DTR_MODE;

0 commit comments

Comments
 (0)