Skip to contentSkip to conversation

Add power domain driver for corners on msm8996/sdm845

PATCH Superseded Rajendra Nayak 5 participants 22 messages Dec 4, 2018 – Dec 7, 2018

Subsystems (4)

v5 of 11 Superseded Latest is v11 →

lore
Share & tools
lore
#0 lore raw

v5 cover Add power domain driver for corners on msm8996/sdm845

Hi Rob,

This series is mainly pending your review/ack for the DT parts. Rest of the genpd parts are reviewed and acked by both Viresh and Ulf.

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 (8):
dt-bindings: opp: Introduce qcom-opp bindings
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

 .../devicetree/bindings/opp/qcom-opp.txt      |  25 +
 .../devicetree/bindings/power/qcom,rpmpd.txt  | 146 ++++++
 arch/arm64/boot/dts/qcom/msm8996.dtsi         |  34 ++
 arch/arm64/boot/dts/qcom/sdm845.dtsi          |  51 ++
 drivers/soc/qcom/Kconfig                      |  18 +
 drivers/soc/qcom/Makefile                     |   2 +
 drivers/soc/qcom/rpmhpd.c                     | 442 ++++++++++++++++++
 drivers/soc/qcom/rpmpd.c                      | 340 ++++++++++++++
 include/dt-bindings/power/qcom-rpmpd.h        |  39 ++
 9 files changed, 1097 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/opp/qcom-opp.txt
 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
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#1 lore raw

PATCH v5 1/8 dt-bindings: opp: Introduce qcom-opp bindings

On Qualcomm Technologies, Inc. platforms, an OPP node needs to describe an additional level/corner value that is then 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.

Describe these bindings in the qcom-opp bindings document.

---
 .../devicetree/bindings/opp/qcom-opp.txt      | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/opp/qcom-opp.txt
Documentation/devicetree/bindings/opp/qcom-opp.txt new file +25 -0
new file mode 100644
index 000000000000..db4d970c7ec7
@@ -0,0 +1,25 @@
+Qualcomm OPP bindings to descibe OPP nodes with corner/level values
+
+OPP tables for devices on Qualcomm platforms require an additional
+platform specific corner/level value to be specified.
+This value is passed on to the RPM (Resource Power Manager) by
+the CPU, which then takes the necessary actions to set a voltage
+rail to an appropriate voltage based on the value passed.
+
+The bindings are based on top of the operating-points-v2 bindings
+described in Documentation/devicetree/bindings/opp/opp.txt
+Additional properties are described below.
+
+* OPP Table Node
+
+Required properties:
+- compatible: Allow OPPs to express their compatibility. It should be:
+  "operating-points-v2-qcom-level"
+
+* OPP Node
+
+Required properties:
+- qcom,level: On Qualcomm platforms an OPP node can describe a positive value
+representing a corner/level that's communicated with a remote microprocessor
+(usually called the RPM) which then translates it into a certain voltage on
+a voltage rail.
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#4 lore raw

PATCH v5 2/8 dt-bindings: power: Add qcom rpm power domain driver bindings

In reply to 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.

---
 .../devicetree/bindings/power/qcom,rpmpd.txt  | 146 ++++++++++++++++++
 include/dt-bindings/power/qcom-rpmpd.h        |  39 +++++
 2 files changed, 185 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/qcom,rpmpd.txt
 create mode 100644 include/dt-bindings/power/qcom-rpmpd.h
