ASoC: SOF: imx8m: Add runtime PM / System PM support
authorDaniel Baluta <daniel.baluta@nxp.com>
Fri, 19 Nov 2021 09:43:17 +0000 (11:43 +0200)
committerMark Brown <broonie@kernel.org>
Mon, 22 Nov 2021 15:40:10 +0000 (15:40 +0000)
commita73b493d8e1b37acad686c15321d2eaab45567ce
tree5a261de364fcb7bf2eae2f84bd7925017bf05787
parent6fc8515806dfd5b7d3198c189b51e7624aadafdc
ASoC: SOF: imx8m: Add runtime PM / System PM support

We make use of common imx8m_suspend / imx8m_resume functions
for both system PM and runtime PM.

imx8m_suspend:
- frees the MU channels
- disables the clocks

imx8m_resume
- enables the clocks
- requests the MU channels

On i.MX8MP there is no dedicated functionality to put the DSP in reset.
The only way of doing this is to POWER DOWN the Audiomix domain.

We are able to do this because turning off the clocks and freeing the
channels makes the Audiomix to have no users thus PM kernel core turns
it down.

SOF core will not call system PM suspend handler if the DSP is already
down, but at resume it will call the system PM resume. So, we need to
keep track of the state via snd_sof_dsp_set_power_state

Few insights on how SOF core handles the PM:
 - SOF core uses PM runtime autosuspend (with a timeout of 2 secs)
 - at probe, SOF core boots the DSP and lets the PM runtime suspend to
   turn it off, if there is no activity
 - when someone opens the ALSA sound card (aplay/arecord, etc) ALSA core
   calls PM runtime resume to turn on the DSP
 - when the ALSA sound card is closed SOF core make use of PM subsystem
  to call PM runtime suspend and thus turning off the DSP.

Signed-off-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Link: https://lore.kernel.org/r/20211119094319.81674-4-daniel.baluta@oss.nxp.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/sof/imx/imx8m.c