rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2018 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 | /* |
| 15 | * Copyright (C) 2018 MediaTek Inc. |
| 16 | * |
| 17 | * This program is free software: you can redistribute it and/or modify |
| 18 | * it under the terms of the GNU General Public License version 2 as |
| 19 | * published by the Free Software Foundation. |
| 20 | * |
| 21 | * This program is distributed in the hope that it will be useful, |
| 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 | * GNU General Public License for more details. |
| 25 | */ |
| 26 | |
| 27 | #include <linux/cpufreq.h> |
| 28 | #include <trace/events/power.h> |
| 29 | |
| 30 | #include "power.h" |
| 31 | #include "met_drv.h" |
| 32 | #include "met_kernel_symbol.h" |
| 33 | |
| 34 | noinline void cpu_frequency(unsigned int frequency, unsigned int cpu_id) |
| 35 | { |
| 36 | /* suppose this symbol is available, otherwise, the met.ko will fail */ |
| 37 | met_cpu_frequency_symbol(frequency, cpu_id); |
| 38 | } |
| 39 | |
| 40 | void force_power_log(int cpu) |
| 41 | { |
| 42 | struct cpufreq_policy *p; |
| 43 | |
| 44 | if (cpu == POWER_LOG_ALL) { |
| 45 | for_each_possible_cpu(cpu) { |
| 46 | p = cpufreq_cpu_get(cpu); |
| 47 | if (p != NULL) { |
| 48 | cpu_frequency(p->cur, cpu); |
| 49 | cpufreq_cpu_put(p); |
| 50 | } else { |
| 51 | cpu_frequency(0, cpu); |
| 52 | } |
| 53 | } |
| 54 | } else { |
| 55 | p = cpufreq_cpu_get(cpu); |
| 56 | if (p != NULL) { |
| 57 | cpu_frequency(p->cur, cpu); |
| 58 | cpufreq_cpu_put(p); |
| 59 | } else { |
| 60 | cpu_frequency(0, cpu); |
| 61 | } |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | void force_power_log_val(unsigned int frequency, int cpu) |
| 66 | { |
| 67 | cpu_frequency(frequency, cpu); |
| 68 | } |