Merge tag 'block-5.11-2021-01-10' of git://git.kernel.dk/linux-block
[linux/fpc-iii.git] / drivers / gpu / drm / nouveau / include / nvkm / subdev / therm.h
blob62c34f98c93079fb0c91bfe21f8a9029606a6e83
1 /* SPDX-License-Identifier: MIT */
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,
25 NVKM_THERM_THRS_NR
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,
49 struct nvkm_therm_clkgate_init {
50 u32 addr;
51 u8 count;
52 u32 data;
55 struct nvkm_therm_clkgate_pack {
56 const struct nvkm_therm_clkgate_init *init;
59 struct nvkm_therm {
60 const struct nvkm_therm_func *func;
61 struct nvkm_subdev subdev;
63 /* automatic thermal management */
64 struct nvkm_alarm alarm;
65 spinlock_t lock;
66 struct nvbios_therm_trip_point *last_trip;
67 int mode;
68 int cstate;
69 int suspend;
71 /* bios */
72 struct nvbios_therm_sensor bios_sensor;
74 /* fan priv */
75 struct nvkm_fan *fan;
77 /* alarms priv */
78 struct {
79 spinlock_t alarm_program_lock;
80 struct nvkm_alarm therm_poll_alarm;
81 enum nvkm_therm_thrs_state alarm_state[NVKM_THERM_THRS_NR];
82 } sensor;
84 /* what should be done if the card overheats */
85 struct {
86 void (*downclock)(struct nvkm_therm *, bool active);
87 void (*pause)(struct nvkm_therm *, bool active);
88 } emergency;
90 /* ic */
91 struct i2c_client *ic;
93 int (*fan_get)(struct nvkm_therm *);
94 int (*fan_set)(struct nvkm_therm *, int);
96 int (*attr_get)(struct nvkm_therm *, enum nvkm_therm_attr_type);
97 int (*attr_set)(struct nvkm_therm *, enum nvkm_therm_attr_type, int);
99 bool clkgating_enabled;
102 int nvkm_therm_temp_get(struct nvkm_therm *);
103 int nvkm_therm_fan_sense(struct nvkm_therm *);
104 int nvkm_therm_cstate(struct nvkm_therm *, int, int);
105 void nvkm_therm_clkgate_init(struct nvkm_therm *,
106 const struct nvkm_therm_clkgate_pack *);
107 void nvkm_therm_clkgate_enable(struct nvkm_therm *);
108 void nvkm_therm_clkgate_fini(struct nvkm_therm *, bool);
110 int nv40_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
111 int nv50_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
112 int g84_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
113 int gt215_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
114 int gf119_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
115 int gk104_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
116 int gm107_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
117 int gm200_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
118 int gp100_therm_new(struct nvkm_device *, int, struct nvkm_therm **);
119 #endif