Skip to contentSkip to conversation

PM / OPP: Introduce ti-opp-supply driver

PATCH New Dave Gerlach 5 participants 12 messages Dec 15, 2017 – Dec 19, 2017

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

v2 cover PM / OPP: Introduce ti-opp-supply driver

Hi,
This is v2 of the series to introduce the ti-opp-supply driver which makes use of the OPP core to enable multiple regulator DVFS and AVS Class0 for TI DRA7 and AM57 platforms. Version 1 of this series can be found here [1].

Very few changes since v1, just added Viresh's acks to patches 1 and 2 and added SPDX license to the ti-opp-supply driver in patch 4.

Pushed updated branch here just in case [2].

Regards,
Dave

[1] https://www.spinics.net/lists/devicetree/msg205957.html
[2] https://github.com/dgerlach/linux-pm/tree/upstream/v4.15/ti-multireg-support-v2

Dave Gerlach (4):
cpufreq: ti-cpufreq: Convert to module_platform_driver
cpufreq: ti-cpufreq: Add support for multiple regulators
dt-bindings: opp: Introduce ti-opp-supply bindings PM / OPP: Add ti-opp-supply driver

 .../bindings/opp/ti-omap5-opp-supply.txt           |  63 +++
 drivers/cpufreq/ti-cpufreq.c                       |  51 ++-
 drivers/opp/Makefile                               |   1 +
 drivers/opp/ti-opp-supply.c                        | 425 +++++++++++++++++++++
 4 files changed, 534 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/opp/ti-omap5-opp-supply.txt
 create mode 100644 drivers/opp/ti-opp-supply.c
Signature · 1 line
2.15.1
#1 lore raw

PATCH v2 1/4 cpufreq: ti-cpufreq: Convert to module_platform_driver

ti-cpufreq will be responsible for calling dev_pm_opp_set_regulators on platforms that require AVS and ABB regulator support so we must be able to defer probe if regulators are not yet available, so change ti-cpufreq to be a module_platform_driver to allow for probe defer.

---
 drivers/cpufreq/ti-cpufreq.c | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
drivers/cpufreq/ti-cpufreq.c +21 -2
index 923317f03b4b..b1c230a1e2aa 100644
@@ -17,6 +17,7 @@
 #include <linux/cpu.h>
 #include <linux/io.h>
 #include <linux/mfd/syscon.h>
+#include <linux/module.h>
 #include <linux/init.h>
 #include <linux/of.h>
 #include <linux/of_platform.h>
@@ -195,7 +196,7 @@ static const struct of_device_id ti_cpufreq_of_match[] = {
 	{},
 };
 
-static int ti_cpufreq_init(void)
+static int ti_cpufreq_probe(struct platform_device *pdev)
 {
 	u32 version[VERSION_COUNT];
 	struct device_node *np;
@@ -269,4 +270,22 @@ static int ti_cpufreq_init(void)
 
 	return ret;
 }
-device_initcall(ti_cpufreq_init);
+
+static int ti_cpufreq_init(void)
+{
+	platform_device_register_simple("ti-cpufreq", -1, NULL, 0);
+	return 0;
+}
+module_init(ti_cpufreq_init);
+
+static struct platform_driver ti_cpufreq_driver = {
+	.probe = ti_cpufreq_probe,
+	.driver = {
+		.name = "ti-cpufreq",
+	},
+};
+module_platform_driver(ti_cpufreq_driver);
+
+MODULE_DESCRIPTION("TI CPUFreq/OPP hw-supported driver");
+MODULE_AUTHOR("Dave Gerlach <[email protected]>");
+MODULE_LICENSE("GPL v2");
Signature · 1 line
2.15.1
#2 lore raw

PATCH v2 2/4 cpufreq: ti-cpufreq: Add support for multiple regulators

In reply to Dave Gerlach

Some platforms, like those in the DRA7 and AM57 families, require the scaling of multiple regulators in order to properly support higher OPPs. Let the ti-cpufreq driver determine when this is required and pass the appropriate regulator names to the OPP core so that they can be properly managed.

---
 drivers/cpufreq/ti-cpufreq.c | 28 ++++++++++++++++++++++++----
 1 file changed, 24 insertions(+), 4 deletions(-)
