Commit | Line | Data |
---|---|---|
9dbd224f MG |
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); |