Skip to content

Commit f6b7cc3

Browse files
committed
ASoC: SOF: acpi: enable PM for ACPI platforms
This patch adds the platform-specific PM callbacks for the BYT/CHT ACPI platforms. Since the Minnowboards do not support PM, the SOF device is prevented from entering runtime suspend by incrementing the ref count after the topology is loaded. Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
1 parent 0f665a4 commit f6b7cc3

File tree

5 files changed

+92
-4
lines changed

5 files changed

+92
-4
lines changed

sound/soc/sof/core.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#include "sof-priv.h"
1717
#include "ops.h"
1818

19+
bool no_PM_support;
20+
EXPORT_SYMBOL(no_PM_support);
21+
1922
/* see SOF_DBG_ flags */
2023
int sof_core_debug;
2124
module_param_named(sof_debug, sof_core_debug, int, 0444);

sound/soc/sof/intel/byt.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,34 @@ static int tangier_pci_probe(struct snd_sof_dev *sdev)
483483
return ret;
484484
}
485485

486+
static int byt_suspend(struct snd_sof_dev *sdev)
487+
{
488+
/* put DSP into reset, set reset vector and stall */
489+
snd_sof_dsp_update_bits64(sdev, BYT_DSP_BAR, SHIM_CSR,
490+
SHIM_BYT_CSR_RST | SHIM_BYT_CSR_VECTOR_SEL |
491+
SHIM_BYT_CSR_STALL,
492+
SHIM_BYT_CSR_RST | SHIM_BYT_CSR_VECTOR_SEL |
493+
SHIM_BYT_CSR_STALL);
494+
}
495+
496+
static int byt_resume(struct snd_sof_dev *sdev)
497+
{
498+
/* enable Interrupt from both sides */
499+
snd_sof_dsp_update_bits64(sdev, BYT_DSP_BAR, SHIM_IMRX, 0x3, 0x0);
500+
snd_sof_dsp_update_bits64(sdev, BYT_DSP_BAR, SHIM_IMRD, 0x3, 0x0);
501+
}
502+
503+
/* Dummy runtime PM ops. Without these top-level PM callbacks will break */
504+
static int byt_runtime_suspend(struct snd_sof_dev *sdev)
505+
{
506+
return 0;
507+
}
508+
509+
static int byt_runtime_resume(struct snd_sof_dev *sdev)
510+
{
511+
return 0;
512+
}
513+
486514
const struct snd_sof_dsp_ops sof_tng_ops = {
487515
/* device init */
488516
.probe = tangier_pci_probe,
@@ -529,6 +557,12 @@ const struct snd_sof_dsp_ops sof_tng_ops = {
529557
/*Firmware loading */
530558
.load_firmware = snd_sof_load_firmware_memcpy,
531559

560+
/* PM */
561+
.suspend = byt_suspend,
562+
.resume = byt_resume,
563+
.runtime_suspend = byt_runtime_suspend,
564+
.runtime_resume = byt_runtime_resume,
565+
532566
/* DAI drivers */
533567
.drv = byt_dai,
534568
.num_drv = 3, /* we have only 3 SSPs on byt*/
@@ -690,6 +724,12 @@ const struct snd_sof_dsp_ops sof_byt_ops = {
690724
/*Firmware loading */
691725
.load_firmware = snd_sof_load_firmware_memcpy,
692726

727+
/* PM */
728+
.suspend = byt_suspend,
729+
.resume = byt_resume,
730+
.runtime_suspend = byt_runtime_suspend,
731+
.runtime_resume = byt_runtime_resume,
732+
693733
/* DAI drivers */
694734
.drv = byt_dai,
695735
.num_drv = 3, /* we have only 3 SSPs on byt*/
@@ -749,6 +789,12 @@ const struct snd_sof_dsp_ops sof_cht_ops = {
749789
/*Firmware loading */
750790
.load_firmware = snd_sof_load_firmware_memcpy,
751791

792+
/* PM */
793+
.suspend = byt_suspend,
794+
.resume = byt_resume,
795+
.runtime_suspend = byt_runtime_suspend,
796+
.runtime_resume = byt_runtime_resume,
797+
752798
/* DAI drivers */
753799
.drv = byt_dai,
754800
/* all 6 SSPs may be available for cherrytrail */

sound/soc/sof/pcm.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -733,11 +733,11 @@ static int sof_pcm_probe(struct snd_soc_component *component)
733733
}
734734

735735
/*
736-
* Some platforms in SOF, ex: BYT, may not have their platform PM
737-
* callbacks set. Increment the usage count so as to
738-
* prevent the device from entering runtime suspend.
736+
* Some boards such as the Minnowboard do not support PM.
737+
* Increment the usage count so as to prevent the device
738+
* from entering runtime suspend.
739739
*/
740-
if (!sof_ops(sdev)->runtime_suspend || !sof_ops(sdev)->runtime_resume)
740+
if (no_PM_support)
741741
pm_runtime_get_noresume(sdev->dev);
742742

743743
return ret;

sound/soc/sof/sof-acpi-dev.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <linux/firmware.h>
1313
#include <linux/module.h>
1414
#include <linux/pm_runtime.h>
15+
#include <linux/dmi.h>
1516
#include <sound/soc-acpi.h>
1617
#include <sound/soc-acpi-intel-match.h>
1718
#include <sound/sof.h>
@@ -117,6 +118,33 @@ static const struct sof_dev_desc sof_acpi_cherrytrail_desc = {
117118
.arch_ops = &sof_xtensa_arch_ops
118119
};
119120

121+
static int byt_rt5651_quirk_cb(const struct dmi_system_id *id)
122+
{
123+
/* S3 is not supported for Minnowboards */
124+
no_PM_support = true;
125+
return 1;
126+
}
127+
128+
static const struct dmi_system_id byt_rt5651_quirk_table[] = {
129+
{
130+
/* Minnowboard Max B3 */
131+
.callback = byt_rt5651_quirk_cb,
132+
.matches = {
133+
DMI_MATCH(DMI_SYS_VENDOR, "Circuitco"),
134+
DMI_MATCH(DMI_PRODUCT_NAME,
135+
"Minnowboard Max B3 PLATFORM"),
136+
},
137+
},
138+
{
139+
/* Minnowboard Turbot */
140+
.callback = byt_rt5651_quirk_cb,
141+
.matches = {
142+
DMI_MATCH(DMI_SYS_VENDOR, "ADI"),
143+
DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Turbot"),
144+
},
145+
},
146+
};
147+
120148
#endif
121149

122150
static const struct dev_pm_ops sof_acpi_pm = {
@@ -133,7 +161,15 @@ static void sof_acpi_probe_complete(struct device *dev)
133161
/* allow runtime_pm */
134162
pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY_MS);
135163
pm_runtime_use_autosuspend(dev);
164+
pm_runtime_set_active(dev);
136165
pm_runtime_enable(dev);
166+
pm_runtime_mark_last_busy(dev);
167+
168+
#if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
169+
/* check for Minnowboards and mark no PM support */
170+
dmi_check_system(byt_rt5651_quirk_table);
171+
#endif
172+
137173
}
138174

139175
static int sof_acpi_probe(struct platform_device *pdev)

sound/soc/sof/sof-priv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
/* global debug state set by SOF_DBG_ flags */
4040
extern int sof_core_debug;
4141

42+
/* global flag to indicate if PM is supported */
43+
extern bool no_PM_support;
44+
4245
/* max BARs mmaped devices can use */
4346
#define SND_SOF_BARS 8
4447

0 commit comments

Comments
 (0)