Add power domain driver for corners on msm8996/sdm845
Subsystems (5)
v9 cover Add power domain driver for corners on msm8996/sdm845
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 (10):
dt-bindings: opp: Introduce opp-level 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
OPP: Add a dev_pm_opp_of_get_level() helper
soc: qcom: rpmpd: Use dev_pm_opp_of_get_level() helper
soc: qcom: rpmhpd: Mark mx as a parent for cx
.../devicetree/bindings/opp/opp-level.txt | 29 ++ .../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/of.c | 23 + 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 | 5 + 11 files changed, 1065 insertions(+) create mode 100644 Documentation/devicetree/bindings/opp/opp-level.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
PATCH v9 1/10 dt-bindings: opp: Introduce opp-level bindings
On some SoCs (especially from Qualcomm and MediaTek) 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 opp-level bindings document.
--- .../devicetree/bindings/opp/opp-level.txt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/devicetree/bindings/opp/opp-level.txt
Documentation/devicetree/bindings/opp/opp-level.txt new file +29 -0
@@ -0,0 +1,29 @@ +OPP level bindings to descibe OPP nodes with corner/level values + +OPP tables for devices on some SoCs, especially from Qualcomm and +MediaTek require an additional platform specific corner/level +value to be specified. +This value is passed on to a 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, +with the exception that all of the properties are now optional, +including the opp-hz property. + +Additional properties are described below. + +* OPP Table Node + +Required properties: +- compatible: Allow OPPs to express their compatibility. It should be: + "operating-points-v2-level" + +* OPP Node + +Required properties: +- opp-level: On some SoC platforms an OPP node can describe a positive value +representing a corner/level that's communicated with a remote microprocessor +(usually called the power manager) 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
PATCH v9 2/10 dt-bindings: power: Add qcom rpm power domain driver bindings
In reply to Rajendra NayakAdd 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 | 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
Documentation/devicetree/bindings/power/qcom,rpmpd.txt new file +145 -0
@@ -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-level.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-level"; + + 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-level"; + + 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>; + }; + };
include/dt-bindings/power/qcom-rpmpd.h new file +39 -0
@@ -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
PATCH v9 3/10 soc: qcom: rpmpd: Add a Power domain driver to model corners
In reply to Rajendra NayakThe 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 | 282 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 292 insertions(+) create mode 100644 drivers/soc/qcom/rpmpd.c
drivers/soc/qcom/Kconfig +9 -0
@@ -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
drivers/soc/qcom/Makefile +1 -0
@@ -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 +282 -0
282 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
PATCH v9 4/10 soc: qcom: rpmpd: Add support for get/set performance state
In reply to Rajendra NayakAdd support for the .set_performace_state() and .opp_to_performance_state() callbacks in the rpmpd driver.
--- drivers/soc/qcom/rpmpd.c | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
drivers/soc/qcom/rpmpd.c +44 -0
@@ -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,45 @@ 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) +{ +struct device_node *np; +unsigned int corner =0 ; + + np =dev_pm_opp_get_of_node (opp); +if (of_property_read_u32 (np,"opp-level" , &corner)) +pr_err ("%s: missing 'opp-level' property\n" , __func__); + +of_node_put (np); + +return corner; +} +static int rpmpd_probe (struct platform_device *pdev) {int i;
@@ -258,6 +300,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
PATCH v9 5/10 arm64: dts: msm8996: Add rpmpd device node
In reply to Rajendra NayakAdd 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
@@ -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-level"; + + 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";
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH v9 6/10 soc: qcom: rpmhpd: Add RPMh power domain driver
In reply to Rajendra NayakThe 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 | 400 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 410 insertions(+) create mode 100644 drivers/soc/qcom/rpmhpd.c
drivers/soc/qcom/Kconfig +9 -0
@@ -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
drivers/soc/qcom/Makefile +1 -0
@@ -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
drivers/soc/qcom/rpmhpd.c new file +400 -0
400 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
PATCH v9 7/10 arm64: dts: sdm845: Add rpmh powercontroller node
In reply to Rajendra NayakAdd 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
@@ -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-level"; + + 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 {
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH v9 8/10 OPP: Add a dev_pm_opp_of_get_level() helper
In reply to Rajendra NayakNow that we have atleast 2 genpd providers, both using a simple routine to read a performance state (opp-level) value from device tree, in order to implement the .opp_to_performance_state callback, add a dev_pm_opp_of_get_level() helper to do it, so it can be resued across all such genpd providers which just need to read the value from DT.
--- drivers/opp/of.c | 23 +++++++++++++++++++++++ include/linux/pm_opp.h | 5 +++++ 2 files changed, 28 insertions(+)
drivers/opp/of.c +23 -0
@@ -1029,6 +1029,29 @@ int of_get_required_opp_performance_state(struct device_node *np, int index) }EXPORT_SYMBOL_GPL (of_get_required_opp_performance_state); +/** +* dev_pm_opp_of_get_level() - Reads the opp-level value from Device Tree +* @opp: opp for which 'opp-level' should be read and returned +* +* Returns the opp-level value read from Device Tree, if present, else 0 +* +* Return: Zero or positive opp-level value read from Device tree +*/ +unsigned int dev_pm_opp_of_get_level (struct dev_pm_opp *opp) +{ +struct device_node *np; +unsigned int perf_state =0 ; + + np =dev_pm_opp_get_of_node (opp); +if (of_property_read_u32 (np,"opp-level" , &perf_state)) +pr_err ("%s: missing 'opp-level' property\n" , __func__); + +of_node_put (np); + +return perf_state; +} +EXPORT_SYMBOL_GPL (dev_pm_opp_of_get_level); +/** * dev_pm_opp_get_of_node() - Gets the DT node corresponding to an opp * @opp: opp for which DT node has to be returned for
include/linux/pm_opp.h +5 -0
@@ -322,6 +322,7 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumastruct device_node *dev_pm_opp_of_get_opp_desc_node (struct device *dev);struct device_node *dev_pm_opp_get_of_node (struct dev_pm_opp *opp);int of_get_required_opp_performance_state (struct device_node *np,int index); +unsigned int dev_pm_opp_of_get_level (struct dev_pm_opp *opp);#else static inline int dev_pm_opp_of_add_table (struct device *dev) {
@@ -364,6 +365,10 @@ static inline int of_get_required_opp_performance_state(struct device_node *np, {return -ENOTSUPP ; } +static inline int dev_pm_opp_of_get_level (struct dev_pm_opp *opp) +{ +return 0 ; +}#endif #endif /* __LINUX_OPP_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
PATCH v9 9/10 soc: qcom: rpmpd: Use dev_pm_opp_of_get_level() helper
In reply to Rajendra NayakGet rid of the duplicate code across rpmpd and rpmhpd to read the performance state value (opp-level) from Device tree and use the dev_pm_opp_of_get_level() helper instead.
--- drivers/soc/qcom/rpmhpd.c | 11 +---------- drivers/soc/qcom/rpmpd.c | 11 +---------- 2 files changed, 2 insertions(+), 20 deletions(-)
drivers/soc/qcom/rpmhpd.c +1 -10
@@ -276,16 +276,7 @@ static int rpmhpd_set_performance_state(struct generic_pm_domain *domain,static unsigned int rpmhpd_get_performance_state (struct generic_pm_domain *genpd,struct dev_pm_opp *opp) { -struct device_node *np; -unsigned int level =0 ; - - np =dev_pm_opp_get_of_node (opp); -if (of_property_read_u32 (np,"opp-level" , &level)) -pr_err ("%s: missing 'opp-level' property\n" , __func__); - -of_node_put (np); - -return level; +return dev_pm_opp_of_get_level (opp); }static int rpmhpd_update_level_mapping (struct rpmhpd *rpmhpd)
drivers/soc/qcom/rpmpd.c +1 -10
@@ -248,16 +248,7 @@ static int rpmpd_set_performance(struct generic_pm_domain *domain,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,"opp-level" , &corner)) -pr_err ("%s: missing 'opp-level' property\n" , __func__); - -of_node_put (np); - -return corner; +return dev_pm_opp_of_get_level (opp); }static int rpmpd_probe (struct platform_device *pdev)
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH v9 10/10 soc: qcom: rpmhpd: Mark mx as a parent for cx
In reply to Rajendra NayakSpecify 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.
--- drivers/soc/qcom/rpmhpd.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
drivers/soc/qcom/rpmhpd.c +11 -0
@@ -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); }
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Re: [PATCH v9 01/10] dt-bindings: opp: Introduce opp-level bindings
In reply to Rajendra NayakQuoted 31 lines · Rajendra Nayak
On some SoCs (especially from Qualcomm and MediaTek) 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 opp-level bindings document.
Signed-off-by Rajendra Nayak <[email protected]>--- .../devicetree/bindings/opp/opp-level.txt | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Documentation/devicetree/bindings/opp/opp-level.txtDocumentation/devicetree/bindings/opp/opp-level.txt new file +11
-0@@ -0,0 +1,29 @@ +OPP level bindings to descibe OPP nodes with corner/level values + +OPP tables for devices on some SoCs, especially from Qualcomm and +MediaTek require an additional platform specific corner/level +value to be specified. +This value is passed on to a 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,
Documentation/devicetree/bindings/opp/opp-level.txt line 21
Quoted 10 lines
Documentation/devicetree/bindings/opp/opp-level.txt new file +10
-0+with the exception that all of the properties are now optional, +including the opp-hz property. + +Additional properties are described below. + +* OPP Table Node + +Required properties: +- compatible: Allow OPPs to express their compatibility. It should be: + "operating-points-v2-level"
All this isn't required. Just define it as a regular property in opp.txt only, just like opp-hz or something else.
Signature · 1 line
viresh
Re: [PATCH v9 08/10] OPP: Add a dev_pm_opp_of_get_level() helper
In reply to Rajendra NayakQuoted 1 line · Rajendra Nayak
Now that we have atleast 2 genpd providers, both using a simple
This kind of reasoning for this patch isn't required anymore. Make this patch the second one in the series, i.e. just after the bindings.
Quoted 27 lines
routine to read a performance state (opp-level) value from device tree, in order to implement the .opp_to_performance_state callback, add a
dev_pm_opp_of_get_level()helper to do it, so it can be resued across all such genpd providers which just need to read the value from DT.Suggested-by Stephen Boyd <[email protected]>Signed-off-by Rajendra Nayak <[email protected]>--- drivers/opp/of.c | 23 +++++++++++++++++++++++ include/linux/pm_opp.h | 5 +++++ 2 files changed, 28 insertions(+)drivers/opp/of.c +6
-0@@ -1029,6 +1029,29 @@ int of_get_required_opp_performance_state(struct device_node *np, int index) }EXPORT_SYMBOL_GPL (of_get_required_opp_performance_state); +/** +* dev_pm_opp_of_get_level() - Reads the opp-level value from Device Tree +* @opp: opp for which 'opp-level' should be read and returned +* +* Returns the opp-level value read from Device Tree, if present, else 0 +*
drivers/opp/of.c int of_get_required_opp_performance_state(struct device_node *np, int index) · line 1047
Quoted 10 lines
drivers/opp/of.c +10
-0+* Return: Zero or positive opp-level value read from Device tree +*/ +unsigned int dev_pm_opp_of_get_level (struct dev_pm_opp *opp) +{ +struct device_node *np; +unsigned int perf_state =0 ; + + np =dev_pm_opp_get_of_node (opp); +if (of_property_read_u32 (np,"opp-level" , &perf_state)) +pr_err ("%s: missing 'opp-level' property\n" , __func__);
Instead of this, add a field "level" in the opp structure in drivers/opp/opp.h and fill it while parsing the OPPs. And here you can just read the values then.
Signature · 1 line
viresh