Skip to contentSkip to conversation

davinci: Add cpufreq support when booting with device tree

PATCH New Adam Ford 2 participants 2 messages Sep 9, 2017 – Sep 11, 2017

Subsystems (3)
lore
Share & tools
lore

Adam Ford

author
#0 lore raw

PATCH 1/1 davinci: Add cpufreq support when booting with device tree

While cpufreq itself doesn't appear to directly support the device tree, we can register it inside da850_init_machine when we register other devices.

---
 arch/arm/mach-davinci/da8xx-dt.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
arch/arm/mach-davinci/da8xx-dt.c +27 -0
index 5699ce3..57e2ade 100644
@@ -14,6 +14,7 @@
 #include <linux/platform_data/ti-aemif.h>
 
 #include <asm/mach/arch.h>
+#include <asm/system_info.h>
 
 #include <mach/common.h>
 #include "cp_intc.h"
@@ -57,6 +58,28 @@ static struct of_dev_auxdata da850_auxdata_lookup[] __initdata = {
 	{}
 };
 
+#ifdef CONFIG_CPU_FREQ
+static __init int da850_init_cpufreq(void)
+{
+	switch (system_rev & 0xF) {
+	case 3:
+		da850_max_speed = 456000;
+		break;
+	case 2:
+		da850_max_speed = 408000;
+		break;
+	case 1:
+		da850_max_speed = 372000;
+		break;
+	}
+
+	return da850_register_cpufreq("pll0_sysclk3");
+}
+#else
+static __init int da850_init_cpufreq(void) { return 0; }
+#endif
+
+
 #ifdef CONFIG_ARCH_DAVINCI_DA850
 
 static void __init da850_init_machine(void)
@@ -80,6 +103,10 @@ static void __init da850_init_machine(void)
 		pr_warn("%s: registering SATA REFCLK failed: %d",
 			__func__, ret);
 
+	ret = da850_init_cpufreq();
+	if (ret)
+		pr_warn("%s: cpufreq registration failed: %d\n", __func__, ret);
+
 	of_platform_default_populate(NULL, da850_auxdata_lookup, NULL);
 	davinci_pm_init();
 	pdata_quirks_init();
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 davinci: Add cpufreq support when booting with device tree

Hi Adam,

Quoted 5 lines · Adam Ford

While cpufreq itself doesn't appear to directly support the device tree, we can register it inside da850_init_machine when we register other devices.

There is an OPP-based, DT-enabled cpufreq driver available. Please see support in drivers/cpufreq/cpufreq-dt-platdev.c

We should use that instead of this platform specific hack.

Looking at Documentation/devicetree/bindings/opp/opp.txt, it seems like we should use the v2 bindings from the start. They do have useful features like disabling certain OPPs on certain parts depending on the parametrics[1]

Thanks,
Sekhar

[1] http://www.ti.com/product/AM1808#parametrics