Skip to contentSkip to conversation

Add CPU Frequency scaling support on Armada 37xx

PATCH Superseded Gregory CLEMENT 6 participants 20 messages Dec 7, 2017 – Dec 13, 2017

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add CPU Frequency scaling support on Armada 37xx

Hi,

This is the second version of a series adding the CPU Frequency support on Armada 37xx using DVFS. It is based on the initial work of Evan Wang and Victor Gu.

The main change since the first version was a bug fixed in the "cpufreq: Add DVFS support for Armada 37xx" patch which was preventing to register the opp. An other noticeable change is the 4th patch which is new adding the use of dev_pm_opp_remove and removing an comment became wrong. The other changes are described in the change log.

DVFS control is done by a set of registers from the North Bridge Power Management block. The binding for this block is documented in patch 1.

While adding a new cpufreq driver I found that the Kconfig and Makefile were no more in order, so it is fixed by patch 2 and 3.

The 5th patch is just about updating the MAINTAINERS file with the new driver.

The next patch is the real purpose of the series. The main goal of this driver is to setup the CPU load level in the hardware to associate them to CPU frequencies and register a standard cpufreq driver. Note that the hardware also capable of doing AVS (Adaptive Voltage Scaling), by associating a voltage on each level beside the CPU frequency. However, this support is not yet ready, so it is not part of this series.

Finally, the last patch is for arm-soc the arm-soc subsystem through mvebu and update the device tree to support the CPU frequency scaling.

An update on the CPU clock driver is needed in order to take into account the DVFS setting. It's the purpose of an other series already sent, but is no dependencies between the series (for building or at runtime).

Thanks,

Gregory

Changelog:

v1 -> v2:

- using syscon instead of nb_pm for the binding of the North bridge power management unit: reported by Rob Herring

- fix sorting inside the big LITTLE section for the Kconfig: reported by Viresh Kumar

- fix the bogus freq calculation in armada37xx_cpufreq_driver_init, bug reported by Andre Heider

- use dev_pm_opp_remove() on the previous opp if dev_pm_opp_add() failed, reported by Viresh Kumar

- add the Tested-by flag from Andre Heider on "cpufreq: Add DVFS support for Armada 37xx" patch

Gregory CLEMENT (7):
dt-bindings: marvell: Add documentation for the North Bridge PM on
Armada 37xx
cpufreq: ARM: sort the Kconfig menu
cpufreq: sort the drivers in ARM part
cpufreq: mvebu: Use dev_pm_opp_remove()
MAINTAINERS: add new entries for Armada 37xx cpufreq driver
cpufreq: Add DVFS support for Armada 37xx
arm64: dts: marvell: armada-37xx: add nodes allowing cpufreq support

 .../bindings/arm/marvell/armada-37xx.txt           |  19 ++
 MAINTAINERS                                        |   1 +
 arch/arm64/boot/dts/marvell/armada-372x.dtsi       |   1 +
 arch/arm64/boot/dts/marvell/armada-37xx.dtsi       |   7 +
 drivers/cpufreq/Kconfig.arm                        |  89 ++++----
 drivers/cpufreq/Makefile                           |   9 +-
 drivers/cpufreq/armada-37xx-cpufreq.c              | 241 +++++++++++++++++++++
 drivers/cpufreq/mvebu-cpufreq.c                    |  11 +-
 8 files changed, 327 insertions(+), 51 deletions(-)
 create mode 100644 drivers/cpufreq/armada-37xx-cpufreq.c
Signature · 1 line
2.15.0
#1 lore raw

PATCH v2 1/7 dt-bindings: marvell: Add documentation for the North Bridge PM on Armada 37xx

Extend the documentation of the Armada 37xx SoC with the the North Bridge Power Management component.

---
 .../devicetree/bindings/arm/marvell/armada-37xx.txt   | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
Documentation/devicetree/bindings/arm/marvell/armada-37xx.txt +19 -0
index 51336e5fc761..35c3c3460d17 100644
@@ -14,3 +14,22 @@ following property before the previous one:
 Example:
 
 compatible = "marvell,armada-3720-db", "marvell,armada3720", "marvell,armada3710";
+
+
+Power management
+----------------
+
+For power management (particularly DVFS and AVS), the North Bridge
+Power Management component is needed:
+
+Required properties:
+- compatible     : should contain "marvell,armada-3700-nb-pm", "syscon";
+- reg            : the register start and length for the North Bridge
+		    Power Management
+
+Example:
+
+nb_pm: syscon at 14000 {
+	compatible = "marvell,armada-3700-nb-pm", "syscon";
+	reg = <0x14000 0x60>;
+}
Signature · 1 line
2.15.0
maintainer
#2 lore raw

PATCH v2 1/7 dt-bindings: marvell: Add documentation for the North Bridge PM on Armada 37xx

Quoted 7 lines · Gregory CLEMENT

Extend the documentation of the Armada 37xx SoC with the the North Bridge Power Management component.

---
 .../devicetree/bindings/arm/marvell/armada-37xx.txt   | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)
#3 lore raw

PATCH v2 2/7 cpufreq: ARM: sort the Kconfig menu

In reply to Gregory CLEMENT

Group all the related big LITTLE configuration together and sort the other entries in alphabetic order.

---
 drivers/cpufreq/Kconfig.arm | 82 ++++++++++++++++++++++-----------------------
 1 file changed, 41 insertions(+), 41 deletions(-)
