Skip to contentSkip to conversation

ARM64: dts: cpufreq: mt8173: Migrate mt8173-cpufreq to use OPPv2 bindings

PATCH New Pi-Cheng Chen 5 participants 15 messages Dec 27, 2015 – Feb 3, 2016

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

v2 cover ARM64: dts: cpufreq: mt8173: Migrate mt8173-cpufreq to use OPPv2 bindings

This series tries to migrate mt8173-cpufreq driver to use operating-points-v2 bindings and add support for mt8173-cpufreq driver

v1->v2:
- update dev_pm_opp_of_get_sharing_cpus() to setup bitfield of original CPU
- rename OPP nodes in dts according to OPPv2 bindings in linux-next

Pi-Cheng Chen (3):
PM/OPP: Don't skip cpu_dev->id when setting up cpumask
cpufreq: mt8173: migrate to use operating-points-v2 bindings
ARM64: dts: mt8173: Add CPU OPP, clock and regulator supply properties

 arch/arm64/boot/dts/mediatek/mt8173-evb.dts | 18 ++++++
 arch/arm64/boot/dts/mediatek/mt8173.dtsi    | 90 +++++++++++++++++++++++++++++
 drivers/base/power/opp/cpu.c                |  4 --
 drivers/cpufreq/mt8173-cpufreq.c            | 17 ++++--
 4 files changed, 119 insertions(+), 10 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH v2 1/3 PM/OPP: Don't skip cpu_dev->id when setting up cpumask

Don't skip cpu_dev->id when setting up cpumask for CPUs that share the same OPP table. This might be helpful when handling cpumask without the original CPU bitfield set.

---
 drivers/base/power/opp/cpu.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/base/power/opp/cpu.c +0 -4
index 7b445e8..4914a0d 100644
@@ -214,7 +214,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_add_table);
 /*
  * Works only for OPP v2 bindings.
  *
- * cpumask should be already set to mask of cpu_dev->id.
  * Returns -ENOENT if operating-points-v2 bindings aren't supported.
  */
 int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask)
@@ -235,9 +234,6 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask
 		goto put_cpu_node;
 
 	for_each_possible_cpu(cpu) {
-		if (cpu == cpu_dev->id)
-			continue;
-
 		tcpu_dev = get_cpu_device(cpu);
 		if (!tcpu_dev) {
 			dev_err(cpu_dev, "%s: failed to get cpu%d device\n",
Signature · 1 line
1.9.1
maintainer
#2 lore raw

PATCH v2 1/3 PM/OPP: Don't skip cpu_dev->id when setting up cpumask

Quoted 22 lines · Pi-Cheng Chen

Don't skip cpu_dev->id when setting up cpumask for CPUs that share the same OPP table. This might be helpful when handling cpumask without the original CPU bitfield set.

---
 drivers/base/power/opp/cpu.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/base/power/opp/cpu.c +0 -1
index 7b445e8..4914a0d 100644
@@ -214,7 +214,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_add_table);
 /*
  * Works only for OPP v2 bindings.
  *
- * cpumask should be already set to mask of cpu_dev->id.
  * Returns -ENOENT if operating-points-v2 bindings aren't supported.
  */
 int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask)

drivers/base/power/opp/cpu.c int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask · line 239

Quoted 9 lines
drivers/base/power/opp/cpu.c +0 -3
@@ -235,9 +234,6 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask
 		goto put_cpu_node;
 
 	for_each_possible_cpu(cpu) {
-		if (cpu == cpu_dev->id)
-			continue;
-
 		tcpu_dev = get_cpu_device(cpu);
 		if (!tcpu_dev) {
 			dev_err(cpu_dev, "%s: failed to get cpu%d device\n",

Not this way. You should just set 'cpumask' to cpumask of cpu_dev->id at the top of the function.

Signature · 1 line
viresh
#3 lore raw

PATCH v2 1/1 PM/OPP: Set cpu_dev->id in cpumask first

Set cpu_dev->id in cpumask first when setting up cpumask for CPUs that share the same OPP table. This might be helpful when handling cpumask without the original CPU bitfield set.

---
v1->v2:
- Set cpu_dev->id in cpumask at the top instead of skip it in the loop

---
 drivers/base/power/opp/cpu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/power/opp/cpu.c +2 -1
index 7b445e8..9f0c155 100644
@@ -214,7 +214,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_add_table);
 /*
  * Works only for OPP v2 bindings.
  *
- * cpumask should be already set to mask of cpu_dev->id.
  * Returns -ENOENT if operating-points-v2 bindings aren't supported.
  */
 int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask)
@@ -230,6 +229,8 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask
 		return -ENOENT;
 	}
 
+	cpumask_set_cpu(cpu_dev->id, cpumask);
+
 	/* OPPs are shared ? */
 	if (!of_property_read_bool(np, "opp-shared"))
 		goto put_cpu_node;
Signature · 1 line
1.9.1
maintainer
#4 lore raw

PATCH v2 1/1 PM/OPP: Set cpu_dev->id in cpumask first

Quoted 25 lines · Pi-Cheng Chen

Set cpu_dev->id in cpumask first when setting up cpumask for CPUs that share the same OPP table. This might be helpful when handling cpumask without the original CPU bitfield set.

---
v1->v2:
- Set cpu_dev->id in cpumask at the top instead of skip it in the loop

---
 drivers/base/power/opp/cpu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/power/opp/cpu.c +0 -1
index 7b445e8..9f0c155 100644
@@ -214,7 +214,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_add_table);
 /*
  * Works only for OPP v2 bindings.
  *
- * cpumask should be already set to mask of cpu_dev->id.
  * Returns -ENOENT if operating-points-v2 bindings aren't supported.
  */
 int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask)

