1 #ifndef __NVTHERM_PRIV_H__
2 #define __NVTHERM_PRIV_H__
5 * Copyright 2012 The Nouveau community
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
25 * Authors: Martin Peres
28 #include <subdev/therm.h>
30 #include <subdev/bios/extdev.h>
31 #include <subdev/bios/gpio.h>
32 #include <subdev/bios/perf.h>
33 #include <subdev/bios/therm.h>
34 #include <subdev/timer.h>
37 struct nouveau_therm
*parent
;
40 struct nvbios_therm_fan bios
;
41 struct nvbios_perf_fan perf
;
43 struct nouveau_alarm alarm
;
47 int (*get
)(struct nouveau_therm
*therm
);
48 int (*set
)(struct nouveau_therm
*therm
, int percent
);
50 struct dcb_gpio_func tach
;
53 enum nouveau_therm_thrs_direction
{
54 NOUVEAU_THERM_THRS_FALLING
= 0,
55 NOUVEAU_THERM_THRS_RISING
= 1
58 enum nouveau_therm_thrs_state
{
59 NOUVEAU_THERM_THRS_LOWER
= 0,
60 NOUVEAU_THERM_THRS_HIGHER
= 1
63 enum nouveau_therm_thrs
{
64 NOUVEAU_THERM_THRS_FANBOOST
= 0,
65 NOUVEAU_THERM_THRS_DOWNCLOCK
= 1,
66 NOUVEAU_THERM_THRS_CRITICAL
= 2,
67 NOUVEAU_THERM_THRS_SHUTDOWN
= 3,
71 struct nouveau_therm_priv
{
72 struct nouveau_therm base
;
74 /* automatic thermal management */
75 struct nouveau_alarm alarm
;
77 struct nouveau_therm_trip_point
*last_trip
;
82 struct nvbios_therm_sensor bios_sensor
;
85 struct nouveau_fan
*fan
;
89 spinlock_t alarm_program_lock
;
90 struct nouveau_alarm therm_poll_alarm
;
91 enum nouveau_therm_thrs_state alarm_state
[NOUVEAU_THERM_THRS_NR
];
92 void (*program_alarms
)(struct nouveau_therm
*);
95 /* what should be done if the card overheats */
97 void (*downclock
)(struct nouveau_therm
*, bool active
);
98 void (*pause
)(struct nouveau_therm
*, bool active
);
102 struct i2c_client
*ic
;
105 int nouveau_therm_fan_mode(struct nouveau_therm
*therm
, int mode
);
106 int nouveau_therm_attr_get(struct nouveau_therm
*therm
,
107 enum nouveau_therm_attr_type type
);
108 int nouveau_therm_attr_set(struct nouveau_therm
*therm
,
109 enum nouveau_therm_attr_type type
, int value
);
111 void nouveau_therm_ic_ctor(struct nouveau_therm
*therm
);
113 int nouveau_therm_sensor_ctor(struct nouveau_therm
*therm
);
115 int nouveau_therm_fan_ctor(struct nouveau_therm
*therm
);
116 int nouveau_therm_fan_get(struct nouveau_therm
*therm
);
117 int nouveau_therm_fan_set(struct nouveau_therm
*therm
, bool now
, int percent
);
118 int nouveau_therm_fan_user_get(struct nouveau_therm
*therm
);
119 int nouveau_therm_fan_user_set(struct nouveau_therm
*therm
, int percent
);
121 int nouveau_therm_fan_sense(struct nouveau_therm
*therm
);
123 int nouveau_therm_preinit(struct nouveau_therm
*);
125 void nouveau_therm_sensor_preinit(struct nouveau_therm
*);
126 void nouveau_therm_sensor_set_threshold_state(struct nouveau_therm
*therm
,
127 enum nouveau_therm_thrs thrs
,
128 enum nouveau_therm_thrs_state st
);
129 enum nouveau_therm_thrs_state
130 nouveau_therm_sensor_get_threshold_state(struct nouveau_therm
*therm
,
131 enum nouveau_therm_thrs thrs
);
132 void nouveau_therm_sensor_event(struct nouveau_therm
*therm
,
133 enum nouveau_therm_thrs thrs
,
134 enum nouveau_therm_thrs_direction dir
);
135 void nouveau_therm_program_alarms_polling(struct nouveau_therm
*therm
);
137 int nv50_fan_pwm_ctrl(struct nouveau_therm
*, int, bool);
138 int nv50_fan_pwm_get(struct nouveau_therm
*, int, u32
*, u32
*);
139 int nv50_fan_pwm_set(struct nouveau_therm
*, int, u32
, u32
);
140 int nv50_fan_pwm_clock(struct nouveau_therm
*);
141 int nv50_temp_get(struct nouveau_therm
*therm
);
143 int nva3_therm_fan_sense(struct nouveau_therm
*);
145 int nouveau_fanpwm_create(struct nouveau_therm
*, struct dcb_gpio_func
*);
146 int nouveau_fantog_create(struct nouveau_therm
*, struct dcb_gpio_func
*);
147 int nouveau_fannil_create(struct nouveau_therm
*);