Documentation/devicetree/bindings/power/qcom,rpmpd.txt new file +146 -0
new file mode 100644
index 000000000000..aa02f8573dd4
@@ -0,0 +1,146 @@
+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/qcom-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>
+
+qcom,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-qcom-level";
+
+		rpmhpd_opp_ret: opp1 {
+			qcom,level = <RPMH_REGULATOR_LEVEL_RETENTION>;
+		};
+
+		rpmhpd_opp_min_svs: opp2 {
+			qcom,level = <RPMH_REGULATOR_LEVEL_MIN_SVS>;
+		};
+
+		rpmhpd_opp_low_svs: opp3 {
+			qcom,level = <RPMH_REGULATOR_LEVEL_LOW_SVS>;
+		};
+
+		rpmhpd_opp_svs: opp4 {
+			qcom,level = <RPMH_REGULATOR_LEVEL_SVS>;
+		};
+
+		rpmhpd_opp_svs_l1: opp5 {
+			qcom,level = <RPMH_REGULATOR_LEVEL_SVS_L1>;
+		};
+
+		rpmhpd_opp_nom: opp6 {
+			qcom,level = <RPMH_REGULATOR_LEVEL_NOM>;
+		};
+
+		rpmhpd_opp_nom_l1: opp7 {
+			qcom,level = <RPMH_REGULATOR_LEVEL_NOM_L1>;
+		};
+
+		rpmhpd_opp_nom_l2: opp8 {
+			qcom,level = <RPMH_REGULATOR_LEVEL_NOM_L2>;
+		};
+
+		rpmhpd_opp_turbo: opp9 {
+			qcom,level = <RPMH_REGULATOR_LEVEL_TURBO>;
+		};
+
+		rpmhpd_opp_turbo_l1: opp10 {
+			qcom,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-qcom-level";
+
+		rpmpd_opp_low: opp1 {
+			qcom,level = <1>;
+		};
+
+		rpmpd_opp_ret: opp2 {
+			qcom,level = <2>;
+		};
+
+		rpmpd_opp_svs: opp3 {
+			qcom,level = <3>;
+		};
+
+		rpmpd_opp_normal: opp4 {
+			qcom,level = <4>;
+		};
+
+		rpmpd_opp_high: opp5 {
+			qcom,level = <5>;
+		};
+
+		rpmpd_opp_turbo: opp6 {
+			qcom,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>;
+		};
+
+	};
include/dt-bindings/power/qcom-rpmpd.h new file +39 -0
new file mode 100644
index 000000000000..87d9c6611682
@@ -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
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#5 lore raw

PATCH v5 3/8 soc: qcom: rpmpd: Add a Power domain driver to model corners

In reply to 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.

---
 drivers/soc/qcom/Kconfig  |   9 ++
 drivers/soc/qcom/Makefile |   1 +
 drivers/soc/qcom/rpmpd.c  | 294 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 304 insertions(+)
 create mode 100644 drivers/soc/qcom/rpmpd.c
drivers/soc/qcom/Kconfig +9 -0
index 684cb51694d1..e9b60695f6e7 100644
@@ -103,6 +103,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
drivers/soc/qcom/Makefile +1 -0
index f25b54cd6cf8..f1b25fdcf2ad 100644
@@ -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
drivers/soc/qcom/rpmpd.c new file +294 -0

294 lines not on this page · raw message

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#8 lore raw

PATCH v5 4/8 soc: qcom: rpmpd: Add support for get/set performance state

In reply to Rajendra Nayak

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

---
 drivers/soc/qcom/rpmpd.c | 46 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
drivers/soc/qcom/rpmpd.c +46 -0
index a0b9f122d793..eb1cfa6a03d6 100644
@@ -12,6 +12,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>
@@ -28,6 +29,8 @@
 #define KEY_ENABLE		0x6e657773 /* swen */
 #define KEY_FLOOR_CORNER	0x636676   /* vfc */
 
+#define MAX_RPMPD_STATE		6
+
 #define DEFINE_RPMPD_CORN_SMPA(_platform, _name, _active, r_id)		\
 	static struct rpmpd _platform##_##_active;			\
 	static struct rpmpd _platform##_##_name = {			\
