linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] QSPI: Add DVFS support
@ 2020-07-03  9:41 Rajendra Nayak
  2020-07-03  9:41 ` [PATCH 1/3] spi: spi-qcom-qspi: Use OPP API to set clk/perf state Rajendra Nayak
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Rajendra Nayak @ 2020-07-03  9:41 UTC (permalink / raw)
  To: bjorn.andersson, agross, broonie
  Cc: linux-arm-msm, linux-spi, linux-kernel, devicetree, mka, Rajendra Nayak

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(-)

-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] spi: spi-qcom-qspi: Use OPP API to set clk/perf state
  2020-07-03  9:41 [PATCH 0/3] QSPI: Add DVFS support Rajendra Nayak
@ 2020-07-03  9:41 ` Rajendra Nayak
  2020-07-03 17:01   ` Mark Brown
  2020-07-03  9:41 ` [PATCH 2/3] arm64: dts: sdm845: Add qspi opps and power-domains Rajendra Nayak
  2020-07-03  9:41 ` [PATCH 3/3] arm64: dts: sc7180: " Rajendra Nayak
  2 siblings, 1 reply; 8+ messages in thread
From: Rajendra Nayak @ 2020-07-03  9:41 UTC (permalink / raw)
  To: bjorn.andersson, agross, broonie
  Cc: linux-arm-msm, linux-spi, linux-kernel, devicetree, mka,
	Rajendra Nayak, Alok Chauhan, Akash Asthana

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.

Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Acked-by: Mark Brown <broonie@kernel.org>
Cc: Alok Chauhan <alokc@codeaurora.org>
Cc: Akash Asthana <akashast@codeaurora.org>
Cc: linux-spi@vger.kernel.org
---
 drivers/spi/spi-qcom-qspi.c | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-qcom-qspi.c b/drivers/spi/spi-qcom-qspi.c
index b5b4cf6..18a59aa 100644
--- a/drivers/spi/spi-qcom-qspi.c
+++ b/drivers/spi/spi-qcom-qspi.c
@@ -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);
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] arm64: dts: sdm845: Add qspi opps and power-domains
  2020-07-03  9:41 [PATCH 0/3] QSPI: Add DVFS support Rajendra Nayak
  2020-07-03  9:41 ` [PATCH 1/3] spi: spi-qcom-qspi: Use OPP API to set clk/perf state Rajendra Nayak
@ 2020-07-03  9:41 ` Rajendra Nayak
  2020-07-06 15:56   ` Matthias Kaehlcke
  2020-07-03  9:41 ` [PATCH 3/3] arm64: dts: sc7180: " Rajendra Nayak
  2 siblings, 1 reply; 8+ messages in thread
From: Rajendra Nayak @ 2020-07-03  9:41 UTC (permalink / raw)
  To: bjorn.andersson, agross, broonie
  Cc: linux-arm-msm, linux-spi, linux-kernel, devicetree, mka, 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 <rnayak@codeaurora.org>
---
 arch/arm64/boot/dts/qcom/sdm845.dtsi | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi
index 8eb5a31..5163090 100644
--- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
@@ -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";
 		};
 
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] arm64: dts: sc7180: Add qspi opps and power-domains
  2020-07-03  9:41 [PATCH 0/3] QSPI: Add DVFS support Rajendra Nayak
  2020-07-03  9:41 ` [PATCH 1/3] spi: spi-qcom-qspi: Use OPP API to set clk/perf state Rajendra Nayak
  2020-07-03  9:41 ` [PATCH 2/3] arm64: dts: sdm845: Add qspi opps and power-domains Rajendra Nayak
@ 2020-07-03  9:41 ` Rajendra Nayak
  2020-07-06 15:58   ` Matthias Kaehlcke
  2 siblings, 1 reply; 8+ messages in thread
From: Rajendra Nayak @ 2020-07-03  9:41 UTC (permalink / raw)
  To: bjorn.andersson, agross, broonie
  Cc: linux-arm-msm, linux-spi, linux-kernel, devicetree, mka, 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 <rnayak@codeaurora.org>
---
 arch/arm64/boot/dts/qcom/sc7180.dtsi | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sc7180.dtsi b/arch/arm64/boot/dts/qcom/sc7180.dtsi
index 2be81a2..34a6d83 100644
--- a/arch/arm64/boot/dts/qcom/sc7180.dtsi
+++ b/arch/arm64/boot/dts/qcom/sc7180.dtsi
@@ -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";
 		};
 
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] spi: spi-qcom-qspi: Use OPP API to set clk/perf state
  2020-07-03  9:41 ` [PATCH 1/3] spi: spi-qcom-qspi: Use OPP API to set clk/perf state Rajendra Nayak