drivers/base/power/opp/cpu.c int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask · line 236

Quoted 8 lines
drivers/base/power/opp/cpu.c +2 -0
@@ -230,6 +229,8 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask
 		return -ENOENT;
 	}
 
+	cpumask_set_cpu(cpu_dev->id, cpumask);
+
 	/* OPPs are shared ? */
 	if (!of_property_read_bool(np, "opp-shared"))
 		goto put_cpu_node;
Signature · 1 line
viresh
#5 lore raw

PATCH v2 1/1 PM/OPP: Set cpu_dev->id in cpumask first

Quoted 29 lines · Viresh Kumar
Quoted 28 lines · Pi-Cheng Chen

Set cpu_dev->id in cpumask first when setting up cpumask for CPUs that share the same OPP table. This might be helpful when handling cpumask without the original CPU bitfield set.

---
v1->v2:
- Set cpu_dev->id in cpumask at the top instead of skip it in the loop

---
 drivers/base/power/opp/cpu.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/base/power/opp/cpu.c +0 -1
index 7b445e8..9f0c155 100644
@@ -214,7 +214,6 @@ EXPORT_SYMBOL_GPL(dev_pm_opp_of_cpumask_add_table);
 /*
  * Works only for OPP v2 bindings.
  *
- * cpumask should be already set to mask of cpu_dev->id.
  * Returns -ENOENT if operating-points-v2 bindings aren't supported.
  */
 int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask)
@@ -230,6 +229,8 @@ int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask
 		return -ENOENT;
 	}
 
Quoted 7 lines

drivers/base/power/opp/cpu.c int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, cpumask_var_t cpumask · line 236

Quoted 5 lines
drivers/base/power/opp/cpu.c +2 -0
+	cpumask_set_cpu(cpu_dev->id, cpumask);
+
 	/* OPPs are shared ? */
 	if (!of_property_read_bool(np, "opp-shared"))
 		goto put_cpu_node;

Applied, along with the [2-3/3], thanks!

#6 lore raw

PATCH v2 2/3 cpufreq: mt8173: migrate to use operating-points-v2 bindings

In reply to Pi-Cheng Chen

Modify mt8173-cpufreq driver to get OPP-sharing information and set up OPP table provided by operating-points-v2 bindings.

---
 drivers/cpufreq/mt8173-cpufreq.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
drivers/cpufreq/mt8173-cpufreq.c +11 -6
index fd601b9..1efba34 100644
@@ -390,7 +390,15 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
 	/* Both presence and absence of sram regulator are valid cases. */
 	sram_reg = regulator_get_exclusive(cpu_dev, "sram");
 
