Skip to content

Commit 287fcda

Browse files
stephan-ghbroonie
authored andcommitted
spi: qup: Parse OPP table for DVFS support
Parse the OPP table from the device tree and use dev_pm_opp_set_rate() instead of clk_set_rate() to allow making performance state for power domains specified in the OPP table. This is needed to guarantee correct behavior of the clock, especially with the higher clock/SPI bus frequencies. Acked-by: Konrad Dybcio <[email protected]> Signed-off-by: Stephan Gerhold <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent e6419c3 commit 287fcda

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

drivers/spi/spi-qup.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/module.h>
1313
#include <linux/of.h>
1414
#include <linux/platform_device.h>
15+
#include <linux/pm_opp.h>
1516
#include <linux/pm_runtime.h>
1617
#include <linux/spi/spi.h>
1718
#include <linux/dmaengine.h>
@@ -667,7 +668,7 @@ static int spi_qup_io_prep(struct spi_device *spi, struct spi_transfer *xfer)
667668
return -EIO;
668669
}
669670

670-
ret = clk_set_rate(controller->cclk, xfer->speed_hz);
671+
ret = dev_pm_opp_set_rate(controller->dev, xfer->speed_hz);
671672
if (ret) {
672673
dev_err(controller->dev, "fail to set frequency %d",
673674
xfer->speed_hz);
@@ -1027,6 +1028,15 @@ static int spi_qup_probe(struct platform_device *pdev)
10271028
return -ENXIO;
10281029
}
10291030

1031+
ret = devm_pm_opp_set_clkname(dev, "core");
1032+
if (ret)
1033+
return ret;
1034+
1035+
/* OPP table is optional */
1036+
ret = devm_pm_opp_of_add_table(dev);
1037+
if (ret && ret != -ENODEV)
1038+
return dev_err_probe(dev, ret, "invalid OPP table\n");
1039+
10301040
host = spi_alloc_host(dev, sizeof(struct spi_qup));
10311041
if (!host) {
10321042
dev_err(dev, "cannot allocate host\n");

0 commit comments

Comments
 (0)