cppc_acpi.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. #ifndef _CPPC_ACPI_H
  10. #define _CPPC_ACPI_H
  11. #include <linux/acpi.h>
  12. #include <linux/types.h>
  13. #include <acpi/pcc.h>
  14. #include <acpi/processor.h>
  15. /* Support CPPCv2 and CPPCv3 */
  16. #define CPPC_V2_REV 2
  17. #define CPPC_V3_REV 3
  18. #define CPPC_V2_NUM_ENT 21
  19. #define CPPC_V3_NUM_ENT 23
  20. #define PCC_CMD_COMPLETE_MASK (1 << 0)
  21. #define PCC_ERROR_MASK (1 << 2)
  22. #define MAX_CPC_REG_ENT 21
  23. /* CPPC specific PCC commands. */
  24. #define CMD_READ 0
  25. #define CMD_WRITE 1
  26. /* Each register has the folowing format. */
  27. struct cpc_reg {
  28. u8 descriptor;
  29. u16 length;
  30. u8 space_id;
  31. u8 bit_width;
  32. u8 bit_offset;
  33. u8 access_width;
  34. u64 __iomem address;
  35. } __packed;
  36. /*
  37. * Each entry in the CPC table is either
  38. * of type ACPI_TYPE_BUFFER or
  39. * ACPI_TYPE_INTEGER.
  40. */
  41. struct cpc_register_resource {
  42. acpi_object_type type;
  43. u64 __iomem *sys_mem_vaddr;
  44. union {
  45. struct cpc_reg reg;
  46. u64 int_value;
  47. } cpc_entry;
  48. };
  49. /* Container to hold the CPC details for each CPU */
  50. struct cpc_desc {
  51. int num_entries;
  52. int version;
  53. int cpu_id;
  54. int write_cmd_status;
  55. int write_cmd_id;
  56. struct cpc_register_resource cpc_regs[MAX_CPC_REG_ENT];
  57. struct acpi_psd_package domain_info;
  58. struct kobject kobj;
  59. };
  60. /* These are indexes into the per-cpu cpc_regs[]. Order is important. */
  61. enum cppc_regs {
  62. HIGHEST_PERF,
  63. NOMINAL_PERF,
  64. LOW_NON_LINEAR_PERF,
  65. LOWEST_PERF,
  66. GUARANTEED_PERF,
  67. DESIRED_PERF,
  68. MIN_PERF,
  69. MAX_PERF,
  70. PERF_REDUC_TOLERANCE,
  71. TIME_WINDOW,
  72. CTR_WRAP_TIME,
  73. REFERENCE_CTR,
  74. DELIVERED_CTR,
  75. PERF_LIMITED,
  76. ENABLE,
  77. AUTO_SEL_ENABLE,
  78. AUTO_ACT_WINDOW,
  79. ENERGY_PERF,
  80. REFERENCE_PERF,
  81. LOWEST_FREQ,
  82. NOMINAL_FREQ,
  83. };
  84. /*
  85. * Categorization of registers as described
  86. * in the ACPI v.5.1 spec.
  87. * XXX: Only filling up ones which are used by governors
  88. * today.
  89. */
  90. struct cppc_perf_caps {
  91. u32 guaranteed_perf;
  92. u32 highest_perf;
  93. u32 nominal_perf;
  94. u32 lowest_perf;
  95. u32 lowest_nonlinear_perf;
  96. u32 lowest_freq;
  97. u32 nominal_freq;
  98. };
  99. struct cppc_perf_ctrls {
  100. u32 max_perf;
  101. u32 min_perf;
  102. u32 desired_perf;
  103. };
  104. struct cppc_perf_fb_ctrs {
  105. u64 reference;
  106. u64 delivered;
  107. u64 reference_perf;
  108. u64 wraparound_time;
  109. };
  110. /* Per CPU container for runtime CPPC management. */
  111. struct cppc_cpudata {
  112. int cpu;
  113. struct cppc_perf_caps perf_caps;
  114. struct cppc_perf_ctrls perf_ctrls;
  115. struct cppc_perf_fb_ctrs perf_fb_ctrs;
  116. struct cpufreq_policy *cur_policy;
  117. unsigned int shared_type;
  118. cpumask_var_t shared_cpu_map;
  119. };
  120. extern int cppc_get_desired_perf(int cpunum, u64 *desired_perf);
  121. extern int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs);
  122. extern int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls);
  123. extern int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps);
  124. extern int acpi_get_psd_map(struct cppc_cpudata **);
  125. extern unsigned int cppc_get_transition_latency(int cpu);
  126. extern bool cpc_ffh_supported(void);
  127. extern int cpc_read_ffh(int cpunum, struct cpc_reg *reg, u64 *val);
  128. extern int cpc_write_ffh(int cpunum, struct cpc_reg *reg, u64 val);
  129. #endif /* _CPPC_ACPI_H*/