clk.h 3.4 KB

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