| From c4780f95777a8d6495d2b0dbe4f8766a337ee9ff Mon Sep 17 00:00:00 2001 |
| From: Sasha Levin <sashal@kernel.org> |
| Date: Wed, 3 Apr 2024 13:52:08 +0300 |
| Subject: ASoC: SOF: Intel: mtl: Implement firmware boot state check |
| |
| From: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> |
| |
| [ Upstream commit 6b1c1c47e76f0161bda2b1ac2e86a219fe70244f ] |
| |
| With the corrected rom_status_reg values we can now add a check for target |
| boot status for firmware booting. |
| With the check now we can identify failed firmware boots (IMR boots) and |
| we can use the fallback to purge boot the DSP. |
| |
| Fixes: 064520e8aeaa ("ASoC: SOF: Intel: Add support for MeteorLake (MTL)") |
| Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> |
| Reviewed-by: Rander Wang <rander.wang@intel.com> |
| Reviewed-by: Kai Vehmanen <kai.vehmanen@linux.intel.com> |
| Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> |
| Reviewed-by: Liam Girdwood <liam.r.girdwood@intel.com> |
| Link: https://msgid.link/r/20240403105210.17949-6-peter.ujfalusi@linux.intel.com |
| Signed-off-by: Mark Brown <broonie@kernel.org> |
| Signed-off-by: Sasha Levin <sashal@kernel.org> |
| --- |
| sound/soc/sof/intel/mtl.c | 37 ++++++++++++++++++++++++++++++++----- |
| 1 file changed, 32 insertions(+), 5 deletions(-) |
| |
| diff --git a/sound/soc/sof/intel/mtl.c b/sound/soc/sof/intel/mtl.c |
| index fbd7cf77e8174..05023763080d9 100644 |
| --- a/sound/soc/sof/intel/mtl.c |
| +++ b/sound/soc/sof/intel/mtl.c |
| @@ -439,7 +439,7 @@ int mtl_dsp_cl_init(struct snd_sof_dev *sdev, int stream_tag, bool imr_boot) |
| { |
| struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; |
| const struct sof_intel_dsp_desc *chip = hda->desc; |
| - unsigned int status; |
| + unsigned int status, target_status; |
| u32 ipc_hdr, flags; |
| char *dump_msg; |
| int ret; |
| @@ -485,13 +485,40 @@ int mtl_dsp_cl_init(struct snd_sof_dev *sdev, int stream_tag, bool imr_boot) |
| |
| mtl_enable_ipc_interrupts(sdev); |
| |
| + if (chip->rom_status_reg == MTL_DSP_ROM_STS) { |
| + /* |
| + * Workaround: when the ROM status register is pointing to |
| + * the SRAM window (MTL_DSP_ROM_STS) the platform cannot catch |
| + * ROM_INIT_DONE because of a very short timing window. |
| + * Follow the recommendations and skip target state waiting. |
| + */ |
| + return 0; |
| + } |
| + |
| /* |
| - * ACE workaround: don't wait for ROM INIT. |
| - * The platform cannot catch ROM_INIT_DONE because of a very short |
| - * timing window. Follow the recommendations and skip this part. |
| + * step 7: |
| + * - Cold/Full boot: wait for ROM init to proceed to download the firmware |
| + * - IMR boot: wait for ROM firmware entered (firmware booted up from IMR) |
| */ |
| + if (imr_boot) |
| + target_status = FSR_STATE_FW_ENTERED; |
| + else |
| + target_status = FSR_STATE_INIT_DONE; |
| |
| - return 0; |
| + ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, |
| + chip->rom_status_reg, status, |
| + (FSR_TO_STATE_CODE(status) == target_status), |
| + HDA_DSP_REG_POLL_INTERVAL_US, |
| + chip->rom_init_timeout * |
| + USEC_PER_MSEC); |
| + |
| + if (!ret) |
| + return 0; |
| + |
| + if (hda->boot_iteration == HDA_FW_BOOT_ATTEMPTS) |
| + dev_err(sdev->dev, |
| + "%s: timeout with rom_status_reg (%#x) read\n", |
| + __func__, chip->rom_status_reg); |
| |
| err: |
| flags = SOF_DBG_DUMP_PCI | SOF_DBG_DUMP_MBOX | SOF_DBG_DUMP_OPTIONAL; |
| -- |
| 2.43.0 |
| |