therm.h 2.5 KB

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