^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2019 Google, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/cpufreq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) static struct cpufreq_frequency_table freq_table[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) { .frequency = 1 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) { .frequency = 2 },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) { .frequency = CPUFREQ_TABLE_END },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) static int dummy_cpufreq_target_index(struct cpufreq_policy *policy,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) unsigned int index)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) static int dummy_cpufreq_driver_init(struct cpufreq_policy *policy)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) policy->freq_table = freq_table;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) static unsigned int dummy_cpufreq_get(unsigned int cpu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) static int dummy_cpufreq_verify(struct cpufreq_policy_data *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static struct cpufreq_driver dummy_cpufreq_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) .name = "dummy",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) .target_index = dummy_cpufreq_target_index,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) .init = dummy_cpufreq_driver_init,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) .get = dummy_cpufreq_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) .verify = dummy_cpufreq_verify,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) .attr = cpufreq_generic_attr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) static int __init dummy_cpufreq_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) return cpufreq_register_driver(&dummy_cpufreq_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) static void __exit dummy_cpufreq_exit(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) cpufreq_unregister_driver(&dummy_cpufreq_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) module_init(dummy_cpufreq_init);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) module_exit(dummy_cpufreq_exit);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) MODULE_AUTHOR("Connor O'Brien <connoro@google.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) MODULE_DESCRIPTION("dummy cpufreq driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) MODULE_LICENSE("GPL");