@@ -221,6 +224,47 @@ 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);
+
+	mutex_lock(&rpmpd_lock);
+
+	if (state > MAX_RPMPD_STATE)
+		goto out;
+
+	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)
+{
+	struct device_node *np;
+	unsigned int corner = 0;
+
+	np = dev_pm_opp_get_of_node(opp);
+	if (of_property_read_u32(np, "qcom,level", &corner)) {
+		pr_err("%s: missing 'qcom,level' property\n", __func__);
+		return 0;
+	}
+
+	of_node_put(np);
+
+	return corner;
+}
+
 static int rpmpd_probe(struct platform_device *pdev)
 {
 	int i;
@@ -261,6 +305,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;
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#13 lore raw

PATCH v5 5/8 arm64: dts: msm8996: Add rpmpd device node

In reply to Rajendra Nayak

Add rpmpd device node and its OPP table

---
 arch/arm64/boot/dts/qcom/msm8996.dtsi | 34 +++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
arch/arm64/boot/dts/qcom/msm8996.dtsi +34 -0
index b29fe80d7288..ed35f0ced699 100644
@@ -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-qcom-level";
+
+				rpmpd_opp1: opp1 {
+					qcom,level = <1>;
+				};
+
+				rpmpd_opp2: opp2 {
+					qcom,level = <2>;
+				};
+
+				rpmpd_opp3: opp3 {
+					qcom,level = <3>;
+				};
+
+				rpmpd_opp4: opp4 {
+					qcom,level = <4>;
+				};
+
+				rpmpd_opp5: opp5 {
+					qcom,level = <5>;
+				};
+
+				rpmpd_opp6: opp6 {
+					qcom,level = <6>;
+				};
+			};
+
 			pm8994-regulators {
 				compatible = "qcom,rpm-pm8994-regulators";
 
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#14 lore raw

PATCH v5 6/8 soc: qcom: rpmhpd: Add RPMh Power domain driver

In reply to 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

---
 drivers/soc/qcom/Kconfig  |   9 +
 drivers/soc/qcom/Makefile |   1 +
 drivers/soc/qcom/rpmhpd.c | 431 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 441 insertions(+)
 create mode 100644 drivers/soc/qcom/rpmhpd.c
drivers/soc/qcom/Kconfig +9 -0
index e9b60695f6e7..a51458022d21 100644
@@ -103,6 +103,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
drivers/soc/qcom/Makefile +1 -0
index f1b25fdcf2ad..dd6ca92985ee 100644
@@ -22,3 +22,4 @@ 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
+obj-$(CONFIG_QCOM_RPMHPD) += rpmhpd.o
drivers/soc/qcom/rpmhpd.c new file +431 -0

431 lines not on this page · raw message

Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#15 lore raw

PATCH v5 7/8 arm64: dts: sdm845: Add rpmh powercontroller node

In reply to Rajendra Nayak

Add the DT node for the rpmhpd powercontroller.

---
 arch/arm64/boot/dts/qcom/sdm845.dtsi | 51 ++++++++++++++++++++++++++++
 1 file changed, 51 insertions(+)
arch/arm64/boot/dts/qcom/sdm845.dtsi +51 -0
index b72bdb0a31a5..a6d0cd8d17b0 100644
@@ -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>
 
@@ -1324,6 +1325,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-qcom-level";
+
+				rpmhpd_opp_ret: opp1 {
+					qcom,level = <RPMH_REGULATOR_LEVEL_RETENTION>;
+				};
+
+				rpmhpd_opp_min_svs: opp2 {
+					qcom,level = <RPMH_REGULATOR_LEVEL_MIN_SVS>;
+				};
+
+				rpmhpd_opp_low_svs: opp3 {
+					qcom,level = <RPMH_REGULATOR_LEVEL_LOW_SVS>;
+				};
+
+				rpmhpd_opp_svs: opp4 {
+					qcom,level = <RPMH_REGULATOR_LEVEL_SVS>;
+				};
+
+				rpmhpd_opp_svs_l1: opp5 {
+					qcom,level = <RPMH_REGULATOR_LEVEL_SVS_L1>;
+				};
+
+				rpmhpd_opp_nom: opp6 {
+					qcom,level = <RPMH_REGULATOR_LEVEL_NOM>;
+				};
+
+				rpmhpd_opp_nom_l1: opp7 {
+					qcom,level = <RPMH_REGULATOR_LEVEL_NOM_L1>;
+				};
+
+				rpmhpd_opp_nom_l2: opp8 {
+					qcom,level = <RPMH_REGULATOR_LEVEL_NOM_L2>;
+				};
+
+				rpmhpd_opp_turbo: opp9 {
+					qcom,level = <RPMH_REGULATOR_LEVEL_TURBO>;
+				};
+
+				rpmhpd_opp_turbo_l1: opp10 {
+					qcom,level = <RPMH_REGULATOR_LEVEL_TURBO_L1>;
+				};
+			};
 		};
 
 		intc: interrupt-controller@17a00000 {
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
#20 lore raw

PATCH v5 8/8 soc: qcom: rpmhpd: Mark mx as a parent for cx

In reply to 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.

---
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.

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

 drivers/soc/qcom/rpmhpd.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
drivers/soc/qcom/rpmhpd.c +11 -0
index 10b45b4f4588..6624c9c56b2e 100644
@@ -104,12 +104,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",
 };
 
