Skip to content

Commit d3f35dd

Browse files
miquelraynalbroonie
authored andcommitted
spi: rockchip-sfc: 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. The per-operation frequency capability is thus advertised to the spi-mem core. Cc: Han Xu <[email protected]> Cc: Haibo Chen <[email protected]> Cc: Yogesh Gaur <[email protected]> Signed-off-by: Miquel Raynal <[email protected]> Link: https://patch.msgid.link/20241224-winbond-6-11-rc1-quad-support-v2-13-ad218dbc406f@bootlin.com Signed-off-by: Mark Brown <[email protected]>
1 parent 26851cf commit d3f35dd

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

drivers/spi/spi-rockchip-sfc.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,11 +492,11 @@ static int rockchip_sfc_exec_mem_op(struct spi_mem *mem, const struct spi_mem_op
492492
u32 len = op->data.nbytes;
493493
int ret;
494494

495-
if (unlikely(mem->spi->max_speed_hz != sfc->frequency)) {
496-
ret = clk_set_rate(sfc->clk, mem->spi->max_speed_hz);
495+
if (unlikely(op->max_freq != sfc->frequency)) {
496+
ret = clk_set_rate(sfc->clk, op->max_freq);
497497
if (ret)
498498
return ret;
499-
sfc->frequency = mem->spi->max_speed_hz;
499+
sfc->frequency = op->max_freq;
500500
dev_dbg(sfc->dev, "set_freq=%dHz real_freq=%ldHz\n",
501501
sfc->frequency, clk_get_rate(sfc->clk));
502502
}
@@ -536,6 +536,10 @@ static const struct spi_controller_mem_ops rockchip_sfc_mem_ops = {
536536
.adjust_op_size = rockchip_sfc_adjust_op_size,
537537
};
538538

539+
static const struct spi_controller_mem_caps rockchip_sfc_mem_caps = {
540+
.per_op_freq = true,
541+
};
542+
539543
static irqreturn_t rockchip_sfc_irq_handler(int irq, void *dev_id)
540544
{
541545
struct rockchip_sfc *sfc = dev_id;
@@ -568,6 +572,7 @@ static int rockchip_sfc_probe(struct platform_device *pdev)
568572

569573
host->flags = SPI_CONTROLLER_HALF_DUPLEX;
570574
host->mem_ops = &rockchip_sfc_mem_ops;
575+
host->mem_caps = &rockchip_sfc_mem_caps;
571576
host->dev.of_node = pdev->dev.of_node;
572577
host->mode_bits = SPI_TX_QUAD | SPI_TX_DUAL | SPI_RX_QUAD | SPI_RX_DUAL;
573578
host->max_speed_hz = SFC_MAX_SPEED;

0 commit comments

Comments
 (0)