]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
spi: nxp-fspi: Support per spi-mem operation frequency switches
authorMiquel Raynal <miquel.raynal@bootlin.com>
Tue, 24 Dec 2024 17:05:57 +0000 (18:05 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 6 Dec 2025 21:24:57 +0000 (06:24 +0900)
[ Upstream commit 26851cf65ffca2d3a8d529a125e54cf0084d69e7 ]

Every ->exec_op() call correctly configures the spi bus speed to the
maximum allowed frequency for the memory using the constant spi default
parameter. Since we can now have per-operation constraints, let's use
the value that comes from the spi-mem operation structure instead. In
case there is no specific limitation for this operation, the default spi
device value will be given anyway.

The per-operation frequency capability is thus advertised to the spi-mem
core.

Cc: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://patch.msgid.link/20241224-winbond-6-11-rc1-quad-support-v2-12-ad218dbc406f@bootlin.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Stable-dep-of: 40ad64ac25bb ("spi: nxp-fspi: Propagate fwnode in ACPI case as well")
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/spi/spi-nxp-fspi.c

index b569302f22e61f88ee175d091db445d8ea89557b..78afef8851fc9b30ff4d7c1d69a8d5f97a7b9cec 100644 (file)
@@ -711,9 +711,10 @@ static void nxp_fspi_dll_calibration(struct nxp_fspi *f)
  * Value for rest of the CS FLSHxxCR0 register would be zero.
  *
  */
-static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi)
+static void nxp_fspi_select_mem(struct nxp_fspi *f, struct spi_device *spi,
+                               const struct spi_mem_op *op)
 {
-       unsigned long rate = spi->max_speed_hz;
+       unsigned long rate = op->max_freq;
        int ret;
        uint64_t size_kb;
 
@@ -937,7 +938,7 @@ static int nxp_fspi_exec_op(struct spi_mem *mem, const struct spi_mem_op *op)
                                   FSPI_STS0_ARB_IDLE, 1, POLL_TOUT, true);
        WARN_ON(err);
 
-       nxp_fspi_select_mem(f, mem->spi);
+       nxp_fspi_select_mem(f, mem->spi, op);
 
        nxp_fspi_prepare_lut(f, op);
        /*
@@ -1155,6 +1156,10 @@ static const struct spi_controller_mem_ops nxp_fspi_mem_ops = {
        .get_name = nxp_fspi_get_name,
 };
 
+static const struct spi_controller_mem_caps nxp_fspi_mem_caps = {
+       .per_op_freq = true,
+};
+
 static int nxp_fspi_probe(struct platform_device *pdev)
 {
        struct spi_controller *ctlr;
@@ -1252,6 +1257,7 @@ static int nxp_fspi_probe(struct platform_device *pdev)
        ctlr->bus_num = -1;
        ctlr->num_chipselect = NXP_FSPI_MAX_CHIPSELECT;
        ctlr->mem_ops = &nxp_fspi_mem_ops;
+       ctlr->mem_caps = &nxp_fspi_mem_caps;
 
        nxp_fspi_default_setup(f);