Skip to content

Commit d0e5fac

Browse files
miquelraynalbroonie
authored andcommitted
spi: amd: Support per spi-mem operation frequency switches
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. This controller however performed a frequency check, which is also observed during the ->check_op() phase. The per-operation frequency capability is thus advertised to the spi-mem core. Cc: Sanjay R Mehta <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://patch.msgid.link/20241224-winbond-6-11-rc1-quad-support-v2-3-ad218dbc406f@bootlin.com Signed-off-by: Mark Brown <[email protected]>
1 parent 1248c9b commit d0e5fac

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/spi/spi-amd.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,9 @@ static bool amd_spi_supports_op(struct spi_mem *mem,
479479
return false;
480480
}
481481

482+
if (op->max_freq < mem->spi->controller->min_speed_hz)
483+
return false;
484+
482485
return spi_mem_default_supports_op(mem, op);
483486
}
484487

@@ -676,7 +679,7 @@ static int amd_spi_exec_mem_op(struct spi_mem *mem,
676679

677680
amd_spi = spi_controller_get_devdata(mem->spi->controller);
678681

679-
ret = amd_set_spi_freq(amd_spi, mem->spi->max_speed_hz);
682+
ret = amd_set_spi_freq(amd_spi, op->max_freq);
680683
if (ret)
681684
return ret;
682685

@@ -705,6 +708,10 @@ static const struct spi_controller_mem_ops amd_spi_mem_ops = {
705708
.supports_op = amd_spi_supports_op,
706709
};
707710

711+
static const struct spi_controller_mem_caps amd_spi_mem_caps = {
712+
.per_op_freq = true,
713+
};
714+
708715
static int amd_spi_host_transfer(struct spi_controller *host,
709716
struct spi_message *msg)
710717
{
@@ -782,6 +789,7 @@ static int amd_spi_probe(struct platform_device *pdev)
782789
host->setup = amd_spi_host_setup;
783790
host->transfer_one_message = amd_spi_host_transfer;
784791
host->mem_ops = &amd_spi_mem_ops;
792+
host->mem_caps = &amd_spi_mem_caps;
785793
host->max_transfer_size = amd_spi_max_transfer_size;
786794
host->max_message_size = amd_spi_max_transfer_size;
787795

0 commit comments

Comments
 (0)