-	ret = dev_pm_opp_of_add_table(cpu_dev);
+	/* Get OPP-sharing information from "operating-points-v2" bindings */
+	ret = dev_pm_opp_of_get_sharing_cpus(cpu_dev, &info->cpus);
+	if (ret) {
+		pr_err("failed to get OPP-sharing information for cpu%d\n",
+		       cpu);
+		goto out_free_resources;
+	}
+
+	ret = dev_pm_opp_of_cpumask_add_table(&info->cpus);
 	if (ret) {
 		pr_warn("no OPP table for cpu%d\n", cpu);
 		goto out_free_resources;
@@ -421,13 +429,10 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
 	 */
 	info->need_voltage_tracking = !IS_ERR(sram_reg);
 
-	/* CPUs in the same cluster share a clock and power domain. */
-	cpumask_copy(&info->cpus, &cpu_topology[cpu].core_sibling);
-
 	return 0;
 
 out_free_opp_table:
-	dev_pm_opp_of_remove_table(cpu_dev);
+	dev_pm_opp_of_cpumask_remove_table(&info->cpus);
 
 out_free_resources:
 	if (!IS_ERR(proc_reg))
@@ -453,7 +458,7 @@ static void mtk_cpu_dvfs_info_release(struct mtk_cpu_dvfs_info *info)
 	if (!IS_ERR(info->inter_clk))
 		clk_put(info->inter_clk);
 
-	dev_pm_opp_of_remove_table(info->cpu_dev);
+	dev_pm_opp_of_cpumask_remove_table(&info->cpus);
 }
 
 static int mtk_cpufreq_init(struct cpufreq_policy *policy)
Signature · 1 line
1.9.1
maintainer
#7 lore raw

PATCH v2 2/3 cpufreq: mt8173: migrate to use operating-points-v2 bindings

Quoted 7 lines · Pi-Cheng Chen

Modify mt8173-cpufreq driver to get OPP-sharing information and set up OPP table provided by operating-points-v2 bindings.

---
 drivers/cpufreq/mt8173-cpufreq.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
Signature · 1 line
viresh
#8 lore raw

PATCH v2 3/3 ARM64: dts: mt8173: Add CPU OPP, clock and regulator supply properties

In reply to Pi-Cheng Chen

Add operating-points-v2, clock, and regulator supply properties required by mt8173-cpufreq driver to enable it.

---
This patch is based on the patch[1] that adds underlying clock MUX for MT8173 which is needed by mt8173-cpufreq driver but not yet picked.

[1] http://article.gmane.org/gmane.linux.kernel.clk/325

---
 arch/arm64/boot/dts/mediatek/mt8173-evb.dts | 18 ++++++
 arch/arm64/boot/dts/mediatek/mt8173.dtsi    | 90 +++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+)
arch/arm64/boot/dts/mediatek/mt8173-evb.dts +18 -0
index 811cb76..5b6321b 100644
@@ -405,6 +405,24 @@
 	status = "okay";
 };
 
+&cpu0 {
+	proc-supply = <&mt6397_vpca15_reg>;
+};
+
+&cpu1 {
+	proc-supply = <&mt6397_vpca15_reg>;
+};
+
+&cpu2 {
+	proc-supply = <&da9211_vcpu_reg>;
+	sram-supply = <&mt6397_vsramca7_reg>;
+};
+
+&cpu3 {
+	proc-supply = <&da9211_vcpu_reg>;
+	sram-supply = <&mt6397_vsramca7_reg>;
+};
+
 &uart0 {
 	status = "okay";
 };
arch/arm64/boot/dts/mediatek/mt8173.dtsi +90 -0

120 lines not on this page · raw message

Signature · 1 line
1.9.1
maintainer
#9 lore raw

PATCH v2 3/3 ARM64: dts: mt8173: Add CPU OPP, clock and regulator supply properties

Quoted 8 lines · Pi-Cheng Chen

Add operating-points-v2, clock, and regulator supply properties required by mt8173-cpufreq driver to enable it.