@@ -403,6 +405,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);
 }
 
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member
of Code Aurora Forum, hosted by The Linux Foundation
Acked-by on v5 8/8
#21 lore raw

Re: [PATCH v5 8/8] soc: qcom: rpmhpd: Mark mx as a parent for cx

In reply to Rajendra Nayak
Quoted 15 lines · 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.

---
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.

Quoted 4 lines

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

 drivers/soc/qcom/rpmhpd.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
Signature · 1 line
viresh
Reviewed-by on v5 1/8
#2 lore raw

Re: [PATCH v5 1/8] dt-bindings: opp: Introduce qcom-opp bindings

In reply to Rajendra Nayak

Quoting Rajendra Nayak (2018-12-03 21:21:12)

Quoted 11 lines

On Qualcomm Technologies, Inc. platforms, an OPP node needs to describe an additional level/corner value that is then 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.

Describe these bindings in the qcom-opp bindings document.

---

maintainer
#6 lore raw

Re: [PATCH v5 3/8] soc: qcom: rpmpd: Add a Power domain driver to model corners

In reply to Rajendra Nayak

Overall looks good to me, just some nitpicks around modules and includes.

Quoting Rajendra Nayak (2018-12-03 21:21:14)

Quoted 8 lines

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.

Why is "Power" capitalized in power domain?

Quoted 15 lines
drivers/soc/qcom/Makefile +1 -0
index f25b54cd6cf8..f1b25fdcf2ad 100644
@@ -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
drivers/soc/qcom/rpmpd.c new file +0 -0
new file mode 100644
index 000000000000..a0b9f122d793

drivers/soc/qcom/rpmpd.c line 5

Quoted 5 lines
drivers/soc/qcom/rpmpd.c new file +5 -0
@@ -0,0 +1,294 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. */
+
+#include <linux/err.h>
+#include <linux/export.h>

And what is exported?

drivers/soc/qcom/rpmpd.c line 8

Quoted 3 lines
drivers/soc/qcom/rpmpd.c new file +3 -0
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>

Is it a module? It's only bool so I don't think so.

Quoted 82 lines
drivers/soc/qcom/rpmpd.c new file +82 -0
+#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_CORN_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_CORN_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 {

drivers/soc/qcom/rpmpd.c line 100

Quoted 10 lines
drivers/soc/qcom/rpmpd.c new file +10 -0
+       struct rpmpd **rpmpds;
+       size_t num_pds;
+};
+
+static DEFINE_MUTEX(rpmpd_lock);
+
+/* msm8996 RPM Power domains */
+DEFINE_RPMPD_CORN_SMPA(msm8996, vddcx, vddcx_ao, 1);
+DEFINE_RPMPD_CORN_SMPA(msm8996, vddmx, vddmx_ao, 2);
+DEFINE_RPMPD_CORN_LDOA(msm8996, vddsscx, 26);

Mmm.. CORN...

Quoted 14 lines
drivers/soc/qcom/rpmpd.c new file +14 -0
+
+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,
+};
+

[...]

drivers/soc/qcom/rpmpd.c line 275

Quoted 9 lines
drivers/soc/qcom/rpmpd.c new file +9 -0
+       }
+
+       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 attributes here?

drivers/soc/qcom/rpmpd.c line 277

Quoted 2 lines
drivers/soc/qcom/rpmpd.c new file +2 -0
+       },
+       .probe = rpmpd_probe,

Because there isn't a remove function to tear down the genpds.

