Skip to content

Commit 52a5577

Browse files
RanderWangbroonie
authored andcommitted
ASoC: SOF: Intel: hda-dsp: harden D0i3 programming sequence
Add delay between set and wait command according to hardware programming sequence. Also add debug log to detect error. Signed-off-by: Rander Wang <rander.wang@intel.com> Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com> Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Link: https://lore.kernel.org/r/20230307095453.3719-1-peter.ujfalusi@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent c99e48f commit 52a5577

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

sound/soc/sof/intel/hda-dsp.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,12 @@ static int hda_dsp_update_d0i3c_register(struct snd_sof_dev *sdev, u8 value)
392392
snd_sof_dsp_update8(sdev, HDA_DSP_HDA_BAR, chip->d0i3_offset,
393393
SOF_HDA_VS_D0I3C_I3, value);
394394

395+
/*
396+
* The value written to the D0I3C::I3 bit may not be taken into account immediately.
397+
* A delay is recommended before checking if D0I3C::CIP is cleared
398+
*/
399+
usleep_range(30, 40);
400+
395401
/* Wait for cmd in progress to be cleared before exiting the function */
396402
ret = hda_dsp_wait_d0i3c_done(sdev);
397403
if (ret < 0) {
@@ -400,6 +406,12 @@ static int hda_dsp_update_d0i3c_register(struct snd_sof_dev *sdev, u8 value)
400406
}
401407

402408
reg = snd_sof_dsp_read8(sdev, HDA_DSP_HDA_BAR, chip->d0i3_offset);
409+
/* Confirm d0i3 state changed with paranoia check */
410+
if ((reg ^ value) & SOF_HDA_VS_D0I3C_I3) {
411+
dev_err(sdev->dev, "failed to update D0I3C!\n");
412+
return -EIO;
413+
}
414+
403415
trace_sof_intel_D0I3C_updated(sdev, reg);
404416

405417
return 0;

0 commit comments

Comments
 (0)