LKML Archive on lore.kernel.org
 help / Atom feed
* [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845
@ 2019-01-10  4:02 Rajendra Nayak
  2019-01-10  4:02 ` [PATCH v11 1/9] dt-bindings: opp: Introduce opp-level bindings Rajendra Nayak
                   ` (10 more replies)
  0 siblings, 11 replies; 26+ messages in thread
From: Rajendra Nayak @ 2019-01-10  4:02 UTC (permalink / raw)
  To: andy.gross, robh, viresh.kumar, sboyd, ulf.hansson, collinsd, mka
  Cc: devicetree, linux-arm-msm, linux-kernel, henryc.chen, Rajendra Nayak

Changes in v11:
* Updated opp-level binding description based on feedback
from Viresh
* Other minor fixups in 'PATCH 2/9'

Changes in v10:
* Updated level bindings to include opp-level as an
optional property using operating-points-v2, no new
compatible for the OPP table
* Updated the dev_pm_opp_get_level() helper as per
suggestions from Viresh

Changes in v9:
* Updated qcom-opp bindings to be generic and usable across other SoCs 
with similar needs (Like MediaTek)
* Removed the simple_opp_to_performance_state() helper and added a
dev_pm_opp_of_get_level() helper instead
* Rebased on 5.0-rc1

Changes in v8:
* Patch 01/10: Bindings updated to mention opp-hz is optional
* Patch 02/10: Fixed #power-domain-cells
* All dependencies for 'Patch 10/10' are on their way to 4.21 via the pm tree

Changes in v7:
* Rebased on Andy's for-next, and used the updated cmd_db_read_aux_data()
* Other minor fixes, all in 'PATCH 06/10' as suggested by Stephen

Changes in v6:
* OPP binding updates for qcom,level reviewed by Rob
* DT bindings for rpmpd and rpmhpd updated to specify the
OPP tables as child nodes of the power-controller itself
* Removed some module specific remains from the drivers,
now that they can only be built-in
* Added a simple_opp_to_performance_state() helper

Changes in v5:
* First 6 patches are unchanged
* Patch 7/8 adds the DT node for rpmh power-controller on sdm845 and the
corresponding OPP tables for it to describe the performance states
* Patch 8/8 adds a parent/child relationship across mx/cx and mx_ao/cx_ao
as needed on sdm845 platform. This patch is dependent on the series from
Viresh [1] which adds support to propogate performance states across the
power domain hierarchy which is still being reviewed

Changes in v4:
* Included the patch to add qcom-opp bindings (dropped accidentally in v3)
* merged the patches to add bindings for rpm and rpmh, added consumer binding example
* Made the drivers built in, removed .remove
* Added better description in changelog for PATCH 6/6
* Updated rpmhpd_aggregate_corner() based on Davids feedback
* rpmhpd_set_performance_state() returns max corner, in cases where its called
with an INT_MAX
* Dropped the patch to max vote on all corners at init, the patch did not
work anyway, and it shouldn't be needed now

Changes in v3:
* Bindings split into seperate patches
* Bindings updated to remove duplicate OPP table phandles
* DT headers defining macros for Power domain indexes and OPP levels
* Optimisations to use rpmh_write_async() whereever applicable
* Fixed up handling of ACTIVE_ONLY/WAKE_ONLY/SLEEP voting for RPMh
* Fixed the vlvl to hlvl conversions in set_performance
* Other minor fixes based on review of v2
* TODO: This series does not handle the case where all VDD_MX votes
should be higher than VDD_CX from APPs, as pointed out
by David Collins in v2. This needs support at genpd to propogate performance
state up the parents, if we model these as Parent/Child to handle the
interdependency.

Changes in v2:
* added a power domain driver for sdm845 which supports communicating to RPMh
* dropped the changes to sdhc driver to move over to using OPP
as there is active discussion on using OPP as the interface vs
handling all of it in clock drivers
* Other minor binding updates based on review of v1

With performance state support for genpd/OPP merged, this is an effort
to model a power domain driver to communicate corner/level
values for qualcomm platforms to RPM (Remote Power Manager) and RPMh.

[1] https://lkml.org/lkml/2018/11/26/333

Rajendra Nayak (9):
  dt-bindings: opp: Introduce opp-level bindings
  OPP: Add support for parsing the 'opp-level' property
  dt-bindings: power: Add qcom rpm power domain driver bindings
  soc: qcom: rpmpd: Add a Power domain driver to model corners
  soc: qcom: rpmpd: Add support for get/set performance state
  arm64: dts: msm8996: Add rpmpd device node
  soc: qcom: rpmhpd: Add RPMh power domain driver
  arm64: dts: sdm845: Add rpmh powercontroller node
  soc: qcom: rpmhpd: Mark mx as a parent for cx

 Documentation/devicetree/bindings/opp/opp.txt |   3 +
 .../devicetree/bindings/power/qcom,rpmpd.txt  | 145 +++++++
 arch/arm64/boot/dts/qcom/msm8996.dtsi         |  34 ++
 arch/arm64/boot/dts/qcom/sdm845.dtsi          |  51 +++
 drivers/opp/core.c                            |  18 +
 drivers/opp/of.c                              |   2 +
 drivers/opp/opp.h                             |   2 +
 drivers/soc/qcom/Kconfig                      |  18 +
 drivers/soc/qcom/Makefile                     |   2 +
 drivers/soc/qcom/rpmhpd.c                     | 402 ++++++++++++++++++
 drivers/soc/qcom/rpmpd.c                      | 317 ++++++++++++++
 include/dt-bindings/power/qcom-rpmpd.h        |  39 ++
 include/linux/pm_opp.h                        |   7 +
 13 files changed, 1040 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/qcom,rpmpd.txt
 create mode 100644 drivers/soc/qcom/rpmhpd.c
 create mode 100644 drivers/soc/qcom/rpmpd.c
 create mode 100644 include/dt-bindings/power/qcom-rpmpd.h

-- 
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] 26+ messages in thread

