Skip to content

Commit d4f71b9

Browse files
committed
SoC: 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 d4f71b9

File tree

4 files changed

+89
-11
lines changed

4 files changed

+89
-11
lines changed

sound/soc/sof/intel/byt.c

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,26 @@ static int byt_reset(struct snd_sof_dev *sdev)
382382
return 0;
383383
}
384384

385+
static int byt_suspend(struct snd_sof_dev *sdev)
386+
{
387+
/* put DSP into reset, set reset vector and stall */
388+
snd_sof_dsp_update_bits64(sdev, BYT_DSP_BAR, SHIM_CSR,
389+
SHIM_BYT_CSR_RST | SHIM_BYT_CSR_VECTOR_SEL |
390+
SHIM_BYT_CSR_STALL,
391+
SHIM_BYT_CSR_RST | SHIM_BYT_CSR_VECTOR_SEL |
392+
SHIM_BYT_CSR_STALL);
393+
394+
return 0;
395+
}
396+
397+
static int byt_resume(struct snd_sof_dev *sdev)
398+
{
399+
/* enable Interrupt from both sides */
400+
snd_sof_dsp_update_bits64(sdev, BYT_DSP_BAR, SHIM_IMRX, 0x3, 0x0);
401+
snd_sof_dsp_update_bits64(sdev, BYT_DSP_BAR, SHIM_IMRD, 0x3, 0x0);
402+
return 0;
403+
}
404+
385405
/* Baytrail DAIs */
386406
static struct snd_soc_dai_driver byt_dai[] = {
387407
{
@@ -529,6 +549,10 @@ const struct snd_sof_dsp_ops sof_tng_ops = {
529549
/*Firmware loading */
530550
.load_firmware = snd_sof_load_firmware_memcpy,
531551

552+
/* PM */
553+
.suspend = byt_suspend,
554+
.resume = byt_resume,
555+
532556
/* DAI drivers */
533557
.drv = byt_dai,
534558
.num_drv = 3, /* we have only 3 SSPs on byt*/
@@ -690,6 +714,10 @@ const struct snd_sof_dsp_ops sof_byt_ops = {
690714
/*Firmware loading */
691715
.load_firmware = snd_sof_load_firmware_memcpy,
692716

717+
/* PM */
718+
.suspend = byt_suspend,
719+
.resume = byt_resume,
720+
693721
/* DAI drivers */
694722
.drv = byt_dai,
695723
.num_drv = 3, /* we have only 3 SSPs on byt*/
@@ -749,6 +777,10 @@ const struct snd_sof_dsp_ops sof_cht_ops = {
749777
/*Firmware loading */
750778
.load_firmware = snd_sof_load_firmware_memcpy,
751779

780+
/* PM */
781+
.suspend = byt_suspend,
782+
.resume = byt_resume,
783+
752784
/* DAI drivers */
753785
.drv = byt_dai,
754786
/* all 6 SSPs may be available for cherrytrail */

sound/soc/sof/pcm.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -732,14 +732,6 @@ static int sof_pcm_probe(struct snd_soc_component *component)
732732
return ret;
733733
}
734734

735-
/*
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.
739-
*/
740-
if (!sof_ops(sdev)->runtime_suspend || !sof_ops(sdev)->runtime_resume)
741-
pm_runtime_get_noresume(sdev->dev);
742-
743735
return ret;
744736
}
745737

sound/soc/sof/pm.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,10 @@ static int sof_resume(struct device *dev, bool runtime_resume)
266266
int ret;
267267

268268
/* do nothing if dsp resume callbacks are not set */
269-
if (!sof_ops(sdev)->resume || !sof_ops(sdev)->runtime_resume)
269+
if (runtime_resume && !sof_ops(sdev)->runtime_resume)
270+
return 0;
271+
272+
if (!runtime_resume && !sof_ops(sdev)->resume)
270273
return 0;
271274

272275
/*
@@ -337,8 +340,11 @@ static int sof_suspend(struct device *dev, bool runtime_suspend)
337340
struct snd_sof_dev *sdev = dev_get_drvdata(dev);
338341
int ret;
339342

340-
/* do nothing if dsp suspend callback is not set */
341-
if (!sof_ops(sdev)->suspend)
343+
/* do nothing if dsp suspend callbacks are not set */
344+
if (!runtime_suspend && !sof_ops(sdev)->suspend)
345+
return 0;
346+
347+
if (runtime_suspend && !sof_ops(sdev)->runtime_suspend)
342348
return 0;
343349

344350
/* release trace */

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

Lines changed: 48 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,39 @@ static const struct sof_dev_desc sof_acpi_cherrytrail_desc = {
117118
.arch_ops = &sof_xtensa_arch_ops
118119
};
119120

121+
static int minnowboard_quirk_cb(const struct dmi_system_id *id)
122+
{
123+
struct device *dev = id->driver_data;
124+
125+
/*
126+
* Increment the usage count so as to prevent the device
127+
* from entering runtime suspend.
128+
*/
129+
pm_runtime_get_noresume(dev);
130+
131+
return 1;
132+
}
133+
134+
static struct dmi_system_id minnowbard_quirk_table[] = {
135+
{
136+
/* Minnowboard Max B3 */
137+
.callback = minnowboard_quirk_cb,
138+
.matches = {
139+
DMI_MATCH(DMI_SYS_VENDOR, "Circuitco"),
140+
DMI_MATCH(DMI_PRODUCT_NAME,
141+
"Minnowboard Max B3 PLATFORM"),
142+
},
143+
},
144+
{
145+
/* Minnowboard Turbot */
146+
.callback = minnowboard_quirk_cb,
147+
.matches = {
148+
DMI_MATCH(DMI_SYS_VENDOR, "ADI"),
149+
DMI_MATCH(DMI_PRODUCT_NAME, "Minnowboard Turbot"),
150+
},
151+
},
152+
};
153+
120154
#endif
121155

122156
static const struct dev_pm_ops sof_acpi_pm = {
@@ -127,13 +161,27 @@ static const struct dev_pm_ops sof_acpi_pm = {
127161

128162
static void sof_acpi_probe_complete(struct device *dev)
129163
{
164+
int i;
165+
130166
if (sof_acpi_debug & SOF_ACPI_DISABLE_PM_RUNTIME)
131167
return;
132168

133169
/* allow runtime_pm */
134170
pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY_MS);
135171
pm_runtime_use_autosuspend(dev);
172+
pm_runtime_set_active(dev);
136173
pm_runtime_enable(dev);
174+
pm_runtime_mark_last_busy(dev);
175+
176+
#if IS_ENABLED(CONFIG_SND_SOC_SOF_BAYTRAIL)
177+
/* set driver data in the quirk table */
178+
for (i = 0; i < ARRAY_SIZE(minnowbard_quirk_table); i++)
179+
minnowbard_quirk_table[i].driver_data = dev;
180+
181+
/* check for Minnowboards */
182+
dmi_check_system(minnowbard_quirk_table);
183+
#endif
184+
pm_runtime_put_autosuspend(dev);
137185
}
138186

139187
static int sof_acpi_probe(struct platform_device *pdev)

0 commit comments

Comments
 (0)