Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eede5262 authored by Eric Huang's avatar Eric Huang Committed by Alex Deucher
Browse files

drm/amd/powerplay: add thermal control for elm/baf

parent 0ff71753
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ HARDWARE_MGR = hwmgr.o processpptables.o functiontables.o \
               tonga_hwmgr.o pppcielanes.o  tonga_thermal.o\
               fiji_powertune.o fiji_hwmgr.o tonga_clockpowergating.o \
               fiji_clockpowergating.o fiji_thermal.o \
	       ellesmere_hwmgr.o ellesmere_powertune.o
	       ellesmere_hwmgr.o ellesmere_powertune.o ellesmere_thermal.o

AMD_PP_HWMGR = $(addprefix $(AMD_PP_PATH)/hwmgr/,$(HARDWARE_MGR))

+27 −12
Original line number Diff line number Diff line
@@ -57,6 +57,8 @@
#include "dce/dce_10_0_d.h"
#include "dce/dce_10_0_sh_mask.h"

#include "ellesmere_thermal.h"

#define MC_CG_ARB_FREQ_F0           0x0a
#define MC_CG_ARB_FREQ_F1           0x0b
#define MC_CG_ARB_FREQ_F2           0x0c
@@ -4198,8 +4200,14 @@ static int ellesmere_set_power_state_tasks(struct pp_hwmgr *hwmgr, const void *i

static int ellesmere_set_max_fan_pwm_output(struct pp_hwmgr *hwmgr, uint16_t us_max_fan_pwm)
{
	hwmgr->thermal_controller.
	advanceFanControlParameters.usMaxFanPWM = us_max_fan_pwm;

	if (phm_is_hw_access_blocked(hwmgr))
		return 0;

	return smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
			PPSMC_MSG_SetFanPwmMax, us_max_fan_pwm);
}

int ellesmere_notify_smc_display_change(struct pp_hwmgr *hwmgr, bool has_display)
@@ -4290,9 +4298,16 @@ int ellesmere_display_configuration_changed_task(struct pp_hwmgr *hwmgr)
* @param    usMaxFanRpm:  max operating fan RPM value.
* @return   The response that came from the SMC.
*/
static int ellesmere_set_max_fan_rpm_output(struct pp_hwmgr *hwmgr, uint16_t us_max_fan_pwm)
static int ellesmere_set_max_fan_rpm_output(struct pp_hwmgr *hwmgr, uint16_t us_max_fan_rpm)
{
	hwmgr->thermal_controller.
	advanceFanControlParameters.usMaxFanRPM = us_max_fan_rpm;

	if (phm_is_hw_access_blocked(hwmgr))
		return 0;

	return smum_send_msg_to_smc_with_parameter(hwmgr->smumgr,
			PPSMC_MSG_SetFanRpmMax, us_max_fan_rpm);
}