drivers/cpufreq/Kconfig.arm +41 -41
index bdce4488ded1..0baf43837b51 100644
@@ -2,6 +2,23 @@
 # ARM CPU Frequency scaling drivers
 #
 
+config ACPI_CPPC_CPUFREQ
+	tristate "CPUFreq driver based on the ACPI CPPC spec"
+	depends on ACPI_PROCESSOR
+	select ACPI_CPPC_LIB
+	default n
+	help
+	  This adds a CPUFreq driver which uses CPPC methods
+	  as described in the ACPIv5.1 spec. CPPC stands for
+	  Collaborative Processor Performance Controls. It
+	  is based on an abstract continuous scale of CPU
+	  performance values which allows the remote power
+	  processor to flexibly optimize for power and
+	  performance. CPPC relies on power management firmware
+	  support for its operation.
+
+	  If in doubt, say N.
+
 # big LITTLE core layer and glue drivers
 config ARM_BIG_LITTLE_CPUFREQ
 	tristate "Generic ARM big LITTLE CPUfreq driver"
@@ -12,6 +29,30 @@ config ARM_BIG_LITTLE_CPUFREQ
 	help
 	  This enables the Generic CPUfreq driver for ARM big.LITTLE platforms.
 
+config ARM_DT_BL_CPUFREQ
+	tristate "Generic probing via DT for ARM big LITTLE CPUfreq driver"
+	depends on ARM_BIG_LITTLE_CPUFREQ && OF
+	help
+	  This enables probing via DT for Generic CPUfreq driver for ARM
+	  big.LITTLE platform. This gets frequency tables from DT.
+
+config ARM_SCPI_CPUFREQ
+        tristate "SCPI based CPUfreq driver"
+	depends on ARM_BIG_LITTLE_CPUFREQ && ARM_SCPI_PROTOCOL && COMMON_CLK_SCPI
+        help
+	  This adds the CPUfreq driver support for ARM big.LITTLE platforms
+	  using SCPI protocol for CPU power management.
+
+	  This driver uses SCPI Message Protocol driver to interact with the
+	  firmware providing the CPU DVFS functionality.
+
+config ARM_VEXPRESS_SPC_CPUFREQ
+        tristate "Versatile Express SPC based CPUfreq driver"
+	depends on ARM_BIG_LITTLE_CPUFREQ && ARCH_VEXPRESS_SPC
+        help
+          This add the CPUfreq driver support for Versatile Express
+	  big.LITTLE platforms using SPC for power management.
+
 config ARM_BRCMSTB_AVS_CPUFREQ
 	tristate "Broadcom STB AVS CPUfreq driver"
 	depends on ARCH_BRCMSTB || COMPILE_TEST
@@ -33,20 +74,6 @@ config ARM_BRCMSTB_AVS_CPUFREQ_DEBUG
 
 	  If in doubt, say N.
 
-config ARM_DT_BL_CPUFREQ
-	tristate "Generic probing via DT for ARM big LITTLE CPUfreq driver"
-	depends on ARM_BIG_LITTLE_CPUFREQ && OF
-	help
-	  This enables probing via DT for Generic CPUfreq driver for ARM
-	  big.LITTLE platform. This gets frequency tables from DT.
-
-config ARM_VEXPRESS_SPC_CPUFREQ
-        tristate "Versatile Express SPC based CPUfreq driver"
-	depends on ARM_BIG_LITTLE_CPUFREQ && ARCH_VEXPRESS_SPC
-        help
-          This add the CPUfreq driver support for Versatile Express
-	  big.LITTLE platforms using SPC for power management.
-
 config ARM_EXYNOS5440_CPUFREQ
 	tristate "SAMSUNG EXYNOS5440"
 	depends on SOC_EXYNOS5440
@@ -205,16 +232,6 @@ config ARM_SA1100_CPUFREQ
 config ARM_SA1110_CPUFREQ
 	bool
 
-config ARM_SCPI_CPUFREQ
-        tristate "SCPI based CPUfreq driver"
-	depends on ARM_BIG_LITTLE_CPUFREQ && ARM_SCPI_PROTOCOL && COMMON_CLK_SCPI
-        help
-	  This adds the CPUfreq driver support for ARM big.LITTLE platforms
-	  using SCPI protocol for CPU power management.
-
-	  This driver uses SCPI Message Protocol driver to interact with the
-	  firmware providing the CPU DVFS functionality.
-
 config ARM_SPEAR_CPUFREQ
 	bool "SPEAr CPUFreq support"
 	depends on PLAT_SPEAR
@@ -275,20 +292,3 @@ config ARM_PXA2xx_CPUFREQ
 	  This add the CPUFreq driver support for Intel PXA2xx SOCs.
 
 	  If in doubt, say N.
-
-config ACPI_CPPC_CPUFREQ
-	tristate "CPUFreq driver based on the ACPI CPPC spec"
-	depends on ACPI_PROCESSOR
-	select ACPI_CPPC_LIB
-	default n
-	help
-	  This adds a CPUFreq driver which uses CPPC methods
-	  as described in the ACPIv5.1 spec. CPPC stands for
-	  Collaborative Processor Performance Controls. It
-	  is based on an abstract continuous scale of CPU
-	  performance values which allows the remote power
-	  processor to flexibly optimize for power and
-	  performance. CPPC relies on power management firmware
-	  support for its operation.
-
-	  If in doubt, say N.
Signature · 1 line
2.15.0
maintainer
#4 lore raw

PATCH v2 2/7 cpufreq: ARM: sort the Kconfig menu

