ASoC: Intel: BSW driver updates
Subsystems (3)
v2 cover ASoC: Intel: BSW driver updates
This series adds rest of the remaining 4 patches posted in v1. This is generated on top of Mark's topic/intel
Subhransu S. Prusty (2):
ASoC: Intel: Remove ignore suspend support
ASoC: Intel: Remove soc pm handling to allow platform driver handle
it
Vinod Koul (2):
ASoC: Intel: add pm support in sst ipc driver
ASoC: Intel: Move the fw download to power_control
sound/soc/intel/cht_bsw_rt5672.c | 3 - sound/soc/intel/sst/sst.c | 128 +++++++++++++++++++++++++++++-- sound/soc/intel/sst/sst.h | 9 +++ sound/soc/intel/sst/sst_drv_interface.c | 27 ++++++- 4 files changed, 152 insertions(+), 15 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v2 1/4 ASoC: Intel: add pm support in sst ipc driver
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
@@ -415,6 +415,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 ;
@@ -430,7 +507,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
@@ -337,6 +337,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 *
@@ -428,6 +435,8 @@ struct intel_sst_drv {* persistent till worker thread gets called */ char firmware_name[FW_NAME_SIZE ]; + +struct sst_fw_save *fw_save; };/* misc definitions */
Signature · 1 line
1.7.9.5
PATCH v2 2/4 ASoC: Intel: Move the fw download to power_control
In reply to Vinod KoulThus 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
@@ -492,21 +492,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);
@@ -515,7 +500,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 );
@@ -560,6 +545,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
@@ -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
PATCH v2 3/4 ASoC: Intel: Remove ignore suspend support
In reply to Vinod KoulFrom: "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
@@ -215,7 +215,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,
@@ -246,7 +245,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
PATCH v2 4/4 ASoC: Intel: Remove soc pm handling to allow platform driver handle it
In reply to Vinod KoulFrom: "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
@@ -283,7 +283,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
Quoted 2 lines · Vinod Koul
This series adds rest of the remaining 4 patches posted in v1. This is generated on top of Mark's topic/intel
Applied all, thanks.