Quoted 7 lines
drivers/soc/qcom/rpmpd.c new file +7 -0
+};
+
+static int __init rpmpd_init(void)
+{
+       return platform_driver_register(&rpmpd_driver);
+}
+core_initcall(rpmpd_init);

drivers/soc/qcom/rpmpd.c line 294

Quoted 10 lines
drivers/soc/qcom/rpmpd.c new file +10 -0
+
+static void __exit rpmpd_exit(void)
+{
+       platform_driver_unregister(&rpmpd_driver);
+}
+module_exit(rpmpd_exit);
+
+MODULE_DESCRIPTION("Qualcomm Technologies, Inc. RPM Power Domain Driver");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:qcom-rpmpd");

Is this MODULE_ALIAS required? I thought this wasn't useful because it's auto-generated or something like that. Also, this is bool so these can all go away unless it becomes tristate.

maintainer
#9 lore raw

Re: [PATCH v5 4/8] soc: qcom: rpmpd: Add support for get/set performance state

In reply to Rajendra Nayak

Quoting Rajendra Nayak (2018-12-03 21:21:15)

Quoted 4 lines
drivers/soc/qcom/rpmpd.c +0 -0
@@ -221,6 +224,47 @@ static int rpmpd_power_off(struct generic_pm_domain *domain)
        return ret;
 }
 

drivers/soc/qcom/rpmpd.c static int rpmpd_power_off(struct generic_pm_domain *domain) · line 236

Quoted 10 lines
drivers/soc/qcom/rpmpd.c +10 -0
+static int rpmpd_set_performance(struct generic_pm_domain *domain,
+                                unsigned int state)
+{
+       int ret = 0;
+       struct rpmpd *pd = domain_to_rpmpd(domain);
+
+       mutex_lock(&rpmpd_lock);
+
+       if (state > MAX_RPMPD_STATE)
+               goto out;

Does this need to be under the mutex lock? Doesn't look like it.

drivers/soc/qcom/rpmpd.c static int rpmpd_power_off(struct generic_pm_domain *domain) · line 240

Quoted 4 lines
drivers/soc/qcom/rpmpd.c +4 -0
+
+       pd->corner = state;
+
+       if (!pd->enabled && (pd->key != KEY_FLOOR_CORNER))

Please drop useless parenthesis.

Quoted 9 lines
drivers/soc/qcom/rpmpd.c +9 -0
+               goto out;
+
+       ret = rpmpd_aggregate_corner(pd);
+
+out:
+       mutex_unlock(&rpmpd_lock);
+
+       return ret;
+}

drivers/soc/qcom/rpmpd.c static int rpmpd_power_off(struct generic_pm_domain *domain) · line 259

Quoted 10 lines
drivers/soc/qcom/rpmpd.c +10 -0
+
+static unsigned int rpmpd_get_performance(struct generic_pm_domain *genpd,
+                                         struct dev_pm_opp *opp)
+{
+       struct device_node *np;
+       unsigned int corner = 0;
+
+       np = dev_pm_opp_get_of_node(opp);
+       if (of_property_read_u32(np, "qcom,level", &corner)) {
+               pr_err("%s: missing 'qcom,level' property\n", __func__);

We leak np reference here, assuming dev_pm_opp_get_of_node() returns an of_node_get() pointer to the caller.

drivers/soc/qcom/rpmpd.c static int rpmpd_power_off(struct generic_pm_domain *domain) · line 263

Quoted 4 lines
drivers/soc/qcom/rpmpd.c +4 -0
+               return 0;
+       }
+
+       of_node_put(np);

This same code exists twice. Perhaps a helper needs to exist for qcom_rpm_get_performance() to pull the number out of the DT.

Quoted 3 lines
drivers/soc/qcom/rpmpd.c +3 -0
+
+       return corner;
+}
maintainer
#17 lore raw

Re: [PATCH v5 7/8] arm64: dts: sdm845: Add rpmh powercontroller node

In reply to Rajendra Nayak

Quoting Rajendra Nayak (2018-12-03 21:21:18)