@ 2020-07-03 17:01   ` Mark Brown
  2020-07-07  4:27     ` Rajendra Nayak
  0 siblings, 1 reply; 8+ messages in thread
From: Mark Brown @ 2020-07-03 17:01 UTC (permalink / raw)
  To: Rajendra Nayak
  Cc: bjorn.andersson, agross, linux-arm-msm, linux-spi, linux-kernel,
	devicetree, mka, Alok Chauhan, Akash Asthana

[-- Attachment #1: Type: text/plain, Size: 317 bytes --]

On Fri, Jul 03, 2020 at 03:11:31PM +0530, Rajendra Nayak wrote:
> 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.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] arm64: dts: sdm845: Add qspi opps and power-domains
  2020-07-03  9:41 ` [PATCH 2/3] arm64: dts: sdm845: Add qspi opps and power-domains Rajendra Nayak
@ 2020-07-06 15:56   ` Matthias Kaehlcke
  0 siblings, 0 replies; 8+ messages in thread
From: Matthias Kaehlcke @ 2020-07-06 15:56 UTC (permalink / raw)
  To: Rajendra Nayak
  Cc: bjorn.andersson, agross, broonie, linux-arm-msm, linux-spi,
	linux-kernel, devicetree

On Fri, Jul 03, 2020 at 03:11:32PM +0530, Rajendra Nayak wrote:
> Add the power domain supporting performance state and the corresponding
> OPP tables for the qspi device on sdm845
> 
> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>

Reviewed-by: Matthias Kaehlcke <mka@chromium.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] arm64: dts: sc7180: Add qspi opps and power-domains
  2020-07-03  9:41 ` [PATCH 3/3] arm64: dts: sc7180: " Rajendra Nayak
@ 2020-07-06 15:58   ` Matthias Kaehlcke
  0 siblings, 0 replies; 8+ messages in thread
From: Matthias Kaehlcke @ 2020-07-06 15:58 UTC (permalink / raw)
  To: Rajendra Nayak
  Cc: bjorn.andersson, agross, broonie, linux-arm-msm, linux-spi,
	linux-kernel, devicetree

On Fri, Jul 03, 2020 at 03:11:33PM +0530, Rajendra Nayak wrote:
> Add the power domain supporting performance state and the corresponding
> OPP tables for the qspi device on sc7180
> 
> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>

Reviewed-by: Matthias Kaehlcke <mka@chromium.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] spi: spi-qcom-qspi: Use OPP API to set clk/perf state
  2020-07-03 17:01   ` Mark Brown
@ 2020-07-07  4:27     ` Rajendra Nayak
  0 siblings, 0 replies; 8+ messages in thread
From: Rajendra Nayak @ 2020-07-07  4:27 UTC (permalink / raw)
  To: Mark Brown
  Cc: bjorn.andersson, agross, linux-arm-msm, linux-spi, linux-kernel,
	devicetree, mka, Alok Chauhan, Akash Asthana


On 7/3/2020 10:31 PM, Mark Brown wrote:
> On Fri, Jul 03, 2020 at 03:11:31PM +0530, Rajendra Nayak wrote:
>> 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

-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-07-07  4:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-03  9:41 [PATCH 0/3] QSPI: Add DVFS support Rajendra Nayak
2020-07-03  9:41 ` [PATCH 1/3] spi: spi-qcom-qspi: Use OPP API to set clk/perf state Rajendra Nayak
2020-07-03 17:01   ` Mark Brown
2020-07-07  4:27     ` Rajendra Nayak
2020-07-03  9:41 ` [PATCH 2/3] arm64: dts: sdm845: Add qspi opps and power-domains Rajendra Nayak
2020-07-06 15:56   ` Matthias Kaehlcke
2020-07-03  9:41 ` [PATCH 3/3] arm64: dts: sc7180: " Rajendra Nayak
2020-07-06 15:58   ` Matthias Kaehlcke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).