* [PATCH v11 1/9] dt-bindings: opp: Introduce opp-level bindings
  2019-01-10  4:02 [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845 Rajendra Nayak
@ 2019-01-10  4:02 ` Rajendra Nayak
  2019-01-10  6:26   ` Viresh Kumar
                     ` (3 more replies)
  2019-01-10  4:02 ` [PATCH v11 2/9] OPP: Add support for parsing the 'opp-level' property Rajendra Nayak
                   ` (9 subsequent siblings)
  10 siblings, 4 replies; 26+ messages in thread
From: Rajendra Nayak @ 2019-01-10  4:02 UTC (permalink / raw)
  To: andy.gross, robh, viresh.kumar, sboyd, ulf.hansson, collinsd, mka
  Cc: devicetree, linux-arm-msm, linux-kernel, henryc.chen, Rajendra Nayak

Add opp-level as an additional property in the OPP node to describe
the performance level of the device.

On some SoCs (especially from Qualcomm and MediaTek) this value
is communicated to a remote microprocessor by the CPU, which
then takes some actions (like adjusting voltage values across various
rails) based on the value passed.

Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
---
 Documentation/devicetree/bindings/opp/opp.txt | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/Documentation/devicetree/bindings/opp/opp.txt b/Documentation/devicetree/bindings/opp/opp.txt
index c396c4c0af92..76b6c79604a5 100644
--- a/Documentation/devicetree/bindings/opp/opp.txt
+++ b/Documentation/devicetree/bindings/opp/opp.txt
@@ -129,6 +129,9 @@ Optional properties:
 - opp-microamp-<name>: Named opp-microamp property. Similar to
   opp-microvolt-<name> property, but for microamp instead.
 
+- opp-level: A value representing the performance level of the device,
+  expressed as a 32-bit integer.
+
 - clock-latency-ns: Specifies the maximum possible transition latency (in
   nanoseconds) for switching to this OPP from any other OPP.
 
-- 
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] 26+ messages in thread

* [PATCH v11 2/9] OPP: Add support for parsing the 'opp-level' property
  2019-01-10  4:02 [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845 Rajendra Nayak
  2019-01-10  4:02 ` [PATCH v11 1/9] dt-bindings: opp: Introduce opp-level bindings Rajendra Nayak
@ 2019-01-10  4:02 ` Rajendra Nayak
  2019-01-10  6:29   ` Viresh Kumar
  2019-01-11 19:06   ` Stephen Boyd
  2019-01-10  4:02 ` [PATCH v11 3/9] dt-bindings: power: Add qcom rpm power domain driver bindings Rajendra Nayak
                   ` (8 subsequent siblings)
  10 siblings, 2 replies; 26+ messages in thread
From: Rajendra Nayak @ 2019-01-10  4:02 UTC (permalink / raw)
  To: andy.gross, robh, viresh.kumar, sboyd, ulf.hansson, collinsd, mka
  Cc: devicetree, linux-arm-msm, linux-kernel, henryc.chen, Rajendra Nayak

Now that the OPP bindings are updated to include an optional
'opp-level' property, add support to parse it from device tree
and store it as part of dev_pm_opp structure.
Also add and export an helper 'dev_pm_opp_get_level()' that can be
used to get the level value read from device tree when present.

Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
---
 drivers/opp/core.c     | 18 ++++++++++++++++++
 drivers/opp/of.c       |  2 ++
 drivers/opp/opp.h      |  2 ++
 include/linux/pm_opp.h |  7 +++++++
 4 files changed, 29 insertions(+)

diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index e5507add8f04..90b78a122be9 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -130,6 +130,24 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
 }
 EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq);
 
+/**
+ * dev_pm_opp_get_level() - Gets the level corresponding to an available opp
+ * @opp:	opp for which level value has to be returned for
+ *
+ * Return: level read from device tree corresponding to the opp, else
+ * return 0.
+ */
+unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp)
+{
+	if (IS_ERR_OR_NULL(opp) || !opp->available) {
+		pr_err("%s: Invalid parameters\n", __func__);
+		return 0;
+	}
+
+	return opp->level;
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_get_level);
+
 /**
  * dev_pm_opp_is_turbo() - Returns if opp is turbo OPP or not
  * @opp: opp for which turbo mode is being verified
diff --git a/drivers/opp/of.c b/drivers/opp/of.c
index 06f0f632ec47..1779f2c93291 100644
--- a/drivers/opp/of.c
+++ b/drivers/opp/of.c
@@ -594,6 +594,8 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table,
 		new_opp->rate = (unsigned long)rate;
 	}
 
+	of_property_read_u32(np, "opp-level", &new_opp->level);
+
 	/* Check if the OPP supports hardware's hierarchy of versions or not */
 	if (!_opp_is_supported(dev, opp_table, np)) {
 		dev_dbg(dev, "OPP not supported by hardware: %llu\n", rate);
diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h
index e24d81497375..4458175aa661 100644
--- a/drivers/opp/opp.h
+++ b/drivers/opp/opp.h
@@ -60,6 +60,7 @@ extern struct list_head opp_tables;
  * @suspend:	true if suspend OPP
  * @pstate: Device's power domain's performance state.
  * @rate:	Frequency in hertz
+ * @level:	Performance level
  * @supplies:	Power supplies voltage/current values
  * @clock_latency_ns: Latency (in nanoseconds) of switching to this OPP's
  *		frequency from any other OPP's frequency.
@@ -80,6 +81,7 @@ struct dev_pm_opp {
 	bool suspend;
 	unsigned int pstate;
 	unsigned long rate;
+	unsigned int level;
 
 	struct dev_pm_opp_supply *supplies;
 
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index 0a2a88e5a383..473d2c7516f0 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -86,6 +86,8 @@ unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp);
 
 unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp);
 
+unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp);
+
 bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp);
 
 int dev_pm_opp_get_opp_count(struct device *dev);
@@ -157,6 +159,11 @@ static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
 	return 0;
 }
 
+static inline unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp)
+{
+	return 0;
+}
+
 static inline bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp)
 {
 	return false;
-- 
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] 26+ messages in thread

* [PATCH v11 3/9] dt-bindings: power: Add qcom rpm power domain driver bindings
  2019-01-10  4:02 [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845 Rajendra Nayak
  2019-01-10  4:02 ` [PATCH v11 1/9] dt-bindings: opp: Introduce opp-level bindings Rajendra Nayak
  2019-01-10  4:02 ` [PATCH v11 2/9] OPP: Add support for parsing the 'opp-level' property Rajendra Nayak
@ 2019-01-10  4:02 ` Rajendra Nayak
  2019-01-10  4:02 ` [PATCH v11 4/9] soc: qcom: rpmpd: Add a Power domain driver to model corners Rajendra Nayak
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2019-01-10  4:02 UTC (permalink / raw)
  To: andy.gross, robh, viresh.kumar, sboyd, ulf.hansson, collinsd, mka
  Cc: devicetree, linux-arm-msm, linux-kernel, henryc.chen, Rajendra Nayak

Add DT bindings to describe the rpm/rpmh power domains found on Qualcomm
Technologies, Inc. SoCs. These power domains communicate a performance
state to RPM/RPMh, which then translates it into corresponding voltage on a
PMIC rail.

Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Rob Herring <robh@kernel.org>
---
 .../devicetree/bindings/power/qcom,rpmpd.txt  | 145 ++++++++++++++++++
 include/dt-bindings/power/qcom-rpmpd.h        |  39 +++++
 2 files changed, 184 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/qcom,rpmpd.txt
 create mode 100644 include/dt-bindings/power/qcom-rpmpd.h

diff --git a/Documentation/devicetree/bindings/power/qcom,rpmpd.txt b/Documentation/devicetree/bindings/power/qcom,rpmpd.txt
new file mode 100644
index 000000000000..980e5413d18f
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/qcom,rpmpd.txt
@@ -0,0 +1,145 @@
+Qualcomm RPM/RPMh Power domains
+
+For RPM/RPMh Power domains, we communicate a performance state to RPM/RPMh
+which then translates it into a corresponding voltage on a rail
+
+Required Properties:
+ - compatible: Should be one of the following
+	* qcom,msm8996-rpmpd: RPM Power domain for the msm8996 family of SoC
+	* qcom,sdm845-rpmhpd: RPMh Power domain for the sdm845 family of SoC
+ - #power-domain-cells: number of cells in Power domain specifier
+	must be 1.
+ - operating-points-v2: Phandle to the OPP table for the Power domain.
+	Refer to Documentation/devicetree/bindings/power/power_domain.txt
+	and Documentation/devicetree/bindings/opp/opp.txt for more details
+
+Refer to <dt-bindings/power/qcom-rpmpd.h> for the level values for
+various OPPs for different platforms as well as Power domain indexes
+
+Example: rpmh power domain controller and OPP table
+
+#include <dt-bindings/power/qcom-rpmhpd.h>
+
+opp-level values specified in the OPP tables for RPMh power domains
+should use the RPMH_REGULATOR_LEVEL_* constants from
+<dt-bindings/power/qcom-rpmhpd.h>
+
+	rpmhpd: power-controller {
+		compatible = "qcom,sdm845-rpmhpd";
+		#power-domain-cells = <1>;
+		operating-points-v2 = <&rpmhpd_opp_table>;
+
+		rpmhpd_opp_table: opp-table {
+			compatible = "operating-points-v2";
+
+			rpmhpd_opp_ret: opp1 {
+				opp-level = <RPMH_REGULATOR_LEVEL_RETENTION>;
+			};
+
+			rpmhpd_opp_min_svs: opp2 {
+				opp-level = <RPMH_REGULATOR_LEVEL_MIN_SVS>;
+			};
+
+			rpmhpd_opp_low_svs: opp3 {
+				opp-level = <RPMH_REGULATOR_LEVEL_LOW_SVS>;
+			};
+
+			rpmhpd_opp_svs: opp4 {
+				opp-level = <RPMH_REGULATOR_LEVEL_SVS>;
+			};
+
+			rpmhpd_opp_svs_l1: opp5 {
+				opp-level = <RPMH_REGULATOR_LEVEL_SVS_L1>;
+			};
+
+			rpmhpd_opp_nom: opp6 {
+				opp-level = <RPMH_REGULATOR_LEVEL_NOM>;
+			};
+
+			rpmhpd_opp_nom_l1: opp7 {
+				opp-level = <RPMH_REGULATOR_LEVEL_NOM_L1>;
+			};
+
+			rpmhpd_opp_nom_l2: opp8 {
+				opp-level = <RPMH_REGULATOR_LEVEL_NOM_L2>;
+			};
+
+			rpmhpd_opp_turbo: opp9 {
+				opp-level = <RPMH_REGULATOR_LEVEL_TURBO>;
+			};
+
+			rpmhpd_opp_turbo_l1: opp10 {
+				opp-level = <RPMH_REGULATOR_LEVEL_TURBO_L1>;
+			};
+		};
+	};
+
+Example: rpm power domain controller and OPP table
+
+	rpmpd: power-controller {
+		compatible = "qcom,msm8996-rpmpd";
+		#power-domain-cells = <1>;
+		operating-points-v2 = <&rpmpd_opp_table>;
+
+		rpmpd_opp_table: opp-table {
+			compatible = "operating-points-v2";
+
+			rpmpd_opp_low: opp1 {
+				opp-level = <1>;
+			};
+
+			rpmpd_opp_ret: opp2 {
+				opp-level = <2>;
+			};
+
+			rpmpd_opp_svs: opp3 {
+				opp-level = <3>;
+			};
+
+			rpmpd_opp_normal: opp4 {
+				opp-level = <4>;
+			};
+
+			rpmpd_opp_high: opp5 {
+				opp-level = <5>;
+			};
+
+			rpmpd_opp_turbo: opp6 {
+				opp-level = <6>;
+			};
+		};
+	};
+
+Example: Client/Consumer device using OPP table
+
+	leaky-device0@12350000 {
+		compatible = "foo,i-leak-current";
+		reg = <0x12350000 0x1000>;
+		power-domains = <&rpmhpd SDM845_MX>;
+		operating-points-v2 = <&leaky_opp_table>;
+	};
+
+
+	leaky_opp_table: opp-table {
+		compatible = "operating-points-v2";
+
+		opp1 {
+			opp-hz = /bits/ 64 <144000>;
+			required-opps = <&rpmhpd_opp_low>;
+		};
+
+		opp2 {
+			opp-hz = /bits/ 64 <400000>;
+			required-opps = <&rpmhpd_opp_ret>;
+		};
+
+		opp3 {
+			opp-hz = /bits/ 64 <20000000>;
+			required-opps = <&rpmpd_opp_svs>;
+		};
+
+		opp4 {
+			opp-hz = /bits/ 64 <25000000>;
+			required-opps = <&rpmpd_opp_normal>;
+		};
+	};
diff --git a/include/dt-bindings/power/qcom-rpmpd.h b/include/dt-bindings/power/qcom-rpmpd.h
new file mode 100644
index 000000000000..87d9c6611682
--- /dev/null
+++ b/include/dt-bindings/power/qcom-rpmpd.h
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/* Copyright (c) 2018, The Linux Foundation. All rights reserved. */
+
+#ifndef _DT_BINDINGS_POWER_QCOM_RPMPD_H
+#define _DT_BINDINGS_POWER_QCOM_RPMPD_H
+
+/* SDM845 Power Domain Indexes */
+#define SDM845_EBI	0
+#define SDM845_MX	1
+#define SDM845_MX_AO	2
+#define SDM845_CX	3
+#define SDM845_CX_AO	4
+#define SDM845_LMX	5
+#define SDM845_LCX	6
+#define SDM845_GFX	7
+#define SDM845_MSS	8
+
+/* SDM845 Power Domain performance levels */
+#define RPMH_REGULATOR_LEVEL_RETENTION	16
+#define RPMH_REGULATOR_LEVEL_MIN_SVS	48
+#define RPMH_REGULATOR_LEVEL_LOW_SVS	64
+#define RPMH_REGULATOR_LEVEL_SVS	128
+#define RPMH_REGULATOR_LEVEL_SVS_L1	192
+#define RPMH_REGULATOR_LEVEL_NOM	256
+#define RPMH_REGULATOR_LEVEL_NOM_L1	320
+#define RPMH_REGULATOR_LEVEL_NOM_L2	336
+#define RPMH_REGULATOR_LEVEL_TURBO	384
+#define RPMH_REGULATOR_LEVEL_TURBO_L1	416
+
+/* MSM8996 Power Domain Indexes */
+#define MSM8996_VDDCX		0
+#define MSM8996_VDDCX_AO	1
+#define MSM8996_VDDCX_VFC	2
+#define MSM8996_VDDMX		3
+#define MSM8996_VDDMX_AO	4
+#define MSM8996_VDDSSCX		5
+#define MSM8996_VDDSSCX_VFC	6
+
+#endif
-- 
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] 26+ messages in thread

* [PATCH v11 4/9] soc: qcom: rpmpd: Add a Power domain driver to model corners
  2019-01-10  4:02 [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845 Rajendra Nayak
                   ` (2 preceding siblings ...)
  2019-01-10  4:02 ` [PATCH v11 3/9] dt-bindings: power: Add qcom rpm power domain driver bindings Rajendra Nayak
@ 2019-01-10  4:02 ` Rajendra Nayak
  2019-01-17 17:42   ` Guenter Roeck
  2019-01-10  4:02 ` [PATCH v11 5/9] soc: qcom: rpmpd: Add support for get/set performance state Rajendra Nayak
                   ` (6 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: Rajendra Nayak @ 2019-01-10  4:02 UTC (permalink / raw)
  To: andy.gross, robh, viresh.kumar, sboyd, ulf.hansson, collinsd, mka
  Cc: devicetree, linux-arm-msm, linux-kernel, henryc.chen, Rajendra Nayak

The Power domains for corners just pass the performance state set by the
consumers to the RPM (Remote Power manager) which then takes care
of setting the appropriate voltage on the corresponding rails to
meet the performance needs.

We add all power domain data needed on msm8996 here. This driver can easily
be extended by adding data for other qualcomm SoCs as well.

Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Rob Herring <robh@kernel.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
---
 drivers/soc/qcom/Kconfig  |   9 ++
 drivers/soc/qcom/Makefile |   1 +
 drivers/soc/qcom/rpmpd.c  | 282 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 292 insertions(+)
 create mode 100644 drivers/soc/qcom/rpmpd.c

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index fcbf8a2e4080..df5cd9fa0d5e 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -98,6 +98,15 @@ config QCOM_RPMH
 	  of hardware components aggregate requests for these resources and
 	  help apply the aggregated state on the resource.
 
+config QCOM_RPMPD
+	bool "Qualcomm RPM Power domain driver"
+	depends on MFD_QCOM_RPM && QCOM_SMD_RPM
+	help
+	  QCOM RPM Power domain driver to support power-domains with
+	  performance states. The driver communicates a performance state
+	  value to RPM which then translates it into corresponding voltage
+	  for the voltage rail.
+
 config QCOM_SMEM
 	tristate "Qualcomm Shared Memory Manager (SMEM)"
 	depends on ARCH_QCOM || COMPILE_TEST
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index f25b54cd6cf8..f1b25fdcf2ad 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -21,3 +21,4 @@ obj-$(CONFIG_QCOM_WCNSS_CTRL) += wcnss_ctrl.o
 obj-$(CONFIG_QCOM_APR) += apr.o
 obj-$(CONFIG_QCOM_LLCC) += llcc-slice.o
 obj-$(CONFIG_QCOM_SDM845_LLCC) += llcc-sdm845.o
+obj-$(CONFIG_QCOM_RPMPD) += rpmpd.o
diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c
new file mode 100644
index 000000000000..7715ba7c9157
--- /dev/null
+++ b/drivers/soc/qcom/rpmpd.c
@@ -0,0 +1,282 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. */
+
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/mutex.h>
+#include <linux/pm_domain.h>
+#include <linux/mfd/qcom_rpm.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/soc/qcom/smd-rpm.h>
+
+#include <dt-bindings/mfd/qcom-rpm.h>
+#include <dt-bindings/power/qcom-rpmpd.h>
+
+#define domain_to_rpmpd(domain) container_of(domain, struct rpmpd, pd)
+
+/* Resource types */
+#define RPMPD_SMPA 0x61706d73
+#define RPMPD_LDOA 0x616f646c
+
+/* Operation Keys */
+#define KEY_CORNER		0x6e726f63 /* corn */
+#define KEY_ENABLE		0x6e657773 /* swen */
+#define KEY_FLOOR_CORNER	0x636676   /* vfc */
+
+#define DEFINE_RPMPD_CORNER_SMPA(_platform, _name, _active, r_id)		\
+	static struct rpmpd _platform##_##_active;			\
+	static struct rpmpd _platform##_##_name = {			\
+		.pd = {	.name = #_name,	},				\
+		.peer = &_platform##_##_active,				\
+		.res_type = RPMPD_SMPA,					\
+		.res_id = r_id,						\
+		.key = KEY_CORNER,					\
+	};								\
+	static struct rpmpd _platform##_##_active = {			\
+		.pd = { .name = #_active, },				\
+		.peer = &_platform##_##_name,				\
+		.active_only = true,					\
+		.res_type = RPMPD_SMPA,					\
+		.res_id = r_id,						\
+		.key = KEY_CORNER,					\
+	}
+
+#define DEFINE_RPMPD_CORNER_LDOA(_platform, _name, r_id)			\
+	static struct rpmpd _platform##_##_name = {			\
+		.pd = { .name = #_name, },				\
+		.res_type = RPMPD_LDOA,					\
+		.res_id = r_id,						\
+		.key = KEY_CORNER,					\
+	}
+
+#define DEFINE_RPMPD_VFC(_platform, _name, r_id, r_type)		\
+	static struct rpmpd _platform##_##_name = {			\
+		.pd = { .name = #_name, },				\
+		.res_type = r_type,					\
+		.res_id = r_id,						\
+		.key = KEY_FLOOR_CORNER,				\
+	}
+
+#define DEFINE_RPMPD_VFC_SMPA(_platform, _name, r_id)			\
+	DEFINE_RPMPD_VFC(_platform, _name, r_id, RPMPD_SMPA)
+
+#define DEFINE_RPMPD_VFC_LDOA(_platform, _name, r_id)			\
+	DEFINE_RPMPD_VFC(_platform, _name, r_id, RPMPD_LDOA)
+
+struct rpmpd_req {
+	__le32 key;
+	__le32 nbytes;
+	__le32 value;
+};
+
+struct rpmpd {
+	struct generic_pm_domain pd;
+	struct rpmpd *peer;
+	const bool active_only;
+	unsigned int corner;
+	bool enabled;
+	const char *res_name;
+	const int res_type;
+	const int res_id;
+	struct qcom_smd_rpm *rpm;
+	__le32 key;
+};
+
+struct rpmpd_desc {
+	struct rpmpd **rpmpds;
+	size_t num_pds;
+};
+
+static DEFINE_MUTEX(rpmpd_lock);
+
+/* msm8996 RPM Power domains */
+DEFINE_RPMPD_CORNER_SMPA(msm8996, vddcx, vddcx_ao, 1);
+DEFINE_RPMPD_CORNER_SMPA(msm8996, vddmx, vddmx_ao, 2);
+DEFINE_RPMPD_CORNER_LDOA(msm8996, vddsscx, 26);
+
+DEFINE_RPMPD_VFC_SMPA(msm8996, vddcx_vfc, 1);
+DEFINE_RPMPD_VFC_LDOA(msm8996, vddsscx_vfc, 26);
+
+static struct rpmpd *msm8996_rpmpds[] = {
+	[MSM8996_VDDCX] =	&msm8996_vddcx,
+	[MSM8996_VDDCX_AO] =	&msm8996_vddcx_ao,
+	[MSM8996_VDDCX_VFC] =	&msm8996_vddcx_vfc,
+	[MSM8996_VDDMX] =	&msm8996_vddmx,
+	[MSM8996_VDDMX_AO] =	&msm8996_vddmx_ao,
+	[MSM8996_VDDSSCX] =	&msm8996_vddsscx,
+	[MSM8996_VDDSSCX_VFC] =	&msm8996_vddsscx_vfc,
+};
+
+static const struct rpmpd_desc msm8996_desc = {
+	.rpmpds = msm8996_rpmpds,
+	.num_pds = ARRAY_SIZE(msm8996_rpmpds),
+};
+
+static const struct of_device_id rpmpd_match_table[] = {
+	{ .compatible = "qcom,msm8996-rpmpd", .data = &msm8996_desc },
+	{ }
+};
+
+static int rpmpd_send_enable(struct rpmpd *pd, bool enable)
+{
+	struct rpmpd_req req = {
+		.key = KEY_ENABLE,
+		.nbytes = cpu_to_le32(sizeof(u32)),
+		.value = cpu_to_le32(enable),
+	};
+
+	return qcom_rpm_smd_write(pd->rpm, QCOM_RPM_ACTIVE_STATE, pd->res_type,
+				  pd->res_id, &req, sizeof(req));
+}
+
+static int rpmpd_send_corner(struct rpmpd *pd, int state, unsigned int corner)
+{
+	struct rpmpd_req req = {
+		.key = pd->key,
+		.nbytes = cpu_to_le32(sizeof(u32)),
+		.value = cpu_to_le32(corner),
+	};
+
+	return qcom_rpm_smd_write(pd->rpm, state, pd->res_type, pd->res_id,
+				  &req, sizeof(req));
+};
+
+static void to_active_sleep(struct rpmpd *pd, unsigned int corner,
+			    unsigned int *active, unsigned int *sleep)
+{
+	*active = corner;
+
+	if (pd->active_only)
+		*sleep = 0;
+	else
+		*sleep = *active;
+}
+
+static int rpmpd_aggregate_corner(struct rpmpd *pd)
+{
+	int ret;
+	struct rpmpd *peer = pd->peer;
+	unsigned int active_corner, sleep_corner;
+	unsigned int this_active_corner = 0, this_sleep_corner = 0;
+	unsigned int peer_active_corner = 0, peer_sleep_corner = 0;
+
+	to_active_sleep(pd, pd->corner, &this_active_corner, &this_sleep_corner);
+
+	if (peer && peer->enabled)
+		to_active_sleep(peer, peer->corner, &peer_active_corner,
+				&peer_sleep_corner);
+
+	active_corner = max(this_active_corner, peer_active_corner);
+
+	ret = rpmpd_send_corner(pd, QCOM_RPM_ACTIVE_STATE, active_corner);
+	if (ret)
+		return ret;
+
+	sleep_corner = max(this_sleep_corner, peer_sleep_corner);
+
+	return rpmpd_send_corner(pd, QCOM_RPM_SLEEP_STATE, sleep_corner);
+}
+
+static int rpmpd_power_on(struct generic_pm_domain *domain)
+{
+	int ret;
+	struct rpmpd *pd = domain_to_rpmpd(domain);
+
+	mutex_lock(&rpmpd_lock);
+
+	ret = rpmpd_send_enable(pd, true);
+	if (ret)
+		goto out;
+
+	pd->enabled = true;
+
+	if (pd->corner)
+		ret = rpmpd_aggregate_corner(pd);
+
+out:
+	mutex_unlock(&rpmpd_lock);
+
+	return ret;
+}
+
+static int rpmpd_power_off(struct generic_pm_domain *domain)
+{
+	int ret;
+	struct rpmpd *pd = domain_to_rpmpd(domain);
+
+	mutex_lock(&rpmpd_lock);
+
+	ret = rpmpd_send_enable(pd, false);
+	if (!ret)
+		pd->enabled = false;
+
+	mutex_unlock(&rpmpd_lock);
+
+	return ret;
+}
+
+static int rpmpd_probe(struct platform_device *pdev)
+{
+	int i;
+	size_t num;
+	struct genpd_onecell_data *data;
+	struct qcom_smd_rpm *rpm;
+	struct rpmpd **rpmpds;
+	const struct rpmpd_desc *desc;
+
+	rpm = dev_get_drvdata(pdev->dev.parent);
+	if (!rpm) {
+		dev_err(&pdev->dev, "Unable to retrieve handle to RPM\n");
+		return -ENODEV;
+	}
+
+	desc = of_device_get_match_data(&pdev->dev);
+	if (!desc)
+		return -EINVAL;
+
+	rpmpds = desc->rpmpds;
+	num = desc->num_pds;
+
+	data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	data->domains = devm_kcalloc(&pdev->dev, num, sizeof(*data->domains),
+				     GFP_KERNEL);
+	data->num_domains = num;
+
+	for (i = 0; i < num; i++) {
+		if (!rpmpds[i]) {
+			dev_warn(&pdev->dev, "rpmpds[] with empty entry at index=%d\n",
+				 i);
+			continue;
+		}
+
+		rpmpds[i]->rpm = rpm;
+		rpmpds[i]->pd.power_off = rpmpd_power_off;
+		rpmpds[i]->pd.power_on = rpmpd_power_on;
+		pm_genpd_init(&rpmpds[i]->pd, NULL, true);
+
+		data->domains[i] = &rpmpds[i]->pd;
+	}
+
+	return of_genpd_add_provider_onecell(pdev->dev.of_node, data);
+}
+
+static struct platform_driver rpmpd_driver = {
+	.driver = {
+		.name = "qcom-rpmpd",
+		.of_match_table = rpmpd_match_table,
+		.suppress_bind_attrs = true,
+	},
+	.probe = rpmpd_probe,
+};
+
+static int __init rpmpd_init(void)
+{
+	return platform_driver_register(&rpmpd_driver);
+}
+core_initcall(rpmpd_init);
-- 
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] 26+ messages in thread

* [PATCH v11 5/9] soc: qcom: rpmpd: Add support for get/set performance state
  2019-01-10  4:02 [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845 Rajendra Nayak
                   ` (3 preceding siblings ...)
  2019-01-10  4:02 ` [PATCH v11 4/9] soc: qcom: rpmpd: Add a Power domain driver to model corners Rajendra Nayak
@ 2019-01-10  4:02 ` Rajendra Nayak
  2019-01-10  4:02 ` [PATCH v11 6/9] arm64: dts: msm8996: Add rpmpd device node Rajendra Nayak
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2019-01-10  4:02 UTC (permalink / raw)
  To: andy.gross, robh, viresh.kumar, sboyd, ulf.hansson, collinsd, mka
  Cc: devicetree, linux-arm-msm, linux-kernel, henryc.chen, Rajendra Nayak

Add support for the .set_performace_state() and .opp_to_performance_state()
callbacks in the rpmpd driver.

Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
---
 drivers/soc/qcom/rpmpd.c | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c
index 7715ba7c9157..35a711017d6f 100644
--- a/drivers/soc/qcom/rpmpd.c
+++ b/drivers/soc/qcom/rpmpd.c
@@ -10,6 +10,7 @@
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
+#include <linux/pm_opp.h>
 #include <linux/soc/qcom/smd-rpm.h>
 
 #include <dt-bindings/mfd/qcom-rpm.h>
@@ -26,6 +27,8 @@
 #define KEY_ENABLE		0x6e657773 /* swen */
 #define KEY_FLOOR_CORNER	0x636676   /* vfc */
 
+#define MAX_RPMPD_STATE		6
+
 #define DEFINE_RPMPD_CORNER_SMPA(_platform, _name, _active, r_id)		\
 	static struct rpmpd _platform##_##_active;			\
 	static struct rpmpd _platform##_##_name = {			\
@@ -218,6 +221,36 @@ static int rpmpd_power_off(struct generic_pm_domain *domain)
 	return ret;
 }
 
+static int rpmpd_set_performance(struct generic_pm_domain *domain,
+				 unsigned int state)
+{
+	int ret = 0;
+	struct rpmpd *pd = domain_to_rpmpd(domain);
+
+	if (state > MAX_RPMPD_STATE)
+		goto out;
+
+	mutex_lock(&rpmpd_lock);
+
+	pd->corner = state;
+
+	if (!pd->enabled && pd->key != KEY_FLOOR_CORNER)
+		goto out;
+
+	ret = rpmpd_aggregate_corner(pd);
+
+out:
+	mutex_unlock(&rpmpd_lock);
+
+	return ret;
+}
+
+static unsigned int rpmpd_get_performance(struct generic_pm_domain *genpd,
+					  struct dev_pm_opp *opp)
+{
+	return dev_pm_opp_get_level(opp);
+}
+
 static int rpmpd_probe(struct platform_device *pdev)
 {
 	int i;
@@ -258,6 +291,8 @@ static int rpmpd_probe(struct platform_device *pdev)
 		rpmpds[i]->rpm = rpm;
 		rpmpds[i]->pd.power_off = rpmpd_power_off;
 		rpmpds[i]->pd.power_on = rpmpd_power_on;
+		rpmpds[i]->pd.set_performance_state = rpmpd_set_performance;
+		rpmpds[i]->pd.opp_to_performance_state = rpmpd_get_performance;
 		pm_genpd_init(&rpmpds[i]->pd, NULL, true);
 
 		data->domains[i] = &rpmpds[i]->pd;
-- 
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] 26+ messages in thread

* [PATCH v11 6/9] arm64: dts: msm8996: Add rpmpd device node
  2019-01-10  4:02 [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845 Rajendra Nayak
                   ` (4 preceding siblings ...)
  2019-01-10  4:02 ` [PATCH v11 5/9] soc: qcom: rpmpd: Add support for get/set performance state Rajendra Nayak
@ 2019-01-10  4:02 ` Rajendra Nayak
  2019-01-10  4:02 ` [PATCH v11 7/9] soc: qcom: rpmhpd: Add RPMh power domain driver Rajendra Nayak
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2019-01-10  4:02 UTC (permalink / raw)
  To: andy.gross, robh, viresh.kumar, sboyd, ulf.hansson, collinsd, mka
  Cc: devicetree, linux-arm-msm, linux-kernel, henryc.chen, Rajendra Nayak

Add rpmpd device node and its OPP table

Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
---
 arch/arm64/boot/dts/qcom/msm8996.dtsi | 34 +++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi b/arch/arm64/boot/dts/qcom/msm8996.dtsi
index 99b7495455a6..6a882d3efe30 100644
--- a/arch/arm64/boot/dts/qcom/msm8996.dtsi
+++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi
@@ -306,6 +306,40 @@
 				#clock-cells = <1>;
 			};
 
+			rpmpd: power-controller {
+				compatible = "qcom,msm8996-rpmpd";
+				#power-domain-cells = <1>;
+				operating-points-v2 = <&rpmpd_opp_table>;
+
+				rpmpd_opp_table: opp-table {
+					compatible = "operating-points-v2";
+
+					rpmpd_opp1: opp1 {
+						opp-level = <1>;
+					};
+
+					rpmpd_opp2: opp2 {
+						opp-level = <2>;
+					};
+
+					rpmpd_opp3: opp3 {
+						opp-level = <3>;
+					};
+
+					rpmpd_opp4: opp4 {
+						opp-level = <4>;
+					};
+
+					rpmpd_opp5: opp5 {
+						opp-level = <5>;
+					};
+
+					rpmpd_opp6: opp6 {
+						opp-level = <6>;
+					};
+				};
+			};
+
 			pm8994-regulators {
 				compatible = "qcom,rpm-pm8994-regulators";
 
-- 
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] 26+ messages in thread

* [PATCH v11 7/9] soc: qcom: rpmhpd: Add RPMh power domain driver
  2019-01-10  4:02 [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845 Rajendra Nayak
                   ` (5 preceding siblings ...)
  2019-01-10  4:02 ` [PATCH v11 6/9] arm64: dts: msm8996: Add rpmpd device node Rajendra Nayak
@ 2019-01-10  4:02 ` Rajendra Nayak
  2019-01-10  4:02 ` [PATCH v11 8/9] arm64: dts: sdm845: Add rpmh powercontroller node Rajendra Nayak
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2019-01-10  4:02 UTC (permalink / raw)
  To: andy.gross, robh, viresh.kumar, sboyd, ulf.hansson, collinsd, mka
  Cc: devicetree, linux-arm-msm, linux-kernel, henryc.chen, Rajendra Nayak

The RPMh power domain driver aggregates the corner votes from various
consumers for the ARC resources and communicates it to RPMh.

With RPMh we use 2 different numbering space for corners, one used
by the clients to express their performance needs, and another used
to communicate to RPMh hardware.

The clients express their performance requirements using a sparse
numbering space which are mapped to meaningful levels like RET, SVS,
NOMINAL, TURBO etc which then get mapped to another number space
between 0 and 15 which is communicated to RPMh. The sparse number space,
also referred to as vlvl is mapped to the continuous number space of 0
to 15, also referred to as hlvl, using command DB.

Some power domain clients could request a performance state only while
the CPU is active, while some others could request for a certain
performance state all the time regardless of the state of the CPU.
We handle this by internally aggregating the votes from both type of
clients and then send the aggregated votes to RPMh.

There are also 3 different types of votes that are comunicated to RPMh
for every resource.
1. ACTIVE_ONLY:
	This specifies the requirement for the resource when the CPU is
 	active
2. SLEEP:
	This specifies the requirement for the resource when the CPU is
	going to sleep
3. WAKE_ONLY:
	This specifies the requirement for the resource when the CPU is
	coming out of sleep to active state

We add data for all power domains on sdm845 SoC as part of the patch.
The driver can be extended to support other SoCs which support RPMh

Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
---
 drivers/soc/qcom/Kconfig  |   9 +
 drivers/soc/qcom/Makefile |   1 +
 drivers/soc/qcom/rpmhpd.c | 391 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 401 insertions(+)
 create mode 100644 drivers/soc/qcom/rpmhpd.c

diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
index df5cd9fa0d5e..6241d3e3b115 100644
--- a/drivers/soc/qcom/Kconfig
+++ b/drivers/soc/qcom/Kconfig
@@ -98,6 +98,15 @@ config QCOM_RPMH
 	  of hardware components aggregate requests for these resources and
 	  help apply the aggregated state on the resource.
 
+config QCOM_RPMHPD
+	bool "Qualcomm RPMh Power domain driver"
+	depends on QCOM_RPMH && QCOM_COMMAND_DB
+	help
+	  QCOM RPMh Power domain driver to support power-domains with
+	  performance states. The driver communicates a performance state
+	  value to RPMh which then translates it into corresponding voltage
+	  for the voltage rail.
+
 config QCOM_RPMPD
 	bool "Qualcomm RPM Power domain driver"
 	depends on MFD_QCOM_RPM && QCOM_SMD_RPM
diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile
index f1b25fdcf2ad..ffe519b0cb66 100644
--- a/drivers/soc/qcom/Makefile
+++ b/drivers/soc/qcom/Makefile
@@ -21,4 +21,5 @@ obj-$(CONFIG_QCOM_WCNSS_CTRL) += wcnss_ctrl.o
 obj-$(CONFIG_QCOM_APR) += apr.o
 obj-$(CONFIG_QCOM_LLCC) += llcc-slice.o
 obj-$(CONFIG_QCOM_SDM845_LLCC) += llcc-sdm845.o
+obj-$(CONFIG_QCOM_RPMHPD) += rpmhpd.o
 obj-$(CONFIG_QCOM_RPMPD) += rpmpd.o
diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c
new file mode 100644
index 000000000000..e45628694f09
--- /dev/null
+++ b/drivers/soc/qcom/rpmhpd.c
@@ -0,0 +1,391 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2018, The Linux Foundation. All rights reserved.*/
+
+#include <linux/err.h>
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/mutex.h>
+#include <linux/pm_domain.h>
+#include <linux/slab.h>
+#include <linux/of.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/pm_opp.h>
+#include <soc/qcom/cmd-db.h>
+#include <soc/qcom/rpmh.h>
+#include <dt-bindings/power/qcom-rpmpd.h>
+
+#define domain_to_rpmhpd(domain) container_of(domain, struct rpmhpd, pd)
+
+#define RPMH_ARC_MAX_LEVELS	16
+
+/**
+ * struct rpmhpd - top level RPMh power domain resource data structure
+ * @dev:		rpmh power domain controller device
+ * @pd: 		generic_pm_domain corrresponding to the power domain
+ * @peer:		A peer power domain in case Active only Voting is supported
+ * @active_only:	True if it represents an Active only peer
+ * @level:		An array of level (vlvl) to corner (hlvl) mappings derived from cmd-db
+ * @level_count:	Number of levels supported by the power domain. max being 16 (0 - 15)
+ * @enabled:		true if the power domain is enabled
+ * @res_name:		Resource name used for cmd-db lookup
+ * @addr:		Resource address as looped up using resource name from cmd-db
+ */
+struct rpmhpd {
+	struct device	*dev;
+	struct generic_pm_domain pd;
+	struct generic_pm_domain *parent;
+	struct rpmhpd	*peer;
+	const bool	active_only;
+	unsigned int	corner;
+	unsigned int	active_corner;
+	u32		level[RPMH_ARC_MAX_LEVELS];
+	size_t		level_count;
+	bool		enabled;
+	const char	*res_name;
+	u32		addr;
+};
+
+struct rpmhpd_desc {
+	struct rpmhpd **rpmhpds;
+	size_t num_pds;
+};
+
+static DEFINE_MUTEX(rpmhpd_lock);
+
+/* SDM845 RPMH powerdomains */
+
+static struct rpmhpd sdm845_ebi = {
+	.pd = { .name = "ebi", },
+	.res_name = "ebi.lvl",
+};
+
+static struct rpmhpd sdm845_lmx = {
+	.pd = { .name = "lmx", },
+	.res_name = "lmx.lvl",
+};
+
+static struct rpmhpd sdm845_lcx = {
+	.pd = { .name = "lcx", },
+	.res_name = "lcx.lvl",
+};
+
+static struct rpmhpd sdm845_gfx = {
+	.pd = { .name = "gfx", },
+	.res_name = "gfx.lvl",
+};
+
+static struct rpmhpd sdm845_mss = {
+	.pd = { .name = "mss", },
+	.res_name = "mss.lvl",
+};
+
+static struct rpmhpd sdm845_mx_ao;
+static struct rpmhpd sdm845_mx = {
+	.pd = { .name = "mx", },
+	.peer = &sdm845_mx_ao,
+	.res_name = "mx.lvl",
+};
+
+static struct rpmhpd sdm845_mx_ao = {
+	.pd = { .name = "mx_ao", },
+	.peer = &sdm845_mx,
+	.res_name = "mx.lvl",
+};
+
+static struct rpmhpd sdm845_cx_ao;
+static struct rpmhpd sdm845_cx = {
+	.pd = { .name = "cx", },
+	.peer = &sdm845_cx_ao,
+	.res_name = "cx.lvl",
+};
+
+static struct rpmhpd sdm845_cx_ao = {
+	.pd = { .name = "cx_ao", },
+	.peer = &sdm845_cx,
+	.res_name = "cx.lvl",
+};
+
+static struct rpmhpd *sdm845_rpmhpds[] = {
+	[SDM845_EBI] = &sdm845_ebi,
+	[SDM845_MX] = &sdm845_mx,
+	[SDM845_MX_AO] = &sdm845_mx_ao,
+	[SDM845_CX] = &sdm845_cx,
+	[SDM845_CX_AO] = &sdm845_cx_ao,
+	[SDM845_LMX] = &sdm845_lmx,
+	[SDM845_LCX] = &sdm845_lcx,
+	[SDM845_GFX] = &sdm845_gfx,
+	[SDM845_MSS] = &sdm845_mss,
+};
+
+static const struct rpmhpd_desc sdm845_desc = {
+	.rpmhpds = sdm845_rpmhpds,
+	.num_pds = ARRAY_SIZE(sdm845_rpmhpds),
+};
+
+static const struct of_device_id rpmhpd_match_table[] = {
+	{ .compatible = "qcom,sdm845-rpmhpd", .data = &sdm845_desc },
+	{ }
+};
+
+static int rpmhpd_send_corner(struct rpmhpd *pd, int state,
+			      unsigned int corner, bool sync)
+{
+	struct tcs_cmd cmd = {
+		.addr = pd->addr,
+		.data = corner,
+	};
+
+	/*
+	 * Wait for an ack only when we are increasing the
+	 * perf state of the power domain
+	 */
+	if (sync)
+		return rpmh_write(pd->dev, state, &cmd, 1);
+	else
+		return rpmh_write_async(pd->dev, state, &cmd, 1);
+}
+
+static void to_active_sleep(struct rpmhpd *pd, unsigned int corner,
+			    unsigned int *active, unsigned int *sleep)
+{
+	*active = corner;
+
+	if (pd->active_only)
+		*sleep = 0;
+	else
+		*sleep = *active;
+}
+
+/*
+ * This function is used to aggregate the votes across the active only
+ * resources and its peers. The aggregated votes are sent to RPMh as
+ * ACTIVE_ONLY votes (which take effect immediately), as WAKE_ONLY votes
+ * (applied by RPMh on system wakeup) and as SLEEP votes (applied by RPMh
+ * on system sleep).
+ * We send ACTIVE_ONLY votes for resources without any peers. For others,
+ * which have an active only peer, all 3 votes are sent.
+ */
+static int rpmhpd_aggregate_corner(struct rpmhpd *pd, unsigned int corner)
+{
+	int ret;
+	struct rpmhpd *peer = pd->peer;
+	unsigned int active_corner, sleep_corner;
+	unsigned int this_active_corner = 0, this_sleep_corner = 0;
+	unsigned int peer_active_corner = 0, peer_sleep_corner = 0;
+
+	to_active_sleep(pd, corner, &this_active_corner, &this_sleep_corner);
+
+	if (peer && peer->enabled)
+		to_active_sleep(peer, peer->corner, &peer_active_corner,
+				&peer_sleep_corner);
+
+	active_corner = max(this_active_corner, peer_active_corner);
+
+	ret = rpmhpd_send_corner(pd, RPMH_ACTIVE_ONLY_STATE, active_corner,
+				 active_corner > pd->active_corner);
+	if (ret)
+		return ret;
+
+	pd->active_corner = active_corner;
+
+	if (peer) {
+		peer->active_corner = active_corner;
+
+		ret = rpmhpd_send_corner(pd, RPMH_WAKE_ONLY_STATE,
+					 active_corner, false);
+		if (ret)
+			return ret;
+
+		sleep_corner = max(this_sleep_corner, peer_sleep_corner);
+
+		return rpmhpd_send_corner(pd, RPMH_SLEEP_STATE, sleep_corner,
+					  false);
+	}
+
+	return ret;
+}
+
+static int rpmhpd_power_on(struct generic_pm_domain *domain)
+{
+	struct rpmhpd *pd = domain_to_rpmhpd(domain);
+	int ret = 0;
+
+	mutex_lock(&rpmhpd_lock);
+
+	if (pd->corner)
+		ret = rpmhpd_aggregate_corner(pd, pd->corner);
+
+	if (!ret)
+		pd->enabled = true;
+
+	mutex_unlock(&rpmhpd_lock);
+
+	return ret;
+}
+
+static int rpmhpd_power_off(struct generic_pm_domain *domain)
+{
+	struct rpmhpd *pd = domain_to_rpmhpd(domain);
+	int ret = 0;
+
+	mutex_lock(&rpmhpd_lock);
+
+	ret = rpmhpd_aggregate_corner(pd, pd->level[0]);
+
+	if (!ret)
+		pd->enabled = false;
+
+	mutex_unlock(&rpmhpd_lock);
+
+	return ret;
+}
+
+static int rpmhpd_set_performance_state(struct generic_pm_domain *domain,
+					unsigned int level)
+{
+	struct rpmhpd *pd = domain_to_rpmhpd(domain);
+	int ret = 0, i;
+
+	mutex_lock(&rpmhpd_lock);
+
+	for (i = 0; i < pd->level_count; i++)
+		if (level <= pd->level[i])
+			break;
+
+	/*
+	 * If the level requested is more than that supported by the
+	 * max corner, just set it to max anyway.
+	 */
+	if (i == pd->level_count)
+		i--;
+
+	if (pd->enabled) {
+		ret = rpmhpd_aggregate_corner(pd, i);
+		if (ret)
+			goto out;
+	}
+
+	pd->corner = i;
+out:
+	mutex_unlock(&rpmhpd_lock);
+
+	return ret;
+}
+
+static unsigned int rpmhpd_get_performance_state(struct generic_pm_domain *genpd,
+						 struct dev_pm_opp *opp)
+{
+	return dev_pm_opp_get_level(opp);
+}
+
+static int rpmhpd_update_level_mapping(struct rpmhpd *rpmhpd)
+{
+	int i;
+	const u16 *buf;
+
+	buf = cmd_db_read_aux_data(rpmhpd->res_name, &rpmhpd->level_count);
+	if (IS_ERR(buf))
+		return PTR_ERR(buf);
+
+	/* 2 bytes used for each command DB aux data entry */
+	rpmhpd->level_count >>= 1;
+
+	if (rpmhpd->level_count > RPMH_ARC_MAX_LEVELS)
+		return -EINVAL;
+
+	for (i = 0; i < rpmhpd->level_count; i++) {
+		rpmhpd->level[i] = buf[i];
+
+		/*
+		 * The AUX data may be zero padded.  These 0 valued entries at
+		 * the end of the map must be ignored.
+		 */
+		if (i > 0 && rpmhpd->level[i] == 0) {
+			rpmhpd->level_count = i;
+			break;
+		}
+		pr_debug("%s: ARC hlvl=%2d --> vlvl=%4u\n", rpmhpd->res_name, i,
+			 rpmhpd->level[i]);
+	}
+
+	return 0;
+}
+
+static int rpmhpd_probe(struct platform_device *pdev)
+{
+	int i, ret;
+	size_t num_pds;
+	struct device *dev = &pdev->dev;
+	struct genpd_onecell_data *data;
+	struct rpmhpd **rpmhpds;
+	const struct rpmhpd_desc *desc;
+
+	desc = of_device_get_match_data(dev);
+	if (!desc)
+		return -EINVAL;
+
+	rpmhpds = desc->rpmhpds;
+	num_pds = desc->num_pds;
+
+	data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
+
+	data->domains = devm_kcalloc(dev, num_pds, sizeof(*data->domains),
+				     GFP_KERNEL);
+	if (!data->domains)
+		return -ENOMEM;
+
+	data->num_domains = num_pds;
+
+	for (i = 0; i < num_pds; i++) {
+		if (!rpmhpds[i]) {
+			dev_warn(dev, "rpmhpds[%d] is empty\n", i);
+			continue;
+		}
+
+		rpmhpds[i]->dev = dev;
+		rpmhpds[i]->addr = cmd_db_read_addr(rpmhpds[i]->res_name);
+		if (!rpmhpds[i]->addr) {
+			dev_err(dev, "Could not find RPMh address for resource %s\n",
+				rpmhpds[i]->res_name);
+			return -ENODEV;
+		}
+
+		ret = cmd_db_read_slave_id(rpmhpds[i]->res_name);
+		if (ret != CMD_DB_HW_ARC) {
+			dev_err(dev, "RPMh slave ID mismatch\n");
+			return -EINVAL;
+		}
+
+		ret = rpmhpd_update_level_mapping(rpmhpds[i]);
+		if (ret)
+			return ret;
+
+		rpmhpds[i]->pd.power_off = rpmhpd_power_off;
+		rpmhpds[i]->pd.power_on = rpmhpd_power_on;
+		rpmhpds[i]->pd.set_performance_state = rpmhpd_set_performance_state;
+		rpmhpds[i]->pd.opp_to_performance_state = rpmhpd_get_performance_state;
+		pm_genpd_init(&rpmhpds[i]->pd, NULL, true);
+
+		data->domains[i] = &rpmhpds[i]->pd;
+	}
+
+	return of_genpd_add_provider_onecell(pdev->dev.of_node, data);
+}
+
+static struct platform_driver rpmhpd_driver = {
+	.driver = {
+		.name = "qcom-rpmhpd",
+		.of_match_table = rpmhpd_match_table,
+		.suppress_bind_attrs = true,
+	},
+	.probe = rpmhpd_probe,
+};
+
+static int __init rpmhpd_init(void)
+{
+	return platform_driver_register(&rpmhpd_driver);
+}
+core_initcall(rpmhpd_init);
-- 
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] 26+ messages in thread

* [PATCH v11 8/9] arm64: dts: sdm845: Add rpmh powercontroller node
  2019-01-10  4:02 [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845 Rajendra Nayak
                   ` (6 preceding siblings ...)
  2019-01-10  4:02 ` [PATCH v11 7/9] soc: qcom: rpmhpd: Add RPMh power domain driver Rajendra Nayak
@ 2019-01-10  4:02 ` Rajendra Nayak
  2019-01-10  4:02 ` [PATCH v11 9/9] soc: qcom: rpmhpd: Mark mx as a parent for cx Rajendra Nayak
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2019-01-10  4:02 UTC (permalink / raw)
  To: andy.gross, robh, viresh.kumar, sboyd, ulf.hansson, collinsd, mka
  Cc: devicetree, linux-arm-msm, linux-kernel, henryc.chen, Rajendra Nayak

Add the DT node for the rpmhpd powercontroller.

Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
---
 arch/arm64/boot/dts/qcom/sdm845.dtsi | 51 ++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)

diff --git a/arch/arm64/boot/dts/qcom/sdm845.dtsi b/arch/arm64/boot/dts/qcom/sdm845.dtsi
index c27cbd3bcb0a..22dc2b2df662 100644
--- a/arch/arm64/boot/dts/qcom/sdm845.dtsi
+++ b/arch/arm64/boot/dts/qcom/sdm845.dtsi
@@ -10,6 +10,7 @@
 #include <dt-bindings/clock/qcom,rpmh.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/phy/phy-qcom-qusb2.h>
+#include <dt-bindings/power/qcom-rpmpd.h>
 #include <dt-bindings/reset/qcom,sdm845-aoss.h>
 #include <dt-bindings/soc/qcom,rpmh-rsc.h>
 #include <dt-bindings/clock/qcom,gcc-sdm845.h>
@@ -1602,6 +1603,56 @@
 				compatible = "qcom,sdm845-rpmh-clk";
 				#clock-cells = <1>;
 			};
+
+			rpmhpd: power-controller {
+				compatible = "qcom,sdm845-rpmhpd";
+				#power-domain-cells = <1>;
+				operating-points-v2 = <&rpmhpd_opp_table>;
+
+				rpmhpd_opp_table: opp-table {
+					compatible = "operating-points-v2";
+
+					rpmhpd_opp_ret: opp1 {
+						opp-level = <RPMH_REGULATOR_LEVEL_RETENTION>;
+					};
+
+					rpmhpd_opp_min_svs: opp2 {
+						opp-level = <RPMH_REGULATOR_LEVEL_MIN_SVS>;
+					};
+
+					rpmhpd_opp_low_svs: opp3 {
+						opp-level = <RPMH_REGULATOR_LEVEL_LOW_SVS>;
+					};
+
+					rpmhpd_opp_svs: opp4 {
+						opp-level = <RPMH_REGULATOR_LEVEL_SVS>;
+					};
+
+					rpmhpd_opp_svs_l1: opp5 {
+						opp-level = <RPMH_REGULATOR_LEVEL_SVS_L1>;
+					};
+
+					rpmhpd_opp_nom: opp6 {
+						opp-level = <RPMH_REGULATOR_LEVEL_NOM>;
+					};
+
+					rpmhpd_opp_nom_l1: opp7 {
+						opp-level = <RPMH_REGULATOR_LEVEL_NOM_L1>;
+					};
+
+					rpmhpd_opp_nom_l2: opp8 {
+						opp-level = <RPMH_REGULATOR_LEVEL_NOM_L2>;
+					};
+
+					rpmhpd_opp_turbo: opp9 {
+						opp-level = <RPMH_REGULATOR_LEVEL_TURBO>;
+					};
+
+					rpmhpd_opp_turbo_l1: opp10 {
+						opp-level = <RPMH_REGULATOR_LEVEL_TURBO_L1>;
+					};
+				};
+			};
 		};
 
 		intc: interrupt-controller@17a00000 {
-- 
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] 26+ messages in thread

* [PATCH v11 9/9] soc: qcom: rpmhpd: Mark mx as a parent for cx
  2019-01-10  4:02 [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845 Rajendra Nayak
                   ` (7 preceding siblings ...)
  2019-01-10  4:02 ` [PATCH v11 8/9] arm64: dts: sdm845: Add rpmh powercontroller node Rajendra Nayak
@ 2019-01-10  4:02 ` Rajendra Nayak
  2019-01-10  6:33 ` [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845 Viresh Kumar
  2019-01-17 15:03 ` Marc Gonzalez
  10 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2019-01-10  4:02 UTC (permalink / raw)
  To: andy.gross, robh, viresh.kumar, sboyd, ulf.hansson, collinsd, mka
  Cc: devicetree, linux-arm-msm, linux-kernel, henryc.chen, Rajendra Nayak

Specify the active + sleep and active-only MX power domains as
the parents of the corresponding CX power domains. This will ensure that
performance state requests on CX automatically generate equivalent requests
on MX power domains.

This is used to enforce a requirement that exists for various
hardware blocks on SDM845 that MX performance state >= CX performance
state for a given operating frequency.

Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: Stephen Boyd <swboyd@chromium.org>
Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/soc/qcom/rpmhpd.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/soc/qcom/rpmhpd.c b/drivers/soc/qcom/rpmhpd.c
index e45628694f09..4aadece0ac5a 100644
--- a/drivers/soc/qcom/rpmhpd.c
+++ b/drivers/soc/qcom/rpmhpd.c
@@ -97,12 +97,14 @@ static struct rpmhpd sdm845_cx_ao;
 static struct rpmhpd sdm845_cx = {
 	.pd = { .name = "cx", },
 	.peer = &sdm845_cx_ao,
+	.parent = &sdm845_mx.pd,
 	.res_name = "cx.lvl",
 };
 
 static struct rpmhpd sdm845_cx_ao = {
 	.pd = { .name = "cx_ao", },
 	.peer = &sdm845_cx,
+	.parent = &sdm845_mx_ao.pd,
 	.res_name = "cx.lvl",
 };
 
@@ -372,6 +374,15 @@ static int rpmhpd_probe(struct platform_device *pdev)
 		data->domains[i] = &rpmhpds[i]->pd;
 	}
 
