File: tango-cpufreq.c

package info (click to toggle)
linux 5.10.46-4
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 1,191,996 kB
  • sloc: ansic: 19,502,768; asm: 263,759; sh: 73,960; makefile: 44,724; perl: 34,644; python: 32,387; cpp: 6,070; yacc: 4,755; lex: 2,742; awk: 1,214; ruby: 25; sed: 5
file content (38 lines) | stat: -rw-r--r-- 927 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <linux/of.h>
#include <linux/cpu.h>
#include <linux/clk.h>
#include <linux/pm_opp.h>
#include <linux/platform_device.h>

static const struct of_device_id machines[] __initconst = {
	{ .compatible = "sigma,tango4" },
	{ /* sentinel */ }
};

static int __init tango_cpufreq_init(void)
{
	struct device *cpu_dev = get_cpu_device(0);
	unsigned long max_freq;
	struct clk *cpu_clk;
	void *res;

	if (!of_match_node(machines, of_root))
		return -ENODEV;

	cpu_clk = clk_get(cpu_dev, NULL);
	if (IS_ERR(cpu_clk))
		return -ENODEV;

	max_freq = clk_get_rate(cpu_clk);

	dev_pm_opp_add(cpu_dev, max_freq / 1, 0);
	dev_pm_opp_add(cpu_dev, max_freq / 2, 0);
	dev_pm_opp_add(cpu_dev, max_freq / 3, 0);
	dev_pm_opp_add(cpu_dev, max_freq / 5, 0);
	dev_pm_opp_add(cpu_dev, max_freq / 9, 0);

	res = platform_device_register_data(NULL, "cpufreq-dt", -1, NULL, 0);

	return PTR_ERR_OR_ZERO(res);
}
device_initcall(tango_cpufreq_init);