Quoted 6 lines
arch/arm64/boot/dts/qcom/sdm845.dtsi +0 -0
index b72bdb0a31a5..a6d0cd8d17b0 100644
@@ -1324,6 +1325,56 @@
                                compatible = "qcom,sdm845-rpmh-clk";

arch/arm64/boot/dts/qcom/sdm845.dtsi line 1335

Quoted 10 lines
arch/arm64/boot/dts/qcom/sdm845.dtsi +8 -0
                                #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 {

This table should go somewhere else? I don't understand why it's in the rpmh node because it's not an rpmh device. Does it go to the root? Or does it go under rpmhpd itself? I'm not sure.

#7 lore raw

Re: [PATCH v5 3/8] soc: qcom: rpmpd: Add a Power domain driver to model corners

In reply to Stephen Boyd
Quoted 2 lines · Stephen Boyd

Overall looks good to me, just some nitpicks around modules and includes.

Thanks for the review, I will fix up all your concerns below and respin soon.

Quoted 191 lines

Quoting Rajendra Nayak (2018-12-03 21:21:14)

Quoted 8 lines

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.

Why is "Power" capitalized in power domain?

Quoted 15 lines
drivers/soc/qcom/Makefile +1 -0
index f25b54cd6cf8..f1b25fdcf2ad 100644
@@ -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
drivers/soc/qcom/rpmpd.c new file +0 -0
new file mode 100644
index 000000000000..a0b9f122d793

drivers/soc/qcom/rpmpd.c line 5

Quoted 5 lines
drivers/soc/qcom/rpmpd.c new file +5 -0
@@ -0,0 +1,294 @@
+// SPDX-License-Identifier: GPL-2.0
+/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. */
+
+#include <linux/err.h>
+#include <linux/export.h>

And what is exported?

drivers/soc/qcom/rpmpd.c line 8

Quoted 3 lines
drivers/soc/qcom/rpmpd.c new file +3 -0
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/module.h>

Is it a module? It's only bool so I don't think so.

Quoted 82 lines
drivers/soc/qcom/rpmpd.c new file +82 -0
+#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_CORN_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_CORN_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 {

drivers/soc/qcom/rpmpd.c line 100

Quoted 10 lines
drivers/soc/qcom/rpmpd.c new file +10 -0
+       struct rpmpd **rpmpds;
+       size_t num_pds;
+};
+
+static DEFINE_MUTEX(rpmpd_lock);
+
+/* msm8996 RPM Power domains */
+DEFINE_RPMPD_CORN_SMPA(msm8996, vddcx, vddcx_ao, 1);
+DEFINE_RPMPD_CORN_SMPA(msm8996, vddmx, vddmx_ao, 2);
+DEFINE_RPMPD_CORN_LDOA(msm8996, vddsscx, 26);

Mmm.. CORN...

Quoted 14 lines
drivers/soc/qcom/rpmpd.c new file +14 -0
+
+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,
+};
+

[...]

drivers/soc/qcom/rpmpd.c line 275

Quoted 9 lines
drivers/soc/qcom/rpmpd.c new file +9 -0
+       }
+
+       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 attributes here?

drivers/soc/qcom/rpmpd.c line 277

Quoted 2 lines
drivers/soc/qcom/rpmpd.c new file +2 -0
+       },
+       .probe = rpmpd_probe,

Because there isn't a remove function to tear down the genpds.

Quoted 7 lines
drivers/soc/qcom/rpmpd.c new file +7 -0
+};
+
+static int __init rpmpd_init(void)
+{
+       return platform_driver_register(&rpmpd_driver);
+}
+core_initcall(rpmpd_init);

drivers/soc/qcom/rpmpd.c line 294

Quoted 10 lines
drivers/soc/qcom/rpmpd.c new file +10 -0
+
+static void __exit rpmpd_exit(void)
+{
+       platform_driver_unregister(&rpmpd_driver);
+}
+module_exit(rpmpd_exit);
+
+MODULE_DESCRIPTION("Qualcomm Technologies, Inc. RPM Power Domain Driver");
+MODULE_LICENSE("GPL v2");
+MODULE_ALIAS("platform:qcom-rpmpd");