+	/* Add subdomains */
+	for (i = 0; i < num_pds; i++) {
+		if (!rpmhpds[i])
+			continue;
+		if (rpmhpds[i]->parent)
+			pm_genpd_add_subdomain(rpmhpds[i]->parent,
+					       &rpmhpds[i]->pd);
+	}
+
 	return of_genpd_add_provider_onecell(pdev->dev.of_node, data);
 }
 
-- 
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] 26+ messages in thread

* Re: [PATCH v11 1/9] dt-bindings: opp: Introduce opp-level bindings
  2019-01-10  4:02 ` [PATCH v11 1/9] dt-bindings: opp: Introduce opp-level bindings Rajendra Nayak
@ 2019-01-10  6:26   ` Viresh Kumar
  2019-01-11 19:06   ` Stephen Boyd
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 26+ messages in thread
From: Viresh Kumar @ 2019-01-10  6:26 UTC (permalink / raw)
  To: Rajendra Nayak
  Cc: andy.gross, robh, sboyd, ulf.hansson, collinsd, mka, devicetree,
	linux-arm-msm, linux-kernel, henryc.chen

On 10-01-19, 09:32, Rajendra Nayak wrote:
> Add opp-level as an additional property in the OPP node to describe
> the performance level of the device.
> 
> On some SoCs (especially from Qualcomm and MediaTek) this value
> is communicated to a remote microprocessor by the CPU, which
> then takes some actions (like adjusting voltage values across various
> rails) based on the value passed.
> 
> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
> ---
>  Documentation/devicetree/bindings/opp/opp.txt | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/opp/opp.txt b/Documentation/devicetree/bindings/opp/opp.txt
> index c396c4c0af92..76b6c79604a5 100644
> --- a/Documentation/devicetree/bindings/opp/opp.txt
> +++ b/Documentation/devicetree/bindings/opp/opp.txt
> @@ -129,6 +129,9 @@ Optional properties:
>  - opp-microamp-<name>: Named opp-microamp property. Similar to
>    opp-microvolt-<name> property, but for microamp instead.
>  
> +- opp-level: A value representing the performance level of the device,
> +  expressed as a 32-bit integer.
> +
>  - clock-latency-ns: Specifies the maximum possible transition latency (in
>    nanoseconds) for switching to this OPP from any other OPP.

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

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

* Re: [PATCH v11 2/9] OPP: Add support for parsing the 'opp-level' property
  2019-01-10  4:02 ` [PATCH v11 2/9] OPP: Add support for parsing the 'opp-level' property Rajendra Nayak
