Skip to contentSkip to conversation

ASoC: Intel: BSW driver updates

PATCH Superseded Vinod Koul 2 participants 17 messages Feb 12, 2015 – Feb 24, 2015

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Vinod Koul

author
#0 lore raw

cover ASoC: Intel: BSW driver updates

This patch series first adds nonatomic pcm ops support in ASoC (it is already availble in ALSA). Then adds driver support.
Later it adds puase/resume and suspend/resume support to the intel driver

Subhransu S. Prusty (3):
ASoC: Intel: Add memcpy32_fromio as well
ASoC: Intel: Remove ignore suspend support
ASoC: Intel: Remove soc pm handling to allow platform driver handle
it

Vinod Koul (10):
ASoC: core: allow pcms to be registered as nonatomic
ASoC: Intel: mark cht machine driver with nonatomic trigger
ASoC: Intel: update MMX ID to 3
ASoC: Intel: add support for pause and resume in sst
ASoC: Intel: add support for pcm stream suspend/resume
ASoC: Intel: add support for platform suspend
ASoC: Intel: save and restore the CSR register
ASoC: Intel: reset the DSP while suspending
ASoC: Intel: add pm support in sst ipc driver
ASoC: Intel: Move the fw download to power_control

 include/sound/soc.h                     |    3 +
 sound/soc/intel/cht_bsw_rt5672.c        |    5 +-
 sound/soc/intel/sst-atom-controls.h     |    2 +-
 sound/soc/intel/sst-mfld-platform-pcm.c |   60 ++++++++++++++
 sound/soc/intel/sst-mfld-platform.h     |    1 +
 sound/soc/intel/sst/sst.c               |  134 ++++++++++++++++++++++++++++---
 sound/soc/intel/sst/sst.h               |   12 +++
 sound/soc/intel/sst/sst_drv_interface.c |   58 ++++++++++++-
 sound/soc/intel/sst/sst_loader.c        |   10 ++-
 sound/soc/soc-pcm.c                     |    1 +
 10 files changed, 268 insertions(+), 18 deletions(-)
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 1/13 ASoC: core: allow pcms to be registered as nonatomic

ALSA core with commit 257f8cce5d40 - "ALSA: pcm: Allow nonatomic trigger operations" allows trigger ops to implemented as nonatomic. For ASoC, we can specify this in dailinks and is updated while snd_pcm is created

---
 include/sound/soc.h |    3 +++
 sound/soc/soc-pcm.c |    1 +
 2 files changed, 4 insertions(+)
