Linux 5.0.7
[linux/fpc-iii.git] / drivers / cpufreq / tango-cpufreq.c
blob89a7f860bfe8ab976bc2fcd57e0deb80976ac914
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>
7 static const struct of_device_id machines[] __initconst = {
8 { .compatible = "sigma,tango4" },
9 { /* sentinel */ }
12 static int __init tango_cpufreq_init(void)
14 struct device *cpu_dev = get_cpu_device(0);
15 unsigned long max_freq;
16 struct clk *cpu_clk;
17 void *res;
19 if (!of_match_node(machines, of_root))
20 return -ENODEV;
22 cpu_clk = clk_get(cpu_dev, NULL);
23 if (IS_ERR(cpu_clk))
24 return -ENODEV;
26 max_freq = clk_get_rate(cpu_clk);
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);
34 res = platform_device_register_data(NULL, "cpufreq-dt", -1, NULL, 0);
36 return PTR_ERR_OR_ZERO(res);
38 device_initcall(tango_cpufreq_init);