Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at ed78aeebef05212ef7dca93bd931e4eff67c113f 282 lines 7.3 kB view raw
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * CPPC (Collaborative Processor Performance Control) methods used 4 * by CPUfreq drivers. 5 * 6 * (C) Copyright 2014, 2015 Linaro Ltd. 7 * Author: Ashwin Chaugule <ashwin.chaugule@linaro.org> 8 */ 9 10#ifndef _CPPC_ACPI_H 11#define _CPPC_ACPI_H 12 13#include <linux/acpi.h> 14#include <linux/cpufreq.h> 15#include <linux/types.h> 16 17#include <acpi/pcc.h> 18#include <acpi/processor.h> 19 20/* CPPCv2 and CPPCv3 support */ 21#define CPPC_V2_REV 2 22#define CPPC_V3_REV 3 23#define CPPC_V2_NUM_ENT 21 24#define CPPC_V3_NUM_ENT 23 25 26#define PCC_CMD_COMPLETE_MASK (1 << 0) 27#define PCC_ERROR_MASK (1 << 2) 28 29#define MAX_CPC_REG_ENT 21 30 31/* CPPC specific PCC commands. */ 32#define CMD_READ 0 33#define CMD_WRITE 1 34 35#define CPPC_AUTO_ACT_WINDOW_SIG_BIT_SIZE (7) 36#define CPPC_AUTO_ACT_WINDOW_EXP_BIT_SIZE (3) 37#define CPPC_AUTO_ACT_WINDOW_MAX_SIG ((1 << CPPC_AUTO_ACT_WINDOW_SIG_BIT_SIZE) - 1) 38#define CPPC_AUTO_ACT_WINDOW_MAX_EXP ((1 << CPPC_AUTO_ACT_WINDOW_EXP_BIT_SIZE) - 1) 39/* CPPC_AUTO_ACT_WINDOW_MAX_SIG is 127, so 128 and 129 will decay to 127 when writing */ 40#define CPPC_AUTO_ACT_WINDOW_SIG_CARRY_THRESH 129 41 42#define CPPC_EPP_PERFORMANCE_PREF 0x00 43#define CPPC_EPP_ENERGY_EFFICIENCY_PREF 0xFF 44 45/* Each register has the folowing format. */ 46struct cpc_reg { 47 u8 descriptor; 48 u16 length; 49 u8 space_id; 50 u8 bit_width; 51 u8 bit_offset; 52 u8 access_width; 53 u64 address; 54} __packed; 55 56/* 57 * Each entry in the CPC table is either 58 * of type ACPI_TYPE_BUFFER or 59 * ACPI_TYPE_INTEGER. 60 */ 61struct cpc_register_resource { 62 acpi_object_type type; 63 u64 __iomem *sys_mem_vaddr; 64 union { 65 struct cpc_reg reg; 66 u64 int_value; 67 } cpc_entry; 68}; 69 70/* Container to hold the CPC details for each CPU */ 71struct cpc_desc { 72 int num_entries; 73 int version; 74 int cpu_id; 75 int write_cmd_status; 76 int write_cmd_id; 77 /* Lock used for RMW operations in cpc_write() */ 78 raw_spinlock_t rmw_lock; 79 struct cpc_register_resource cpc_regs[MAX_CPC_REG_ENT]; 80 struct acpi_psd_package domain_info; 81 struct kobject kobj; 82}; 83 84/* These are indexes into the per-cpu cpc_regs[]. Order is important. */ 85enum cppc_regs { 86 HIGHEST_PERF, 87 NOMINAL_PERF, 88 LOW_NON_LINEAR_PERF, 89 LOWEST_PERF, 90 GUARANTEED_PERF, 91 DESIRED_PERF, 92 MIN_PERF, 93 MAX_PERF, 94 PERF_REDUC_TOLERANCE, 95 TIME_WINDOW, 96 CTR_WRAP_TIME, 97 REFERENCE_CTR, 98 DELIVERED_CTR, 99 PERF_LIMITED, 100 ENABLE, 101 AUTO_SEL_ENABLE, 102 AUTO_ACT_WINDOW, 103 ENERGY_PERF, 104 REFERENCE_PERF, 105 LOWEST_FREQ, 106 NOMINAL_FREQ, 107}; 108 109/* 110 * Categorization of registers as described 111 * in the ACPI v.5.1 spec. 112 * XXX: Only filling up ones which are used by governors 113 * today. 114 */ 115struct cppc_perf_caps { 116 u32 guaranteed_perf; 117 u32 highest_perf; 118 u32 nominal_perf; 119 u32 lowest_perf; 120 u32 lowest_nonlinear_perf; 121 u32 lowest_freq; 122 u32 nominal_freq; 123}; 124 125struct cppc_perf_ctrls { 126 u32 max_perf; 127 u32 min_perf; 128 u32 desired_perf; 129 u32 energy_perf; 130 bool auto_sel; 131}; 132 133struct cppc_perf_fb_ctrs { 134 u64 reference; 135 u64 delivered; 136 u64 reference_perf; 137 u64 wraparound_time; 138}; 139 140/* Per CPU container for runtime CPPC management. */ 141struct cppc_cpudata { 142 struct cppc_perf_caps perf_caps; 143 struct cppc_perf_ctrls perf_ctrls; 144 struct cppc_perf_fb_ctrs perf_fb_ctrs; 145 unsigned int shared_type; 146 cpumask_var_t shared_cpu_map; 147}; 148 149#ifdef CONFIG_ACPI_CPPC_LIB 150extern int cppc_get_desired_perf(int cpunum, u64 *desired_perf); 151extern int cppc_get_nominal_perf(int cpunum, u64 *nominal_perf); 152extern int cppc_get_highest_perf(int cpunum, u64 *highest_perf); 153extern int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs); 154extern int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls); 155extern int cppc_set_enable(int cpu, bool enable); 156extern int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps); 157extern bool cppc_perf_ctrs_in_pcc_cpu(unsigned int cpu); 158extern bool cppc_perf_ctrs_in_pcc(void); 159extern unsigned int cppc_perf_to_khz(struct cppc_perf_caps *caps, unsigned int perf); 160extern unsigned int cppc_khz_to_perf(struct cppc_perf_caps *caps, unsigned int freq); 161extern bool acpi_cpc_valid(void); 162extern bool cppc_allow_fast_switch(void); 163extern int acpi_get_psd_map(unsigned int cpu, struct cppc_cpudata *cpu_data); 164extern int cppc_get_transition_latency(int cpu); 165extern bool cpc_ffh_supported(void); 166extern bool cpc_supported_by_cpu(void); 167extern int cpc_read_ffh(int cpunum, struct cpc_reg *reg, u64 *val); 168extern int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val); 169extern int cppc_get_epp_perf(int cpunum, u64 *epp_perf); 170extern int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, bool enable); 171extern int cppc_set_epp(int cpu, u64 epp_val); 172extern int cppc_get_auto_act_window(int cpu, u64 *auto_act_window); 173extern int cppc_set_auto_act_window(int cpu, u64 auto_act_window); 174extern int cppc_get_auto_sel(int cpu, bool *enable); 175extern int cppc_set_auto_sel(int cpu, bool enable); 176extern int amd_get_highest_perf(unsigned int cpu, u32 *highest_perf); 177extern int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator); 178extern int amd_detect_prefcore(bool *detected); 179#else /* !CONFIG_ACPI_CPPC_LIB */ 180static inline int cppc_get_desired_perf(int cpunum, u64 *desired_perf) 181{ 182 return -EOPNOTSUPP; 183} 184static inline int cppc_get_nominal_perf(int cpunum, u64 *nominal_perf) 185{ 186 return -EOPNOTSUPP; 187} 188static inline int cppc_get_highest_perf(int cpunum, u64 *highest_perf) 189{ 190 return -EOPNOTSUPP; 191} 192static inline int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs) 193{ 194 return -EOPNOTSUPP; 195} 196static inline int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls) 197{ 198 return -EOPNOTSUPP; 199} 200static inline int cppc_set_enable(int cpu, bool enable) 201{ 202 return -EOPNOTSUPP; 203} 204static inline int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps) 205{ 206 return -EOPNOTSUPP; 207} 208static inline bool cppc_perf_ctrs_in_pcc_cpu(unsigned int cpu) 209{ 210 return false; 211} 212static inline bool cppc_perf_ctrs_in_pcc(void) 213{ 214 return false; 215} 216static inline bool acpi_cpc_valid(void) 217{ 218 return false; 219} 220static inline bool cppc_allow_fast_switch(void) 221{ 222 return false; 223} 224static inline int cppc_get_transition_latency(int cpu) 225{ 226 return -ENODATA; 227} 228static inline bool cpc_ffh_supported(void) 229{ 230 return false; 231} 232static inline int cpc_read_ffh(int cpunum, struct cpc_reg *reg, u64 *val) 233{ 234 return -EOPNOTSUPP; 235} 236static inline int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val) 237{ 238 return -EOPNOTSUPP; 239} 240static inline int cppc_set_epp_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls, bool enable) 241{ 242 return -EOPNOTSUPP; 243} 244static inline int cppc_get_epp_perf(int cpunum, u64 *epp_perf) 245{ 246 return -EOPNOTSUPP; 247} 248static inline int cppc_set_epp(int cpu, u64 epp_val) 249{ 250 return -EOPNOTSUPP; 251} 252static inline int cppc_get_auto_act_window(int cpu, u64 *auto_act_window) 253{ 254 return -EOPNOTSUPP; 255} 256static inline int cppc_set_auto_act_window(int cpu, u64 auto_act_window) 257{ 258 return -EOPNOTSUPP; 259} 260static inline int cppc_get_auto_sel(int cpu, bool *enable) 261{ 262 return -EOPNOTSUPP; 263} 264static inline int cppc_set_auto_sel(int cpu, bool enable) 265{ 266 return -EOPNOTSUPP; 267} 268static inline int amd_get_highest_perf(unsigned int cpu, u32 *highest_perf) 269{ 270 return -ENODEV; 271} 272static inline int amd_get_boost_ratio_numerator(unsigned int cpu, u64 *numerator) 273{ 274 return -EOPNOTSUPP; 275} 276static inline int amd_detect_prefcore(bool *detected) 277{ 278 return -ENODEV; 279} 280#endif /* !CONFIG_ACPI_CPPC_LIB */ 281 282#endif /* _CPPC_ACPI_H*/