Quoted 7 lines · Gregory CLEMENT

Group all the related big LITTLE configuration together and sort the other entries in alphabetic order.

---
 drivers/cpufreq/Kconfig.arm | 82 ++++++++++++++++++++++-----------------------
 1 file changed, 41 insertions(+), 41 deletions(-)
Signature · 1 line
viresh
#5 lore raw

PATCH v2 3/7 cpufreq: sort the drivers in ARM part

In reply to Gregory CLEMENT

Keep the driver files alphabetically sorted.

---
 drivers/cpufreq/Makefile | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/cpufreq/Makefile +4 -4
index 812f9e0d01a3..d762e76887e7 100644
@@ -53,22 +53,24 @@ obj-$(CONFIG_ARM_BIG_LITTLE_CPUFREQ)	+= arm_big_little.o
 obj-$(CONFIG_ARM_DT_BL_CPUFREQ)		+= arm_big_little_dt.o
 
 obj-$(CONFIG_ARM_BRCMSTB_AVS_CPUFREQ)	+= brcmstb-avs-cpufreq.o
+obj-$(CONFIG_ACPI_CPPC_CPUFREQ)		+= cppc_cpufreq.o
 obj-$(CONFIG_ARCH_DAVINCI)		+= davinci-cpufreq.o
 obj-$(CONFIG_ARM_EXYNOS5440_CPUFREQ)	+= exynos5440-cpufreq.o
 obj-$(CONFIG_ARM_HIGHBANK_CPUFREQ)	+= highbank-cpufreq.o
 obj-$(CONFIG_ARM_IMX6Q_CPUFREQ)		+= imx6q-cpufreq.o
 obj-$(CONFIG_ARM_KIRKWOOD_CPUFREQ)	+= kirkwood-cpufreq.o
 obj-$(CONFIG_ARM_MEDIATEK_CPUFREQ)	+= mediatek-cpufreq.o
+obj-$(CONFIG_MACH_MVEBU_V7)		+= mvebu-cpufreq.o
 obj-$(CONFIG_ARM_OMAP2PLUS_CPUFREQ)	+= omap-cpufreq.o
 obj-$(CONFIG_ARM_PXA2xx_CPUFREQ)	+= pxa2xx-cpufreq.o
 obj-$(CONFIG_PXA3xx)			+= pxa3xx-cpufreq.o
-obj-$(CONFIG_ARM_S3C24XX_CPUFREQ)	+= s3c24xx-cpufreq.o
-obj-$(CONFIG_ARM_S3C24XX_CPUFREQ_DEBUGFS) += s3c24xx-cpufreq-debugfs.o
 obj-$(CONFIG_ARM_S3C2410_CPUFREQ)	+= s3c2410-cpufreq.o
 obj-$(CONFIG_ARM_S3C2412_CPUFREQ)	+= s3c2412-cpufreq.o
 obj-$(CONFIG_ARM_S3C2416_CPUFREQ)	+= s3c2416-cpufreq.o
 obj-$(CONFIG_ARM_S3C2440_CPUFREQ)	+= s3c2440-cpufreq.o
 obj-$(CONFIG_ARM_S3C64XX_CPUFREQ)	+= s3c64xx-cpufreq.o
+obj-$(CONFIG_ARM_S3C24XX_CPUFREQ)	+= s3c24xx-cpufreq.o
+obj-$(CONFIG_ARM_S3C24XX_CPUFREQ_DEBUGFS) += s3c24xx-cpufreq-debugfs.o
 obj-$(CONFIG_ARM_S5PV210_CPUFREQ)	+= s5pv210-cpufreq.o
 obj-$(CONFIG_ARM_SA1100_CPUFREQ)	+= sa1100-cpufreq.o
 obj-$(CONFIG_ARM_SA1110_CPUFREQ)	+= sa1110-cpufreq.o
@@ -81,8 +83,6 @@ obj-$(CONFIG_ARM_TEGRA124_CPUFREQ)	+= tegra124-cpufreq.o
 obj-$(CONFIG_ARM_TEGRA186_CPUFREQ)	+= tegra186-cpufreq.o
 obj-$(CONFIG_ARM_TI_CPUFREQ)		+= ti-cpufreq.o
 obj-$(CONFIG_ARM_VEXPRESS_SPC_CPUFREQ)	+= vexpress-spc-cpufreq.o
-obj-$(CONFIG_ACPI_CPPC_CPUFREQ) += cppc_cpufreq.o
-obj-$(CONFIG_MACH_MVEBU_V7)		+= mvebu-cpufreq.o
 
 
 ##################################################################################
Signature · 1 line
2.15.0
#7 lore raw

PATCH v2 4/7 cpufreq: mvebu: Use dev_pm_opp_remove()

In reply to Gregory CLEMENT

Since the introduction of this driver, the dev_pm_opp_remove() was added. So stop claiming we can't remove opp and use it in case of failure.

---
 drivers/cpufreq/mvebu-cpufreq.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/cpufreq/mvebu-cpufreq.c +5 -6
index ed915ee85dd9..419c2b01a44c 100644
@@ -76,12 +76,6 @@ static int __init armada_xp_pmsu_cpufreq_init(void)
 			return PTR_ERR(clk);
 		}
 
