#include <linux/init.h>
 #include <linux/rcupdate.h>
 #include <linux/sched.h>
+#include <linux/units.h>
 
 #define CREATE_TRACE_POINTS
 #include <trace/events/thermal_pressure.h>
 static DEFINE_PER_CPU(struct scale_freq_data __rcu *, sft_data);
 static struct cpumask scale_freq_counters_mask;
 static bool scale_freq_invariant;
-static DEFINE_PER_CPU(u32, freq_factor) = 1;
+DEFINE_PER_CPU(unsigned long, capacity_freq_ref) = 1;
+EXPORT_PER_CPU_SYMBOL_GPL(capacity_freq_ref);
 
 static bool supports_scale_freq_counters(const struct cpumask *cpus)
 {
  * operating on stale data when hot-plug is used for some CPUs. The
  * @capped_freq reflects the currently allowed max CPUs frequency due to
  * thermal capping. It might be also a boost frequency value, which is bigger
- * than the internal 'freq_factor' max frequency. In such case the pressure
- * value should simply be removed, since this is an indication that there is
- * no thermal throttling. The @capped_freq must be provided in kHz.
+ * than the internal 'capacity_freq_ref' max frequency. In such case the
+ * pressure value should simply be removed, since this is an indication that
+ * there is no thermal throttling. The @capped_freq must be provided in kHz.
  */
 void topology_update_thermal_pressure(const struct cpumask *cpus,
                                      unsigned long capped_freq)
 
        cpu = cpumask_first(cpus);
        max_capacity = arch_scale_cpu_capacity(cpu);
-       max_freq = per_cpu(freq_factor, cpu);
-
-       /* Convert to MHz scale which is used in 'freq_factor' */
-       capped_freq /= 1000;
+       max_freq = arch_scale_freq_ref(cpu);
 
        /*
         * Handle properly the boost frequencies, which should simply clean
 
        capacity_scale = 1;
        for_each_possible_cpu(cpu) {
-               capacity = raw_capacity[cpu] * per_cpu(freq_factor, cpu);
+               capacity = raw_capacity[cpu] * per_cpu(capacity_freq_ref, cpu);
                capacity_scale = max(capacity, capacity_scale);
        }
 
        pr_debug("cpu_capacity: capacity_scale=%llu\n", capacity_scale);
        for_each_possible_cpu(cpu) {
-               capacity = raw_capacity[cpu] * per_cpu(freq_factor, cpu);
+               capacity = raw_capacity[cpu] * per_cpu(capacity_freq_ref, cpu);
                capacity = div64_u64(capacity << SCHED_CAPACITY_SHIFT,
                        capacity_scale);
                topology_set_cpu_scale(cpu, capacity);
                        cpu_node, raw_capacity[cpu]);
 
                /*
-                * Update freq_factor for calculating early boot cpu capacities.
+                * Update capacity_freq_ref for calculating early boot CPU capacities.
                 * For non-clk CPU DVFS mechanism, there's no way to get the
                 * frequency value now, assuming they are running at the same
-                * frequency (by keeping the initial freq_factor value).
+                * frequency (by keeping the initial capacity_freq_ref value).
                 */
                cpu_clk = of_clk_get(cpu_node, 0);
                if (!PTR_ERR_OR_ZERO(cpu_clk)) {
-                       per_cpu(freq_factor, cpu) =
-                               clk_get_rate(cpu_clk) / 1000;
+                       per_cpu(capacity_freq_ref, cpu) =
+                               clk_get_rate(cpu_clk) / HZ_PER_KHZ;
                        clk_put(cpu_clk);
                }
        } else {
        cpumask_andnot(cpus_to_visit, cpus_to_visit, policy->related_cpus);
 
        for_each_cpu(cpu, policy->related_cpus)
-               per_cpu(freq_factor, cpu) = policy->cpuinfo.max_freq / 1000;
+               per_cpu(capacity_freq_ref, cpu) = policy->cpuinfo.max_freq;
 
        if (cpumask_empty(cpus_to_visit)) {
                topology_normalize_cpu_scale();