cppc_acpi.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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_MASK (1 << 0)
  23. #define PCC_ERROR_MASK (1 << 2)
  24. #define MAX_CPC_REG_ENT 19
  25. /* CPPC specific PCC commands. */
  26. #define CMD_READ 0
  27. #define CMD_WRITE 1
  28. /* Each register has the folowing format. */
  29. struct cpc_reg {
  30. u8 descriptor;
  31. u16 length;
  32. u8 space_id;
  33. u8 bit_width;
  34. u8 bit_offset;
  35. u8 access_width;
  36. u64 __iomem address;
  37. } __packed;
  38. /*
  39. * Each entry in the CPC table is either
  40. * of type ACPI_TYPE_BUFFER or
  41. * ACPI_TYPE_INTEGER.
  42. */
  43. struct cpc_register_resource {
  44. acpi_object_type type;
  45. u64 __iomem *sys_mem_vaddr;
  46. union {
  47. struct cpc_reg reg;
  48. u64 int_value;
  49. } cpc_entry;
  50. };
  51. /* Container to hold the CPC details for each CPU */
  52. struct cpc_desc {
  53. int num_entries;
  54. int version;
  55. int cpu_id;
  56. int write_cmd_status;
  57. int write_cmd_id;
  58. struct cpc_register_resource cpc_regs[MAX_CPC_REG_ENT];
  59. struct acpi_psd_package domain_info;
  60. struct kobject kobj;
  61. };
  62. /* These are indexes into the per-cpu cpc_regs[]. Order is important. */
  63. enum cppc_regs {
  64. HIGHEST_PERF,
  65. NOMINAL_PERF,
  66. LOW_NON_LINEAR_PERF,
  67. LOWEST_PERF,
  68. GUARANTEED_PERF,
  69. DESIRED_PERF,
  70. MIN_PERF,
  71. MAX_PERF,
  72. PERF_REDUC_TOLERANCE,
  73. TIME_WINDOW,
  74. CTR_WRAP_TIME,
  75. REFERENCE_CTR,
  76. DELIVERED_CTR,
  77. PERF_LIMITED,
  78. ENABLE,
  79. AUTO_SEL_ENABLE,
  80. AUTO_ACT_WINDOW,
  81. ENERGY_PERF,
  82. REFERENCE_PERF,
  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 highest_perf;
  92. u32 nominal_perf;
  93. u32 lowest_perf;
  94. };
  95. struct cppc_perf_ctrls {
  96. u32 max_perf;
  97. u32 min_perf;
  98. u32 desired_perf;
  99. };
  100. struct cppc_perf_fb_ctrs {
  101. u64 reference;
  102. u64 delivered;
  103. u64 reference_perf;
  104. u64 ctr_wrap_time;
  105. };
  106. /* Per CPU container for runtime CPPC management. */
  107. struct cppc_cpudata {
  108. int cpu;
  109. struct cppc_perf_caps perf_caps;
  110. struct cppc_perf_ctrls perf_ctrls;
  111. struct cppc_perf_fb_ctrs perf_fb_ctrs;
  112. struct cpufreq_policy *cur_policy;
  113. unsigned int shared_type;
  114. cpumask_var_t shared_cpu_map;
  115. };
  116. extern int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs);
  117. extern int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls);
  118. extern int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps);
  119. extern int acpi_get_psd_map(struct cppc_cpudata **);
  120. extern unsigned int cppc_get_transition_latency(int cpu);
  121. #endif /* _CPPC_ACPI_H*/