cppc_acpi.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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/mailbox_controller.h>
  17. #include <linux/mailbox_client.h>
  18. #include <linux/types.h>
  19. #include <acpi/processor.h>
  20. /* Only support CPPCv2 for now. */
  21. #define CPPC_NUM_ENT 21
  22. #define CPPC_REV 2
  23. #define PCC_CMD_COMPLETE 1
  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. 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. struct cpc_register_resource cpc_regs[MAX_CPC_REG_ENT];
  56. struct acpi_psd_package domain_info;
  57. };
  58. /* These are indexes into the per-cpu cpc_regs[]. Order is important. */
  59. enum cppc_regs {
  60. HIGHEST_PERF,
  61. NOMINAL_PERF,
  62. LOW_NON_LINEAR_PERF,
  63. LOWEST_PERF,
  64. GUARANTEED_PERF,
  65. DESIRED_PERF,
  66. MIN_PERF,
  67. MAX_PERF,
  68. PERF_REDUC_TOLERANCE,
  69. TIME_WINDOW,
  70. CTR_WRAP_TIME,
  71. REFERENCE_CTR,
  72. DELIVERED_CTR,
  73. PERF_LIMITED,
  74. ENABLE,
  75. AUTO_SEL_ENABLE,
  76. AUTO_ACT_WINDOW,
  77. ENERGY_PERF,
  78. REFERENCE_PERF,
  79. };
  80. /*
  81. * Categorization of registers as described
  82. * in the ACPI v.5.1 spec.
  83. * XXX: Only filling up ones which are used by governors
  84. * today.
  85. */
  86. struct cppc_perf_caps {
  87. u32 highest_perf;
  88. u32 nominal_perf;
  89. u32 reference_perf;
  90. u32 lowest_perf;
  91. };
  92. struct cppc_perf_ctrls {
  93. u32 max_perf;
  94. u32 min_perf;
  95. u32 desired_perf;
  96. };
  97. struct cppc_perf_fb_ctrs {
  98. u64 reference;
  99. u64 prev_reference;
  100. u64 delivered;
  101. u64 prev_delivered;
  102. };
  103. /* Per CPU container for runtime CPPC management. */
  104. struct cpudata {
  105. int cpu;
  106. struct cppc_perf_caps perf_caps;
  107. struct cppc_perf_ctrls perf_ctrls;
  108. struct cppc_perf_fb_ctrs perf_fb_ctrs;
  109. struct cpufreq_policy *cur_policy;
  110. unsigned int shared_type;
  111. cpumask_var_t shared_cpu_map;
  112. };
  113. extern int cppc_get_perf_ctrs(int cpu, struct cppc_perf_fb_ctrs *perf_fb_ctrs);
  114. extern int cppc_set_perf(int cpu, struct cppc_perf_ctrls *perf_ctrls);
  115. extern int cppc_get_perf_caps(int cpu, struct cppc_perf_caps *caps);
  116. extern int acpi_get_psd_map(struct cpudata **);
  117. /* Methods to interact with the PCC mailbox controller. */
  118. extern struct mbox_chan *
  119. pcc_mbox_request_channel(struct mbox_client *, unsigned int);
  120. extern int mbox_send_message(struct mbox_chan *chan, void *mssg);
  121. #endif /* _CPPC_ACPI_H*/