int ellesmere_register_internal_thermal_interrupt(struct pp_hwmgr *hwmgr,
@@ -4529,15 +4544,15 @@ static const struct pp_hwmgr_func ellesmere_hwmgr_funcs = {
	.display_config_changed = ellesmere_display_configuration_changed_task,
	.set_max_fan_pwm_output = ellesmere_set_max_fan_pwm_output,
	.set_max_fan_rpm_output = ellesmere_set_max_fan_rpm_output,
	.get_temperature = NULL,
	.stop_thermal_controller = NULL,
	.get_fan_speed_info = NULL,
	.get_fan_speed_percent = NULL,
	.set_fan_speed_percent = NULL,
	.reset_fan_speed_to_default = NULL,
	.get_fan_speed_rpm = NULL,
	.set_fan_speed_rpm = NULL,
	.uninitialize_thermal_controller = NULL,
	.get_temperature = ellesmere_thermal_get_temperature,
	.stop_thermal_controller = ellesmere_thermal_stop_thermal_controller,
	.get_fan_speed_info = ellesmere_fan_ctrl_get_fan_speed_info,
	.get_fan_speed_percent = ellesmere_fan_ctrl_get_fan_speed_percent,
	.set_fan_speed_percent = ellesmere_fan_ctrl_set_fan_speed_percent,
	.reset_fan_speed_to_default = ellesmere_fan_ctrl_reset_fan_speed_to_default,
	.get_fan_speed_rpm = ellesmere_fan_ctrl_get_fan_speed_rpm,
	.set_fan_speed_rpm = ellesmere_fan_ctrl_set_fan_speed_rpm,
	.uninitialize_thermal_controller = ellesmere_thermal_ctrl_uninitialize_thermal_controller,
	.register_internal_thermal_interrupt = ellesmere_register_internal_thermal_interrupt,
	.check_smc_update_required_for_display_configuration = ellesmere_check_smc_update_required_for_display_configuration,
	.check_states_equal = ellesmere_check_states_equal,
@@ -4554,7 +4569,7 @@ int ellesemere_hwmgr_init(struct pp_hwmgr *hwmgr)
	hwmgr->backend = data;
	hwmgr->hwmgr_func = &ellesmere_hwmgr_funcs;
	hwmgr->pptable_func = &tonga_pptable_funcs;

	pp_ellesmere_thermal_initialize(hwmgr);

	return 0;
}
+711 −0

File added.

Preview size limit exceeded, changes collapsed.

+62 −0
Original line number Diff line number Diff line
/*
 * Copyright 2016 Advanced Micro Devices, Inc.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 * OTHER DEALINGS IN THE SOFTWARE.
 *
 */

#ifndef _ELLESMERE_THERMAL_H_
#define _ELLESMERE_THERMAL_H_

#include "hwmgr.h"

#define ELLESMERE_THERMAL_HIGH_ALERT_MASK         0x1
#define ELLESMERE_THERMAL_LOW_ALERT_MASK          0x2

#define ELLESMERE_THERMAL_MINIMUM_TEMP_READING    -256
#define ELLESMERE_THERMAL_MAXIMUM_TEMP_READING    255

#define ELLESMERE_THERMAL_MINIMUM_ALERT_TEMP      0
#define ELLESMERE_THERMAL_MAXIMUM_ALERT_TEMP      255

#define FDO_PWM_MODE_STATIC  1
#define FDO_PWM_MODE_STATIC_RPM 5


extern int tf_ellesmere_thermal_initialize(struct pp_hwmgr *hwmgr, void *input, void *output, void *storage, int result);
extern int tf_ellesmere_thermal_set_temperature_range(struct pp_hwmgr *hwmgr, void *input, void *output, void *storage, int result);
extern int tf_ellesmere_thermal_enable_alert(struct pp_hwmgr *hwmgr, void *input, void *output, void *storage, int result);

extern int ellesmere_thermal_get_temperature(struct pp_hwmgr *hwmgr);
extern int ellesmere_thermal_stop_thermal_controller(struct pp_hwmgr *hwmgr);
extern int ellesmere_fan_ctrl_get_fan_speed_info(struct pp_hwmgr *hwmgr, struct phm_fan_speed_info *fan_speed_info);
extern int ellesmere_fan_ctrl_get_fan_speed_percent(struct pp_hwmgr *hwmgr, uint32_t *speed);
extern int ellesmere_fan_ctrl_set_default_mode(struct pp_hwmgr *hwmgr);
extern int ellesmere_fan_ctrl_set_static_mode(struct pp_hwmgr *hwmgr, uint32_t mode);
extern int ellesmere_fan_ctrl_set_fan_speed_percent(struct pp_hwmgr *hwmgr, uint32_t speed);
extern int ellesmere_fan_ctrl_reset_fan_speed_to_default(struct pp_hwmgr *hwmgr);
extern int pp_ellesmere_thermal_initialize(struct pp_hwmgr *hwmgr);
extern int ellesmere_thermal_ctrl_uninitialize_thermal_controller(struct pp_hwmgr *hwmgr);
extern int ellesmere_fan_ctrl_set_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t speed);
extern int ellesmere_fan_ctrl_get_fan_speed_rpm(struct pp_hwmgr *hwmgr, uint32_t *speed);
extern int ellesmere_fan_ctrl_stop_smc_fan_control(struct pp_hwmgr *hwmgr);
extern uint32_t tonga_get_xclk(struct pp_hwmgr *hwmgr);

#endif