include/sound/soc.h +3 -0
index b4fca9aed2a2..3ccab0b7349f 100644
@@ -950,6 +950,9 @@ struct snd_soc_dai_link {
 	unsigned int symmetric_channels:1;
 	unsigned int symmetric_samplebits:1;
 
+	/* Mark this pcm with non atomic ops */
+	bool nonatomic;
+
 	/* Do not create a PCM for this DAI link (Backend link) */
 	unsigned int no_pcm:1;
 
sound/soc/soc-pcm.c +1 -0
index eb87d96e2cf0..cef2ff5188d1 100644
@@ -2526,6 +2526,7 @@ int soc_new_pcm(struct snd_soc_pcm_runtime *rtd, int num)
 	/* DAPM dai link stream work */
 	INIT_DELAYED_WORK(&rtd->delayed_work, close_delayed_work);
 
+	pcm->nonatomic = rtd->dai_link->nonatomic;
 	rtd->pcm = pcm;
 	pcm->private_data = rtd;
 
Signature · 1 line
1.7.9.5
author
#2 lore raw

PATCH 2/13 ASoC: Intel: mark cht machine driver with nonatomic trigger

In reply to Vinod Koul

The DSP messages are sent with nonatomic context, which include trigger messages, so mark the driver as nonatomic

---
 sound/soc/intel/cht_bsw_rt5672.c |    2 ++
 1 file changed, 2 insertions(+)
sound/soc/intel/cht_bsw_rt5672.c +2 -0
index ff016621583a..152e7703dd8a 100644
@@ -218,6 +218,7 @@ static struct snd_soc_dai_link cht_dailink[] = {
 		.codec_name = "snd-soc-dummy",
 		.platform_name = "sst-mfld-platform",
 		.ignore_suspend = 1,
+		.nonatomic = true,
 		.dynamic = 1,
 		.dpcm_playback = 1,
 		.dpcm_capture = 1,
@@ -240,6 +241,7 @@ static struct snd_soc_dai_link cht_dailink[] = {
 		.cpu_dai_name = "ssp2-port",
 		.platform_name = "sst-mfld-platform",
 		.no_pcm = 1,
+		.nonatomic = true,
 		.codec_dai_name = "rt5670-aif1",
 		.codec_name = "i2c-10EC5670:00",
 		.dai_fmt = SND_SOC_DAIFMT_DSP_B | SND_SOC_DAIFMT_IB_NF
Signature · 1 line
1.7.9.5
author
#3 lore raw

PATCH 3/13 ASoC: Intel: update MMX ID to 3

In reply to Vinod Koul

The updated firmware expects the MMX ID to be used as 3, so update the driver as well

---
 sound/soc/intel/sst-atom-controls.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/intel/sst-atom-controls.h +1 -1
index dfebfdd5eb2a..daecc58f28af 100644
@@ -150,7 +150,7 @@ enum sst_cmd_type {
 
 enum sst_task {
 	SST_TASK_SBA = 1,
-	SST_TASK_MMX,
+	SST_TASK_MMX = 3,
 };
 
 enum sst_type {
Signature · 1 line
1.7.9.5
author
#4 lore raw

PATCH 4/13 ASoC: Intel: add support for pause and resume in sst

In reply to Vinod Koul

This adds missing pcm pause and resume ops in the driver

---
 sound/soc/intel/sst/sst_drv_interface.c |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
sound/soc/intel/sst/sst_drv_interface.c +31 -0
index 5f75ef3cdd22..5d56fcdd58d8 100644
@@ -572,6 +572,35 @@ static int sst_stream_drop(struct device *dev, int str_id)
 	return sst_drop_stream(ctx, str_id);
 }
 
+static int sst_stream_pause(struct device *dev, int str_id)
+{
+	struct stream_info *str_info;
+	struct intel_sst_drv *ctx = dev_get_drvdata(dev);
+
+	if (ctx->sst_state != SST_FW_RUNNING)
+		return 0;
+
+	str_info = get_stream_info(ctx, str_id);
+	if (!str_info)
+		return -EINVAL;
+
+	return sst_pause_stream(ctx, str_id);
+}
+
+static int sst_stream_resume(struct device *dev, int str_id)
+{
+	struct stream_info *str_info;
+	struct intel_sst_drv *ctx = dev_get_drvdata(dev);
+
+	if (ctx->sst_state != SST_FW_RUNNING)
+		return 0;
+
+	str_info = get_stream_info(ctx, str_id);
+	if (!str_info)
+		return -EINVAL;
+	return sst_resume_stream(ctx, str_id);
+}
+
 static int sst_stream_init(struct device *dev, struct pcm_stream_info *str_info)
 {
 	int str_id = 0;
@@ -633,6 +662,8 @@ static struct sst_ops pcm_ops = {
 	.stream_init = sst_stream_init,
 	.stream_start = sst_stream_start,
 	.stream_drop = sst_stream_drop,
+	.stream_pause = sst_stream_pause,
+	.stream_pause_release = sst_stream_resume,
 	.stream_read_tstamp = sst_read_timestamp,
 	.send_byte_stream = sst_send_byte_stream,
 	.close = sst_close_pcm_stream,
Signature · 1 line
1.7.9.5
author
#5 lore raw

PATCH 5/13 ASoC: Intel: add support for pcm stream suspend/resume

In reply to Vinod Koul

The driver didn't implement support for pcm stream suspend and resume, so add it

---
 sound/soc/intel/sst-mfld-platform-pcm.c |    2 ++
 1 file changed, 2 insertions(+)
sound/soc/intel/sst-mfld-platform-pcm.c +2 -0
index 7523cbef8780..ea0fa4b90bb0 100644
@@ -594,11 +594,13 @@ static int sst_platform_pcm_trigger(struct snd_pcm_substream *substream,
 		ret_val = stream->ops->stream_drop(sst->dev, str_id);
 		break;
 	case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
+	case SNDRV_PCM_TRIGGER_SUSPEND:
 		dev_dbg(rtd->dev, "sst: in pause\n");
 		status = SST_PLATFORM_PAUSED;
 		ret_val = stream->ops->stream_pause(sst->dev, str_id);
 		break;
 	case SNDRV_PCM_TRIGGER_PAUSE_RELEASE:
+	case SNDRV_PCM_TRIGGER_RESUME:
 		dev_dbg(rtd->dev, "sst: in pause release\n");
 		status = SST_PLATFORM_RUNNING;
 		ret_val = stream->ops->stream_pause_release(sst->dev, str_id);
Signature · 1 line
1.7.9.5
author
#6 lore raw

PATCH 6/13 ASoC: Intel: add support for platform suspend

In reply to Vinod Koul

This adds support for platform suspend and resume. We ensure all pcms are suspended by invoking snd_soc_suspend() and then stop the DSP

---
 sound/soc/intel/sst-mfld-platform-pcm.c |   58 +++++++++++++++++++++++++++++++
 sound/soc/intel/sst-mfld-platform.h     |    1 +
 2 files changed, 59 insertions(+)
sound/soc/intel/sst-mfld-platform-pcm.c +58 -0
index ea0fa4b90bb0..2fbaf2c75d17 100644
@@ -667,6 +667,9 @@ static int sst_pcm_new(struct snd_soc_pcm_runtime *rtd)
 
 static int sst_soc_probe(struct snd_soc_platform *platform)
 {
+	struct sst_data *drv = dev_get_drvdata(platform->dev);
+
+	drv->soc_card = platform->component.card;
 	return sst_dsp_init_v2_dpcm(platform);
 }
 
@@ -729,9 +732,64 @@ static int sst_platform_remove(struct platform_device *pdev)
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+
+static int sst_soc_prepare(struct device *dev)
+{
+	struct sst_data *drv = dev_get_drvdata(dev);
+	int i;
+
+	/* suspend all pcms first */
+	snd_soc_suspend(drv->soc_card->dev);
+	snd_soc_poweroff(drv->soc_card->dev);
+
+	/* set the SSPs to idle */
+	for (i = 0; i < drv->soc_card->num_rtd; i++) {
+		struct snd_soc_dai *dai = drv->soc_card->rtd[i].cpu_dai;
+
+		if (dai->active) {
+			send_ssp_cmd(dai, dai->name, 0);
+			sst_handle_vb_timer(dai, false);
+		}
+	}
+
+	return 0;
+}
+
+static void sst_soc_complete(struct device *dev)
+{
+	struct sst_data *drv = dev_get_drvdata(dev);
+	int i;
+
+	/* restart SSPs */
+	for (i = 0; i < drv->soc_card->num_rtd; i++) {
+		struct snd_soc_dai *dai = drv->soc_card->rtd[i].cpu_dai;
+
+		if (dai->active) {
+			sst_handle_vb_timer(dai, true);
+			send_ssp_cmd(dai, dai->name, 1);
+		}
+	}
+	snd_soc_resume(drv->soc_card->dev);
+}
+
+#else
+
+#define sst_soc_prepare NULL
+#define sst_soc_complete NULL
+
+#endif
+
+
+static const struct dev_pm_ops sst_platform_pm = {
+	.prepare	= sst_soc_prepare,
+	.complete	= sst_soc_complete,
+};
+
 static struct platform_driver sst_platform_driver = {
 	.driver		= {
 		.name		= "sst-mfld-platform",
+		.pm             = &sst_platform_pm,
 	},
 	.probe		= sst_platform_probe,
 	.remove		= sst_platform_remove,
sound/soc/intel/sst-mfld-platform.h +1 -0
index 79c8d1246a8f..9094314be2b0 100644
@@ -174,6 +174,7 @@ struct sst_data {
 	struct sst_platform_data *pdata;
 	struct snd_sst_bytes_v2 *byte_stream;
 	struct mutex lock;
+	struct snd_soc_card *soc_card;
 };
 int sst_register_dsp(struct sst_device *sst);
 int sst_unregister_dsp(struct sst_device *sst);
Signature · 1 line
1.7.9.5
author
#7 lore raw

PATCH 7/13 ASoC: Intel: save and restore the CSR register

In reply to Vinod Koul

The IPC driver saved only IMR register, we need to save the CSR as well, so add it

---
 sound/soc/intel/sst/sst.c |    5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/intel/sst/sst.c +4 -1
index 8a8d56a146e7..0fb1b0ea164c 100644
@@ -350,7 +350,9 @@ static inline void sst_save_shim64(struct intel_sst_drv *ctx,
 
 	spin_lock_irqsave(&ctx->ipc_spin_lock, irq_flags);
 
-	shim_regs->imrx = sst_shim_read64(shim, SST_IMRX),
+	shim_regs->imrx = sst_shim_read64(shim, SST_IMRX);
+	shim_regs->csr = sst_shim_read64(shim, SST_CSR);
+
 
 	spin_unlock_irqrestore(&ctx->ipc_spin_lock, irq_flags);
 }
@@ -367,6 +369,7 @@ static inline void sst_restore_shim64(struct intel_sst_drv *ctx,
 	 */
 	spin_lock_irqsave(&ctx->ipc_spin_lock, irq_flags);
 	sst_shim_write64(shim, SST_IMRX, shim_regs->imrx),
+	sst_shim_write64(shim, SST_CSR, shim_regs->csr),
 	spin_unlock_irqrestore(&ctx->ipc_spin_lock, irq_flags);
 }
 
Signature · 1 line
1.7.9.5
author
#8 lore raw

PATCH 8/13 ASoC: Intel: reset the DSP while suspending

In reply to Vinod Koul

The manual recommends that we reset the DSP when we suspend so add that in runtime suspend handler

---
 sound/soc/intel/sst/sst.c |    1 +
 1 file changed, 1 insertion(+)
sound/soc/intel/sst/sst.c +1 -0
index 0fb1b0ea164c..ea85789641f2 100644
@@ -412,6 +412,7 @@ static int intel_sst_runtime_suspend(struct device *dev)
 	synchronize_irq(ctx->irq_num);
 	flush_workqueue(ctx->post_msg_wq);
 
+	ctx->ops->reset(ctx);
 	/* save the shim registers because PMC doesn't save state */
 	sst_save_shim64(ctx, ctx->shim, ctx->shim_regs64);
 
Signature · 1 line
1.7.9.5
author
#9 lore raw

PATCH 9/13 ASoC: Intel: Add memcpy32_fromio as well

In reply to Vinod Koul

From: "Subhransu S. Prusty" <[email protected]>

Export 32-bit version of memcpy for use in suspend/resume.

---
 sound/soc/intel/sst/sst.h        |    3 +++
 sound/soc/intel/sst/sst_loader.c |   10 +++++++++-
 2 files changed, 12 insertions(+), 1 deletion(-)
sound/soc/intel/sst/sst.h +3 -0
index 7f4bbfcbc6f5..9fea01401e65 100644
@@ -543,4 +543,7 @@ int sst_alloc_drv_context(struct intel_sst_drv **ctx,
 int sst_context_init(struct intel_sst_drv *ctx);
 void sst_context_cleanup(struct intel_sst_drv *ctx);
 void sst_configure_runtime_pm(struct intel_sst_drv *ctx);
+void memcpy32_toio(void __iomem *dst, const void *src, int count);
+void memcpy32_fromio(void *dst, const void __iomem *src, int count);
+
 #endif
sound/soc/intel/sst/sst_loader.c +9 -1
index 7888cd707853..e88907ae8b15 100644
@@ -39,7 +39,15 @@
 #include "sst.h"
 #include "../sst-dsp.h"
 
-static inline void memcpy32_toio(void __iomem *dst, const void *src, int count)
+void memcpy32_toio(void __iomem *dst, const void *src, int count)
+{
+	/* __iowrite32_copy uses 32-bit count values so divide by 4 for
+	 * right count in words
+	 */
+	__iowrite32_copy(dst, src, count/4);
+}
+
+void memcpy32_fromio(void *dst, const void __iomem *src, int count)
 {
 	/* __iowrite32_copy uses 32-bit count values so divide by 4 for
 	 * right count in words
Signature · 1 line
1.7.9.5
author
#10 lore raw

PATCH 10/13 ASoC: Intel: add pm support in sst ipc driver

In reply to Vinod Koul

This adds support for system pm support. We need to save the dsp memory which gets lost on suspend and restore that on resume

---
 sound/soc/intel/sst/sst.c |  128 +++++++++++++++++++++++++++++++++++++++++++++
 sound/soc/intel/sst/sst.h |    9 ++++
 2 files changed, 137 insertions(+)
sound/soc/intel/sst/sst.c +128 -0
index ea85789641f2..6f39f4d4e326 100644
@@ -419,6 +419,83 @@ static int intel_sst_runtime_suspend(struct device *dev)
 	return ret;
 }
 
+static int intel_sst_suspend(struct device *dev)
+{
+	struct intel_sst_drv *ctx = dev_get_drvdata(dev);
+	struct sst_fw_save *fw_save;
+	int i, ret = 0;
+
+	/* check first if we are already in SW reset */
+	if (ctx->sst_state == SST_RESET)
+		return 0;
+
+	/*
+	 * check if any stream is active and running
+	 * they should already by suspend by soc_suspend
+	 */
+	for (i = 1; i <= ctx->info.max_streams; i++) {
+		struct stream_info *stream = &ctx->streams[i];
+
+		if (stream->status == STREAM_RUNNING) {
+			dev_err(dev, "stream %d is running, cant susupend, abort\n", i);
+			return -EBUSY;
+		}
+	}
+	synchronize_irq(ctx->irq_num);
+	flush_workqueue(ctx->post_msg_wq);
+
+	/* Move the SST state to Reset */
+	sst_set_fw_state_locked(ctx, SST_RESET);
+
+	/* tell DSP we are suspending */
+	if (ctx->ops->save_dsp_context(ctx))
+		return -EBUSY;
+
+	/* save the memories */
+	fw_save = kzalloc(sizeof(*fw_save), GFP_KERNEL);
+	if (!fw_save)
+		return -ENOMEM;
+	fw_save->iram = kzalloc(ctx->iram_end - ctx->iram_base, GFP_KERNEL);
+	if (!fw_save->iram) {
+		ret = -ENOMEM;
+		goto iram;
+	}
+	fw_save->dram = kzalloc(ctx->dram_end - ctx->dram_base, GFP_KERNEL);
+	if (!fw_save->dram) {
+		ret = -ENOMEM;
+		goto dram;
+	}
+	fw_save->sram = kzalloc(SST_MAILBOX_SIZE, GFP_KERNEL);
+	if (!fw_save->sram) {
+		ret = -ENOMEM;
+		goto sram;
+	}
+
+	fw_save->ddr = kzalloc(ctx->ddr_end - ctx->ddr_base, GFP_KERNEL);
+	if (!fw_save->ddr) {
+		ret = -ENOMEM;
+		goto ddr;
+	}
+
+	memcpy32_fromio(fw_save->iram, ctx->iram, ctx->iram_end - ctx->iram_base);
+	memcpy32_fromio(fw_save->dram, ctx->dram, ctx->dram_end - ctx->dram_base);
+	memcpy32_fromio(fw_save->sram, ctx->mailbox, SST_MAILBOX_SIZE);
+	memcpy32_fromio(fw_save->ddr, ctx->ddr, ctx->ddr_end - ctx->ddr_base);
+
+	ctx->fw_save = fw_save;
+	ctx->ops->reset(ctx);
+	return 0;
+ddr:
+	kfree(fw_save->sram);
+sram:
+	kfree(fw_save->dram);
+dram:
+	kfree(fw_save->iram);
+iram:
+	kfree(fw_save);
+	return ret;
+}
+
 static int intel_sst_runtime_resume(struct device *dev)
 {
 	int ret = 0;
@@ -434,7 +511,58 @@ static int intel_sst_runtime_resume(struct device *dev)
 	return ret;
 }
 
+static int intel_sst_resume(struct device *dev)
+{
+	struct intel_sst_drv *ctx = dev_get_drvdata(dev);
+	struct sst_fw_save *fw_save = ctx->fw_save;
+	int ret = 0;
+	struct sst_block *block;
+
+	if (!fw_save)
+		return intel_sst_runtime_resume(dev);
+
+	sst_set_fw_state_locked(ctx, SST_FW_LOADING);
+
+	/* we have to restore the memory saved */
+	ctx->ops->reset(ctx);
+
+	ctx->fw_save = NULL;
+
+	memcpy32_toio(ctx->iram, fw_save->iram, ctx->iram_end - ctx->iram_base);
+	memcpy32_toio(ctx->dram, fw_save->dram, ctx->dram_end - ctx->dram_base);
+	memcpy32_toio(ctx->mailbox, fw_save->sram, SST_MAILBOX_SIZE);
+	memcpy32_toio(ctx->ddr, fw_save->ddr, ctx->ddr_end - ctx->ddr_base);
+
+	kfree(fw_save->sram);
+	kfree(fw_save->dram);
+	kfree(fw_save->iram);
+	kfree(fw_save->ddr);
+	kfree(fw_save);
+
+	block = sst_create_block(ctx, 0, FW_DWNL_ID);
+	if (block == NULL)
+		return -ENOMEM;
+
+
+	/* start and wait for ack */
+	ctx->ops->start(ctx);
+	ret = sst_wait_timeout(ctx, block);
+	if (ret) {
+		dev_err(ctx->dev, "fw download failed %d\n", ret);
+		/* FW download failed due to timeout */
+		ret = -EBUSY;
+
+	} else {
+		sst_set_fw_state_locked(ctx, SST_FW_RUNNING);
+	}
+
+	sst_free_block(ctx, block);
+	return ret;
+}
+
 const struct dev_pm_ops intel_sst_pm = {
+	.suspend = intel_sst_suspend,
+	.resume = intel_sst_resume,
 	.runtime_suspend = intel_sst_runtime_suspend,
 	.runtime_resume = intel_sst_runtime_resume,
 };
sound/soc/intel/sst/sst.h +9 -0
index 9fea01401e65..7b3eac426571 100644
@@ -336,6 +336,13 @@ struct sst_shim_regs64 {
 	u64 csr2;
 };
 
+struct sst_fw_save {
+	void *iram;
+	void *dram;
+	void *sram;
+	void *ddr;
+};
+
 /**
  * struct intel_sst_drv - driver ops
  *
@@ -427,6 +434,8 @@ struct intel_sst_drv {
 	 * persistent till worker thread gets called
 	 */
 	char firmware_name[20];
+
+	struct sst_fw_save	*fw_save;
 };
 
 /* misc definitions */
Signature · 1 line
1.7.9.5
maintainer
#11 lore raw

Re: [PATCH 10/13] ASoC: Intel: add pm support in sst ipc driver

Quoted 2 lines · Vinod Koul

This adds support for system pm support. We need to save the dsp memory which gets lost on suspend and restore that on resume

This doesn't seem to apply against current code, not entirely sure what's going on there, can you take a look please? I've applied everything up to here, thanks!

author
#12 lore raw

Re: [PATCH 10/13] ASoC: Intel: add pm support in sst ipc driver

Quoted 7 lines · Mark Brown
Quoted 2 lines · Vinod Koul

This adds support for system pm support. We need to save the dsp memory which gets lost on suspend and restore that on resume

This doesn't seem to apply against current code, not entirely sure what's going on there, can you take a look please? I've applied everything up to here, thanks!

Sure, I will resend the remaining 4 patches. I am not sure why they are conflicting. Btw where did you apply the 9 patches. I fetched your tree and see 3 in mark/fix/intel and not rest

Thanks

Signature · 1 line
~Vinod
maintainer
#13 lore raw

Re: [PATCH 10/13] ASoC: Intel: add pm support in sst ipc driver

Quoted 3 lines · Vinod Koul

Sure, I will resend the remaining 4 patches. I am not sure why they are conflicting. Btw where did you apply the 9 patches. I fetched your tree and see 3 in mark/fix/intel and not rest

topic/intel. When I say I've applied things I've applied them locally, that doesn't mean they're published (especially not when I'm travelling and internet access can be spotty).

author
#14 lore raw

PATCH 11/13 ASoC: Intel: Move the fw download to power_control

In reply to Vinod Koul

Thus removing the runtime_resume handler.

---
 sound/soc/intel/sst/sst.c               |   18 +-----------------
 sound/soc/intel/sst/sst_drv_interface.c |   27 +++++++++++++++++++++++----
 2 files changed, 24 insertions(+), 21 deletions(-)
sound/soc/intel/sst/sst.c +1 -17
index 6f39f4d4e326..10d9f5a72391 100644
@@ -496,21 +496,6 @@ iram:
 	return ret;
 }
 
-static int intel_sst_runtime_resume(struct device *dev)
-{
-	int ret = 0;
-	struct intel_sst_drv *ctx = dev_get_drvdata(dev);
-
-	if (ctx->sst_state == SST_RESET) {
-		ret = sst_load_fw(ctx);
-		if (ret) {
-			dev_err(dev, "FW download fail %d\n", ret);
-			sst_set_fw_state_locked(ctx, SST_RESET);
-		}
-	}
-	return ret;
-}
-
 static int intel_sst_resume(struct device *dev)
 {
 	struct intel_sst_drv *ctx = dev_get_drvdata(dev);
@@ -519,7 +504,7 @@ static int intel_sst_resume(struct device *dev)
 	struct sst_block *block;
 
 	if (!fw_save)
-		return intel_sst_runtime_resume(dev);
+		return 0;
 
 	sst_set_fw_state_locked(ctx, SST_FW_LOADING);
 
@@ -564,6 +549,5 @@ const struct dev_pm_ops intel_sst_pm = {
 	.suspend = intel_sst_suspend,
 	.resume = intel_sst_resume,
 	.runtime_suspend = intel_sst_runtime_suspend,
-	.runtime_resume = intel_sst_runtime_resume,
 };
 EXPORT_SYMBOL_GPL(intel_sst_pm);
sound/soc/intel/sst/sst_drv_interface.c +23 -4
index 5d56fcdd58d8..5c9399160430 100644
@@ -138,12 +138,31 @@ int sst_get_stream(struct intel_sst_drv *ctx,
 static int sst_power_control(struct device *dev, bool state)
 {
 	struct intel_sst_drv *ctx = dev_get_drvdata(dev);
+	int ret = 0;
 
-	dev_dbg(ctx->dev, "state:%d", state);
-	if (state == true)
-		return pm_runtime_get_sync(dev);
-	else
+	if (state == true) {
+		ret = pm_runtime_get_sync(dev);
+		dev_dbg(ctx->dev, "Enable: pm usage count: %d\n",
+				atomic_read(&dev->power.usage_count));
+		if (ret < 0) {
+			dev_err(ctx->dev, "Runtime get failed with err: %d\n", ret);
+			return ret;
+		}
+		if ((ctx->sst_state == SST_RESET) &&
+			(atomic_read(&dev->power.usage_count) == 1)) {
+			ret = sst_load_fw(ctx);
+			if (ret) {
+				dev_err(dev, "FW download fail %d\n", ret);
+				sst_set_fw_state_locked(ctx, SST_RESET);
+				ret = sst_pm_runtime_put(ctx);
+			}
+		}
+	} else {
+		dev_dbg(ctx->dev, "Disable: pm usage count: %d\n",
+				atomic_read(&dev->power.usage_count));
 		return sst_pm_runtime_put(ctx);
+	}
+	return ret;
 }
 
 /*
Signature · 1 line
1.7.9.5
author
#15 lore raw

PATCH 12/13 ASoC: Intel: Remove ignore suspend support

In reply to Vinod Koul

From: "Subhransu S. Prusty" <[email protected]>

In our platform we want platform and codec driver routines to get invoked and don't need the machine routines so remove here

---
 sound/soc/intel/cht_bsw_rt5672.c |    2 --
 1 file changed, 2 deletions(-)
sound/soc/intel/cht_bsw_rt5672.c +0 -2
index 152e7703dd8a..46e7e50f7d74 100644
@@ -217,7 +217,6 @@ static struct snd_soc_dai_link cht_dailink[] = {
 		.codec_dai_name = "snd-soc-dummy-dai",
 		.codec_name = "snd-soc-dummy",
 		.platform_name = "sst-mfld-platform",
-		.ignore_suspend = 1,
 		.nonatomic = true,
 		.dynamic = 1,
 		.dpcm_playback = 1,
@@ -248,7 +247,6 @@ static struct snd_soc_dai_link cht_dailink[] = {
 					| SND_SOC_DAIFMT_CBS_CFS,
 		.init = cht_codec_init,
 		.be_hw_params_fixup = cht_codec_fixup,
-		.ignore_suspend = 1,
 		.dpcm_playback = 1,
 		.dpcm_capture = 1,
 		.ops = &cht_be_ssp2_ops,
Signature · 1 line
1.7.9.5
author
#16 lore raw

PATCH 13/13 ASoC: Intel: Remove soc pm handling to allow platform driver handle it

In reply to Vinod Koul

From: "Subhransu S. Prusty" <[email protected]>

---
 sound/soc/intel/cht_bsw_rt5672.c |    1 -
 1 file changed, 1 deletion(-)
sound/soc/intel/cht_bsw_rt5672.c +0 -1
index 46e7e50f7d74..d782dcc9f9a7 100644
@@ -285,7 +285,6 @@ static int snd_cht_mc_probe(struct platform_device *pdev)
 static struct platform_driver snd_cht_mc_driver = {
 	.driver = {
 		.name = "cht-bsw-rt5672",
-		.pm = &snd_soc_pm_ops,
 	},
 	.probe = snd_cht_mc_probe,
 };
Signature · 1 line
1.7.9.5