Commit 8bf16963 authored by Kevin Wang's avatar Kevin Wang Committed by Alex Deucher

drm/amd/powerplay: implement smu_init[fini]_power function for smu11

This patch implements smu_init[fini]_power function for smu v11.
Signed-off-by: default avatarKevin Wang <Kevin1.Wang@amd.com>
Reviewed-by: default avatarHuang Rui <ray.huang@amd.com>
Acked-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 142dec62
......@@ -167,6 +167,12 @@ static int smu_sw_fini(void *handle)
return ret;
}
ret = smu_fini_power(smu);
if (ret) {
pr_err("Failed to init smu_fini_power!\n");
return ret;
}
return 0;
}
......
......@@ -54,6 +54,11 @@ struct smu_dpm_context {
uint32_t dpm_context_size;
};
struct smu_power_context {
void *power_context;
uint32_t power_context_size;
};
struct smu_context
{
struct amdgpu_device *adev;
......@@ -63,6 +68,7 @@ struct smu_context
struct smu_table_context smu_table;
struct smu_dpm_context smu_dpm;
struct smu_power_context smu_power;
};
struct smu_funcs
......@@ -71,6 +77,7 @@ struct smu_funcs
int (*init_smc_tables)(struct smu_context *smu);
int (*fini_smc_tables)(struct smu_context *smu);
int (*init_power)(struct smu_context *smu);
int (*fini_power)(struct smu_context *smu);
int (*load_microcode)(struct smu_context *smu);
int (*check_fw_status)(struct smu_context *smu);
int (*read_pptable_from_vbios)(struct smu_context *smu);
......@@ -99,6 +106,8 @@ struct smu_funcs
((smu)->funcs->fini_smc_tables ? (smu)->funcs->fini_smc_tables((smu)) : 0)
#define smu_init_power(smu) \
((smu)->funcs->init_power ? (smu)->funcs->init_power((smu)) : 0)
#define smu_fini_power(smu) \
((smu)->funcs->fini_power ? (smu)->funcs->fini_power((smu)) : 0)
#define smu_load_microcode(smu) \
((smu)->funcs->load_microcode ? (smu)->funcs->load_microcode((smu)) : 0)
#define smu_check_fw_status(smu) \
......
......@@ -62,6 +62,20 @@ struct smu_11_0_dpm_context {
uint32_t dcef_min_ds_clk;
};
enum smu_11_0_power_state {
SMU_11_0_POWER_STATE__D0 = 0,
SMU_11_0_POWER_STATE__D1,
SMU_11_0_POWER_STATE__D3, /* Sleep*/
SMU_11_0_POWER_STATE__D4, /* Hibernate*/
SMU_11_0_POWER_STATE__D5, /* Power off*/
};
struct smu_11_0_power_context {
uint32_t power_source;
uint8_t in_power_limit_boost_mode;
enum smu_11_0_power_state power_state;
};
void smu_v11_0_set_smu_funcs(struct smu_context *smu);
#endif
......@@ -313,6 +313,37 @@ static int smu_v11_0_fini_smc_tables(struct smu_context *smu)
return 0;
}
static int smu_v11_0_init_power(struct smu_context *smu)
{
struct smu_power_context *smu_power = &smu->smu_power;
if (smu_power->power_context || smu_power->power_context_size != 0)
return -EINVAL;
smu_power->power_context = kzalloc(sizeof(struct smu_11_0_dpm_context),
GFP_KERNEL);
if (!smu_power->power_context)
return -ENOMEM;
smu_power->power_context_size = sizeof(struct smu_11_0_dpm_context);
return 0;
}
static int smu_v11_0_fini_power(struct smu_context *smu)
{
struct smu_power_context *smu_power = &smu->smu_power;
if (!smu_power->power_context || smu_power->power_context_size == 0)
return -EINVAL;
kfree(smu_power->power_context);
smu_power->power_context = NULL;
smu_power->power_context_size = 0;
return 0;
}
static const struct smu_funcs smu_v11_0_funcs = {
.init_microcode = smu_v11_0_init_microcode,
.load_microcode = smu_v11_0_load_microcode,
......@@ -323,6 +354,8 @@ static const struct smu_funcs smu_v11_0_funcs = {
.read_pptable_from_vbios = smu_v11_0_read_pptable_from_vbios,
.init_smc_tables = smu_v11_0_init_smc_tables,
.fini_smc_tables = smu_v11_0_fini_smc_tables,
.init_power = smu_v11_0_init_power,
.fini_power = smu_v11_0_fini_power,
};
void smu_v11_0_set_smu_funcs(struct smu_context *smu)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment