QSPI: Add DVFS support
Subsystems (5)
cover QSPI: Add DVFS support
Hi Bjorn,
This patchset adds support for QSPI DVFS, and adds device tree changes for sdm845 and sc7180 SoC's.
Though this patchset has no other dependency, it would result in a merge conflict with changes already in qcom for-next, if pulled into another tree for 5.9.
Hence requesting you to take these changes via the qcom tree for 5.9. The qspi driver changes are already ACK'ed by Mark.
thanks,
Rajendra
Rajendra Nayak (3):
spi: spi-qcom-qspi: Use OPP API to set clk/perf state
arm64: dts: sdm845: Add qspi opps and power-domains
arm64: dts: sc7180: Add qspi opps and power-domains
arch/arm64/boot/dts/qcom/sc7180.dtsi | 21 +++++++++++++++++++++ arch/arm64/boot/dts/qcom/sdm845.dtsi | 26 ++++++++++++++++++++++++++ drivers/spi/spi-qcom-qspi.c | 28 +++++++++++++++++++++++++++- 3 files changed, 74 insertions(+), 1 deletion(-)
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH 1/3 spi: spi-qcom-qspi: Use OPP API to set clk/perf state
QSPI needs to vote on a performance state of a power domain depending on the clock rate. Add support for it by specifying the perf state/clock rate as an OPP table in device tree.
--- drivers/spi/spi-qcom-qspi.c | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-)
drivers/spi/spi-qcom-qspi.c +27 -1
@@ -9,6 +9,7 @@#include <linux/of.h> #include <linux/of_platform.h> #include <linux/pm_runtime.h> +#include <linux/pm_opp.h> #include <linux/spi/spi.h> #include <linux/spi/spi-mem.h>
@@ -141,6 +142,8 @@ struct qcom_qspi {struct clk_bulk_data *clks;struct qspi_xfer xfer;struct icc_path *icc_path_cpu_to_qspi; +struct opp_table *opp_table; +bool has_opp_table;/* Lock to protect data accessed by IRQs */ spinlock_t lock; };
@@ -238,7 +241,7 @@ static int qcom_qspi_transfer_one(struct spi_master *master, speed_hz = xfer->speed_hz;/* In regular operation (SBL_EN=1) core must be 4x transfer clock */ - ret =clk_set_rate (ctrl->clks[QSPI_CLK_CORE ].clk, speed_hz *4 ); + ret =dev_pm_opp_set_rate (ctrl->dev, speed_hz *4 );if (ret) {dev_err (ctrl->dev,"Failed to set core clk %d\n" , ret);return ret;
@@ -519,6 +522,20 @@ static int qcom_qspi_probe(struct platform_device *pdev) master->handle_err = qcom_qspi_handle_err; master->auto_runtime_pm = true; + ctrl->opp_table =dev_pm_opp_set_clkname (&pdev->dev,"core" ); +if (IS_ERR (ctrl->opp_table)) { + ret =PTR_ERR (ctrl->opp_table); + goto exit_probe_master_put; + } +/* OPP table is optional */ + ret =dev_pm_opp_of_add_table (&pdev->dev); +if (!ret) { + ctrl->has_opp_table = true; + }else if (ret != -ENODEV ) { +dev_err (&pdev->dev,"invalid OPP table in device tree\n" ); + goto exit_probe_master_put; + } +pm_runtime_enable (dev); ret =spi_register_master (master);
@@ -526,6 +543,9 @@ static int qcom_qspi_probe(struct platform_device *pdev)return 0 ;pm_runtime_disable (dev); +if (ctrl->has_opp_table) +dev_pm_opp_of_remove_table (&pdev->dev); +dev_pm_opp_put_clkname (ctrl->opp_table); exit_probe_master_put:spi_master_put (master);
@@ -536,11 +556,15 @@ static int qcom_qspi_probe(struct platform_device *pdev)static int qcom_qspi_remove (struct platform_device *pdev) {struct spi_master *master =platform_get_drvdata (pdev); +struct qcom_qspi *ctrl =spi_master_get_devdata (master);/* Unregister _before_ disabling pm_runtime() so we stop transfers */ spi_unregister_master (master);pm_runtime_disable (&pdev->dev); +if (ctrl->has_opp_table) +dev_pm_opp_of_remove_table (&pdev->dev); +dev_pm_opp_put_clkname (ctrl->opp_table);return 0 ; }
@@ -551,6 +575,8 @@ static int __maybe_unused qcom_qspi_runtime_suspend(struct device *dev)struct qcom_qspi *ctrl =spi_master_get_devdata (master);int ret; +/* Drop the performance state vote */ +dev_pm_opp_set_rate (dev,0 );clk_bulk_disable_unprepare (QSPI_NUM_CLKS , ctrl->clks); ret =icc_disable (ctrl->icc_path_cpu_to_qspi);
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Mark Brown
maintainerRe: [PATCH 1/3] spi: spi-qcom-qspi: Use OPP API to set clk/perf state
Quoted 3 lines · Rajendra Nayak
QSPI needs to vote on a performance state of a power domain depending on the clock rate. Add support for it by specifying the perf state/clock rate as an OPP table in device tree.
This doesn't apply against current code, please check and resend.
Re: [PATCH 1/3] spi: spi-qcom-qspi: Use OPP API to set clk/perf state
Quoted 6 lines · Mark Brown
Quoted 3 lines · Rajendra Nayak
QSPI needs to vote on a performance state of a power domain depending on the clock rate. Add support for it by specifying the perf state/clock rate as an OPP table in device tree.
This doesn't apply against current code, please check and resend.
Hey Mark, as mentioned in the cover letter I wanted this to land via the qcom tree, since Bjorn already has a patch in his tree which would otherwise conflict with this change, if you were to pull this.
Hence I had this rebased on qcom for-next and requested Bjorn to pull it in, with your ACK. Hope thats fine with you.
thanks,
Rajendra
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH 2/3 arm64: dts: sdm845: Add qspi opps and power-domains
In reply to Rajendra NayakAdd the power domain supporting performance state and the corresponding OPP tables for the qspi device on sdm845
--- arch/arm64/boot/dts/qcom/sdm845.dtsi | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
arch/arm64/boot/dts/qcom/sdm845.dtsi +26 -0
@@ -2915,6 +2915,30 @@ status = "disabled"; }; + qspi_opp_table: qspi-opp-table { + compatible = "operating-points-v2"; + + opp-19200000 { + opp-hz = /bits/ 64 <19200000>; + required-opps = <&rpmhpd_opp_min_svs>; + }; + + opp-100000000 { + opp-hz = /bits/ 64 <100000000>; + required-opps = <&rpmhpd_opp_low_svs>; + }; + + opp-150000000 { + opp-hz = /bits/ 64 <150000000>; + required-opps = <&rpmhpd_opp_svs>; + }; + + opp-300000000 { + opp-hz = /bits/ 64 <300000000>; + required-opps = <&rpmhpd_opp_nom>; + }; + }; + qspi: spi@88df000 { compatible = "qcom,sdm845-qspi", "qcom,qspi-v1"; reg = <0 0x088df000 0 0x600>;
@@ -2924,6 +2948,8 @@ clocks = <&gcc GCC_QSPI_CNOC_PERIPH_AHB_CLK>, <&gcc GCC_QSPI_CORE_CLK>; clock-names = "iface", "core"; + power-domains = <&rpmhpd SDM845_CX>; + operating-points-v2 = <&qspi_opp_table>; status = "disabled"; };
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Re: [PATCH 2/3] arm64: dts: sdm845: Add qspi opps and power-domains
Quoted 4 lines · Rajendra Nayak
Add the power domain supporting performance state and the corresponding OPP tables for the qspi device on sdm845
Signed-off-by Rajendra Nayak <[email protected]>
PATCH 3/3 arm64: dts: sc7180: Add qspi opps and power-domains
In reply to Rajendra NayakAdd the power domain supporting performance state and the corresponding OPP tables for the qspi device on sc7180
--- arch/arm64/boot/dts/qcom/sc7180.dtsi | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
arch/arm64/boot/dts/qcom/sc7180.dtsi +21 -0
@@ -2407,6 +2407,25 @@ status = "disabled"; }; + qspi_opp_table: qspi-opp-table { + compatible = "operating-points-v2"; + + opp-75000000 { + opp-hz = /bits/ 64 <75000000>; + required-opps = <&rpmhpd_opp_low_svs>; + }; + + opp-150000000 { + opp-hz = /bits/ 64 <150000000>; + required-opps = <&rpmhpd_opp_svs>; + }; + + opp-300000000 { + opp-hz = /bits/ 64 <300000000>; + required-opps = <&rpmhpd_opp_nom>; + }; + }; + qspi: spi@88dc000 { compatible = "qcom,qspi-v1"; reg = <0 0x088dc000 0 0x600>;
@@ -2419,6 +2438,8 @@ interconnects = <&gem_noc MASTER_APPSS_PROC &config_noc SLAVE_QSPI_0>; interconnect-names = "qspi-config"; + power-domains = <&rpmhpd SC7180_CX>; + operating-points-v2 = <&qspi_opp_table>; status = "disabled"; };
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Re: [PATCH 3/3] arm64: dts: sc7180: Add qspi opps and power-domains
Quoted 4 lines · Rajendra Nayak
Add the power domain supporting performance state and the corresponding OPP tables for the qspi device on sc7180
Signed-off-by Rajendra Nayak <[email protected]>