drivers/cpufreq/ti-cpufreq.c +24 -4
index b1c230a1e2aa..a099b7bf74cd 100644
@@ -51,6 +51,7 @@ struct ti_cpufreq_soc_data {
 	unsigned long efuse_mask;
 	unsigned long efuse_shift;
 	unsigned long rev_offset;
+	bool multi_regulator;
 };
 
 struct ti_cpufreq_data {
@@ -58,6 +59,7 @@ struct ti_cpufreq_data {
 	struct device_node *opp_node;
 	struct regmap *syscon;
 	const struct ti_cpufreq_soc_data *soc_data;
+	struct opp_table *opp_table;
 };
 
 static unsigned long amx3_efuse_xlate(struct ti_cpufreq_data *opp_data,
@@ -96,6 +98,7 @@ static struct ti_cpufreq_soc_data am3x_soc_data = {
 	.efuse_offset = 0x07fc,
 	.efuse_mask = 0x1fff,
 	.rev_offset = 0x600,
+	.multi_regulator = false,
 };
 
 static struct ti_cpufreq_soc_data am4x_soc_data = {
@@ -104,6 +107,7 @@ static struct ti_cpufreq_soc_data am4x_soc_data = {
 	.efuse_offset = 0x0610,
 	.efuse_mask = 0x3f,
 	.rev_offset = 0x600,
+	.multi_regulator = false,
 };
 
 static struct ti_cpufreq_soc_data dra7_soc_data = {
@@ -112,6 +116,7 @@ static struct ti_cpufreq_soc_data dra7_soc_data = {
 	.efuse_mask = 0xf80000,
 	.efuse_shift = 19,
 	.rev_offset = 0x204,
+	.multi_regulator = true,
 };
 
 /**
@@ -201,7 +206,9 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
 	u32 version[VERSION_COUNT];
 	struct device_node *np;
 	const struct of_device_id *match;
+	struct opp_table *ti_opp_table;
 	struct ti_cpufreq_data *opp_data;
+	const char * const reg_names[] = {"vdd", "vbb"};
 	int ret;
 
 	np = of_find_node_by_path("/");
@@ -248,16 +255,29 @@ static int ti_cpufreq_probe(struct platform_device *pdev)
 	if (ret)
 		goto fail_put_node;
 
-	ret = PTR_ERR_OR_ZERO(dev_pm_opp_set_supported_hw(opp_data->cpu_dev,
-							  version, VERSION_COUNT));
-	if (ret) {
+	ti_opp_table = dev_pm_opp_set_supported_hw(opp_data->cpu_dev,
+						   version, VERSION_COUNT);
+	if (IS_ERR(ti_opp_table)) {
 		dev_err(opp_data->cpu_dev,
 			"Failed to set supported hardware\n");
+		ret = PTR_ERR(ti_opp_table);
 		goto fail_put_node;
 	}
 
-	of_node_put(opp_data->opp_node);
+	opp_data->opp_table = ti_opp_table;
+
+	if (opp_data->soc_data->multi_regulator) {
+		ti_opp_table = dev_pm_opp_set_regulators(opp_data->cpu_dev,
+							 reg_names,
+							 ARRAY_SIZE(reg_names));
+		if (IS_ERR(ti_opp_table)) {
+			dev_pm_opp_put_supported_hw(opp_data->opp_table);
+			ret =  PTR_ERR(ti_opp_table);
+			goto fail_put_node;
+		}
+	}
 
+	of_node_put(opp_data->opp_node);
 register_cpufreq_dt:
 	platform_device_register_simple("cpufreq-dt", -1, NULL, 0);
 
Signature · 1 line
2.15.1
#3 lore raw

PATCH v2 3/4 dt-bindings: opp: Introduce ti-opp-supply bindings

In reply to Dave Gerlach

Document the devicetree bindings that describe Texas Instruments opp-supply which allow a platform to describe multiple regulators and additional information, such as registers containing data needed to program aforementioned regulators.

---
 .../bindings/opp/ti-omap5-opp-supply.txt           | 63 ++++++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/opp/ti-omap5-opp-supply.txt
Documentation/devicetree/bindings/opp/ti-omap5-opp-supply.txt new file +63 -0
new file mode 100644
index 000000000000..832346e489a3
@@ -0,0 +1,63 @@
+Texas Instruments OMAP compatible OPP supply description
+
+OMAP5, DRA7, and AM57 family of SoCs have Class0 AVS eFuse registers which
+contain data that can be used to adjust voltages programmed for some of their
+supplies for more efficient operation. This binding provides the information
+needed to read these values and use them to program the main regulator during
+an OPP transitions.
+
+Also, some supplies may have an associated vbb-supply which is an Adaptive Body
+Bias regulator which much be transitioned in a specific sequence with regards
+to the vdd-supply and clk when making an OPP transition. By supplying two
+regulators to the device that will undergo OPP transitions we can make use
+of the multi regulator binding that is part of the OPP core described here [1]
+to describe both regulators needed by the platform.
+
+[1] Documentation/devicetree/bindings/opp/opp.txt
+
+Required Properties for Device Node:
+- vdd-supply: phandle to regulator controlling VDD supply
+- vbb-supply: phandle to regulator controlling Body Bias supply
+	      (Usually Adaptive Body Bias regulator)
+
+Required Properties for opp-supply node:
+- compatible: Should be one of:
+	"ti,omap-opp-supply" - basic OPP supply controlling VDD and VBB
+	"ti,omap5-opp-supply" - OMAP5+ optimized voltages in efuse(class0)VDD
+			    along with VBB
+	"ti,omap5-core-opp-supply" - OMAP5+ optimized voltages in efuse(class0) VDD
+			    but no VBB.
+- reg: Address and length of the efuse register set for the device (mandatory
+	only for "ti,omap5-opp-supply")
+- ti,efuse-settings: An array of u32 tuple items providing information about
+	optimized efuse configuration. Each item consists of the following:
+	volt: voltage in uV - reference voltage (OPP voltage)
+	efuse_offseet: efuse offset from reg where the optimized voltage is stored.
+- ti,absolute-max-voltage-uv: absolute maximum voltage for the OPP supply.
+
+Example:
+
+/* Device Node (CPU)  */
+cpus {
+	cpu0: cpu at 0 {
+		device_type = "cpu";
+
+		...
+
+		vdd-supply = <&vcc>;
+		vbb-supply = <&abb_mpu>;
+	};
+};
+
+/* OMAP OPP Supply with Class0 registers */
+opp_supply_mpu: opp_supply at 4a003b20 {
+	compatible = "ti,omap5-opp-supply";
+	reg = <0x4a003b20 0x8>;
+	ti,efuse-settings = <
+	/* uV   offset */
+	1060000 0x0
+	1160000 0x4
+	1210000 0x8
+	>;
+	ti,absolute-max-voltage-uv = <1500000>;
+};
Signature · 1 line
2.15.1
#4 lore raw

PATCH v2 3/4 dt-bindings: opp: Introduce ti-opp-supply bindings

Quoted 6 lines · Dave Gerlach

Document the devicetree bindings that describe Texas Instruments opp-supply which allow a platform to describe multiple regulators and additional information, such as registers containing data needed to program aforementioned regulators.

I need an ACK from Rob on this one.

Quoted 77 lines
---
 .../bindings/opp/ti-omap5-opp-supply.txt           | 63 ++++++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/opp/ti-omap5-opp-supply.txt
Documentation/devicetree/bindings/opp/ti-omap5-opp-supply.txt new file +63 -1
new file mode 100644
index 000000000000..832346e489a3
@@ -0,0 +1,63 @@
+Texas Instruments OMAP compatible OPP supply description
+
+OMAP5, DRA7, and AM57 family of SoCs have Class0 AVS eFuse registers which
+contain data that can be used to adjust voltages programmed for some of their
+supplies for more efficient operation. This binding provides the information
+needed to read these values and use them to program the main regulator during
+an OPP transitions.
+
+Also, some supplies may have an associated vbb-supply which is an Adaptive Body
+Bias regulator which much be transitioned in a specific sequence with regards
+to the vdd-supply and clk when making an OPP transition. By supplying two
+regulators to the device that will undergo OPP transitions we can make use
+of the multi regulator binding that is part of the OPP core described here [1]
+to describe both regulators needed by the platform.
+
+[1] Documentation/devicetree/bindings/opp/opp.txt
+
+Required Properties for Device Node:
+- vdd-supply: phandle to regulator controlling VDD supply
+- vbb-supply: phandle to regulator controlling Body Bias supply
+             (Usually Adaptive Body Bias regulator)
+
+Required Properties for opp-supply node:
+- compatible: Should be one of:
+       "ti,omap-opp-supply" - basic OPP supply controlling VDD and VBB
+       "ti,omap5-opp-supply" - OMAP5+ optimized voltages in efuse(class0)VDD
+                           along with VBB
+       "ti,omap5-core-opp-supply" - OMAP5+ optimized voltages in efuse(class0) VDD
+                           but no VBB.
+- reg: Address and length of the efuse register set for the device (mandatory
+       only for "ti,omap5-opp-supply")
+- ti,efuse-settings: An array of u32 tuple items providing information about
+       optimized efuse configuration. Each item consists of the following:
+       volt: voltage in uV - reference voltage (OPP voltage)
+       efuse_offseet: efuse offset from reg where the optimized voltage is stored.
+- ti,absolute-max-voltage-uv: absolute maximum voltage for the OPP supply.
+
+Example:
+
+/* Device Node (CPU)  */
+cpus {
+       cpu0: cpu at 0 {
+               device_type = "cpu";
+
+               ...
+
+               vdd-supply = <&vcc>;
+               vbb-supply = <&abb_mpu>;
+       };
+};
+
+/* OMAP OPP Supply with Class0 registers */
+opp_supply_mpu: opp_supply at 4a003b20 {
+       compatible = "ti,omap5-opp-supply";
+       reg = <0x4a003b20 0x8>;
+       ti,efuse-settings = <
+       /* uV   offset */
+       1060000 0x0
+       1160000 0x4
+       1210000 0x8
+       >;
+       ti,absolute-max-voltage-uv = <1500000>;
+};
--

2.15.1

#5 lore raw

PATCH v2 3/4 dt-bindings: opp: Introduce ti-opp-supply bindings

Quoted 9 lines · Rafael J. Wysocki
Quoted 6 lines · Dave Gerlach

Document the devicetree bindings that describe Texas Instruments opp-supply which allow a platform to describe multiple regulators and additional information, such as registers containing data needed to program aforementioned regulators.

I need an ACK from Rob on this one.

Actually, how this (and the next patch) is related to the [1-2/4]?

#6 lore raw

PATCH v2 3/4 dt-bindings: opp: Introduce ti-opp-supply bindings

Rafael,

Quoted 7 lines · Rafael J. Wysocki
Quoted 6 lines · Rafael J. Wysocki
Quoted 5 lines · Dave Gerlach

Document the devicetree bindings that describe Texas Instruments opp-supply which allow a platform to describe multiple regulators and additional information, such as registers containing data needed to program aforementioned regulators.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I need an ACK from Rob on this one.

Actually, how this (and the next patch) is related to the [1-2/4]?

The main goal of this series is to add support for scaling the multiple regulators needed for the CPU on these TI platforms. The OPP core supports multiple regulators but only to the point that it can associate a list of regulators to a device. It still by default only scales the normal vdd regulator when doing a rate transition. Because of this, we must define our own method of doing rate transitions to take the references to our regulators held in the OPP core and scale them in the proper sequence depending on what the platform needs.

So to describe the purpose of each patch and their relation to each other:

Patch 1: We must be able to defer the ti-cpufreq driver now that we look for regulators during probe as they likely won't be ready when we probe.

Patch 2: Tell the OPP core about regulators needed for TI CPUFreq operation using the OPP core. This doesn't actually do anything besides place them in a list at this point because the OPP core can't know how TI platforms needs them scaled in relation to each other. Placing the regulator definition in ti-cpufreq driver ensures they are registered with opp core before cpufreq-dt probes (which is triggered at the end of ti-cpufreq probe) and actually makes the opp core get the regulators.

Patch 3: Binding doc for patch 4 driver.

Patch 4: TI OPP supply driver which understands how to actually make use of the two regulators that the OPP core now has a reference to. This overrides the standard opp_set_rate function to let us scale frequency and voltage as needed for TI platforms.

Regards,
Dave

#7 lore raw

PATCH v2 3/4 dt-bindings: opp: Introduce ti-opp-supply bindings

Quoted 37 lines · Dave Gerlach

Rafael,

Quoted 7 lines · Rafael J. Wysocki
Quoted 6 lines · Rafael J. Wysocki
Quoted 5 lines · Dave Gerlach

Document the devicetree bindings that describe Texas Instruments opp-supply which allow a platform to describe multiple regulators and additional information, such as registers containing data needed to program aforementioned regulators.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I need an ACK from Rob on this one.

Actually, how this (and the next patch) is related to the [1-2/4]?

The main goal of this series is to add support for scaling the multiple regulators needed for the CPU on these TI platforms. The OPP core supports multiple regulators but only to the point that it can associate a list of regulators to a device. It still by default only scales the normal vdd regulator when doing a rate transition. Because of this, we must define our own method of doing rate transitions to take the references to our regulators held in the OPP core and scale them in the proper sequence depending on what the platform needs.

So to describe the purpose of each patch and their relation to each other:

Patch 1: We must be able to defer the ti-cpufreq driver now that we look for regulators during probe as they likely won't be ready when we probe.

Patch 2: Tell the OPP core about regulators needed for TI CPUFreq operation using the OPP core. This doesn't actually do anything besides place them in a list at this point because the OPP core can't know how TI platforms needs them scaled in relation to each other. Placing the regulator definition in ti-cpufreq driver ensures they are registered with opp core before cpufreq-dt probes (which is triggered at the end of ti-cpufreq probe) and actually makes the opp core get the regulators.

Quoted 6 lines

Patch 3: Binding doc for patch 4 driver.

Patch 4: TI OPP supply driver which understands how to actually make use of the two regulators that the OPP core now has a reference to. This overrides the standard opp_set_rate function to let us scale frequency and voltage as needed for TI platforms.

Thanks for the explanation, I've applied the series.

maintainer
#8 lore raw

PATCH v2 3/4 dt-bindings: opp: Introduce ti-opp-supply bindings

In reply to Dave Gerlach
Quoted 10 lines · Dave Gerlach

Document the devicetree bindings that describe Texas Instruments opp-supply which allow a platform to describe multiple regulators and additional information, such as registers containing data needed to program aforementioned regulators.

---
 .../bindings/opp/ti-omap5-opp-supply.txt           | 63 ++++++++++++++++++++++
 1 file changed, 63 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/opp/ti-omap5-opp-supply.txt
#9 lore raw

PATCH v2 4/4 PM / OPP: Add ti-opp-supply driver

In reply to Dave Gerlach

Introduce a ti-opp-supply driver that will use new multiple regulator support that is part of the OPP core This is needed on TI platforms like DRA7/AM57 in order to control both CPU regulator and Adaptive Body Bias (ABB) regulator. These regulators must be scaled in sequence during an OPP transition depending on whether or not the frequency is being scaled up or down.

This driver also implements AVS Class0 for these parts by looking up the required values from registers in the SoC and programming adjusted optimal voltage values for each OPP.

---
 drivers/opp/Makefile        |   1 +
 drivers/opp/ti-opp-supply.c | 425 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 426 insertions(+)
 create mode 100644 drivers/opp/ti-opp-supply.c
drivers/opp/Makefile +1 -0
index e70ceb406fe9..6ce6aefacc81 100644
@@ -2,3 +2,4 @@ ccflags-$(CONFIG_DEBUG_DRIVER)	:= -DDEBUG
 obj-y				+= core.o cpu.o
 obj-$(CONFIG_OF)		+= of.o
 obj-$(CONFIG_DEBUG_FS)		+= debugfs.o
+obj-$(CONFIG_ARM_TI_CPUFREQ)	+= ti-opp-supply.o
drivers/opp/ti-opp-supply.c new file +425 -0

425 lines not on this page · raw message

Signature · 1 line
2.15.1
maintainer
#10 lore raw

v2 cover PM / OPP: Introduce ti-opp-supply driver

In reply to Dave Gerlach
Quoted 22 lines · Dave Gerlach

Hi,
This is v2 of the series to introduce the ti-opp-supply driver which makes use of the OPP core to enable multiple regulator DVFS and AVS Class0 for TI DRA7 and AM57 platforms. Version 1 of this series can be found here [1].

Very few changes since v1, just added Viresh's acks to patches 1 and 2 and added SPDX license to the ti-opp-supply driver in patch 4.

Pushed updated branch here just in case [2].

Regards,
Dave

[1] https://www.spinics.net/lists/devicetree/msg205957.html
[2] https://github.com/dgerlach/linux-pm/tree/upstream/v4.15/ti-multireg-support-v2

Dave Gerlach (4):
cpufreq: ti-cpufreq: Convert to module_platform_driver
cpufreq: ti-cpufreq: Add support for multiple regulators
dt-bindings: opp: Introduce ti-opp-supply bindings PM / OPP: Add ti-opp-supply driver

Quoted 7 lines
 .../bindings/opp/ti-omap5-opp-supply.txt           |  63 +++
 drivers/cpufreq/ti-cpufreq.c                       |  51 ++-
 drivers/opp/Makefile                               |   1 +
 drivers/opp/ti-opp-supply.c                        | 425 +++++++++++++++++++++
 4 files changed, 534 insertions(+), 6 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/opp/ti-omap5-opp-supply.txt
 create mode 100644 drivers/opp/ti-opp-supply.c
Signature · 1 line
viresh
#11 lore raw

v2 cover PM / OPP: Introduce ti-opp-supply driver

In reply to Dave Gerlach
Quoted 4 lines · Dave Gerlach

Hi,
This is v2 of the series to introduce the ti-opp-supply driver which makes use of the OPP core to enable multiple regulator DVFS and AVS Class0 for TI DRA7 and AM57 platforms. Version 1 of this series can be found here [1].

Good to see this :) For the whole series: