18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * include/linux/arch_topology.h - arch specific cpu topology information
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci#ifndef _LINUX_ARCH_TOPOLOGY_H_
68c2ecf20Sopenharmony_ci#define _LINUX_ARCH_TOPOLOGY_H_
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#include <linux/types.h>
98c2ecf20Sopenharmony_ci#include <linux/percpu.h>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_civoid topology_normalize_cpu_scale(void);
128c2ecf20Sopenharmony_ciint topology_update_cpu_topology(void);
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_cistruct device_node;
158c2ecf20Sopenharmony_cibool topology_parse_cpu_capacity(struct device_node *cpu_node, int cpu);
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ciDECLARE_PER_CPU(unsigned long, cpu_scale);
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_cistatic inline unsigned long topology_get_cpu_scale(int cpu)
208c2ecf20Sopenharmony_ci{
218c2ecf20Sopenharmony_ci	return per_cpu(cpu_scale, cpu);
228c2ecf20Sopenharmony_ci}
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_civoid topology_set_cpu_scale(unsigned int cpu, unsigned long capacity);
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciDECLARE_PER_CPU(unsigned long, freq_scale);
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_cistatic inline unsigned long topology_get_freq_scale(int cpu)
298c2ecf20Sopenharmony_ci{
308c2ecf20Sopenharmony_ci	return per_cpu(freq_scale, cpu);
318c2ecf20Sopenharmony_ci}
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_civoid topology_set_freq_scale(const struct cpumask *cpus, unsigned long cur_freq,
348c2ecf20Sopenharmony_ci			     unsigned long max_freq);
358c2ecf20Sopenharmony_cibool topology_scale_freq_invariant(void);
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_cibool arch_freq_counters_available(const struct cpumask *cpus);
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ciDECLARE_PER_CPU(unsigned long, thermal_pressure);
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_cistatic inline unsigned long topology_get_thermal_pressure(int cpu)
428c2ecf20Sopenharmony_ci{
438c2ecf20Sopenharmony_ci	return per_cpu(thermal_pressure, cpu);
448c2ecf20Sopenharmony_ci}
458c2ecf20Sopenharmony_ci
468c2ecf20Sopenharmony_civoid topology_set_thermal_pressure(const struct cpumask *cpus,
478c2ecf20Sopenharmony_ci				   unsigned long th_pressure);
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_cistruct cpu_topology {
508c2ecf20Sopenharmony_ci	int thread_id;
518c2ecf20Sopenharmony_ci	int core_id;
528c2ecf20Sopenharmony_ci	int package_id;
538c2ecf20Sopenharmony_ci	int llc_id;
548c2ecf20Sopenharmony_ci	cpumask_t thread_sibling;
558c2ecf20Sopenharmony_ci	cpumask_t core_sibling;
568c2ecf20Sopenharmony_ci	cpumask_t llc_sibling;
578c2ecf20Sopenharmony_ci};
588c2ecf20Sopenharmony_ci
598c2ecf20Sopenharmony_ci#ifdef CONFIG_GENERIC_ARCH_TOPOLOGY
608c2ecf20Sopenharmony_ciextern struct cpu_topology cpu_topology[NR_CPUS];
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci#define topology_physical_package_id(cpu)	(cpu_topology[cpu].package_id)
638c2ecf20Sopenharmony_ci#define topology_core_id(cpu)		(cpu_topology[cpu].core_id)
648c2ecf20Sopenharmony_ci#define topology_core_cpumask(cpu)	(&cpu_topology[cpu].core_sibling)
658c2ecf20Sopenharmony_ci#define topology_sibling_cpumask(cpu)	(&cpu_topology[cpu].thread_sibling)
668c2ecf20Sopenharmony_ci#define topology_llc_cpumask(cpu)	(&cpu_topology[cpu].llc_sibling)
678c2ecf20Sopenharmony_civoid init_cpu_topology(void);
688c2ecf20Sopenharmony_civoid store_cpu_topology(unsigned int cpuid);
698c2ecf20Sopenharmony_ciconst struct cpumask *cpu_coregroup_mask(int cpu);
708c2ecf20Sopenharmony_civoid update_siblings_masks(unsigned int cpu);
718c2ecf20Sopenharmony_civoid remove_cpu_topology(unsigned int cpuid);
728c2ecf20Sopenharmony_civoid reset_cpu_topology(void);
738c2ecf20Sopenharmony_ciint parse_acpi_topology(void);
748c2ecf20Sopenharmony_ci#endif
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci#endif /* _LINUX_ARCH_TOPOLOGY_H_ */
77