Skip to content

Commit

Permalink
ASoC: SOF: Intel: hda-dsp: harden D0i3 programming sequence
Browse files Browse the repository at this point in the history
[ Upstream commit 52a5577 ]

Add delay between set and wait command according to hardware programming
sequence. Also add debug log to detect error.

Signed-off-by: Rander Wang <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Pierre-Louis Bossart <[email protected]>
Reviewed-by: Péter Ujfalusi <[email protected]>
Reviewed-by: Ranjani Sridharan <[email protected]>
Signed-off-by: Peter Ujfalusi <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Mark Brown <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
RanderWang authored and sirlucjan committed Apr 5, 2023
1 parent 3e78630 commit 7041ed7
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions sound/soc/sof/intel/hda-dsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,12 @@ static int hda_dsp_update_d0i3c_register(struct snd_sof_dev *sdev, u8 value)
snd_sof_dsp_update8(sdev, HDA_DSP_HDA_BAR, chip->d0i3_offset,
SOF_HDA_VS_D0I3C_I3, value);

/*
* The value written to the D0I3C::I3 bit may not be taken into account immediately.
* A delay is recommended before checking if D0I3C::CIP is cleared
*/
usleep_range(30, 40);

/* Wait for cmd in progress to be cleared before exiting the function */
ret = hda_dsp_wait_d0i3c_done(sdev);
if (ret < 0) {
Expand All @@ -407,6 +413,12 @@ static int hda_dsp_update_d0i3c_register(struct snd_sof_dev *sdev, u8 value)
}

reg = snd_sof_dsp_read8(sdev, HDA_DSP_HDA_BAR, chip->d0i3_offset);
/* Confirm d0i3 state changed with paranoia check */
if ((reg ^ value) & SOF_HDA_VS_D0I3C_I3) {
dev_err(sdev->dev, "failed to update D0I3C!\n");
return -EIO;
}

trace_sof_intel_D0I3C_updated(sdev, reg);

return 0;
Expand Down

0 comments on commit 7041ed7

Please sign in to comment.