Add powerdomain driver for corners on msm8996
Subsystems (9)
cover Add powerdomain driver for corners on msm8996
With performance state support for genpd merged, and with some more patches to add support for them in the OPP layer [1] under discussion, this is an effort to model a powerdomain driver to communicate corner/level values for qualcomm platforms to RPM (Remote Power Manager)
This series adds data specific to msm8996 and is tested on the db820c. We also modify mmc as one of the first devices to move to using an OPP table and vote on corners using the performance state infrastructure.
[1] https://lwn.net/Articles/742136/
Rajendra Nayak (6):
soc: qcom: rpmpd: Add a powerdomain driver to model corners
dt-bindings: opp: Introduce qcom-opp bindings
soc: qcom: rpmpd: Add support for get/set performance state
arm64: dts: msm8996: Add rpmpd device node
mmc: sdhci-msm: Adapt the driver to use OPPs to set clocks/performance
state
soc: qcom: rpmpd: Add a max vote on all corners at init
Viresh Kumar (1):
PM / OPP: Add dev_pm_opp_get_of_node()
Documentation/devicetree/bindings/opp/qcom-opp.txt | 25 ++ .../devicetree/bindings/power/qcom,rpmpd.txt | 14 + arch/arm64/boot/dts/qcom/msm8996.dtsi | 87 +++++ drivers/clk/qcom/gcc-msm8996.c | 8 +- drivers/mmc/host/sdhci-msm.c | 57 +++- drivers/opp/of.c | 19 ++ drivers/soc/qcom/Kconfig | 9 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/rpmpd.c | 350 +++++++++++++++++++++ include/linux/pm_opp.h | 5 + 10 files changed, 561 insertions(+), 14 deletions(-) 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/rpmpd.c
Signature · 2 lines
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH 1/7 PM / OPP: Add dev_pm_opp_get_of_node()
From: Viresh Kumar <[email protected]>
This adds a new helper to let the power domain drivers to access opp->np, so that they can read platform specific properties from the node.
--- drivers/opp/of.c | 19 +++++++++++++++++++ include/linux/pm_opp.h | 5 +++++ 2 files changed, 24 insertions(+)
drivers/opp/of.c +19 -0
@@ -736,3 +736,22 @@ struct dev_pm_opp *of_dev_pm_opp_find_required_opp(struct device *dev,return opp; }EXPORT_SYMBOL_GPL (of_dev_pm_opp_find_required_opp); + +/** +* 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 +* +* Return: DT node corresponding to the opp, else 0 on success. +* +* The caller needs to put the node of_node_put() after using it. +*/ +struct device_node *dev_pm_opp_get_of_node (struct dev_pm_opp *opp) +{ +if (IS_ERR_OR_NULL (opp)) { +pr_err ("%s: Invalid parameters\n" , __func__); +return NULL ; + } + +return of_node_get (opp->np); +} +EXPORT_SYMBOL_GPL (dev_pm_opp_get_of_node);
include/linux/pm_opp.h +5 -0
@@ -300,6 +300,7 @@ void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask);int dev_pm_opp_of_get_sharing_cpus (struct device *cpu_dev,struct cpumask *cpumask);struct device_node *dev_pm_opp_of_get_opp_desc_node (struct device *dev);struct dev_pm_opp *of_dev_pm_opp_find_required_opp (struct device *dev,struct device_node *np); +struct device_node *dev_pm_opp_get_of_node (struct dev_pm_opp *opp);#else static inline int dev_pm_opp_of_add_table (struct device *dev) {
@@ -338,6 +339,10 @@ static inline struct dev_pm_opp *of_dev_pm_opp_find_required_opp(struct device * {return NULL ; } +static inline struct device_node *dev_pm_opp_get_of_node (struct dev_pm_opp *opp) +{ +return NULL ; +}#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
Re: [PATCH 1/7] PM / OPP: Add dev_pm_opp_get_of_node()
Quoting Rajendra Nayak (2018-03-15 21:08:18)
Quoted 9 lines
From: Viresh Kumar <[email protected]>
This adds a new helper to let the power domain drivers to access
opp->np, so that they can read platform specific properties from the node.Signed-off-by Viresh Kumar <[email protected]>Signed-off-by Rajendra Nayak <[email protected]>---
Are there two versions of this patch floating around?
Quoted 10 lines
drivers/opp/of.c | 19 +++++++++++++++++++ include/linux/pm_opp.h | 5 +++++ 2 files changed, 24 insertions(+)drivers/opp/of.c +0
-0@@ -736,3 +736,22 @@ struct dev_pm_opp *of_dev_pm_opp_find_required_opp(struct device *dev,return opp;
drivers/opp/of.c struct dev_pm_opp *of_dev_pm_opp_find_required_opp(struct device *dev, · line 746
Quoted 10 lines
drivers/opp/of.c +8
-0}EXPORT_SYMBOL_GPL (of_dev_pm_opp_find_required_opp); + +/** +* 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 +* +* Return: DT node corresponding to the opp, else 0 on success. +* +* The caller needs to put the node of_node_put() after using it.
put the node with of_node_put()
Re: [PATCH 1/7] PM / OPP: Add dev_pm_opp_get_of_node()
Quoted 7 lines · Stephen Boyd
Quoting Rajendra Nayak (2018-03-15 21:08:18)
Quoted 6 lines
From: Viresh Kumar <[email protected]>
This adds a new helper to let the power domain drivers to access
opp->np, so that they can read platform specific properties from the node.
Quoted 5 lines
Quoted 3 lines
Signed-off-by Viresh Kumar <[email protected]>Signed-off-by Rajendra Nayak <[email protected]>---
Are there two versions of this patch floating around?
Yeah, I will carry this patch in my series now going forward.
Quoted 14 lines
Quoted 14 lines
drivers/opp/of.c | 19 +++++++++++++++++++ include/linux/pm_opp.h | 5 +++++ 2 files changed, 24 insertions(+)drivers/opp/of.c +2
-0@@ -736,3 +736,22 @@ struct dev_pm_opp *of_dev_pm_opp_find_required_opp(struct device *dev,return opp; }EXPORT_SYMBOL_GPL (of_dev_pm_opp_find_required_opp); + +/**
Quoted 8 lines
drivers/opp/of.c struct dev_pm_opp *of_dev_pm_opp_find_required_opp(struct device *dev, · line 746
Quoted 6 lines
drivers/opp/of.c +6
-0+* 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 +* +* Return: DT node corresponding to the opp, else 0 on success. +* +* The caller needs to put the node of_node_put() after using it. put the node with
of_node_put()
Fixed it up, thanks.
Signature · 1 line
viresh
Re: [PATCH 1/7] PM / OPP: Add dev_pm_opp_get_of_node()
In reply to Stephen BoydQuoted 7 lines · Stephen Boyd
Quoting Rajendra Nayak (2018-03-15 21:08:18)
Quoted 6 lines
From: Viresh Kumar <[email protected]>
This adds a new helper to let the power domain drivers to access
opp->np, so that they can read platform specific properties from the node.
Quoted 5 lines
Quoted 3 lines
Signed-off-by Viresh Kumar <[email protected]>Signed-off-by Rajendra Nayak <[email protected]>---
Are there two versions of this patch floating around?
The other one was mine, but it is identical to this.
Jordan
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
PATCH 2/7 soc: qcom: rpmpd: Add a powerdomain driver to model corners
In reply to Rajendra NayakThe powerdomains 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 powerdomain data needed on msm8996 here. This driver can easily be extended by adding data for other qualcomm SoCs as well.
--- .../devicetree/bindings/power/qcom,rpmpd.txt | 14 + drivers/soc/qcom/Kconfig | 9 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/rpmpd.c | 299 +++++++++++++++++++++ 4 files changed, 323 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/qcom,rpmpd.txt create mode 100644 drivers/soc/qcom/rpmpd.c
Documentation/devicetree/bindings/power/qcom,rpmpd.txt new file +14 -0
@@ -0,0 +1,14 @@ +Qualcomm RPM Powerdomains + +* For RPM powerdomains, we communicate a performance state to RPM +which then translates it into a corresponding voltage on a rail + +Required Properties: + - compatible: Should be one of the following + * qcom,rpmpd-msm8996: RPM Powerdomain for the msm8996 family of SoC + - power-domain-cells: number of cells in power domain specifier + must be 1. + - domain-performance-state: One or more nodes describing the performance-states + supported by the powerdomain. + For domain-performance-state bindings refer to + Documentation/devicetree/bindings/power/power_domain.txt
drivers/soc/qcom/Kconfig +9 -0
@@ -55,6 +55,15 @@ config QCOM_RMTFS_MEM Say y here if you intend to boot the modem remoteproc. +config QCOM_RPMPD + tristate "Qualcomm RPM Powerdomain driver" + depends on MFD_QCOM_RPM && QCOM_SMD_RPM + help + QCOM RPM powerdomain driver to support powerdomain 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
drivers/soc/qcom/Makefile +1 -0
@@ -12,3 +12,4 @@ obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o obj-$(CONFIG_QCOM_SMP2P) += smp2p.o obj-$(CONFIG_QCOM_SMSM) += smsm.o obj-$(CONFIG_QCOM_WCNSS_CTRL) += wcnss_ctrl.o +obj-$(CONFIG_QCOM_RPMPD) += rpmpd.o
drivers/soc/qcom/rpmpd.c new file +299 -0
299 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
Rob Herring
maintainerRe: [PATCH 2/7] soc: qcom: rpmpd: Add a powerdomain driver to model corners
Quoted 25 lines · Rajendra Nayak
The powerdomains 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 powerdomain 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 <[email protected]>Signed-off-by Viresh Kumar <[email protected]>--- .../devicetree/bindings/power/qcom,rpmpd.txt | 14 + drivers/soc/qcom/Kconfig | 9 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/rpmpd.c | 299 +++++++++++++++++++++ 4 files changed, 323 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/qcom,rpmpd.txt create mode 100644 drivers/soc/qcom/rpmpd.cDocumentation/devicetree/bindings/power/qcom,rpmpd.txt new file +0
-0
Documentation/devicetree/bindings/power/qcom,rpmpd.txt line 8
Quoted 8 lines
Documentation/devicetree/bindings/power/qcom,rpmpd.txt new file +8
-0@@ -0,0 +1,14 @@ +Qualcomm RPM Powerdomains + +* For RPM powerdomains, we communicate a performance state to RPM +which then translates it into a corresponding voltage on a rail + +Required Properties: + - compatible: Should be one of the following + * qcom,rpmpd-msm8996: RPM Powerdomain for the msm8996 family of SoC
qcom,msm8996-rpmpd
Quoted 6 lines
Documentation/devicetree/bindings/power/qcom,rpmpd.txt new file +6
-0+ - power-domain-cells: number of cells in power domain specifier + must be 1. + - domain-performance-state: One or more nodes describing the performance-states + supported by the powerdomain. + For domain-performance-state bindings refer to + Documentation/devicetree/bindings/power/power_domain.txt
PATCH 3/7 dt-bindings: opp: Introduce qcom-opp bindings
In reply to Rajendra NayakOn Qualcomm 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.
--- Documentation/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
@@ -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 a 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" + +* OPP Node + +Required properties: +- qcom,level: On Qualcomm platforms an OPP node can describe a positive value +representing a corner/level thats comminicated 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
Re: [PATCH 3/7] dt-bindings: opp: Introduce qcom-opp bindings
Quoted 35 lines · Rajendra Nayak
On Qualcomm 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.
Signed-off-by Rajendra Nayak <[email protected]>--- Documentation/devicetree/bindings/opp/qcom-opp.txt | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Documentation/devicetree/bindings/opp/qcom-opp.txtDocumentation/devicetree/bindings/opp/qcom-opp.txt new file +15
-0@@ -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 a 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:
Documentation/devicetree/bindings/opp/qcom-opp.txt line 25
Quoted 10 lines
Documentation/devicetree/bindings/opp/qcom-opp.txt new file +10
-0+- compatible: Allow OPPs to express their compatibility. It should be: + "operating-points-v2-qcom" + +* OPP Node + +Required properties: +- qcom,level: On Qualcomm platforms an OPP node can describe a positive value +representing a corner/level thats comminicated with a remote microprocessor +(Usually called the RPM) which then translates it into a certain voltage on +a voltage rail.
Signature · 1 line
viresh
Re: [PATCH 3/7] dt-bindings: opp: Introduce qcom-opp bindings
In reply to Rajendra NayakQuoted 6 lines · Rajendra Nayak
On Qualcomm 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 7 lines
Describe these bindings in the qcom-opp bindings document.
Signed-off-by Rajendra Nayak <[email protected]>--- Documentation/devicetree/bindings/opp/qcom-opp.txt | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Documentation/devicetree/bindings/opp/qcom-opp.txt
Re: [PATCH 3/7] dt-bindings: opp: Introduce qcom-opp bindings
In reply to Rajendra NayakQuoting Rajendra Nayak (2018-03-15 21:08:20)
Quoted 16 lines
On Qualcomm 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.
Signed-off-by Rajendra Nayak <[email protected]>---
Documentation/devicetree/bindings/opp/qcom-opp.txt new file +0
-0
Documentation/devicetree/bindings/opp/qcom-opp.txt line 3
Quoted 3 lines
Documentation/devicetree/bindings/opp/qcom-opp.txt new file +3
-0@@ -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
Capitalize qualcomm?
Documentation/devicetree/bindings/opp/qcom-opp.txt line 7
Quoted 4 lines
Documentation/devicetree/bindings/opp/qcom-opp.txt new file +4
-0+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 a appropriate voltage based on the value passed.
to an
Documentation/devicetree/bindings/opp/qcom-opp.txt line 17
Quoted 10 lines
Documentation/devicetree/bindings/opp/qcom-opp.txt new file +10
-0+ +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"
Can this be operating-points-v2-level or -qcom-level? Just worried that qcom is too generic.
Documentation/devicetree/bindings/opp/qcom-opp.txt line 23
Quoted 6 lines
Documentation/devicetree/bindings/opp/qcom-opp.txt new file +6
-0+ +* OPP Node + +Required properties: +- qcom,level: On Qualcomm platforms an OPP node can describe a positive value +representing a corner/level thats comminicated with a remote microprocessor
s/thats/that's/
Documentation/devicetree/bindings/opp/qcom-opp.txt line 24
Quoted 1 line
Documentation/devicetree/bindings/opp/qcom-opp.txt new file +1
-0+(Usually called the RPM) which then translates it into a certain voltage on
lowercase Usually
Quoted 1 line
Documentation/devicetree/bindings/opp/qcom-opp.txt new file +1
-0+a voltage rail.
PATCH 4/7 soc: qcom: rpmpd: Add support for get/set performance state
In reply to Rajendra NayakWith genpd now expecting powerdomain drivers supporting performance state to support get/set performance state callbacks, add support for it in the rpmpd driver.
--- drivers/soc/qcom/rpmpd.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
drivers/soc/qcom/rpmpd.c +42 -0
@@ -14,6 +14,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>
@@ -29,6 +30,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 = { \
@@ -222,6 +225,43 @@ 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); +of_property_read_u32 (np,"qcom,level" , &corner); +of_node_put (np); + +return corner; +} +static int rpmpd_probe (struct platform_device *pdev) {int i;
@@ -259,6 +299,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.get_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
Re: [PATCH 4/7] soc: qcom: rpmpd: Add support for get/set performance state
Quoted 57 lines · Rajendra Nayak
With genpd now expecting powerdomain drivers supporting performance state to support get/set performance state callbacks, add support for it in the rpmpd driver.
Signed-off-by Rajendra Nayak <[email protected]>Signed-off-by Viresh Kumar <[email protected]>--- drivers/soc/qcom/rpmpd.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)drivers/soc/qcom/rpmpd.c +25
-0@@ -14,6 +14,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> @@ -29,6 +30,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 = { \@@ -222,6 +225,43 @@ 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;
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); +of_property_read_u32 (np,"qcom,level" , &corner);
Don't we want to error out or do something else in case of an error ?
Quoted 9 lines
drivers/soc/qcom/rpmpd.c +5
-0+of_node_put (np); + +return corner; +} +static int rpmpd_probe (struct platform_device *pdev) {int i;
drivers/soc/qcom/rpmpd.c static int rpmpd_probe(struct platform_device *pdev) · line 306
Quoted 8 lines
drivers/soc/qcom/rpmpd.c +2
-0@@ -259,6 +299,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.get_performance_state = rpmpd_get_performance;pm_genpd_init (&rpmpds[i]->pd,NULL , true); data->domains[i] = &rpmpds[i]->pd;
Signature · 1 line
viresh
Re: [PATCH 4/7] soc: qcom: rpmpd: Add support for get/set performance state
Quoted 62 lines · Viresh Kumar
Quoted 61 lines · Rajendra Nayak
With genpd now expecting powerdomain drivers supporting performance state to support get/set performance state callbacks, add support for it in the rpmpd driver.
Signed-off-by Rajendra Nayak <[email protected]>Signed-off-by Viresh Kumar <[email protected]>--- drivers/soc/qcom/rpmpd.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+)drivers/soc/qcom/rpmpd.c +29
-0@@ -14,6 +14,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> @@ -29,6 +30,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 = { \@@ -222,6 +225,43 @@ 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)
Quoted 8 lines
drivers/soc/qcom/rpmpd.c static int rpmpd_power_off(struct generic_pm_domain *domain) · line 259
Quoted 6 lines
drivers/soc/qcom/rpmpd.c +6
-0+{ +struct device_node *np; +unsigned int corner =0 ; + + np =dev_pm_opp_get_of_node (opp); +of_property_read_u32 (np,"qcom,level" , &corner);Don't we want to error out or do something else in case of an error ?
yes, I missed the error checks, will add.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH 5/7 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 | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
arch/arm64/boot/dts/qcom/msm8996.dtsi +46 -0
@@ -297,6 +297,52 @@ #clock-cells = <1>; }; + rpmpd: qcom,rpmpd { + compatible = "qcom,rpmpd-msm8996"; + #power-domain-cells = <1>; + operating-points-v2 = <&rpmpd_opp_table>, /* cx */ + <&rpmpd_opp_table>, /* cx_ao */ + <&rpmpd_opp_table>, /* cx_vfc */ + <&rpmpd_opp_table>, /* mx */ + <&rpmpd_opp_table>, /* mx_ao */ + <&rpmpd_opp_table>, /* sscx */ + <&rpmpd_opp_table>; /* sscx_vfc */ + }; + + rpmpd_opp_table: opp-table { + compatible = "operating-points-v2", "operating-points-v2-qcom"; + + rpmpd_opp1: opp@1 { + opp-hz = /bits/ 64 <1>; + qcom,level = <1>; + }; + + rpmpd_opp2: opp@2 { + opp-hz = /bits/ 64 <2>; + qcom,level = <2>; + }; + + rpmpd_opp3: opp@3 { + opp-hz = /bits/ 64 <3>; + qcom,level = <3>; + }; + + rpmpd_opp4: opp@4 { + opp-hz = /bits/ 64 <4>; + qcom,level = <4>; + }; + + rpmpd_opp5: opp@5 { + opp-hz = /bits/ 64 <5>; + qcom,level = <5>; + }; + + rpmpd_opp6: opp@6 { + opp-hz = /bits/ 64 <6>; + 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
Re: [PATCH 5/7] arm64: dts: msm8996: Add rpmpd device node
Quoted 23 lines · Rajendra Nayak
Add rpmpd device node and its OPP table
Signed-off-by Rajendra Nayak <[email protected]>Signed-off-by Viresh Kumar <[email protected]>--- arch/arm64/boot/dts/qcom/msm8996.dtsi | 46 +++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)arch/arm64/boot/dts/qcom/msm8996.dtsi +7
-0@@ -297,6 +297,52 @@ #clock-cells = <1>; }; + rpmpd: qcom,rpmpd { + compatible = "qcom,rpmpd-msm8996"; + #power-domain-cells = <1>; + operating-points-v2 = <&rpmpd_opp_table>, /* cx */ + <&rpmpd_opp_table>, /* cx_ao */ + <&rpmpd_opp_table>, /* cx_vfc */ + <&rpmpd_opp_table>, /* mx */
arch/arm64/boot/dts/qcom/msm8996.dtsi line 316
Quoted 10 lines
arch/arm64/boot/dts/qcom/msm8996.dtsi +10
-0+ <&rpmpd_opp_table>, /* mx_ao */ + <&rpmpd_opp_table>, /* sscx */ + <&rpmpd_opp_table>; /* sscx_vfc */ + }; + + rpmpd_opp_table: opp-table { + compatible = "operating-points-v2", "operating-points-v2-qcom"; + + rpmpd_opp1: opp@1 { + opp-hz = /bits/ 64 <1>;
Actually this (magic values) isn't allowed right now. I will send a patchset to make this property optional later on separately (once the other series is accepted).
Quoted 22 lines
arch/arm64/boot/dts/qcom/msm8996.dtsi +22
-0+ qcom,level = <1>; + }; + + rpmpd_opp2: opp@2 { + opp-hz = /bits/ 64 <2>; + qcom,level = <2>; + }; + + rpmpd_opp3: opp@3 { + opp-hz = /bits/ 64 <3>; + qcom,level = <3>; + }; + + rpmpd_opp4: opp@4 { + opp-hz = /bits/ 64 <4>; + qcom,level = <4>; + }; + + rpmpd_opp5: opp@5 { + opp-hz = /bits/ 64 <5>; + qcom,level = <5>; + };
arch/arm64/boot/dts/qcom/msm8996.dtsi line 348
Quoted 10 lines
arch/arm64/boot/dts/qcom/msm8996.dtsi +7
-0+ + rpmpd_opp6: opp@6 { + opp-hz = /bits/ 64 <6>; + qcom,level = <6>; + }; + }; + pm8994-regulators { compatible = "qcom,rpm-pm8994-regulators";
Everything else is fine. After you remove the opp-hz property from this table:
Signature · 1 line
viresh
Stephen Boyd
maintainerRe: [PATCH 5/7] arm64: dts: msm8996: Add rpmpd device node
In reply to Rajendra NayakQuoting Rajendra Nayak (2018-03-15 21:08:22)
arch/arm64/boot/dts/qcom/msm8996.dtsi line 300
Quoted 9 lines
arch/arm64/boot/dts/qcom/msm8996.dtsi +1
-0@@ -297,6 +297,52 @@ #clock-cells = <1>; }; + rpmpd: qcom,rpmpd {
power-controller? power-domain-controller? power-domains? Or something like that.
arch/arm64/boot/dts/qcom/msm8996.dtsi line 312
Quoted 12 lines
arch/arm64/boot/dts/qcom/msm8996.dtsi +12
-0+ compatible = "qcom,rpmpd-msm8996"; + #power-domain-cells = <1>; + operating-points-v2 = <&rpmpd_opp_table>, /* cx */ + <&rpmpd_opp_table>, /* cx_ao */ + <&rpmpd_opp_table>, /* cx_vfc */ + <&rpmpd_opp_table>, /* mx */ + <&rpmpd_opp_table>, /* mx_ao */ + <&rpmpd_opp_table>, /* sscx */ + <&rpmpd_opp_table>; /* sscx_vfc */ + }; + + rpmpd_opp_table: opp-table {
This should go into the root of the tree? Otherwise it may be populated by the RPMh platform populate code which would be odd. We should go and update the platform populate code to always ignore operating-points-v2 compatible nodes too.
arch/arm64/boot/dts/qcom/msm8996.dtsi line 313
Quoted 1 line
arch/arm64/boot/dts/qcom/msm8996.dtsi +1
-0+ compatible = "operating-points-v2", "operating-points-v2-qcom";
This is backwards? I thought more specific compatible went first.
Re: [PATCH 5/7] arm64: dts: msm8996: Add rpmpd device node
Quoted 3 lines · Stephen Boyd
We should go and
update the platform populate code to always ignore operating-points-v2 compatible nodes too.
Will do that.
Signature · 1 line
viresh
Re: [PATCH 5/7] arm64: dts: msm8996: Add rpmpd device node
In reply to Stephen BoydQuoted 27 lines · Stephen Boyd
Quoting Rajendra Nayak (2018-03-15 21:08:22)
arch/arm64/boot/dts/qcom/msm8996.dtsi line 300
Quoted 9 lines
arch/arm64/boot/dts/qcom/msm8996.dtsi +1
-0@@ -297,6 +297,52 @@ #clock-cells = <1>; }; + rpmpd: qcom,rpmpd {power-controller? power-domain-controller? power-domains? Or something like that.
arch/arm64/boot/dts/qcom/msm8996.dtsi line 312
Quoted 12 lines
arch/arm64/boot/dts/qcom/msm8996.dtsi +12
-0+ compatible = "qcom,rpmpd-msm8996"; + #power-domain-cells = <1>; + operating-points-v2 = <&rpmpd_opp_table>, /* cx */ + <&rpmpd_opp_table>, /* cx_ao */ + <&rpmpd_opp_table>, /* cx_vfc */ + <&rpmpd_opp_table>, /* mx */ + <&rpmpd_opp_table>, /* mx_ao */ + <&rpmpd_opp_table>, /* sscx */ + <&rpmpd_opp_table>; /* sscx_vfc */ + }; + + rpmpd_opp_table: opp-table {
Quoted 8 lines
This should go into the root of the tree? Otherwise it may be populated by the RPMh platform populate code which would be odd. We should go and update the platform populate code to always ignore operating-points-v2 compatible nodes too.
arch/arm64/boot/dts/qcom/msm8996.dtsi line 313
Quoted 1 line
arch/arm64/boot/dts/qcom/msm8996.dtsi +1
-0+ compatible = "operating-points-v2", "operating-points-v2-qcom";This is backwards? I thought more specific compatible went first.
thanks for the review, will fixup all of these when I respin.
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
PATCH 6/7 mmc: sdhci-msm: Adapt the driver to use OPPs to set clocks/performance state
In reply to Rajendra NayakSDHCI driver needs to set a performance state along with scaling its clocks. Modify the driver to use the newly introduced powerdomain performance state based OPPs to scale clocks as well as set an appropriate powerdomain performance state.
The patch also adds OPPs for sdhci device on msm8996.
On platforms which don't specify an OPP table the driver falls back to just setting the clock rates (as is done today)
--- arch/arm64/boot/dts/qcom/msm8996.dtsi | 41 +++++++++++++++++++++++++ drivers/clk/qcom/gcc-msm8996.c | 8 ++--- drivers/mmc/host/sdhci-msm.c | 57 +++++++++++++++++++++++++++++------ 3 files changed, 92 insertions(+), 14 deletions(-)
arch/arm64/boot/dts/qcom/msm8996.dtsi +41 -0
@@ -569,8 +569,49 @@ <&gcc GCC_SDCC2_APPS_CLK>, <&xo_board>; bus-width = <4>; + power-domains = <&rpmpd 0>; + operating-points-v2 = <&sdhc_opp_table>; }; + sdhc_opp_table: opp_table { + compatible = "operating-points-v2"; + + opp@144000 { + opp-hz = /bits/ 64 <144000>; + required-opp = <&rpmpd_opp1>; + }; + + opp@4000000 { + opp-hz = /bits/ 64 <400000>; + required-opp = <&rpmpd_opp1>; + }; + + opp@20000000 { + opp-hz = /bits/ 64 <20000000>; + required-opp = <&rpmpd_opp2>; + }; + + opp@25000000 { + opp-hz = /bits/ 64 <25000000>; + required-opp = <&rpmpd_opp2>; + }; + + opp@50000000 { + opp-hz = /bits/ 64 <50000000>; + required-opp = <&rpmpd_opp2>; + }; + + opp@100000000 { + opp-hz = /bits/ 64 <100000000>; + required-opp = <&rpmpd_opp3>; + }; + + opp@200000000 { + opp-hz = /bits/ 64 <200000000>; + required-opp = <&rpmpd_opp3>; + }; + }; + msmgpio: pinctrl@1010000 { compatible = "qcom,msm8996-pinctrl"; reg = <0x01010000 0x300000>;
drivers/clk/qcom/gcc-msm8996.c +4 -4
@@ -464,7 +464,7 @@ static struct clk_rcg2 sdcc1_apps_clk_src = { .name = "sdcc1_apps_clk_src", .parent_names = gcc_xo_gpll0_gpll4_gpll0_early_div, .num_parents = 4, - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_ops, }, };
@@ -509,7 +509,7 @@ static struct clk_rcg2 sdcc2_apps_clk_src = { .name = "sdcc2_apps_clk_src", .parent_names = gcc_xo_gpll0_gpll4, .num_parents = 3, - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_ops, }, };
@@ -523,7 +523,7 @@ static struct clk_rcg2 sdcc3_apps_clk_src = { .name = "sdcc3_apps_clk_src", .parent_names = gcc_xo_gpll0_gpll4, .num_parents = 3, - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_ops, }, };
@@ -547,7 +547,7 @@ static struct clk_rcg2 sdcc4_apps_clk_src = { .name = "sdcc4_apps_clk_src", .parent_names = gcc_xo_gpll0, .num_parents = 2, - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_ops, }, };
drivers/mmc/host/sdhci-msm.c +47 -10
102 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
Re: [PATCH 6/7] mmc: sdhci-msm: Adapt the driver to use OPPs to set clocks/performance state
drivers/mmc/host/sdhci-msm.c static int sdhci_msm_probe(struct platform_device *pdev) · line 1574
Quoted 5 lines · Rajendra Nayak
drivers/mmc/host/sdhci-msm.c +1
-0@@ -1540,6 +1571,9 @@ static int sdhci_msm_probe(struct platform_device *pdev)pm_runtime_disable (&pdev->dev);pm_runtime_set_suspended (&pdev->dev);pm_runtime_put_noidle (&pdev->dev); +dev_pm_opp_of_remove_table (&pdev->dev);
You can't do this if there is no OPP table. Probably you should just make it part of the below if block.
drivers/mmc/host/sdhci-msm.c static int sdhci_msm_remove(struct platform_device *pdev) · line 1601
Quoted 10 lines
drivers/mmc/host/sdhci-msm.c +3
-0+if (msm_host->opp_table) +dev_pm_opp_put_clkname (msm_host->opp_table); clk_disable:clk_bulk_disable_unprepare (ARRAY_SIZE (msm_host->bulk_clks), msm_host->bulk_clks);@@ -1564,6 +1598,9 @@ static int sdhci_msm_remove(struct platform_device *pdev)pm_runtime_get_sync (&pdev->dev);pm_runtime_disable (&pdev->dev);pm_runtime_put_noidle (&pdev->dev); +dev_pm_opp_of_remove_table (&pdev->dev);
And this too.
drivers/mmc/host/sdhci-msm.c static int sdhci_msm_remove(struct platform_device *pdev) · line 1606
Quoted 5 lines
drivers/mmc/host/sdhci-msm.c +2
-0+if (msm_host->opp_table) +dev_pm_opp_put_clkname (msm_host->opp_table);clk_bulk_disable_unprepare (ARRAY_SIZE (msm_host->bulk_clks), msm_host->bulk_clks);
Signature · 1 line
viresh
PATCH 7/7 soc: qcom: rpmpd: Add a max vote on all corners at init
In reply to Rajendra NayakAs we move from no clients/consumers in kernel voting on corners, to *some* voting and some not voting, we might end up in a situation where the clients which remove votes can adversly impact others who still don't have a way to vote.
To avoid this situation, have a max vote on all corners at init. This should/can be removed once we have all clients moved to be able to vote/unvote for themselves.
--- drivers/soc/qcom/rpmpd.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/soc/qcom/rpmpd.c +9 -0
@@ -304,6 +304,15 @@ static int rpmpd_probe(struct platform_device *pdev)pm_genpd_init (&rpmpds[i]->pd,NULL , true); data->domains[i] = &rpmpds[i]->pd; + +/* +* Until we have all consumers voting on corners +* just vote the max corner on all PDs +* This should ideally be *removed* once we have +* all (most) consumers being able to vote +*/ +rpmpd_set_performance (&rpmpds[i]->pd,MAX_RPMPD_STATE ); +rpmpd_power_on (&rpmpds[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 7/7] soc: qcom: rpmpd: Add a max vote on all corners at init
Quoted 24 lines · Rajendra Nayak
As we move from no clients/consumers in kernel voting on corners, to *some* voting and some not voting, we might end up in a situation where the clients which remove votes can adversly impact others who still don't have a way to vote.
To avoid this situation, have a max vote on all corners at init. This should/can be removed once we have all clients moved to be able to vote/unvote for themselves.
Signed-off-by Rajendra Nayak <[email protected]>--- drivers/soc/qcom/rpmpd.c | 9 +++++++++ 1 file changed, 9 insertions(+)drivers/soc/qcom/rpmpd.c +2
-0@@ -304,6 +304,15 @@ static int rpmpd_probe(struct platform_device *pdev)pm_genpd_init (&rpmpds[i]->pd,NULL , true); data->domains[i] = &rpmpds[i]->pd; + +/*
drivers/soc/qcom/rpmpd.c static int rpmpd_probe(struct platform_device *pdev) · line 318
Quoted 10 lines
drivers/soc/qcom/rpmpd.c +7
-0+* Until we have all consumers voting on corners +* just vote the max corner on all PDs +* This should ideally be *removed* once we have +* all (most) consumers being able to vote +*/ +rpmpd_set_performance (&rpmpds[i]->pd,MAX_RPMPD_STATE ); +rpmpd_power_on (&rpmpds[i]->pd); }return of_genpd_add_provider_onecell (pdev->dev.of_node, data);
Signature · 1 line
viresh