cppc_acpi.h 3.1 KB

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