Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

cpufreq: dt: Don't use generic platdev driver for tango

On tango platforms, firmware configures the CPU clock, and Linux is
then only allowed to use the cpu_clk_divider to change the frequency.
Build the OPP table dynamically at init, in order to support whatever
firmware throws at us.

Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

authored by

Marc Gonzalez and committed by
Rafael J. Wysocki
9dbd224f bb33270c

+44 -3
-1
arch/arm/boot/dts/tango4-smp8758.dtsi
··· 13 13 reg = <0>; 14 14 clocks = <&clkgen CPU_CLK>; 15 15 clock-latency = <1>; 16 - operating-points = <1215000 0 607500 0 405000 0 243000 0 135000 0>; 17 16 }; 18 17 19 18 cpu1: cpu@1 {
+5
drivers/cpufreq/Kconfig.arm
··· 241 241 this config option if you wish to add CPUFreq support for STi based 242 242 SoCs. 243 243 244 + config ARM_TANGO_CPUFREQ 245 + bool 246 + depends on CPUFREQ_DT && ARCH_TANGO 247 + default y 248 + 244 249 config ARM_TEGRA20_CPUFREQ 245 250 bool "Tegra20 CPUFreq support" 246 251 depends on ARCH_TEGRA
+1
drivers/cpufreq/Makefile
··· 75 75 obj-$(CONFIG_ARM_SCPI_CPUFREQ) += scpi-cpufreq.o 76 76 obj-$(CONFIG_ARM_SPEAR_CPUFREQ) += spear-cpufreq.o 77 77 obj-$(CONFIG_ARM_STI_CPUFREQ) += sti-cpufreq.o 78 + obj-$(CONFIG_ARM_TANGO_CPUFREQ) += tango-cpufreq.o 78 79 obj-$(CONFIG_ARM_TEGRA20_CPUFREQ) += tegra20-cpufreq.o 79 80 obj-$(CONFIG_ARM_TEGRA124_CPUFREQ) += tegra124-cpufreq.o 80 81 obj-$(CONFIG_ARM_TEGRA186_CPUFREQ) += tegra186-cpufreq.o
-2
drivers/cpufreq/cpufreq-dt-platdev.c
··· 80 80 { .compatible = "rockchip,rk3368", }, 81 81 { .compatible = "rockchip,rk3399", }, 82 82 83 - { .compatible = "sigma,tango4" }, 84 - 85 83 { .compatible = "socionext,uniphier-pro5", }, 86 84 { .compatible = "socionext,uniphier-pxs2", }, 87 85 { .compatible = "socionext,uniphier-ld6b", },
+38
drivers/cpufreq/tango-cpufreq.c
··· 1 + #include <linux/of.h> 2 + #include <linux/cpu.h> 3 + #include <linux/clk.h> 4 + #include <linux/pm_opp.h> 5 + #include <linux/platform_device.h> 6 + 7 + static const struct of_device_id machines[] __initconst = { 8 + { .compatible = "sigma,tango4" }, 9 + { /* sentinel */ } 10 + }; 11 + 12 + static int __init tango_cpufreq_init(void) 13 + { 14 + struct device *cpu_dev = get_cpu_device(0); 15 + unsigned long max_freq; 16 + struct clk *cpu_clk; 17 + void *res; 18 + 19 + if (!of_match_node(machines, of_root)) 20 + return -ENODEV; 21 + 22 + cpu_clk = clk_get(cpu_dev, NULL); 23 + if (IS_ERR(cpu_clk)) 24 + return -ENODEV; 25 + 26 + max_freq = clk_get_rate(cpu_clk); 27 + 28 + dev_pm_opp_add(cpu_dev, max_freq / 1, 0); 29 + dev_pm_opp_add(cpu_dev, max_freq / 2, 0); 30 + dev_pm_opp_add(cpu_dev, max_freq / 3, 0); 31 + dev_pm_opp_add(cpu_dev, max_freq / 5, 0); 32 + dev_pm_opp_add(cpu_dev, max_freq / 9, 0); 33 + 34 + res = platform_device_register_data(NULL, "cpufreq-dt", -1, NULL, 0); 35 + 36 + return PTR_ERR_OR_ZERO(res); 37 + } 38 + device_initcall(tango_cpufreq_init);