Is this MODULE_ALIAS required? I thought this wasn't useful because it's auto-generated or something like that. Also, this is bool so these can all go away unless it becomes tristate.

#10 lore raw

Re: [PATCH v5 4/8] soc: qcom: rpmpd: Add support for get/set performance state

In reply to Stephen Boyd
Quoted 5 lines · Stephen Boyd

Quoting Rajendra Nayak (2018-12-03 21:21:15)

Quoted 4 lines
drivers/soc/qcom/rpmpd.c +0 -0
@@ -221,6 +224,47 @@ static int rpmpd_power_off(struct generic_pm_domain *domain)
         return ret;
  }
 
Quoted 12 lines

drivers/soc/qcom/rpmpd.c static int rpmpd_power_off(struct generic_pm_domain *domain) · line 236

Quoted 10 lines
drivers/soc/qcom/rpmpd.c +10 -0
+static int rpmpd_set_performance(struct generic_pm_domain *domain,
+                                unsigned int state)
+{
+       int ret = 0;
+       struct rpmpd *pd = domain_to_rpmpd(domain);
+
+       mutex_lock(&rpmpd_lock);
+
+       if (state > MAX_RPMPD_STATE)
+               goto out;

Does this need to be under the mutex lock? Doesn't look like it.

Nope, will move it out.

Quoted 7 lines

drivers/soc/qcom/rpmpd.c static int rpmpd_power_off(struct generic_pm_domain *domain) · line 240

Quoted 5 lines
drivers/soc/qcom/rpmpd.c +4 -0
+
+       pd->corner = state;
+
+       if (!pd->enabled && (pd->key != KEY_FLOOR_CORNER))

Please drop useless parenthesis.

sure

Quoted 15 lines
Quoted 15 lines
drivers/soc/qcom/rpmpd.c +14 -0
+               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)
+{
+       struct device_node *np;
Quoted 8 lines

drivers/soc/qcom/rpmpd.c static int rpmpd_power_off(struct generic_pm_domain *domain) · line 259

Quoted 5 lines
drivers/soc/qcom/rpmpd.c +5 -0
+       unsigned int corner = 0;
+
+       np = dev_pm_opp_get_of_node(opp);
+       if (of_property_read_u32(np, "qcom,level", &corner)) {
+               pr_err("%s: missing 'qcom,level' property\n", __func__);

We leak np reference here, assuming dev_pm_opp_get_of_node() returns an of_node_get() pointer to the caller.

good catch, will fix.

Quoted 8 lines

drivers/soc/qcom/rpmpd.c static int rpmpd_power_off(struct generic_pm_domain *domain) · line 263

Quoted 5 lines
drivers/soc/qcom/rpmpd.c +4 -0
+               return 0;
+       }
+
+       of_node_put(np);

This same code exists twice. Perhaps a helper needs to exist for qcom_rpm_get_performance() to pull the number out of the DT.

Sure I can make both drivers use a common helper instead of duplicating it.

Quoted 4 lines
Quoted 4 lines
drivers/soc/qcom/rpmpd.c +3 -0
+
+       return corner;
+}
#18 lore raw

Re: [PATCH v5 7/8] arm64: dts: sdm845: Add rpmh powercontroller node

In reply to Stephen Boyd
Quoted 13 lines · Stephen Boyd

Quoting Rajendra Nayak (2018-12-03 21:21:18)

Quoted 12 lines
arch/arm64/boot/dts/qcom/sdm845.dtsi +4 -0
index b72bdb0a31a5..a6d0cd8d17b0 100644
@@ -1324,6 +1325,56 @@
                                 compatible = "qcom,sdm845-rpmh-clk";
                                 #clock-cells = <1>;
                         };
