/* SPDX-License-Identifier: GPL-2.0-only */1/*2* Copyright (C) 2022 Advanced Micro Devices, Inc.3*4* Author: Meng Li <[email protected]>5*/67#ifndef _LINUX_AMD_PSTATE_H8#define _LINUX_AMD_PSTATE_H910#include <linux/pm_qos.h>1112/*********************************************************************13* AMD P-state INTERFACE *14*********************************************************************/1516/**17* union perf_cached - A union to cache performance-related data.18* @highest_perf: the maximum performance an individual processor may reach,19* assuming ideal conditions20* For platforms that support the preferred core feature, the highest_perf value maybe21* configured to any value in the range 166-255 by the firmware (because the preferred22* core ranking is encoded in the highest_perf value). To maintain consistency across23* all platforms, we split the highest_perf and preferred core ranking values into24* cpudata->perf.highest_perf and cpudata->prefcore_ranking.25* @nominal_perf: the maximum sustained performance level of the processor,26* assuming ideal operating conditions27* @lowest_nonlinear_perf: the lowest performance level at which nonlinear power28* savings are achieved29* @lowest_perf: the absolute lowest performance level of the processor30* @min_limit_perf: Cached value of the performance corresponding to policy->min31* @max_limit_perf: Cached value of the performance corresponding to policy->max32* @bios_min_perf: Cached perf value corresponding to the "Requested CPU Min Frequency" BIOS option33*/34union perf_cached {35struct {36u8 highest_perf;37u8 nominal_perf;38u8 lowest_nonlinear_perf;39u8 lowest_perf;40u8 min_limit_perf;41u8 max_limit_perf;42u8 bios_min_perf;43};44u64 val;45};4647/**48* struct amd_aperf_mperf49* @aperf: actual performance frequency clock count50* @mperf: maximum performance frequency clock count51* @tsc: time stamp counter52*/53struct amd_aperf_mperf {54u64 aperf;55u64 mperf;56u64 tsc;57};5859/**60* struct amd_cpudata - private CPU data for AMD P-State61* @cpu: CPU number62* @req: constraint request to apply63* @cppc_req_cached: cached performance request hints64* @perf: cached performance-related data65* @prefcore_ranking: the preferred core ranking, the higher value indicates a higher66* priority.67* @min_limit_freq: Cached value of policy->min (in khz)68* @max_limit_freq: Cached value of policy->max (in khz)69* @nominal_freq: the frequency (in khz) that mapped to nominal_perf70* @lowest_nonlinear_freq: the frequency (in khz) that mapped to lowest_nonlinear_perf71* @cur: Difference of Aperf/Mperf/tsc count between last and current sample72* @prev: Last Aperf/Mperf/tsc count value read from register73* @freq: current cpu frequency value (in khz)74* @boost_supported: check whether the Processor or SBIOS supports boost mode75* @hw_prefcore: check whether HW supports preferred core featue.76* Only when hw_prefcore and early prefcore param are true,77* AMD P-State driver supports preferred core featue.78* @epp_cached: Cached CPPC energy-performance preference value79* @policy: Cpufreq policy value80*81* The amd_cpudata is key private data for each CPU thread in AMD P-State, and82* represents all the attributes and goals that AMD P-State requests at runtime.83*/84struct amd_cpudata {85int cpu;8687struct freq_qos_request req[2];88u64 cppc_req_cached;8990union perf_cached perf;9192u8 prefcore_ranking;93u32 min_limit_freq;94u32 max_limit_freq;95u32 nominal_freq;96u32 lowest_nonlinear_freq;9798struct amd_aperf_mperf cur;99struct amd_aperf_mperf prev;100101u64 freq;102bool boost_supported;103bool hw_prefcore;104105/* EPP feature related attributes*/106u32 policy;107bool suspended;108u8 epp_default;109};110111/*112* enum amd_pstate_mode - driver working mode of amd pstate113*/114enum amd_pstate_mode {115AMD_PSTATE_UNDEFINED = 0,116AMD_PSTATE_DISABLE,117AMD_PSTATE_PASSIVE,118AMD_PSTATE_ACTIVE,119AMD_PSTATE_GUIDED,120AMD_PSTATE_MAX,121};122const char *amd_pstate_get_mode_string(enum amd_pstate_mode mode);123int amd_pstate_get_status(void);124int amd_pstate_update_status(const char *buf, size_t size);125126#endif /* _LINUX_AMD_PSTATE_H */127128129