1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * CPPC (Collaborative Processor Performance Control) methods used
6 * (C) Copyright 2014, 2015 Linaro Ltd.
7 * Author: Ashwin Chaugule <ashwin.chaugule@linaro.org>
13 #include <linux/acpi.h>
14 #include <linux/cpufreq.h>
15 #include <linux/types.h>
18 #include <acpi/processor.h>
20 /* CPPCv2 and CPPCv3 support */
23 #define CPPC_V2_NUM_ENT 21
24 #define CPPC_V3_NUM_ENT 23
26 #define PCC_CMD_COMPLETE_MASK (1 << 0)
27 #define PCC_ERROR_MASK (1 << 2)
29 #define MAX_CPC_REG_ENT 21
31 /* CPPC specific PCC commands. */
35 /* Each register has the folowing format. */
47 * Each entry in the CPC table is either
48 * of type ACPI_TYPE_BUFFER or
51 struct cpc_register_resource {
52 acpi_object_type type;
53 u64 __iomem *sys_mem_vaddr;
60 /* Container to hold the CPC details for each CPU */
67 struct cpc_register_resource cpc_regs[MAX_CPC_REG_ENT];
68 struct acpi_psd_package domain_info;
72 /* These are indexes into the per-cpu cpc_regs[]. Order is important. */
98 * Categorization of registers as described
99 * in the ACPI v.5.1 spec.
100 * XXX: Only filling up ones which are used by governors
103 struct cppc_perf_caps {
108 u32 lowest_nonlinear_perf;
113 struct cppc_perf_ctrls {
119 struct cppc_perf_fb_ctrs {
126 /* Per CPU container for runtime CPPC management. */
127 struct cppc_cpudata {
128 struct list_head node;
129 struct cppc_perf_caps perf_caps;
130 struct cppc_perf_ctrls perf_ctrls;
131 struct cppc_perf_fb_ctrs perf_fb_ctrs;
132 unsigned int shared_type;
133 cpumask_var_t shared_cpu_map;
136 #ifdef CONFIG_ACPI_CPPC_LIB
137 extern int cppc_get_desired_perf(int cpunum, u64 *desired_perf);
138 extern int cppc_get_nominal_perf(int cpunum, u64 *nominal_perf);
139 extern int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs);
140 extern int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls);
141 extern int cppc_set_enable(int cpu, bool enable);
142 extern int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps);
143 extern bool cppc_perf_ctrs_in_pcc(void);
144 extern bool acpi_cpc_valid(void);
145 extern bool cppc_allow_fast_switch(void);
146 extern int acpi_get_psd_map(unsigned int cpu, struct cppc_cpudata *cpu_data);
147 extern unsigned int cppc_get_transition_latency(int cpu);
148 extern bool cpc_ffh_supported(void);
149 extern bool cpc_supported_by_cpu(void);
150 extern int cpc_read_ffh(int cpunum, struct cpc_reg *reg, u64 *val);
151 extern int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val);
152 #else /* !CONFIG_ACPI_CPPC_LIB */
153 static inline int cppc_get_desired_perf(int cpunum, u64 *desired_perf)
157 static inline int cppc_get_nominal_perf(int cpunum, u64 *nominal_perf)
161 static inline int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs)
165 static inline int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls)
169 static inline int cppc_set_enable(int cpu, bool enable)
173 static inline int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps)
177 static inline bool cppc_perf_ctrs_in_pcc(void)
181 static inline bool acpi_cpc_valid(void)
185 static inline bool cppc_allow_fast_switch(void)
189 static inline unsigned int cppc_get_transition_latency(int cpu)
191 return CPUFREQ_ETERNAL;
193 static inline bool cpc_ffh_supported(void)
197 static inline int cpc_read_ffh(int cpunum, struct cpc_reg *reg, u64 *val)
201 static inline int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val)
205 #endif /* !CONFIG_ACPI_CPPC_LIB */
207 #endif /* _CPPC_ACPI_H*/