Skip to content

Commit

Permalink
ASoC: SOF: Intel: CNL/ICL: set core_get op
Browse files Browse the repository at this point in the history
Set core_get op for CNL/ICL platforms. These platforms
do not support enabling/disabling secondary cores
dynamically. So power them up when requested for the
first time and they will be powered down during D3.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
  • Loading branch information
ranj063 committed Jun 30, 2021
1 parent f349185 commit 46a4d78
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions sound/soc/sof/intel/cnl.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ const struct snd_sof_dsp_ops sof_cnl_ops = {
/* dsp core power up/down */
.core_power_up = hda_dsp_enable_core,
.core_power_down = hda_dsp_core_reset_power_down,
.core_get = hda_dsp_core_get,

/* firmware run */
.run = hda_dsp_cl_boot_firmware,
Expand Down
62 changes: 62 additions & 0 deletions sound/soc/sof/intel/hda-dsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -963,3 +963,65 @@ void hda_dsp_d0i3_work(struct work_struct *work)
"error: failed to set DSP state %d substate %d\n",
target_state.state, target_state.substate);
}

/*
* Some platforms do not support enabling/disabling secondary cores dynamically. Power up
* the requested core when used for the first time.
*/
int hda_dsp_core_get(struct snd_sof_dev *sdev, int core)
{
struct sof_ipc_pm_core_config pm_core_config = {
.hdr = {
.cmd = SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_CORE_ENABLE,
.size = sizeof(pm_core_config),
},
.enable_mask = sdev->enabled_cores_mask | BIT(core),
};
const struct sof_intel_dsp_desc *chip = get_chip_info(sdev->pdata);
int ret, ret1;

if (!chip)
return -EIO;

if (core > sdev->num_cores - 1) {
dev_err(sdev->dev, "invalid core id: %d for num_cores: %d \n", core,
sdev->num_cores);
return -EINVAL;
}

/* nothing to do if core is already enabled */
if (sdev->enabled_cores_mask && BIT(core))
return 0;

/* first power up the core if it is host managed */
if (BIT(core) & chip->host_managed_cores_mask) {
ret = snd_sof_dsp_core_power_up(sdev, BIT(core));
if (ret < 0) {
dev_err(sdev->dev, "failed to power up core %d with err: %d\n",
core, ret);
return ret;
}
}

/* Now notify DSP */
ret = sof_ipc_tx_message(sdev->ipc, pm_core_config.hdr.cmd,
&pm_core_config, sizeof(pm_core_config),
&pm_core_config, sizeof(pm_core_config));
if (ret < 0) {
dev_err(sdev->dev, "failed to enable secondary core '%d' failed with %d\n",
core, ret);
goto power_down;
}

sdev->enabled_cores_mask |= BIT(core);

return ret;

power_down:
/* power down core if it is host managed and return the original error if this fails too */
ret1 = snd_sof_dsp_core_power_down(sdev, BIT(core));
if (ret1 < 0)
dev_err(sdev->dev, "failed to power down core: %d with err: %d\n", core, ret1);

return ret;
}
1 change: 1 addition & 0 deletions sound/soc/sof/intel/hda.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ int hda_dsp_core_run(struct snd_sof_dev *sdev, unsigned int core_mask);
int hda_dsp_enable_core(struct snd_sof_dev *sdev, unsigned int core_mask);
int hda_dsp_core_reset_power_down(struct snd_sof_dev *sdev,
unsigned int core_mask);
int hda_dsp_core_get(struct snd_sof_dev *sdev, int core);
void hda_dsp_ipc_int_enable(struct snd_sof_dev *sdev);
void hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev);

Expand Down
1 change: 1 addition & 0 deletions sound/soc/sof/intel/icl.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const struct snd_sof_dsp_ops sof_icl_ops = {
/* dsp core power up/down */
.core_power_up = hda_dsp_enable_core,
.core_power_down = hda_dsp_core_reset_power_down,
.core_get = hda_dsp_core_get,

/* firmware run */
.run = hda_dsp_cl_boot_firmware_iccmax,
Expand Down

0 comments on commit 46a4d78

Please sign in to comment.