+
+                       rpmhpd: power-controller {
+                               compatible = "qcom,sdm845-rpmhpd";
+                               #power-domain-cells = <1>;
Quoted 8 lines

arch/arm64/boot/dts/qcom/sdm845.dtsi line 1335

Quoted 4 lines
arch/arm64/boot/dts/qcom/sdm845.dtsi +4 -0
+                               operating-points-v2 = <&rpmhpd_opp_table>;
+                       };
+
+                       rpmhpd_opp_table: opp-table {

This table should go somewhere else? I don't understand why it's in the rpmh node because it's not an rpmh device. Does it go to the root? Or does it go under rpmhpd itself? I'm not sure.

I could move it to root perhaps, we seem to do that atleast in the case of GPU. The power domain bindings (Documentation/devicetree/bindings/power/power_domain.txt) seem to suggest it can't be under the power-controller node itself.

#11 lore raw

Re: [PATCH v5 4/8] soc: qcom: rpmpd: Add support for get/set performance state

In reply to Rajendra Nayak
Quoted 10 lines · Rajendra Nayak
Quoted 8 lines
Quoted 5 lines

+               return 0;
+       }
+
+       of_node_put(np);

This same code exists twice. Perhaps a helper needs to exist for qcom_rpm_get_performance() to pull the number out of the DT.

Sure I can make both drivers use a common helper instead of duplicating it.

which would mean I will need to create a new file just to define the common helper. Does that seem like an overkill?

maintainer
#12 lore raw

Re: [PATCH v5 4/8] soc: qcom: rpmpd: Add support for get/set performance state

Quoting Rajendra Nayak (2018-12-05 02:11:22)

Quoted 8 lines · Rajendra Nayak
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines

+               return 0;
+       }
+
+       of_node_put(np);

Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

This same code exists twice. Perhaps a helper needs to exist for qcom_rpm_get_performance() to pull the number out of the DT.

Sure I can make both drivers use a common helper instead of duplicating it.

which would mean I will need to create a new file just to define the common helper. Does that seem like an overkill?

Maybe put it in the genpd code and let it take a const char *name argument that picks out the property that drivers want to look at? That way other OPP properties can be picked out with a simple call to the function but it's generic enough to be used in other places.

maintainer Reviewed-by on v5 1/8
#3 lore raw

Re: [PATCH v5 1/8] dt-bindings: opp: Introduce qcom-opp bindings

In reply to Rajendra Nayak
Quoted 6 lines · Rajendra Nayak

On Qualcomm Technologies, Inc. platforms, an OPP node needs to describe an additional level/corner value that is then 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.

Quoted 9 lines

Describe these bindings in the qcom-opp bindings document.

---
 .../devicetree/bindings/opp/qcom-opp.txt      | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/opp/qcom-opp.txt
maintainer
#19 lore raw

Re: [PATCH v5 7/8] arm64: dts: sdm845: Add rpmh powercontroller node

In reply to Rajendra Nayak
Quoted 25 lines · Rajendra Nayak
Quoted 13 lines · Stephen Boyd

Quoting Rajendra Nayak (2018-12-03 21:21:18)

Quoted 12 lines
arch/arm64/boot/dts/qcom/sdm845.dtsi +4 -0
index b72bdb0a31a5..a6d0cd8d17b0 100644
@@ -1324,6 +1325,56 @@
                                 compatible = "qcom,sdm845-rpmh-clk";
                                 #clock-cells = <1>;
                         };
+
+                       rpmhpd: power-controller {
+                               compatible = "qcom,sdm845-rpmhpd";
+                               #power-domain-cells = <1>;
Quoted 8 lines

arch/arm64/boot/dts/qcom/sdm845.dtsi line 1335

Quoted 4 lines
arch/arm64/boot/dts/qcom/sdm845.dtsi +4 -0
+                               operating-points-v2 = <&rpmhpd_opp_table>;
+                       };
+
+                       rpmhpd_opp_table: opp-table {

This table should go somewhere else? I don't understand why it's in the rpmh node because it's not an rpmh device. Does it go to the root? Or does it go under rpmhpd itself? I'm not sure.

Quoted 3 lines

I could move it to root perhaps, we seem to do that atleast in the case of GPU. The power domain bindings (Documentation/devicetree/bindings/power/power_domain.txt) seem to suggest it can't be under the power-controller node itself.

Why not? I don't see anything forbidding that like already having some other type of child nodes. It's a little weird to have operating-points-v2 point to a child node, but that will still work.

Rob