misc.c 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // SPDX-License-Identifier: GPL-2.0
  2. #if defined(__i386__) || defined(__x86_64__)
  3. #include "helpers/helpers.h"
  4. #define MSR_AMD_HWCR 0xc0010015
  5. int cpufreq_has_boost_support(unsigned int cpu, int *support, int *active,
  6. int *states)
  7. {
  8. struct cpupower_cpu_info cpu_info;
  9. int ret;
  10. unsigned long long val;
  11. *support = *active = *states = 0;
  12. ret = get_cpu_info(&cpu_info);
  13. if (ret)
  14. return ret;
  15. if (cpupower_cpu_info.caps & CPUPOWER_CAP_AMD_CBP) {
  16. *support = 1;
  17. /* AMD Family 0x17 does not utilize PCI D18F4 like prior
  18. * families and has no fixed discrete boost states but
  19. * has Hardware determined variable increments instead.
  20. */
  21. if (cpu_info.family == 0x17) {
  22. if (!read_msr(cpu, MSR_AMD_HWCR, &val)) {
  23. if (!(val & CPUPOWER_AMD_CPBDIS))
  24. *active = 1;
  25. }
  26. } else {
  27. ret = amd_pci_get_num_boost_states(active, states);
  28. if (ret)
  29. return ret;
  30. }
  31. } else if (cpupower_cpu_info.caps & CPUPOWER_CAP_INTEL_IDA)
  32. *support = *active = 1;
  33. return 0;
  34. }
  35. #endif /* #if defined(__i386__) || defined(__x86_64__) */