blob: d3cf7234752ef403043523e40d72ba3244c1a60c [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001/*
2 * Copyright (C) 2019 MediaTek Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <linux/cpufreq.h>
15#include <trace/events/power.h>
16
17#include "power.h"
18#include "met_drv.h"
19#include "met_kernel_symbol.h"
20
21noinline void cpu_frequency(unsigned int frequency, unsigned int cpu_id)
22{
23 /* suppose this symbol is available, otherwise, the met.ko will fail */
24 met_cpu_frequency_symbol(frequency, cpu_id);
25}
26
27void force_power_log(int cpu)
28{
29 struct cpufreq_policy *p;
30
31 if (cpu == POWER_LOG_ALL) {
32 for_each_possible_cpu(cpu) {
33 p = cpufreq_cpu_get(cpu);
34 if (p != NULL) {
35 cpu_frequency(p->cur, cpu);
36 cpufreq_cpu_put(p);
37 } else {
38 cpu_frequency(0, cpu);
39 }
40 }
41 } else {
42 p = cpufreq_cpu_get(cpu);
43 if (p != NULL) {
44 cpu_frequency(p->cur, cpu);
45 cpufreq_cpu_put(p);
46 } else {
47 cpu_frequency(0, cpu);
48 }
49 }
50}
51
52void force_power_log_val(unsigned int frequency, int cpu)
53{
54 cpu_frequency(frequency, cpu);
55}