-		/*
-		 * In case of a failure of dev_pm_opp_add(), we don't
-		 * bother with cleaning up the registered OPP (there's
-		 * no function to do so), and simply cancel the
-		 * registration of the cpufreq device.
-		 */
 		ret = dev_pm_opp_add(cpu_dev, clk_get_rate(clk), 0);
 		if (ret) {
 			clk_put(clk);
@@ -90,6 +84,11 @@ static int __init armada_xp_pmsu_cpufreq_init(void)
 
 		ret = dev_pm_opp_add(cpu_dev, clk_get_rate(clk) / 2, 0);
 		if (ret) {
+			/*
+			 * The second opp failed to be added, remove
+			 * the first one before exiting.
+			 */
+			dev_pm_opp_remove(cpu_dev, clk_get_rate(clk));
 			clk_put(clk);
 			return ret;
 		}
Signature · 1 line
2.15.0
maintainer
#8 lore raw

PATCH v2 4/7 cpufreq: mvebu: Use dev_pm_opp_remove()

Quoted 8 lines · Gregory CLEMENT

Since the introduction of this driver, the dev_pm_opp_remove() was added. So stop claiming we can't remove opp and use it in case of failure.

---
 drivers/cpufreq/mvebu-cpufreq.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

There is no reason for this patch to be part of your series. You should have sent it separately. Please do it now.

And while you do it, you can add

Signature · 1 line
viresh
#9 lore raw

PATCH v2 4/7 cpufreq: mvebu: Use dev_pm_opp_remove()

In reply to Gregory CLEMENT

Hello,

Quoted 11 lines · Gregory CLEMENT
drivers/cpufreq/mvebu-cpufreq.c +0 -6
-		/*
-		 * In case of a failure of dev_pm_opp_add(), we don't
-		 * bother with cleaning up the registered OPP (there's
-		 * no function to do so), and simply cancel the
-		 * registration of the cpufreq device.
-		 */
 		ret = dev_pm_opp_add(cpu_dev, clk_get_rate(clk), 0);
 		if (ret) {
 			clk_put(clk);
@@ -90,6 +84,11 @@ static int __init armada_xp_pmsu_cpufreq_init(void)
 

drivers/cpufreq/mvebu-cpufreq.c static int __init armada_xp_pmsu_cpufreq_init(void) · line 94

Quoted 10 lines
drivers/cpufreq/mvebu-cpufreq.c +5 -0
 		ret = dev_pm_opp_add(cpu_dev, clk_get_rate(clk) / 2, 0);
 		if (ret) {
+			/*
+			 * The second opp failed to be added, remove
+			 * the first one before exiting.
+			 */
+			dev_pm_opp_remove(cpu_dev, clk_get_rate(clk));
 			clk_put(clk);
 			return ret;
 		}

This still doesn't fix the failure situation. Indeed, you are only removing the OPP at full rate for the current CPU, but you are not removing the OPPs for the N-1 previous CPUs that have been handled in previous iterations of the loop.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
maintainer
#10 lore raw

PATCH v2 4/7 cpufreq: mvebu: Use dev_pm_opp_remove()

Quoted 15 lines · Thomas Petazzoni

Hello,

Quoted 11 lines · Gregory CLEMENT
drivers/cpufreq/mvebu-cpufreq.c +0 -6
-		/*
-		 * In case of a failure of dev_pm_opp_add(), we don't
-		 * bother with cleaning up the registered OPP (there's
-		 * no function to do so), and simply cancel the
-		 * registration of the cpufreq device.
-		 */
 		ret = dev_pm_opp_add(cpu_dev, clk_get_rate(clk), 0);
 		if (ret) {
 			clk_put(clk);
@@ -90,6 +84,11 @@ static int __init armada_xp_pmsu_cpufreq_init(void)
 
Quoted 15 lines

drivers/cpufreq/mvebu-cpufreq.c static int __init armada_xp_pmsu_cpufreq_init(void) · line 94

Quoted 10 lines
drivers/cpufreq/mvebu-cpufreq.c +5 -0
 		ret = dev_pm_opp_add(cpu_dev, clk_get_rate(clk) / 2, 0);
 		if (ret) {
+			/*
+			 * The second opp failed to be added, remove
+			 * the first one before exiting.
+			 */
+			dev_pm_opp_remove(cpu_dev, clk_get_rate(clk));
 			clk_put(clk);
 			return ret;
 		}

This still doesn't fix the failure situation. Indeed, you are only removing the OPP at full rate for the current CPU, but you are not removing the OPPs for the N-1 previous CPUs that have been handled in previous iterations of the loop.

Sorry for missing that, I quickly looked at source and missed seeing the for_each_cpu loop :(

Signature · 1 line
viresh
#11 lore raw

PATCH v2 5/7 MAINTAINERS: add new entries for Armada 37xx cpufreq driver

In reply to Gregory CLEMENT

This new driver belongs to the mvebu family, update the MAINTAINER file to document it.

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +1 -0
index aa71ab52fd76..98dcee849481 100644
@@ -1582,6 +1582,7 @@ F:	arch/arm/boot/dts/kirkwood*
 F:	arch/arm/configs/mvebu_*_defconfig
 F:	arch/arm/mach-mvebu/
 F:	arch/arm64/boot/dts/marvell/armada*
+F:	drivers/cpufreq/armada-37xx-cpufreq.c
 F:	drivers/cpufreq/mvebu-cpufreq.c
 F:	drivers/irqchip/irq-armada-370-xp.c
 F:	drivers/irqchip/irq-mvebu-*
Signature · 1 line
2.15.0
maintainer
#12 lore raw

PATCH v2 5/7 MAINTAINERS: add new entries for Armada 37xx cpufreq driver

Quoted 13 lines · Gregory CLEMENT

This new driver belongs to the mvebu family, update the MAINTAINER file to document it.

---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)
MAINTAINERS +0 -0
index aa71ab52fd76..98dcee849481 100644

MAINTAINERS F: arch/arm/boot/dts/kirkwood* · line 1588

Quoted 7 lines
MAINTAINERS +1 -0
@@ -1582,6 +1582,7 @@ F:	arch/arm/boot/dts/kirkwood*
 F:	arch/arm/configs/mvebu_*_defconfig
 F:	arch/arm/mach-mvebu/
 F:	arch/arm64/boot/dts/marvell/armada*
+F:	drivers/cpufreq/armada-37xx-cpufreq.c
 F:	drivers/cpufreq/mvebu-cpufreq.c
 F:	drivers/irqchip/irq-armada-370-xp.c
 F:	drivers/irqchip/irq-mvebu-*
Signature · 1 line
viresh
#13 lore raw

PATCH v2 6/7 cpufreq: Add DVFS support for Armada 37xx

In reply to Gregory CLEMENT

This patch adds DVFS support for the Armada 37xx SoCs

There are up to four CPU frequency loads for Armada 37xx controlled by the hardware.

This driver associates the CPU load level to a frequency, then the hardware will switch while selecting a load level.

The hardware also can associate a voltage for each level (AVS support) but it is not yet supported

---
 drivers/cpufreq/Kconfig.arm           |   7 +
 drivers/cpufreq/Makefile              |   1 +
 drivers/cpufreq/armada-37xx-cpufreq.c | 241 ++++++++++++++++++++++++++++++++++
 3 files changed, 249 insertions(+)
 create mode 100644 drivers/cpufreq/armada-37xx-cpufreq.c
drivers/cpufreq/Kconfig.arm +7 -0
index 0baf43837b51..93c2987da83b 100644
@@ -19,6 +19,13 @@ config ACPI_CPPC_CPUFREQ
 
 	  If in doubt, say N.
 
+config ARM_ARMADA_37XX_CPUFREQ
+	tristate "Armada 37xx CPUFreq support"
+	depends on ARCH_MVEBU
+	help
+	  This adds the CPUFreq driver support for Marvell Armada 37xx SoCs.
+	  The Armada 37xx PMU supports 4 frequency and VDD levels.
+
 # big LITTLE core layer and glue drivers
 config ARM_BIG_LITTLE_CPUFREQ
 	tristate "Generic ARM big LITTLE CPUfreq driver"
drivers/cpufreq/Makefile +1 -0
index d762e76887e7..e07715ce8844 100644
@@ -52,6 +52,7 @@ obj-$(CONFIG_ARM_BIG_LITTLE_CPUFREQ)	+= arm_big_little.o
 # LITTLE drivers, so that it is probed last.
 obj-$(CONFIG_ARM_DT_BL_CPUFREQ)		+= arm_big_little_dt.o
 
+obj-$(CONFIG_ARM_ARMADA_37XX_CPUFREQ)	+= armada-37xx-cpufreq.o
 obj-$(CONFIG_ARM_BRCMSTB_AVS_CPUFREQ)	+= brcmstb-avs-cpufreq.o
 obj-$(CONFIG_ACPI_CPPC_CPUFREQ)		+= cppc_cpufreq.o
 obj-$(CONFIG_ARCH_DAVINCI)		+= davinci-cpufreq.o
drivers/cpufreq/armada-37xx-cpufreq.c new file +241 -0

241 lines not on this page · raw message

Signature · 1 line
2.15.0
maintainer
#14 lore raw

PATCH v2 6/7 cpufreq: Add DVFS support for Armada 37xx

Quoted 15 lines · Gregory CLEMENT
drivers/cpufreq/armada-37xx-cpufreq.c new file +15 -0
+/* Power management in North Bridge register set */
+#define ARMADA_37XX_NB_L0L1	0x18
+#define ARMADA_37XX_NB_L2L3	0x1C
+#define	ARMADA_37XX_NB_TBG_DIV_OFF	13
+#define	ARMADA_37XX_NB_TBG_DIV_MASK	0x7
+#define	 ARMADA_37XX_NB_CLK_SEL_OFF	11
+#define	 ARMADA_37XX_NB_CLK_SEL_MASK	0x1
+#define	 ARMADA_37XX_NB_CLK_SEL_TBG      0x1
+#define	 ARMADA_37XX_NB_TBG_SEL_OFF	9
+#define	 ARMADA_37XX_NB_TBG_SEL_MASK	0x3
+#define	 ARMADA_37XX_NB_VDD_SEL_OFF	6
+#define	 ARMADA_37XX_NB_VDD_SEL_MASK	0x3
+#define	 ARMADA_37XX_NB_CONFIG_SHIFT	16
+#define ARMADA_37XX_NB_DYN_MOD	0x24
+#define	 ARMADA_37XX_NB_CLK_SEL_EN	BIT(26)

drivers/cpufreq/armada-37xx-cpufreq.c line 50

Quoted 10 lines
drivers/cpufreq/armada-37xx-cpufreq.c new file +10 -0
+#define	 ARMADA_37XX_NB_TBG_EN		BIT(28)
+#define	 ARMADA_37XX_NB_DIV_EN		BIT(29)
+#define	 ARMADA_37XX_NB_VDD_EN		BIT(30)
+#define	 ARMADA_37XX_NB_DFS_EN		BIT(31)
+#define ARMADA_37XX_NB_CPU_LOAD	0x30
+#define	 ARMADA_37XX_NB_CPU_LOAD_MASK	0x3
+#define	 ARMADA_37XX_DVFS_LOAD_0		0
+#define	 ARMADA_37XX_DVFS_LOAD_1		1
+#define	 ARMADA_37XX_DVFS_LOAD_2		2
+#define	 ARMADA_37XX_DVFS_LOAD_3		3

I thought you agreed to using space instead of tab after #define ?

Looks fine otherwise. You can add below after fixing above tab/space thing:

Signature · 1 line
viresh
#15 lore raw

PATCH v2 6/7 cpufreq: Add DVFS support for Armada 37xx

Hi Viresh,

Quoted 20 lines · Viresh Kumar
Quoted 19 lines · Gregory CLEMENT
drivers/cpufreq/armada-37xx-cpufreq.c new file +19 -0
+/* Power management in North Bridge register set */
+#define ARMADA_37XX_NB_L0L1	0x18
+#define ARMADA_37XX_NB_L2L3	0x1C
+#define	ARMADA_37XX_NB_TBG_DIV_OFF	13
+#define	ARMADA_37XX_NB_TBG_DIV_MASK	0x7
+#define	 ARMADA_37XX_NB_CLK_SEL_OFF	11
+#define	 ARMADA_37XX_NB_CLK_SEL_MASK	0x1
+#define	 ARMADA_37XX_NB_CLK_SEL_TBG      0x1
+#define	 ARMADA_37XX_NB_TBG_SEL_OFF	9
+#define	 ARMADA_37XX_NB_TBG_SEL_MASK	0x3
+#define	 ARMADA_37XX_NB_VDD_SEL_OFF	6
+#define	 ARMADA_37XX_NB_VDD_SEL_MASK	0x3
+#define	 ARMADA_37XX_NB_CONFIG_SHIFT	16
+#define ARMADA_37XX_NB_DYN_MOD	0x24
+#define	 ARMADA_37XX_NB_CLK_SEL_EN	BIT(26)
+#define	 ARMADA_37XX_NB_TBG_EN		BIT(28)
+#define	 ARMADA_37XX_NB_DIV_EN		BIT(29)
+#define	 ARMADA_37XX_NB_VDD_EN		BIT(30)
+#define	 ARMADA_37XX_NB_DFS_EN		BIT(31)
Quoted 8 lines

drivers/cpufreq/armada-37xx-cpufreq.c line 50

Quoted 6 lines
drivers/cpufreq/armada-37xx-cpufreq.c new file +6 -0
+#define ARMADA_37XX_NB_CPU_LOAD	0x30
+#define	 ARMADA_37XX_NB_CPU_LOAD_MASK	0x3
+#define	 ARMADA_37XX_DVFS_LOAD_0		0
+#define	 ARMADA_37XX_DVFS_LOAD_1		1
+#define	 ARMADA_37XX_DVFS_LOAD_2		2
+#define	 ARMADA_37XX_DVFS_LOAD_3		3

I thought you agreed to using space instead of tab after #define ?

Me too! Actually I did it, and I don't know what happened with this patch.

However it will be part of the next version and I will double check it.

Quoted 4 lines

Looks fine otherwise. You can add below after fixing above tab/space thing:

Thanks,

Gregory

Quoted 3 lines
Signature · 2 lines
-- 
viresh
Signature · 4 lines
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#16 lore raw

PATCH v2 7/7 arm64: dts: marvell: armada-37xx: add nodes allowing cpufreq support

In reply to Gregory CLEMENT

In order to be able to use cpu freq, we need to associate a clock to each CPU and to expose the power management registers.

---
 arch/arm64/boot/dts/marvell/armada-372x.dtsi | 1 +
 arch/arm64/boot/dts/marvell/armada-37xx.dtsi | 7 +++++++
 2 files changed, 8 insertions(+)
arch/arm64/boot/dts/marvell/armada-372x.dtsi +1 -0
index 59d7557d3b1b..2554e0baea6b 100644
@@ -56,6 +56,7 @@
 			device_type = "cpu";
 			compatible = "arm,cortex-a53","arm,armv8";
 			reg = <0x1>;
+			clocks = <&nb_periph_clk 16>;
 			enable-method = "psci";
 		};
 	};
arch/arm64/boot/dts/marvell/armada-37xx.dtsi +7 -0
index 90c26d616a54..3056d7168e0b 100644
@@ -65,6 +65,7 @@
 			device_type = "cpu";
 			compatible = "arm,cortex-a53", "arm,armv8";
 			reg = <0>;
+			clocks = <&nb_periph_clk 16>;
 			enable-method = "psci";
 		};
 	};
