cppc_acpi.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  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. u64 __iomem *sys_mem_vaddr;
  45. union {
  46. struct cpc_reg reg;
  47. u64 int_value;
  48. } cpc_entry;
  49. };
  50. /* Container to hold the CPC details for each CPU */
  51. struct cpc_desc {
  52. int num_entries;
  53. int version;
  54. int cpu_id;
  55. int write_cmd_status;
  56. int write_cmd_id;
  57. struct cpc_register_resource cpc_regs[MAX_CPC_REG_ENT];
  58. struct acpi_psd_package domain_info;
  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. };
  82. /*
  83. * Categorization of registers as described
  84. * in the ACPI v.5.1 spec.
  85. * XXX: Only filling up ones which are used by governors
  86. * today.
  87. */
  88. struct cppc_perf_caps {
  89. u32 highest_perf;
  90. u32 nominal_perf;
  91. u32 reference_perf;
  92. u32 lowest_perf;
  93. };
  94. struct cppc_perf_ctrls {
  95. u32 max_perf;
  96. u32 min_perf;
  97. u32 desired_perf;
  98. };
  99. struct cppc_perf_fb_ctrs {
  100. u64 reference;
  101. u64 prev_reference;
  102. u64 delivered;
  103. u64 prev_delivered;
  104. };
  105. /* Per CPU container for runtime CPPC management. */
  106. struct cpudata {
  107. int cpu;
  108. struct cppc_perf_caps perf_caps;
  109. struct cppc_perf_ctrls perf_ctrls;
  110. struct cppc_perf_fb_ctrs perf_fb_ctrs;
  111. struct cpufreq_policy *cur_policy;
  112. unsigned int shared_type;
  113. cpumask_var_t shared_cpu_map;
  114. };
  115. extern int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs);
  116. extern int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls);
  117. extern int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps);
  118. extern int acpi_get_psd_map(struct cpudata **);
  119. #endif /* _CPPC_ACPI_H*/