---
This patch is based on the patch[1] that adds underlying clock MUX for MT8173 which is needed by mt8173-cpufreq driver but not yet picked.

Quoted 5 lines

[1] http://article.gmane.org/gmane.linux.kernel.clk/325

---
 arch/arm64/boot/dts/mediatek/mt8173-evb.dts | 18 ++++++
 arch/arm64/boot/dts/mediatek/mt8173.dtsi    | 90 +++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+)
Signature · 1 line
viresh
#10 lore raw

PATCH v2 3/3 ARM64: dts: mt8173: Add CPU OPP, clock and regulator supply properties

Quoted 9 lines · On Monday 28 December 2015 08:43:40 Viresh Kumar wrote:
Quoted 8 lines · Pi-Cheng Chen

Add operating-points-v2, clock, and regulator supply properties required by mt8173-cpufreq driver to enable it.

---
This patch is based on the patch[1] that adds underlying clock MUX for MT8173 which is needed by mt8173-cpufreq driver but not yet picked.

Quoted 8 lines
Quoted 5 lines

[1] http://article.gmane.org/gmane.linux.kernel.clk/325

---
 arch/arm64/boot/dts/mediatek/mt8173-evb.dts | 18 ++++++
 arch/arm64/boot/dts/mediatek/mt8173.dtsi    | 90 +++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+)

This patch is now in linux-next through Rafael's pm tree, and it breaks the arm64 build:

arm64-defconfig
Error: ../arch/arm64/boot/dts/mediatek/mt8173.dtsi:132.24-25 syntax error

Please revert.

In the future, please send all dts changes through the proper maintainer channels (-> Mattias -> arm-soc), and make sure they actually build.

Arnd

maintainer
#11 lore raw

PATCH v2 3/3 ARM64: dts: mt8173: Add CPU OPP, clock and regulator supply properties

Quoted 22 lines · Arnd Bergmann
Quoted 9 lines · On Monday 28 December 2015 08:43:40 Viresh Kumar wrote:
Quoted 8 lines · Pi-Cheng Chen

Add operating-points-v2, clock, and regulator supply properties required by mt8173-cpufreq driver to enable it.

---
This patch is based on the patch[1] that adds underlying clock MUX for MT8173 which is needed by mt8173-cpufreq driver but not yet picked.

Quoted 8 lines
Quoted 5 lines

[1] http://article.gmane.org/gmane.linux.kernel.clk/325

---
 arch/arm64/boot/dts/mediatek/mt8173-evb.dts | 18 ++++++
 arch/arm64/boot/dts/mediatek/mt8173.dtsi    | 90 +++++++++++++++++++++++++++++
 2 files changed, 108 insertions(+)

This patch is now in linux-next through Rafael's pm tree, and it breaks the arm64 build:

Quoted 8 lines

arm64-defconfig
Error: ../arch/arm64/boot/dts/mediatek/mt8173.dtsi:132.24-25 syntax error

Please revert.

In the future, please send all dts changes through the proper maintainer channels (-> Mattias -> arm-soc), and make sure they actually build.

Rafael has already reverted that, AFAIK, after Mark Brown reported the build issue.

Signature · 1 line
viresh
maintainer Applied
#12 lore raw

PATCH v2 3/3 ARM64: dts: mt8173: Add CPU OPP, clock and regulator supply properties

Quoted 27 lines · Viresh Kumar
Quoted 26 lines · Arnd Bergmann
Quoted 9 lines · On Monday 28 December 2015 08:43:40 Viresh Kumar wrote:
Quoted 8 lines · Pi-Cheng Chen

Add operating-points-v2, clock, and regulator supply properties required by mt8173-cpufreq driver to enable it.

---
This patch is based on the patch[1] that adds underlying clock MUX for MT8173 which is needed by mt8173-cpufreq driver but not yet picked.

Quoted 8 lines
Quoted 5 lines

[1] http://article.gmane.org/gmane.linux.kernel.clk/325

---
  arch/arm64/boot/dts/mediatek/mt8173-evb.dts | 18 ++++++
  arch/arm64/boot/dts/mediatek/mt8173.dtsi    | 90 +++++++++++++++++++++++++++++
  2 files changed, 108 insertions(+)

