therm.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef __NVKM_THERM_H__
  3. #define __NVKM_THERM_H__
  4. #include <core/subdev.h>
  5. #include <subdev/bios.h>
  6. #include <subdev/bios/therm.h>
  7. #include <subdev/timer.h>
  8. enum nvkm_therm_thrs_direction {
  9. NVKM_THERM_THRS_FALLING = 0,
  10. NVKM_THERM_THRS_RISING = 1
  11. };
  12. enum nvkm_therm_thrs_state {
  13. NVKM_THERM_THRS_LOWER = 0,
  14. NVKM_THERM_THRS_HIGHER = 1
  15. };
  16. enum nvkm_therm_thrs {
  17. NVKM_THERM_THRS_FANBOOST = 0,
  18. NVKM_THERM_THRS_DOWNCLOCK = 1,
  19. NVKM_THERM_THRS_CRITICAL = 2,
  20. NVKM_THERM_THRS_SHUTDOWN = 3,
  21. NVKM_THERM_THRS_NR
  22. };
  23. enum nvkm_therm_fan_mode {
  24. NVKM_THERM_CTRL_NONE = 0,
  25. NVKM_THERM_CTRL_MANUAL = 1,
  26. NVKM_THERM_CTRL_AUTO = 2,
  27. };
  28. enum nvkm_therm_attr_type {
  29. NVKM_THERM_ATTR_FAN_MIN_DUTY = 0,
  30. NVKM_THERM_ATTR_FAN_MAX_DUTY = 1,
  31. NVKM_THERM_ATTR_FAN_MODE = 2,
  32. NVKM_THERM_ATTR_THRS_FAN_BOOST = 10,
  33. NVKM_THERM_ATTR_THRS_FAN_BOOST_HYST = 11,
  34. NVKM_THERM_ATTR_THRS_DOWN_CLK = 12,
  35. NVKM_THERM_ATTR_THRS_DOWN_CLK_HYST = 13,
  36. NVKM_THERM_ATTR_THRS_CRITICAL = 14,
  37. NVKM_THERM_ATTR_THRS_CRITICAL_HYST = 15,
  38. NVKM_THERM_ATTR_THRS_SHUTDOWN = 16,
  39. NVKM_THERM_ATTR_THRS_SHUTDOWN_HYST = 17,
  40. };
  41. struct nvkm_therm_clkgate_init {
  42. u32 addr;
  43. u8 count;
  44. u32 data;
  45. };
  46. struct nvkm_therm_clkgate_pack {
  47. const struct nvkm_therm_clkgate_init *init;
  48. };
  49. struct nvkm_therm {
  50. const struct nvkm_therm_func *func;
  51. struct nvkm_subdev subdev;
  52. /* automatic thermal management */
  53. struct nvkm_alarm alarm;
  54. spinlock_t lock;
  55. struct nvbios_therm_trip_point *last_trip;
  56. int mode;
  57. int cstate;
  58. int suspend;
  59. /* bios */
  60. struct nvbios_therm_sensor bios_sensor;
  61. /* fan priv */
  62. struct nvkm_fan *fan;
  63. /* alarms priv */
  64. struct {
  65. spinlock_t alarm_program_lock;
  66. struct nvkm_alarm therm_poll_alarm;
  67. enum nvkm_therm_thrs_state alarm_state[NVKM_THERM_THRS_NR];
  68. } sensor;
  69. /* what should be done if the card overheats */
  70. struct {
  71. void (*downclock)(struct nvkm_therm *, bool active);
  72. void (*pause)(struct nvkm_therm *, bool active);
  73. } emergency;
  74. /* ic */
  75. struct i2c_client *ic;
  76. int (*fan_get)(struct nvkm_therm *);
  77. int (*fan_set)(struct nvkm_therm *, int);
  78. int (*attr_get)(struct nvkm_therm *, enum nvkm_therm_attr_type);
  79. int (*attr_set)(struct nvkm_therm *, enum nvkm_therm_attr_type, int);
  80. bool clkgating_enabled;
  81. };
  82. int nvkm_therm_temp_get(struct nvkm_therm *);
  83. int nvkm_therm_fan_sense(struct nvkm_therm *);
  84. int nvkm_therm_cstate(struct nvkm_therm *, int, int);
  85. void nvkm_therm_clkgate_init(struct nvkm_therm *,
  86. const struct nvkm_therm_clkgate_pack *);
  87. void nvkm_therm_clkgate_enable(struct nvkm_therm *);
  88. void nvkm_therm_clkgate_fini(struct nvkm_therm *, bool);
  89. int nv40_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
  90. int nv50_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
  91. int g84_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
  92. int gt215_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
  93. int gf119_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
  94. int gk104_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
  95. int gm107_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
  96. int gm200_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
  97. int gp100_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
  98. #endif