1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __NVKM_THERM_H__
3 #define __NVKM_THERM_H__
4 #include <core/subdev.h>
6 #include <subdev/bios.h>
7 #include <subdev/bios/therm.h>
8 #include <subdev/timer.h>
10 enum nvkm_therm_thrs_direction
{
11 NVKM_THERM_THRS_FALLING
= 0,
12 NVKM_THERM_THRS_RISING
= 1
15 enum nvkm_therm_thrs_state
{
16 NVKM_THERM_THRS_LOWER
= 0,
17 NVKM_THERM_THRS_HIGHER
= 1
20 enum nvkm_therm_thrs
{
21 NVKM_THERM_THRS_FANBOOST
= 0,
22 NVKM_THERM_THRS_DOWNCLOCK
= 1,
23 NVKM_THERM_THRS_CRITICAL
= 2,
24 NVKM_THERM_THRS_SHUTDOWN
= 3,
28 enum nvkm_therm_fan_mode
{
29 NVKM_THERM_CTRL_NONE
= 0,
30 NVKM_THERM_CTRL_MANUAL
= 1,
31 NVKM_THERM_CTRL_AUTO
= 2,
34 enum nvkm_therm_attr_type
{
35 NVKM_THERM_ATTR_FAN_MIN_DUTY
= 0,
36 NVKM_THERM_ATTR_FAN_MAX_DUTY
= 1,
37 NVKM_THERM_ATTR_FAN_MODE
= 2,
39 NVKM_THERM_ATTR_THRS_FAN_BOOST
= 10,
40 NVKM_THERM_ATTR_THRS_FAN_BOOST_HYST
= 11,
41 NVKM_THERM_ATTR_THRS_DOWN_CLK
= 12,
42 NVKM_THERM_ATTR_THRS_DOWN_CLK_HYST
= 13,
43 NVKM_THERM_ATTR_THRS_CRITICAL
= 14,
44 NVKM_THERM_ATTR_THRS_CRITICAL_HYST
= 15,
45 NVKM_THERM_ATTR_THRS_SHUTDOWN
= 16,
46 NVKM_THERM_ATTR_THRS_SHUTDOWN_HYST
= 17,
50 const struct nvkm_therm_func
*func
;
51 struct nvkm_subdev subdev
;
53 /* automatic thermal management */
54 struct nvkm_alarm alarm
;
56 struct nvbios_therm_trip_point
*last_trip
;
62 struct nvbios_therm_sensor bios_sensor
;
69 spinlock_t alarm_program_lock
;
70 struct nvkm_alarm therm_poll_alarm
;
71 enum nvkm_therm_thrs_state alarm_state
[NVKM_THERM_THRS_NR
];
74 /* what should be done if the card overheats */
76 void (*downclock
)(struct nvkm_therm
*, bool active
);
77 void (*pause
)(struct nvkm_therm
*, bool active
);
81 struct i2c_client
*ic
;
83 int (*fan_get
)(struct nvkm_therm
*);
84 int (*fan_set
)(struct nvkm_therm
*, int);
86 int (*attr_get
)(struct nvkm_therm
*, enum nvkm_therm_attr_type
);
87 int (*attr_set
)(struct nvkm_therm
*, enum nvkm_therm_attr_type
, int);
90 int nvkm_therm_temp_get(struct nvkm_therm
*);
91 int nvkm_therm_fan_sense(struct nvkm_therm
*);
92 int nvkm_therm_cstate(struct nvkm_therm
*, int, int);
94 int nv40_therm_new(struct nvkm_device
*, int, struct nvkm_therm
**);
95 int nv50_therm_new(struct nvkm_device
*, int, struct nvkm_therm
**);
96 int g84_therm_new(struct nvkm_device
*, int, struct nvkm_therm
**);
97 int gt215_therm_new(struct nvkm_device
*, int, struct nvkm_therm
**);
98 int gf119_therm_new(struct nvkm_device
*, int, struct nvkm_therm
**);
99 int gm107_therm_new(struct nvkm_device
*, int, struct nvkm_therm
**);
100 int gm200_therm_new(struct nvkm_device
*, int, struct nvkm_therm
**);