This patch is now in linux-next through Rafael's pm tree, and it breaks the arm64 build:

arm64-defconfig
Error: ../arch/arm64/boot/dts/mediatek/mt8173.dtsi:132.24-25 syntax error

Quoted 8 lines
Quoted 4 lines

Please revert.

In the future, please send all dts changes through the proper maintainer channels (-> Mattias -> arm-soc), and make sure they actually build.

Rafael has already reverted that, AFAIK, after Mark Brown reported the build issue.

Applied to v4.5-next/dts

Thanks.

maintainer
#13 lore raw

PATCH v2 3/3 ARM64: dts: mt8173: Add CPU OPP, clock and regulator supply properties

Quoted 35 lines · Matthias Brugger
Quoted 32 lines · Viresh Kumar
Quoted 31 lines · Arnd Bergmann
Quoted 9 lines · On Monday 28 December 2015 08:43:40 Viresh Kumar wrote:
Quoted 8 lines · Pi-Cheng Chen

Add operating-points-v2, clock, and regulator supply properties required by mt8173-cpufreq driver to enable it.

---
This patch is based on the patch[1] that adds underlying clock MUX for MT8173 which is needed by mt8173-cpufreq driver but not yet picked.

Quoted 9 lines
Quoted 6 lines

[1] http://article.gmane.org/gmane.linux.kernel.clk/325

---
  arch/arm64/boot/dts/mediatek/mt8173-evb.dts | 18 ++++++
  arch/arm64/boot/dts/mediatek/mt8173.dtsi    | 90
+++++++++++++++++++++++++++++
  2 files changed, 108 insertions(+)

This patch is now in linux-next through Rafael's pm tree, and it breaks the
arm64 build:

arm64-defconfig
Error: ../arch/arm64/boot/dts/mediatek/mt8173.dtsi:132.24-25 syntax error

Please revert.

Quoted 9 lines
Quoted 6 lines
Quoted 2 lines

In the future, please send all dts changes through the proper maintainer channels (-> Mattias -> arm-soc), and make sure they actually build.

Rafael has already reverted that, AFAIK, after Mark Brown reported the build issue.

Applied to v4.5-next/dts

I oversaw that this needs a clock patch, which is not yet mainlined. I deleted this patch from my tree.

#14 lore raw

PATCH v2 3/3 ARM64: dts: mt8173: Add CPU OPP, clock and regulator supply properties

Quoted 52 lines · Matthias Brugger
Quoted 49 lines · Matthias Brugger
Quoted 44 lines · Viresh Kumar
Quoted 33 lines · Arnd Bergmann
Quoted 19 lines · On Monday 28 December 2015 08:43:40 Viresh Kumar wrote:
Quoted 9 lines · Pi-Cheng Chen

Add operating-points-v2, clock, and regulator supply properties required by mt8173-cpufreq driver to enable it.

---
This patch is based on the patch[1] that adds underlying clock MUX for MT8173 which is needed by mt8173-cpufreq driver but not yet picked.

Quoted 6 lines

[1] http://article.gmane.org/gmane.linux.kernel.clk/325

---
  arch/arm64/boot/dts/mediatek/mt8173-evb.dts | 18 ++++++
  arch/arm64/boot/dts/mediatek/mt8173.dtsi    | 90
+++++++++++++++++++++++++++++
  2 files changed, 108 insertions(+)
Quoted 2 lines

This patch is now in linux-next through Rafael's pm tree, and it breaks the
arm64 build:

arm64-defconfig
Error: ../arch/arm64/boot/dts/mediatek/mt8173.dtsi:132.24-25 syntax error

Quoted 4 lines

Please revert.

In the future, please send all dts changes through the proper maintainer channels (-> Mattias -> arm-soc), and make sure they actually build.

Rafael has already reverted that, AFAIK, after Mark Brown reported the build issue.

Quoted 5 lines
Quoted 2 lines

Applied to v4.5-next/dts

I oversaw that this needs a clock patch, which is not yet mainlined. I deleted this patch from my tree.

I should mention that explicitly.
Sorry for the inconvenience.

Pi-Cheng