@@ -234,6 +235,12 @@
 				};
 			};
 
+			nb_pm: syscon at 14000 {
+				compatible = "marvell,armada-3700-nb-pm",
+					     "syscon";
+				reg = <0x14000 0x60>;
+			};
+
 			pinctrl_sb: pinctrl at 18800 {
 				compatible = "marvell,armada3710-sb-pinctrl",
 					     "syscon", "simple-mfd";
Signature · 1 line
2.15.0
#17 lore raw

v2 cover Add CPU Frequency scaling support on Armada 37xx

In reply to Gregory CLEMENT
Quoted 70 lines · CET Gregory CLEMENT

Hi,

This is the second version of a series adding the CPU Frequency support on Armada 37xx using DVFS. It is based on the initial work of Evan Wang and Victor Gu.

The main change since the first version was a bug fixed in the "cpufreq: Add DVFS support for Armada 37xx" patch which was preventing to register the opp. An other noticeable change is the 4th patch which is new adding the use of dev_pm_opp_remove and removing an comment became wrong. The other changes are described in the change log.

DVFS control is done by a set of registers from the North Bridge Power Management block. The binding for this block is documented in patch 1.

While adding a new cpufreq driver I found that the Kconfig and Makefile were no more in order, so it is fixed by patch 2 and 3.

The 5th patch is just about updating the MAINTAINERS file with the new driver.

The next patch is the real purpose of the series. The main goal of this driver is to setup the CPU load level in the hardware to associate them to CPU frequencies and register a standard cpufreq driver. Note that the hardware also capable of doing AVS (Adaptive Voltage Scaling), by associating a voltage on each level beside the CPU frequency. However, this support is not yet ready, so it is not part of this series.

Finally, the last patch is for arm-soc the arm-soc subsystem through mvebu and update the device tree to support the CPU frequency scaling.

An update on the CPU clock driver is needed in order to take into account the DVFS setting. It's the purpose of an other series already sent, but is no dependencies between the series (for building or at runtime).

Thanks,

Gregory

Changelog:

v1 -> v2:

- using syscon instead of nb_pm for the binding of the North bridge power management unit: reported by Rob Herring

- fix sorting inside the big LITTLE section for the Kconfig: reported by Viresh Kumar

- fix the bogus freq calculation in armada37xx_cpufreq_driver_init, bug reported by Andre Heider

- use dev_pm_opp_remove() on the previous opp if dev_pm_opp_add() failed, reported by Viresh Kumar

- add the Tested-by flag from Andre Heider on "cpufreq: Add DVFS support for Armada 37xx" patch

Gregory CLEMENT (7):
dt-bindings: marvell: Add documentation for the North Bridge PM on
Armada 37xx
cpufreq: ARM: sort the Kconfig menu
cpufreq: sort the drivers in ARM part
cpufreq: mvebu: Use dev_pm_opp_remove()
MAINTAINERS: add new entries for Armada 37xx cpufreq driver
cpufreq: Add DVFS support for Armada 37xx
arm64: dts: marvell: armada-37xx: add nodes allowing cpufreq support

Quoted 10 lines
 .../bindings/arm/marvell/armada-37xx.txt           |  19 ++
 MAINTAINERS                                        |   1 +
 arch/arm64/boot/dts/marvell/armada-372x.dtsi       |   1 +
 arch/arm64/boot/dts/marvell/armada-37xx.dtsi       |   7 +
 drivers/cpufreq/Kconfig.arm                        |  89 ++++----
 drivers/cpufreq/Makefile                           |   9 +-
 drivers/cpufreq/armada-37xx-cpufreq.c              | 241 +++++++++++++++++++++
 drivers/cpufreq/mvebu-cpufreq.c                    |  11 +-
 8 files changed, 327 insertions(+), 51 deletions(-)
 create mode 100644 drivers/cpufreq/armada-37xx-cpufreq.c

I'd like you to split patches [2-3/7] off this series as they aren't exactly related to the other changes in it.

Thanks,
Rafael

#18 lore raw

v2 cover Add CPU Frequency scaling support on Armada 37xx

Hi Rafael,

Quoted 82 lines · Rafael J. Wysocki
Quoted 70 lines · CET Gregory CLEMENT

Hi,

This is the second version of a series adding the CPU Frequency support on Armada 37xx using DVFS. It is based on the initial work of Evan Wang and Victor Gu.

The main change since the first version was a bug fixed in the "cpufreq: Add DVFS support for Armada 37xx" patch which was preventing to register the opp. An other noticeable change is the 4th patch which is new adding the use of dev_pm_opp_remove and removing an comment became wrong. The other changes are described in the change log.

DVFS control is done by a set of registers from the North Bridge Power Management block. The binding for this block is documented in patch 1.

While adding a new cpufreq driver I found that the Kconfig and Makefile were no more in order, so it is fixed by patch 2 and 3.

The 5th patch is just about updating the MAINTAINERS file with the new driver.

The next patch is the real purpose of the series. The main goal of this driver is to setup the CPU load level in the hardware to associate them to CPU frequencies and register a standard cpufreq driver. Note that the hardware also capable of doing AVS (Adaptive Voltage Scaling), by associating a voltage on each level beside the CPU frequency. However, this support is not yet ready, so it is not part of this series.

Finally, the last patch is for arm-soc the arm-soc subsystem through mvebu and update the device tree to support the CPU frequency scaling.

An update on the CPU clock driver is needed in order to take into account the DVFS setting. It's the purpose of an other series already sent, but is no dependencies between the series (for building or at runtime).

Thanks,

Gregory

Changelog:

v1 -> v2:

- using syscon instead of nb_pm for the binding of the North bridge power management unit: reported by Rob Herring

- fix sorting inside the big LITTLE section for the Kconfig: reported by Viresh Kumar

- fix the bogus freq calculation in armada37xx_cpufreq_driver_init, bug reported by Andre Heider

- use dev_pm_opp_remove() on the previous opp if dev_pm_opp_add() failed, reported by Viresh Kumar

- add the Tested-by flag from Andre Heider on "cpufreq: Add DVFS support for Armada 37xx" patch

Gregory CLEMENT (7):
dt-bindings: marvell: Add documentation for the North Bridge PM on
Armada 37xx
cpufreq: ARM: sort the Kconfig menu
cpufreq: sort the drivers in ARM part
cpufreq: mvebu: Use dev_pm_opp_remove()
MAINTAINERS: add new entries for Armada 37xx cpufreq driver
cpufreq: Add DVFS support for Armada 37xx
arm64: dts: marvell: armada-37xx: add nodes allowing cpufreq support

Quoted 10 lines
 .../bindings/arm/marvell/armada-37xx.txt           |  19 ++
 MAINTAINERS                                        |   1 +
 arch/arm64/boot/dts/marvell/armada-372x.dtsi       |   1 +
 arch/arm64/boot/dts/marvell/armada-37xx.dtsi       |   7 +
 drivers/cpufreq/Kconfig.arm                        |  89 ++++----
 drivers/cpufreq/Makefile                           |   9 +-
 drivers/cpufreq/armada-37xx-cpufreq.c              | 241 +++++++++++++++++++++
 drivers/cpufreq/mvebu-cpufreq.c                    |  11 +-
 8 files changed, 327 insertions(+), 51 deletions(-)
 create mode 100644 drivers/cpufreq/armada-37xx-cpufreq.c
Quoted 2 lines

I'd like you to split patches [2-3/7] off this series as they aren't exactly related to the other changes in it.

Actually the patch 6 depend on patch 2 and 3. To be more precise they modify the same area inside the files drivers/cpufreq/Kconfig.arm and drivers/cpufreq/Makefile.

So if I move them in an other series then there could be some merge conflicts.

Gregory

Quoted 4 lines

Thanks,
Rafael

Signature · 4 lines
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
#19 lore raw

v2 cover Add CPU Frequency scaling support on Armada 37xx

Quoted 89 lines · Gregory CLEMENT

Hi Rafael,

Quoted 82 lines · Rafael J. Wysocki
Quoted 70 lines · CET Gregory CLEMENT

Hi,

This is the second version of a series adding the CPU Frequency support on Armada 37xx using DVFS. It is based on the initial work of Evan Wang and Victor Gu.

The main change since the first version was a bug fixed in the "cpufreq: Add DVFS support for Armada 37xx" patch which was preventing to register the opp. An other noticeable change is the 4th patch which is new adding the use of dev_pm_opp_remove and removing an comment became wrong. The other changes are described in the change log.

DVFS control is done by a set of registers from the North Bridge Power Management block. The binding for this block is documented in patch 1.

While adding a new cpufreq driver I found that the Kconfig and Makefile were no more in order, so it is fixed by patch 2 and 3.

The 5th patch is just about updating the MAINTAINERS file with the new driver.

The next patch is the real purpose of the series. The main goal of this driver is to setup the CPU load level in the hardware to associate them to CPU frequencies and register a standard cpufreq driver. Note that the hardware also capable of doing AVS (Adaptive Voltage Scaling), by associating a voltage on each level beside the CPU frequency. However, this support is not yet ready, so it is not part of this series.

Finally, the last patch is for arm-soc the arm-soc subsystem through mvebu and update the device tree to support the CPU frequency scaling.

An update on the CPU clock driver is needed in order to take into account the DVFS setting. It's the purpose of an other series already sent, but is no dependencies between the series (for building or at runtime).

Thanks,

Gregory

Changelog:

v1 -> v2:

- using syscon instead of nb_pm for the binding of the North bridge power management unit: reported by Rob Herring

- fix sorting inside the big LITTLE section for the Kconfig: reported by Viresh Kumar

- fix the bogus freq calculation in armada37xx_cpufreq_driver_init, bug reported by Andre Heider

- use dev_pm_opp_remove() on the previous opp if dev_pm_opp_add() failed, reported by Viresh Kumar

- add the Tested-by flag from Andre Heider on "cpufreq: Add DVFS support for Armada 37xx" patch

Gregory CLEMENT (7):
dt-bindings: marvell: Add documentation for the North Bridge PM on
Armada 37xx
cpufreq: ARM: sort the Kconfig menu
cpufreq: sort the drivers in ARM part
cpufreq: mvebu: Use dev_pm_opp_remove()
MAINTAINERS: add new entries for Armada 37xx cpufreq driver
cpufreq: Add DVFS support for Armada 37xx
arm64: dts: marvell: armada-37xx: add nodes allowing cpufreq support

Quoted 10 lines
 .../bindings/arm/marvell/armada-37xx.txt           |  19 ++
 MAINTAINERS                                        |   1 +
 arch/arm64/boot/dts/marvell/armada-372x.dtsi       |   1 +
 arch/arm64/boot/dts/marvell/armada-37xx.dtsi       |   7 +
 drivers/cpufreq/Kconfig.arm                        |  89 ++++----
 drivers/cpufreq/Makefile                           |   9 +-
 drivers/cpufreq/armada-37xx-cpufreq.c              | 241 +++++++++++++++++++++
 drivers/cpufreq/mvebu-cpufreq.c                    |  11 +-
 8 files changed, 327 insertions(+), 51 deletions(-)
 create mode 100644 drivers/cpufreq/armada-37xx-cpufreq.c
Quoted 2 lines

I'd like you to split patches [2-3/7] off this series as they aren't exactly related to the other changes in it.

Quoted 6 lines

Actually the patch 6 depend on patch 2 and 3. To be more precise they modify the same area inside the files drivers/cpufreq/Kconfig.arm and drivers/cpufreq/Makefile.

So if I move them in an other series then there could be some merge conflicts.

That's fine. Merge conflicts are not a big issue to me.