cppc_acpi.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. /* Only support CPPCv2 for now. */
  20. #define CPPC_NUM_ENT 21
  21. #define CPPC_REV 2
  22. #define PCC_CMD_COMPLETE 1
  23. #define MAX_CPC_REG_ENT 19
  24. /* CPPC specific PCC commands. */
  25. #define CMD_READ 0
  26. #define CMD_WRITE 1
  27. /* Each register has the folowing format. */
  28. struct cpc_reg {
  29. u8 descriptor;
  30. u16 length;
  31. u8 space_id;
  32. u8 bit_width;
  33. u8 bit_offset;
  34. u8 access_width;
  35. u64 __iomem address;
  36. } __packed;
  37. /*
  38. * Each entry in the CPC table is either
  39. * of type ACPI_TYPE_BUFFER or
  40. * ACPI_TYPE_INTEGER.
  41. */
  42. struct cpc_register_resource {
  43. acpi_object_type type;
  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. struct cpc_register_resource cpc_regs[MAX_CPC_REG_ENT];
  55. struct acpi_psd_package domain_info;
  56. };
  57. /* These are indexes into the per-cpu cpc_regs[]. Order is important. */
  58. enum cppc_regs {
  59. HIGHEST_PERF,
  60. NOMINAL_PERF,
  61. LOW_NON_LINEAR_PERF,
  62. LOWEST_PERF,
  63. GUARANTEED_PERF,
  64. DESIRED_PERF,
  65. MIN_PERF,
  66. MAX_PERF,
  67. PERF_REDUC_TOLERANCE,
  68. TIME_WINDOW,
  69. CTR_WRAP_TIME,
  70. REFERENCE_CTR,
  71. DELIVERED_CTR,
  72. PERF_LIMITED,
  73. ENABLE,
  74. AUTO_SEL_ENABLE,
  75. AUTO_ACT_WINDOW,
  76. ENERGY_PERF,
  77. REFERENCE_PERF,
  78. };
  79. /*
  80. * Categorization of registers as described
  81. * in the ACPI v.5.1 spec.
  82. * XXX: Only filling up ones which are used by governors
  83. * today.
  84. */
  85. struct cppc_perf_caps {
  86. u32 highest_perf;
  87. u32 nominal_perf;
  88. u32 reference_perf;
  89. u32 lowest_perf;
  90. };
  91. struct cppc_perf_ctrls {
  92. u32 max_perf;
  93. u32 min_perf;
  94. u32 desired_perf;
  95. };
  96. struct cppc_perf_fb_ctrs {
  97. u64 reference;
  98. u64 prev_reference;
  99. u64 delivered;
  100. u64 prev_delivered;
  101. };
  102. /* Per CPU container for runtime CPPC management. */
  103. struct cpudata {
  104. int cpu;
  105. struct cppc_perf_caps perf_caps;
  106. struct cppc_perf_ctrls perf_ctrls;
  107. struct cppc_perf_fb_ctrs perf_fb_ctrs;
  108. struct cpufreq_policy *cur_policy;
  109. unsigned int shared_type;
  110. cpumask_var_t shared_cpu_map;
  111. };
  112. extern int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs);
  113. extern int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls);
  114. extern int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps);
  115. extern int acpi_get_psd_map(struct cpudata **);
  116. #endif /* _CPPC_ACPI_H*/