clk.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __NVKM_CLK_H__
  3. #define __NVKM_CLK_H__
  4. #include <core/subdev.h>
  5. #include <core/notify.h>
  6. #include <subdev/pci.h>
  7. struct nvbios_pll;
  8. struct nvkm_pll_vals;
  9. #define NVKM_CLK_CSTATE_DEFAULT -1 /* POSTed default */
  10. #define NVKM_CLK_CSTATE_BASE -2 /* pstate base */
  11. #define NVKM_CLK_CSTATE_HIGHEST -3 /* highest possible */
  12. enum nv_clk_src {
  13. nv_clk_src_crystal,
  14. nv_clk_src_href,
  15. nv_clk_src_hclk,
  16. nv_clk_src_hclkm3,
  17. nv_clk_src_hclkm3d2,
  18. nv_clk_src_hclkm2d3, /* NVAA */
  19. nv_clk_src_hclkm4, /* NVAA */
  20. nv_clk_src_cclk, /* NVAA */
  21. nv_clk_src_host,
  22. nv_clk_src_sppll0,
  23. nv_clk_src_sppll1,
  24. nv_clk_src_mpllsrcref,
  25. nv_clk_src_mpllsrc,
  26. nv_clk_src_mpll,
  27. nv_clk_src_mdiv,
  28. nv_clk_src_core,
  29. nv_clk_src_core_intm,
  30. nv_clk_src_shader,
  31. nv_clk_src_mem,
  32. nv_clk_src_gpc,
  33. nv_clk_src_rop,
  34. nv_clk_src_hubk01,
  35. nv_clk_src_hubk06,
  36. nv_clk_src_hubk07,
  37. nv_clk_src_copy,
  38. nv_clk_src_pmu,
  39. nv_clk_src_disp,
  40. nv_clk_src_vdec,
  41. nv_clk_src_dom6,
  42. nv_clk_src_max,
  43. };
  44. struct nvkm_cstate {
  45. struct list_head head;
  46. u8 voltage;
  47. u32 domain[nv_clk_src_max];
  48. u8 id;
  49. };
  50. struct nvkm_pstate {
  51. struct list_head head;
  52. struct list_head list; /* c-states */
  53. struct nvkm_cstate base;
  54. u8 pstate;
  55. u8 fanspeed;
  56. enum nvkm_pcie_speed pcie_speed;
  57. u8 pcie_width;
  58. };
  59. struct nvkm_domain {
  60. enum nv_clk_src name;
  61. u8 bios; /* 0xff for none */
  62. #define NVKM_CLK_DOM_FLAG_CORE 0x01
  63. #define NVKM_CLK_DOM_FLAG_VPSTATE 0x02
  64. u8 flags;
  65. const char *mname;
  66. int mdiv;
  67. };
  68. struct nvkm_clk {
  69. const struct nvkm_clk_func *func;
  70. struct nvkm_subdev subdev;
  71. const struct nvkm_domain *domains;
  72. struct nvkm_pstate bstate;
  73. struct list_head states;
  74. int state_nr;
  75. struct work_struct work;
  76. wait_queue_head_t wait;
  77. atomic_t waiting;
  78. struct nvkm_notify pwrsrc_ntfy;
  79. int pwrsrc;
  80. int pstate; /* current */
  81. int ustate_ac; /* user-requested (-1 disabled, -2 perfmon) */
  82. int ustate_dc; /* user-requested (-1 disabled, -2 perfmon) */
  83. int astate; /* perfmon adjustment (base) */
  84. int dstate; /* display adjustment (min+) */
  85. u8 temp;
  86. bool allow_reclock;
  87. #define NVKM_CLK_BOOST_NONE 0x0
  88. #define NVKM_CLK_BOOST_BIOS 0x1
  89. #define NVKM_CLK_BOOST_FULL 0x2
  90. u8 boost_mode;
  91. u32 base_khz;
  92. u32 boost_khz;
  93. /*XXX: die, these are here *only* to support the completely
  94. * bat-shit insane what-was-nouveau_hw.c code
  95. */
  96. int (*pll_calc)(struct nvkm_clk *, struct nvbios_pll *, int clk,
  97. struct nvkm_pll_vals *pv);
  98. int (*pll_prog)(struct nvkm_clk *, u32 reg1, struct nvkm_pll_vals *pv);
  99. };
  100. int nvkm_clk_read(struct nvkm_clk *, enum nv_clk_src);
  101. int nvkm_clk_ustate(struct nvkm_clk *, int req, int pwr);
  102. int nvkm_clk_astate(struct nvkm_clk *, int req, int rel, bool wait);
  103. int nvkm_clk_dstate(struct nvkm_clk *, int req, int rel);
  104. int nvkm_clk_tstate(struct nvkm_clk *, u8 temperature);
  105. int nv04_clk_new(struct nvkm_device *, int, struct nvkm_clk **);
  106. int nv40_clk_new(struct nvkm_device *, int, struct nvkm_clk **);
  107. int nv50_clk_new(struct nvkm_device *, int, struct nvkm_clk **);
  108. int g84_clk_new(struct nvkm_device *, int, struct nvkm_clk **);
  109. int mcp77_clk_new(struct nvkm_device *, int, struct nvkm_clk **);
  110. int gt215_clk_new(struct nvkm_device *, int, struct nvkm_clk **);
  111. int gf100_clk_new(struct nvkm_device *, int, struct nvkm_clk **);
  112. int gk104_clk_new(struct nvkm_device *, int, struct nvkm_clk **);
  113. int gk20a_clk_new(struct nvkm_device *, int, struct nvkm_clk **);
  114. int gm20b_clk_new(struct nvkm_device *, int, struct nvkm_clk **);
  115. #endif