@ 2019-01-10  6:29   ` Viresh Kumar
  2019-01-11 19:06   ` Stephen Boyd
  1 sibling, 0 replies; 26+ messages in thread
From: Viresh Kumar @ 2019-01-10  6:29 UTC (permalink / raw)
  To: Rajendra Nayak
  Cc: andy.gross, robh, sboyd, ulf.hansson, collinsd, mka, devicetree,
	linux-arm-msm, linux-kernel, henryc.chen

On 10-01-19, 09:32, Rajendra Nayak wrote:
> Now that the OPP bindings are updated to include an optional
> 'opp-level' property, add support to parse it from device tree
> and store it as part of dev_pm_opp structure.
> Also add and export an helper 'dev_pm_opp_get_level()' that can be
> used to get the level value read from device tree when present.
> 
> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
> ---
>  drivers/opp/core.c     | 18 ++++++++++++++++++
>  drivers/opp/of.c       |  2 ++
>  drivers/opp/opp.h      |  2 ++
>  include/linux/pm_opp.h |  7 +++++++
>  4 files changed, 29 insertions(+)
> 
> diff --git a/drivers/opp/core.c b/drivers/opp/core.c
> index e5507add8f04..90b78a122be9 100644
> --- a/drivers/opp/core.c
> +++ b/drivers/opp/core.c
> @@ -130,6 +130,24 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
>  }
>  EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq);
>  
> +/**
> + * dev_pm_opp_get_level() - Gets the level corresponding to an available opp
> + * @opp:	opp for which level value has to be returned for
> + *
> + * Return: level read from device tree corresponding to the opp, else
> + * return 0.
> + */
> +unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp)
> +{
> +	if (IS_ERR_OR_NULL(opp) || !opp->available) {
> +		pr_err("%s: Invalid parameters\n", __func__);
> +		return 0;
> +	}
> +
> +	return opp->level;
> +}
> +EXPORT_SYMBOL_GPL(dev_pm_opp_get_level);
> +
>  /**
>   * dev_pm_opp_is_turbo() - Returns if opp is turbo OPP or not
>   * @opp: opp for which turbo mode is being verified
> diff --git a/drivers/opp/of.c b/drivers/opp/of.c
> index 06f0f632ec47..1779f2c93291 100644
> --- a/drivers/opp/of.c
> +++ b/drivers/opp/of.c
> @@ -594,6 +594,8 @@ static struct dev_pm_opp *_opp_add_static_v2(struct opp_table *opp_table,
>  		new_opp->rate = (unsigned long)rate;
>  	}
>  
> +	of_property_read_u32(np, "opp-level", &new_opp->level);
> +
>  	/* Check if the OPP supports hardware's hierarchy of versions or not */
>  	if (!_opp_is_supported(dev, opp_table, np)) {
>  		dev_dbg(dev, "OPP not supported by hardware: %llu\n", rate);
> diff --git a/drivers/opp/opp.h b/drivers/opp/opp.h
> index e24d81497375..4458175aa661 100644
> --- a/drivers/opp/opp.h
> +++ b/drivers/opp/opp.h
> @@ -60,6 +60,7 @@ extern struct list_head opp_tables;
>   * @suspend:	true if suspend OPP
>   * @pstate: Device's power domain's performance state.
>   * @rate:	Frequency in hertz
> + * @level:	Performance level
>   * @supplies:	Power supplies voltage/current values
>   * @clock_latency_ns: Latency (in nanoseconds) of switching to this OPP's
>   *		frequency from any other OPP's frequency.
> @@ -80,6 +81,7 @@ struct dev_pm_opp {
>  	bool suspend;
>  	unsigned int pstate;
>  	unsigned long rate;
> +	unsigned int level;
>  
>  	struct dev_pm_opp_supply *supplies;
>  
> diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
> index 0a2a88e5a383..473d2c7516f0 100644
> --- a/include/linux/pm_opp.h
> +++ b/include/linux/pm_opp.h
> @@ -86,6 +86,8 @@ unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp);
>  
>  unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp);
>  
> +unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp);
> +
>  bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp);
>  
>  int dev_pm_opp_get_opp_count(struct device *dev);
> @@ -157,6 +159,11 @@ static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp)
>  	return 0;
>  }
>  
> +static inline unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp)
> +{
> +	return 0;
> +}
> +
>  static inline bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp)
>  {
>  	return false;

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>

-- 
viresh

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

* Re: [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845
  2019-01-10  4:02 [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845 Rajendra Nayak
                   ` (8 preceding siblings ...)
  2019-01-10  4:02 ` [PATCH v11 9/9] soc: qcom: rpmhpd: Mark mx as a parent for cx Rajendra Nayak
@ 2019-01-10  6:33 ` Viresh Kumar
  2019-01-16  5:52   ` Bjorn Andersson
  2019-01-17 15:03 ` Marc Gonzalez
  10 siblings, 1 reply; 26+ messages in thread
From: Viresh Kumar @ 2019-01-10  6:33 UTC (permalink / raw)
  To: Rajendra Nayak, rjw, ulf.hansson
  Cc: andy.gross, robh, sboyd, collinsd, mka, devicetree,
	linux-arm-msm, linux-kernel, henryc.chen

+Rafael

On 10-01-19, 09:32, Rajendra Nayak wrote:
> Changes in v11:
> * Updated opp-level binding description based on feedback
> from Viresh
> * Other minor fixups in 'PATCH 2/9'

>  Documentation/devicetree/bindings/opp/opp.txt |   3 +
>  .../devicetree/bindings/power/qcom,rpmpd.txt  | 145 +++++++
>  arch/arm64/boot/dts/qcom/msm8996.dtsi         |  34 ++
>  arch/arm64/boot/dts/qcom/sdm845.dtsi          |  51 +++
>  drivers/opp/core.c                            |  18 +
>  drivers/opp/of.c                              |   2 +
>  drivers/opp/opp.h                             |   2 +
>  drivers/soc/qcom/Kconfig                      |  18 +
>  drivers/soc/qcom/Makefile                     |   2 +
>  drivers/soc/qcom/rpmhpd.c                     | 402 ++++++++++++++++++
>  drivers/soc/qcom/rpmpd.c                      | 317 ++++++++++++++
>  include/dt-bindings/power/qcom-rpmpd.h        |  39 ++
>  include/linux/pm_opp.h                        |   7 +
>  13 files changed, 1040 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/power/qcom,rpmpd.txt
>  create mode 100644 drivers/soc/qcom/rpmhpd.c
>  create mode 100644 drivers/soc/qcom/rpmpd.c
>  create mode 100644 include/dt-bindings/power/qcom-rpmpd.h

Rafael/Ulf: Who should pick this series ? Should I take this via OPP
tree ?

-- 
viresh

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

* Re: [PATCH v11 1/9] dt-bindings: opp: Introduce opp-level bindings
  2019-01-10  4:02 ` [PATCH v11 1/9] dt-bindings: opp: Introduce opp-level bindings Rajendra Nayak
  2019-01-10  6:26   ` Viresh Kumar
@ 2019-01-11 19:06   ` Stephen Boyd
  2019-01-11 22:16   ` Doug Anderson
  2019-01-15 19:59   ` Rob Herring
  3 siblings, 0 replies; 26+ messages in thread
From: Stephen Boyd @ 2019-01-11 19:06 UTC (permalink / raw)
  To: Rajendra Nayak, andy.gross, collinsd, mka, robh, ulf.hansson,
	viresh.kumar
  Cc: devicetree, linux-arm-msm, linux-kernel, henryc.chen, Rajendra Nayak

Quoting Rajendra Nayak (2019-01-09 20:02:01)
> Add opp-level as an additional property in the OPP node to describe
> the performance level of the device.
> 
> On some SoCs (especially from Qualcomm and MediaTek) this value
> is communicated to a remote microprocessor by the CPU, which
> then takes some actions (like adjusting voltage values across various
> rails) based on the value passed.
> 
> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>


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

* Re: [PATCH v11 2/9] OPP: Add support for parsing the 'opp-level' property
  2019-01-10  4:02 ` [PATCH v11 2/9] OPP: Add support for parsing the 'opp-level' property Rajendra Nayak
  2019-01-10  6:29   ` Viresh Kumar
@ 2019-01-11 19:06   ` Stephen Boyd
  1 sibling, 0 replies; 26+ messages in thread
From: Stephen Boyd @ 2019-01-11 19:06 UTC (permalink / raw)
  To: Rajendra Nayak, andy.gross, collinsd, mka, robh, ulf.hansson,
	viresh.kumar
  Cc: devicetree, linux-arm-msm, linux-kernel, henryc.chen, Rajendra Nayak

Quoting Rajendra Nayak (2019-01-09 20:02:02)
> Now that the OPP bindings are updated to include an optional
> 'opp-level' property, add support to parse it from device tree
> and store it as part of dev_pm_opp structure.
> Also add and export an helper 'dev_pm_opp_get_level()' that can be
> used to get the level value read from device tree when present.
> 
> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
> ---

Reviewed-by: Stephen Boyd <swboyd@chromium.org>


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

* Re: [PATCH v11 1/9] dt-bindings: opp: Introduce opp-level bindings
  2019-01-10  4:02 ` [PATCH v11 1/9] dt-bindings: opp: Introduce opp-level bindings Rajendra Nayak
  2019-01-10  6:26   ` Viresh Kumar
  2019-01-11 19:06   ` Stephen Boyd
@ 2019-01-11 22:16   ` Doug Anderson
  2019-01-15 19:59   ` Rob Herring
  3 siblings, 0 replies; 26+ messages in thread
From: Doug Anderson @ 2019-01-11 22:16 UTC (permalink / raw)
  To: Rajendra Nayak, Rob Herring
  Cc: Andy Gross, Viresh Kumar, Stephen Boyd, Ulf Hansson,
	David Collins, Matthias Kaehlcke, devicetree, linux-arm-msm,
	LKML, henryc.chen

Hi,

On Wed, Jan 9, 2019 at 8:03 PM Rajendra Nayak <rnayak@codeaurora.org> wrote:
>
> Add opp-level as an additional property in the OPP node to describe
> the performance level of the device.
>
> On some SoCs (especially from Qualcomm and MediaTek) this value
> is communicated to a remote microprocessor by the CPU, which
> then takes some actions (like adjusting voltage values across various
> rails) based on the value passed.
>
> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
> ---
>  Documentation/devicetree/bindings/opp/opp.txt | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/Documentation/devicetree/bindings/opp/opp.txt b/Documentation/devicetree/bindings/opp/opp.txt
> index c396c4c0af92..76b6c79604a5 100644
> --- a/Documentation/devicetree/bindings/opp/opp.txt
> +++ b/Documentation/devicetree/bindings/opp/opp.txt
> @@ -129,6 +129,9 @@ Optional properties:
>  - opp-microamp-<name>: Named opp-microamp property. Similar to
>    opp-microvolt-<name> property, but for microamp instead.
>
> +- opp-level: A value representing the performance level of the device,
> +  expressed as a 32-bit integer.
> +

I like how this ended up!  :-)

Reviewed-by: Douglas Anderson <dianders@chromium.org>

...are we just waiting for Rob to weigh back in about whether he's OK
w/ this solution?

Thanks!


-Doug

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

* Re: [PATCH v11 1/9] dt-bindings: opp: Introduce opp-level bindings
  2019-01-10  4:02 ` [PATCH v11 1/9] dt-bindings: opp: Introduce opp-level bindings Rajendra Nayak
                     ` (2 preceding siblings ...)
  2019-01-11 22:16   ` Doug Anderson
@ 2019-01-15 19:59   ` Rob Herring
  3 siblings, 0 replies; 26+ messages in thread
From: Rob Herring @ 2019-01-15 19:59 UTC (permalink / raw)
  To: Rajendra Nayak
  Cc: andy.gross, robh, viresh.kumar, sboyd, ulf.hansson, collinsd,
	mka, devicetree, linux-arm-msm, linux-kernel, henryc.chen,
	Rajendra Nayak

On Thu, 10 Jan 2019 09:32:01 +0530, Rajendra Nayak wrote:
> Add opp-level as an additional property in the OPP node to describe
> the performance level of the device.
> 
> On some SoCs (especially from Qualcomm and MediaTek) this value
> is communicated to a remote microprocessor by the CPU, which
> then takes some actions (like adjusting voltage values across various
> rails) based on the value passed.
> 
> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
> ---
>  Documentation/devicetree/bindings/opp/opp.txt | 3 +++
>  1 file changed, 3 insertions(+)
> 

Reviewed-by: Rob Herring <robh@kernel.org>

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

* Re: [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845
  2019-01-10  6:33 ` [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845 Viresh Kumar
@ 2019-01-16  5:52   ` Bjorn Andersson
  2019-01-16 15:18     ` Ulf Hansson
  2019-01-17  4:24     ` Viresh Kumar
  0 siblings, 2 replies; 26+ messages in thread
From: Bjorn Andersson @ 2019-01-16  5:52 UTC (permalink / raw)
  To: Viresh Kumar
  Cc: Rajendra Nayak, rjw, ulf.hansson, andy.gross, robh, sboyd,
	collinsd, mka, devicetree, linux-arm-msm, linux-kernel,
	henryc.chen

On Wed 09 Jan 22:33 PST 2019, Viresh Kumar wrote:

> +Rafael
> 
> On 10-01-19, 09:32, Rajendra Nayak wrote:
> > Changes in v11:
> > * Updated opp-level binding description based on feedback
> > from Viresh
> > * Other minor fixups in 'PATCH 2/9'
> 
> >  Documentation/devicetree/bindings/opp/opp.txt |   3 +
> >  .../devicetree/bindings/power/qcom,rpmpd.txt  | 145 +++++++
> >  arch/arm64/boot/dts/qcom/msm8996.dtsi         |  34 ++
> >  arch/arm64/boot/dts/qcom/sdm845.dtsi          |  51 +++
> >  drivers/opp/core.c                            |  18 +
> >  drivers/opp/of.c                              |   2 +
> >  drivers/opp/opp.h                             |   2 +
> >  drivers/soc/qcom/Kconfig                      |  18 +
> >  drivers/soc/qcom/Makefile                     |   2 +
> >  drivers/soc/qcom/rpmhpd.c                     | 402 ++++++++++++++++++
> >  drivers/soc/qcom/rpmpd.c                      | 317 ++++++++++++++
> >  include/dt-bindings/power/qcom-rpmpd.h        |  39 ++
> >  include/linux/pm_opp.h                        |   7 +
> >  13 files changed, 1040 insertions(+)
> >  create mode 100644 Documentation/devicetree/bindings/power/qcom,rpmpd.txt
> >  create mode 100644 drivers/soc/qcom/rpmhpd.c
> >  create mode 100644 drivers/soc/qcom/rpmpd.c
> >  create mode 100644 include/dt-bindings/power/qcom-rpmpd.h
> 
> Rafael/Ulf: Who should pick this series ? Should I take this via OPP
> tree ?
> 

Given that the weight of the patches lies in arm-soc area it could be
favourable to just take them that way, with the one opp-patch carrying
your (Rafael's?) ack.

If you prefer otherwise, I suggest that we take patch 6 and 8 (the two
dts patches) through arm-soc and you merge the rest in your tree.

Regards,
Bjorn

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

* Re: [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845
  2019-01-16  5:52   ` Bjorn Andersson
@ 2019-01-16 15:18     ` Ulf Hansson
  2019-01-17  4:24     ` Viresh Kumar
  1 sibling, 0 replies; 26+ messages in thread
From: Ulf Hansson @ 2019-01-16 15:18 UTC (permalink / raw)
  To: Bjorn Andersson, Viresh Kumar
  Cc: Rajendra Nayak, Rafael J. Wysocki, Andy Gross, Rob Herring,
	Stephen Boyd, David Collins, Matthias Kaehlcke, DTML,
	linux-arm-msm, Linux Kernel Mailing List, henryc.chen

On Wed, 16 Jan 2019 at 06:52, Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
>
> On Wed 09 Jan 22:33 PST 2019, Viresh Kumar wrote:
>
> > +Rafael
> >
> > On 10-01-19, 09:32, Rajendra Nayak wrote:
> > > Changes in v11:
> > > * Updated opp-level binding description based on feedback
> > > from Viresh
> > > * Other minor fixups in 'PATCH 2/9'
> >
> > >  Documentation/devicetree/bindings/opp/opp.txt |   3 +
> > >  .../devicetree/bindings/power/qcom,rpmpd.txt  | 145 +++++++
> > >  arch/arm64/boot/dts/qcom/msm8996.dtsi         |  34 ++
> > >  arch/arm64/boot/dts/qcom/sdm845.dtsi          |  51 +++
> > >  drivers/opp/core.c                            |  18 +
> > >  drivers/opp/of.c                              |   2 +
> > >  drivers/opp/opp.h                             |   2 +
> > >  drivers/soc/qcom/Kconfig                      |  18 +
> > >  drivers/soc/qcom/Makefile                     |   2 +
> > >  drivers/soc/qcom/rpmhpd.c                     | 402 ++++++++++++++++++
> > >  drivers/soc/qcom/rpmpd.c                      | 317 ++++++++++++++
> > >  include/dt-bindings/power/qcom-rpmpd.h        |  39 ++
> > >  include/linux/pm_opp.h                        |   7 +
> > >  13 files changed, 1040 insertions(+)
> > >  create mode 100644 Documentation/devicetree/bindings/power/qcom,rpmpd.txt
> > >  create mode 100644 drivers/soc/qcom/rpmhpd.c
> > >  create mode 100644 drivers/soc/qcom/rpmpd.c
> > >  create mode 100644 include/dt-bindings/power/qcom-rpmpd.h
> >
> > Rafael/Ulf: Who should pick this series ? Should I take this via OPP
> > tree ?
> >
>
> Given that the weight of the patches lies in arm-soc area it could be
> favourable to just take them that way, with the one opp-patch carrying
> your (Rafael's?) ack.
>
> If you prefer otherwise, I suggest that we take patch 6 and 8 (the two
> dts patches) through arm-soc and you merge the rest in your tree.

It sure sounds easiest to funnel this though the soc maintainer tree,
unless Viresh think there are lots of additional changes to the OPP
core going in this cycle, which thus may conflict.

However, it's not my call.

Kind regards
Uffe

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

* Re: [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845
  2019-01-16  5:52   ` Bjorn Andersson
  2019-01-16 15:18     ` Ulf Hansson
@ 2019-01-17  4:24     ` Viresh Kumar
  1 sibling, 0 replies; 26+ messages in thread
From: Viresh Kumar @ 2019-01-17  4:24 UTC (permalink / raw)
  To: Bjorn Andersson
  Cc: Rajendra Nayak, rjw, ulf.hansson, andy.gross, robh, sboyd,
	collinsd, mka, devicetree, linux-arm-msm, linux-kernel,
	henryc.chen

On 15-01-19, 21:52, Bjorn Andersson wrote:
> On Wed 09 Jan 22:33 PST 2019, Viresh Kumar wrote:
> 
> > +Rafael
> > 
> > On 10-01-19, 09:32, Rajendra Nayak wrote:
> > > Changes in v11:
> > > * Updated opp-level binding description based on feedback
> > > from Viresh
> > > * Other minor fixups in 'PATCH 2/9'
> > 
> > >  Documentation/devicetree/bindings/opp/opp.txt |   3 +
> > >  .../devicetree/bindings/power/qcom,rpmpd.txt  | 145 +++++++
> > >  arch/arm64/boot/dts/qcom/msm8996.dtsi         |  34 ++
> > >  arch/arm64/boot/dts/qcom/sdm845.dtsi          |  51 +++
> > >  drivers/opp/core.c                            |  18 +
> > >  drivers/opp/of.c                              |   2 +
> > >  drivers/opp/opp.h                             |   2 +
> > >  drivers/soc/qcom/Kconfig                      |  18 +
> > >  drivers/soc/qcom/Makefile                     |   2 +
> > >  drivers/soc/qcom/rpmhpd.c                     | 402 ++++++++++++++++++
> > >  drivers/soc/qcom/rpmpd.c                      | 317 ++++++++++++++
> > >  include/dt-bindings/power/qcom-rpmpd.h        |  39 ++
> > >  include/linux/pm_opp.h                        |   7 +
> > >  13 files changed, 1040 insertions(+)
> > >  create mode 100644 Documentation/devicetree/bindings/power/qcom,rpmpd.txt
> > >  create mode 100644 drivers/soc/qcom/rpmhpd.c
> > >  create mode 100644 drivers/soc/qcom/rpmpd.c
> > >  create mode 100644 include/dt-bindings/power/qcom-rpmpd.h
> > 
> > Rafael/Ulf: Who should pick this series ? Should I take this via OPP
> > tree ?
> > 
> 
> Given that the weight of the patches lies in arm-soc area it could be
> favourable to just take them that way, with the one opp-patch carrying
> your (Rafael's?) ack.
> 
> If you prefer otherwise, I suggest that we take patch 6 and 8 (the two
> dts patches) through arm-soc and you merge the rest in your tree.

Okay, take it via arm-soc. I will ask for a branch later on if I find
more patches going for the OPP core this cycle.

-- 
viresh

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

* Re: [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845
  2019-01-10  4:02 [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845 Rajendra Nayak
                   ` (9 preceding siblings ...)
  2019-01-10  6:33 ` [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845 Viresh Kumar
@ 2019-01-17 15:03 ` Marc Gonzalez
  2019-01-18  3:54   ` Rajendra Nayak
  10 siblings, 1 reply; 26+ messages in thread
From: Marc Gonzalez @ 2019-01-17 15:03 UTC (permalink / raw)
  To: Rajendra Nayak, MSM
  Cc: Andy Gross, Viresh Kumar, Bjorn Andersson, Jeffrey Hugo, LKML

On 10/01/2019 05:02, Rajendra Nayak wrote:

> Rajendra Nayak (9):
>   dt-bindings: opp: Introduce opp-level bindings
>   OPP: Add support for parsing the 'opp-level' property
>   dt-bindings: power: Add qcom rpm power domain driver bindings
>   soc: qcom: rpmpd: Add a Power domain driver to model corners
>   soc: qcom: rpmpd: Add support for get/set performance state
>   arm64: dts: msm8996: Add rpmpd device node
>   soc: qcom: rpmhpd: Add RPMh power domain driver
>   arm64: dts: sdm845: Add rpmh powercontroller node
>   soc: qcom: rpmhpd: Mark mx as a parent for cx
> 
>  Documentation/devicetree/bindings/opp/opp.txt |   3 +
>  .../devicetree/bindings/power/qcom,rpmpd.txt  | 145 +++++++
>  arch/arm64/boot/dts/qcom/msm8996.dtsi         |  34 ++
>  arch/arm64/boot/dts/qcom/sdm845.dtsi          |  51 +++

Whenever I see these patches adding support for msm8996 (aka sdm820) and sdm845
simultaneously, I think to myself: "Why is sdm835 being left out? It was released
between sdm820 and sdm845, it cannot be /that/ different."

So I'm wondering: how much extra work would it be to add support for msm8998
aka sdm835?

Regards.

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

* Re: [PATCH v11 4/9] soc: qcom: rpmpd: Add a Power domain driver to model corners
  2019-01-10  4:02 ` [PATCH v11 4/9] soc: qcom: rpmpd: Add a Power domain driver to model corners Rajendra Nayak
@ 2019-01-17 17:42   ` Guenter Roeck
  2019-01-18  4:54     ` Rajendra Nayak
  0 siblings, 1 reply; 26+ messages in thread
From: Guenter Roeck @ 2019-01-17 17:42 UTC (permalink / raw)
  To: Rajendra Nayak
  Cc: andy.gross, robh, viresh.kumar, sboyd, ulf.hansson, collinsd,
	mka, devicetree, linux-arm-msm, linux-kernel, henryc.chen

On Thu, Jan 10, 2019 at 09:32:04AM +0530, Rajendra Nayak wrote:
> The Power domains for corners just pass the performance state set by the
> consumers to the RPM (Remote Power manager) which then takes care
> of setting the appropriate voltage on the corresponding rails to
> meet the performance needs.
> 
> We add all power domain data needed on msm8996 here. This driver can easily
> be extended by adding data for other qualcomm SoCs as well.
> 
> Signed-off-by: Rajendra Nayak <rnayak@codeaurora.org>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
> Acked-by: Rob Herring <robh@kernel.org>
> Reviewed-by: Stephen Boyd <swboyd@chromium.org>
> ---
>  drivers/soc/qcom/Kconfig  |   9 ++
>  drivers/soc/qcom/Makefile |   1 +
>  drivers/soc/qcom/rpmpd.c  | 282 ++++++++++++++++++++++++++++++++++++++
>  3 files changed, 292 insertions(+)
>  create mode 100644 drivers/soc/qcom/rpmpd.c
> 
> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
> index fcbf8a2e4080..df5cd9fa0d5e 100644
> --- a/drivers/soc/qcom/Kconfig
> +++ b/drivers/soc/qcom/Kconfig
> @@ -98,6 +98,15 @@ config QCOM_RPMH
>  	  of hardware components aggregate requests for these resources and
>  	  help apply the aggregated state on the resource.
>  
> +config QCOM_RPMPD
> +	bool "Qualcomm RPM Power domain driver"
> +	depends on MFD_QCOM_RPM && QCOM_SMD_RPM

Since this is bool, but the dependent configurations are tristate,
configurations such as arm64:allmodconfig result in

CONFIG_QCOM_RPMPD=y
CONFIG_MFD_QCOM_RPM=m
CONFIG_QCOM_SMD_RPM=m

This in turn results in

   arm-linux-gnueabi-ld: drivers/soc/qcom/rpmpd.o: in function `rpmpd_send_enable': 
>> rpmpd.c:(.text+0x64): undefined reference to `qcom_rpm_smd_write' 
   arm-linux-gnueabi-ld: drivers/soc/qcom/rpmpd.o: in function `rpmpd_power_on': 
   rpmpd.c:(.text+0x408): undefined reference to `qcom_rpm_smd_write' 
>> arm-linux-gnueabi-ld: rpmpd.c:(.text+0x460): undefined reference to `qcom_rpm_smd_write' 

as reported by 0day.

Either this needs to change to tristate, or the dependency must be
	depends on MFD_QCOM_RPM=y && QCOM_SMD_RPM=y

Guenter

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

* Re: [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845
  2019-01-17 15:03 ` Marc Gonzalez
@ 2019-01-18  3:54   ` Rajendra Nayak
  2019-01-18 10:17     ` Marc Gonzalez
  0 siblings, 1 reply; 26+ messages in thread
From: Rajendra Nayak @ 2019-01-18  3:54 UTC (permalink / raw)
  To: Marc Gonzalez, MSM
  Cc: Andy Gross, Viresh Kumar, Bjorn Andersson, Jeffrey Hugo, LKML



On 1/17/2019 8:33 PM, Marc Gonzalez wrote:
> On 10/01/2019 05:02, Rajendra Nayak wrote:
> 
>> Rajendra Nayak (9):
>>    dt-bindings: opp: Introduce opp-level bindings
>>    OPP: Add support for parsing the 'opp-level' property
>>    dt-bindings: power: Add qcom rpm power domain driver bindings
>>    soc: qcom: rpmpd: Add a Power domain driver to model corners
>>    soc: qcom: rpmpd: Add support for get/set performance state
>>    arm64: dts: msm8996: Add rpmpd device node
>>    soc: qcom: rpmhpd: Add RPMh power domain driver
>>    arm64: dts: sdm845: Add rpmh powercontroller node
>>    soc: qcom: rpmhpd: Mark mx as a parent for cx
>>
>>   Documentation/devicetree/bindings/opp/opp.txt |   3 +
>>   .../devicetree/bindings/power/qcom,rpmpd.txt  | 145 +++++++
>>   arch/arm64/boot/dts/qcom/msm8996.dtsi         |  34 ++
>>   arch/arm64/boot/dts/qcom/sdm845.dtsi          |  51 +++
> 
> Whenever I see these patches adding support for msm8996 (aka sdm820) and sdm845
> simultaneously, I think to myself: "Why is sdm835 being left out? It was released
> between sdm820 and sdm845, it cannot be /that/ different."

It isn't that different, and it should be quite straight forward to add support for it
with the rpmpd driver (the rpmhpd is for platforms sdm845 and beyond which use rpmh)

When I started working on these patches, support for sdm835 upstream was non-existent
so I started off with what was the better supported one which was the 820 (msm8996).

-- 
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] 26+ messages in thread

* Re: [PATCH v11 4/9] soc: qcom: rpmpd: Add a Power domain driver to model corners
  2019-01-17 17:42   ` Guenter Roeck
@ 2019-01-18  4:54     ` Rajendra Nayak
  0 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2019-01-18  4:54 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: andy.gross, robh, viresh.kumar, sboyd, ulf.hansson, collinsd,
	mka, devicetree, linux-arm-msm, linux-kernel, henryc.chen

[]..

>>
>> diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig
>> index fcbf8a2e4080..df5cd9fa0d5e 100644
>> --- a/drivers/soc/qcom/Kconfig
>> +++ b/drivers/soc/qcom/Kconfig
>> @@ -98,6 +98,15 @@ config QCOM_RPMH
>>   	  of hardware components aggregate requests for these resources and
>>   	  help apply the aggregated state on the resource.
>>   
>> +config QCOM_RPMPD
>> +	bool "Qualcomm RPM Power domain driver"
>> +	depends on MFD_QCOM_RPM && QCOM_SMD_RPM
> 
> Since this is bool, but the dependent configurations are tristate,
> configurations such as arm64:allmodconfig result in
> 
> CONFIG_QCOM_RPMPD=y
> CONFIG_MFD_QCOM_RPM=m
> CONFIG_QCOM_SMD_RPM=m
> 
> This in turn results in
> 
>     arm-linux-gnueabi-ld: drivers/soc/qcom/rpmpd.o: in function `rpmpd_send_enable':
>>> rpmpd.c:(.text+0x64): undefined reference to `qcom_rpm_smd_write'
>     arm-linux-gnueabi-ld: drivers/soc/qcom/rpmpd.o: in function `rpmpd_power_on':
>     rpmpd.c:(.text+0x408): undefined reference to `qcom_rpm_smd_write'
>>> arm-linux-gnueabi-ld: rpmpd.c:(.text+0x460): undefined reference to `qcom_rpm_smd_write'
> 
> as reported by 0day.

Thanks for reporting this, the QCOM_RPMPD dependency on MFD_QCOM_RPM was removed
by a patch on top from Bjorn [1]. I have posted a fix now [2] to make QCOM_RPMPD
depend on QCOM_SMD_RPM=y

[1] https://lkml.org/lkml/2019/1/17/5
[2] https://lkml.org/lkml/2019/1/17/1043

-- 
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] 26+ messages in thread

* Re: [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845
  2019-01-18  3:54   ` Rajendra Nayak
@ 2019-01-18 10:17     ` Marc Gonzalez
  2019-01-21  9:20       ` Rajendra Nayak
  0 siblings, 1 reply; 26+ messages in thread
From: Marc Gonzalez @ 2019-01-18 10:17 UTC (permalink / raw)
  To: Rajendra Nayak, MSM
  Cc: Andy Gross, Viresh Kumar, Bjorn Andersson, Jeffrey Hugo, LKML

On 18/01/2019 04:54, Rajendra Nayak wrote:

> On 1/17/2019 8:33 PM, Marc Gonzalez wrote:
> 
>> On 10/01/2019 05:02, Rajendra Nayak wrote:
>>
>>> Rajendra Nayak (9):
>>>    dt-bindings: opp: Introduce opp-level bindings
>>>    OPP: Add support for parsing the 'opp-level' property
>>>    dt-bindings: power: Add qcom rpm power domain driver bindings
>>>    soc: qcom: rpmpd: Add a Power domain driver to model corners
>>>    soc: qcom: rpmpd: Add support for get/set performance state
>>>    arm64: dts: msm8996: Add rpmpd device node
>>>    soc: qcom: rpmhpd: Add RPMh power domain driver
>>>    arm64: dts: sdm845: Add rpmh powercontroller node
>>>    soc: qcom: rpmhpd: Mark mx as a parent for cx
>>>
>>>   Documentation/devicetree/bindings/opp/opp.txt |   3 +
>>>   .../devicetree/bindings/power/qcom,rpmpd.txt  | 145 +++++++
>>>   arch/arm64/boot/dts/qcom/msm8996.dtsi         |  34 ++
>>>   arch/arm64/boot/dts/qcom/sdm845.dtsi          |  51 +++
>>
>> Whenever I see these patches adding support for msm8996 (aka sdm820) and sdm845
>> simultaneously, I think to myself: "Why is sdm835 being left out? It was released
>> between sdm820 and sdm845, it cannot be /that/ different."
> 
> It isn't that different, and it should be quite straight forward to add support for it
> with the rpmpd driver (the rpmhpd is for platforms sdm845 and beyond which use rpmh)
> 
> When I started working on these patches, support for sdm835 upstream was non-existent
> so I started off with what was the better supported one which was the 820 (msm8996).

Once you land this patch series, could you take a quick look at how much work is needed
to add msm8998 support? I'm betting it would take you only a few hours.

Regards.

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

* Re: [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845
  2019-01-18 10:17     ` Marc Gonzalez
@ 2019-01-21  9:20       ` Rajendra Nayak
  0 siblings, 0 replies; 26+ messages in thread
From: Rajendra Nayak @ 2019-01-21  9:20 UTC (permalink / raw)
  To: Marc Gonzalez, MSM
  Cc: Andy Gross, Viresh Kumar, Bjorn Andersson, Jeffrey Hugo, LKML



On 1/18/2019 3:47 PM, Marc Gonzalez wrote:
> On 18/01/2019 04:54, Rajendra Nayak wrote:
> 
>> On 1/17/2019 8:33 PM, Marc Gonzalez wrote:
>>
>>> On 10/01/2019 05:02, Rajendra Nayak wrote:
>>>
>>>> Rajendra Nayak (9):
>>>>     dt-bindings: opp: Introduce opp-level bindings
>>>>     OPP: Add support for parsing the 'opp-level' property
>>>>     dt-bindings: power: Add qcom rpm power domain driver bindings
>>>>     soc: qcom: rpmpd: Add a Power domain driver to model corners
>>>>     soc: qcom: rpmpd: Add support for get/set performance state
>>>>     arm64: dts: msm8996: Add rpmpd device node
>>>>     soc: qcom: rpmhpd: Add RPMh power domain driver
>>>>     arm64: dts: sdm845: Add rpmh powercontroller node
>>>>     soc: qcom: rpmhpd: Mark mx as a parent for cx
>>>>
>>>>    Documentation/devicetree/bindings/opp/opp.txt |   3 +
>>>>    .../devicetree/bindings/power/qcom,rpmpd.txt  | 145 +++++++
>>>>    arch/arm64/boot/dts/qcom/msm8996.dtsi         |  34 ++
>>>>    arch/arm64/boot/dts/qcom/sdm845.dtsi          |  51 +++
>>>
>>> Whenever I see these patches adding support for msm8996 (aka sdm820) and sdm845
>>> simultaneously, I think to myself: "Why is sdm835 being left out? It was released
>>> between sdm820 and sdm845, it cannot be /that/ different."
>>
>> It isn't that different, and it should be quite straight forward to add support for it
>> with the rpmpd driver (the rpmhpd is for platforms sdm845 and beyond which use rpmh)
>>
>> When I started working on these patches, support for sdm835 upstream was non-existent
>> so I started off with what was the better supported one which was the 820 (msm8996).
> 
> Once you land this patch series, could you take a quick look at how much work is needed
> to add msm8998 support? I'm betting it would take you only a few hours.

Sure, I can take a look. I think I do have a 8998 device which I can probably do
some testing on too.

-- 
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] 26+ messages in thread

end of thread, back to index

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-10  4:02 [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845 Rajendra Nayak
2019-01-10  4:02 ` [PATCH v11 1/9] dt-bindings: opp: Introduce opp-level bindings Rajendra Nayak
2019-01-10  6:26   ` Viresh Kumar
2019-01-11 19:06   ` Stephen Boyd
2019-01-11 22:16   ` Doug Anderson
2019-01-15 19:59   ` Rob Herring
2019-01-10  4:02 ` [PATCH v11 2/9] OPP: Add support for parsing the 'opp-level' property Rajendra Nayak
2019-01-10  6:29   ` Viresh Kumar
2019-01-11 19:06   ` Stephen Boyd
2019-01-10  4:02 ` [PATCH v11 3/9] dt-bindings: power: Add qcom rpm power domain driver bindings Rajendra Nayak
2019-01-10  4:02 ` [PATCH v11 4/9] soc: qcom: rpmpd: Add a Power domain driver to model corners Rajendra Nayak
2019-01-17 17:42   ` Guenter Roeck
2019-01-18  4:54     ` Rajendra Nayak
2019-01-10  4:02 ` [PATCH v11 5/9] soc: qcom: rpmpd: Add support for get/set performance state Rajendra Nayak
2019-01-10  4:02 ` [PATCH v11 6/9] arm64: dts: msm8996: Add rpmpd device node Rajendra Nayak
2019-01-10  4:02 ` [PATCH v11 7/9] soc: qcom: rpmhpd: Add RPMh power domain driver Rajendra Nayak
2019-01-10  4:02 ` [PATCH v11 8/9] arm64: dts: sdm845: Add rpmh powercontroller node Rajendra Nayak
2019-01-10  4:02 ` [PATCH v11 9/9] soc: qcom: rpmhpd: Mark mx as a parent for cx Rajendra Nayak
2019-01-10  6:33 ` [PATCH v11 0/9] Add power domain driver for corners on msm8996/sdm845 Viresh Kumar
2019-01-16  5:52   ` Bjorn Andersson
2019-01-16 15:18     ` Ulf Hansson
2019-01-17  4:24     ` Viresh Kumar
2019-01-17 15:03 ` Marc Gonzalez
2019-01-18  3:54   ` Rajendra Nayak
2019-01-18 10:17     ` Marc Gonzalez
2019-01-21  9:20       ` Rajendra Nayak

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org linux-kernel@archiver.kernel.org
	public-inbox-index lkml


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox