1 #ifndef __NVTHERM_PRIV_H__
2 #define __NVTHERM_PRIV_H__
4 * Copyright 2012 The Nouveau community
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
24 * Authors: Martin Peres
26 #include <subdev/therm.h>
27 #include <subdev/bios.h>
28 #include <subdev/bios/extdev.h>
29 #include <subdev/bios/gpio.h>
30 #include <subdev/bios/perf.h>
31 #include <subdev/bios/therm.h>
32 #include <subdev/timer.h>
35 struct nvkm_therm
*parent
;
38 struct nvbios_therm_fan bios
;
39 struct nvbios_perf_fan perf
;
41 struct nvkm_alarm alarm
;
45 int (*get
)(struct nvkm_therm
*);
46 int (*set
)(struct nvkm_therm
*, int percent
);
48 struct dcb_gpio_func tach
;
51 enum nvkm_therm_thrs_direction
{
52 NVKM_THERM_THRS_FALLING
= 0,
53 NVKM_THERM_THRS_RISING
= 1
56 enum nvkm_therm_thrs_state
{
57 NVKM_THERM_THRS_LOWER
= 0,
58 NVKM_THERM_THRS_HIGHER
= 1
61 enum nvkm_therm_thrs
{
62 NVKM_THERM_THRS_FANBOOST
= 0,
63 NVKM_THERM_THRS_DOWNCLOCK
= 1,
64 NVKM_THERM_THRS_CRITICAL
= 2,
65 NVKM_THERM_THRS_SHUTDOWN
= 3,
69 struct nvkm_therm_priv
{
70 struct nvkm_therm base
;
72 /* automatic thermal management */
73 struct nvkm_alarm alarm
;
75 struct nvbios_therm_trip_point
*last_trip
;
81 struct nvbios_therm_sensor bios_sensor
;
88 spinlock_t alarm_program_lock
;
89 struct nvkm_alarm therm_poll_alarm
;
90 enum nvkm_therm_thrs_state alarm_state
[NVKM_THERM_THRS_NR
];
91 void (*program_alarms
)(struct nvkm_therm
*);
94 /* what should be done if the card overheats */
96 void (*downclock
)(struct nvkm_therm
*, bool active
);
97 void (*pause
)(struct nvkm_therm
*, bool active
);
101 struct i2c_client
*ic
;
104 int nvkm_therm_fan_mode(struct nvkm_therm
*, int mode
);
105 int nvkm_therm_attr_get(struct nvkm_therm
*, enum nvkm_therm_attr_type
);
106 int nvkm_therm_attr_set(struct nvkm_therm
*, enum nvkm_therm_attr_type
, int);
108 void nvkm_therm_ic_ctor(struct nvkm_therm
*);
110 int nvkm_therm_sensor_ctor(struct nvkm_therm
*);
112 int nvkm_therm_fan_ctor(struct nvkm_therm
*);
113 int nvkm_therm_fan_init(struct nvkm_therm
*);
114 int nvkm_therm_fan_fini(struct nvkm_therm
*, bool suspend
);
115 int nvkm_therm_fan_get(struct nvkm_therm
*);
116 int nvkm_therm_fan_set(struct nvkm_therm
*, bool now
, int percent
);
117 int nvkm_therm_fan_user_get(struct nvkm_therm
*);
118 int nvkm_therm_fan_user_set(struct nvkm_therm
*, int percent
);
120 int nvkm_therm_fan_sense(struct nvkm_therm
*);
122 int nvkm_therm_preinit(struct nvkm_therm
*);
124 int nvkm_therm_sensor_init(struct nvkm_therm
*);
125 int nvkm_therm_sensor_fini(struct nvkm_therm
*, bool suspend
);
126 void nvkm_therm_sensor_preinit(struct nvkm_therm
*);
127 void nvkm_therm_sensor_set_threshold_state(struct nvkm_therm
*,
128 enum nvkm_therm_thrs
,
129 enum nvkm_therm_thrs_state
);
130 enum nvkm_therm_thrs_state
131 nvkm_therm_sensor_get_threshold_state(struct nvkm_therm
*,
132 enum nvkm_therm_thrs
);
133 void nvkm_therm_sensor_event(struct nvkm_therm
*, enum nvkm_therm_thrs
,
134 enum nvkm_therm_thrs_direction
);
135 void nvkm_therm_program_alarms_polling(struct nvkm_therm
*);
137 void nv40_therm_intr(struct nvkm_subdev
*);
138 int nv50_fan_pwm_ctrl(struct nvkm_therm
*, int, bool);
139 int nv50_fan_pwm_get(struct nvkm_therm
*, int, u32
*, u32
*);
140 int nv50_fan_pwm_set(struct nvkm_therm
*, int, u32
, u32
);
141 int nv50_fan_pwm_clock(struct nvkm_therm
*, int);
142 int g84_temp_get(struct nvkm_therm
*);
143 void g84_sensor_setup(struct nvkm_therm
*);
144 int g84_therm_fini(struct nvkm_object
*, bool suspend
);
146 int gt215_therm_fan_sense(struct nvkm_therm
*);
148 int gf110_therm_init(struct nvkm_object
*);
150 int nvkm_fanpwm_create(struct nvkm_therm
*, struct dcb_gpio_func
*);
151 int nvkm_fantog_create(struct nvkm_therm
*, struct dcb_gpio_func
*);
152 int nvkm_fannil_create(struct nvkm_therm
*);