[PATCH 5/7] spi: qcom-geni: Use geni_se_set_rate() for setting source clock frequency
Praveen Talari <[email protected]> Wed, 05 Aug 2026 01:27:43 +0530
| Newsgroups | gmane.linux.ports.arm.msm,gmane.linux.ports.arm.kernel,gmane.linux.power-management.general,gmane.linux.kernel,gmane.linux.serial,gmane.linux.kernel.spi.devel,gmane.linux.drivers.i2c |
|---|---|
| Message-ID | <20260805-derive_clk_perf_tbl_from_perf_domain_opp_table-v1-5-61171ab1cdce@oss.qualcomm.com> |
On the SA8255P platform there is no Linux clock handler for the SE source clock, so the driver has no way to look up the source clock index and divider needed to fill the GSI CONFIG0 TRE for a requested transfer frequency. To work around this, firmware instead exposes the SE HW supported source clock frequencies as OPPs on the perf domain device. geni_se_domain_attach() now populates se->clk_perf_tbl from this OPP table at attach time, mirroring clk_perf_tbl on the Linux-clock-managed path. This lets get_spi_clk_cfg() call geni_se_clk_freq_match() to pick the closest supported source clock frequency and divider on SA8255P exactly as it already does when a Linux clock is present, and fill in the GSI CONFIG0 TRE accordingly. Switch get_spi_clk_cfg() and spi_geni_runtime_resume() from calling dev_pm_opp_set_rate() directly to the new geni_se_set_rate() helper, so the matched frequency is applied to the correct device (the perf domain device on the firmware managed path, or se->dev otherwise) without the SPI driver needing to know which resources_init variant is in use. Signed-off-by: Praveen Talari <[email protected]> --- drivers/spi/spi-geni-qcom.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c index 6566975eb24f..09e796d22ab1 100644 --- a/drivers/spi/spi-geni-qcom.c +++ b/drivers/spi/spi-geni-qcom.c @@ -15,7 +15,6 @@ #include <linux/log2.h> #include <linux/module.h> #include <linux/platform_device.h> -#include <linux/pm_opp.h> #include <linux/pm_runtime.h> #include <linux/property.h> #include <linux/soc/qcom/geni-se.h> @@ -82,7 +81,6 @@ struct geni_spi_desc { int (*resources_init)(struct geni_se *se); - int (*set_rate)(struct geni_se *se, unsigned long clk_freq); int (*power_on)(struct geni_se *se); int (*power_off)(struct geni_se *se); }; @@ -150,9 +148,9 @@ static int get_spi_clk_cfg(unsigned int speed_hz, dev_dbg(mas->dev, "req %u=>%u sclk %lu, idx %d, div %d\n", speed_hz, actual_hz, sclk_freq, *clk_idx, *clk_div); - ret = dev_pm_opp_set_rate(mas->dev, sclk_freq); + ret = geni_se_set_rate(&mas->se, sclk_freq); if (ret) - dev_err(mas->dev, "dev_pm_opp_set_rate failed %d\n", ret); + dev_err(mas->dev, "geni_se_set_rate failed %d\n", ret); else mas->cur_sclk_hz = sclk_freq; @@ -847,7 +845,7 @@ static int setup_se_xfer(struct spi_transfer *xfer, } /* Speed and bits per word can be overridden per transfer */ - ret = mas->dev_data->set_rate(&mas->se, xfer->speed_hz); + ret = geni_spi_set_clock_and_bw(&mas->se, xfer->speed_hz); if (ret) return ret; @@ -1162,6 +1160,8 @@ static int __maybe_unused spi_geni_runtime_suspend(struct device *dev) struct spi_controller *spi = dev_get_drvdata(dev); struct spi_geni_master *mas = spi_controller_get_devdata(spi); + geni_se_set_rate(&mas->se, 0); + return mas->dev_data->power_off ? mas->dev_data->power_off(&mas->se) : 0; } @@ -1178,10 +1178,7 @@ static int __maybe_unused spi_geni_runtime_resume(struct device *dev) return ret; } - if (mas->se.has_opp) - return dev_pm_opp_set_rate(mas->dev, mas->cur_sclk_hz); - - return 0; + return geni_se_set_rate(&mas->se, mas->cur_sclk_hz); } static int __maybe_unused spi_geni_suspend(struct device *dev) @@ -1224,14 +1221,12 @@ static const struct dev_pm_ops spi_geni_pm_ops = { static const struct geni_spi_desc geni_spi = { .resources_init = geni_se_resources_init, - .set_rate = geni_spi_set_clock_and_bw, .power_on = geni_se_resources_activate, .power_off = geni_se_resources_deactivate, }; static const struct geni_spi_desc sa8255p_geni_spi = { .resources_init = geni_se_domain_attach, - .set_rate = geni_se_set_perf_opp, }; static const struct of_device_id spi_geni_dt_match[] = { -- 2.34.1