blob: 87e5bdc5ec74cb4e03be68ca4e7134e297bbfaad [file] [log] [blame]
Sudeep KarkadaNagesha47ac9aa2013-10-29 12:18:39 +00001/*
2 * Versatile Express SPC CPUFreq Interface driver
3 *
4 * It provides necessary ops to arm_big_little cpufreq driver.
5 *
6 * Copyright (C) 2013 ARM Ltd.
7 * Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 *
13 * This program is distributed "as is" WITHOUT ANY WARRANTY of any
14 * kind, whether express or implied; without even the implied warranty
15 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 */
18
19#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
20
Sudeep Hollad9975b02016-05-03 15:05:05 +010021#include <linux/cpu.h>
Sudeep KarkadaNagesha47ac9aa2013-10-29 12:18:39 +000022#include <linux/cpufreq.h>
23#include <linux/module.h>
24#include <linux/platform_device.h>
25#include <linux/pm_opp.h>
26#include <linux/types.h>
27
28#include "arm_big_little.h"
29
Sudeep Hollad9975b02016-05-03 15:05:05 +010030static int ve_spc_init_opp_table(const struct cpumask *cpumask)
Sudeep KarkadaNagesha47ac9aa2013-10-29 12:18:39 +000031{
Sudeep Hollad9975b02016-05-03 15:05:05 +010032 struct device *cpu_dev = get_cpu_device(cpumask_first(cpumask));
Sudeep KarkadaNagesha47ac9aa2013-10-29 12:18:39 +000033 /*
34 * platform specific SPC code must initialise the opp table
35 * so just check if the OPP count is non-zero
36 */
37 return dev_pm_opp_get_opp_count(cpu_dev) <= 0;
38}
39
40static int ve_spc_get_transition_latency(struct device *cpu_dev)
41{
42 return 1000000; /* 1 ms */
43}
44
45static struct cpufreq_arm_bL_ops ve_spc_cpufreq_ops = {
46 .name = "vexpress-spc",
47 .get_transition_latency = ve_spc_get_transition_latency,
48 .init_opp_table = ve_spc_init_opp_table,
49};
50
51static int ve_spc_cpufreq_probe(struct platform_device *pdev)
52{
53 return bL_cpufreq_register(&ve_spc_cpufreq_ops);
54}
55
56static int ve_spc_cpufreq_remove(struct platform_device *pdev)
57{
58 bL_cpufreq_unregister(&ve_spc_cpufreq_ops);
59 return 0;
60}
61
62static struct platform_driver ve_spc_cpufreq_platdrv = {
63 .driver = {
64 .name = "vexpress-spc-cpufreq",
Sudeep KarkadaNagesha47ac9aa2013-10-29 12:18:39 +000065 },
66 .probe = ve_spc_cpufreq_probe,
67 .remove = ve_spc_cpufreq_remove,
68};
69module_platform_driver(ve_spc_cpufreq_platdrv);
70
71MODULE_LICENSE("GPL");