summaryrefslogtreecommitdiffstats
path: root/sound/soc/intel
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-09-17 20:43:33 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-09-17 20:43:33 -0400
commit6ab8ad31601f29470eb895fd95e5c963e125aa1b (patch)
tree73327fe9fc2ee62e7815fa0a666fdf46aaab7322 /sound/soc/intel
parentea982ba7f79141d86eb7a440fcba6796ed718b9b (diff)
parent9bf9bf5440b99edfba496388c90b52ebcd9df715 (diff)
Merge tag 'sound-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound
Pull sound updates from Takashi Iwai: "As shown in diffstat and logs, it was again a busy development cycle at this time, too. The most significant changes are still on-going refactoring / modernization works for ASoC core and drivers, but there are lots of other changes as well. Here we go, some highlights below: ASoC: - Quite a lot of cleanup / refactoring of ASoC core and APIs; most of them are systematic, but also including cleanups and modernization - A bulk of updates for some ASoC platforms, Freescale, sunxi and Intel SST/SOF - Initial support for Sound Open Firmware on i.MX8 - Removal of deprecated w90x900 and nuc900 drivers - New support for Cirrus Logic CS47L15 and CS47L92, Freescale i.MX 7ULP and 8MQ, Meson G12A and NXP UDA1334 USB-audio: - More validations of descriptor units for hardening against bugs reported by fuzzers - PCM device assignment workaround for a past call-order change - Scarlett Gen2 mixer interface, a few more more quirks HD-audio: - Support for audio component with AMD/ATI and Nvidia HDMI codecs - Clean up HD-audio core and remove indirect access ops for Intel SOF - DMIC detection at probe; it would make systems automatically falling back to SST/SOF driver on devices that need DMIC handling. Needs a new Kconfig to set, and beware that it's still new and a bit experimental FireWire: - Lots of code refactoring and cleanups" * tag 'sound-5.4-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound: (521 commits) ASoC: sdm845: remove unneeded semicolon ASoC: fsl_sai: Implement set_bclk_ratio ASoC: dmaengine: Replace strncpy() with strscpy_pad() for pcm->name ASoC: wcd9335: remove redundant use of ret variable ALSA: firewire-tascam: check intermediate state of clock status and retry ALSA: firewire-tascam: handle error code when getting current source of clock ASoC: hdmi-codec: Add an op to set callback function for plug event ASoC: rt5677: keep analog power register at SND_SOC_BIAS_OFF ASoC: rt5677: Remove magic number register writes ASoC: soc-core: self contained soc_unbind_aux_dev() ASoC: soc-core: add soc_unbind_aux_dev() ASoC: soc-core: self contained soc_bind_aux_dev() ASoC: soc-core: move soc_probe_link_dais() next to soc_remove_link_dais() ASoC: soc-core: self contained soc_probe_link_dais() ASoC: soc-core: add new soc_link_init() ASoC: soc-core: move soc_probe_dai() next to soc_remove_dai() ASoC: soc-core: self contained soc_remove_link_dais() ASoC: soc-core: self contained soc_remove_link_components() ASoC: soc-core: self contained soc_probe_link_components() ASoC: rt1308: make array pd static const, makes object smaller ...
Diffstat (limited to 'sound/soc/intel')
-rw-r--r--sound/soc/intel/Kconfig1
-rw-r--r--sound/soc/intel/baytrail/sst-baytrail-ipc.c65
-rw-r--r--sound/soc/intel/baytrail/sst-baytrail-pcm.c1
-rw-r--r--sound/soc/intel/boards/Kconfig28
-rw-r--r--sound/soc/intel/boards/bdw-rt5677.c6
-rw-r--r--sound/soc/intel/boards/broadwell.c6
-rw-r--r--sound/soc/intel/boards/bxt_da7219_max98357a.c31
-rw-r--r--sound/soc/intel/boards/cht_bsw_max98090_ti.c101
-rw-r--r--sound/soc/intel/boards/haswell.c6
-rw-r--r--sound/soc/intel/boards/skl_hda_dsp_common.c5
-rw-r--r--sound/soc/intel/boards/skl_hda_dsp_generic.c4
-rw-r--r--sound/soc/intel/boards/sof_rt5682.c7
-rw-r--r--sound/soc/intel/common/Makefile1
-rw-r--r--sound/soc/intel/common/soc-acpi-intel-cnl-match.c12
-rw-r--r--sound/soc/intel/common/soc-acpi-intel-ehl-match.c18
-rw-r--r--sound/soc/intel/common/soc-acpi-intel-tgl-match.c24
-rw-r--r--sound/soc/intel/common/soc-intel-quirks.h5
-rw-r--r--sound/soc/intel/common/sst-acpi.c3
-rw-r--r--sound/soc/intel/common/sst-ipc.c71
-rw-r--r--sound/soc/intel/common/sst-ipc.h28
-rw-r--r--sound/soc/intel/haswell/sst-haswell-ipc.c164
-rw-r--r--sound/soc/intel/skylake/Makefile12
-rw-r--r--sound/soc/intel/skylake/bxt-sst.c50
-rw-r--r--sound/soc/intel/skylake/cnl-sst-dsp.h7
-rw-r--r--sound/soc/intel/skylake/cnl-sst.c43
-rw-r--r--sound/soc/intel/skylake/skl-debug.c44
-rw-r--r--sound/soc/intel/skylake/skl-messages.c264
-rw-r--r--sound/soc/intel/skylake/skl-nhlt.c109
-rw-r--r--sound/soc/intel/skylake/skl-nhlt.h119
-rw-r--r--sound/soc/intel/skylake/skl-pcm.c74
-rw-r--r--sound/soc/intel/skylake/skl-ssp-clk.c5
-rw-r--r--sound/soc/intel/skylake/skl-sst-dsp.c10
-rw-r--r--sound/soc/intel/skylake/skl-sst-dsp.h29
-rw-r--r--sound/soc/intel/skylake/skl-sst-ipc.c160
-rw-r--r--sound/soc/intel/skylake/skl-sst-ipc.h55
-rw-r--r--sound/soc/intel/skylake/skl-sst-utils.c37
-rw-r--r--sound/soc/intel/skylake/skl-sst.c54
-rw-r--r--sound/soc/intel/skylake/skl-topology.c494
-rw-r--r--sound/soc/intel/skylake/skl-topology.h43
-rw-r--r--sound/soc/intel/skylake/skl.c73
-rw-r--r--sound/soc/intel/skylake/skl.h105
41 files changed, 1082 insertions, 1292 deletions
diff --git a/sound/soc/intel/Kconfig b/sound/soc/intel/Kconfig
index 96a00a9d4cf8..01c99750212a 100644
--- a/sound/soc/intel/Kconfig
+++ b/sound/soc/intel/Kconfig
@@ -215,6 +215,7 @@ config SND_SOC_INTEL_SKYLAKE_COMMON
215 select SND_SOC_INTEL_SST 215 select SND_SOC_INTEL_SST
216 select SND_SOC_HDAC_HDA if SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC 216 select SND_SOC_HDAC_HDA if SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC
217 select SND_SOC_ACPI_INTEL_MATCH 217 select SND_SOC_ACPI_INTEL_MATCH
218 select SND_INTEL_NHLT if ACPI
218 help 219 help
219 If you have a Intel Skylake/Broxton/ApolloLake/KabyLake/ 220 If you have a Intel Skylake/Broxton/ApolloLake/KabyLake/
220 GeminiLake or CannonLake platform with the DSP enabled in the BIOS 221 GeminiLake or CannonLake platform with the DSP enabled in the BIOS
diff --git a/sound/soc/intel/baytrail/sst-baytrail-ipc.c b/sound/soc/intel/baytrail/sst-baytrail-ipc.c
index 8bd1eddcc091..74274bd38f7a 100644
--- a/sound/soc/intel/baytrail/sst-baytrail-ipc.c
+++ b/sound/soc/intel/baytrail/sst-baytrail-ipc.c
@@ -211,7 +211,7 @@ static struct sst_byt_stream *sst_byt_get_stream(struct sst_byt *byt,
211static void sst_byt_stream_update(struct sst_byt *byt, struct ipc_message *msg) 211static void sst_byt_stream_update(struct sst_byt *byt, struct ipc_message *msg)
212{ 212{
213 struct sst_byt_stream *stream; 213 struct sst_byt_stream *stream;
214 u64 header = msg->header; 214 u64 header = msg->tx.header;
215 u8 stream_id = sst_byt_header_str_id(header); 215 u8 stream_id = sst_byt_header_str_id(header);
216 u8 stream_msg = sst_byt_header_msg_id(header); 216 u8 stream_msg = sst_byt_header_msg_id(header);
217 217
@@ -240,9 +240,10 @@ static int sst_byt_process_reply(struct sst_byt *byt, u64 header)
240 if (msg == NULL) 240 if (msg == NULL)
241 return 1; 241 return 1;
242 242
243 msg->rx.header = header;
243 if (header & IPC_HEADER_LARGE(true)) { 244 if (header & IPC_HEADER_LARGE(true)) {
244 msg->rx_size = sst_byt_header_data(header); 245 msg->rx.size = sst_byt_header_data(header);
245 sst_dsp_inbox_read(byt->dsp, msg->rx_data, msg->rx_size); 246 sst_dsp_inbox_read(byt->dsp, msg->rx.data, msg->rx.size);
246 } 247 }
247 248
248 /* update any stream states */ 249 /* update any stream states */
@@ -407,17 +408,18 @@ int sst_byt_stream_buffer(struct sst_byt *byt, struct sst_byt_stream *stream,
407 408
408int sst_byt_stream_commit(struct sst_byt *byt, struct sst_byt_stream *stream) 409int sst_byt_stream_commit(struct sst_byt *byt, struct sst_byt_stream *stream)
409{ 410{
410 struct sst_byt_alloc_params *str_req = &stream->request; 411 struct sst_ipc_message request, reply = {0};
411 struct sst_byt_alloc_response *reply = &stream->reply;
412 u64 header;
413 int ret; 412 int ret;
414 413
415 header = sst_byt_header(IPC_IA_ALLOC_STREAM, 414 request.header = sst_byt_header(IPC_IA_ALLOC_STREAM,
416 sizeof(*str_req) + sizeof(u32), 415 sizeof(stream->request) + sizeof(u32),
417 true, stream->str_id); 416 true, stream->str_id);
418 ret = sst_ipc_tx_message_wait(&byt->ipc, header, str_req, 417 request.data = &stream->request;
419 sizeof(*str_req), 418 request.size = sizeof(stream->request);
420 reply, sizeof(*reply)); 419 reply.data = &stream->reply;
420 reply.size = sizeof(stream->reply);
421
422 ret = sst_ipc_tx_message_wait(&byt->ipc, request, &reply);
421 if (ret < 0) { 423 if (ret < 0) {
422 dev_err(byt->dev, "ipc: error stream commit failed\n"); 424 dev_err(byt->dev, "ipc: error stream commit failed\n");
423 return ret; 425 return ret;
@@ -430,7 +432,7 @@ int sst_byt_stream_commit(struct sst_byt *byt, struct sst_byt_stream *stream)
430 432
431int sst_byt_stream_free(struct sst_byt *byt, struct sst_byt_stream *stream) 433int sst_byt_stream_free(struct sst_byt *byt, struct sst_byt_stream *stream)
432{ 434{
433 u64 header; 435 struct sst_ipc_message request = {0};
434 int ret = 0; 436 int ret = 0;
435 struct sst_dsp *sst = byt->dsp; 437 struct sst_dsp *sst = byt->dsp;
436 unsigned long flags; 438 unsigned long flags;
@@ -438,8 +440,9 @@ int sst_byt_stream_free(struct sst_byt *byt, struct sst_byt_stream *stream)
438 if (!stream->commited) 440 if (!stream->commited)
439 goto out; 441 goto out;
440 442
441 header = sst_byt_header(IPC_IA_FREE_STREAM, 0, false, stream->str_id); 443 request.header = sst_byt_header(IPC_IA_FREE_STREAM,
442 ret = sst_ipc_tx_message_wait(&byt->ipc, header, NULL, 0, NULL, 0); 444 0, false, stream->str_id);
445 ret = sst_ipc_tx_message_wait(&byt->ipc, request, NULL);
443 if (ret < 0) { 446 if (ret < 0) {
444 dev_err(byt->dev, "ipc: free stream %d failed\n", 447 dev_err(byt->dev, "ipc: free stream %d failed\n",
445 stream->str_id); 448 stream->str_id);
@@ -459,15 +462,13 @@ out:
459static int sst_byt_stream_operations(struct sst_byt *byt, int type, 462static int sst_byt_stream_operations(struct sst_byt *byt, int type,
460 int stream_id, int wait) 463 int stream_id, int wait)
461{ 464{
462 u64 header; 465 struct sst_ipc_message request = {0};
463 466
464 header = sst_byt_header(type, 0, false, stream_id); 467 request.header = sst_byt_header(type, 0, false, stream_id);
465 if (wait) 468 if (wait)
466 return sst_ipc_tx_message_wait(&byt->ipc, header, NULL, 469 return sst_ipc_tx_message_wait(&byt->ipc, request, NULL);
467 0, NULL, 0);
468 else 470 else
469 return sst_ipc_tx_message_nowait(&byt->ipc, header, 471 return sst_ipc_tx_message_nowait(&byt->ipc, request);
470 NULL, 0);
471} 472}
472 473
473/* stream ALSA trigger operations */ 474/* stream ALSA trigger operations */
@@ -475,19 +476,17 @@ int sst_byt_stream_start(struct sst_byt *byt, struct sst_byt_stream *stream,
475 u32 start_offset) 476 u32 start_offset)
476{ 477{
477 struct sst_byt_start_stream_params start_stream; 478 struct sst_byt_start_stream_params start_stream;
478 void *tx_msg; 479 struct sst_ipc_message request;
479 size_t size;
480 u64 header;
481 int ret; 480 int ret;
482 481
483 start_stream.byte_offset = start_offset; 482 start_stream.byte_offset = start_offset;
484 header = sst_byt_header(IPC_IA_START_STREAM, 483 request.header = sst_byt_header(IPC_IA_START_STREAM,
485 sizeof(start_stream) + sizeof(u32), 484 sizeof(start_stream) + sizeof(u32),
486 true, stream->str_id); 485 true, stream->str_id);
487 tx_msg = &start_stream; 486 request.data = &start_stream;
488 size = sizeof(start_stream); 487 request.size = sizeof(start_stream);
489 488
490 ret = sst_ipc_tx_message_nowait(&byt->ipc, header, tx_msg, size); 489 ret = sst_ipc_tx_message_nowait(&byt->ipc, request);
491 if (ret < 0) 490 if (ret < 0)
492 dev_err(byt->dev, "ipc: error failed to start stream %d\n", 491 dev_err(byt->dev, "ipc: error failed to start stream %d\n",
493 stream->str_id); 492 stream->str_id);
@@ -623,10 +622,10 @@ EXPORT_SYMBOL_GPL(sst_byt_dsp_wait_for_ready);
623 622
624static void byt_tx_msg(struct sst_generic_ipc *ipc, struct ipc_message *msg) 623static void byt_tx_msg(struct sst_generic_ipc *ipc, struct ipc_message *msg)
625{ 624{
626 if (msg->header & IPC_HEADER_LARGE(true)) 625 if (msg->tx.header & IPC_HEADER_LARGE(true))
627 sst_dsp_outbox_write(ipc->dsp, msg->tx_data, msg->tx_size); 626 sst_dsp_outbox_write(ipc->dsp, msg->tx.data, msg->tx.size);
628 627
629 sst_dsp_shim_write64_unlocked(ipc->dsp, SST_IPCX, msg->header); 628 sst_dsp_shim_write64_unlocked(ipc->dsp, SST_IPCX, msg->tx.header);
630} 629}
631 630
632static void byt_shim_dbg(struct sst_generic_ipc *ipc, const char *text) 631static void byt_shim_dbg(struct sst_generic_ipc *ipc, const char *text)
@@ -648,9 +647,9 @@ static void byt_tx_data_copy(struct ipc_message *msg, char *tx_data,
648 size_t tx_size) 647 size_t tx_size)
649{ 648{
650 /* msg content = lower 32-bit of the header + data */ 649 /* msg content = lower 32-bit of the header + data */
651 *(u32 *)msg->tx_data = (u32)(msg->header & (u32)-1); 650 *(u32 *)msg->tx.data = (u32)(msg->tx.header & (u32)-1);
652 memcpy(msg->tx_data + sizeof(u32), tx_data, tx_size); 651 memcpy(msg->tx.data + sizeof(u32), tx_data, tx_size);
653 msg->tx_size += sizeof(u32); 652 msg->tx.size += sizeof(u32);
654} 653}
655 654
656static u64 byt_reply_msg_match(u64 header, u64 *mask) 655static u64 byt_reply_msg_match(u64 header, u64 *mask)
diff --git a/sound/soc/intel/baytrail/sst-baytrail-pcm.c b/sound/soc/intel/baytrail/sst-baytrail-pcm.c
index 9cbc982d46a9..54f2ee3010ee 100644
--- a/sound/soc/intel/baytrail/sst-baytrail-pcm.c
+++ b/sound/soc/intel/baytrail/sst-baytrail-pcm.c
@@ -193,6 +193,7 @@ static int sst_byt_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
193 break; 193 break;
194 case SNDRV_PCM_TRIGGER_SUSPEND: 194 case SNDRV_PCM_TRIGGER_SUSPEND:
195 pdata->restore_stream = false; 195 pdata->restore_stream = false;
196 /* fallthrough */
196 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 197 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
197 sst_byt_stream_pause(byt, pcm_data->stream); 198 sst_byt_stream_pause(byt, pcm_data->stream);
198 break; 199 break;
diff --git a/sound/soc/intel/boards/Kconfig b/sound/soc/intel/boards/Kconfig
index 50bf149818b5..5c27f7ab4a5f 100644
--- a/sound/soc/intel/boards/Kconfig
+++ b/sound/soc/intel/boards/Kconfig
@@ -256,16 +256,20 @@ config SND_SOC_INTEL_SKL_NAU88L25_MAX98357A_MACH
256 256
257endif ## SND_SOC_INTEL_SKL 257endif ## SND_SOC_INTEL_SKL
258 258
259config SND_SOC_INTEL_DA7219_MAX98357A_GENERIC
260 tristate
261 select SND_SOC_DA7219
262 select SND_SOC_MAX98357A
263 select SND_SOC_DMIC
264 select SND_SOC_HDAC_HDMI
265
259if SND_SOC_INTEL_APL 266if SND_SOC_INTEL_APL
260 267
261config SND_SOC_INTEL_BXT_DA7219_MAX98357A_MACH 268config SND_SOC_INTEL_BXT_DA7219_MAX98357A_MACH
262 tristate "Broxton with DA7219 and MAX98357A in I2S Mode" 269 tristate "Broxton with DA7219 and MAX98357A in I2S Mode"
263 depends on I2C && ACPI 270 depends on I2C && ACPI
264 depends on MFD_INTEL_LPSS || COMPILE_TEST 271 depends on MFD_INTEL_LPSS || COMPILE_TEST
265 select SND_SOC_DA7219 272 select SND_SOC_INTEL_DA7219_MAX98357A_GENERIC
266 select SND_SOC_MAX98357A
267 select SND_SOC_DMIC
268 select SND_SOC_HDAC_HDMI
269 select SND_HDA_DSP_LOADER 273 select SND_HDA_DSP_LOADER
270 help 274 help
271 This adds support for ASoC machine driver for Broxton-P platforms 275 This adds support for ASoC machine driver for Broxton-P platforms
@@ -326,10 +330,7 @@ config SND_SOC_INTEL_KBL_DA7219_MAX98357A_MACH
326 tristate "KBL with DA7219 and MAX98357A in I2S Mode" 330 tristate "KBL with DA7219 and MAX98357A in I2S Mode"
327 depends on I2C && ACPI 331 depends on I2C && ACPI
328 depends on MFD_INTEL_LPSS || COMPILE_TEST 332 depends on MFD_INTEL_LPSS || COMPILE_TEST
329 select SND_SOC_DA7219 333 select SND_SOC_INTEL_DA7219_MAX98357A_GENERIC
330 select SND_SOC_MAX98357A
331 select SND_SOC_DMIC
332 select SND_SOC_HDAC_HDMI
333 help 334 help
334 This adds support for ASoC Onboard Codec I2S machine driver. This will 335 This adds support for ASoC Onboard Codec I2S machine driver. This will
335 create an alsa sound card for DA7219 + MAX98357A I2S audio codec. 336 create an alsa sound card for DA7219 + MAX98357A I2S audio codec.
@@ -387,6 +388,7 @@ if SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC || SND_SOC_SOF_HDA_AUDIO_CODEC
387config SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH 388config SND_SOC_INTEL_SKL_HDA_DSP_GENERIC_MACH
388 tristate "SKL/KBL/BXT/APL with HDA Codecs" 389 tristate "SKL/KBL/BXT/APL with HDA Codecs"
389 select SND_SOC_HDAC_HDMI 390 select SND_SOC_HDAC_HDMI
391 select SND_SOC_DMIC
390 # SND_SOC_HDAC_HDA is already selected 392 # SND_SOC_HDAC_HDA is already selected
391 help 393 help
392 This adds support for ASoC machine driver for Intel platforms 394 This adds support for ASoC machine driver for Intel platforms
@@ -412,4 +414,14 @@ config SND_SOC_INTEL_SOF_RT5682_MACH
412 If unsure select "N". 414 If unsure select "N".
413endif ## SND_SOC_SOF_HDA_COMMON || SND_SOC_SOF_BAYTRAIL 415endif ## SND_SOC_SOF_HDA_COMMON || SND_SOC_SOF_BAYTRAIL
414 416
417if (SND_SOC_SOF_COMETLAKE_LP && SND_SOC_SOF_HDA_LINK)
418
419config SND_SOC_INTEL_CML_LP_DA7219_MAX98357A_MACH
420 tristate "CML_LP with DA7219 and MAX98357A in I2S Mode"
421 depends on I2C && ACPI
422 depends on MFD_INTEL_LPSS || COMPILE_TEST
423 select SND_SOC_INTEL_DA7219_MAX98357A_GENERIC
424
425endif ## SND_SOC_SOF_COMETLAKE_LP && SND_SOC_SOF_HDA_LINK
426
415endif ## SND_SOC_INTEL_MACH 427endif ## SND_SOC_INTEL_MACH
diff --git a/sound/soc/intel/boards/bdw-rt5677.c b/sound/soc/intel/boards/bdw-rt5677.c
index e8e9c3dc82a5..4a4d3353e26d 100644
--- a/sound/soc/intel/boards/bdw-rt5677.c
+++ b/sound/soc/intel/boards/bdw-rt5677.c
@@ -340,7 +340,6 @@ static int bdw_rt5677_probe(struct platform_device *pdev)
340{ 340{
341 struct bdw_rt5677_priv *bdw_rt5677; 341 struct bdw_rt5677_priv *bdw_rt5677;
342 struct snd_soc_acpi_mach *mach; 342 struct snd_soc_acpi_mach *mach;
343 const char *platform_name = NULL;
344 int ret; 343 int ret;
345 344
346 bdw_rt5677_card.dev = &pdev->dev; 345 bdw_rt5677_card.dev = &pdev->dev;
@@ -355,11 +354,8 @@ static int bdw_rt5677_probe(struct platform_device *pdev)
355 354
356 /* override plaform name, if required */ 355 /* override plaform name, if required */
357 mach = (&pdev->dev)->platform_data; 356 mach = (&pdev->dev)->platform_data;
358 if (mach) /* extra check since legacy does not pass parameters */
359 platform_name = mach->mach_params.platform;
360
361 ret = snd_soc_fixup_dai_links_platform_name(&bdw_rt5677_card, 357 ret = snd_soc_fixup_dai_links_platform_name(&bdw_rt5677_card,
362 platform_name); 358 mach->mach_params.platform);
363 if (ret) 359 if (ret)
364 return ret; 360 return ret;
365 361
diff --git a/sound/soc/intel/boards/broadwell.c b/sound/soc/intel/boards/broadwell.c
index ab38ef30dfff..db7e1e87156d 100644
--- a/sound/soc/intel/boards/broadwell.c
+++ b/sound/soc/intel/boards/broadwell.c
@@ -270,18 +270,14 @@ static struct snd_soc_card broadwell_rt286 = {
270static int broadwell_audio_probe(struct platform_device *pdev) 270static int broadwell_audio_probe(struct platform_device *pdev)
271{ 271{
272 struct snd_soc_acpi_mach *mach; 272 struct snd_soc_acpi_mach *mach;
273 const char *platform_name = NULL;
274 int ret; 273 int ret;
275 274
276 broadwell_rt286.dev = &pdev->dev; 275 broadwell_rt286.dev = &pdev->dev;
277 276
278 /* override plaform name, if required */ 277 /* override plaform name, if required */
279 mach = (&pdev->dev)->platform_data; 278 mach = (&pdev->dev)->platform_data;
280 if (mach) /* extra check since legacy does not pass parameters */
281 platform_name = mach->mach_params.platform;
282
283 ret = snd_soc_fixup_dai_links_platform_name(&broadwell_rt286, 279 ret = snd_soc_fixup_dai_links_platform_name(&broadwell_rt286,
284 platform_name); 280 mach->mach_params.platform);
285 if (ret) 281 if (ret)
286 return ret; 282 return ret;
287 283
diff --git a/sound/soc/intel/boards/bxt_da7219_max98357a.c b/sound/soc/intel/boards/bxt_da7219_max98357a.c
index c0d865a940dc..ac1dea5f9d11 100644
--- a/sound/soc/intel/boards/bxt_da7219_max98357a.c
+++ b/sound/soc/intel/boards/bxt_da7219_max98357a.c
@@ -179,10 +179,17 @@ static int broxton_da7219_codec_init(struct snd_soc_pcm_runtime *rtd)
179 int ret; 179 int ret;
180 struct snd_soc_dai *codec_dai = rtd->codec_dai; 180 struct snd_soc_dai *codec_dai = rtd->codec_dai;
181 struct snd_soc_component *component = rtd->codec_dai->component; 181 struct snd_soc_component *component = rtd->codec_dai->component;
182 int clk_freq;
182 183
183 /* Configure sysclk for codec */ 184 /* Configure sysclk for codec */
184 ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, 19200000, 185 if (soc_intel_is_cml())
186 clk_freq = 24000000;
187 else
188 clk_freq = 19200000;
189
190 ret = snd_soc_dai_set_sysclk(codec_dai, DA7219_CLKSRC_MCLK, clk_freq,
185 SND_SOC_CLOCK_IN); 191 SND_SOC_CLOCK_IN);
192
186 if (ret) { 193 if (ret) {
187 dev_err(rtd->dev, "can't set codec sysclk configuration\n"); 194 dev_err(rtd->dev, "can't set codec sysclk configuration\n");
188 return ret; 195 return ret;
@@ -683,6 +690,25 @@ static int broxton_audio_probe(struct platform_device *pdev)
683 broxton_dais[i].cpus->dai_name = "SSP2 Pin"; 690 broxton_dais[i].cpus->dai_name = "SSP2 Pin";
684 } 691 }
685 } 692 }
693 } else if (soc_intel_is_cml()) {
694 unsigned int i;
695
696 broxton_audio_card.name = "cmlda7219max";
697
698 for (i = 0; i < ARRAY_SIZE(broxton_dais); i++) {
699 /* MAXIM_CODEC is connected to SSP1. */
700 if (!strcmp(broxton_dais[i].codecs->dai_name,
701 BXT_MAXIM_CODEC_DAI)) {
702 broxton_dais[i].name = "SSP1-Codec";
703 broxton_dais[i].cpus->dai_name = "SSP1 Pin";
704 }
705 /* DIALOG_CODEC is connected to SSP0 */
706 else if (!strcmp(broxton_dais[i].codecs->dai_name,
707 BXT_DIALOG_CODEC_DAI)) {
708 broxton_dais[i].name = "SSP0-Codec";
709 broxton_dais[i].cpus->dai_name = "SSP0 Pin";
710 }
711 }
686 } 712 }
687 713
688 /* override plaform name, if required */ 714 /* override plaform name, if required */
@@ -700,6 +726,7 @@ static int broxton_audio_probe(struct platform_device *pdev)
700static const struct platform_device_id bxt_board_ids[] = { 726static const struct platform_device_id bxt_board_ids[] = {
701 { .name = "bxt_da7219_max98357a" }, 727 { .name = "bxt_da7219_max98357a" },
702 { .name = "glk_da7219_max98357a" }, 728 { .name = "glk_da7219_max98357a" },
729 { .name = "cml_da7219_max98357a" },
703 { } 730 { }
704}; 731};
705 732
@@ -720,6 +747,8 @@ MODULE_AUTHOR("Rohit Ainapure <rohit.m.ainapure@intel.com>");
720MODULE_AUTHOR("Harsha Priya <harshapriya.n@intel.com>"); 747MODULE_AUTHOR("Harsha Priya <harshapriya.n@intel.com>");
721MODULE_AUTHOR("Conrad Cooke <conrad.cooke@intel.com>"); 748MODULE_AUTHOR("Conrad Cooke <conrad.cooke@intel.com>");
722MODULE_AUTHOR("Naveen Manohar <naveen.m@intel.com>"); 749MODULE_AUTHOR("Naveen Manohar <naveen.m@intel.com>");
750MODULE_AUTHOR("Mac Chiang <mac.chiang@intel.com>");
723MODULE_LICENSE("GPL v2"); 751MODULE_LICENSE("GPL v2");
724MODULE_ALIAS("platform:bxt_da7219_max98357a"); 752MODULE_ALIAS("platform:bxt_da7219_max98357a");
725MODULE_ALIAS("platform:glk_da7219_max98357a"); 753MODULE_ALIAS("platform:glk_da7219_max98357a");
754MODULE_ALIAS("platform:cml_da7219_max98357a");
diff --git a/sound/soc/intel/boards/cht_bsw_max98090_ti.c b/sound/soc/intel/boards/cht_bsw_max98090_ti.c
index 05db311b579e..70bb86f3342f 100644
--- a/sound/soc/intel/boards/cht_bsw_max98090_ti.c
+++ b/sound/soc/intel/boards/cht_bsw_max98090_ti.c
@@ -325,9 +325,8 @@ static const struct snd_soc_ops cht_be_ssp2_ops = {
325}; 325};
326 326
327static struct snd_soc_aux_dev cht_max98090_headset_dev = { 327static struct snd_soc_aux_dev cht_max98090_headset_dev = {
328 .name = "Headset Chip", 328 .dlc = COMP_AUX("i2c-104C227E:00"),
329 .init = cht_max98090_headset_init, 329 .init = cht_max98090_headset_init,
330 .codec_name = "i2c-104C227E:00",
331}; 330};
332 331
333SND_SOC_DAILINK_DEF(dummy, 332SND_SOC_DAILINK_DEF(dummy,
@@ -401,6 +400,20 @@ static struct snd_soc_card snd_soc_card_cht = {
401 400
402static const struct dmi_system_id cht_max98090_quirk_table[] = { 401static const struct dmi_system_id cht_max98090_quirk_table[] = {
403 { 402 {
403 /* Banjo model Chromebook */
404 .matches = {
405 DMI_MATCH(DMI_PRODUCT_NAME, "Banjo"),
406 },
407 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0,
408 },
409 {
410 /* Candy model Chromebook */
411 .matches = {
412 DMI_MATCH(DMI_PRODUCT_NAME, "Candy"),
413 },
414 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0,
415 },
416 {
404 /* Clapper model Chromebook */ 417 /* Clapper model Chromebook */
405 .matches = { 418 .matches = {
406 DMI_MATCH(DMI_PRODUCT_NAME, "Clapper"), 419 DMI_MATCH(DMI_PRODUCT_NAME, "Clapper"),
@@ -408,6 +421,27 @@ static const struct dmi_system_id cht_max98090_quirk_table[] = {
408 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0, 421 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0,
409 }, 422 },
410 { 423 {
424 /* Cyan model Chromebook */
425 .matches = {
426 DMI_MATCH(DMI_PRODUCT_NAME, "Cyan"),
427 },
428 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0,
429 },
430 {
431 /* Enguarde model Chromebook */
432 .matches = {
433 DMI_MATCH(DMI_PRODUCT_NAME, "Enguarde"),
434 },
435 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0,
436 },
437 {
438 /* Glimmer model Chromebook */
439 .matches = {
440 DMI_MATCH(DMI_PRODUCT_NAME, "Glimmer"),
441 },
442 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0,
443 },
444 {
411 /* Gnawty model Chromebook (Acer Chromebook CB3-111) */ 445 /* Gnawty model Chromebook (Acer Chromebook CB3-111) */
412 .matches = { 446 .matches = {
413 DMI_MATCH(DMI_PRODUCT_NAME, "Gnawty"), 447 DMI_MATCH(DMI_PRODUCT_NAME, "Gnawty"),
@@ -415,12 +449,75 @@ static const struct dmi_system_id cht_max98090_quirk_table[] = {
415 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0, 449 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0,
416 }, 450 },
417 { 451 {
452 /* Heli model Chromebook */
453 .matches = {
454 DMI_MATCH(DMI_PRODUCT_NAME, "Heli"),
455 },
456 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0,
457 },
458 {
459 /* Kip model Chromebook */
460 .matches = {
461 DMI_MATCH(DMI_PRODUCT_NAME, "Kip"),
462 },
463 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0,
464 },
465 {
466 /* Ninja model Chromebook */
467 .matches = {
468 DMI_MATCH(DMI_PRODUCT_NAME, "Ninja"),
469 },
470 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0,
471 },
472 {
473 /* Orco model Chromebook */
474 .matches = {
475 DMI_MATCH(DMI_PRODUCT_NAME, "Orco"),
476 },
477 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0,
478 },
479 {
480 /* Quawks model Chromebook */
481 .matches = {
482 DMI_MATCH(DMI_PRODUCT_NAME, "Quawks"),
483 },
484 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0,
485 },
486 {
487 /* Rambi model Chromebook */
488 .matches = {
489 DMI_MATCH(DMI_PRODUCT_NAME, "Rambi"),
490 },
491 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0,
492 },
493 {
494 /* Squawks model Chromebook */
495 .matches = {
496 DMI_MATCH(DMI_PRODUCT_NAME, "Squawks"),
497 },
498 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0,
499 },
500 {
501 /* Sumo model Chromebook */
502 .matches = {
503 DMI_MATCH(DMI_PRODUCT_NAME, "Sumo"),
504 },
505 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0,
506 },
507 {
418 /* Swanky model Chromebook (Toshiba Chromebook 2) */ 508 /* Swanky model Chromebook (Toshiba Chromebook 2) */
419 .matches = { 509 .matches = {
420 DMI_MATCH(DMI_PRODUCT_NAME, "Swanky"), 510 DMI_MATCH(DMI_PRODUCT_NAME, "Swanky"),
421 }, 511 },
422 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0, 512 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0,
423 }, 513 },
514 {
515 /* Winky model Chromebook */
516 .matches = {
517 DMI_MATCH(DMI_PRODUCT_NAME, "Winky"),
518 },
519 .driver_data = (void *)QUIRK_PMC_PLT_CLK_0,
520 },
424 {} 521 {}
425}; 522};
426 523
diff --git a/sound/soc/intel/boards/haswell.c b/sound/soc/intel/boards/haswell.c
index 4d3822cff98c..3dadf9bff796 100644
--- a/sound/soc/intel/boards/haswell.c
+++ b/sound/soc/intel/boards/haswell.c
@@ -188,18 +188,14 @@ static struct snd_soc_card haswell_rt5640 = {
188static int haswell_audio_probe(struct platform_device *pdev) 188static int haswell_audio_probe(struct platform_device *pdev)
189{ 189{
190 struct snd_soc_acpi_mach *mach; 190 struct snd_soc_acpi_mach *mach;
191 const char *platform_name = NULL;
192 int ret; 191 int ret;
193 192
194 haswell_rt5640.dev = &pdev->dev; 193 haswell_rt5640.dev = &pdev->dev;
195 194
196 /* override plaform name, if required */ 195 /* override plaform name, if required */
197 mach = (&pdev->dev)->platform_data; 196 mach = (&pdev->dev)->platform_data;
198 if (mach) /* extra check since legacy does not pass parameters */
199 platform_name = mach->mach_params.platform;
200
201 ret = snd_soc_fixup_dai_links_platform_name(&haswell_rt5640, 197 ret = snd_soc_fixup_dai_links_platform_name(&haswell_rt5640,
202 platform_name); 198 mach->mach_params.platform);
203 if (ret) 199 if (ret)
204 return ret; 200 return ret;
205 201
diff --git a/sound/soc/intel/boards/skl_hda_dsp_common.c b/sound/soc/intel/boards/skl_hda_dsp_common.c
index 55fd82e05e2c..58409b6e476e 100644
--- a/sound/soc/intel/boards/skl_hda_dsp_common.c
+++ b/sound/soc/intel/boards/skl_hda_dsp_common.c
@@ -147,6 +147,11 @@ int skl_hda_hdmi_jack_init(struct snd_soc_card *card)
147 if (err) 147 if (err)
148 return err; 148 return err;
149 149
150 err = snd_jack_add_new_kctl(pcm->hdmi_jack.jack,
151 jack_name, SND_JACK_AVOUT);
152 if (err)
153 dev_warn(component->dev, "failed creating Jack kctl\n");
154
150 err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device, 155 err = hdac_hdmi_jack_init(pcm->codec_dai, pcm->device,
151 &pcm->hdmi_jack); 156 &pcm->hdmi_jack);
152 if (err < 0) 157 if (err < 0)
diff --git a/sound/soc/intel/boards/skl_hda_dsp_generic.c b/sound/soc/intel/boards/skl_hda_dsp_generic.c
index 9ed68eb4f058..1778acdc367c 100644
--- a/sound/soc/intel/boards/skl_hda_dsp_generic.c
+++ b/sound/soc/intel/boards/skl_hda_dsp_generic.c
@@ -23,6 +23,7 @@ static const struct snd_soc_dapm_widget skl_hda_widgets[] = {
23 SND_SOC_DAPM_MIC("Alt Analog In", NULL), 23 SND_SOC_DAPM_MIC("Alt Analog In", NULL),
24 SND_SOC_DAPM_SPK("Digital Out", NULL), 24 SND_SOC_DAPM_SPK("Digital Out", NULL),
25 SND_SOC_DAPM_MIC("Digital In", NULL), 25 SND_SOC_DAPM_MIC("Digital In", NULL),
26 SND_SOC_DAPM_MIC("SoC DMIC", NULL),
26}; 27};
27 28
28static const struct snd_soc_dapm_route skl_hda_map[] = { 29static const struct snd_soc_dapm_route skl_hda_map[] = {
@@ -41,6 +42,9 @@ static const struct snd_soc_dapm_route skl_hda_map[] = {
41 { "Codec Input Pin2", NULL, "Digital In" }, 42 { "Codec Input Pin2", NULL, "Digital In" },
42 { "Codec Input Pin3", NULL, "Alt Analog In" }, 43 { "Codec Input Pin3", NULL, "Alt Analog In" },
43 44
45 /* digital mics */
46 {"DMic", NULL, "SoC DMIC"},
47
44 /* CODEC BE connections */ 48 /* CODEC BE connections */
45 { "Analog Codec Playback", NULL, "Analog CPU Playback" }, 49 { "Analog Codec Playback", NULL, "Analog CPU Playback" },
46 { "Analog CPU Playback", NULL, "codec0_out" }, 50 { "Analog CPU Playback", NULL, "codec0_out" },
diff --git a/sound/soc/intel/boards/sof_rt5682.c b/sound/soc/intel/boards/sof_rt5682.c
index daeaa396d928..a437567b8cee 100644
--- a/sound/soc/intel/boards/sof_rt5682.c
+++ b/sound/soc/intel/boards/sof_rt5682.c
@@ -91,8 +91,7 @@ static const struct dmi_system_id sof_rt5682_quirk_table[] = {
91 { 91 {
92 .callback = sof_rt5682_quirk_cb, 92 .callback = sof_rt5682_quirk_cb,
93 .matches = { 93 .matches = {
94 DMI_MATCH(DMI_SYS_VENDOR, "Google"), 94 DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Hatch"),
95 DMI_MATCH(DMI_PRODUCT_NAME, "Hatch"),
96 }, 95 },
97 .driver_data = (void *)(SOF_RT5682_MCLK_EN | 96 .driver_data = (void *)(SOF_RT5682_MCLK_EN |
98 SOF_RT5682_MCLK_24MHZ | 97 SOF_RT5682_MCLK_24MHZ |
@@ -309,6 +308,7 @@ static const struct snd_soc_dapm_widget sof_widgets[] = {
309 SND_SOC_DAPM_HP("Headphone Jack", NULL), 308 SND_SOC_DAPM_HP("Headphone Jack", NULL),
310 SND_SOC_DAPM_MIC("Headset Mic", NULL), 309 SND_SOC_DAPM_MIC("Headset Mic", NULL),
311 SND_SOC_DAPM_SPK("Spk", NULL), 310 SND_SOC_DAPM_SPK("Spk", NULL),
311 SND_SOC_DAPM_MIC("SoC DMIC", NULL),
312}; 312};
313 313
314static const struct snd_soc_dapm_route sof_map[] = { 314static const struct snd_soc_dapm_route sof_map[] = {
@@ -319,6 +319,9 @@ static const struct snd_soc_dapm_route sof_map[] = {
319 /* other jacks */ 319 /* other jacks */
320 { "IN1P", NULL, "Headset Mic" }, 320 { "IN1P", NULL, "Headset Mic" },
321 321
322 /* digital mics */
323 {"DMic", NULL, "SoC DMIC"},
324
322}; 325};
323 326
324static const struct snd_soc_dapm_route speaker_map[] = { 327static const struct snd_soc_dapm_route speaker_map[] = {
diff --git a/sound/soc/intel/common/Makefile b/sound/soc/intel/common/Makefile
index 56c81e20b5bf..18d9630ae9a2 100644
--- a/sound/soc/intel/common/Makefile
+++ b/sound/soc/intel/common/Makefile
@@ -8,6 +8,7 @@ snd-soc-acpi-intel-match-objs := soc-acpi-intel-byt-match.o soc-acpi-intel-cht-m
8 soc-acpi-intel-skl-match.o soc-acpi-intel-kbl-match.o \ 8 soc-acpi-intel-skl-match.o soc-acpi-intel-kbl-match.o \
9 soc-acpi-intel-bxt-match.o soc-acpi-intel-glk-match.o \ 9 soc-acpi-intel-bxt-match.o soc-acpi-intel-glk-match.o \
10 soc-acpi-intel-cnl-match.o soc-acpi-intel-icl-match.o \ 10 soc-acpi-intel-cnl-match.o soc-acpi-intel-icl-match.o \
11 soc-acpi-intel-tgl-match.o soc-acpi-intel-ehl-match.o \
11 soc-acpi-intel-hda-match.o 12 soc-acpi-intel-hda-match.o
12 13
13obj-$(CONFIG_SND_SOC_INTEL_SST) += snd-soc-sst-dsp.o snd-soc-sst-ipc.o 14obj-$(CONFIG_SND_SOC_INTEL_SST) += snd-soc-sst-dsp.o snd-soc-sst-ipc.o
diff --git a/sound/soc/intel/common/soc-acpi-intel-cnl-match.c b/sound/soc/intel/common/soc-acpi-intel-cnl-match.c
index 771b0ef21051..985aa366c9e8 100644
--- a/sound/soc/intel/common/soc-acpi-intel-cnl-match.c
+++ b/sound/soc/intel/common/soc-acpi-intel-cnl-match.c
@@ -19,6 +19,11 @@ static struct snd_soc_acpi_codecs cml_codecs = {
19 .codecs = {"10EC5682"} 19 .codecs = {"10EC5682"}
20}; 20};
21 21
22static struct snd_soc_acpi_codecs cml_spk_codecs = {
23 .num_codecs = 1,
24 .codecs = {"MX98357A"}
25};
26
22struct snd_soc_acpi_mach snd_soc_acpi_intel_cnl_machines[] = { 27struct snd_soc_acpi_mach snd_soc_acpi_intel_cnl_machines[] = {
23 { 28 {
24 .id = "INT34C2", 29 .id = "INT34C2",
@@ -29,6 +34,13 @@ struct snd_soc_acpi_mach snd_soc_acpi_intel_cnl_machines[] = {
29 .sof_tplg_filename = "sof-cnl-rt274.tplg", 34 .sof_tplg_filename = "sof-cnl-rt274.tplg",
30 }, 35 },
31 { 36 {
37 .id = "DLGS7219",
38 .drv_name = "cml_da7219_max98357a",
39 .quirk_data = &cml_spk_codecs,
40 .sof_fw_filename = "sof-cnl.ri",
41 .sof_tplg_filename = "sof-cml-da7219-max98357a.tplg",
42 },
43 {
32 .id = "MX98357A", 44 .id = "MX98357A",
33 .drv_name = "sof_rt5682", 45 .drv_name = "sof_rt5682",
34 .quirk_data = &cml_codecs, 46 .quirk_data = &cml_codecs,
diff --git a/sound/soc/intel/common/soc-acpi-intel-ehl-match.c b/sound/soc/intel/common/soc-acpi-intel-ehl-match.c
new file mode 100644
index 000000000000..a1290c3fa99f
--- /dev/null
+++ b/sound/soc/intel/common/soc-acpi-intel-ehl-match.c
@@ -0,0 +1,18 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * soc-apci-intel-ehl-match.c - tables and support for EHL ACPI enumeration.
4 *
5 * Copyright (c) 2019, Intel Corporation.
6 *
7 */
8
9#include <sound/soc-acpi.h>
10#include <sound/soc-acpi-intel-match.h>
11
12struct snd_soc_acpi_mach snd_soc_acpi_intel_ehl_machines[] = {
13 {},
14};
15EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_ehl_machines);
16
17MODULE_LICENSE("GPL v2");
18MODULE_DESCRIPTION("Intel Common ACPI Match module");
diff --git a/sound/soc/intel/common/soc-acpi-intel-tgl-match.c b/sound/soc/intel/common/soc-acpi-intel-tgl-match.c
new file mode 100644
index 000000000000..57a6298d6dca
--- /dev/null
+++ b/sound/soc/intel/common/soc-acpi-intel-tgl-match.c
@@ -0,0 +1,24 @@
1// SPDX-License-Identifier: GPL-2.0
2/*
3 * soc-apci-intel-tgl-match.c - tables and support for ICL ACPI enumeration.
4 *
5 * Copyright (c) 2019, Intel Corporation.
6 *
7 */
8
9#include <sound/soc-acpi.h>
10#include <sound/soc-acpi-intel-match.h>
11
12struct snd_soc_acpi_mach snd_soc_acpi_intel_tgl_machines[] = {
13 {
14 .id = "10EC1308",
15 .drv_name = "tgl_rt1308",
16 .sof_fw_filename = "sof-tgl.ri",
17 .sof_tplg_filename = "sof-tgl-rt1308.tplg",
18 },
19 {},
20};
21EXPORT_SYMBOL_GPL(snd_soc_acpi_intel_tgl_machines);
22
23MODULE_LICENSE("GPL v2");
24MODULE_DESCRIPTION("Intel Common ACPI Match module");
diff --git a/sound/soc/intel/common/soc-intel-quirks.h b/sound/soc/intel/common/soc-intel-quirks.h
index 4718fd3cf636..863a477d3405 100644
--- a/sound/soc/intel/common/soc-intel-quirks.h
+++ b/sound/soc/intel/common/soc-intel-quirks.h
@@ -36,6 +36,7 @@ SOC_INTEL_IS_CPU(byt, INTEL_FAM6_ATOM_SILVERMONT);
36SOC_INTEL_IS_CPU(cht, INTEL_FAM6_ATOM_AIRMONT); 36SOC_INTEL_IS_CPU(cht, INTEL_FAM6_ATOM_AIRMONT);
37SOC_INTEL_IS_CPU(apl, INTEL_FAM6_ATOM_GOLDMONT); 37SOC_INTEL_IS_CPU(apl, INTEL_FAM6_ATOM_GOLDMONT);
38SOC_INTEL_IS_CPU(glk, INTEL_FAM6_ATOM_GOLDMONT_PLUS); 38SOC_INTEL_IS_CPU(glk, INTEL_FAM6_ATOM_GOLDMONT_PLUS);
39SOC_INTEL_IS_CPU(cml, INTEL_FAM6_KABYLAKE_L);
39 40
40static inline bool soc_intel_is_byt_cr(struct platform_device *pdev) 41static inline bool soc_intel_is_byt_cr(struct platform_device *pdev)
41{ 42{
@@ -110,6 +111,10 @@ static inline bool soc_intel_is_glk(void)
110 return false; 111 return false;
111} 112}
112 113
114static inline bool soc_intel_is_cml(void)
115{
116 return false;
117}
113#endif 118#endif
114 119
115 #endif /* _SND_SOC_INTEL_QUIRKS_H */ 120 #endif /* _SND_SOC_INTEL_QUIRKS_H */
diff --git a/sound/soc/intel/common/sst-acpi.c b/sound/soc/intel/common/sst-acpi.c
index 0e8e0a7a11df..5854868650b9 100644
--- a/sound/soc/intel/common/sst-acpi.c
+++ b/sound/soc/intel/common/sst-acpi.c
@@ -141,11 +141,12 @@ static int sst_acpi_probe(struct platform_device *pdev)
141 } 141 }
142 142
143 platform_set_drvdata(pdev, sst_acpi); 143 platform_set_drvdata(pdev, sst_acpi);
144 mach->pdata = sst_pdata;
144 145
145 /* register machine driver */ 146 /* register machine driver */
146 sst_acpi->pdev_mach = 147 sst_acpi->pdev_mach =
147 platform_device_register_data(dev, mach->drv_name, -1, 148 platform_device_register_data(dev, mach->drv_name, -1,
148 sst_pdata, sizeof(*sst_pdata)); 149 mach, sizeof(*mach));
149 if (IS_ERR(sst_acpi->pdev_mach)) 150 if (IS_ERR(sst_acpi->pdev_mach))
150 return PTR_ERR(sst_acpi->pdev_mach); 151 return PTR_ERR(sst_acpi->pdev_mach);
151 152
diff --git a/sound/soc/intel/common/sst-ipc.c b/sound/soc/intel/common/sst-ipc.c
index ef5b66af1cd2..6068bb697e22 100644
--- a/sound/soc/intel/common/sst-ipc.c
+++ b/sound/soc/intel/common/sst-ipc.c
@@ -43,7 +43,7 @@ static struct ipc_message *msg_get_empty(struct sst_generic_ipc *ipc)
43} 43}
44 44
45static int tx_wait_done(struct sst_generic_ipc *ipc, 45static int tx_wait_done(struct sst_generic_ipc *ipc,
46 struct ipc_message *msg, void *rx_data) 46 struct ipc_message *msg, struct sst_ipc_message *reply)
47{ 47{
48 unsigned long flags; 48 unsigned long flags;
49 int ret; 49 int ret;
@@ -62,8 +62,11 @@ static int tx_wait_done(struct sst_generic_ipc *ipc,
62 } else { 62 } else {
63 63
64 /* copy the data returned from DSP */ 64 /* copy the data returned from DSP */
65 if (rx_data) 65 if (reply) {
66 memcpy(rx_data, msg->rx_data, msg->rx_size); 66 reply->header = msg->rx.header;
67 if (reply->data)
68 memcpy(reply->data, msg->rx.data, msg->rx.size);
69 }
67 ret = msg->errno; 70 ret = msg->errno;
68 } 71 }
69 72
@@ -72,9 +75,9 @@ static int tx_wait_done(struct sst_generic_ipc *ipc,
72 return ret; 75 return ret;
73} 76}
74 77
75static int ipc_tx_message(struct sst_generic_ipc *ipc, u64 header, 78static int ipc_tx_message(struct sst_generic_ipc *ipc,
76 void *tx_data, size_t tx_bytes, void *rx_data, 79 struct sst_ipc_message request,
77 size_t rx_bytes, int wait) 80 struct sst_ipc_message *reply, int wait)
78{ 81{
79 struct ipc_message *msg; 82 struct ipc_message *msg;
80 unsigned long flags; 83 unsigned long flags;
@@ -87,23 +90,24 @@ static int ipc_tx_message(struct sst_generic_ipc *ipc, u64 header,
87 return -EBUSY; 90 return -EBUSY;
88 } 91 }
89 92
90 msg->header = header; 93 msg->tx.header = request.header;
91 msg->tx_size = tx_bytes; 94 msg->tx.size = request.size;
92 msg->rx_size = rx_bytes; 95 msg->rx.header = 0;
96 msg->rx.size = reply ? reply->size : 0;
93 msg->wait = wait; 97 msg->wait = wait;
94 msg->errno = 0; 98 msg->errno = 0;
95 msg->pending = false; 99 msg->pending = false;
96 msg->complete = false; 100 msg->complete = false;
97 101
98 if ((tx_bytes) && (ipc->ops.tx_data_copy != NULL)) 102 if ((request.size) && (ipc->ops.tx_data_copy != NULL))
99 ipc->ops.tx_data_copy(msg, tx_data, tx_bytes); 103 ipc->ops.tx_data_copy(msg, request.data, request.size);
100 104
101 list_add_tail(&msg->list, &ipc->tx_list); 105 list_add_tail(&msg->list, &ipc->tx_list);
102 schedule_work(&ipc->kwork); 106 schedule_work(&ipc->kwork);
103 spin_unlock_irqrestore(&ipc->dsp->spinlock, flags); 107 spin_unlock_irqrestore(&ipc->dsp->spinlock, flags);
104 108
105 if (wait) 109 if (wait)
106 return tx_wait_done(ipc, msg, rx_data); 110 return tx_wait_done(ipc, msg, reply);
107 else 111 else
108 return 0; 112 return 0;
109} 113}
@@ -118,13 +122,13 @@ static int msg_empty_list_init(struct sst_generic_ipc *ipc)
118 return -ENOMEM; 122 return -ENOMEM;
119 123
120 for (i = 0; i < IPC_EMPTY_LIST_SIZE; i++) { 124 for (i = 0; i < IPC_EMPTY_LIST_SIZE; i++) {
121 ipc->msg[i].tx_data = kzalloc(ipc->tx_data_max_size, GFP_KERNEL); 125 ipc->msg[i].tx.data = kzalloc(ipc->tx_data_max_size, GFP_KERNEL);
122 if (ipc->msg[i].tx_data == NULL) 126 if (ipc->msg[i].tx.data == NULL)
123 goto free_mem; 127 goto free_mem;
124 128
125 ipc->msg[i].rx_data = kzalloc(ipc->rx_data_max_size, GFP_KERNEL); 129 ipc->msg[i].rx.data = kzalloc(ipc->rx_data_max_size, GFP_KERNEL);
126 if (ipc->msg[i].rx_data == NULL) { 130 if (ipc->msg[i].rx.data == NULL) {
127 kfree(ipc->msg[i].tx_data); 131 kfree(ipc->msg[i].tx.data);
128 goto free_mem; 132 goto free_mem;
129 } 133 }
130 134
@@ -136,8 +140,8 @@ static int msg_empty_list_init(struct sst_generic_ipc *ipc)
136 140
137free_mem: 141free_mem:
138 while (i > 0) { 142 while (i > 0) {
139 kfree(ipc->msg[i-1].tx_data); 143 kfree(ipc->msg[i-1].tx.data);
140 kfree(ipc->msg[i-1].rx_data); 144 kfree(ipc->msg[i-1].rx.data);
141 --i; 145 --i;
142 } 146 }
143 kfree(ipc->msg); 147 kfree(ipc->msg);
@@ -173,8 +177,8 @@ static void ipc_tx_msgs(struct work_struct *work)
173 spin_unlock_irq(&ipc->dsp->spinlock); 177 spin_unlock_irq(&ipc->dsp->spinlock);
174} 178}
175 179
176int sst_ipc_tx_message_wait(struct sst_generic_ipc *ipc, u64 header, 180int sst_ipc_tx_message_wait(struct sst_generic_ipc *ipc,
177 void *tx_data, size_t tx_bytes, void *rx_data, size_t rx_bytes) 181 struct sst_ipc_message request, struct sst_ipc_message *reply)
178{ 182{
179 int ret; 183 int ret;
180 184
@@ -187,8 +191,7 @@ int sst_ipc_tx_message_wait(struct sst_generic_ipc *ipc, u64 header,
187 if (ipc->ops.check_dsp_lp_on(ipc->dsp, true)) 191 if (ipc->ops.check_dsp_lp_on(ipc->dsp, true))
188 return -EIO; 192 return -EIO;
189 193
190 ret = ipc_tx_message(ipc, header, tx_data, tx_bytes, 194 ret = ipc_tx_message(ipc, request, reply, 1);
191 rx_data, rx_bytes, 1);
192 195
193 if (ipc->ops.check_dsp_lp_on) 196 if (ipc->ops.check_dsp_lp_on)
194 if (ipc->ops.check_dsp_lp_on(ipc->dsp, false)) 197 if (ipc->ops.check_dsp_lp_on(ipc->dsp, false))
@@ -198,19 +201,17 @@ int sst_ipc_tx_message_wait(struct sst_generic_ipc *ipc, u64 header,
198} 201}
199EXPORT_SYMBOL_GPL(sst_ipc_tx_message_wait); 202EXPORT_SYMBOL_GPL(sst_ipc_tx_message_wait);
200 203
201int sst_ipc_tx_message_nowait(struct sst_generic_ipc *ipc, u64 header, 204int sst_ipc_tx_message_nowait(struct sst_generic_ipc *ipc,
202 void *tx_data, size_t tx_bytes) 205 struct sst_ipc_message request)
203{ 206{
204 return ipc_tx_message(ipc, header, tx_data, tx_bytes, 207 return ipc_tx_message(ipc, request, NULL, 0);
205 NULL, 0, 0);
206} 208}
207EXPORT_SYMBOL_GPL(sst_ipc_tx_message_nowait); 209EXPORT_SYMBOL_GPL(sst_ipc_tx_message_nowait);
208 210
209int sst_ipc_tx_message_nopm(struct sst_generic_ipc *ipc, u64 header, 211int sst_ipc_tx_message_nopm(struct sst_generic_ipc *ipc,
210 void *tx_data, size_t tx_bytes, void *rx_data, size_t rx_bytes) 212 struct sst_ipc_message request, struct sst_ipc_message *reply)
211{ 213{
212 return ipc_tx_message(ipc, header, tx_data, tx_bytes, 214 return ipc_tx_message(ipc, request, reply, 1);
213 rx_data, rx_bytes, 1);
214} 215}
215EXPORT_SYMBOL_GPL(sst_ipc_tx_message_nopm); 216EXPORT_SYMBOL_GPL(sst_ipc_tx_message_nopm);
216 217
@@ -222,6 +223,8 @@ struct ipc_message *sst_ipc_reply_find_msg(struct sst_generic_ipc *ipc,
222 223
223 if (ipc->ops.reply_msg_match != NULL) 224 if (ipc->ops.reply_msg_match != NULL)
224 header = ipc->ops.reply_msg_match(header, &mask); 225 header = ipc->ops.reply_msg_match(header, &mask);
226 else
227 mask = (u64)-1;
225 228
226 if (list_empty(&ipc->rx_list)) { 229 if (list_empty(&ipc->rx_list)) {
227 dev_err(ipc->dev, "error: rx list empty but received 0x%llx\n", 230 dev_err(ipc->dev, "error: rx list empty but received 0x%llx\n",
@@ -230,7 +233,7 @@ struct ipc_message *sst_ipc_reply_find_msg(struct sst_generic_ipc *ipc,
230 } 233 }
231 234
232 list_for_each_entry(msg, &ipc->rx_list, list) { 235 list_for_each_entry(msg, &ipc->rx_list, list) {
233 if ((msg->header & mask) == header) 236 if ((msg->tx.header & mask) == header)
234 return msg; 237 return msg;
235 } 238 }
236 239
@@ -304,8 +307,8 @@ void sst_ipc_fini(struct sst_generic_ipc *ipc)
304 307
305 if (ipc->msg) { 308 if (ipc->msg) {
306 for (i = 0; i < IPC_EMPTY_LIST_SIZE; i++) { 309 for (i = 0; i < IPC_EMPTY_LIST_SIZE; i++) {
307 kfree(ipc->msg[i].tx_data); 310 kfree(ipc->msg[i].tx.data);
308 kfree(ipc->msg[i].rx_data); 311 kfree(ipc->msg[i].rx.data);
309 } 312 }
310 kfree(ipc->msg); 313 kfree(ipc->msg);
311 } 314 }
diff --git a/sound/soc/intel/common/sst-ipc.h b/sound/soc/intel/common/sst-ipc.h
index c6779e2ac830..08c4831b2664 100644
--- a/sound/soc/intel/common/sst-ipc.h
+++ b/sound/soc/intel/common/sst-ipc.h
@@ -17,15 +17,16 @@
17 17
18#define IPC_MAX_MAILBOX_BYTES 256 18#define IPC_MAX_MAILBOX_BYTES 256
19 19
20struct ipc_message { 20struct sst_ipc_message {
21 struct list_head list;
22 u64 header; 21 u64 header;
22 void *data;
23 size_t size;
24};
23 25
24 /* direction wrt host CPU */ 26struct ipc_message {
25 char *tx_data; 27 struct list_head list;
26 size_t tx_size; 28 struct sst_ipc_message tx;
27 char *rx_data; 29 struct sst_ipc_message rx;
28 size_t rx_size;
29 30
30 wait_queue_head_t waitq; 31 wait_queue_head_t waitq;
31 bool pending; 32 bool pending;
@@ -35,6 +36,7 @@ struct ipc_message {
35}; 36};
36 37
37struct sst_generic_ipc; 38struct sst_generic_ipc;
39struct sst_dsp;
38 40
39struct sst_plat_ipc_ops { 41struct sst_plat_ipc_ops {
40 void (*tx_msg)(struct sst_generic_ipc *, struct ipc_message *); 42 void (*tx_msg)(struct sst_generic_ipc *, struct ipc_message *);
@@ -65,14 +67,14 @@ struct sst_generic_ipc {
65 struct sst_plat_ipc_ops ops; 67 struct sst_plat_ipc_ops ops;
66}; 68};
67 69
68int sst_ipc_tx_message_wait(struct sst_generic_ipc *ipc, u64 header, 70int sst_ipc_tx_message_wait(struct sst_generic_ipc *ipc,
69 void *tx_data, size_t tx_bytes, void *rx_data, size_t rx_bytes); 71 struct sst_ipc_message request, struct sst_ipc_message *reply);
70 72
71int sst_ipc_tx_message_nowait(struct sst_generic_ipc *ipc, u64 header, 73int sst_ipc_tx_message_nowait(struct sst_generic_ipc *ipc,
72 void *tx_data, size_t tx_bytes); 74 struct sst_ipc_message request);
73 75
74int sst_ipc_tx_message_nopm(struct sst_generic_ipc *ipc, u64 header, 76int sst_ipc_tx_message_nopm(struct sst_generic_ipc *ipc,
75 void *tx_data, size_t tx_bytes, void *rx_data, size_t rx_bytes); 77 struct sst_ipc_message request, struct sst_ipc_message *reply);
76 78
77struct ipc_message *sst_ipc_reply_find_msg(struct sst_generic_ipc *ipc, 79struct ipc_message *sst_ipc_reply_find_msg(struct sst_generic_ipc *ipc,
78 u64 header); 80 u64 header);
diff --git a/sound/soc/intel/haswell/sst-haswell-ipc.c b/sound/soc/intel/haswell/sst-haswell-ipc.c
index a83b92d6bea8..0ff89ea96ccf 100644
--- a/sound/soc/intel/haswell/sst-haswell-ipc.c
+++ b/sound/soc/intel/haswell/sst-haswell-ipc.c
@@ -511,7 +511,7 @@ static void hsw_notification_work(struct work_struct *work)
511static void hsw_stream_update(struct sst_hsw *hsw, struct ipc_message *msg) 511static void hsw_stream_update(struct sst_hsw *hsw, struct ipc_message *msg)
512{ 512{
513 struct sst_hsw_stream *stream; 513 struct sst_hsw_stream *stream;
514 u32 header = msg->header & ~(IPC_STATUS_MASK | IPC_GLB_REPLY_MASK); 514 u32 header = msg->tx.header & ~(IPC_STATUS_MASK | IPC_GLB_REPLY_MASK);
515 u32 stream_id = msg_get_stream_id(header); 515 u32 stream_id = msg_get_stream_id(header);
516 u32 stream_msg = msg_get_stream_type(header); 516 u32 stream_msg = msg_get_stream_type(header);
517 517
@@ -552,6 +552,7 @@ static int hsw_process_reply(struct sst_hsw *hsw, u32 header)
552 return -EIO; 552 return -EIO;
553 } 553 }
554 554
555 msg->rx.header = header;
555 /* first process the header */ 556 /* first process the header */
556 switch (reply) { 557 switch (reply) {
557 case IPC_GLB_REPLY_PENDING: 558 case IPC_GLB_REPLY_PENDING:
@@ -562,13 +563,13 @@ static int hsw_process_reply(struct sst_hsw *hsw, u32 header)
562 case IPC_GLB_REPLY_SUCCESS: 563 case IPC_GLB_REPLY_SUCCESS:
563 if (msg->pending) { 564 if (msg->pending) {
564 trace_ipc_pending_reply("completed", header); 565 trace_ipc_pending_reply("completed", header);
565 sst_dsp_inbox_read(hsw->dsp, msg->rx_data, 566 sst_dsp_inbox_read(hsw->dsp, msg->rx.data,
566 msg->rx_size); 567 msg->rx.size);
567 hsw->ipc.pending = false; 568 hsw->ipc.pending = false;
568 } else { 569 } else {
569 /* copy data from the DSP */ 570 /* copy data from the DSP */
570 sst_dsp_outbox_read(hsw->dsp, msg->rx_data, 571 sst_dsp_outbox_read(hsw->dsp, msg->rx.data,
571 msg->rx_size); 572 msg->rx.size);
572 } 573 }
573 break; 574 break;
574 /* these will be rare - but useful for debug */ 575 /* these will be rare - but useful for debug */
@@ -810,11 +811,13 @@ static irqreturn_t hsw_irq_thread(int irq, void *context)
810int sst_hsw_fw_get_version(struct sst_hsw *hsw, 811int sst_hsw_fw_get_version(struct sst_hsw *hsw,
811 struct sst_hsw_ipc_fw_version *version) 812 struct sst_hsw_ipc_fw_version *version)
812{ 813{
814 struct sst_ipc_message request = {0}, reply = {0};
813 int ret; 815 int ret;
814 816
815 ret = sst_ipc_tx_message_wait(&hsw->ipc, 817 request.header = IPC_GLB_TYPE(IPC_GLB_GET_FW_VERSION);
816 IPC_GLB_TYPE(IPC_GLB_GET_FW_VERSION), 818 reply.data = version;
817 NULL, 0, version, sizeof(*version)); 819 reply.size = sizeof(*version);
820 ret = sst_ipc_tx_message_wait(&hsw->ipc, request, &reply);
818 if (ret < 0) 821 if (ret < 0)
819 dev_err(hsw->dev, "error: get version failed\n"); 822 dev_err(hsw->dev, "error: get version failed\n");
820 823
@@ -840,7 +843,7 @@ int sst_hsw_stream_set_volume(struct sst_hsw *hsw,
840 struct sst_hsw_stream *stream, u32 stage_id, u32 channel, u32 volume) 843 struct sst_hsw_stream *stream, u32 stage_id, u32 channel, u32 volume)
841{ 844{
842 struct sst_hsw_ipc_volume_req *req; 845 struct sst_hsw_ipc_volume_req *req;
843 u32 header; 846 struct sst_ipc_message request;
844 int ret; 847 int ret;
845 848
846 trace_ipc_request("set stream volume", stream->reply.stream_hw_id); 849 trace_ipc_request("set stream volume", stream->reply.stream_hw_id);
@@ -848,11 +851,11 @@ int sst_hsw_stream_set_volume(struct sst_hsw *hsw,
848 if (channel >= 2 && channel != SST_HSW_CHANNELS_ALL) 851 if (channel >= 2 && channel != SST_HSW_CHANNELS_ALL)
849 return -EINVAL; 852 return -EINVAL;
850 853
851 header = IPC_GLB_TYPE(IPC_GLB_STREAM_MESSAGE) | 854 request.header = IPC_GLB_TYPE(IPC_GLB_STREAM_MESSAGE) |
852 IPC_STR_TYPE(IPC_STR_STAGE_MESSAGE); 855 IPC_STR_TYPE(IPC_STR_STAGE_MESSAGE);
853 header |= (stream->reply.stream_hw_id << IPC_STR_ID_SHIFT); 856 request.header |= (stream->reply.stream_hw_id << IPC_STR_ID_SHIFT);
854 header |= (IPC_STG_SET_VOLUME << IPC_STG_TYPE_SHIFT); 857 request.header |= (IPC_STG_SET_VOLUME << IPC_STG_TYPE_SHIFT);
855 header |= (stage_id << IPC_STG_ID_SHIFT); 858 request.header |= (stage_id << IPC_STG_ID_SHIFT);
856 859
857 req = &stream->vol_req; 860 req = &stream->vol_req;
858 req->target_volume = volume; 861 req->target_volume = volume;
@@ -877,8 +880,9 @@ int sst_hsw_stream_set_volume(struct sst_hsw *hsw,
877 req->channel = channel; 880 req->channel = channel;
878 } 881 }
879 882
880 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, req, 883 request.data = req;
881 sizeof(*req), NULL, 0); 884 request.size = sizeof(*req);
885 ret = sst_ipc_tx_message_wait(&hsw->ipc, request, NULL);
882 if (ret < 0) { 886 if (ret < 0) {
883 dev_err(hsw->dev, "error: set stream volume failed\n"); 887 dev_err(hsw->dev, "error: set stream volume failed\n");
884 return ret; 888 return ret;
@@ -905,7 +909,7 @@ int sst_hsw_mixer_set_volume(struct sst_hsw *hsw, u32 stage_id, u32 channel,
905 u32 volume) 909 u32 volume)
906{ 910{
907 struct sst_hsw_ipc_volume_req req; 911 struct sst_hsw_ipc_volume_req req;
908 u32 header; 912 struct sst_ipc_message request;
909 int ret; 913 int ret;
910 914
911 trace_ipc_request("set mixer volume", volume); 915 trace_ipc_request("set mixer volume", volume);
@@ -933,18 +937,19 @@ int sst_hsw_mixer_set_volume(struct sst_hsw *hsw, u32 stage_id, u32 channel,
933 req.channel = channel; 937 req.channel = channel;
934 } 938 }
935 939
936 header = IPC_GLB_TYPE(IPC_GLB_STREAM_MESSAGE) | 940 request.header = IPC_GLB_TYPE(IPC_GLB_STREAM_MESSAGE) |
937 IPC_STR_TYPE(IPC_STR_STAGE_MESSAGE); 941 IPC_STR_TYPE(IPC_STR_STAGE_MESSAGE);
938 header |= (hsw->mixer_info.mixer_hw_id << IPC_STR_ID_SHIFT); 942 request.header |= (hsw->mixer_info.mixer_hw_id << IPC_STR_ID_SHIFT);
939 header |= (IPC_STG_SET_VOLUME << IPC_STG_TYPE_SHIFT); 943 request.header |= (IPC_STG_SET_VOLUME << IPC_STG_TYPE_SHIFT);
940 header |= (stage_id << IPC_STG_ID_SHIFT); 944 request.header |= (stage_id << IPC_STG_ID_SHIFT);
941 945
942 req.curve_duration = hsw->curve_duration; 946 req.curve_duration = hsw->curve_duration;
943 req.curve_type = hsw->curve_type; 947 req.curve_type = hsw->curve_type;
944 req.target_volume = volume; 948 req.target_volume = volume;
945 949
946 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, &req, 950 request.data = &req;
947 sizeof(req), NULL, 0); 951 request.size = sizeof(req);
952 ret = sst_ipc_tx_message_wait(&hsw->ipc, request, NULL);
948 if (ret < 0) { 953 if (ret < 0) {
949 dev_err(hsw->dev, "error: set mixer volume failed\n"); 954 dev_err(hsw->dev, "error: set mixer volume failed\n");
950 return ret; 955 return ret;
@@ -983,7 +988,7 @@ struct sst_hsw_stream *sst_hsw_stream_new(struct sst_hsw *hsw, int id,
983 988
984int sst_hsw_stream_free(struct sst_hsw *hsw, struct sst_hsw_stream *stream) 989int sst_hsw_stream_free(struct sst_hsw *hsw, struct sst_hsw_stream *stream)
985{ 990{
986 u32 header; 991 struct sst_ipc_message request;
987 int ret = 0; 992 int ret = 0;
988 struct sst_dsp *sst = hsw->dsp; 993 struct sst_dsp *sst = hsw->dsp;
989 unsigned long flags; 994 unsigned long flags;
@@ -1000,10 +1005,11 @@ int sst_hsw_stream_free(struct sst_hsw *hsw, struct sst_hsw_stream *stream)
1000 trace_ipc_request("stream free", stream->host_id); 1005 trace_ipc_request("stream free", stream->host_id);
1001 1006
1002 stream->free_req.stream_id = stream->reply.stream_hw_id; 1007 stream->free_req.stream_id = stream->reply.stream_hw_id;
1003 header = IPC_GLB_TYPE(IPC_GLB_FREE_STREAM); 1008 request.header = IPC_GLB_TYPE(IPC_GLB_FREE_STREAM);
1009 request.data = &stream->free_req;
1010 request.size = sizeof(stream->free_req);
1004 1011
1005 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, &stream->free_req, 1012 ret = sst_ipc_tx_message_wait(&hsw->ipc, request, NULL);
1006 sizeof(stream->free_req), NULL, 0);
1007 if (ret < 0) { 1013 if (ret < 0) {
1008 dev_err(hsw->dev, "error: free stream %d failed\n", 1014 dev_err(hsw->dev, "error: free stream %d failed\n",
1009 stream->free_req.stream_id); 1015 stream->free_req.stream_id);
@@ -1175,9 +1181,7 @@ int sst_hsw_stream_set_module_info(struct sst_hsw *hsw,
1175 1181
1176int sst_hsw_stream_commit(struct sst_hsw *hsw, struct sst_hsw_stream *stream) 1182int sst_hsw_stream_commit(struct sst_hsw *hsw, struct sst_hsw_stream *stream)
1177{ 1183{
1178 struct sst_hsw_ipc_stream_alloc_req *str_req = &stream->request; 1184 struct sst_ipc_message request, reply = {0};
1179 struct sst_hsw_ipc_stream_alloc_reply *reply = &stream->reply;
1180 u32 header;
1181 int ret; 1185 int ret;
1182 1186
1183 if (!stream) { 1187 if (!stream) {
@@ -1192,10 +1196,13 @@ int sst_hsw_stream_commit(struct sst_hsw *hsw, struct sst_hsw_stream *stream)
1192 1196
1193 trace_ipc_request("stream alloc", stream->host_id); 1197 trace_ipc_request("stream alloc", stream->host_id);
1194 1198
1195 header = IPC_GLB_TYPE(IPC_GLB_ALLOCATE_STREAM); 1199 request.header = IPC_GLB_TYPE(IPC_GLB_ALLOCATE_STREAM);
1200 request.data = &stream->request;
1201 request.size = sizeof(stream->request);
1202 reply.data = &stream->reply;
1203 reply.size = sizeof(stream->reply);
1196 1204
1197 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, str_req, 1205 ret = sst_ipc_tx_message_wait(&hsw->ipc, request, &reply);
1198 sizeof(*str_req), reply, sizeof(*reply));
1199 if (ret < 0) { 1206 if (ret < 0) {
1200 dev_err(hsw->dev, "error: stream commit failed\n"); 1207 dev_err(hsw->dev, "error: stream commit failed\n");
1201 return ret; 1208 return ret;
@@ -1235,23 +1242,22 @@ void sst_hsw_stream_set_silence_start(struct sst_hsw *hsw,
1235 ABI to be opaque to client PCM drivers to cope with any future ABI changes */ 1242 ABI to be opaque to client PCM drivers to cope with any future ABI changes */
1236int sst_hsw_mixer_get_info(struct sst_hsw *hsw) 1243int sst_hsw_mixer_get_info(struct sst_hsw *hsw)
1237{ 1244{
1238 struct sst_hsw_ipc_stream_info_reply *reply; 1245 struct sst_ipc_message request = {0}, reply = {0};
1239 u32 header;
1240 int ret; 1246 int ret;
1241 1247
1242 reply = &hsw->mixer_info; 1248 request.header = IPC_GLB_TYPE(IPC_GLB_GET_MIXER_STREAM_INFO);
1243 header = IPC_GLB_TYPE(IPC_GLB_GET_MIXER_STREAM_INFO); 1249 reply.data = &hsw->mixer_info;
1250 reply.size = sizeof(hsw->mixer_info);
1244 1251
1245 trace_ipc_request("get global mixer info", 0); 1252 trace_ipc_request("get global mixer info", 0);
1246 1253
1247 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, NULL, 0, 1254 ret = sst_ipc_tx_message_wait(&hsw->ipc, request, &reply);
1248 reply, sizeof(*reply));
1249 if (ret < 0) { 1255 if (ret < 0) {
1250 dev_err(hsw->dev, "error: get stream info failed\n"); 1256 dev_err(hsw->dev, "error: get stream info failed\n");
1251 return ret; 1257 return ret;
1252 } 1258 }
1253 1259
1254 trace_hsw_mixer_info_reply(reply); 1260 trace_hsw_mixer_info_reply(&hsw->mixer_info);
1255 1261
1256 return 0; 1262 return 0;
1257} 1263}
@@ -1260,16 +1266,15 @@ int sst_hsw_mixer_get_info(struct sst_hsw *hsw)
1260static int sst_hsw_stream_operations(struct sst_hsw *hsw, int type, 1266static int sst_hsw_stream_operations(struct sst_hsw *hsw, int type,
1261 int stream_id, int wait) 1267 int stream_id, int wait)
1262{ 1268{
1263 u32 header; 1269 struct sst_ipc_message request = {0};
1264 1270
1265 header = IPC_GLB_TYPE(IPC_GLB_STREAM_MESSAGE) | IPC_STR_TYPE(type); 1271 request.header = IPC_GLB_TYPE(IPC_GLB_STREAM_MESSAGE);
1266 header |= (stream_id << IPC_STR_ID_SHIFT); 1272 request.header |= IPC_STR_TYPE(type) | (stream_id << IPC_STR_ID_SHIFT);
1267 1273
1268 if (wait) 1274 if (wait)
1269 return sst_ipc_tx_message_wait(&hsw->ipc, header, 1275 return sst_ipc_tx_message_wait(&hsw->ipc, request, NULL);
1270 NULL, 0, NULL, 0);
1271 else 1276 else
1272 return sst_ipc_tx_message_nowait(&hsw->ipc, header, NULL, 0); 1277 return sst_ipc_tx_message_nowait(&hsw->ipc, request);
1273} 1278}
1274 1279
1275/* Stream ALSA trigger operations */ 1280/* Stream ALSA trigger operations */
@@ -1377,8 +1382,8 @@ int sst_hsw_device_set_config(struct sst_hsw *hsw,
1377 enum sst_hsw_device_id dev, enum sst_hsw_device_mclk mclk, 1382 enum sst_hsw_device_id dev, enum sst_hsw_device_mclk mclk,
1378 enum sst_hsw_device_mode mode, u32 clock_divider) 1383 enum sst_hsw_device_mode mode, u32 clock_divider)
1379{ 1384{
1385 struct sst_ipc_message request;
1380 struct sst_hsw_ipc_device_config_req config; 1386 struct sst_hsw_ipc_device_config_req config;
1381 u32 header;
1382 int ret; 1387 int ret;
1383 1388
1384 trace_ipc_request("set device config", dev); 1389 trace_ipc_request("set device config", dev);
@@ -1394,10 +1399,11 @@ int sst_hsw_device_set_config(struct sst_hsw *hsw,
1394 1399
1395 trace_hsw_device_config_req(&config); 1400 trace_hsw_device_config_req(&config);
1396 1401
1397 header = IPC_GLB_TYPE(IPC_GLB_SET_DEVICE_FORMATS); 1402 request.header = IPC_GLB_TYPE(IPC_GLB_SET_DEVICE_FORMATS);
1403 request.data = &config;
1404 request.size = sizeof(config);
1398 1405
1399 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, &config, 1406 ret = sst_ipc_tx_message_wait(&hsw->ipc, request, NULL);
1400 sizeof(config), NULL, 0);
1401 if (ret < 0) 1407 if (ret < 0)
1402 dev_err(hsw->dev, "error: set device formats failed\n"); 1408 dev_err(hsw->dev, "error: set device formats failed\n");
1403 1409
@@ -1409,16 +1415,20 @@ EXPORT_SYMBOL_GPL(sst_hsw_device_set_config);
1409int sst_hsw_dx_set_state(struct sst_hsw *hsw, 1415int sst_hsw_dx_set_state(struct sst_hsw *hsw,
1410 enum sst_hsw_dx_state state, struct sst_hsw_ipc_dx_reply *dx) 1416 enum sst_hsw_dx_state state, struct sst_hsw_ipc_dx_reply *dx)
1411{ 1417{
1412 u32 header, state_; 1418 struct sst_ipc_message request, reply = {0};
1419 u32 state_;
1413 int ret, item; 1420 int ret, item;
1414 1421
1415 header = IPC_GLB_TYPE(IPC_GLB_ENTER_DX_STATE);
1416 state_ = state; 1422 state_ = state;
1423 request.header = IPC_GLB_TYPE(IPC_GLB_ENTER_DX_STATE);
1424 request.data = &state_;
1425 request.size = sizeof(state_);
1426 reply.data = dx;
1427 reply.size = sizeof(*dx);
1417 1428
1418 trace_ipc_request("PM enter Dx state", state); 1429 trace_ipc_request("PM enter Dx state", state);
1419 1430
1420 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, &state_, 1431 ret = sst_ipc_tx_message_wait(&hsw->ipc, request, &reply);
1421 sizeof(state_), dx, sizeof(*dx));
1422 if (ret < 0) { 1432 if (ret < 0) {
1423 dev_err(hsw->dev, "ipc: error set dx state %d failed\n", state); 1433 dev_err(hsw->dev, "ipc: error set dx state %d failed\n", state);
1424 return ret; 1434 return ret;
@@ -1878,7 +1888,7 @@ int sst_hsw_module_enable(struct sst_hsw *hsw,
1878 u32 module_id, u32 instance_id) 1888 u32 module_id, u32 instance_id)
1879{ 1889{
1880 int ret; 1890 int ret;
1881 u32 header = 0; 1891 struct sst_ipc_message request;
1882 struct sst_hsw_ipc_module_config config; 1892 struct sst_hsw_ipc_module_config config;
1883 struct sst_module *module; 1893 struct sst_module *module;
1884 struct sst_module_runtime *runtime; 1894 struct sst_module_runtime *runtime;
@@ -1907,10 +1917,10 @@ int sst_hsw_module_enable(struct sst_hsw *hsw,
1907 return -ENXIO; 1917 return -ENXIO;
1908 } 1918 }
1909 1919
1910 header = IPC_GLB_TYPE(IPC_GLB_MODULE_OPERATION) | 1920 request.header = IPC_GLB_TYPE(IPC_GLB_MODULE_OPERATION) |
1911 IPC_MODULE_OPERATION(IPC_MODULE_ENABLE) | 1921 IPC_MODULE_OPERATION(IPC_MODULE_ENABLE) |
1912 IPC_MODULE_ID(module_id); 1922 IPC_MODULE_ID(module_id);
1913 dev_dbg(dev, "module enable header: %x\n", header); 1923 dev_dbg(dev, "module enable header: %x\n", (u32)request.header);
1914 1924
1915 config.map.module_entries_count = 1; 1925 config.map.module_entries_count = 1;
1916 config.map.module_entries[0].module_id = module->id; 1926 config.map.module_entries[0].module_id = module->id;
@@ -1932,8 +1942,9 @@ int sst_hsw_module_enable(struct sst_hsw *hsw,
1932 config.scratch_mem.size, config.scratch_mem.offset, 1942 config.scratch_mem.size, config.scratch_mem.offset,
1933 config.map.module_entries[0].entry_point); 1943 config.map.module_entries[0].entry_point);
1934 1944
1935 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, 1945 request.data = &config;
1936 &config, sizeof(config), NULL, 0); 1946 request.size = sizeof(config);
1947 ret = sst_ipc_tx_message_wait(&hsw->ipc, request, NULL);
1937 if (ret < 0) 1948 if (ret < 0)
1938 dev_err(dev, "ipc: module enable failed - %d\n", ret); 1949 dev_err(dev, "ipc: module enable failed - %d\n", ret);
1939 else 1950 else
@@ -1946,7 +1957,7 @@ int sst_hsw_module_disable(struct sst_hsw *hsw,
1946 u32 module_id, u32 instance_id) 1957 u32 module_id, u32 instance_id)
1947{ 1958{
1948 int ret; 1959 int ret;
1949 u32 header; 1960 struct sst_ipc_message request = {0};
1950 struct sst_module *module; 1961 struct sst_module *module;
1951 struct device *dev = hsw->dev; 1962 struct device *dev = hsw->dev;
1952 struct sst_dsp *dsp = hsw->dsp; 1963 struct sst_dsp *dsp = hsw->dsp;
@@ -1967,11 +1978,11 @@ int sst_hsw_module_disable(struct sst_hsw *hsw,
1967 return -ENXIO; 1978 return -ENXIO;
1968 } 1979 }
1969 1980
1970 header = IPC_GLB_TYPE(IPC_GLB_MODULE_OPERATION) | 1981 request.header = IPC_GLB_TYPE(IPC_GLB_MODULE_OPERATION) |
1971 IPC_MODULE_OPERATION(IPC_MODULE_DISABLE) | 1982 IPC_MODULE_OPERATION(IPC_MODULE_DISABLE) |
1972 IPC_MODULE_ID(module_id); 1983 IPC_MODULE_ID(module_id);
1973 1984
1974 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, NULL, 0, NULL, 0); 1985 ret = sst_ipc_tx_message_wait(&hsw->ipc, request, NULL);
1975 if (ret < 0) 1986 if (ret < 0)
1976 dev_err(dev, "module disable failed - %d\n", ret); 1987 dev_err(dev, "module disable failed - %d\n", ret);
1977 else 1988 else
@@ -1985,15 +1996,16 @@ int sst_hsw_module_set_param(struct sst_hsw *hsw,
1985 u32 param_size, char *param) 1996 u32 param_size, char *param)
1986{ 1997{
1987 int ret; 1998 int ret;
1988 u32 header = 0; 1999 struct sst_ipc_message request = {0};
1989 u32 payload_size = 0, transfer_parameter_size = 0; 2000 u32 payload_size = 0;
1990 struct sst_hsw_transfer_parameter *parameter; 2001 struct sst_hsw_transfer_parameter *parameter;
1991 struct device *dev = hsw->dev; 2002 struct device *dev = hsw->dev;
1992 2003
1993 header = IPC_GLB_TYPE(IPC_GLB_MODULE_OPERATION) | 2004 request.header = IPC_GLB_TYPE(IPC_GLB_MODULE_OPERATION) |
1994 IPC_MODULE_OPERATION(IPC_MODULE_SET_PARAMETER) | 2005 IPC_MODULE_OPERATION(IPC_MODULE_SET_PARAMETER) |
1995 IPC_MODULE_ID(module_id); 2006 IPC_MODULE_ID(module_id);
1996 dev_dbg(dev, "sst_hsw_module_set_param header=%x\n", header); 2007 dev_dbg(dev, "sst_hsw_module_set_param header=%x\n",
2008 (u32)request.header);
1997 2009
1998 payload_size = param_size + 2010 payload_size = param_size +
1999 sizeof(struct sst_hsw_transfer_parameter) - 2011 sizeof(struct sst_hsw_transfer_parameter) -
@@ -2003,14 +2015,14 @@ int sst_hsw_module_set_param(struct sst_hsw *hsw,
2003 2015
2004 if (payload_size <= SST_HSW_IPC_MAX_SHORT_PARAMETER_SIZE) { 2016 if (payload_size <= SST_HSW_IPC_MAX_SHORT_PARAMETER_SIZE) {
2005 /* short parameter, mailbox can contain data */ 2017 /* short parameter, mailbox can contain data */
2006 dev_dbg(dev, "transfer parameter size : %d\n", 2018 dev_dbg(dev, "transfer parameter size : %zu\n",
2007 transfer_parameter_size); 2019 request.size);
2008 2020
2009 transfer_parameter_size = ALIGN(payload_size, 4); 2021 request.size = ALIGN(payload_size, 4);
2010 dev_dbg(dev, "transfer parameter aligned size : %d\n", 2022 dev_dbg(dev, "transfer parameter aligned size : %zu\n",
2011 transfer_parameter_size); 2023 request.size);
2012 2024
2013 parameter = kzalloc(transfer_parameter_size, GFP_KERNEL); 2025 parameter = kzalloc(request.size, GFP_KERNEL);
2014 if (parameter == NULL) 2026 if (parameter == NULL)
2015 return -ENOMEM; 2027 return -ENOMEM;
2016 2028
@@ -2022,9 +2034,9 @@ int sst_hsw_module_set_param(struct sst_hsw *hsw,
2022 2034
2023 parameter->parameter_id = parameter_id; 2035 parameter->parameter_id = parameter_id;
2024 parameter->data_size = param_size; 2036 parameter->data_size = param_size;
2037 request.data = parameter;
2025 2038
2026 ret = sst_ipc_tx_message_wait(&hsw->ipc, header, 2039 ret = sst_ipc_tx_message_wait(&hsw->ipc, request, NULL);
2027 parameter, transfer_parameter_size , NULL, 0);
2028 if (ret < 0) 2040 if (ret < 0)
2029 dev_err(dev, "ipc: module set parameter failed - %d\n", ret); 2041 dev_err(dev, "ipc: module set parameter failed - %d\n", ret);
2030 2042
@@ -2041,8 +2053,8 @@ static struct sst_dsp_device hsw_dev = {
2041static void hsw_tx_msg(struct sst_generic_ipc *ipc, struct ipc_message *msg) 2053static void hsw_tx_msg(struct sst_generic_ipc *ipc, struct ipc_message *msg)
2042{ 2054{
2043 /* send the message */ 2055 /* send the message */
2044 sst_dsp_outbox_write(ipc->dsp, msg->tx_data, msg->tx_size); 2056 sst_dsp_outbox_write(ipc->dsp, msg->tx.data, msg->tx.size);
2045 sst_dsp_ipc_msg_tx(ipc->dsp, msg->header); 2057 sst_dsp_ipc_msg_tx(ipc->dsp, msg->tx.header);
2046} 2058}
2047 2059
2048static void hsw_shim_dbg(struct sst_generic_ipc *ipc, const char *text) 2060static void hsw_shim_dbg(struct sst_generic_ipc *ipc, const char *text)
@@ -2063,7 +2075,7 @@ static void hsw_shim_dbg(struct sst_generic_ipc *ipc, const char *text)
2063static void hsw_tx_data_copy(struct ipc_message *msg, char *tx_data, 2075static void hsw_tx_data_copy(struct ipc_message *msg, char *tx_data,
2064 size_t tx_size) 2076 size_t tx_size)
2065{ 2077{
2066 memcpy(msg->tx_data, tx_data, tx_size); 2078 memcpy(msg->tx.data, tx_data, tx_size);
2067} 2079}
2068 2080
2069static u64 hsw_reply_msg_match(u64 header, u64 *mask) 2081static u64 hsw_reply_msg_match(u64 header, u64 *mask)
diff --git a/sound/soc/intel/skylake/Makefile b/sound/soc/intel/skylake/Makefile
index 86f6e1d801af..48544ff1a3e6 100644
--- a/sound/soc/intel/skylake/Makefile
+++ b/sound/soc/intel/skylake/Makefile
@@ -1,6 +1,7 @@
1# SPDX-License-Identifier: GPL-2.0 1# SPDX-License-Identifier: GPL-2.0
2snd-soc-skl-objs := skl.o skl-pcm.o skl-nhlt.o skl-messages.o \ 2snd-soc-skl-objs := skl.o skl-pcm.o skl-nhlt.o skl-messages.o skl-topology.o \
3skl-topology.o 3 skl-sst-ipc.o skl-sst-dsp.o cnl-sst-dsp.o skl-sst-cldma.o \
4 skl-sst.o bxt-sst.o cnl-sst.o skl-sst-utils.o
4 5
5ifdef CONFIG_DEBUG_FS 6ifdef CONFIG_DEBUG_FS
6 snd-soc-skl-objs += skl-debug.o 7 snd-soc-skl-objs += skl-debug.o
@@ -8,13 +9,6 @@ endif
8 9
9obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o 10obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl.o
10 11
11# Skylake IPC Support
12snd-soc-skl-ipc-objs := skl-sst-ipc.o skl-sst-dsp.o cnl-sst-dsp.o \
13 skl-sst-cldma.o skl-sst.o bxt-sst.o cnl-sst.o \
14 skl-sst-utils.o
15
16obj-$(CONFIG_SND_SOC_INTEL_SKYLAKE) += snd-soc-skl-ipc.o
17
18#Skylake Clock device support 12#Skylake Clock device support
19snd-soc-skl-ssp-clk-objs := skl-ssp-clk.o 13snd-soc-skl-ssp-clk-objs := skl-ssp-clk.o
20 14
diff --git a/sound/soc/intel/skylake/bxt-sst.c b/sound/soc/intel/skylake/bxt-sst.c
index 46d5159cf905..92a82e6b5fe6 100644
--- a/sound/soc/intel/skylake/bxt-sst.c
+++ b/sound/soc/intel/skylake/bxt-sst.c
@@ -14,7 +14,7 @@
14 14
15#include "../common/sst-dsp.h" 15#include "../common/sst-dsp.h"
16#include "../common/sst-dsp-priv.h" 16#include "../common/sst-dsp-priv.h"
17#include "skl-sst-ipc.h" 17#include "skl.h"
18 18
19#define BXT_BASEFW_TIMEOUT 3000 19#define BXT_BASEFW_TIMEOUT 3000
20#define BXT_INIT_TIMEOUT 300 20#define BXT_INIT_TIMEOUT 300
@@ -49,7 +49,7 @@ static int
49bxt_load_library(struct sst_dsp *ctx, struct skl_lib_info *linfo, int lib_count) 49bxt_load_library(struct sst_dsp *ctx, struct skl_lib_info *linfo, int lib_count)
50{ 50{
51 struct snd_dma_buffer dmab; 51 struct snd_dma_buffer dmab;
52 struct skl_sst *skl = ctx->thread_context; 52 struct skl_dev *skl = ctx->thread_context;
53 struct firmware stripped_fw; 53 struct firmware stripped_fw;
54 int ret = 0, i, dma_id, stream_tag; 54 int ret = 0, i, dma_id, stream_tag;
55 55
@@ -184,7 +184,7 @@ static int sst_transfer_fw_host_dma(struct sst_dsp *ctx)
184static int bxt_load_base_firmware(struct sst_dsp *ctx) 184static int bxt_load_base_firmware(struct sst_dsp *ctx)
185{ 185{
186 struct firmware stripped_fw; 186 struct firmware stripped_fw;
187 struct skl_sst *skl = ctx->thread_context; 187 struct skl_dev *skl = ctx->thread_context;
188 int ret, i; 188 int ret, i;
189 189
190 if (ctx->fw == NULL) { 190 if (ctx->fw == NULL) {
@@ -268,7 +268,7 @@ sst_load_base_firmware_failed:
268 */ 268 */
269static int bxt_d0i3_target_state(struct sst_dsp *ctx) 269static int bxt_d0i3_target_state(struct sst_dsp *ctx)
270{ 270{
271 struct skl_sst *skl = ctx->thread_context; 271 struct skl_dev *skl = ctx->thread_context;
272 struct skl_d0i3_data *d0i3 = &skl->d0i3; 272 struct skl_d0i3_data *d0i3 = &skl->d0i3;
273 273
274 if (skl->cores.state[SKL_DSP_CORE0_ID] != SKL_DSP_RUNNING) 274 if (skl->cores.state[SKL_DSP_CORE0_ID] != SKL_DSP_RUNNING)
@@ -288,8 +288,8 @@ static void bxt_set_dsp_D0i3(struct work_struct *work)
288{ 288{
289 int ret; 289 int ret;
290 struct skl_ipc_d0ix_msg msg; 290 struct skl_ipc_d0ix_msg msg;
291 struct skl_sst *skl = container_of(work, 291 struct skl_dev *skl = container_of(work,
292 struct skl_sst, d0i3.work.work); 292 struct skl_dev, d0i3.work.work);
293 struct sst_dsp *ctx = skl->dsp; 293 struct sst_dsp *ctx = skl->dsp;
294 struct skl_d0i3_data *d0i3 = &skl->d0i3; 294 struct skl_d0i3_data *d0i3 = &skl->d0i3;
295 int target_state; 295 int target_state;
@@ -331,7 +331,7 @@ static void bxt_set_dsp_D0i3(struct work_struct *work)
331 331
332static int bxt_schedule_dsp_D0i3(struct sst_dsp *ctx) 332static int bxt_schedule_dsp_D0i3(struct sst_dsp *ctx)
333{ 333{
334 struct skl_sst *skl = ctx->thread_context; 334 struct skl_dev *skl = ctx->thread_context;
335 struct skl_d0i3_data *d0i3 = &skl->d0i3; 335 struct skl_d0i3_data *d0i3 = &skl->d0i3;
336 336
337 /* Schedule D0i3 only if the usecase ref counts are appropriate */ 337 /* Schedule D0i3 only if the usecase ref counts are appropriate */
@@ -350,7 +350,7 @@ static int bxt_set_dsp_D0i0(struct sst_dsp *ctx)
350{ 350{
351 int ret; 351 int ret;
352 struct skl_ipc_d0ix_msg msg; 352 struct skl_ipc_d0ix_msg msg;
353 struct skl_sst *skl = ctx->thread_context; 353 struct skl_dev *skl = ctx->thread_context;
354 354
355 dev_dbg(ctx->dev, "In %s:\n", __func__); 355 dev_dbg(ctx->dev, "In %s:\n", __func__);
356 356
@@ -389,7 +389,7 @@ static int bxt_set_dsp_D0i0(struct sst_dsp *ctx)
389 389
390static int bxt_set_dsp_D0(struct sst_dsp *ctx, unsigned int core_id) 390static int bxt_set_dsp_D0(struct sst_dsp *ctx, unsigned int core_id)
391{ 391{
392 struct skl_sst *skl = ctx->thread_context; 392 struct skl_dev *skl = ctx->thread_context;
393 int ret; 393 int ret;
394 struct skl_ipc_dxstate_info dx; 394 struct skl_ipc_dxstate_info dx;
395 unsigned int core_mask = SKL_DSP_CORE_MASK(core_id); 395 unsigned int core_mask = SKL_DSP_CORE_MASK(core_id);
@@ -486,7 +486,7 @@ static int bxt_set_dsp_D3(struct sst_dsp *ctx, unsigned int core_id)
486{ 486{
487 int ret; 487 int ret;
488 struct skl_ipc_dxstate_info dx; 488 struct skl_ipc_dxstate_info dx;
489 struct skl_sst *skl = ctx->thread_context; 489 struct skl_dev *skl = ctx->thread_context;
490 unsigned int core_mask = SKL_DSP_CORE_MASK(core_id); 490 unsigned int core_mask = SKL_DSP_CORE_MASK(core_id);
491 491
492 dx.core_mask = core_mask; 492 dx.core_mask = core_mask;
@@ -548,9 +548,9 @@ static struct sst_dsp_device skl_dev = {
548 548
549int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq, 549int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
550 const char *fw_name, struct skl_dsp_loader_ops dsp_ops, 550 const char *fw_name, struct skl_dsp_loader_ops dsp_ops,
551 struct skl_sst **dsp) 551 struct skl_dev **dsp)
552{ 552{
553 struct skl_sst *skl; 553 struct skl_dev *skl;
554 struct sst_dsp *sst; 554 struct sst_dsp *sst;
555 int ret; 555 int ret;
556 556
@@ -591,10 +591,10 @@ int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
591} 591}
592EXPORT_SYMBOL_GPL(bxt_sst_dsp_init); 592EXPORT_SYMBOL_GPL(bxt_sst_dsp_init);
593 593
594int bxt_sst_init_fw(struct device *dev, struct skl_sst *ctx) 594int bxt_sst_init_fw(struct device *dev, struct skl_dev *skl)
595{ 595{
596 int ret; 596 int ret;
597 struct sst_dsp *sst = ctx->dsp; 597 struct sst_dsp *sst = skl->dsp;
598 598
599 ret = sst->fw_ops.load_fw(sst); 599 ret = sst->fw_ops.load_fw(sst);
600 if (ret < 0) { 600 if (ret < 0) {
@@ -604,29 +604,29 @@ int bxt_sst_init_fw(struct device *dev, struct skl_sst *ctx)
604 604
605 skl_dsp_init_core_state(sst); 605 skl_dsp_init_core_state(sst);
606 606
607 if (ctx->lib_count > 1) { 607 if (skl->lib_count > 1) {
608 ret = sst->fw_ops.load_library(sst, ctx->lib_info, 608 ret = sst->fw_ops.load_library(sst, skl->lib_info,
609 ctx->lib_count); 609 skl->lib_count);
610 if (ret < 0) { 610 if (ret < 0) {
611 dev_err(dev, "Load Library failed : %x\n", ret); 611 dev_err(dev, "Load Library failed : %x\n", ret);
612 return ret; 612 return ret;
613 } 613 }
614 } 614 }
615 ctx->is_first_boot = false; 615 skl->is_first_boot = false;
616 616
617 return 0; 617 return 0;
618} 618}
619EXPORT_SYMBOL_GPL(bxt_sst_init_fw); 619EXPORT_SYMBOL_GPL(bxt_sst_init_fw);
620 620
621void bxt_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx) 621void bxt_sst_dsp_cleanup(struct device *dev, struct skl_dev *skl)
622{ 622{
623 623
624 skl_release_library(ctx->lib_info, ctx->lib_count); 624 skl_release_library(skl->lib_info, skl->lib_count);
625 if (ctx->dsp->fw) 625 if (skl->dsp->fw)
626 release_firmware(ctx->dsp->fw); 626 release_firmware(skl->dsp->fw);
627 skl_freeup_uuid_list(ctx); 627 skl_freeup_uuid_list(skl);
628 skl_ipc_free(&ctx->ipc); 628 skl_ipc_free(&skl->ipc);
629 ctx->dsp->ops->free(ctx->dsp); 629 skl->dsp->ops->free(skl->dsp);
630} 630}
631EXPORT_SYMBOL_GPL(bxt_sst_dsp_cleanup); 631EXPORT_SYMBOL_GPL(bxt_sst_dsp_cleanup);
632 632
diff --git a/sound/soc/intel/skylake/cnl-sst-dsp.h b/sound/soc/intel/skylake/cnl-sst-dsp.h
index 426515faab52..7bd4d2a8fdfa 100644
--- a/sound/soc/intel/skylake/cnl-sst-dsp.h
+++ b/sound/soc/intel/skylake/cnl-sst-dsp.h
@@ -9,7 +9,6 @@
9#define __CNL_SST_DSP_H__ 9#define __CNL_SST_DSP_H__
10 10
11struct sst_dsp; 11struct sst_dsp;
12struct skl_sst;
13struct sst_dsp_device; 12struct sst_dsp_device;
14struct sst_generic_ipc; 13struct sst_generic_ipc;
15 14
@@ -97,8 +96,8 @@ void cnl_ipc_free(struct sst_generic_ipc *ipc);
97 96
98int cnl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq, 97int cnl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
99 const char *fw_name, struct skl_dsp_loader_ops dsp_ops, 98 const char *fw_name, struct skl_dsp_loader_ops dsp_ops,
100 struct skl_sst **dsp); 99 struct skl_dev **dsp);
101int cnl_sst_init_fw(struct device *dev, struct skl_sst *ctx); 100int cnl_sst_init_fw(struct device *dev, struct skl_dev *skl);
102void cnl_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx); 101void cnl_sst_dsp_cleanup(struct device *dev, struct skl_dev *skl);
103 102
104#endif /*__CNL_SST_DSP_H__*/ 103#endif /*__CNL_SST_DSP_H__*/
diff --git a/sound/soc/intel/skylake/cnl-sst.c b/sound/soc/intel/skylake/cnl-sst.c
index f2c09fa6ea40..4f64f097e9ae 100644
--- a/sound/soc/intel/skylake/cnl-sst.c
+++ b/sound/soc/intel/skylake/cnl-sst.c
@@ -24,8 +24,7 @@
24#include "../common/sst-dsp-priv.h" 24#include "../common/sst-dsp-priv.h"
25#include "../common/sst-ipc.h" 25#include "../common/sst-ipc.h"
26#include "cnl-sst-dsp.h" 26#include "cnl-sst-dsp.h"
27#include "skl-sst-dsp.h" 27#include "skl.h"
28#include "skl-sst-ipc.h"
29 28
30#define CNL_FW_ROM_INIT 0x1 29#define CNL_FW_ROM_INIT 0x1
31#define CNL_FW_INIT 0x5 30#define CNL_FW_INIT 0x5
@@ -109,7 +108,7 @@ static int sst_transfer_fw_host_dma(struct sst_dsp *ctx)
109static int cnl_load_base_firmware(struct sst_dsp *ctx) 108static int cnl_load_base_firmware(struct sst_dsp *ctx)
110{ 109{
111 struct firmware stripped_fw; 110 struct firmware stripped_fw;
112 struct skl_sst *cnl = ctx->thread_context; 111 struct skl_dev *cnl = ctx->thread_context;
113 int ret; 112 int ret;
114 113
115 if (!ctx->fw) { 114 if (!ctx->fw) {
@@ -167,7 +166,7 @@ cnl_load_base_firmware_failed:
167 166
168static int cnl_set_dsp_D0(struct sst_dsp *ctx, unsigned int core_id) 167static int cnl_set_dsp_D0(struct sst_dsp *ctx, unsigned int core_id)
169{ 168{
170 struct skl_sst *cnl = ctx->thread_context; 169 struct skl_dev *cnl = ctx->thread_context;
171 unsigned int core_mask = SKL_DSP_CORE_MASK(core_id); 170 unsigned int core_mask = SKL_DSP_CORE_MASK(core_id);
172 struct skl_ipc_dxstate_info dx; 171 struct skl_ipc_dxstate_info dx;
173 int ret; 172 int ret;
@@ -229,7 +228,7 @@ err:
229 228
230static int cnl_set_dsp_D3(struct sst_dsp *ctx, unsigned int core_id) 229static int cnl_set_dsp_D3(struct sst_dsp *ctx, unsigned int core_id)
231{ 230{
232 struct skl_sst *cnl = ctx->thread_context; 231 struct skl_dev *cnl = ctx->thread_context;
233 unsigned int core_mask = SKL_DSP_CORE_MASK(core_id); 232 unsigned int core_mask = SKL_DSP_CORE_MASK(core_id);
234 struct skl_ipc_dxstate_info dx; 233 struct skl_ipc_dxstate_info dx;
235 int ret; 234 int ret;
@@ -293,7 +292,7 @@ static struct sst_ops cnl_ops = {
293static irqreturn_t cnl_dsp_irq_thread_handler(int irq, void *context) 292static irqreturn_t cnl_dsp_irq_thread_handler(int irq, void *context)
294{ 293{
295 struct sst_dsp *dsp = context; 294 struct sst_dsp *dsp = context;
296 struct skl_sst *cnl = sst_dsp_get_thread_context(dsp); 295 struct skl_dev *cnl = sst_dsp_get_thread_context(dsp);
297 struct sst_generic_ipc *ipc = &cnl->ipc; 296 struct sst_generic_ipc *ipc = &cnl->ipc;
298 struct skl_ipc_header header = {0}; 297 struct skl_ipc_header header = {0};
299 u32 hipcida, hipctdr, hipctdd; 298 u32 hipcida, hipctdr, hipctdd;
@@ -367,10 +366,10 @@ static struct sst_dsp_device cnl_dev = {
367 366
368static void cnl_ipc_tx_msg(struct sst_generic_ipc *ipc, struct ipc_message *msg) 367static void cnl_ipc_tx_msg(struct sst_generic_ipc *ipc, struct ipc_message *msg)
369{ 368{
370 struct skl_ipc_header *header = (struct skl_ipc_header *)(&msg->header); 369 struct skl_ipc_header *header = (struct skl_ipc_header *)(&msg->tx.header);
371 370
372 if (msg->tx_size) 371 if (msg->tx.size)
373 sst_dsp_outbox_write(ipc->dsp, msg->tx_data, msg->tx_size); 372 sst_dsp_outbox_write(ipc->dsp, msg->tx.data, msg->tx.size);
374 sst_dsp_shim_write_unlocked(ipc->dsp, CNL_ADSP_REG_HIPCIDD, 373 sst_dsp_shim_write_unlocked(ipc->dsp, CNL_ADSP_REG_HIPCIDD,
375 header->extension); 374 header->extension);
376 sst_dsp_shim_write_unlocked(ipc->dsp, CNL_ADSP_REG_HIPCIDR, 375 sst_dsp_shim_write_unlocked(ipc->dsp, CNL_ADSP_REG_HIPCIDR,
@@ -386,7 +385,7 @@ static bool cnl_ipc_is_dsp_busy(struct sst_dsp *dsp)
386 return (hipcidr & CNL_ADSP_REG_HIPCIDR_BUSY); 385 return (hipcidr & CNL_ADSP_REG_HIPCIDR_BUSY);
387} 386}
388 387
389static int cnl_ipc_init(struct device *dev, struct skl_sst *cnl) 388static int cnl_ipc_init(struct device *dev, struct skl_dev *cnl)
390{ 389{
391 struct sst_generic_ipc *ipc; 390 struct sst_generic_ipc *ipc;
392 int err; 391 int err;
@@ -415,9 +414,9 @@ static int cnl_ipc_init(struct device *dev, struct skl_sst *cnl)
415 414
416int cnl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq, 415int cnl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
417 const char *fw_name, struct skl_dsp_loader_ops dsp_ops, 416 const char *fw_name, struct skl_dsp_loader_ops dsp_ops,
418 struct skl_sst **dsp) 417 struct skl_dev **dsp)
419{ 418{
420 struct skl_sst *cnl; 419 struct skl_dev *cnl;
421 struct sst_dsp *sst; 420 struct sst_dsp *sst;
422 int ret; 421 int ret;
423 422
@@ -454,12 +453,12 @@ int cnl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
454} 453}
455EXPORT_SYMBOL_GPL(cnl_sst_dsp_init); 454EXPORT_SYMBOL_GPL(cnl_sst_dsp_init);
456 455
457int cnl_sst_init_fw(struct device *dev, struct skl_sst *ctx) 456int cnl_sst_init_fw(struct device *dev, struct skl_dev *skl)
458{ 457{
459 int ret; 458 int ret;
460 struct sst_dsp *sst = ctx->dsp; 459 struct sst_dsp *sst = skl->dsp;
461 460
462 ret = ctx->dsp->fw_ops.load_fw(sst); 461 ret = skl->dsp->fw_ops.load_fw(sst);
463 if (ret < 0) { 462 if (ret < 0) {
464 dev_err(dev, "load base fw failed: %d", ret); 463 dev_err(dev, "load base fw failed: %d", ret);
465 return ret; 464 return ret;
@@ -467,21 +466,21 @@ int cnl_sst_init_fw(struct device *dev, struct skl_sst *ctx)
467 466
468 skl_dsp_init_core_state(sst); 467 skl_dsp_init_core_state(sst);
469 468
470 ctx->is_first_boot = false; 469 skl->is_first_boot = false;
471 470
472 return 0; 471 return 0;
473} 472}
474EXPORT_SYMBOL_GPL(cnl_sst_init_fw); 473EXPORT_SYMBOL_GPL(cnl_sst_init_fw);
475 474
476void cnl_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx) 475void cnl_sst_dsp_cleanup(struct device *dev, struct skl_dev *skl)
477{ 476{
478 if (ctx->dsp->fw) 477 if (skl->dsp->fw)
479 release_firmware(ctx->dsp->fw); 478 release_firmware(skl->dsp->fw);
480 479
481 skl_freeup_uuid_list(ctx); 480 skl_freeup_uuid_list(skl);
482 cnl_ipc_free(&ctx->ipc); 481 cnl_ipc_free(&skl->ipc);
483 482
484 ctx->dsp->ops->free(ctx->dsp); 483 skl->dsp->ops->free(skl->dsp);
485} 484}
486EXPORT_SYMBOL_GPL(cnl_sst_dsp_cleanup); 485EXPORT_SYMBOL_GPL(cnl_sst_dsp_cleanup);
487 486
diff --git a/sound/soc/intel/skylake/skl-debug.c b/sound/soc/intel/skylake/skl-debug.c
index b9b4a72a4334..3466675f2678 100644
--- a/sound/soc/intel/skylake/skl-debug.c
+++ b/sound/soc/intel/skylake/skl-debug.c
@@ -20,7 +20,7 @@
20#define FW_REG_SIZE 0x60 20#define FW_REG_SIZE 0x60
21 21
22struct skl_debug { 22struct skl_debug {
23 struct skl *skl; 23 struct skl_dev *skl;
24 struct device *dev; 24 struct device *dev;
25 25
26 struct dentry *fs; 26 struct dentry *fs;
@@ -66,6 +66,8 @@ static ssize_t module_read(struct file *file, char __user *user_buf,
66 size_t count, loff_t *ppos) 66 size_t count, loff_t *ppos)
67{ 67{
68 struct skl_module_cfg *mconfig = file->private_data; 68 struct skl_module_cfg *mconfig = file->private_data;
69 struct skl_module *module = mconfig->module;
70 struct skl_module_res *res = &module->resources[mconfig->res_idx];
69 char *buf; 71 char *buf;
70 ssize_t ret; 72 ssize_t ret;
71 73
@@ -79,8 +81,8 @@ static ssize_t module_read(struct file *file, char __user *user_buf,
79 mconfig->id.pvt_id); 81 mconfig->id.pvt_id);
80 82
81 ret += snprintf(buf + ret, MOD_BUF - ret, 83 ret += snprintf(buf + ret, MOD_BUF - ret,
82 "Resources:\n\tMCPS %#x\n\tIBS %#x\n\tOBS %#x\t\n", 84 "Resources:\n\tCPC %#x\n\tIBS %#x\n\tOBS %#x\t\n",
83 mconfig->mcps, mconfig->ibs, mconfig->obs); 85 res->cpc, res->ibs, res->obs);
84 86
85 ret += snprintf(buf + ret, MOD_BUF - ret, 87 ret += snprintf(buf + ret, MOD_BUF - ret,
86 "Module data:\n\tCore %d\n\tIn queue %d\n\t" 88 "Module data:\n\tCore %d\n\tIn queue %d\n\t"
@@ -162,17 +164,15 @@ void skl_debug_init_module(struct skl_debug *d,
162 struct snd_soc_dapm_widget *w, 164 struct snd_soc_dapm_widget *w,
163 struct skl_module_cfg *mconfig) 165 struct skl_module_cfg *mconfig)
164{ 166{
165 if (!debugfs_create_file(w->name, 0444, 167 debugfs_create_file(w->name, 0444, d->modules, mconfig,
166 d->modules, mconfig, 168 &mcfg_fops);
167 &mcfg_fops))
168 dev_err(d->dev, "%s: module debugfs init failed\n", w->name);
169} 169}
170 170
171static ssize_t fw_softreg_read(struct file *file, char __user *user_buf, 171static ssize_t fw_softreg_read(struct file *file, char __user *user_buf,
172 size_t count, loff_t *ppos) 172 size_t count, loff_t *ppos)
173{ 173{
174 struct skl_debug *d = file->private_data; 174 struct skl_debug *d = file->private_data;
175 struct sst_dsp *sst = d->skl->skl_sst->dsp; 175 struct sst_dsp *sst = d->skl->dsp;
176 size_t w0_stat_sz = sst->addr.w0_stat_sz; 176 size_t w0_stat_sz = sst->addr.w0_stat_sz;
177 void __iomem *in_base = sst->mailbox.in_base; 177 void __iomem *in_base = sst->mailbox.in_base;
178 void __iomem *fw_reg_addr; 178 void __iomem *fw_reg_addr;
@@ -188,7 +188,7 @@ static ssize_t fw_softreg_read(struct file *file, char __user *user_buf,
188 memset(d->fw_read_buff, 0, FW_REG_BUF); 188 memset(d->fw_read_buff, 0, FW_REG_BUF);
189 189
190 if (w0_stat_sz > 0) 190 if (w0_stat_sz > 0)
191 __iowrite32_copy(d->fw_read_buff, fw_reg_addr, w0_stat_sz >> 2); 191 __ioread32_copy(d->fw_read_buff, fw_reg_addr, w0_stat_sz >> 2);
192 192
193 for (offset = 0; offset < FW_REG_SIZE; offset += 16) { 193 for (offset = 0; offset < FW_REG_SIZE; offset += 16) {
194 ret += snprintf(tmp + ret, FW_REG_BUF - ret, "%#.4x: ", offset); 194 ret += snprintf(tmp + ret, FW_REG_BUF - ret, "%#.4x: ", offset);
@@ -213,7 +213,7 @@ static const struct file_operations soft_regs_ctrl_fops = {
213 .llseek = default_llseek, 213 .llseek = default_llseek,
214}; 214};
215 215
216struct skl_debug *skl_debugfs_init(struct skl *skl) 216struct skl_debug *skl_debugfs_init(struct skl_dev *skl)
217{ 217{
218 struct skl_debug *d; 218 struct skl_debug *d;
219 219
@@ -222,37 +222,21 @@ struct skl_debug *skl_debugfs_init(struct skl *skl)
222 return NULL; 222 return NULL;
223 223
224 /* create the debugfs dir with platform component's debugfs as parent */ 224 /* create the debugfs dir with platform component's debugfs as parent */
225 d->fs = debugfs_create_dir("dsp", 225 d->fs = debugfs_create_dir("dsp", skl->component->debugfs_root);
226 skl->component->debugfs_root);
227 if (IS_ERR(d->fs) || !d->fs) {
228 dev_err(&skl->pci->dev, "debugfs root creation failed\n");
229 return NULL;
230 }
231 226
232 d->skl = skl; 227 d->skl = skl;
233 d->dev = &skl->pci->dev; 228 d->dev = &skl->pci->dev;
234 229
235 /* now create the module dir */ 230 /* now create the module dir */
236 d->modules = debugfs_create_dir("modules", d->fs); 231 d->modules = debugfs_create_dir("modules", d->fs);
237 if (IS_ERR(d->modules) || !d->modules) {
238 dev_err(&skl->pci->dev, "modules debugfs create failed\n");
239 goto err;
240 }
241 232
242 if (!debugfs_create_file("fw_soft_regs_rd", 0444, d->fs, d, 233 debugfs_create_file("fw_soft_regs_rd", 0444, d->fs, d,
243 &soft_regs_ctrl_fops)) { 234 &soft_regs_ctrl_fops);
244 dev_err(d->dev, "fw soft regs control debugfs init failed\n");
245 goto err;
246 }
247 235
248 return d; 236 return d;
249
250err:
251 debugfs_remove_recursive(d->fs);
252 return NULL;
253} 237}
254 238
255void skl_debugfs_exit(struct skl *skl) 239void skl_debugfs_exit(struct skl_dev *skl)
256{ 240{
257 struct skl_debug *d = skl->debugfs; 241 struct skl_debug *d = skl->debugfs;
258 242
diff --git a/sound/soc/intel/skylake/skl-messages.c b/sound/soc/intel/skylake/skl-messages.c
index febc070839e0..476ef1897961 100644
--- a/sound/soc/intel/skylake/skl-messages.c
+++ b/sound/soc/intel/skylake/skl-messages.c
@@ -25,29 +25,18 @@
25static int skl_alloc_dma_buf(struct device *dev, 25static int skl_alloc_dma_buf(struct device *dev,
26 struct snd_dma_buffer *dmab, size_t size) 26 struct snd_dma_buffer *dmab, size_t size)
27{ 27{
28 struct hdac_bus *bus = dev_get_drvdata(dev); 28 return snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, dev, size, dmab);
29
30 if (!bus)
31 return -ENODEV;
32
33 return bus->io_ops->dma_alloc_pages(bus, SNDRV_DMA_TYPE_DEV, size, dmab);
34} 29}
35 30
36static int skl_free_dma_buf(struct device *dev, struct snd_dma_buffer *dmab) 31static int skl_free_dma_buf(struct device *dev, struct snd_dma_buffer *dmab)
37{ 32{
38 struct hdac_bus *bus = dev_get_drvdata(dev); 33 snd_dma_free_pages(dmab);
39
40 if (!bus)
41 return -ENODEV;
42
43 bus->io_ops->dma_free_pages(bus, dmab);
44
45 return 0; 34 return 0;
46} 35}
47 36
48#define SKL_ASTATE_PARAM_ID 4 37#define SKL_ASTATE_PARAM_ID 4
49 38
50void skl_dsp_set_astate_cfg(struct skl_sst *ctx, u32 cnt, void *data) 39void skl_dsp_set_astate_cfg(struct skl_dev *skl, u32 cnt, void *data)
51{ 40{
52 struct skl_ipc_large_config_msg msg = {0}; 41 struct skl_ipc_large_config_msg msg = {0};
53 42
@@ -55,25 +44,7 @@ void skl_dsp_set_astate_cfg(struct skl_sst *ctx, u32 cnt, void *data)
55 msg.param_data_size = (cnt * sizeof(struct skl_astate_param) + 44 msg.param_data_size = (cnt * sizeof(struct skl_astate_param) +
56 sizeof(cnt)); 45 sizeof(cnt));
57 46
58 skl_ipc_set_large_config(&ctx->ipc, &msg, data); 47 skl_ipc_set_large_config(&skl->ipc, &msg, data);
59}
60
61#define NOTIFICATION_PARAM_ID 3
62#define NOTIFICATION_MASK 0xf
63
64/* disable notfication for underruns/overruns from firmware module */
65void skl_dsp_enable_notification(struct skl_sst *ctx, bool enable)
66{
67 struct notification_mask mask;
68 struct skl_ipc_large_config_msg msg = {0};
69
70 mask.notify = NOTIFICATION_MASK;
71 mask.enable = enable;
72
73 msg.large_param_id = NOTIFICATION_PARAM_ID;
74 msg.param_data_size = sizeof(mask);
75
76 skl_ipc_set_large_config(&ctx->ipc, &msg, (u32 *)&mask);
77} 48}
78 49
79static int skl_dsp_setup_spib(struct device *dev, unsigned int size, 50static int skl_dsp_setup_spib(struct device *dev, unsigned int size,
@@ -277,7 +248,7 @@ const struct skl_dsp_ops *skl_get_dsp_ops(int pci_id)
277 return NULL; 248 return NULL;
278} 249}
279 250
280int skl_init_dsp(struct skl *skl) 251int skl_init_dsp(struct skl_dev *skl)
281{ 252{
282 void __iomem *mmio_base; 253 void __iomem *mmio_base;
283 struct hdac_bus *bus = skl_to_bus(skl); 254 struct hdac_bus *bus = skl_to_bus(skl);
@@ -307,13 +278,13 @@ int skl_init_dsp(struct skl *skl)
307 loader_ops = ops->loader_ops(); 278 loader_ops = ops->loader_ops();
308 ret = ops->init(bus->dev, mmio_base, irq, 279 ret = ops->init(bus->dev, mmio_base, irq,
309 skl->fw_name, loader_ops, 280 skl->fw_name, loader_ops,
310 &skl->skl_sst); 281 &skl);
311 282
312 if (ret < 0) 283 if (ret < 0)
313 goto unmap_mmio; 284 goto unmap_mmio;
314 285
315 skl->skl_sst->dsp_ops = ops; 286 skl->dsp_ops = ops;
316 cores = &skl->skl_sst->cores; 287 cores = &skl->cores;
317 cores->count = ops->num_cores; 288 cores->count = ops->num_cores;
318 289
319 cores->state = kcalloc(cores->count, sizeof(*cores->state), GFP_KERNEL); 290 cores->state = kcalloc(cores->count, sizeof(*cores->state), GFP_KERNEL);
@@ -342,21 +313,20 @@ unmap_mmio:
342 return ret; 313 return ret;
343} 314}
344 315
345int skl_free_dsp(struct skl *skl) 316int skl_free_dsp(struct skl_dev *skl)
346{ 317{
347 struct hdac_bus *bus = skl_to_bus(skl); 318 struct hdac_bus *bus = skl_to_bus(skl);
348 struct skl_sst *ctx = skl->skl_sst;
349 319
350 /* disable ppcap interrupt */ 320 /* disable ppcap interrupt */
351 snd_hdac_ext_bus_ppcap_int_enable(bus, false); 321 snd_hdac_ext_bus_ppcap_int_enable(bus, false);
352 322
353 ctx->dsp_ops->cleanup(bus->dev, ctx); 323 skl->dsp_ops->cleanup(bus->dev, skl);
354 324
355 kfree(ctx->cores.state); 325 kfree(skl->cores.state);
356 kfree(ctx->cores.usage_count); 326 kfree(skl->cores.usage_count);
357 327
358 if (ctx->dsp->addr.lpe) 328 if (skl->dsp->addr.lpe)
359 iounmap(ctx->dsp->addr.lpe); 329 iounmap(skl->dsp->addr.lpe);
360 330
361 return 0; 331 return 0;
362} 332}
@@ -368,15 +338,14 @@ int skl_free_dsp(struct skl *skl)
368 * mode during system suspend. In the case of normal suspend, cancel 338 * mode during system suspend. In the case of normal suspend, cancel
369 * any pending D0i3 work. 339 * any pending D0i3 work.
370 */ 340 */
371int skl_suspend_late_dsp(struct skl *skl) 341int skl_suspend_late_dsp(struct skl_dev *skl)
372{ 342{
373 struct skl_sst *ctx = skl->skl_sst;
374 struct delayed_work *dwork; 343 struct delayed_work *dwork;
375 344
376 if (!ctx) 345 if (!skl)
377 return 0; 346 return 0;
378 347
379 dwork = &ctx->d0i3.work; 348 dwork = &skl->d0i3.work;
380 349
381 if (dwork->work.func) { 350 if (dwork->work.func) {
382 if (skl->supend_active) 351 if (skl->supend_active)
@@ -388,9 +357,8 @@ int skl_suspend_late_dsp(struct skl *skl)
388 return 0; 357 return 0;
389} 358}
390 359
391int skl_suspend_dsp(struct skl *skl) 360int skl_suspend_dsp(struct skl_dev *skl)
392{ 361{
393 struct skl_sst *ctx = skl->skl_sst;
394 struct hdac_bus *bus = skl_to_bus(skl); 362 struct hdac_bus *bus = skl_to_bus(skl);
395 int ret; 363 int ret;
396 364
@@ -398,7 +366,7 @@ int skl_suspend_dsp(struct skl *skl)
398 if (!bus->ppcap) 366 if (!bus->ppcap)
399 return 0; 367 return 0;
400 368
401 ret = skl_dsp_sleep(ctx->dsp); 369 ret = skl_dsp_sleep(skl->dsp);
402 if (ret < 0) 370 if (ret < 0)
403 return ret; 371 return ret;
404 372
@@ -409,9 +377,8 @@ int skl_suspend_dsp(struct skl *skl)
409 return 0; 377 return 0;
410} 378}
411 379
412int skl_resume_dsp(struct skl *skl) 380int skl_resume_dsp(struct skl_dev *skl)
413{ 381{
414 struct skl_sst *ctx = skl->skl_sst;
415 struct hdac_bus *bus = skl_to_bus(skl); 382 struct hdac_bus *bus = skl_to_bus(skl);
416 int ret; 383 int ret;
417 384
@@ -424,26 +391,24 @@ int skl_resume_dsp(struct skl *skl)
424 snd_hdac_ext_bus_ppcap_int_enable(bus, true); 391 snd_hdac_ext_bus_ppcap_int_enable(bus, true);
425 392
426 /* check if DSP 1st boot is done */ 393 /* check if DSP 1st boot is done */
427 if (skl->skl_sst->is_first_boot) 394 if (skl->is_first_boot)
428 return 0; 395 return 0;
429 396
430 /* 397 /*
431 * Disable dynamic clock and power gating during firmware 398 * Disable dynamic clock and power gating during firmware
432 * and library download 399 * and library download
433 */ 400 */
434 ctx->enable_miscbdcge(ctx->dev, false); 401 skl->enable_miscbdcge(skl->dev, false);
435 ctx->clock_power_gating(ctx->dev, false); 402 skl->clock_power_gating(skl->dev, false);
436 403
437 ret = skl_dsp_wake(ctx->dsp); 404 ret = skl_dsp_wake(skl->dsp);
438 ctx->enable_miscbdcge(ctx->dev, true); 405 skl->enable_miscbdcge(skl->dev, true);
439 ctx->clock_power_gating(ctx->dev, true); 406 skl->clock_power_gating(skl->dev, true);
440 if (ret < 0) 407 if (ret < 0)
441 return ret; 408 return ret;
442 409
443 skl_dsp_enable_notification(skl->skl_sst, false);
444
445 if (skl->cfg.astate_cfg != NULL) { 410 if (skl->cfg.astate_cfg != NULL) {
446 skl_dsp_set_astate_cfg(skl->skl_sst, skl->cfg.astate_cfg->count, 411 skl_dsp_set_astate_cfg(skl, skl->cfg.astate_cfg->count,
447 skl->cfg.astate_cfg); 412 skl->cfg.astate_cfg);
448 } 413 }
449 return ret; 414 return ret;
@@ -476,7 +441,7 @@ enum skl_bitdepth skl_get_bit_depth(int params)
476 * which are read from widget information passed through topology binary 441 * which are read from widget information passed through topology binary
477 * This is send when we create a module with INIT_INSTANCE IPC msg 442 * This is send when we create a module with INIT_INSTANCE IPC msg
478 */ 443 */
479static void skl_set_base_module_format(struct skl_sst *ctx, 444static void skl_set_base_module_format(struct skl_dev *skl,
480 struct skl_module_cfg *mconfig, 445 struct skl_module_cfg *mconfig,
481 struct skl_base_cfg *base_cfg) 446 struct skl_base_cfg *base_cfg)
482{ 447{
@@ -493,7 +458,7 @@ static void skl_set_base_module_format(struct skl_sst *ctx,
493 base_cfg->audio_fmt.ch_cfg = format->ch_cfg; 458 base_cfg->audio_fmt.ch_cfg = format->ch_cfg;
494 base_cfg->audio_fmt.sample_type = format->sample_type; 459 base_cfg->audio_fmt.sample_type = format->sample_type;
495 460
496 dev_dbg(ctx->dev, "bit_depth=%x valid_bd=%x ch_config=%x\n", 461 dev_dbg(skl->dev, "bit_depth=%x valid_bd=%x ch_config=%x\n",
497 format->bit_depth, format->valid_bit_depth, 462 format->bit_depth, format->valid_bit_depth,
498 format->ch_cfg); 463 format->ch_cfg);
499 464
@@ -501,7 +466,7 @@ static void skl_set_base_module_format(struct skl_sst *ctx,
501 466
502 base_cfg->audio_fmt.interleaving = format->interleaving_style; 467 base_cfg->audio_fmt.interleaving = format->interleaving_style;
503 468
504 base_cfg->cps = res->cps; 469 base_cfg->cpc = res->cpc;
505 base_cfg->ibs = res->ibs; 470 base_cfg->ibs = res->ibs;
506 base_cfg->obs = res->obs; 471 base_cfg->obs = res->obs;
507 base_cfg->is_pages = res->is_pages; 472 base_cfg->is_pages = res->is_pages;
@@ -530,7 +495,7 @@ static void skl_copy_copier_caps(struct skl_module_cfg *mconfig,
530 * Calculate the gatewat settings required for copier module, type of 495 * Calculate the gatewat settings required for copier module, type of
531 * gateway and index of gateway to use 496 * gateway and index of gateway to use
532 */ 497 */
533static u32 skl_get_node_id(struct skl_sst *ctx, 498static u32 skl_get_node_id(struct skl_dev *skl,
534 struct skl_module_cfg *mconfig) 499 struct skl_module_cfg *mconfig)
535{ 500{
536 union skl_connector_node_id node_id = {0}; 501 union skl_connector_node_id node_id = {0};
@@ -587,16 +552,15 @@ static u32 skl_get_node_id(struct skl_sst *ctx,
587 return node_id.val; 552 return node_id.val;
588} 553}
589 554
590static void skl_setup_cpr_gateway_cfg(struct skl_sst *ctx, 555static void skl_setup_cpr_gateway_cfg(struct skl_dev *skl,
591 struct skl_module_cfg *mconfig, 556 struct skl_module_cfg *mconfig,
592 struct skl_cpr_cfg *cpr_mconfig) 557 struct skl_cpr_cfg *cpr_mconfig)
593{ 558{
594 u32 dma_io_buf; 559 u32 dma_io_buf;
595 struct skl_module_res *res; 560 struct skl_module_res *res;
596 int res_idx = mconfig->res_idx; 561 int res_idx = mconfig->res_idx;
597 struct skl *skl = get_skl_ctx(ctx->dev);
598 562
599 cpr_mconfig->gtw_cfg.node_id = skl_get_node_id(ctx, mconfig); 563 cpr_mconfig->gtw_cfg.node_id = skl_get_node_id(skl, mconfig);
600 564
601 if (cpr_mconfig->gtw_cfg.node_id == SKL_NON_GATEWAY_CPR_NODE_ID) { 565 if (cpr_mconfig->gtw_cfg.node_id == SKL_NON_GATEWAY_CPR_NODE_ID) {
602 cpr_mconfig->cpr_feature_mask = 0; 566 cpr_mconfig->cpr_feature_mask = 0;
@@ -627,7 +591,7 @@ static void skl_setup_cpr_gateway_cfg(struct skl_sst *ctx,
627 break; 591 break;
628 592
629 default: 593 default:
630 dev_warn(ctx->dev, "wrong connection type: %d\n", 594 dev_warn(skl->dev, "wrong connection type: %d\n",
631 mconfig->hw_conn_type); 595 mconfig->hw_conn_type);
632 return; 596 return;
633 } 597 }
@@ -653,7 +617,7 @@ skip_buf_size_calc:
653#define DMA_CONTROL_ID 5 617#define DMA_CONTROL_ID 5
654#define DMA_I2S_BLOB_SIZE 21 618#define DMA_I2S_BLOB_SIZE 21
655 619
656int skl_dsp_set_dma_control(struct skl_sst *ctx, u32 *caps, 620int skl_dsp_set_dma_control(struct skl_dev *skl, u32 *caps,
657 u32 caps_size, u32 node_id) 621 u32 caps_size, u32 node_id)
658{ 622{
659 struct skl_dma_control *dma_ctrl; 623 struct skl_dma_control *dma_ctrl;
@@ -686,14 +650,14 @@ int skl_dsp_set_dma_control(struct skl_sst *ctx, u32 *caps,
686 650
687 memcpy(dma_ctrl->config_data, caps, caps_size); 651 memcpy(dma_ctrl->config_data, caps, caps_size);
688 652
689 err = skl_ipc_set_large_config(&ctx->ipc, &msg, (u32 *)dma_ctrl); 653 err = skl_ipc_set_large_config(&skl->ipc, &msg, (u32 *)dma_ctrl);
690 654
691 kfree(dma_ctrl); 655 kfree(dma_ctrl);
692 return err; 656 return err;
693} 657}
694EXPORT_SYMBOL_GPL(skl_dsp_set_dma_control); 658EXPORT_SYMBOL_GPL(skl_dsp_set_dma_control);
695 659
696static void skl_setup_out_format(struct skl_sst *ctx, 660static void skl_setup_out_format(struct skl_dev *skl,
697 struct skl_module_cfg *mconfig, 661 struct skl_module_cfg *mconfig,
698 struct skl_audio_data_format *out_fmt) 662 struct skl_audio_data_format *out_fmt)
699{ 663{
@@ -711,7 +675,7 @@ static void skl_setup_out_format(struct skl_sst *ctx,
711 out_fmt->interleaving = format->interleaving_style; 675 out_fmt->interleaving = format->interleaving_style;
712 out_fmt->sample_type = format->sample_type; 676 out_fmt->sample_type = format->sample_type;
713 677
714 dev_dbg(ctx->dev, "copier out format chan=%d fre=%d bitdepth=%d\n", 678 dev_dbg(skl->dev, "copier out format chan=%d fre=%d bitdepth=%d\n",
715 out_fmt->number_of_channels, format->s_freq, format->bit_depth); 679 out_fmt->number_of_channels, format->s_freq, format->bit_depth);
716} 680}
717 681
@@ -720,7 +684,7 @@ static void skl_setup_out_format(struct skl_sst *ctx,
720 * configuration and the target frequency as extra parameter passed as src 684 * configuration and the target frequency as extra parameter passed as src
721 * config 685 * config
722 */ 686 */
723static void skl_set_src_format(struct skl_sst *ctx, 687static void skl_set_src_format(struct skl_dev *skl,
724 struct skl_module_cfg *mconfig, 688 struct skl_module_cfg *mconfig,
725 struct skl_src_module_cfg *src_mconfig) 689 struct skl_src_module_cfg *src_mconfig)
726{ 690{
@@ -728,7 +692,7 @@ static void skl_set_src_format(struct skl_sst *ctx,
728 struct skl_module_iface *iface = &module->formats[mconfig->fmt_idx]; 692 struct skl_module_iface *iface = &module->formats[mconfig->fmt_idx];
729 struct skl_module_fmt *fmt = &iface->outputs[0].fmt; 693 struct skl_module_fmt *fmt = &iface->outputs[0].fmt;
730 694
731 skl_set_base_module_format(ctx, mconfig, 695 skl_set_base_module_format(skl, mconfig,
732 (struct skl_base_cfg *)src_mconfig); 696 (struct skl_base_cfg *)src_mconfig);
733 697
734 src_mconfig->src_cfg = fmt->s_freq; 698 src_mconfig->src_cfg = fmt->s_freq;
@@ -739,7 +703,7 @@ static void skl_set_src_format(struct skl_sst *ctx,
739 * module configuration and channel configuration 703 * module configuration and channel configuration
740 * It also take coefficients and now we have defaults applied here 704 * It also take coefficients and now we have defaults applied here
741 */ 705 */
742static void skl_set_updown_mixer_format(struct skl_sst *ctx, 706static void skl_set_updown_mixer_format(struct skl_dev *skl,
743 struct skl_module_cfg *mconfig, 707 struct skl_module_cfg *mconfig,
744 struct skl_up_down_mixer_cfg *mixer_mconfig) 708 struct skl_up_down_mixer_cfg *mixer_mconfig)
745{ 709{
@@ -747,7 +711,7 @@ static void skl_set_updown_mixer_format(struct skl_sst *ctx,
747 struct skl_module_iface *iface = &module->formats[mconfig->fmt_idx]; 711 struct skl_module_iface *iface = &module->formats[mconfig->fmt_idx];
748 struct skl_module_fmt *fmt = &iface->outputs[0].fmt; 712 struct skl_module_fmt *fmt = &iface->outputs[0].fmt;
749 713
750 skl_set_base_module_format(ctx, mconfig, 714 skl_set_base_module_format(skl, mconfig,
751 (struct skl_base_cfg *)mixer_mconfig); 715 (struct skl_base_cfg *)mixer_mconfig);
752 mixer_mconfig->out_ch_cfg = fmt->ch_cfg; 716 mixer_mconfig->out_ch_cfg = fmt->ch_cfg;
753 mixer_mconfig->ch_map = fmt->ch_map; 717 mixer_mconfig->ch_map = fmt->ch_map;
@@ -760,17 +724,17 @@ static void skl_set_updown_mixer_format(struct skl_sst *ctx,
760 * format, gateway settings 724 * format, gateway settings
761 * copier_module_config is sent as input buffer with INIT_INSTANCE IPC msg 725 * copier_module_config is sent as input buffer with INIT_INSTANCE IPC msg
762 */ 726 */
763static void skl_set_copier_format(struct skl_sst *ctx, 727static void skl_set_copier_format(struct skl_dev *skl,
764 struct skl_module_cfg *mconfig, 728 struct skl_module_cfg *mconfig,
765 struct skl_cpr_cfg *cpr_mconfig) 729 struct skl_cpr_cfg *cpr_mconfig)
766{ 730{
767 struct skl_audio_data_format *out_fmt = &cpr_mconfig->out_fmt; 731 struct skl_audio_data_format *out_fmt = &cpr_mconfig->out_fmt;
768 struct skl_base_cfg *base_cfg = (struct skl_base_cfg *)cpr_mconfig; 732 struct skl_base_cfg *base_cfg = (struct skl_base_cfg *)cpr_mconfig;
769 733
770 skl_set_base_module_format(ctx, mconfig, base_cfg); 734 skl_set_base_module_format(skl, mconfig, base_cfg);
771 735
772 skl_setup_out_format(ctx, mconfig, out_fmt); 736 skl_setup_out_format(skl, mconfig, out_fmt);
773 skl_setup_cpr_gateway_cfg(ctx, mconfig, cpr_mconfig); 737 skl_setup_cpr_gateway_cfg(skl, mconfig, cpr_mconfig);
774} 738}
775 739
776/* 740/*
@@ -778,13 +742,13 @@ static void skl_set_copier_format(struct skl_sst *ctx,
778 * configuration and params 742 * configuration and params
779 */ 743 */
780 744
781static void skl_set_algo_format(struct skl_sst *ctx, 745static void skl_set_algo_format(struct skl_dev *skl,
782 struct skl_module_cfg *mconfig, 746 struct skl_module_cfg *mconfig,
783 struct skl_algo_cfg *algo_mcfg) 747 struct skl_algo_cfg *algo_mcfg)
784{ 748{
785 struct skl_base_cfg *base_cfg = (struct skl_base_cfg *)algo_mcfg; 749 struct skl_base_cfg *base_cfg = (struct skl_base_cfg *)algo_mcfg;
786 750
787 skl_set_base_module_format(ctx, mconfig, base_cfg); 751 skl_set_base_module_format(skl, mconfig, base_cfg);
788 752
789 if (mconfig->formats_config.caps_size == 0) 753 if (mconfig->formats_config.caps_size == 0)
790 return; 754 return;
@@ -802,7 +766,7 @@ static void skl_set_algo_format(struct skl_sst *ctx,
802 * Mic select module take base module configuration and out-format 766 * Mic select module take base module configuration and out-format
803 * configuration 767 * configuration
804 */ 768 */
805static void skl_set_base_outfmt_format(struct skl_sst *ctx, 769static void skl_set_base_outfmt_format(struct skl_dev *skl,
806 struct skl_module_cfg *mconfig, 770 struct skl_module_cfg *mconfig,
807 struct skl_base_outfmt_cfg *base_outfmt_mcfg) 771 struct skl_base_outfmt_cfg *base_outfmt_mcfg)
808{ 772{
@@ -810,11 +774,11 @@ static void skl_set_base_outfmt_format(struct skl_sst *ctx,
810 struct skl_base_cfg *base_cfg = 774 struct skl_base_cfg *base_cfg =
811 (struct skl_base_cfg *)base_outfmt_mcfg; 775 (struct skl_base_cfg *)base_outfmt_mcfg;
812 776
813 skl_set_base_module_format(ctx, mconfig, base_cfg); 777 skl_set_base_module_format(skl, mconfig, base_cfg);
814 skl_setup_out_format(ctx, mconfig, out_fmt); 778 skl_setup_out_format(skl, mconfig, out_fmt);
815} 779}
816 780
817static u16 skl_get_module_param_size(struct skl_sst *ctx, 781static u16 skl_get_module_param_size(struct skl_dev *skl,
818 struct skl_module_cfg *mconfig) 782 struct skl_module_cfg *mconfig)
819{ 783{
820 u16 param_size; 784 u16 param_size;
@@ -859,14 +823,14 @@ static u16 skl_get_module_param_size(struct skl_sst *ctx,
859 * base module format configuration 823 * base module format configuration
860 */ 824 */
861 825
862static int skl_set_module_format(struct skl_sst *ctx, 826static int skl_set_module_format(struct skl_dev *skl,
863 struct skl_module_cfg *module_config, 827 struct skl_module_cfg *module_config,
864 u16 *module_config_size, 828 u16 *module_config_size,
865 void **param_data) 829 void **param_data)
866{ 830{
867 u16 param_size; 831 u16 param_size;
868 832
869 param_size = skl_get_module_param_size(ctx, module_config); 833 param_size = skl_get_module_param_size(skl, module_config);
870 834
871 *param_data = kzalloc(param_size, GFP_KERNEL); 835 *param_data = kzalloc(param_size, GFP_KERNEL);
872 if (NULL == *param_data) 836 if (NULL == *param_data)
@@ -876,35 +840,36 @@ static int skl_set_module_format(struct skl_sst *ctx,
876 840
877 switch (module_config->m_type) { 841 switch (module_config->m_type) {
878 case SKL_MODULE_TYPE_COPIER: 842 case SKL_MODULE_TYPE_COPIER:
879 skl_set_copier_format(ctx, module_config, *param_data); 843 skl_set_copier_format(skl, module_config, *param_data);
880 break; 844 break;
881 845
882 case SKL_MODULE_TYPE_SRCINT: 846 case SKL_MODULE_TYPE_SRCINT:
883 skl_set_src_format(ctx, module_config, *param_data); 847 skl_set_src_format(skl, module_config, *param_data);
884 break; 848 break;
885 849
886 case SKL_MODULE_TYPE_UPDWMIX: 850 case SKL_MODULE_TYPE_UPDWMIX:
887 skl_set_updown_mixer_format(ctx, module_config, *param_data); 851 skl_set_updown_mixer_format(skl, module_config, *param_data);
888 break; 852 break;
889 853
890 case SKL_MODULE_TYPE_ALGO: 854 case SKL_MODULE_TYPE_ALGO:
891 skl_set_algo_format(ctx, module_config, *param_data); 855 skl_set_algo_format(skl, module_config, *param_data);
892 break; 856 break;
893 857
894 case SKL_MODULE_TYPE_BASE_OUTFMT: 858 case SKL_MODULE_TYPE_BASE_OUTFMT:
895 case SKL_MODULE_TYPE_MIC_SELECT: 859 case SKL_MODULE_TYPE_MIC_SELECT:
896 case SKL_MODULE_TYPE_KPB: 860 case SKL_MODULE_TYPE_KPB:
897 skl_set_base_outfmt_format(ctx, module_config, *param_data); 861 skl_set_base_outfmt_format(skl, module_config, *param_data);
898 break; 862 break;
899 863
900 default: 864 default:
901 skl_set_base_module_format(ctx, module_config, *param_data); 865 skl_set_base_module_format(skl, module_config, *param_data);
902 break; 866 break;
903 867
904 } 868 }
905 869
906 dev_dbg(ctx->dev, "Module type=%d config size: %d bytes\n", 870 dev_dbg(skl->dev, "Module type=%d id=%d config size: %d bytes\n",
907 module_config->id.module_id, param_size); 871 module_config->m_type, module_config->id.module_id,
872 param_size);
908 print_hex_dump_debug("Module params:", DUMP_PREFIX_OFFSET, 8, 4, 873 print_hex_dump_debug("Module params:", DUMP_PREFIX_OFFSET, 8, 4,
909 *param_data, param_size, false); 874 *param_data, param_size, false);
910 return 0; 875 return 0;
@@ -1004,7 +969,7 @@ static void skl_clear_module_state(struct skl_module_pin *mpin, int max,
1004 * We first calculate the module format, based on module type and then 969 * We first calculate the module format, based on module type and then
1005 * invoke the DSP by sending IPC INIT_INSTANCE using ipc helper 970 * invoke the DSP by sending IPC INIT_INSTANCE using ipc helper
1006 */ 971 */
1007int skl_init_module(struct skl_sst *ctx, 972int skl_init_module(struct skl_dev *skl,
1008 struct skl_module_cfg *mconfig) 973 struct skl_module_cfg *mconfig)
1009{ 974{
1010 u16 module_config_size = 0; 975 u16 module_config_size = 0;
@@ -1012,19 +977,19 @@ int skl_init_module(struct skl_sst *ctx,
1012 int ret; 977 int ret;
1013 struct skl_ipc_init_instance_msg msg; 978 struct skl_ipc_init_instance_msg msg;
1014 979
1015 dev_dbg(ctx->dev, "%s: module_id = %d instance=%d\n", __func__, 980 dev_dbg(skl->dev, "%s: module_id = %d instance=%d\n", __func__,
1016 mconfig->id.module_id, mconfig->id.pvt_id); 981 mconfig->id.module_id, mconfig->id.pvt_id);
1017 982
1018 if (mconfig->pipe->state != SKL_PIPE_CREATED) { 983 if (mconfig->pipe->state != SKL_PIPE_CREATED) {
1019 dev_err(ctx->dev, "Pipe not created state= %d pipe_id= %d\n", 984 dev_err(skl->dev, "Pipe not created state= %d pipe_id= %d\n",
1020 mconfig->pipe->state, mconfig->pipe->ppl_id); 985 mconfig->pipe->state, mconfig->pipe->ppl_id);
1021 return -EIO; 986 return -EIO;
1022 } 987 }
1023 988
1024 ret = skl_set_module_format(ctx, mconfig, 989 ret = skl_set_module_format(skl, mconfig,
1025 &module_config_size, &param_data); 990 &module_config_size, &param_data);
1026 if (ret < 0) { 991 if (ret < 0) {
1027 dev_err(ctx->dev, "Failed to set module format ret=%d\n", ret); 992 dev_err(skl->dev, "Failed to set module format ret=%d\n", ret);
1028 return ret; 993 return ret;
1029 } 994 }
1030 995
@@ -1035,9 +1000,9 @@ int skl_init_module(struct skl_sst *ctx,
1035 msg.core_id = mconfig->core_id; 1000 msg.core_id = mconfig->core_id;
1036 msg.domain = mconfig->domain; 1001 msg.domain = mconfig->domain;
1037 1002
1038 ret = skl_ipc_init_instance(&ctx->ipc, &msg, param_data); 1003 ret = skl_ipc_init_instance(&skl->ipc, &msg, param_data);
1039 if (ret < 0) { 1004 if (ret < 0) {
1040 dev_err(ctx->dev, "Failed to init instance ret=%d\n", ret); 1005 dev_err(skl->dev, "Failed to init instance ret=%d\n", ret);
1041 kfree(param_data); 1006 kfree(param_data);
1042 return ret; 1007 return ret;
1043 } 1008 }
@@ -1046,15 +1011,15 @@ int skl_init_module(struct skl_sst *ctx,
1046 return ret; 1011 return ret;
1047} 1012}
1048 1013
1049static void skl_dump_bind_info(struct skl_sst *ctx, struct skl_module_cfg 1014static void skl_dump_bind_info(struct skl_dev *skl, struct skl_module_cfg
1050 *src_module, struct skl_module_cfg *dst_module) 1015 *src_module, struct skl_module_cfg *dst_module)
1051{ 1016{
1052 dev_dbg(ctx->dev, "%s: src module_id = %d src_instance=%d\n", 1017 dev_dbg(skl->dev, "%s: src module_id = %d src_instance=%d\n",
1053 __func__, src_module->id.module_id, src_module->id.pvt_id); 1018 __func__, src_module->id.module_id, src_module->id.pvt_id);
1054 dev_dbg(ctx->dev, "%s: dst_module=%d dst_instance=%d\n", __func__, 1019 dev_dbg(skl->dev, "%s: dst_module=%d dst_instance=%d\n", __func__,
1055 dst_module->id.module_id, dst_module->id.pvt_id); 1020 dst_module->id.module_id, dst_module->id.pvt_id);
1056 1021
1057 dev_dbg(ctx->dev, "src_module state = %d dst module state = %d\n", 1022 dev_dbg(skl->dev, "src_module state = %d dst module state = %d\n",
1058 src_module->m_state, dst_module->m_state); 1023 src_module->m_state, dst_module->m_state);
1059} 1024}
1060 1025
@@ -1063,7 +1028,7 @@ static void skl_dump_bind_info(struct skl_sst *ctx, struct skl_module_cfg
1063 * it is already bind. 1028 * it is already bind.
1064 * Find the pin allocated and unbind then using bind_unbind IPC 1029 * Find the pin allocated and unbind then using bind_unbind IPC
1065 */ 1030 */
1066int skl_unbind_modules(struct skl_sst *ctx, 1031int skl_unbind_modules(struct skl_dev *skl,
1067 struct skl_module_cfg *src_mcfg, 1032 struct skl_module_cfg *src_mcfg,
1068 struct skl_module_cfg *dst_mcfg) 1033 struct skl_module_cfg *dst_mcfg)
1069{ 1034{
@@ -1075,7 +1040,7 @@ int skl_unbind_modules(struct skl_sst *ctx,
1075 int out_max = src_mcfg->module->max_output_pins; 1040 int out_max = src_mcfg->module->max_output_pins;
1076 int src_index, dst_index, src_pin_state, dst_pin_state; 1041 int src_index, dst_index, src_pin_state, dst_pin_state;
1077 1042
1078 skl_dump_bind_info(ctx, src_mcfg, dst_mcfg); 1043 skl_dump_bind_info(skl, src_mcfg, dst_mcfg);
1079 1044
1080 /* get src queue index */ 1045 /* get src queue index */
1081 src_index = skl_get_queue_index(src_mcfg->m_out_pin, dst_id, out_max); 1046 src_index = skl_get_queue_index(src_mcfg->m_out_pin, dst_id, out_max);
@@ -1104,7 +1069,7 @@ int skl_unbind_modules(struct skl_sst *ctx,
1104 msg.dst_instance_id = dst_mcfg->id.pvt_id; 1069 msg.dst_instance_id = dst_mcfg->id.pvt_id;
1105 msg.bind = false; 1070 msg.bind = false;
1106 1071
1107 ret = skl_ipc_bind_unbind(&ctx->ipc, &msg); 1072 ret = skl_ipc_bind_unbind(&skl->ipc, &msg);
1108 if (!ret) { 1073 if (!ret) {
1109 /* free queue only if unbind is success */ 1074 /* free queue only if unbind is success */
1110 skl_free_queue(src_mcfg->m_out_pin, src_index); 1075 skl_free_queue(src_mcfg->m_out_pin, src_index);
@@ -1142,7 +1107,7 @@ static void fill_pin_params(struct skl_audio_data_format *pin_fmt,
1142 * This function finds the pins and then sends bund_unbind IPC message to 1107 * This function finds the pins and then sends bund_unbind IPC message to
1143 * DSP using IPC helper 1108 * DSP using IPC helper
1144 */ 1109 */
1145int skl_bind_modules(struct skl_sst *ctx, 1110int skl_bind_modules(struct skl_dev *skl,
1146 struct skl_module_cfg *src_mcfg, 1111 struct skl_module_cfg *src_mcfg,
1147 struct skl_module_cfg *dst_mcfg) 1112 struct skl_module_cfg *dst_mcfg)
1148{ 1113{
@@ -1156,7 +1121,7 @@ int skl_bind_modules(struct skl_sst *ctx,
1156 struct skl_module *module; 1121 struct skl_module *module;
1157 struct skl_module_iface *fmt; 1122 struct skl_module_iface *fmt;
1158 1123
1159 skl_dump_bind_info(ctx, src_mcfg, dst_mcfg); 1124 skl_dump_bind_info(skl, src_mcfg, dst_mcfg);
1160 1125
1161 if (src_mcfg->m_state < SKL_MODULE_INIT_DONE || 1126 if (src_mcfg->m_state < SKL_MODULE_INIT_DONE ||
1162 dst_mcfg->m_state < SKL_MODULE_INIT_DONE) 1127 dst_mcfg->m_state < SKL_MODULE_INIT_DONE)
@@ -1188,7 +1153,7 @@ int skl_bind_modules(struct skl_sst *ctx,
1188 1153
1189 format = &fmt->outputs[src_index].fmt; 1154 format = &fmt->outputs[src_index].fmt;
1190 fill_pin_params(&(pin_fmt.dst_fmt), format); 1155 fill_pin_params(&(pin_fmt.dst_fmt), format);
1191 ret = skl_set_module_params(ctx, (void *)&pin_fmt, 1156 ret = skl_set_module_params(skl, (void *)&pin_fmt,
1192 sizeof(struct skl_cpr_pin_fmt), 1157 sizeof(struct skl_cpr_pin_fmt),
1193 CPR_SINK_FMT_PARAM_ID, src_mcfg); 1158 CPR_SINK_FMT_PARAM_ID, src_mcfg);
1194 1159
@@ -1198,7 +1163,7 @@ int skl_bind_modules(struct skl_sst *ctx,
1198 1163
1199 msg.dst_queue = dst_index; 1164 msg.dst_queue = dst_index;
1200 1165
1201 dev_dbg(ctx->dev, "src queue = %d dst queue =%d\n", 1166 dev_dbg(skl->dev, "src queue = %d dst queue =%d\n",
1202 msg.src_queue, msg.dst_queue); 1167 msg.src_queue, msg.dst_queue);
1203 1168
1204 msg.module_id = src_mcfg->id.module_id; 1169 msg.module_id = src_mcfg->id.module_id;
@@ -1207,7 +1172,7 @@ int skl_bind_modules(struct skl_sst *ctx,
1207 msg.dst_instance_id = dst_mcfg->id.pvt_id; 1172 msg.dst_instance_id = dst_mcfg->id.pvt_id;
1208 msg.bind = true; 1173 msg.bind = true;
1209 1174
1210 ret = skl_ipc_bind_unbind(&ctx->ipc, &msg); 1175 ret = skl_ipc_bind_unbind(&skl->ipc, &msg);
1211 1176
1212 if (!ret) { 1177 if (!ret) {
1213 src_mcfg->m_state = SKL_MODULE_BIND_DONE; 1178 src_mcfg->m_state = SKL_MODULE_BIND_DONE;
@@ -1223,12 +1188,12 @@ out:
1223 return ret; 1188 return ret;
1224} 1189}
1225 1190
1226static int skl_set_pipe_state(struct skl_sst *ctx, struct skl_pipe *pipe, 1191static int skl_set_pipe_state(struct skl_dev *skl, struct skl_pipe *pipe,
1227 enum skl_ipc_pipeline_state state) 1192 enum skl_ipc_pipeline_state state)
1228{ 1193{
1229 dev_dbg(ctx->dev, "%s: pipe_state = %d\n", __func__, state); 1194 dev_dbg(skl->dev, "%s: pipe_state = %d\n", __func__, state);
1230 1195
1231 return skl_ipc_set_pipeline_state(&ctx->ipc, pipe->ppl_id, state); 1196 return skl_ipc_set_pipeline_state(&skl->ipc, pipe->ppl_id, state);
1232} 1197}
1233 1198
1234/* 1199/*
@@ -1237,17 +1202,17 @@ static int skl_set_pipe_state(struct skl_sst *ctx, struct skl_pipe *pipe,
1237 * This function creates pipeline, by sending create pipeline IPC messages 1202 * This function creates pipeline, by sending create pipeline IPC messages
1238 * to FW 1203 * to FW
1239 */ 1204 */
1240int skl_create_pipeline(struct skl_sst *ctx, struct skl_pipe *pipe) 1205int skl_create_pipeline(struct skl_dev *skl, struct skl_pipe *pipe)
1241{ 1206{
1242 int ret; 1207 int ret;
1243 1208
1244 dev_dbg(ctx->dev, "%s: pipe_id = %d\n", __func__, pipe->ppl_id); 1209 dev_dbg(skl->dev, "%s: pipe_id = %d\n", __func__, pipe->ppl_id);
1245 1210
1246 ret = skl_ipc_create_pipeline(&ctx->ipc, pipe->memory_pages, 1211 ret = skl_ipc_create_pipeline(&skl->ipc, pipe->memory_pages,
1247 pipe->pipe_priority, pipe->ppl_id, 1212 pipe->pipe_priority, pipe->ppl_id,
1248 pipe->lp_mode); 1213 pipe->lp_mode);
1249 if (ret < 0) { 1214 if (ret < 0) {
1250 dev_err(ctx->dev, "Failed to create pipeline\n"); 1215 dev_err(skl->dev, "Failed to create pipeline\n");
1251 return ret; 1216 return ret;
1252 } 1217 }
1253 1218
@@ -1262,11 +1227,11 @@ int skl_create_pipeline(struct skl_sst *ctx, struct skl_pipe *pipe)
1262 * reset state. Finish the procedure by sending delete pipeline IPC. 1227 * reset state. Finish the procedure by sending delete pipeline IPC.
1263 * DSP will stop the DMA engines and release resources 1228 * DSP will stop the DMA engines and release resources
1264 */ 1229 */
1265int skl_delete_pipe(struct skl_sst *ctx, struct skl_pipe *pipe) 1230int skl_delete_pipe(struct skl_dev *skl, struct skl_pipe *pipe)
1266{ 1231{
1267 int ret; 1232 int ret;
1268 1233
1269 dev_dbg(ctx->dev, "%s: pipe = %d\n", __func__, pipe->ppl_id); 1234 dev_dbg(skl->dev, "%s: pipe = %d\n", __func__, pipe->ppl_id);
1270 1235
1271 /* If pipe was not created in FW, do not try to delete it */ 1236 /* If pipe was not created in FW, do not try to delete it */
1272 if (pipe->state < SKL_PIPE_CREATED) 1237 if (pipe->state < SKL_PIPE_CREATED)
@@ -1274,9 +1239,9 @@ int skl_delete_pipe(struct skl_sst *ctx, struct skl_pipe *pipe)
1274 1239
1275 /* If pipe is started, do stop the pipe in FW. */ 1240 /* If pipe is started, do stop the pipe in FW. */
1276 if (pipe->state >= SKL_PIPE_STARTED) { 1241 if (pipe->state >= SKL_PIPE_STARTED) {
1277 ret = skl_set_pipe_state(ctx, pipe, PPL_PAUSED); 1242 ret = skl_set_pipe_state(skl, pipe, PPL_PAUSED);
1278 if (ret < 0) { 1243 if (ret < 0) {
1279 dev_err(ctx->dev, "Failed to stop pipeline\n"); 1244 dev_err(skl->dev, "Failed to stop pipeline\n");
1280 return ret; 1245 return ret;
1281 } 1246 }
1282 1247
@@ -1284,17 +1249,17 @@ int skl_delete_pipe(struct skl_sst *ctx, struct skl_pipe *pipe)
1284 } 1249 }
1285 1250
1286 /* reset pipe state before deletion */ 1251 /* reset pipe state before deletion */
1287 ret = skl_set_pipe_state(ctx, pipe, PPL_RESET); 1252 ret = skl_set_pipe_state(skl, pipe, PPL_RESET);
1288 if (ret < 0) { 1253 if (ret < 0) {
1289 dev_err(ctx->dev, "Failed to reset pipe ret=%d\n", ret); 1254 dev_err(skl->dev, "Failed to reset pipe ret=%d\n", ret);
1290 return ret; 1255 return ret;
1291 } 1256 }
1292 1257
1293 pipe->state = SKL_PIPE_RESET; 1258 pipe->state = SKL_PIPE_RESET;
1294 1259
1295 ret = skl_ipc_delete_pipeline(&ctx->ipc, pipe->ppl_id); 1260 ret = skl_ipc_delete_pipeline(&skl->ipc, pipe->ppl_id);
1296 if (ret < 0) { 1261 if (ret < 0) {
1297 dev_err(ctx->dev, "Failed to delete pipeline\n"); 1262 dev_err(skl->dev, "Failed to delete pipeline\n");
1298 return ret; 1263 return ret;
1299 } 1264 }
1300 1265
@@ -1308,28 +1273,28 @@ int skl_delete_pipe(struct skl_sst *ctx, struct skl_pipe *pipe)
1308 * For processing data the pipe need to be run by sending IPC set pipe state 1273 * For processing data the pipe need to be run by sending IPC set pipe state
1309 * to DSP 1274 * to DSP
1310 */ 1275 */
1311int skl_run_pipe(struct skl_sst *ctx, struct skl_pipe *pipe) 1276int skl_run_pipe(struct skl_dev *skl, struct skl_pipe *pipe)
1312{ 1277{
1313 int ret; 1278 int ret;
1314 1279
1315 dev_dbg(ctx->dev, "%s: pipe = %d\n", __func__, pipe->ppl_id); 1280 dev_dbg(skl->dev, "%s: pipe = %d\n", __func__, pipe->ppl_id);
1316 1281
1317 /* If pipe was not created in FW, do not try to pause or delete */ 1282 /* If pipe was not created in FW, do not try to pause or delete */
1318 if (pipe->state < SKL_PIPE_CREATED) 1283 if (pipe->state < SKL_PIPE_CREATED)
1319 return 0; 1284 return 0;
1320 1285
1321 /* Pipe has to be paused before it is started */ 1286 /* Pipe has to be paused before it is started */
1322 ret = skl_set_pipe_state(ctx, pipe, PPL_PAUSED); 1287 ret = skl_set_pipe_state(skl, pipe, PPL_PAUSED);
1323 if (ret < 0) { 1288 if (ret < 0) {
1324 dev_err(ctx->dev, "Failed to pause pipe\n"); 1289 dev_err(skl->dev, "Failed to pause pipe\n");
1325 return ret; 1290 return ret;
1326 } 1291 }
1327 1292
1328 pipe->state = SKL_PIPE_PAUSED; 1293 pipe->state = SKL_PIPE_PAUSED;
1329 1294
1330 ret = skl_set_pipe_state(ctx, pipe, PPL_RUNNING); 1295 ret = skl_set_pipe_state(skl, pipe, PPL_RUNNING);
1331 if (ret < 0) { 1296 if (ret < 0) {
1332 dev_err(ctx->dev, "Failed to start pipe\n"); 1297 dev_err(skl->dev, "Failed to start pipe\n");
1333 return ret; 1298 return ret;
1334 } 1299 }
1335 1300
@@ -1342,19 +1307,19 @@ int skl_run_pipe(struct skl_sst *ctx, struct skl_pipe *pipe)
1342 * Stop the pipeline by sending set pipe state IPC 1307 * Stop the pipeline by sending set pipe state IPC
1343 * DSP doesnt implement stop so we always send pause message 1308 * DSP doesnt implement stop so we always send pause message
1344 */ 1309 */
1345int skl_stop_pipe(struct skl_sst *ctx, struct skl_pipe *pipe) 1310int skl_stop_pipe(struct skl_dev *skl, struct skl_pipe *pipe)
1346{ 1311{
1347 int ret; 1312 int ret;
1348 1313
1349 dev_dbg(ctx->dev, "In %s pipe=%d\n", __func__, pipe->ppl_id); 1314 dev_dbg(skl->dev, "In %s pipe=%d\n", __func__, pipe->ppl_id);
1350 1315
1351 /* If pipe was not created in FW, do not try to pause or delete */ 1316 /* If pipe was not created in FW, do not try to pause or delete */
1352 if (pipe->state < SKL_PIPE_PAUSED) 1317 if (pipe->state < SKL_PIPE_PAUSED)
1353 return 0; 1318 return 0;
1354 1319
1355 ret = skl_set_pipe_state(ctx, pipe, PPL_PAUSED); 1320 ret = skl_set_pipe_state(skl, pipe, PPL_PAUSED);
1356 if (ret < 0) { 1321 if (ret < 0) {
1357 dev_dbg(ctx->dev, "Failed to stop pipe\n"); 1322 dev_dbg(skl->dev, "Failed to stop pipe\n");
1358 return ret; 1323 return ret;
1359 } 1324 }
1360 1325
@@ -1367,7 +1332,7 @@ int skl_stop_pipe(struct skl_sst *ctx, struct skl_pipe *pipe)
1367 * Reset the pipeline by sending set pipe state IPC this will reset the DMA 1332 * Reset the pipeline by sending set pipe state IPC this will reset the DMA
1368 * from the DSP side 1333 * from the DSP side
1369 */ 1334 */
1370int skl_reset_pipe(struct skl_sst *ctx, struct skl_pipe *pipe) 1335int skl_reset_pipe(struct skl_dev *skl, struct skl_pipe *pipe)
1371{ 1336{
1372 int ret; 1337 int ret;
1373 1338
@@ -1375,9 +1340,9 @@ int skl_reset_pipe(struct skl_sst *ctx, struct skl_pipe *pipe)
1375 if (pipe->state < SKL_PIPE_PAUSED) 1340 if (pipe->state < SKL_PIPE_PAUSED)
1376 return 0; 1341 return 0;
1377 1342
1378 ret = skl_set_pipe_state(ctx, pipe, PPL_RESET); 1343 ret = skl_set_pipe_state(skl, pipe, PPL_RESET);
1379 if (ret < 0) { 1344 if (ret < 0) {
1380 dev_dbg(ctx->dev, "Failed to reset pipe ret=%d\n", ret); 1345 dev_dbg(skl->dev, "Failed to reset pipe ret=%d\n", ret);
1381 return ret; 1346 return ret;
1382 } 1347 }
1383 1348
@@ -1387,7 +1352,7 @@ int skl_reset_pipe(struct skl_sst *ctx, struct skl_pipe *pipe)
1387} 1352}
1388 1353
1389/* Algo parameter set helper function */ 1354/* Algo parameter set helper function */
1390int skl_set_module_params(struct skl_sst *ctx, u32 *params, int size, 1355int skl_set_module_params(struct skl_dev *skl, u32 *params, int size,
1391 u32 param_id, struct skl_module_cfg *mcfg) 1356 u32 param_id, struct skl_module_cfg *mcfg)
1392{ 1357{
1393 struct skl_ipc_large_config_msg msg; 1358 struct skl_ipc_large_config_msg msg;
@@ -1397,18 +1362,19 @@ int skl_set_module_params(struct skl_sst *ctx, u32 *params, int size,
1397 msg.param_data_size = size; 1362 msg.param_data_size = size;
1398 msg.large_param_id = param_id; 1363 msg.large_param_id = param_id;
1399 1364
1400 return skl_ipc_set_large_config(&ctx->ipc, &msg, params); 1365 return skl_ipc_set_large_config(&skl->ipc, &msg, params);
1401} 1366}
1402 1367
1403int skl_get_module_params(struct skl_sst *ctx, u32 *params, int size, 1368int skl_get_module_params(struct skl_dev *skl, u32 *params, int size,
1404 u32 param_id, struct skl_module_cfg *mcfg) 1369 u32 param_id, struct skl_module_cfg *mcfg)
1405{ 1370{
1406 struct skl_ipc_large_config_msg msg; 1371 struct skl_ipc_large_config_msg msg;
1372 size_t bytes = size;
1407 1373
1408 msg.module_id = mcfg->id.module_id; 1374 msg.module_id = mcfg->id.module_id;
1409 msg.instance_id = mcfg->id.pvt_id; 1375 msg.instance_id = mcfg->id.pvt_id;
1410 msg.param_data_size = size; 1376 msg.param_data_size = size;
1411 msg.large_param_id = param_id; 1377 msg.large_param_id = param_id;
1412 1378
1413 return skl_ipc_get_large_config(&ctx->ipc, &msg, params); 1379 return skl_ipc_get_large_config(&skl->ipc, &msg, &params, &bytes);
1414} 1380}
diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c
index 1132109cb992..19f328d71f24 100644
--- a/sound/soc/intel/skylake/skl-nhlt.c
+++ b/sound/soc/intel/skylake/skl-nhlt.c
@@ -9,57 +9,10 @@
9 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 9 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 */ 10 */
11#include <linux/pci.h> 11#include <linux/pci.h>
12#include <sound/intel-nhlt.h>
12#include "skl.h" 13#include "skl.h"
13#include "skl-i2s.h" 14#include "skl-i2s.h"
14 15
15#define NHLT_ACPI_HEADER_SIG "NHLT"
16
17/* Unique identification for getting NHLT blobs */
18static guid_t osc_guid =
19 GUID_INIT(0xA69F886E, 0x6CEB, 0x4594,
20 0xA4, 0x1F, 0x7B, 0x5D, 0xCE, 0x24, 0xC5, 0x53);
21
22
23struct nhlt_acpi_table *skl_nhlt_init(struct device *dev)
24{
25 acpi_handle handle;
26 union acpi_object *obj;
27 struct nhlt_resource_desc *nhlt_ptr = NULL;
28 struct nhlt_acpi_table *nhlt_table = NULL;
29
30 handle = ACPI_HANDLE(dev);
31 if (!handle) {
32 dev_err(dev, "Didn't find ACPI_HANDLE\n");
33 return NULL;
34 }
35
36 obj = acpi_evaluate_dsm(handle, &osc_guid, 1, 1, NULL);
37 if (obj && obj->type == ACPI_TYPE_BUFFER) {
38 nhlt_ptr = (struct nhlt_resource_desc *)obj->buffer.pointer;
39 if (nhlt_ptr->length)
40 nhlt_table = (struct nhlt_acpi_table *)
41 memremap(nhlt_ptr->min_addr, nhlt_ptr->length,
42 MEMREMAP_WB);
43 ACPI_FREE(obj);
44 if (nhlt_table && (strncmp(nhlt_table->header.signature,
45 NHLT_ACPI_HEADER_SIG,
46 strlen(NHLT_ACPI_HEADER_SIG)) != 0)) {
47 memunmap(nhlt_table);
48 dev_err(dev, "NHLT ACPI header signature incorrect\n");
49 return NULL;
50 }
51 return nhlt_table;
52 }
53
54 dev_err(dev, "device specific method to extract NHLT blob failed\n");
55 return NULL;
56}
57
58void skl_nhlt_free(struct nhlt_acpi_table *nhlt)
59{
60 memunmap((void *) nhlt);
61}
62
63static struct nhlt_specific_cfg *skl_get_specific_cfg( 16static struct nhlt_specific_cfg *skl_get_specific_cfg(
64 struct device *dev, struct nhlt_fmt *fmt, 17 struct device *dev, struct nhlt_fmt *fmt,
65 u8 no_ch, u32 rate, u16 bps, u8 linktype) 18 u8 no_ch, u32 rate, u16 bps, u8 linktype)
@@ -126,7 +79,7 @@ static bool skl_check_ep_match(struct device *dev, struct nhlt_endpoint *epnt,
126} 79}
127 80
128struct nhlt_specific_cfg 81struct nhlt_specific_cfg
129*skl_get_ep_blob(struct skl *skl, u32 instance, u8 link_type, 82*skl_get_ep_blob(struct skl_dev *skl, u32 instance, u8 link_type,
130 u8 s_fmt, u8 num_ch, u32 s_rate, 83 u8 s_fmt, u8 num_ch, u32 s_rate,
131 u8 dirn, u8 dev_type) 84 u8 dirn, u8 dev_type)
132{ 85{
@@ -162,48 +115,6 @@ struct nhlt_specific_cfg
162 return NULL; 115 return NULL;
163} 116}
164 117
165int skl_get_dmic_geo(struct skl *skl)
166{
167 struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt;
168 struct nhlt_endpoint *epnt;
169 struct nhlt_dmic_array_config *cfg;
170 struct device *dev = &skl->pci->dev;
171 unsigned int dmic_geo = 0;
172 u8 j;
173
174 if (!nhlt)
175 return 0;
176
177 epnt = (struct nhlt_endpoint *)nhlt->desc;
178
179 for (j = 0; j < nhlt->endpoint_count; j++) {
180 if (epnt->linktype == NHLT_LINK_DMIC) {
181 cfg = (struct nhlt_dmic_array_config *)
182 (epnt->config.caps);
183 switch (cfg->array_type) {
184 case NHLT_MIC_ARRAY_2CH_SMALL:
185 case NHLT_MIC_ARRAY_2CH_BIG:
186 dmic_geo |= MIC_ARRAY_2CH;
187 break;
188
189 case NHLT_MIC_ARRAY_4CH_1ST_GEOM:
190 case NHLT_MIC_ARRAY_4CH_L_SHAPED:
191 case NHLT_MIC_ARRAY_4CH_2ND_GEOM:
192 dmic_geo |= MIC_ARRAY_4CH;
193 break;
194
195 default:
196 dev_warn(dev, "undefined DMIC array_type 0x%0x\n",
197 cfg->array_type);
198
199 }
200 }
201 epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length);
202 }
203
204 return dmic_geo;
205}
206
207static void skl_nhlt_trim_space(char *trim) 118static void skl_nhlt_trim_space(char *trim)
208{ 119{
209 char *s = trim; 120 char *s = trim;
@@ -219,13 +130,13 @@ static void skl_nhlt_trim_space(char *trim)
219 s[cnt] = '\0'; 130 s[cnt] = '\0';
220} 131}
221 132
222int skl_nhlt_update_topology_bin(struct skl *skl) 133int skl_nhlt_update_topology_bin(struct skl_dev *skl)
223{ 134{
224 struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt; 135 struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt;
225 struct hdac_bus *bus = skl_to_bus(skl); 136 struct hdac_bus *bus = skl_to_bus(skl);
226 struct device *dev = bus->dev; 137 struct device *dev = bus->dev;
227 138
228 dev_dbg(dev, "oem_id %.6s, oem_table_id %8s oem_revision %d\n", 139 dev_dbg(dev, "oem_id %.6s, oem_table_id %.8s oem_revision %d\n",
229 nhlt->header.oem_id, nhlt->header.oem_table_id, 140 nhlt->header.oem_id, nhlt->header.oem_table_id,
230 nhlt->header.oem_revision); 141 nhlt->header.oem_revision);
231 142
@@ -243,7 +154,7 @@ static ssize_t skl_nhlt_platform_id_show(struct device *dev,
243{ 154{
244 struct pci_dev *pci = to_pci_dev(dev); 155 struct pci_dev *pci = to_pci_dev(dev);
245 struct hdac_bus *bus = pci_get_drvdata(pci); 156 struct hdac_bus *bus = pci_get_drvdata(pci);
246 struct skl *skl = bus_to_skl(bus); 157 struct skl_dev *skl = bus_to_skl(bus);
247 struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt; 158 struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt;
248 char platform_id[32]; 159 char platform_id[32];
249 160
@@ -257,7 +168,7 @@ static ssize_t skl_nhlt_platform_id_show(struct device *dev,
257 168
258static DEVICE_ATTR(platform_id, 0444, skl_nhlt_platform_id_show, NULL); 169static DEVICE_ATTR(platform_id, 0444, skl_nhlt_platform_id_show, NULL);
259 170
260int skl_nhlt_create_sysfs(struct skl *skl) 171int skl_nhlt_create_sysfs(struct skl_dev *skl)
261{ 172{
262 struct device *dev = &skl->pci->dev; 173 struct device *dev = &skl->pci->dev;
263 174
@@ -267,7 +178,7 @@ int skl_nhlt_create_sysfs(struct skl *skl)
267 return 0; 178 return 0;
268} 179}
269 180
270void skl_nhlt_remove_sysfs(struct skl *skl) 181void skl_nhlt_remove_sysfs(struct skl_dev *skl)
271{ 182{
272 struct device *dev = &skl->pci->dev; 183 struct device *dev = &skl->pci->dev;
273 184
@@ -279,7 +190,7 @@ void skl_nhlt_remove_sysfs(struct skl *skl)
279 * stores all possible rates supported in a rate table for the corresponding 190 * stores all possible rates supported in a rate table for the corresponding
280 * sclk/sclkfs. 191 * sclk/sclkfs.
281 */ 192 */
282static void skl_get_ssp_clks(struct skl *skl, struct skl_ssp_clk *ssp_clks, 193static void skl_get_ssp_clks(struct skl_dev *skl, struct skl_ssp_clk *ssp_clks,
283 struct nhlt_fmt *fmt, u8 id) 194 struct nhlt_fmt *fmt, u8 id)
284{ 195{
285 struct skl_i2s_config_blob_ext *i2s_config_ext; 196 struct skl_i2s_config_blob_ext *i2s_config_ext;
@@ -377,7 +288,7 @@ static void skl_get_ssp_clks(struct skl *skl, struct skl_ssp_clk *ssp_clks,
377 } 288 }
378} 289}
379 290
380static void skl_get_mclk(struct skl *skl, struct skl_ssp_clk *mclk, 291static void skl_get_mclk(struct skl_dev *skl, struct skl_ssp_clk *mclk,
381 struct nhlt_fmt *fmt, u8 id) 292 struct nhlt_fmt *fmt, u8 id)
382{ 293{
383 struct skl_i2s_config_blob_ext *i2s_config_ext; 294 struct skl_i2s_config_blob_ext *i2s_config_ext;
@@ -421,7 +332,7 @@ static void skl_get_mclk(struct skl *skl, struct skl_ssp_clk *mclk,
421 mclk[id].parent_name = parent->name; 332 mclk[id].parent_name = parent->name;
422} 333}
423 334
424void skl_get_clks(struct skl *skl, struct skl_ssp_clk *ssp_clks) 335void skl_get_clks(struct skl_dev *skl, struct skl_ssp_clk *ssp_clks)
425{ 336{
426 struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt; 337 struct nhlt_acpi_table *nhlt = (struct nhlt_acpi_table *)skl->nhlt;
427 struct nhlt_endpoint *epnt; 338 struct nhlt_endpoint *epnt;
diff --git a/sound/soc/intel/skylake/skl-nhlt.h b/sound/soc/intel/skylake/skl-nhlt.h
deleted file mode 100644
index f85fbf9c7ce4..000000000000
--- a/sound/soc/intel/skylake/skl-nhlt.h
+++ /dev/null
@@ -1,119 +0,0 @@
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * skl-nhlt.h - Intel HDA Platform NHLT header
4 *
5 * Copyright (C) 2015 Intel Corp
6 * Author: Sanjiv Kumar <sanjiv.kumar@intel.com>
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 *
9 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 */
11#ifndef __SKL_NHLT_H__
12#define __SKL_NHLT_H__
13
14#include <linux/acpi.h>
15
16struct wav_fmt {
17 u16 fmt_tag;
18 u16 channels;
19 u32 samples_per_sec;
20 u32 avg_bytes_per_sec;
21 u16 block_align;
22 u16 bits_per_sample;
23 u16 cb_size;
24} __packed;
25
26struct wav_fmt_ext {
27 struct wav_fmt fmt;
28 union samples {
29 u16 valid_bits_per_sample;
30 u16 samples_per_block;
31 u16 reserved;
32 } sample;
33 u32 channel_mask;
34 u8 sub_fmt[16];
35} __packed;
36
37enum nhlt_link_type {
38 NHLT_LINK_HDA = 0,
39 NHLT_LINK_DSP = 1,
40 NHLT_LINK_DMIC = 2,
41 NHLT_LINK_SSP = 3,
42 NHLT_LINK_INVALID
43};
44
45enum nhlt_device_type {
46 NHLT_DEVICE_BT = 0,
47 NHLT_DEVICE_DMIC = 1,
48 NHLT_DEVICE_I2S = 4,
49 NHLT_DEVICE_INVALID
50};
51
52struct nhlt_specific_cfg {
53 u32 size;
54 u8 caps[0];
55} __packed;
56
57struct nhlt_fmt_cfg {
58 struct wav_fmt_ext fmt_ext;
59 struct nhlt_specific_cfg config;
60} __packed;
61
62struct nhlt_fmt {
63 u8 fmt_count;
64 struct nhlt_fmt_cfg fmt_config[0];
65} __packed;
66
67struct nhlt_endpoint {
68 u32 length;
69 u8 linktype;
70 u8 instance_id;
71 u16 vendor_id;
72 u16 device_id;
73 u16 revision_id;
74 u32 subsystem_id;
75 u8 device_type;
76 u8 direction;
77 u8 virtual_bus_id;
78 struct nhlt_specific_cfg config;
79} __packed;
80
81struct nhlt_acpi_table {
82 struct acpi_table_header header;
83 u8 endpoint_count;
84 struct nhlt_endpoint desc[0];
85} __packed;
86
87struct nhlt_resource_desc {
88 u32 extra;
89 u16 flags;
90 u64 addr_spc_gra;
91 u64 min_addr;
92 u64 max_addr;
93 u64 addr_trans_offset;
94 u64 length;
95} __packed;
96
97#define MIC_ARRAY_2CH 2
98#define MIC_ARRAY_4CH 4
99
100struct nhlt_tdm_config {
101 u8 virtual_slot;
102 u8 config_type;
103} __packed;
104
105struct nhlt_dmic_array_config {
106 struct nhlt_tdm_config tdm_config;
107 u8 array_type;
108} __packed;
109
110enum {
111 NHLT_MIC_ARRAY_2CH_SMALL = 0xa,
112 NHLT_MIC_ARRAY_2CH_BIG = 0xb,
113 NHLT_MIC_ARRAY_4CH_1ST_GEOM = 0xc,
114 NHLT_MIC_ARRAY_4CH_L_SHAPED = 0xd,
115 NHLT_MIC_ARRAY_4CH_2ND_GEOM = 0xe,
116 NHLT_MIC_ARRAY_VENDOR_DEFINED = 0xf,
117};
118
119#endif
diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c
index 760bbcf9a469..7f287424af9b 100644
--- a/sound/soc/intel/skylake/skl-pcm.c
+++ b/sound/soc/intel/skylake/skl-pcm.c
@@ -116,7 +116,7 @@ static void skl_set_suspend_active(struct snd_pcm_substream *substream,
116{ 116{
117 struct hdac_bus *bus = dev_get_drvdata(dai->dev); 117 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
118 struct snd_soc_dapm_widget *w; 118 struct snd_soc_dapm_widget *w;
119 struct skl *skl = bus_to_skl(bus); 119 struct skl_dev *skl = bus_to_skl(bus);
120 120
121 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) 121 if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK)
122 w = dai->playback_widget; 122 w = dai->playback_widget;
@@ -132,7 +132,7 @@ static void skl_set_suspend_active(struct snd_pcm_substream *substream,
132int skl_pcm_host_dma_prepare(struct device *dev, struct skl_pipe_params *params) 132int skl_pcm_host_dma_prepare(struct device *dev, struct skl_pipe_params *params)
133{ 133{
134 struct hdac_bus *bus = dev_get_drvdata(dev); 134 struct hdac_bus *bus = dev_get_drvdata(dev);
135 struct skl *skl = bus_to_skl(bus); 135 struct skl_dev *skl = bus_to_skl(bus);
136 unsigned int format_val; 136 unsigned int format_val;
137 struct hdac_stream *hstream; 137 struct hdac_stream *hstream;
138 struct hdac_ext_stream *stream; 138 struct hdac_ext_stream *stream;
@@ -224,7 +224,7 @@ static int skl_pcm_open(struct snd_pcm_substream *substream,
224 struct hdac_ext_stream *stream; 224 struct hdac_ext_stream *stream;
225 struct snd_pcm_runtime *runtime = substream->runtime; 225 struct snd_pcm_runtime *runtime = substream->runtime;
226 struct skl_dma_params *dma_params; 226 struct skl_dma_params *dma_params;
227 struct skl *skl = get_skl_ctx(dai->dev); 227 struct skl_dev *skl = get_skl_ctx(dai->dev);
228 struct skl_module_cfg *mconfig; 228 struct skl_module_cfg *mconfig;
229 229
230 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name); 230 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
@@ -271,7 +271,7 @@ static int skl_pcm_open(struct snd_pcm_substream *substream,
271static int skl_pcm_prepare(struct snd_pcm_substream *substream, 271static int skl_pcm_prepare(struct snd_pcm_substream *substream,
272 struct snd_soc_dai *dai) 272 struct snd_soc_dai *dai)
273{ 273{
274 struct skl *skl = get_skl_ctx(dai->dev); 274 struct skl_dev *skl = get_skl_ctx(dai->dev);
275 struct skl_module_cfg *mconfig; 275 struct skl_module_cfg *mconfig;
276 int ret; 276 int ret;
277 277
@@ -288,7 +288,7 @@ static int skl_pcm_prepare(struct snd_pcm_substream *substream,
288 mconfig->pipe->state == SKL_PIPE_CREATED || 288 mconfig->pipe->state == SKL_PIPE_CREATED ||
289 mconfig->pipe->state == SKL_PIPE_PAUSED)) { 289 mconfig->pipe->state == SKL_PIPE_PAUSED)) {
290 290
291 ret = skl_reset_pipe(skl->skl_sst, mconfig->pipe); 291 ret = skl_reset_pipe(skl, mconfig->pipe);
292 292
293 if (ret < 0) 293 if (ret < 0)
294 return ret; 294 return ret;
@@ -350,7 +350,7 @@ static void skl_pcm_close(struct snd_pcm_substream *substream,
350 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream); 350 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
351 struct hdac_bus *bus = dev_get_drvdata(dai->dev); 351 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
352 struct skl_dma_params *dma_params = NULL; 352 struct skl_dma_params *dma_params = NULL;
353 struct skl *skl = bus_to_skl(bus); 353 struct skl_dev *skl = bus_to_skl(bus);
354 struct skl_module_cfg *mconfig; 354 struct skl_module_cfg *mconfig;
355 355
356 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name); 356 dev_dbg(dai->dev, "%s: %s\n", __func__, dai->name);
@@ -370,9 +370,9 @@ static void skl_pcm_close(struct snd_pcm_substream *substream,
370 * CGCTL.MISCBDCGE if disabled by driver 370 * CGCTL.MISCBDCGE if disabled by driver
371 */ 371 */
372 if (!strncmp(dai->name, "Reference Pin", 13) && 372 if (!strncmp(dai->name, "Reference Pin", 13) &&
373 skl->skl_sst->miscbdcg_disabled) { 373 skl->miscbdcg_disabled) {
374 skl->skl_sst->enable_miscbdcge(dai->dev, true); 374 skl->enable_miscbdcge(dai->dev, true);
375 skl->skl_sst->miscbdcg_disabled = false; 375 skl->miscbdcg_disabled = false;
376 } 376 }
377 377
378 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream); 378 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
@@ -387,7 +387,7 @@ static int skl_pcm_hw_free(struct snd_pcm_substream *substream,
387{ 387{
388 struct hdac_bus *bus = dev_get_drvdata(dai->dev); 388 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
389 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream); 389 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
390 struct skl *skl = get_skl_ctx(dai->dev); 390 struct skl_dev *skl = get_skl_ctx(dai->dev);
391 struct skl_module_cfg *mconfig; 391 struct skl_module_cfg *mconfig;
392 int ret; 392 int ret;
393 393
@@ -396,7 +396,7 @@ static int skl_pcm_hw_free(struct snd_pcm_substream *substream,
396 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream); 396 mconfig = skl_tplg_fe_get_cpr_module(dai, substream->stream);
397 397
398 if (mconfig) { 398 if (mconfig) {
399 ret = skl_reset_pipe(skl->skl_sst, mconfig->pipe); 399 ret = skl_reset_pipe(skl, mconfig->pipe);
400 if (ret < 0) 400 if (ret < 0)
401 dev_err(dai->dev, "%s:Reset failed ret =%d", 401 dev_err(dai->dev, "%s:Reset failed ret =%d",
402 __func__, ret); 402 __func__, ret);
@@ -471,8 +471,7 @@ static int skl_decoupled_trigger(struct snd_pcm_substream *substream,
471static int skl_pcm_trigger(struct snd_pcm_substream *substream, int cmd, 471static int skl_pcm_trigger(struct snd_pcm_substream *substream, int cmd,
472 struct snd_soc_dai *dai) 472 struct snd_soc_dai *dai)
473{ 473{
474 struct skl *skl = get_skl_ctx(dai->dev); 474 struct skl_dev *skl = get_skl_ctx(dai->dev);
475 struct skl_sst *ctx = skl->skl_sst;
476 struct skl_module_cfg *mconfig; 475 struct skl_module_cfg *mconfig;
477 struct hdac_bus *bus = get_bus_ctx(substream); 476 struct hdac_bus *bus = get_bus_ctx(substream);
478 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream); 477 struct hdac_ext_stream *stream = get_hdac_ext_stream(substream);
@@ -515,7 +514,7 @@ static int skl_pcm_trigger(struct snd_pcm_substream *substream, int cmd,
515 ret = skl_decoupled_trigger(substream, cmd); 514 ret = skl_decoupled_trigger(substream, cmd);
516 if (ret < 0) 515 if (ret < 0)
517 return ret; 516 return ret;
518 return skl_run_pipe(ctx, mconfig->pipe); 517 return skl_run_pipe(skl, mconfig->pipe);
519 break; 518 break;
520 519
521 case SNDRV_PCM_TRIGGER_PAUSE_PUSH: 520 case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
@@ -526,7 +525,7 @@ static int skl_pcm_trigger(struct snd_pcm_substream *substream, int cmd,
526 * there are no underrun/overrun in the case if there is a delay 525 * there are no underrun/overrun in the case if there is a delay
527 * between the two operations. 526 * between the two operations.
528 */ 527 */
529 ret = skl_stop_pipe(ctx, mconfig->pipe); 528 ret = skl_stop_pipe(skl, mconfig->pipe);
530 if (ret < 0) 529 if (ret < 0)
531 return ret; 530 return ret;
532 531
@@ -602,14 +601,14 @@ static int skl_link_hw_params(struct snd_pcm_substream *substream,
602static int skl_link_pcm_prepare(struct snd_pcm_substream *substream, 601static int skl_link_pcm_prepare(struct snd_pcm_substream *substream,
603 struct snd_soc_dai *dai) 602 struct snd_soc_dai *dai)
604{ 603{
605 struct skl *skl = get_skl_ctx(dai->dev); 604 struct skl_dev *skl = get_skl_ctx(dai->dev);
606 struct skl_module_cfg *mconfig = NULL; 605 struct skl_module_cfg *mconfig = NULL;
607 606
608 /* In case of XRUN recovery, reset the FW pipe to clean state */ 607 /* In case of XRUN recovery, reset the FW pipe to clean state */
609 mconfig = skl_tplg_be_get_cpr_module(dai, substream->stream); 608 mconfig = skl_tplg_be_get_cpr_module(dai, substream->stream);
610 if (mconfig && !mconfig->pipe->passthru && 609 if (mconfig && !mconfig->pipe->passthru &&
611 (substream->runtime->status->state == SNDRV_PCM_STATE_XRUN)) 610 (substream->runtime->status->state == SNDRV_PCM_STATE_XRUN))
612 skl_reset_pipe(skl->skl_sst, mconfig->pipe); 611 skl_reset_pipe(skl, mconfig->pipe);
613 612
614 return 0; 613 return 0;
615} 614}
@@ -1301,7 +1300,7 @@ static int skl_pcm_new(struct snd_soc_pcm_runtime *rtd)
1301 struct hdac_bus *bus = dev_get_drvdata(dai->dev); 1300 struct hdac_bus *bus = dev_get_drvdata(dai->dev);
1302 struct snd_pcm *pcm = rtd->pcm; 1301 struct snd_pcm *pcm = rtd->pcm;
1303 unsigned int size; 1302 unsigned int size;
1304 struct skl *skl = bus_to_skl(bus); 1303 struct skl_dev *skl = bus_to_skl(bus);
1305 1304
1306 if (dai->driver->playback.channels_min || 1305 if (dai->driver->playback.channels_min ||
1307 dai->driver->capture.channels_min) { 1306 dai->driver->capture.channels_min) {
@@ -1318,9 +1317,9 @@ static int skl_pcm_new(struct snd_soc_pcm_runtime *rtd)
1318 return 0; 1317 return 0;
1319} 1318}
1320 1319
1321static int skl_get_module_info(struct skl *skl, struct skl_module_cfg *mconfig) 1320static int skl_get_module_info(struct skl_dev *skl,
1321 struct skl_module_cfg *mconfig)
1322{ 1322{
1323 struct skl_sst *ctx = skl->skl_sst;
1324 struct skl_module_inst_id *pin_id; 1323 struct skl_module_inst_id *pin_id;
1325 guid_t *uuid_mod, *uuid_tplg; 1324 guid_t *uuid_mod, *uuid_tplg;
1326 struct skl_module *skl_module; 1325 struct skl_module *skl_module;
@@ -1329,12 +1328,12 @@ static int skl_get_module_info(struct skl *skl, struct skl_module_cfg *mconfig)
1329 1328
1330 uuid_mod = (guid_t *)mconfig->guid; 1329 uuid_mod = (guid_t *)mconfig->guid;
1331 1330
1332 if (list_empty(&ctx->uuid_list)) { 1331 if (list_empty(&skl->uuid_list)) {
1333 dev_err(ctx->dev, "Module list is empty\n"); 1332 dev_err(skl->dev, "Module list is empty\n");
1334 return -EIO; 1333 return -EIO;
1335 } 1334 }
1336 1335
1337 list_for_each_entry(module, &ctx->uuid_list, list) { 1336 list_for_each_entry(module, &skl->uuid_list, list) {
1338 if (guid_equal(uuid_mod, &module->uuid)) { 1337 if (guid_equal(uuid_mod, &module->uuid)) {
1339 mconfig->id.module_id = module->id; 1338 mconfig->id.module_id = module->id;
1340 if (mconfig->module) 1339 if (mconfig->module)
@@ -1361,7 +1360,7 @@ static int skl_get_module_info(struct skl *skl, struct skl_module_cfg *mconfig)
1361 if (skl->nr_modules && ret) 1360 if (skl->nr_modules && ret)
1362 return ret; 1361 return ret;
1363 1362
1364 list_for_each_entry(module, &ctx->uuid_list, list) { 1363 list_for_each_entry(module, &skl->uuid_list, list) {
1365 for (i = 0; i < MAX_IN_QUEUE; i++) { 1364 for (i = 0; i < MAX_IN_QUEUE; i++) {
1366 pin_id = &mconfig->m_in_pin[i].id; 1365 pin_id = &mconfig->m_in_pin[i].id;
1367 if (guid_equal(&pin_id->mod_uuid, &module->uuid)) 1366 if (guid_equal(&pin_id->mod_uuid, &module->uuid))
@@ -1378,7 +1377,7 @@ static int skl_get_module_info(struct skl *skl, struct skl_module_cfg *mconfig)
1378 return 0; 1377 return 0;
1379} 1378}
1380 1379
1381static int skl_populate_modules(struct skl *skl) 1380static int skl_populate_modules(struct skl_dev *skl)
1382{ 1381{
1383 struct skl_pipeline *p; 1382 struct skl_pipeline *p;
1384 struct skl_pipe_module *m; 1383 struct skl_pipe_module *m;
@@ -1393,7 +1392,7 @@ static int skl_populate_modules(struct skl *skl)
1393 1392
1394 ret = skl_get_module_info(skl, mconfig); 1393 ret = skl_get_module_info(skl, mconfig);
1395 if (ret < 0) { 1394 if (ret < 0) {
1396 dev_err(skl->skl_sst->dev, 1395 dev_err(skl->dev,
1397 "query module info failed\n"); 1396 "query module info failed\n");
1398 return ret; 1397 return ret;
1399 } 1398 }
@@ -1408,7 +1407,7 @@ static int skl_populate_modules(struct skl *skl)
1408static int skl_platform_soc_probe(struct snd_soc_component *component) 1407static int skl_platform_soc_probe(struct snd_soc_component *component)
1409{ 1408{
1410 struct hdac_bus *bus = dev_get_drvdata(component->dev); 1409 struct hdac_bus *bus = dev_get_drvdata(component->dev);
1411 struct skl *skl = bus_to_skl(bus); 1410 struct skl_dev *skl = bus_to_skl(bus);
1412 const struct skl_dsp_ops *ops; 1411 const struct skl_dsp_ops *ops;
1413 int ret; 1412 int ret;
1414 1413
@@ -1434,22 +1433,21 @@ static int skl_platform_soc_probe(struct snd_soc_component *component)
1434 * Disable dynamic clock and power gating during firmware 1433 * Disable dynamic clock and power gating during firmware
1435 * and library download 1434 * and library download
1436 */ 1435 */
1437 skl->skl_sst->enable_miscbdcge(component->dev, false); 1436 skl->enable_miscbdcge(component->dev, false);
1438 skl->skl_sst->clock_power_gating(component->dev, false); 1437 skl->clock_power_gating(component->dev, false);
1439 1438
1440 ret = ops->init_fw(component->dev, skl->skl_sst); 1439 ret = ops->init_fw(component->dev, skl);
1441 skl->skl_sst->enable_miscbdcge(component->dev, true); 1440 skl->enable_miscbdcge(component->dev, true);
1442 skl->skl_sst->clock_power_gating(component->dev, true); 1441 skl->clock_power_gating(component->dev, true);
1443 if (ret < 0) { 1442 if (ret < 0) {
1444 dev_err(component->dev, "Failed to boot first fw: %d\n", ret); 1443 dev_err(component->dev, "Failed to boot first fw: %d\n", ret);
1445 return ret; 1444 return ret;
1446 } 1445 }
1447 skl_populate_modules(skl); 1446 skl_populate_modules(skl);
1448 skl->skl_sst->update_d0i3c = skl_update_d0i3c; 1447 skl->update_d0i3c = skl_update_d0i3c;
1449 skl_dsp_enable_notification(skl->skl_sst, false);
1450 1448
1451 if (skl->cfg.astate_cfg != NULL) { 1449 if (skl->cfg.astate_cfg != NULL) {
1452 skl_dsp_set_astate_cfg(skl->skl_sst, 1450 skl_dsp_set_astate_cfg(skl,
1453 skl->cfg.astate_cfg->count, 1451 skl->cfg.astate_cfg->count,
1454 skl->cfg.astate_cfg); 1452 skl->cfg.astate_cfg);
1455 } 1453 }
@@ -1463,7 +1461,7 @@ static int skl_platform_soc_probe(struct snd_soc_component *component)
1463static void skl_pcm_remove(struct snd_soc_component *component) 1461static void skl_pcm_remove(struct snd_soc_component *component)
1464{ 1462{
1465 struct hdac_bus *bus = dev_get_drvdata(component->dev); 1463 struct hdac_bus *bus = dev_get_drvdata(component->dev);
1466 struct skl *skl = bus_to_skl(bus); 1464 struct skl_dev *skl = bus_to_skl(bus);
1467 1465
1468 skl_tplg_exit(component, bus); 1466 skl_tplg_exit(component, bus);
1469 1467
@@ -1486,7 +1484,7 @@ int skl_platform_register(struct device *dev)
1486 struct snd_soc_dai_driver *dais; 1484 struct snd_soc_dai_driver *dais;
1487 int num_dais = ARRAY_SIZE(skl_platform_dai); 1485 int num_dais = ARRAY_SIZE(skl_platform_dai);
1488 struct hdac_bus *bus = dev_get_drvdata(dev); 1486 struct hdac_bus *bus = dev_get_drvdata(dev);
1489 struct skl *skl = bus_to_skl(bus); 1487 struct skl_dev *skl = bus_to_skl(bus);
1490 1488
1491 skl->dais = kmemdup(skl_platform_dai, sizeof(skl_platform_dai), 1489 skl->dais = kmemdup(skl_platform_dai, sizeof(skl_platform_dai),
1492 GFP_KERNEL); 1490 GFP_KERNEL);
@@ -1520,7 +1518,7 @@ err:
1520int skl_platform_unregister(struct device *dev) 1518int skl_platform_unregister(struct device *dev)
1521{ 1519{
1522 struct hdac_bus *bus = dev_get_drvdata(dev); 1520 struct hdac_bus *bus = dev_get_drvdata(dev);
1523 struct skl *skl = bus_to_skl(bus); 1521 struct skl_dev *skl = bus_to_skl(bus);
1524 struct skl_module_deferred_bind *modules, *tmp; 1522 struct skl_module_deferred_bind *modules, *tmp;
1525 1523
1526 if (!list_empty(&skl->bind_list)) { 1524 if (!list_empty(&skl->bind_list)) {
diff --git a/sound/soc/intel/skylake/skl-ssp-clk.c b/sound/soc/intel/skylake/skl-ssp-clk.c
index 5bb6e40d4d3e..1c0e5226cb5b 100644
--- a/sound/soc/intel/skylake/skl-ssp-clk.c
+++ b/sound/soc/intel/skylake/skl-ssp-clk.c
@@ -11,6 +11,7 @@
11#include <linux/platform_device.h> 11#include <linux/platform_device.h>
12#include <linux/clk-provider.h> 12#include <linux/clk-provider.h>
13#include <linux/clkdev.h> 13#include <linux/clkdev.h>
14#include <sound/intel-nhlt.h>
14#include "skl.h" 15#include "skl.h"
15#include "skl-ssp-clk.h" 16#include "skl-ssp-clk.h"
16#include "skl-topology.h" 17#include "skl-topology.h"
@@ -101,7 +102,7 @@ static void skl_fill_clk_ipc(struct skl_clk_rate_cfg_table *rcfg, u8 clk_type)
101} 102}
102 103
103/* Sends dma control IPC to turn the clock ON/OFF */ 104/* Sends dma control IPC to turn the clock ON/OFF */
104static int skl_send_clk_dma_control(struct skl *skl, 105static int skl_send_clk_dma_control(struct skl_dev *skl,
105 struct skl_clk_rate_cfg_table *rcfg, 106 struct skl_clk_rate_cfg_table *rcfg,
106 u32 vbus_id, u8 clk_type, 107 u32 vbus_id, u8 clk_type,
107 bool enable) 108 bool enable)
@@ -152,7 +153,7 @@ static int skl_send_clk_dma_control(struct skl *skl,
152 memcpy(i2s_config + sp_cfg->size, data, size); 153 memcpy(i2s_config + sp_cfg->size, data, size);
153 154
154 node_id = ((SKL_DMA_I2S_LINK_INPUT_CLASS << 8) | (vbus_id << 4)); 155 node_id = ((SKL_DMA_I2S_LINK_INPUT_CLASS << 8) | (vbus_id << 4));
155 ret = skl_dsp_set_dma_control(skl->skl_sst, (u32 *)i2s_config, 156 ret = skl_dsp_set_dma_control(skl, (u32 *)i2s_config,
156 i2s_config_size, node_id); 157 i2s_config_size, node_id);
157 kfree(i2s_config); 158 kfree(i2s_config);
158 159
diff --git a/sound/soc/intel/skylake/skl-sst-dsp.c b/sound/soc/intel/skylake/skl-sst-dsp.c
index 36590c5b4673..225706d148d8 100644
--- a/sound/soc/intel/skylake/skl-sst-dsp.c
+++ b/sound/soc/intel/skylake/skl-sst-dsp.c
@@ -12,7 +12,7 @@
12#include "../common/sst-dsp.h" 12#include "../common/sst-dsp.h"
13#include "../common/sst-ipc.h" 13#include "../common/sst-ipc.h"
14#include "../common/sst-dsp-priv.h" 14#include "../common/sst-dsp-priv.h"
15#include "skl-sst-ipc.h" 15#include "skl.h"
16 16
17/* various timeout values */ 17/* various timeout values */
18#define SKL_DSP_PU_TO 50 18#define SKL_DSP_PU_TO 50
@@ -33,7 +33,7 @@ void skl_dsp_set_state_locked(struct sst_dsp *ctx, int state)
33 */ 33 */
34void skl_dsp_init_core_state(struct sst_dsp *ctx) 34void skl_dsp_init_core_state(struct sst_dsp *ctx)
35{ 35{
36 struct skl_sst *skl = ctx->thread_context; 36 struct skl_dev *skl = ctx->thread_context;
37 int i; 37 int i;
38 38
39 skl->cores.state[SKL_DSP_CORE0_ID] = SKL_DSP_RUNNING; 39 skl->cores.state[SKL_DSP_CORE0_ID] = SKL_DSP_RUNNING;
@@ -48,7 +48,7 @@ void skl_dsp_init_core_state(struct sst_dsp *ctx)
48/* Get the mask for all enabled cores */ 48/* Get the mask for all enabled cores */
49unsigned int skl_dsp_get_enabled_cores(struct sst_dsp *ctx) 49unsigned int skl_dsp_get_enabled_cores(struct sst_dsp *ctx)
50{ 50{
51 struct skl_sst *skl = ctx->thread_context; 51 struct skl_dev *skl = ctx->thread_context;
52 unsigned int core_mask, en_cores_mask; 52 unsigned int core_mask, en_cores_mask;
53 u32 val; 53 u32 val;
54 54
@@ -335,7 +335,7 @@ irqreturn_t skl_dsp_sst_interrupt(int irq, void *dev_id)
335 */ 335 */
336int skl_dsp_get_core(struct sst_dsp *ctx, unsigned int core_id) 336int skl_dsp_get_core(struct sst_dsp *ctx, unsigned int core_id)
337{ 337{
338 struct skl_sst *skl = ctx->thread_context; 338 struct skl_dev *skl = ctx->thread_context;
339 int ret = 0; 339 int ret = 0;
340 340
341 if (core_id >= skl->cores.count) { 341 if (core_id >= skl->cores.count) {
@@ -364,7 +364,7 @@ EXPORT_SYMBOL_GPL(skl_dsp_get_core);
364 364
365int skl_dsp_put_core(struct sst_dsp *ctx, unsigned int core_id) 365int skl_dsp_put_core(struct sst_dsp *ctx, unsigned int core_id)
366{ 366{
367 struct skl_sst *skl = ctx->thread_context; 367 struct skl_dev *skl = ctx->thread_context;
368 int ret = 0; 368 int ret = 0;
369 369
370 if (core_id >= skl->cores.count) { 370 if (core_id >= skl->cores.count) {
diff --git a/sound/soc/intel/skylake/skl-sst-dsp.h b/sound/soc/intel/skylake/skl-sst-dsp.h
index a80219562036..cdfec0fca577 100644
--- a/sound/soc/intel/skylake/skl-sst-dsp.h
+++ b/sound/soc/intel/skylake/skl-sst-dsp.h
@@ -15,9 +15,9 @@
15#include "skl-sst-cldma.h" 15#include "skl-sst-cldma.h"
16 16
17struct sst_dsp; 17struct sst_dsp;
18struct skl_sst;
19struct sst_dsp_device; 18struct sst_dsp_device;
20struct skl_lib_info; 19struct skl_lib_info;
20struct skl_dev;
21 21
22/* Intel HD Audio General DSP Registers */ 22/* Intel HD Audio General DSP Registers */
23#define SKL_ADSP_GEN_BASE 0x0 23#define SKL_ADSP_GEN_BASE 0x0
@@ -222,32 +222,31 @@ int skl_dsp_put_core(struct sst_dsp *ctx, unsigned int core_id);
222int skl_dsp_boot(struct sst_dsp *ctx); 222int skl_dsp_boot(struct sst_dsp *ctx);
223int skl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq, 223int skl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
224 const char *fw_name, struct skl_dsp_loader_ops dsp_ops, 224 const char *fw_name, struct skl_dsp_loader_ops dsp_ops,
225 struct skl_sst **dsp); 225 struct skl_dev **dsp);
226int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq, 226int bxt_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
227 const char *fw_name, struct skl_dsp_loader_ops dsp_ops, 227 const char *fw_name, struct skl_dsp_loader_ops dsp_ops,
228 struct skl_sst **dsp); 228 struct skl_dev **dsp);
229int skl_sst_init_fw(struct device *dev, struct skl_sst *ctx); 229int skl_sst_init_fw(struct device *dev, struct skl_dev *skl);
230int bxt_sst_init_fw(struct device *dev, struct skl_sst *ctx); 230int bxt_sst_init_fw(struct device *dev, struct skl_dev *skl);
231void skl_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx); 231void skl_sst_dsp_cleanup(struct device *dev, struct skl_dev *skl);
232void bxt_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx); 232void bxt_sst_dsp_cleanup(struct device *dev, struct skl_dev *skl);
233 233
234int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw, 234int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw,
235 unsigned int offset, int index); 235 unsigned int offset, int index);
236int skl_get_pvt_id(struct skl_sst *ctx, guid_t *uuid_mod, int instance_id); 236int skl_get_pvt_id(struct skl_dev *skl, guid_t *uuid_mod, int instance_id);
237int skl_put_pvt_id(struct skl_sst *ctx, guid_t *uuid_mod, int *pvt_id); 237int skl_put_pvt_id(struct skl_dev *skl, guid_t *uuid_mod, int *pvt_id);
238int skl_get_pvt_instance_id_map(struct skl_sst *ctx, 238int skl_get_pvt_instance_id_map(struct skl_dev *skl,
239 int module_id, int instance_id); 239 int module_id, int instance_id);
240void skl_freeup_uuid_list(struct skl_sst *ctx); 240void skl_freeup_uuid_list(struct skl_dev *skl);
241 241
242int skl_dsp_strip_extended_manifest(struct firmware *fw); 242int skl_dsp_strip_extended_manifest(struct firmware *fw);
243void skl_dsp_enable_notification(struct skl_sst *ctx, bool enable);
244 243
245void skl_dsp_set_astate_cfg(struct skl_sst *ctx, u32 cnt, void *data); 244void skl_dsp_set_astate_cfg(struct skl_dev *skl, u32 cnt, void *data);
246 245
247int skl_sst_ctx_init(struct device *dev, int irq, const char *fw_name, 246int skl_sst_ctx_init(struct device *dev, int irq, const char *fw_name,
248 struct skl_dsp_loader_ops dsp_ops, struct skl_sst **dsp, 247 struct skl_dsp_loader_ops dsp_ops, struct skl_dev **dsp,
249 struct sst_dsp_device *skl_dev); 248 struct sst_dsp_device *skl_dev);
250int skl_prepare_lib_load(struct skl_sst *skl, struct skl_lib_info *linfo, 249int skl_prepare_lib_load(struct skl_dev *skl, struct skl_lib_info *linfo,
251 struct firmware *stripped_fw, 250 struct firmware *stripped_fw,
252 unsigned int hdr_offset, int index); 251 unsigned int hdr_offset, int index);
253void skl_release_library(struct skl_lib_info *linfo, int lib_count); 252void skl_release_library(struct skl_lib_info *linfo, int lib_count);
diff --git a/sound/soc/intel/skylake/skl-sst-ipc.c b/sound/soc/intel/skylake/skl-sst-ipc.c
index 2cc8f7d2d319..667cdddc289f 100644
--- a/sound/soc/intel/skylake/skl-sst-ipc.c
+++ b/sound/soc/intel/skylake/skl-sst-ipc.c
@@ -281,7 +281,7 @@ void skl_ipc_tx_data_copy(struct ipc_message *msg, char *tx_data,
281 size_t tx_size) 281 size_t tx_size)
282{ 282{
283 if (tx_size) 283 if (tx_size)
284 memcpy(msg->tx_data, tx_data, tx_size); 284 memcpy(msg->tx.data, tx_data, tx_size);
285} 285}
286 286
287static bool skl_ipc_is_dsp_busy(struct sst_dsp *dsp) 287static bool skl_ipc_is_dsp_busy(struct sst_dsp *dsp)
@@ -295,10 +295,10 @@ static bool skl_ipc_is_dsp_busy(struct sst_dsp *dsp)
295/* Lock to be held by caller */ 295/* Lock to be held by caller */
296static void skl_ipc_tx_msg(struct sst_generic_ipc *ipc, struct ipc_message *msg) 296static void skl_ipc_tx_msg(struct sst_generic_ipc *ipc, struct ipc_message *msg)
297{ 297{
298 struct skl_ipc_header *header = (struct skl_ipc_header *)(&msg->header); 298 struct skl_ipc_header *header = (struct skl_ipc_header *)(&msg->tx.header);
299 299
300 if (msg->tx_size) 300 if (msg->tx.size)
301 sst_dsp_outbox_write(ipc->dsp, msg->tx_data, msg->tx_size); 301 sst_dsp_outbox_write(ipc->dsp, msg->tx.data, msg->tx.size);
302 sst_dsp_shim_write_unlocked(ipc->dsp, SKL_ADSP_REG_HIPCIE, 302 sst_dsp_shim_write_unlocked(ipc->dsp, SKL_ADSP_REG_HIPCIE,
303 header->extension); 303 header->extension);
304 sst_dsp_shim_write_unlocked(ipc->dsp, SKL_ADSP_REG_HIPCI, 304 sst_dsp_shim_write_unlocked(ipc->dsp, SKL_ADSP_REG_HIPCI,
@@ -345,7 +345,7 @@ out:
345int skl_ipc_process_notification(struct sst_generic_ipc *ipc, 345int skl_ipc_process_notification(struct sst_generic_ipc *ipc,
346 struct skl_ipc_header header) 346 struct skl_ipc_header header)
347{ 347{
348 struct skl_sst *skl = container_of(ipc, struct skl_sst, ipc); 348 struct skl_dev *skl = container_of(ipc, struct skl_dev, ipc);
349 349
350 if (IPC_GLB_NOTIFY_MSG_TYPE(header.primary)) { 350 if (IPC_GLB_NOTIFY_MSG_TYPE(header.primary)) {
351 switch (IPC_GLB_NOTIFY_TYPE(header.primary)) { 351 switch (IPC_GLB_NOTIFY_TYPE(header.primary)) {
@@ -436,7 +436,7 @@ void skl_ipc_process_reply(struct sst_generic_ipc *ipc,
436 struct ipc_message *msg; 436 struct ipc_message *msg;
437 u32 reply = header.primary & IPC_GLB_REPLY_STATUS_MASK; 437 u32 reply = header.primary & IPC_GLB_REPLY_STATUS_MASK;
438 u64 *ipc_header = (u64 *)(&header); 438 u64 *ipc_header = (u64 *)(&header);
439 struct skl_sst *skl = container_of(ipc, struct skl_sst, ipc); 439 struct skl_dev *skl = container_of(ipc, struct skl_dev, ipc);
440 unsigned long flags; 440 unsigned long flags;
441 441
442 spin_lock_irqsave(&ipc->dsp->spinlock, flags); 442 spin_lock_irqsave(&ipc->dsp->spinlock, flags);
@@ -447,11 +447,12 @@ void skl_ipc_process_reply(struct sst_generic_ipc *ipc,
447 return; 447 return;
448 } 448 }
449 449
450 msg->rx.header = *ipc_header;
450 /* first process the header */ 451 /* first process the header */
451 if (reply == IPC_GLB_REPLY_SUCCESS) { 452 if (reply == IPC_GLB_REPLY_SUCCESS) {
452 dev_dbg(ipc->dev, "ipc FW reply %x: success\n", header.primary); 453 dev_dbg(ipc->dev, "ipc FW reply %x: success\n", header.primary);
453 /* copy the rx data from the mailbox */ 454 /* copy the rx data from the mailbox */
454 sst_dsp_inbox_read(ipc->dsp, msg->rx_data, msg->rx_size); 455 sst_dsp_inbox_read(ipc->dsp, msg->rx.data, msg->rx.size);
455 switch (IPC_GLB_NOTIFY_MSG_TYPE(header.primary)) { 456 switch (IPC_GLB_NOTIFY_MSG_TYPE(header.primary)) {
456 case IPC_GLB_LOAD_MULTIPLE_MODS: 457 case IPC_GLB_LOAD_MULTIPLE_MODS:
457 case IPC_GLB_LOAD_LIBRARY: 458 case IPC_GLB_LOAD_LIBRARY:
@@ -488,7 +489,7 @@ void skl_ipc_process_reply(struct sst_generic_ipc *ipc,
488irqreturn_t skl_dsp_irq_thread_handler(int irq, void *context) 489irqreturn_t skl_dsp_irq_thread_handler(int irq, void *context)
489{ 490{
490 struct sst_dsp *dsp = context; 491 struct sst_dsp *dsp = context;
491 struct skl_sst *skl = sst_dsp_get_thread_context(dsp); 492 struct skl_dev *skl = sst_dsp_get_thread_context(dsp);
492 struct sst_generic_ipc *ipc = &skl->ipc; 493 struct sst_generic_ipc *ipc = &skl->ipc;
493 struct skl_ipc_header header = {0}; 494 struct skl_ipc_header header = {0};
494 u32 hipcie, hipct, hipcte; 495 u32 hipcie, hipct, hipcte;
@@ -595,7 +596,7 @@ bool skl_ipc_int_status(struct sst_dsp *ctx)
595 SKL_ADSP_REG_ADSPIS) & SKL_ADSPIS_IPC; 596 SKL_ADSP_REG_ADSPIS) & SKL_ADSPIS_IPC;
596} 597}
597 598
598int skl_ipc_init(struct device *dev, struct skl_sst *skl) 599int skl_ipc_init(struct device *dev, struct skl_dev *skl)
599{ 600{
600 struct sst_generic_ipc *ipc; 601 struct sst_generic_ipc *ipc;
601 int err; 602 int err;
@@ -635,7 +636,7 @@ int skl_ipc_create_pipeline(struct sst_generic_ipc *ipc,
635 u16 ppl_mem_size, u8 ppl_type, u8 instance_id, u8 lp_mode) 636 u16 ppl_mem_size, u8 ppl_type, u8 instance_id, u8 lp_mode)
636{ 637{
637 struct skl_ipc_header header = {0}; 638 struct skl_ipc_header header = {0};
638 u64 *ipc_header = (u64 *)(&header); 639 struct sst_ipc_message request = {0};
639 int ret; 640 int ret;
640 641
641 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG); 642 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG);
@@ -646,9 +647,10 @@ int skl_ipc_create_pipeline(struct sst_generic_ipc *ipc,
646 header.primary |= IPC_PPL_MEM_SIZE(ppl_mem_size); 647 header.primary |= IPC_PPL_MEM_SIZE(ppl_mem_size);
647 648
648 header.extension = IPC_PPL_LP_MODE(lp_mode); 649 header.extension = IPC_PPL_LP_MODE(lp_mode);
650 request.header = *(u64 *)(&header);
649 651
650 dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary); 652 dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary);
651 ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0, NULL, 0); 653 ret = sst_ipc_tx_message_wait(ipc, request, NULL);
652 if (ret < 0) { 654 if (ret < 0) {
653 dev_err(ipc->dev, "ipc: create pipeline fail, err: %d\n", ret); 655 dev_err(ipc->dev, "ipc: create pipeline fail, err: %d\n", ret);
654 return ret; 656 return ret;
@@ -661,16 +663,17 @@ EXPORT_SYMBOL_GPL(skl_ipc_create_pipeline);
661int skl_ipc_delete_pipeline(struct sst_generic_ipc *ipc, u8 instance_id) 663int skl_ipc_delete_pipeline(struct sst_generic_ipc *ipc, u8 instance_id)
662{ 664{
663 struct skl_ipc_header header = {0}; 665 struct skl_ipc_header header = {0};
664 u64 *ipc_header = (u64 *)(&header); 666 struct sst_ipc_message request = {0};
665 int ret; 667 int ret;
666 668
667 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG); 669 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG);
668 header.primary |= IPC_MSG_DIR(IPC_MSG_REQUEST); 670 header.primary |= IPC_MSG_DIR(IPC_MSG_REQUEST);
669 header.primary |= IPC_GLB_TYPE(IPC_GLB_DELETE_PPL); 671 header.primary |= IPC_GLB_TYPE(IPC_GLB_DELETE_PPL);
670 header.primary |= IPC_INSTANCE_ID(instance_id); 672 header.primary |= IPC_INSTANCE_ID(instance_id);
673 request.header = *(u64 *)(&header);
671 674
672 dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary); 675 dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary);
673 ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0, NULL, 0); 676 ret = sst_ipc_tx_message_wait(ipc, request, NULL);
674 if (ret < 0) { 677 if (ret < 0) {
675 dev_err(ipc->dev, "ipc: delete pipeline failed, err %d\n", ret); 678 dev_err(ipc->dev, "ipc: delete pipeline failed, err %d\n", ret);
676 return ret; 679 return ret;
@@ -684,7 +687,7 @@ int skl_ipc_set_pipeline_state(struct sst_generic_ipc *ipc,
684 u8 instance_id, enum skl_ipc_pipeline_state state) 687 u8 instance_id, enum skl_ipc_pipeline_state state)
685{ 688{
686 struct skl_ipc_header header = {0}; 689 struct skl_ipc_header header = {0};
687 u64 *ipc_header = (u64 *)(&header); 690 struct sst_ipc_message request = {0};
688 int ret; 691 int ret;
689 692
690 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG); 693 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG);
@@ -692,9 +695,10 @@ int skl_ipc_set_pipeline_state(struct sst_generic_ipc *ipc,
692 header.primary |= IPC_GLB_TYPE(IPC_GLB_SET_PPL_STATE); 695 header.primary |= IPC_GLB_TYPE(IPC_GLB_SET_PPL_STATE);
693 header.primary |= IPC_INSTANCE_ID(instance_id); 696 header.primary |= IPC_INSTANCE_ID(instance_id);
694 header.primary |= IPC_PPL_STATE(state); 697 header.primary |= IPC_PPL_STATE(state);
698 request.header = *(u64 *)(&header);
695 699
696 dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary); 700 dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary);
697 ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0, NULL, 0); 701 ret = sst_ipc_tx_message_wait(ipc, request, NULL);
698 if (ret < 0) { 702 if (ret < 0) {
699 dev_err(ipc->dev, "ipc: set pipeline state failed, err: %d\n", ret); 703 dev_err(ipc->dev, "ipc: set pipeline state failed, err: %d\n", ret);
700 return ret; 704 return ret;
@@ -707,7 +711,7 @@ int
707skl_ipc_save_pipeline(struct sst_generic_ipc *ipc, u8 instance_id, int dma_id) 711skl_ipc_save_pipeline(struct sst_generic_ipc *ipc, u8 instance_id, int dma_id)
708{ 712{
709 struct skl_ipc_header header = {0}; 713 struct skl_ipc_header header = {0};
710 u64 *ipc_header = (u64 *)(&header); 714 struct sst_ipc_message request = {0};
711 int ret; 715 int ret;
712 716
713 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG); 717 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG);
@@ -716,8 +720,10 @@ skl_ipc_save_pipeline(struct sst_generic_ipc *ipc, u8 instance_id, int dma_id)
716 header.primary |= IPC_INSTANCE_ID(instance_id); 720 header.primary |= IPC_INSTANCE_ID(instance_id);
717 721
718 header.extension = IPC_DMA_ID(dma_id); 722 header.extension = IPC_DMA_ID(dma_id);
723 request.header = *(u64 *)(&header);
724
719 dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary); 725 dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary);
720 ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0, NULL, 0); 726 ret = sst_ipc_tx_message_wait(ipc, request, NULL);
721 if (ret < 0) { 727 if (ret < 0) {
722 dev_err(ipc->dev, "ipc: save pipeline failed, err: %d\n", ret); 728 dev_err(ipc->dev, "ipc: save pipeline failed, err: %d\n", ret);
723 return ret; 729 return ret;
@@ -730,16 +736,17 @@ EXPORT_SYMBOL_GPL(skl_ipc_save_pipeline);
730int skl_ipc_restore_pipeline(struct sst_generic_ipc *ipc, u8 instance_id) 736int skl_ipc_restore_pipeline(struct sst_generic_ipc *ipc, u8 instance_id)
731{ 737{
732 struct skl_ipc_header header = {0}; 738 struct skl_ipc_header header = {0};
733 u64 *ipc_header = (u64 *)(&header); 739 struct sst_ipc_message request = {0};
734 int ret; 740 int ret;
735 741
736 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG); 742 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG);
737 header.primary |= IPC_MSG_DIR(IPC_MSG_REQUEST); 743 header.primary |= IPC_MSG_DIR(IPC_MSG_REQUEST);
738 header.primary |= IPC_GLB_TYPE(IPC_GLB_RESTORE_PPL); 744 header.primary |= IPC_GLB_TYPE(IPC_GLB_RESTORE_PPL);
739 header.primary |= IPC_INSTANCE_ID(instance_id); 745 header.primary |= IPC_INSTANCE_ID(instance_id);
746 request.header = *(u64 *)(&header);
740 747
741 dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary); 748 dev_dbg(ipc->dev, "In %s header=%d\n", __func__, header.primary);
742 ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0, NULL, 0); 749 ret = sst_ipc_tx_message_wait(ipc, request, NULL);
743 if (ret < 0) { 750 if (ret < 0) {
744 dev_err(ipc->dev, "ipc: restore pipeline failed, err: %d\n", ret); 751 dev_err(ipc->dev, "ipc: restore pipeline failed, err: %d\n", ret);
745 return ret; 752 return ret;
@@ -753,7 +760,7 @@ int skl_ipc_set_dx(struct sst_generic_ipc *ipc, u8 instance_id,
753 u16 module_id, struct skl_ipc_dxstate_info *dx) 760 u16 module_id, struct skl_ipc_dxstate_info *dx)
754{ 761{
755 struct skl_ipc_header header = {0}; 762 struct skl_ipc_header header = {0};
756 u64 *ipc_header = (u64 *)(&header); 763 struct sst_ipc_message request;
757 int ret; 764 int ret;
758 765
759 header.primary = IPC_MSG_TARGET(IPC_MOD_MSG); 766 header.primary = IPC_MSG_TARGET(IPC_MOD_MSG);
@@ -762,10 +769,13 @@ int skl_ipc_set_dx(struct sst_generic_ipc *ipc, u8 instance_id,
762 header.primary |= IPC_MOD_INSTANCE_ID(instance_id); 769 header.primary |= IPC_MOD_INSTANCE_ID(instance_id);
763 header.primary |= IPC_MOD_ID(module_id); 770 header.primary |= IPC_MOD_ID(module_id);
764 771
772 request.header = *(u64 *)(&header);
773 request.data = dx;
774 request.size = sizeof(*dx);
775
765 dev_dbg(ipc->dev, "In %s primary =%x ext=%x\n", __func__, 776 dev_dbg(ipc->dev, "In %s primary =%x ext=%x\n", __func__,
766 header.primary, header.extension); 777 header.primary, header.extension);
767 ret = sst_ipc_tx_message_wait(ipc, *ipc_header, 778 ret = sst_ipc_tx_message_wait(ipc, request, NULL);
768 dx, sizeof(*dx), NULL, 0);
769 if (ret < 0) { 779 if (ret < 0) {
770 dev_err(ipc->dev, "ipc: set dx failed, err %d\n", ret); 780 dev_err(ipc->dev, "ipc: set dx failed, err %d\n", ret);
771 return ret; 781 return ret;
@@ -779,7 +789,7 @@ int skl_ipc_init_instance(struct sst_generic_ipc *ipc,
779 struct skl_ipc_init_instance_msg *msg, void *param_data) 789 struct skl_ipc_init_instance_msg *msg, void *param_data)
780{ 790{
781 struct skl_ipc_header header = {0}; 791 struct skl_ipc_header header = {0};
782 u64 *ipc_header = (u64 *)(&header); 792 struct sst_ipc_message request;
783 int ret; 793 int ret;
784 u32 *buffer = (u32 *)param_data; 794 u32 *buffer = (u32 *)param_data;
785 /* param_block_size must be in dwords */ 795 /* param_block_size must be in dwords */
@@ -799,10 +809,13 @@ int skl_ipc_init_instance(struct sst_generic_ipc *ipc,
799 header.extension |= IPC_PARAM_BLOCK_SIZE(param_block_size); 809 header.extension |= IPC_PARAM_BLOCK_SIZE(param_block_size);
800 header.extension |= IPC_DOMAIN(msg->domain); 810 header.extension |= IPC_DOMAIN(msg->domain);
801 811
812 request.header = *(u64 *)(&header);
813 request.data = param_data;
814 request.size = msg->param_data_size;
815
802 dev_dbg(ipc->dev, "In %s primary =%x ext=%x\n", __func__, 816 dev_dbg(ipc->dev, "In %s primary =%x ext=%x\n", __func__,
803 header.primary, header.extension); 817 header.primary, header.extension);
804 ret = sst_ipc_tx_message_wait(ipc, *ipc_header, param_data, 818 ret = sst_ipc_tx_message_wait(ipc, request, NULL);
805 msg->param_data_size, NULL, 0);
806 819
807 if (ret < 0) { 820 if (ret < 0) {
808 dev_err(ipc->dev, "ipc: init instance failed\n"); 821 dev_err(ipc->dev, "ipc: init instance failed\n");
@@ -817,7 +830,7 @@ int skl_ipc_bind_unbind(struct sst_generic_ipc *ipc,
817 struct skl_ipc_bind_unbind_msg *msg) 830 struct skl_ipc_bind_unbind_msg *msg)
818{ 831{
819 struct skl_ipc_header header = {0}; 832 struct skl_ipc_header header = {0};
820 u64 *ipc_header = (u64 *)(&header); 833 struct sst_ipc_message request = {0};
821 u8 bind_unbind = msg->bind ? IPC_MOD_BIND : IPC_MOD_UNBIND; 834 u8 bind_unbind = msg->bind ? IPC_MOD_BIND : IPC_MOD_UNBIND;
822 int ret; 835 int ret;
823 836
@@ -831,10 +844,11 @@ int skl_ipc_bind_unbind(struct sst_generic_ipc *ipc,
831 header.extension |= IPC_DST_MOD_INSTANCE_ID(msg->dst_instance_id); 844 header.extension |= IPC_DST_MOD_INSTANCE_ID(msg->dst_instance_id);
832 header.extension |= IPC_DST_QUEUE(msg->dst_queue); 845 header.extension |= IPC_DST_QUEUE(msg->dst_queue);
833 header.extension |= IPC_SRC_QUEUE(msg->src_queue); 846 header.extension |= IPC_SRC_QUEUE(msg->src_queue);
847 request.header = *(u64 *)(&header);
834 848
835 dev_dbg(ipc->dev, "In %s hdr=%x ext=%x\n", __func__, header.primary, 849 dev_dbg(ipc->dev, "In %s hdr=%x ext=%x\n", __func__, header.primary,
836 header.extension); 850 header.extension);
837 ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0, NULL, 0); 851 ret = sst_ipc_tx_message_wait(ipc, request, NULL);
838 if (ret < 0) { 852 if (ret < 0) {
839 dev_err(ipc->dev, "ipc: bind/unbind failed\n"); 853 dev_err(ipc->dev, "ipc: bind/unbind failed\n");
840 return ret; 854 return ret;
@@ -854,7 +868,7 @@ int skl_ipc_load_modules(struct sst_generic_ipc *ipc,
854 u8 module_cnt, void *data) 868 u8 module_cnt, void *data)
855{ 869{
856 struct skl_ipc_header header = {0}; 870 struct skl_ipc_header header = {0};
857 u64 *ipc_header = (u64 *)(&header); 871 struct sst_ipc_message request;
858 int ret; 872 int ret;
859 873
860 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG); 874 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG);
@@ -862,8 +876,11 @@ int skl_ipc_load_modules(struct sst_generic_ipc *ipc,
862 header.primary |= IPC_GLB_TYPE(IPC_GLB_LOAD_MULTIPLE_MODS); 876 header.primary |= IPC_GLB_TYPE(IPC_GLB_LOAD_MULTIPLE_MODS);
863 header.primary |= IPC_LOAD_MODULE_CNT(module_cnt); 877 header.primary |= IPC_LOAD_MODULE_CNT(module_cnt);
864 878
865 ret = sst_ipc_tx_message_nowait(ipc, *ipc_header, data, 879 request.header = *(u64 *)(&header);
866 (sizeof(u16) * module_cnt)); 880 request.data = data;
881 request.size = sizeof(u16) * module_cnt;
882
883 ret = sst_ipc_tx_message_nowait(ipc, request);
867 if (ret < 0) 884 if (ret < 0)
868 dev_err(ipc->dev, "ipc: load modules failed :%d\n", ret); 885 dev_err(ipc->dev, "ipc: load modules failed :%d\n", ret);
869 886
@@ -875,7 +892,7 @@ int skl_ipc_unload_modules(struct sst_generic_ipc *ipc, u8 module_cnt,
875 void *data) 892 void *data)
876{ 893{
877 struct skl_ipc_header header = {0}; 894 struct skl_ipc_header header = {0};
878 u64 *ipc_header = (u64 *)(&header); 895 struct sst_ipc_message request;
879 int ret; 896 int ret;
880 897
881 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG); 898 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG);
@@ -883,8 +900,11 @@ int skl_ipc_unload_modules(struct sst_generic_ipc *ipc, u8 module_cnt,
883 header.primary |= IPC_GLB_TYPE(IPC_GLB_UNLOAD_MULTIPLE_MODS); 900 header.primary |= IPC_GLB_TYPE(IPC_GLB_UNLOAD_MULTIPLE_MODS);
884 header.primary |= IPC_LOAD_MODULE_CNT(module_cnt); 901 header.primary |= IPC_LOAD_MODULE_CNT(module_cnt);
885 902
886 ret = sst_ipc_tx_message_wait(ipc, *ipc_header, data, 903 request.header = *(u64 *)(&header);
887 (sizeof(u16) * module_cnt), NULL, 0); 904 request.data = data;
905 request.size = sizeof(u16) * module_cnt;
906
907 ret = sst_ipc_tx_message_wait(ipc, request, NULL);
888 if (ret < 0) 908 if (ret < 0)
889 dev_err(ipc->dev, "ipc: unload modules failed :%d\n", ret); 909 dev_err(ipc->dev, "ipc: unload modules failed :%d\n", ret);
890 910
@@ -896,7 +916,7 @@ int skl_ipc_set_large_config(struct sst_generic_ipc *ipc,
896 struct skl_ipc_large_config_msg *msg, u32 *param) 916 struct skl_ipc_large_config_msg *msg, u32 *param)
897{ 917{
898 struct skl_ipc_header header = {0}; 918 struct skl_ipc_header header = {0};
899 u64 *ipc_header = (u64 *)(&header); 919 struct sst_ipc_message request;
900 int ret = 0; 920 int ret = 0;
901 size_t sz_remaining, tx_size, data_offset; 921 size_t sz_remaining, tx_size, data_offset;
902 922
@@ -923,9 +943,11 @@ int skl_ipc_set_large_config(struct sst_generic_ipc *ipc,
923 header.primary, header.extension); 943 header.primary, header.extension);
924 dev_dbg(ipc->dev, "transmitting offset: %#x, size: %#x\n", 944 dev_dbg(ipc->dev, "transmitting offset: %#x, size: %#x\n",
925 (unsigned)data_offset, (unsigned)tx_size); 945 (unsigned)data_offset, (unsigned)tx_size);
926 ret = sst_ipc_tx_message_wait(ipc, *ipc_header, 946
927 ((char *)param) + data_offset, 947 request.header = *(u64 *)(&header);
928 tx_size, NULL, 0); 948 request.data = ((char *)param) + data_offset;
949 request.size = tx_size;
950 ret = sst_ipc_tx_message_wait(ipc, request, NULL);
929 if (ret < 0) { 951 if (ret < 0) {
930 dev_err(ipc->dev, 952 dev_err(ipc->dev,
931 "ipc: set large config fail, err: %d\n", ret); 953 "ipc: set large config fail, err: %d\n", ret);
@@ -947,12 +969,17 @@ int skl_ipc_set_large_config(struct sst_generic_ipc *ipc,
947EXPORT_SYMBOL_GPL(skl_ipc_set_large_config); 969EXPORT_SYMBOL_GPL(skl_ipc_set_large_config);
948 970
949int skl_ipc_get_large_config(struct sst_generic_ipc *ipc, 971int skl_ipc_get_large_config(struct sst_generic_ipc *ipc,
950 struct skl_ipc_large_config_msg *msg, u32 *param) 972 struct skl_ipc_large_config_msg *msg,
973 u32 **payload, size_t *bytes)
951{ 974{
952 struct skl_ipc_header header = {0}; 975 struct skl_ipc_header header = {0};
953 u64 *ipc_header = (u64 *)(&header); 976 struct sst_ipc_message request, reply = {0};
954 int ret = 0; 977 unsigned int *buf;
955 size_t sz_remaining, rx_size, data_offset; 978 int ret;
979
980 reply.data = kzalloc(SKL_ADSP_W1_SZ, GFP_KERNEL);
981 if (!reply.data)
982 return -ENOMEM;
956 983
957 header.primary = IPC_MSG_TARGET(IPC_MOD_MSG); 984 header.primary = IPC_MSG_TARGET(IPC_MOD_MSG);
958 header.primary |= IPC_MSG_DIR(IPC_MSG_REQUEST); 985 header.primary |= IPC_MSG_DIR(IPC_MSG_REQUEST);
@@ -965,33 +992,21 @@ int skl_ipc_get_large_config(struct sst_generic_ipc *ipc,
965 header.extension |= IPC_FINAL_BLOCK(1); 992 header.extension |= IPC_FINAL_BLOCK(1);
966 header.extension |= IPC_INITIAL_BLOCK(1); 993 header.extension |= IPC_INITIAL_BLOCK(1);
967 994
968 sz_remaining = msg->param_data_size; 995 request.header = *(u64 *)&header;
969 data_offset = 0; 996 request.data = *payload;
997 request.size = *bytes;
998 reply.size = SKL_ADSP_W1_SZ;
970 999
971 while (sz_remaining != 0) { 1000 ret = sst_ipc_tx_message_wait(ipc, request, &reply);
972 rx_size = sz_remaining > SKL_ADSP_W1_SZ 1001 if (ret < 0)
973 ? SKL_ADSP_W1_SZ : sz_remaining; 1002 dev_err(ipc->dev, "ipc: get large config fail, err: %d\n", ret);
974 if (rx_size == sz_remaining)
975 header.extension |= IPC_FINAL_BLOCK(1);
976
977 ret = sst_ipc_tx_message_wait(ipc, *ipc_header, NULL, 0,
978 ((char *)param) + data_offset,
979 msg->param_data_size);
980 if (ret < 0) {
981 dev_err(ipc->dev,
982 "ipc: get large config fail, err: %d\n", ret);
983 return ret;
984 }
985 sz_remaining -= rx_size;
986 data_offset = msg->param_data_size - sz_remaining;
987 1003
988 /* clear the fields */ 1004 reply.size = (reply.header >> 32) & IPC_DATA_OFFSET_SZ_MASK;
989 header.extension &= IPC_INITIAL_BLOCK_CLEAR; 1005 buf = krealloc(reply.data, reply.size, GFP_KERNEL);
990 header.extension &= IPC_DATA_OFFSET_SZ_CLEAR; 1006 if (!buf)
991 /* fill the fields */ 1007 return -ENOMEM;
992 header.extension |= IPC_INITIAL_BLOCK(1); 1008 *payload = buf;
993 header.extension |= IPC_DATA_OFFSET_SZ(data_offset); 1009 *bytes = reply.size;
994 }
995 1010
996 return ret; 1011 return ret;
997} 1012}
@@ -1001,7 +1016,7 @@ int skl_sst_ipc_load_library(struct sst_generic_ipc *ipc,
1001 u8 dma_id, u8 table_id, bool wait) 1016 u8 dma_id, u8 table_id, bool wait)
1002{ 1017{
1003 struct skl_ipc_header header = {0}; 1018 struct skl_ipc_header header = {0};
1004 u64 *ipc_header = (u64 *)(&header); 1019 struct sst_ipc_message request = {0};
1005 int ret = 0; 1020 int ret = 0;
1006 1021
1007 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG); 1022 header.primary = IPC_MSG_TARGET(IPC_FW_GEN_MSG);
@@ -1009,12 +1024,12 @@ int skl_sst_ipc_load_library(struct sst_generic_ipc *ipc,
1009 header.primary |= IPC_GLB_TYPE(IPC_GLB_LOAD_LIBRARY); 1024 header.primary |= IPC_GLB_TYPE(IPC_GLB_LOAD_LIBRARY);
1010 header.primary |= IPC_MOD_INSTANCE_ID(table_id); 1025 header.primary |= IPC_MOD_INSTANCE_ID(table_id);
1011 header.primary |= IPC_MOD_ID(dma_id); 1026 header.primary |= IPC_MOD_ID(dma_id);
1027 request.header = *(u64 *)(&header);
1012 1028
1013 if (wait) 1029 if (wait)
1014 ret = sst_ipc_tx_message_wait(ipc, *ipc_header, 1030 ret = sst_ipc_tx_message_wait(ipc, request, NULL);
1015 NULL, 0, NULL, 0);
1016 else 1031 else
1017 ret = sst_ipc_tx_message_nowait(ipc, *ipc_header, NULL, 0); 1032 ret = sst_ipc_tx_message_nowait(ipc, request);
1018 1033
1019 if (ret < 0) 1034 if (ret < 0)
1020 dev_err(ipc->dev, "ipc: load lib failed\n"); 1035 dev_err(ipc->dev, "ipc: load lib failed\n");
@@ -1026,7 +1041,7 @@ EXPORT_SYMBOL_GPL(skl_sst_ipc_load_library);
1026int skl_ipc_set_d0ix(struct sst_generic_ipc *ipc, struct skl_ipc_d0ix_msg *msg) 1041int skl_ipc_set_d0ix(struct sst_generic_ipc *ipc, struct skl_ipc_d0ix_msg *msg)
1027{ 1042{
1028 struct skl_ipc_header header = {0}; 1043 struct skl_ipc_header header = {0};
1029 u64 *ipc_header = (u64 *)(&header); 1044 struct sst_ipc_message request = {0};
1030 int ret; 1045 int ret;
1031 1046
1032 header.primary = IPC_MSG_TARGET(IPC_MOD_MSG); 1047 header.primary = IPC_MSG_TARGET(IPC_MOD_MSG);
@@ -1037,6 +1052,7 @@ int skl_ipc_set_d0ix(struct sst_generic_ipc *ipc, struct skl_ipc_d0ix_msg *msg)
1037 1052
1038 header.extension = IPC_D0IX_WAKE(msg->wake); 1053 header.extension = IPC_D0IX_WAKE(msg->wake);
1039 header.extension |= IPC_D0IX_STREAMING(msg->streaming); 1054 header.extension |= IPC_D0IX_STREAMING(msg->streaming);
1055 request.header = *(u64 *)(&header);
1040 1056
1041 dev_dbg(ipc->dev, "In %s primary=%x ext=%x\n", __func__, 1057 dev_dbg(ipc->dev, "In %s primary=%x ext=%x\n", __func__,
1042 header.primary, header.extension); 1058 header.primary, header.extension);
@@ -1044,7 +1060,7 @@ int skl_ipc_set_d0ix(struct sst_generic_ipc *ipc, struct skl_ipc_d0ix_msg *msg)
1044 /* 1060 /*
1045 * Use the nopm IPC here as we dont want it checking for D0iX 1061 * Use the nopm IPC here as we dont want it checking for D0iX
1046 */ 1062 */
1047 ret = sst_ipc_tx_message_nopm(ipc, *ipc_header, NULL, 0, NULL, 0); 1063 ret = sst_ipc_tx_message_nopm(ipc, request, NULL);
1048 if (ret < 0) 1064 if (ret < 0)
1049 dev_err(ipc->dev, "ipc: set d0ix failed, err %d\n", ret); 1065 dev_err(ipc->dev, "ipc: set d0ix failed, err %d\n", ret);
1050 1066
diff --git a/sound/soc/intel/skylake/skl-sst-ipc.h b/sound/soc/intel/skylake/skl-sst-ipc.h
index 9c31a48e99dd..08ac31778325 100644
--- a/sound/soc/intel/skylake/skl-sst-ipc.h
+++ b/sound/soc/intel/skylake/skl-sst-ipc.h
@@ -10,9 +10,9 @@
10 10
11#include <linux/irqreturn.h> 11#include <linux/irqreturn.h>
12#include "../common/sst-ipc.h" 12#include "../common/sst-ipc.h"
13#include "skl-sst-dsp.h"
13 14
14struct sst_dsp; 15struct sst_dsp;
15struct skl_sst;
16struct sst_generic_ipc; 16struct sst_generic_ipc;
17 17
18enum skl_ipc_pipeline_state { 18enum skl_ipc_pipeline_state {
@@ -67,54 +67,6 @@ struct skl_lib_info {
67 const struct firmware *fw; 67 const struct firmware *fw;
68}; 68};
69 69
70struct skl_sst {
71 struct device *dev;
72 struct sst_dsp *dsp;
73
74 /* boot */
75 wait_queue_head_t boot_wait;
76 bool boot_complete;
77
78 /* module load */
79 wait_queue_head_t mod_load_wait;
80 bool mod_load_complete;
81 bool mod_load_status;
82
83 /* IPC messaging */
84 struct sst_generic_ipc ipc;
85
86 /* callback for miscbdge */
87 void (*enable_miscbdcge)(struct device *dev, bool enable);
88 /* Is CGCTL.MISCBDCGE disabled */
89 bool miscbdcg_disabled;
90
91 /* Populate module information */
92 struct list_head uuid_list;
93
94 /* Is firmware loaded */
95 bool fw_loaded;
96
97 /* first boot ? */
98 bool is_first_boot;
99
100 /* multi-core */
101 struct skl_dsp_cores cores;
102
103 /* library info */
104 struct skl_lib_info lib_info[SKL_MAX_LIB];
105 int lib_count;
106
107 /* Callback to update D0i3C register */
108 void (*update_d0i3c)(struct device *dev, bool enable);
109
110 struct skl_d0i3_data d0i3;
111
112 const struct skl_dsp_ops *dsp_ops;
113
114 /* Callback to update dynamic clock and power gating registers */
115 void (*clock_power_gating)(struct device *dev, bool enable);
116};
117
118struct skl_ipc_init_instance_msg { 70struct skl_ipc_init_instance_msg {
119 u32 module_id; 71 u32 module_id;
120 u32 instance_id; 72 u32 instance_id;
@@ -187,7 +139,8 @@ int skl_ipc_set_large_config(struct sst_generic_ipc *ipc,
187 struct skl_ipc_large_config_msg *msg, u32 *param); 139 struct skl_ipc_large_config_msg *msg, u32 *param);
188 140
189int skl_ipc_get_large_config(struct sst_generic_ipc *ipc, 141int skl_ipc_get_large_config(struct sst_generic_ipc *ipc,
190 struct skl_ipc_large_config_msg *msg, u32 *param); 142 struct skl_ipc_large_config_msg *msg,
143 u32 **payload, size_t *bytes);
191 144
192int skl_sst_ipc_load_library(struct sst_generic_ipc *ipc, 145int skl_sst_ipc_load_library(struct sst_generic_ipc *ipc,
193 u8 dma_id, u8 table_id, bool wait); 146 u8 dma_id, u8 table_id, bool wait);
@@ -204,7 +157,7 @@ void skl_ipc_int_disable(struct sst_dsp *dsp);
204 157
205bool skl_ipc_int_status(struct sst_dsp *dsp); 158bool skl_ipc_int_status(struct sst_dsp *dsp);
206void skl_ipc_free(struct sst_generic_ipc *ipc); 159void skl_ipc_free(struct sst_generic_ipc *ipc);
207int skl_ipc_init(struct device *dev, struct skl_sst *skl); 160int skl_ipc_init(struct device *dev, struct skl_dev *skl);
208void skl_clear_module_cnt(struct sst_dsp *ctx); 161void skl_clear_module_cnt(struct sst_dsp *ctx);
209 162
210void skl_ipc_process_reply(struct sst_generic_ipc *ipc, 163void skl_ipc_process_reply(struct sst_generic_ipc *ipc,
diff --git a/sound/soc/intel/skylake/skl-sst-utils.c b/sound/soc/intel/skylake/skl-sst-utils.c
index 928c677b506c..d43cbf4a71ef 100644
--- a/sound/soc/intel/skylake/skl-sst-utils.c
+++ b/sound/soc/intel/skylake/skl-sst-utils.c
@@ -8,10 +8,9 @@
8#include <linux/device.h> 8#include <linux/device.h>
9#include <linux/slab.h> 9#include <linux/slab.h>
10#include <linux/uuid.h> 10#include <linux/uuid.h>
11#include "skl-sst-dsp.h"
12#include "../common/sst-dsp.h" 11#include "../common/sst-dsp.h"
13#include "../common/sst-dsp-priv.h" 12#include "../common/sst-dsp-priv.h"
14#include "skl-sst-ipc.h" 13#include "skl.h"
15 14
16#define DEFAULT_HASH_SHA256_LEN 32 15#define DEFAULT_HASH_SHA256_LEN 32
17 16
@@ -99,12 +98,12 @@ static int skl_get_pvtid_map(struct uuid_module *module, int instance_id)
99 return -EINVAL; 98 return -EINVAL;
100} 99}
101 100
102int skl_get_pvt_instance_id_map(struct skl_sst *ctx, 101int skl_get_pvt_instance_id_map(struct skl_dev *skl,
103 int module_id, int instance_id) 102 int module_id, int instance_id)
104{ 103{
105 struct uuid_module *module; 104 struct uuid_module *module;
106 105
107 list_for_each_entry(module, &ctx->uuid_list, list) { 106 list_for_each_entry(module, &skl->uuid_list, list) {
108 if (module->id == module_id) 107 if (module->id == module_id)
109 return skl_get_pvtid_map(module, instance_id); 108 return skl_get_pvtid_map(module, instance_id);
110 } 109 }
@@ -163,19 +162,19 @@ static inline int skl_pvtid_128(struct uuid_module *module)
163/** 162/**
164 * skl_get_pvt_id: generate a private id for use as module id 163 * skl_get_pvt_id: generate a private id for use as module id
165 * 164 *
166 * @ctx: driver context 165 * @skl: driver context
167 * @uuid_mod: module's uuid 166 * @uuid_mod: module's uuid
168 * @instance_id: module's instance id 167 * @instance_id: module's instance id
169 * 168 *
170 * This generates a 128 bit private unique id for a module TYPE so that 169 * This generates a 128 bit private unique id for a module TYPE so that
171 * module instance is unique 170 * module instance is unique
172 */ 171 */
173int skl_get_pvt_id(struct skl_sst *ctx, guid_t *uuid_mod, int instance_id) 172int skl_get_pvt_id(struct skl_dev *skl, guid_t *uuid_mod, int instance_id)
174{ 173{
175 struct uuid_module *module; 174 struct uuid_module *module;
176 int pvt_id; 175 int pvt_id;
177 176
178 list_for_each_entry(module, &ctx->uuid_list, list) { 177 list_for_each_entry(module, &skl->uuid_list, list) {
179 if (guid_equal(uuid_mod, &module->uuid)) { 178 if (guid_equal(uuid_mod, &module->uuid)) {
180 179
181 pvt_id = skl_pvtid_128(module); 180 pvt_id = skl_pvtid_128(module);
@@ -194,18 +193,18 @@ EXPORT_SYMBOL_GPL(skl_get_pvt_id);
194/** 193/**
195 * skl_put_pvt_id: free up the private id allocated 194 * skl_put_pvt_id: free up the private id allocated
196 * 195 *
197 * @ctx: driver context 196 * @skl: driver context
198 * @uuid_mod: module's uuid 197 * @uuid_mod: module's uuid
199 * @pvt_id: module pvt id 198 * @pvt_id: module pvt id
200 * 199 *
201 * This frees a 128 bit private unique id previously generated 200 * This frees a 128 bit private unique id previously generated
202 */ 201 */
203int skl_put_pvt_id(struct skl_sst *ctx, guid_t *uuid_mod, int *pvt_id) 202int skl_put_pvt_id(struct skl_dev *skl, guid_t *uuid_mod, int *pvt_id)
204{ 203{
205 int i; 204 int i;
206 struct uuid_module *module; 205 struct uuid_module *module;
207 206
208 list_for_each_entry(module, &ctx->uuid_list, list) { 207 list_for_each_entry(module, &skl->uuid_list, list) {
209 if (guid_equal(uuid_mod, &module->uuid)) { 208 if (guid_equal(uuid_mod, &module->uuid)) {
210 209
211 if (*pvt_id != 0) 210 if (*pvt_id != 0)
@@ -234,7 +233,7 @@ int snd_skl_parse_uuids(struct sst_dsp *ctx, const struct firmware *fw,
234 struct adsp_module_entry *mod_entry; 233 struct adsp_module_entry *mod_entry;
235 int i, num_entry, size; 234 int i, num_entry, size;
236 const char *buf; 235 const char *buf;
237 struct skl_sst *skl = ctx->thread_context; 236 struct skl_dev *skl = ctx->thread_context;
238 struct uuid_module *module; 237 struct uuid_module *module;
239 struct firmware stripped_fw; 238 struct firmware stripped_fw;
240 unsigned int safe_file; 239 unsigned int safe_file;
@@ -317,11 +316,11 @@ free_uuid_list:
317 return ret; 316 return ret;
318} 317}
319 318
320void skl_freeup_uuid_list(struct skl_sst *ctx) 319void skl_freeup_uuid_list(struct skl_dev *skl)
321{ 320{
322 struct uuid_module *uuid, *_uuid; 321 struct uuid_module *uuid, *_uuid;
323 322
324 list_for_each_entry_safe(uuid, _uuid, &ctx->uuid_list, list) { 323 list_for_each_entry_safe(uuid, _uuid, &skl->uuid_list, list) {
325 list_del(&uuid->list); 324 list_del(&uuid->list);
326 kfree(uuid); 325 kfree(uuid);
327 } 326 }
@@ -355,16 +354,12 @@ int skl_dsp_strip_extended_manifest(struct firmware *fw)
355} 354}
356 355
357int skl_sst_ctx_init(struct device *dev, int irq, const char *fw_name, 356int skl_sst_ctx_init(struct device *dev, int irq, const char *fw_name,
358 struct skl_dsp_loader_ops dsp_ops, struct skl_sst **dsp, 357 struct skl_dsp_loader_ops dsp_ops, struct skl_dev **dsp,
359 struct sst_dsp_device *skl_dev) 358 struct sst_dsp_device *skl_dev)
360{ 359{
361 struct skl_sst *skl; 360 struct skl_dev *skl = *dsp;
362 struct sst_dsp *sst; 361 struct sst_dsp *sst;
363 362
364 skl = devm_kzalloc(dev, sizeof(*skl), GFP_KERNEL);
365 if (skl == NULL)
366 return -ENOMEM;
367
368 skl->dev = dev; 363 skl->dev = dev;
369 skl_dev->thread_context = skl; 364 skl_dev->thread_context = skl;
370 INIT_LIST_HEAD(&skl->uuid_list); 365 INIT_LIST_HEAD(&skl->uuid_list);
@@ -381,13 +376,11 @@ int skl_sst_ctx_init(struct device *dev, int irq, const char *fw_name,
381 INIT_LIST_HEAD(&sst->module_list); 376 INIT_LIST_HEAD(&sst->module_list);
382 377
383 skl->is_first_boot = true; 378 skl->is_first_boot = true;
384 if (dsp)
385 *dsp = skl;
386 379
387 return 0; 380 return 0;
388} 381}
389 382
390int skl_prepare_lib_load(struct skl_sst *skl, struct skl_lib_info *linfo, 383int skl_prepare_lib_load(struct skl_dev *skl, struct skl_lib_info *linfo,
391 struct firmware *stripped_fw, 384 struct firmware *stripped_fw,
392 unsigned int hdr_offset, int index) 385 unsigned int hdr_offset, int index)
393{ 386{
diff --git a/sound/soc/intel/skylake/skl-sst.c b/sound/soc/intel/skylake/skl-sst.c
index 70c3a604c381..61a8e4756a2b 100644
--- a/sound/soc/intel/skylake/skl-sst.c
+++ b/sound/soc/intel/skylake/skl-sst.c
@@ -16,7 +16,7 @@
16#include "../common/sst-dsp.h" 16#include "../common/sst-dsp.h"
17#include "../common/sst-dsp-priv.h" 17#include "../common/sst-dsp-priv.h"
18#include "../common/sst-ipc.h" 18#include "../common/sst-ipc.h"
19#include "skl-sst-ipc.h" 19#include "skl.h"
20 20
21#define SKL_BASEFW_TIMEOUT 300 21#define SKL_BASEFW_TIMEOUT 300
22#define SKL_INIT_TIMEOUT 1000 22#define SKL_INIT_TIMEOUT 1000
@@ -66,7 +66,7 @@ static int skl_transfer_firmware(struct sst_dsp *ctx,
66static int skl_load_base_firmware(struct sst_dsp *ctx) 66static int skl_load_base_firmware(struct sst_dsp *ctx)
67{ 67{
68 int ret = 0, i; 68 int ret = 0, i;
69 struct skl_sst *skl = ctx->thread_context; 69 struct skl_dev *skl = ctx->thread_context;
70 struct firmware stripped_fw; 70 struct firmware stripped_fw;
71 u32 reg; 71 u32 reg;
72 72
@@ -161,7 +161,7 @@ static int skl_set_dsp_D0(struct sst_dsp *ctx, unsigned int core_id)
161{ 161{
162 int ret; 162 int ret;
163 struct skl_ipc_dxstate_info dx; 163 struct skl_ipc_dxstate_info dx;
164 struct skl_sst *skl = ctx->thread_context; 164 struct skl_dev *skl = ctx->thread_context;
165 unsigned int core_mask = SKL_DSP_CORE_MASK(core_id); 165 unsigned int core_mask = SKL_DSP_CORE_MASK(core_id);
166 166
167 /* If core0 is being turned on, we need to load the FW */ 167 /* If core0 is being turned on, we need to load the FW */
@@ -215,7 +215,7 @@ static int skl_set_dsp_D3(struct sst_dsp *ctx, unsigned int core_id)
215{ 215{
216 int ret; 216 int ret;
217 struct skl_ipc_dxstate_info dx; 217 struct skl_ipc_dxstate_info dx;
218 struct skl_sst *skl = ctx->thread_context; 218 struct skl_dev *skl = ctx->thread_context;
219 unsigned int core_mask = SKL_DSP_CORE_MASK(core_id); 219 unsigned int core_mask = SKL_DSP_CORE_MASK(core_id);
220 220
221 dx.core_mask = core_mask; 221 dx.core_mask = core_mask;
@@ -332,7 +332,7 @@ static int skl_transfer_module(struct sst_dsp *ctx, const void *data,
332 u32 size, u16 mod_id, u8 table_id, bool is_module) 332 u32 size, u16 mod_id, u8 table_id, bool is_module)
333{ 333{
334 int ret, bytes_left, curr_pos; 334 int ret, bytes_left, curr_pos;
335 struct skl_sst *skl = ctx->thread_context; 335 struct skl_dev *skl = ctx->thread_context;
336 skl->mod_load_complete = false; 336 skl->mod_load_complete = false;
337 337
338 bytes_left = ctx->cl_dev.ops.cl_copy_to_dmabuf(ctx, data, size, false); 338 bytes_left = ctx->cl_dev.ops.cl_copy_to_dmabuf(ctx, data, size, false);
@@ -384,7 +384,7 @@ out:
384static int 384static int
385skl_load_library(struct sst_dsp *ctx, struct skl_lib_info *linfo, int lib_count) 385skl_load_library(struct sst_dsp *ctx, struct skl_lib_info *linfo, int lib_count)
386{ 386{
387 struct skl_sst *skl = ctx->thread_context; 387 struct skl_dev *skl = ctx->thread_context;
388 struct firmware stripped_fw; 388 struct firmware stripped_fw;
389 int ret, i; 389 int ret, i;
390 390
@@ -413,8 +413,7 @@ static int skl_load_module(struct sst_dsp *ctx, u16 mod_id, u8 *guid)
413 int ret = 0; 413 int ret = 0;
414 char mod_name[64]; /* guid str = 32 chars + 4 hyphens */ 414 char mod_name[64]; /* guid str = 32 chars + 4 hyphens */
415 415
416 snprintf(mod_name, sizeof(mod_name), "%s%pUL%s", 416 snprintf(mod_name, sizeof(mod_name), "intel/dsp_fw_%pUL.bin", guid);
417 "intel/dsp_fw_", guid, ".bin");
418 417
419 module_entry = skl_module_get_from_id(ctx, mod_id); 418 module_entry = skl_module_get_from_id(ctx, mod_id);
420 if (module_entry == NULL) { 419 if (module_entry == NULL) {
@@ -443,7 +442,7 @@ static int skl_load_module(struct sst_dsp *ctx, u16 mod_id, u8 *guid)
443static int skl_unload_module(struct sst_dsp *ctx, u16 mod_id) 442static int skl_unload_module(struct sst_dsp *ctx, u16 mod_id)
444{ 443{
445 int usage_cnt; 444 int usage_cnt;
446 struct skl_sst *skl = ctx->thread_context; 445 struct skl_dev *skl = ctx->thread_context;
447 int ret = 0; 446 int ret = 0;
448 447
449 usage_cnt = skl_put_module(ctx, mod_id); 448 usage_cnt = skl_put_module(ctx, mod_id);
@@ -518,9 +517,10 @@ static struct sst_dsp_device skl_dev = {
518}; 517};
519 518
520int skl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq, 519int skl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
521 const char *fw_name, struct skl_dsp_loader_ops dsp_ops, struct skl_sst **dsp) 520 const char *fw_name, struct skl_dsp_loader_ops dsp_ops,
521 struct skl_dev **dsp)
522{ 522{
523 struct skl_sst *skl; 523 struct skl_dev *skl;
524 struct sst_dsp *sst; 524 struct sst_dsp *sst;
525 int ret; 525 int ret;
526 526
@@ -554,10 +554,10 @@ int skl_sst_dsp_init(struct device *dev, void __iomem *mmio_base, int irq,
554} 554}
555EXPORT_SYMBOL_GPL(skl_sst_dsp_init); 555EXPORT_SYMBOL_GPL(skl_sst_dsp_init);
556 556
557int skl_sst_init_fw(struct device *dev, struct skl_sst *ctx) 557int skl_sst_init_fw(struct device *dev, struct skl_dev *skl)
558{ 558{
559 int ret; 559 int ret;
560 struct sst_dsp *sst = ctx->dsp; 560 struct sst_dsp *sst = skl->dsp;
561 561
562 ret = sst->fw_ops.load_fw(sst); 562 ret = sst->fw_ops.load_fw(sst);
563 if (ret < 0) { 563 if (ret < 0) {
@@ -567,32 +567,32 @@ int skl_sst_init_fw(struct device *dev, struct skl_sst *ctx)
567 567
568 skl_dsp_init_core_state(sst); 568 skl_dsp_init_core_state(sst);
569 569
570 if (ctx->lib_count > 1) { 570 if (skl->lib_count > 1) {
571 ret = sst->fw_ops.load_library(sst, ctx->lib_info, 571 ret = sst->fw_ops.load_library(sst, skl->lib_info,
572 ctx->lib_count); 572 skl->lib_count);
573 if (ret < 0) { 573 if (ret < 0) {
574 dev_err(dev, "Load Library failed : %x\n", ret); 574 dev_err(dev, "Load Library failed : %x\n", ret);
575 return ret; 575 return ret;
576 } 576 }
577 } 577 }
578 ctx->is_first_boot = false; 578 skl->is_first_boot = false;
579 579
580 return 0; 580 return 0;
581} 581}
582EXPORT_SYMBOL_GPL(skl_sst_init_fw); 582EXPORT_SYMBOL_GPL(skl_sst_init_fw);
583 583
584void skl_sst_dsp_cleanup(struct device *dev, struct skl_sst *ctx) 584void skl_sst_dsp_cleanup(struct device *dev, struct skl_dev *skl)
585{ 585{
586 586
587 if (ctx->dsp->fw) 587 if (skl->dsp->fw)
588 release_firmware(ctx->dsp->fw); 588 release_firmware(skl->dsp->fw);
589 skl_clear_module_table(ctx->dsp); 589 skl_clear_module_table(skl->dsp);
590 skl_freeup_uuid_list(ctx); 590 skl_freeup_uuid_list(skl);
591 skl_ipc_free(&ctx->ipc); 591 skl_ipc_free(&skl->ipc);
592 ctx->dsp->ops->free(ctx->dsp); 592 skl->dsp->ops->free(skl->dsp);
593 if (ctx->boot_complete) { 593 if (skl->boot_complete) {
594 ctx->dsp->cl_dev.ops.cl_cleanup_controller(ctx->dsp); 594 skl->dsp->cl_dev.ops.cl_cleanup_controller(skl->dsp);
595 skl_cldma_int_disable(ctx->dsp); 595 skl_cldma_int_disable(skl->dsp);
596 } 596 }
597} 597}
598EXPORT_SYMBOL_GPL(skl_sst_dsp_cleanup); 598EXPORT_SYMBOL_GPL(skl_sst_dsp_cleanup);
diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c
index 6241e35213af..69cd7a81bf2a 100644
--- a/sound/soc/intel/skylake/skl-topology.c
+++ b/sound/soc/intel/skylake/skl-topology.c
@@ -12,6 +12,7 @@
12#include <linux/types.h> 12#include <linux/types.h>
13#include <linux/firmware.h> 13#include <linux/firmware.h>
14#include <linux/uuid.h> 14#include <linux/uuid.h>
15#include <sound/intel-nhlt.h>
15#include <sound/soc.h> 16#include <sound/soc.h>
16#include <sound/soc-topology.h> 17#include <sound/soc-topology.h>
17#include <uapi/sound/snd_sst_tokens.h> 18#include <uapi/sound/snd_sst_tokens.h>
@@ -45,9 +46,9 @@ static const int mic_quatro_list[][SKL_CH_QUATRO] = {
45#define CHECK_HW_PARAMS(ch, freq, bps, prm_ch, prm_freq, prm_bps) \ 46#define CHECK_HW_PARAMS(ch, freq, bps, prm_ch, prm_freq, prm_bps) \
46 ((ch == prm_ch) && (bps == prm_bps) && (freq == prm_freq)) 47 ((ch == prm_ch) && (bps == prm_bps) && (freq == prm_freq))
47 48
48void skl_tplg_d0i3_get(struct skl *skl, enum d0i3_capability caps) 49void skl_tplg_d0i3_get(struct skl_dev *skl, enum d0i3_capability caps)
49{ 50{
50 struct skl_d0i3_data *d0i3 = &skl->skl_sst->d0i3; 51 struct skl_d0i3_data *d0i3 = &skl->d0i3;
51 52
52 switch (caps) { 53 switch (caps) {
53 case SKL_D0I3_NONE: 54 case SKL_D0I3_NONE:
@@ -64,9 +65,9 @@ void skl_tplg_d0i3_get(struct skl *skl, enum d0i3_capability caps)
64 } 65 }
65} 66}
66 67
67void skl_tplg_d0i3_put(struct skl *skl, enum d0i3_capability caps) 68void skl_tplg_d0i3_put(struct skl_dev *skl, enum d0i3_capability caps)
68{ 69{
69 struct skl_d0i3_data *d0i3 = &skl->skl_sst->d0i3; 70 struct skl_d0i3_data *d0i3 = &skl->d0i3;
70 71
71 switch (caps) { 72 switch (caps) {
72 case SKL_D0I3_NONE: 73 case SKL_D0I3_NONE:
@@ -109,118 +110,23 @@ static int is_skl_dsp_widget_type(struct snd_soc_dapm_widget *w,
109 } 110 }
110} 111}
111 112
112/* 113static void skl_dump_mconfig(struct skl_dev *skl, struct skl_module_cfg *mcfg)
113 * Each pipelines needs memory to be allocated. Check if we have free memory
114 * from available pool.
115 */
116static bool skl_is_pipe_mem_avail(struct skl *skl,
117 struct skl_module_cfg *mconfig)
118{
119 struct skl_sst *ctx = skl->skl_sst;
120
121 if (skl->resource.mem + mconfig->pipe->memory_pages >
122 skl->resource.max_mem) {
123 dev_err(ctx->dev,
124 "%s: module_id %d instance %d\n", __func__,
125 mconfig->id.module_id,
126 mconfig->id.instance_id);
127 dev_err(ctx->dev,
128 "exceeds ppl memory available %d mem %d\n",
129 skl->resource.max_mem, skl->resource.mem);
130 return false;
131 } else {
132 return true;
133 }
134}
135
136/*
137 * Add the mem to the mem pool. This is freed when pipe is deleted.
138 * Note: DSP does actual memory management we only keep track for complete
139 * pool
140 */
141static void skl_tplg_alloc_pipe_mem(struct skl *skl,
142 struct skl_module_cfg *mconfig)
143{
144 skl->resource.mem += mconfig->pipe->memory_pages;
145}
146
147/*
148 * Pipeline needs needs DSP CPU resources for computation, this is
149 * quantified in MCPS (Million Clocks Per Second) required for module/pipe
150 *
151 * Each pipelines needs mcps to be allocated. Check if we have mcps for this
152 * pipe.
153 */
154
155static bool skl_is_pipe_mcps_avail(struct skl *skl,
156 struct skl_module_cfg *mconfig)
157{
158 struct skl_sst *ctx = skl->skl_sst;
159 u8 res_idx = mconfig->res_idx;
160 struct skl_module_res *res = &mconfig->module->resources[res_idx];
161
162 if (skl->resource.mcps + res->cps > skl->resource.max_mcps) {
163 dev_err(ctx->dev,
164 "%s: module_id %d instance %d\n", __func__,
165 mconfig->id.module_id, mconfig->id.instance_id);
166 dev_err(ctx->dev,
167 "exceeds ppl mcps available %d > mem %d\n",
168 skl->resource.max_mcps, skl->resource.mcps);
169 return false;
170 } else {
171 return true;
172 }
173}
174
175static void skl_tplg_alloc_pipe_mcps(struct skl *skl,
176 struct skl_module_cfg *mconfig)
177{
178 u8 res_idx = mconfig->res_idx;
179 struct skl_module_res *res = &mconfig->module->resources[res_idx];
180
181 skl->resource.mcps += res->cps;
182}
183
184/*
185 * Free the mcps when tearing down
186 */
187static void
188skl_tplg_free_pipe_mcps(struct skl *skl, struct skl_module_cfg *mconfig)
189{
190 u8 res_idx = mconfig->res_idx;
191 struct skl_module_res *res = &mconfig->module->resources[res_idx];
192
193 skl->resource.mcps -= res->cps;
194}
195
196/*
197 * Free the memory when tearing down
198 */
199static void
200skl_tplg_free_pipe_mem(struct skl *skl, struct skl_module_cfg *mconfig)
201{
202 skl->resource.mem -= mconfig->pipe->memory_pages;
203}
204
205
206static void skl_dump_mconfig(struct skl_sst *ctx,
207 struct skl_module_cfg *mcfg)
208{ 114{
209 struct skl_module_iface *iface = &mcfg->module->formats[0]; 115 struct skl_module_iface *iface = &mcfg->module->formats[0];
210 116
211 dev_dbg(ctx->dev, "Dumping config\n"); 117 dev_dbg(skl->dev, "Dumping config\n");
212 dev_dbg(ctx->dev, "Input Format:\n"); 118 dev_dbg(skl->dev, "Input Format:\n");
213 dev_dbg(ctx->dev, "channels = %d\n", iface->inputs[0].fmt.channels); 119 dev_dbg(skl->dev, "channels = %d\n", iface->inputs[0].fmt.channels);
214 dev_dbg(ctx->dev, "s_freq = %d\n", iface->inputs[0].fmt.s_freq); 120 dev_dbg(skl->dev, "s_freq = %d\n", iface->inputs[0].fmt.s_freq);
215 dev_dbg(ctx->dev, "ch_cfg = %d\n", iface->inputs[0].fmt.ch_cfg); 121 dev_dbg(skl->dev, "ch_cfg = %d\n", iface->inputs[0].fmt.ch_cfg);
216 dev_dbg(ctx->dev, "valid bit depth = %d\n", 122 dev_dbg(skl->dev, "valid bit depth = %d\n",
217 iface->inputs[0].fmt.valid_bit_depth); 123 iface->inputs[0].fmt.valid_bit_depth);
218 dev_dbg(ctx->dev, "Output Format:\n"); 124 dev_dbg(skl->dev, "Output Format:\n");
219 dev_dbg(ctx->dev, "channels = %d\n", iface->outputs[0].fmt.channels); 125 dev_dbg(skl->dev, "channels = %d\n", iface->outputs[0].fmt.channels);
220 dev_dbg(ctx->dev, "s_freq = %d\n", iface->outputs[0].fmt.s_freq); 126 dev_dbg(skl->dev, "s_freq = %d\n", iface->outputs[0].fmt.s_freq);
221 dev_dbg(ctx->dev, "valid bit depth = %d\n", 127 dev_dbg(skl->dev, "valid bit depth = %d\n",
222 iface->outputs[0].fmt.valid_bit_depth); 128 iface->outputs[0].fmt.valid_bit_depth);
223 dev_dbg(ctx->dev, "ch_cfg = %d\n", iface->outputs[0].fmt.ch_cfg); 129 dev_dbg(skl->dev, "ch_cfg = %d\n", iface->outputs[0].fmt.ch_cfg);
224} 130}
225 131
226static void skl_tplg_update_chmap(struct skl_module_fmt *fmt, int chs) 132static void skl_tplg_update_chmap(struct skl_module_fmt *fmt, int chs)
@@ -322,7 +228,7 @@ static void skl_tplg_update_params_fixup(struct skl_module_cfg *m_cfg,
322 * params, so once we have calculate params, we need buffer calculation as 228 * params, so once we have calculate params, we need buffer calculation as
323 * well. 229 * well.
324 */ 230 */
325static void skl_tplg_update_buffer_size(struct skl_sst *ctx, 231static void skl_tplg_update_buffer_size(struct skl_dev *skl,
326 struct skl_module_cfg *mcfg) 232 struct skl_module_cfg *mcfg)
327{ 233{
328 int multiplier = 1; 234 int multiplier = 1;
@@ -374,13 +280,12 @@ static u8 skl_tplg_be_dev_type(int dev_type)
374} 280}
375 281
376static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w, 282static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w,
377 struct skl_sst *ctx) 283 struct skl_dev *skl)
378{ 284{
379 struct skl_module_cfg *m_cfg = w->priv; 285 struct skl_module_cfg *m_cfg = w->priv;
380 int link_type, dir; 286 int link_type, dir;
381 u32 ch, s_freq, s_fmt; 287 u32 ch, s_freq, s_fmt;
382 struct nhlt_specific_cfg *cfg; 288 struct nhlt_specific_cfg *cfg;
383 struct skl *skl = get_skl_ctx(ctx->dev);
384 u8 dev_type = skl_tplg_be_dev_type(m_cfg->dev_type); 289 u8 dev_type = skl_tplg_be_dev_type(m_cfg->dev_type);
385 int fmt_idx = m_cfg->fmt_idx; 290 int fmt_idx = m_cfg->fmt_idx;
386 struct skl_module_iface *m_iface = &m_cfg->module->formats[fmt_idx]; 291 struct skl_module_iface *m_iface = &m_cfg->module->formats[fmt_idx];
@@ -389,7 +294,7 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w,
389 if (m_cfg->formats_config.caps_size > 0) 294 if (m_cfg->formats_config.caps_size > 0)
390 return 0; 295 return 0;
391 296
392 dev_dbg(ctx->dev, "Applying default cfg blob\n"); 297 dev_dbg(skl->dev, "Applying default cfg blob\n");
393 switch (m_cfg->dev_type) { 298 switch (m_cfg->dev_type) {
394 case SKL_DEVICE_DMIC: 299 case SKL_DEVICE_DMIC:
395 link_type = NHLT_LINK_DMIC; 300 link_type = NHLT_LINK_DMIC;
@@ -425,9 +330,9 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w,
425 m_cfg->formats_config.caps_size = cfg->size; 330 m_cfg->formats_config.caps_size = cfg->size;
426 m_cfg->formats_config.caps = (u32 *) &cfg->caps; 331 m_cfg->formats_config.caps = (u32 *) &cfg->caps;
427 } else { 332 } else {
428 dev_err(ctx->dev, "Blob NULL for id %x type %d dirn %d\n", 333 dev_err(skl->dev, "Blob NULL for id %x type %d dirn %d\n",
429 m_cfg->vbus_id, link_type, dir); 334 m_cfg->vbus_id, link_type, dir);
430 dev_err(ctx->dev, "PCM: ch %d, freq %d, fmt %d\n", 335 dev_err(skl->dev, "PCM: ch %d, freq %d, fmt %d\n",
431 ch, s_freq, s_fmt); 336 ch, s_freq, s_fmt);
432 return -EIO; 337 return -EIO;
433 } 338 }
@@ -436,7 +341,7 @@ static int skl_tplg_update_be_blob(struct snd_soc_dapm_widget *w,
436} 341}
437 342
438static void skl_tplg_update_module_params(struct snd_soc_dapm_widget *w, 343static void skl_tplg_update_module_params(struct snd_soc_dapm_widget *w,
439 struct skl_sst *ctx) 344 struct skl_dev *skl)
440{ 345{
441 struct skl_module_cfg *m_cfg = w->priv; 346 struct skl_module_cfg *m_cfg = w->priv;
442 struct skl_pipe_params *params = m_cfg->pipe->p_params; 347 struct skl_pipe_params *params = m_cfg->pipe->p_params;
@@ -446,10 +351,10 @@ static void skl_tplg_update_module_params(struct snd_soc_dapm_widget *w,
446 if (!m_cfg->params_fixup) 351 if (!m_cfg->params_fixup)
447 return; 352 return;
448 353
449 dev_dbg(ctx->dev, "Mconfig for widget=%s BEFORE updation\n", 354 dev_dbg(skl->dev, "Mconfig for widget=%s BEFORE updation\n",
450 w->name); 355 w->name);
451 356
452 skl_dump_mconfig(ctx, m_cfg); 357 skl_dump_mconfig(skl, m_cfg);
453 358
454 if (p_conn_type == SKL_PIPE_CONN_TYPE_FE) 359 if (p_conn_type == SKL_PIPE_CONN_TYPE_FE)
455 is_fe = true; 360 is_fe = true;
@@ -457,12 +362,12 @@ static void skl_tplg_update_module_params(struct snd_soc_dapm_widget *w,
457 is_fe = false; 362 is_fe = false;
458 363
459 skl_tplg_update_params_fixup(m_cfg, params, is_fe); 364 skl_tplg_update_params_fixup(m_cfg, params, is_fe);
460 skl_tplg_update_buffer_size(ctx, m_cfg); 365 skl_tplg_update_buffer_size(skl, m_cfg);
461 366
462 dev_dbg(ctx->dev, "Mconfig for widget=%s AFTER updation\n", 367 dev_dbg(skl->dev, "Mconfig for widget=%s AFTER updation\n",
463 w->name); 368 w->name);
464 369
465 skl_dump_mconfig(ctx, m_cfg); 370 skl_dump_mconfig(skl, m_cfg);
466} 371}
467 372
468/* 373/*
@@ -471,7 +376,7 @@ static void skl_tplg_update_module_params(struct snd_soc_dapm_widget *w,
471 * set module params will be done after module is initialised. 376 * set module params will be done after module is initialised.
472 */ 377 */
473static int skl_tplg_set_module_params(struct snd_soc_dapm_widget *w, 378static int skl_tplg_set_module_params(struct snd_soc_dapm_widget *w,
474 struct skl_sst *ctx) 379 struct skl_dev *skl)
475{ 380{
476 int i, ret; 381 int i, ret;
477 struct skl_module_cfg *mconfig = w->priv; 382 struct skl_module_cfg *mconfig = w->priv;
@@ -483,7 +388,7 @@ static int skl_tplg_set_module_params(struct snd_soc_dapm_widget *w,
483 if (mconfig->formats_config.caps_size > 0 && 388 if (mconfig->formats_config.caps_size > 0 &&
484 mconfig->formats_config.set_params == SKL_PARAM_SET) { 389 mconfig->formats_config.set_params == SKL_PARAM_SET) {
485 sp_cfg = &mconfig->formats_config; 390 sp_cfg = &mconfig->formats_config;
486 ret = skl_set_module_params(ctx, sp_cfg->caps, 391 ret = skl_set_module_params(skl, sp_cfg->caps,
487 sp_cfg->caps_size, 392 sp_cfg->caps_size,
488 sp_cfg->param_id, mconfig); 393 sp_cfg->param_id, mconfig);
489 if (ret < 0) 394 if (ret < 0)
@@ -497,7 +402,7 @@ static int skl_tplg_set_module_params(struct snd_soc_dapm_widget *w,
497 bc = (struct skl_algo_data *)sb->dobj.private; 402 bc = (struct skl_algo_data *)sb->dobj.private;
498 403
499 if (bc->set_params == SKL_PARAM_SET) { 404 if (bc->set_params == SKL_PARAM_SET) {
500 ret = skl_set_module_params(ctx, 405 ret = skl_set_module_params(skl,
501 (u32 *)bc->params, bc->size, 406 (u32 *)bc->params, bc->size,
502 bc->param_id, mconfig); 407 bc->param_id, mconfig);
503 if (ret < 0) 408 if (ret < 0)
@@ -542,15 +447,15 @@ static int skl_tplg_set_module_init_data(struct snd_soc_dapm_widget *w)
542 return 0; 447 return 0;
543} 448}
544 449
545static int skl_tplg_module_prepare(struct skl_sst *ctx, struct skl_pipe *pipe, 450static int skl_tplg_module_prepare(struct skl_dev *skl, struct skl_pipe *pipe,
546 struct snd_soc_dapm_widget *w, struct skl_module_cfg *mcfg) 451 struct snd_soc_dapm_widget *w, struct skl_module_cfg *mcfg)
547{ 452{
548 switch (mcfg->dev_type) { 453 switch (mcfg->dev_type) {
549 case SKL_DEVICE_HDAHOST: 454 case SKL_DEVICE_HDAHOST:
550 return skl_pcm_host_dma_prepare(ctx->dev, pipe->p_params); 455 return skl_pcm_host_dma_prepare(skl->dev, pipe->p_params);
551 456
552 case SKL_DEVICE_HDALINK: 457 case SKL_DEVICE_HDALINK:
553 return skl_pcm_link_dma_prepare(ctx->dev, pipe->p_params); 458 return skl_pcm_link_dma_prepare(skl->dev, pipe->p_params);
554 } 459 }
555 460
556 return 0; 461 return 0;
@@ -562,12 +467,11 @@ static int skl_tplg_module_prepare(struct skl_sst *ctx, struct skl_pipe *pipe,
562 * skl_init_module() routine, so invoke that for all modules in a pipeline 467 * skl_init_module() routine, so invoke that for all modules in a pipeline
563 */ 468 */
564static int 469static int
565skl_tplg_init_pipe_modules(struct skl *skl, struct skl_pipe *pipe) 470skl_tplg_init_pipe_modules(struct skl_dev *skl, struct skl_pipe *pipe)
566{ 471{
567 struct skl_pipe_module *w_module; 472 struct skl_pipe_module *w_module;
568 struct snd_soc_dapm_widget *w; 473 struct snd_soc_dapm_widget *w;
569 struct skl_module_cfg *mconfig; 474 struct skl_module_cfg *mconfig;
570 struct skl_sst *ctx = skl->skl_sst;
571 u8 cfg_idx; 475 u8 cfg_idx;
572 int ret = 0; 476 int ret = 0;
573 477
@@ -578,7 +482,7 @@ skl_tplg_init_pipe_modules(struct skl *skl, struct skl_pipe *pipe)
578 482
579 /* check if module ids are populated */ 483 /* check if module ids are populated */
580 if (mconfig->id.module_id < 0) { 484 if (mconfig->id.module_id < 0) {
581 dev_err(skl->skl_sst->dev, 485 dev_err(skl->dev,
582 "module %pUL id not populated\n", 486 "module %pUL id not populated\n",
583 (guid_t *)mconfig->guid); 487 (guid_t *)mconfig->guid);
584 return -EIO; 488 return -EIO;
@@ -588,12 +492,8 @@ skl_tplg_init_pipe_modules(struct skl *skl, struct skl_pipe *pipe)
588 mconfig->fmt_idx = mconfig->mod_cfg[cfg_idx].fmt_idx; 492 mconfig->fmt_idx = mconfig->mod_cfg[cfg_idx].fmt_idx;
589 mconfig->res_idx = mconfig->mod_cfg[cfg_idx].res_idx; 493 mconfig->res_idx = mconfig->mod_cfg[cfg_idx].res_idx;
590 494
591 /* check resource available */ 495 if (mconfig->module->loadable && skl->dsp->fw_ops.load_mod) {
592 if (!skl_is_pipe_mcps_avail(skl, mconfig)) 496 ret = skl->dsp->fw_ops.load_mod(skl->dsp,
593 return -ENOMEM;
594
595 if (mconfig->module->loadable && ctx->dsp->fw_ops.load_mod) {
596 ret = ctx->dsp->fw_ops.load_mod(ctx->dsp,
597 mconfig->id.module_id, mconfig->guid); 497 mconfig->id.module_id, mconfig->guid);
598 if (ret < 0) 498 if (ret < 0)
599 return ret; 499 return ret;
@@ -602,50 +502,50 @@ skl_tplg_init_pipe_modules(struct skl *skl, struct skl_pipe *pipe)
602 } 502 }
603 503
604 /* prepare the DMA if the module is gateway cpr */ 504 /* prepare the DMA if the module is gateway cpr */
605 ret = skl_tplg_module_prepare(ctx, pipe, w, mconfig); 505 ret = skl_tplg_module_prepare(skl, pipe, w, mconfig);
606 if (ret < 0) 506 if (ret < 0)
607 return ret; 507 return ret;
608 508
609 /* update blob if blob is null for be with default value */ 509 /* update blob if blob is null for be with default value */
610 skl_tplg_update_be_blob(w, ctx); 510 skl_tplg_update_be_blob(w, skl);
611 511
612 /* 512 /*
613 * apply fix/conversion to module params based on 513 * apply fix/conversion to module params based on
614 * FE/BE params 514 * FE/BE params
615 */ 515 */
616 skl_tplg_update_module_params(w, ctx); 516 skl_tplg_update_module_params(w, skl);
617 uuid_mod = (guid_t *)mconfig->guid; 517 uuid_mod = (guid_t *)mconfig->guid;
618 mconfig->id.pvt_id = skl_get_pvt_id(ctx, uuid_mod, 518 mconfig->id.pvt_id = skl_get_pvt_id(skl, uuid_mod,
619 mconfig->id.instance_id); 519 mconfig->id.instance_id);
620 if (mconfig->id.pvt_id < 0) 520 if (mconfig->id.pvt_id < 0)
621 return ret; 521 return ret;
622 skl_tplg_set_module_init_data(w); 522 skl_tplg_set_module_init_data(w);
623 523
624 ret = skl_dsp_get_core(ctx->dsp, mconfig->core_id); 524 ret = skl_dsp_get_core(skl->dsp, mconfig->core_id);
625 if (ret < 0) { 525 if (ret < 0) {
626 dev_err(ctx->dev, "Failed to wake up core %d ret=%d\n", 526 dev_err(skl->dev, "Failed to wake up core %d ret=%d\n",
627 mconfig->core_id, ret); 527 mconfig->core_id, ret);
628 return ret; 528 return ret;
629 } 529 }
630 530
631 ret = skl_init_module(ctx, mconfig); 531 ret = skl_init_module(skl, mconfig);
632 if (ret < 0) { 532 if (ret < 0) {
633 skl_put_pvt_id(ctx, uuid_mod, &mconfig->id.pvt_id); 533 skl_put_pvt_id(skl, uuid_mod, &mconfig->id.pvt_id);
634 goto err; 534 goto err;
635 } 535 }
636 skl_tplg_alloc_pipe_mcps(skl, mconfig); 536
637 ret = skl_tplg_set_module_params(w, ctx); 537 ret = skl_tplg_set_module_params(w, skl);
638 if (ret < 0) 538 if (ret < 0)
639 goto err; 539 goto err;
640 } 540 }
641 541
642 return 0; 542 return 0;
643err: 543err:
644 skl_dsp_put_core(ctx->dsp, mconfig->core_id); 544 skl_dsp_put_core(skl->dsp, mconfig->core_id);
645 return ret; 545 return ret;
646} 546}
647 547
648static int skl_tplg_unload_pipe_modules(struct skl_sst *ctx, 548static int skl_tplg_unload_pipe_modules(struct skl_dev *skl,
649 struct skl_pipe *pipe) 549 struct skl_pipe *pipe)
650{ 550{
651 int ret = 0; 551 int ret = 0;
@@ -657,19 +557,19 @@ static int skl_tplg_unload_pipe_modules(struct skl_sst *ctx,
657 mconfig = w_module->w->priv; 557 mconfig = w_module->w->priv;
658 uuid_mod = (guid_t *)mconfig->guid; 558 uuid_mod = (guid_t *)mconfig->guid;
659 559
660 if (mconfig->module->loadable && ctx->dsp->fw_ops.unload_mod && 560 if (mconfig->module->loadable && skl->dsp->fw_ops.unload_mod &&
661 mconfig->m_state > SKL_MODULE_UNINIT) { 561 mconfig->m_state > SKL_MODULE_UNINIT) {
662 ret = ctx->dsp->fw_ops.unload_mod(ctx->dsp, 562 ret = skl->dsp->fw_ops.unload_mod(skl->dsp,
663 mconfig->id.module_id); 563 mconfig->id.module_id);
664 if (ret < 0) 564 if (ret < 0)
665 return -EIO; 565 return -EIO;
666 } 566 }
667 skl_put_pvt_id(ctx, uuid_mod, &mconfig->id.pvt_id); 567 skl_put_pvt_id(skl, uuid_mod, &mconfig->id.pvt_id);
668 568
669 ret = skl_dsp_put_core(ctx->dsp, mconfig->core_id); 569 ret = skl_dsp_put_core(skl->dsp, mconfig->core_id);
670 if (ret < 0) { 570 if (ret < 0) {
671 /* don't return; continue with other modules */ 571 /* don't return; continue with other modules */
672 dev_err(ctx->dev, "Failed to sleep core %d ret=%d\n", 572 dev_err(skl->dev, "Failed to sleep core %d ret=%d\n",
673 mconfig->core_id, ret); 573 mconfig->core_id, ret);
674 } 574 }
675 } 575 }
@@ -686,9 +586,8 @@ static int skl_tplg_unload_pipe_modules(struct skl_sst *ctx,
686 * 0th configuratation by default for such pipes. 586 * 0th configuratation by default for such pipes.
687 */ 587 */
688static int 588static int
689skl_tplg_get_pipe_config(struct skl *skl, struct skl_module_cfg *mconfig) 589skl_tplg_get_pipe_config(struct skl_dev *skl, struct skl_module_cfg *mconfig)
690{ 590{
691 struct skl_sst *ctx = skl->skl_sst;
692 struct skl_pipe *pipe = mconfig->pipe; 591 struct skl_pipe *pipe = mconfig->pipe;
693 struct skl_pipe_params *params = pipe->p_params; 592 struct skl_pipe_params *params = pipe->p_params;
694 struct skl_path_config *pconfig = &pipe->configs[0]; 593 struct skl_path_config *pconfig = &pipe->configs[0];
@@ -702,7 +601,7 @@ skl_tplg_get_pipe_config(struct skl *skl, struct skl_module_cfg *mconfig)
702 } 601 }
703 602
704 if (pipe->conn_type == SKL_PIPE_CONN_TYPE_NONE) { 603 if (pipe->conn_type == SKL_PIPE_CONN_TYPE_NONE) {
705 dev_dbg(ctx->dev, "No conn_type detected, take 0th config\n"); 604 dev_dbg(skl->dev, "No conn_type detected, take 0th config\n");
706 pipe->cur_config_idx = 0; 605 pipe->cur_config_idx = 0;
707 pipe->memory_pages = pconfig->mem_pages; 606 pipe->memory_pages = pconfig->mem_pages;
708 607
@@ -726,13 +625,13 @@ skl_tplg_get_pipe_config(struct skl *skl, struct skl_module_cfg *mconfig)
726 fmt->channels, fmt->freq, fmt->bps)) { 625 fmt->channels, fmt->freq, fmt->bps)) {
727 pipe->cur_config_idx = i; 626 pipe->cur_config_idx = i;
728 pipe->memory_pages = pconfig->mem_pages; 627 pipe->memory_pages = pconfig->mem_pages;
729 dev_dbg(ctx->dev, "Using pipe config: %d\n", i); 628 dev_dbg(skl->dev, "Using pipe config: %d\n", i);
730 629
731 return 0; 630 return 0;
732 } 631 }
733 } 632 }
734 633
735 dev_err(ctx->dev, "Invalid pipe config: %d %d %d for pipe: %d\n", 634 dev_err(skl->dev, "Invalid pipe config: %d %d %d for pipe: %d\n",
736 params->ch, params->s_freq, params->s_fmt, pipe->ppl_id); 635 params->ch, params->s_freq, params->s_fmt, pipe->ppl_id);
737 return -EINVAL; 636 return -EINVAL;
738} 637}
@@ -740,44 +639,32 @@ skl_tplg_get_pipe_config(struct skl *skl, struct skl_module_cfg *mconfig)
740/* 639/*
741 * Mixer module represents a pipeline. So in the Pre-PMU event of mixer we 640 * Mixer module represents a pipeline. So in the Pre-PMU event of mixer we
742 * need create the pipeline. So we do following: 641 * need create the pipeline. So we do following:
743 * - check the resources
744 * - Create the pipeline 642 * - Create the pipeline
745 * - Initialize the modules in pipeline 643 * - Initialize the modules in pipeline
746 * - finally bind all modules together 644 * - finally bind all modules together
747 */ 645 */
748static int skl_tplg_mixer_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w, 646static int skl_tplg_mixer_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w,
749 struct skl *skl) 647 struct skl_dev *skl)
750{ 648{
751 int ret; 649 int ret;
752 struct skl_module_cfg *mconfig = w->priv; 650 struct skl_module_cfg *mconfig = w->priv;
753 struct skl_pipe_module *w_module; 651 struct skl_pipe_module *w_module;
754 struct skl_pipe *s_pipe = mconfig->pipe; 652 struct skl_pipe *s_pipe = mconfig->pipe;
755 struct skl_module_cfg *src_module = NULL, *dst_module, *module; 653 struct skl_module_cfg *src_module = NULL, *dst_module, *module;
756 struct skl_sst *ctx = skl->skl_sst;
757 struct skl_module_deferred_bind *modules; 654 struct skl_module_deferred_bind *modules;
758 655
759 ret = skl_tplg_get_pipe_config(skl, mconfig); 656 ret = skl_tplg_get_pipe_config(skl, mconfig);
760 if (ret < 0) 657 if (ret < 0)
761 return ret; 658 return ret;
762 659
763 /* check resource available */
764 if (!skl_is_pipe_mcps_avail(skl, mconfig))
765 return -EBUSY;
766
767 if (!skl_is_pipe_mem_avail(skl, mconfig))
768 return -ENOMEM;
769
770 /* 660 /*
771 * Create a list of modules for pipe. 661 * Create a list of modules for pipe.
772 * This list contains modules from source to sink 662 * This list contains modules from source to sink
773 */ 663 */
774 ret = skl_create_pipeline(ctx, mconfig->pipe); 664 ret = skl_create_pipeline(skl, mconfig->pipe);
775 if (ret < 0) 665 if (ret < 0)
776 return ret; 666 return ret;
777 667
778 skl_tplg_alloc_pipe_mem(skl, mconfig);
779 skl_tplg_alloc_pipe_mcps(skl, mconfig);
780
781 /* Init all pipe modules from source to sink */ 668 /* Init all pipe modules from source to sink */
782 ret = skl_tplg_init_pipe_modules(skl, s_pipe); 669 ret = skl_tplg_init_pipe_modules(skl, s_pipe);
783 if (ret < 0) 670 if (ret < 0)
@@ -792,7 +679,7 @@ static int skl_tplg_mixer_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w,
792 continue; 679 continue;
793 } 680 }
794 681
795 ret = skl_bind_modules(ctx, src_module, dst_module); 682 ret = skl_bind_modules(skl, src_module, dst_module);
796 if (ret < 0) 683 if (ret < 0)
797 return ret; 684 return ret;
798 685
@@ -810,7 +697,7 @@ static int skl_tplg_mixer_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w,
810 list_for_each_entry(modules, &skl->bind_list, node) { 697 list_for_each_entry(modules, &skl->bind_list, node) {
811 module = w_module->w->priv; 698 module = w_module->w->priv;
812 if (modules->dst == module) 699 if (modules->dst == module)
813 skl_bind_modules(ctx, modules->src, 700 skl_bind_modules(skl, modules->src,
814 modules->dst); 701 modules->dst);
815 } 702 }
816 } 703 }
@@ -818,7 +705,7 @@ static int skl_tplg_mixer_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w,
818 return 0; 705 return 0;
819} 706}
820 707
821static int skl_fill_sink_instance_id(struct skl_sst *ctx, u32 *params, 708static int skl_fill_sink_instance_id(struct skl_dev *skl, u32 *params,
822 int size, struct skl_module_cfg *mcfg) 709 int size, struct skl_module_cfg *mcfg)
823{ 710{
824 int i, pvt_id; 711 int i, pvt_id;
@@ -829,7 +716,7 @@ static int skl_fill_sink_instance_id(struct skl_sst *ctx, u32 *params,
829 struct skl_mod_inst_map *inst = kpb_params->u.map; 716 struct skl_mod_inst_map *inst = kpb_params->u.map;
830 717
831 for (i = 0; i < kpb_params->num_modules; i++) { 718 for (i = 0; i < kpb_params->num_modules; i++) {
832 pvt_id = skl_get_pvt_instance_id_map(ctx, inst->mod_id, 719 pvt_id = skl_get_pvt_instance_id_map(skl, inst->mod_id,
833 inst->inst_id); 720 inst->inst_id);
834 if (pvt_id < 0) 721 if (pvt_id < 0)
835 return -EINVAL; 722 return -EINVAL;
@@ -849,7 +736,7 @@ static int skl_fill_sink_instance_id(struct skl_sst *ctx, u32 *params,
849 * send params after binding 736 * send params after binding
850 */ 737 */
851static int skl_tplg_set_module_bind_params(struct snd_soc_dapm_widget *w, 738static int skl_tplg_set_module_bind_params(struct snd_soc_dapm_widget *w,
852 struct skl_module_cfg *mcfg, struct skl_sst *ctx) 739 struct skl_module_cfg *mcfg, struct skl_dev *skl)
853{ 740{
854 int i, ret; 741 int i, ret;
855 struct skl_module_cfg *mconfig = w->priv; 742 struct skl_module_cfg *mconfig = w->priv;
@@ -876,7 +763,7 @@ static int skl_tplg_set_module_bind_params(struct snd_soc_dapm_widget *w,
876 if (mconfig->formats_config.caps_size > 0 && 763 if (mconfig->formats_config.caps_size > 0 &&
877 mconfig->formats_config.set_params == SKL_PARAM_BIND) { 764 mconfig->formats_config.set_params == SKL_PARAM_BIND) {
878 sp_cfg = &mconfig->formats_config; 765 sp_cfg = &mconfig->formats_config;
879 ret = skl_set_module_params(ctx, sp_cfg->caps, 766 ret = skl_set_module_params(skl, sp_cfg->caps,
880 sp_cfg->caps_size, 767 sp_cfg->caps_size,
881 sp_cfg->param_id, mconfig); 768 sp_cfg->param_id, mconfig);
882 if (ret < 0) 769 if (ret < 0)
@@ -894,10 +781,10 @@ static int skl_tplg_set_module_bind_params(struct snd_soc_dapm_widget *w,
894 if (!params) 781 if (!params)
895 return -ENOMEM; 782 return -ENOMEM;
896 783
897 skl_fill_sink_instance_id(ctx, params, bc->max, 784 skl_fill_sink_instance_id(skl, params, bc->max,
898 mconfig); 785 mconfig);
899 786
900 ret = skl_set_module_params(ctx, params, 787 ret = skl_set_module_params(skl, params,
901 bc->max, bc->param_id, mconfig); 788 bc->max, bc->param_id, mconfig);
902 kfree(params); 789 kfree(params);
903 790
@@ -910,11 +797,11 @@ static int skl_tplg_set_module_bind_params(struct snd_soc_dapm_widget *w,
910 return 0; 797 return 0;
911} 798}
912 799
913static int skl_get_module_id(struct skl_sst *ctx, guid_t *uuid) 800static int skl_get_module_id(struct skl_dev *skl, guid_t *uuid)
914{ 801{
915 struct uuid_module *module; 802 struct uuid_module *module;
916 803
917 list_for_each_entry(module, &ctx->uuid_list, list) { 804 list_for_each_entry(module, &skl->uuid_list, list) {
918 if (guid_equal(uuid, &module->uuid)) 805 if (guid_equal(uuid, &module->uuid))
919 return module->id; 806 return module->id;
920 } 807 }
@@ -922,7 +809,7 @@ static int skl_get_module_id(struct skl_sst *ctx, guid_t *uuid)
922 return -EINVAL; 809 return -EINVAL;
923} 810}
924 811
925static int skl_tplg_find_moduleid_from_uuid(struct skl *skl, 812static int skl_tplg_find_moduleid_from_uuid(struct skl_dev *skl,
926 const struct snd_kcontrol_new *k) 813 const struct snd_kcontrol_new *k)
927{ 814{
928 struct soc_bytes_ext *sb = (void *) k->private_value; 815 struct soc_bytes_ext *sb = (void *) k->private_value;
@@ -942,7 +829,7 @@ static int skl_tplg_find_moduleid_from_uuid(struct skl *skl,
942 params->num_modules = uuid_params->num_modules; 829 params->num_modules = uuid_params->num_modules;
943 830
944 for (i = 0; i < uuid_params->num_modules; i++) { 831 for (i = 0; i < uuid_params->num_modules; i++) {
945 module_id = skl_get_module_id(skl->skl_sst, 832 module_id = skl_get_module_id(skl,
946 &uuid_params->u.map_uuid[i].mod_uuid); 833 &uuid_params->u.map_uuid[i].mod_uuid);
947 if (module_id < 0) { 834 if (module_id < 0) {
948 devm_kfree(bus->dev, params); 835 devm_kfree(bus->dev, params);
@@ -966,7 +853,7 @@ static int skl_tplg_find_moduleid_from_uuid(struct skl *skl,
966 * Retrieve the module id from UUID mentioned in the 853 * Retrieve the module id from UUID mentioned in the
967 * post bind params 854 * post bind params
968 */ 855 */
969void skl_tplg_add_moduleid_in_bind_params(struct skl *skl, 856void skl_tplg_add_moduleid_in_bind_params(struct skl_dev *skl,
970 struct snd_soc_dapm_widget *w) 857 struct snd_soc_dapm_widget *w)
971{ 858{
972 struct skl_module_cfg *mconfig = w->priv; 859 struct skl_module_cfg *mconfig = w->priv;
@@ -985,12 +872,12 @@ void skl_tplg_add_moduleid_in_bind_params(struct skl *skl,
985 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) && 872 SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) &&
986 (skl_tplg_find_moduleid_from_uuid(skl, 873 (skl_tplg_find_moduleid_from_uuid(skl,
987 &w->kcontrol_news[i]) < 0)) 874 &w->kcontrol_news[i]) < 0))
988 dev_err(skl->skl_sst->dev, 875 dev_err(skl->dev,
989 "%s: invalid kpb post bind params\n", 876 "%s: invalid kpb post bind params\n",
990 __func__); 877 __func__);
991} 878}
992 879
993static int skl_tplg_module_add_deferred_bind(struct skl *skl, 880static int skl_tplg_module_add_deferred_bind(struct skl_dev *skl,
994 struct skl_module_cfg *src, struct skl_module_cfg *dst) 881 struct skl_module_cfg *src, struct skl_module_cfg *dst)
995{ 882{
996 struct skl_module_deferred_bind *m_list, *modules; 883 struct skl_module_deferred_bind *m_list, *modules;
@@ -1028,26 +915,27 @@ static int skl_tplg_module_add_deferred_bind(struct skl *skl,
1028} 915}
1029 916
1030static int skl_tplg_bind_sinks(struct snd_soc_dapm_widget *w, 917static int skl_tplg_bind_sinks(struct snd_soc_dapm_widget *w,
1031 struct skl *skl, 918 struct skl_dev *skl,
1032 struct snd_soc_dapm_widget *src_w, 919 struct snd_soc_dapm_widget *src_w,
1033 struct skl_module_cfg *src_mconfig) 920 struct skl_module_cfg *src_mconfig)
1034{ 921{
1035 struct snd_soc_dapm_path *p; 922 struct snd_soc_dapm_path *p;
1036 struct snd_soc_dapm_widget *sink = NULL, *next_sink = NULL; 923 struct snd_soc_dapm_widget *sink = NULL, *next_sink = NULL;
1037 struct skl_module_cfg *sink_mconfig; 924 struct skl_module_cfg *sink_mconfig;
1038 struct skl_sst *ctx = skl->skl_sst;
1039 int ret; 925 int ret;
1040 926
1041 snd_soc_dapm_widget_for_each_sink_path(w, p) { 927 snd_soc_dapm_widget_for_each_sink_path(w, p) {
1042 if (!p->connect) 928 if (!p->connect)
1043 continue; 929 continue;
1044 930
1045 dev_dbg(ctx->dev, "%s: src widget=%s\n", __func__, w->name); 931 dev_dbg(skl->dev,
1046 dev_dbg(ctx->dev, "%s: sink widget=%s\n", __func__, p->sink->name); 932 "%s: src widget=%s\n", __func__, w->name);
933 dev_dbg(skl->dev,
934 "%s: sink widget=%s\n", __func__, p->sink->name);
1047 935
1048 next_sink = p->sink; 936 next_sink = p->sink;
1049 937
1050 if (!is_skl_dsp_widget_type(p->sink, ctx->dev)) 938 if (!is_skl_dsp_widget_type(p->sink, skl->dev))
1051 return skl_tplg_bind_sinks(p->sink, skl, src_w, src_mconfig); 939 return skl_tplg_bind_sinks(p->sink, skl, src_w, src_mconfig);
1052 940
1053 /* 941 /*
@@ -1056,7 +944,7 @@ static int skl_tplg_bind_sinks(struct snd_soc_dapm_widget *w,
1056 * they are ones used for SKL so check that first 944 * they are ones used for SKL so check that first
1057 */ 945 */
1058 if ((p->sink->priv != NULL) && 946 if ((p->sink->priv != NULL) &&
1059 is_skl_dsp_widget_type(p->sink, ctx->dev)) { 947 is_skl_dsp_widget_type(p->sink, skl->dev)) {
1060 948
1061 sink = p->sink; 949 sink = p->sink;
1062 sink_mconfig = sink->priv; 950 sink_mconfig = sink->priv;
@@ -1088,19 +976,21 @@ static int skl_tplg_bind_sinks(struct snd_soc_dapm_widget *w,
1088 continue; 976 continue;
1089 977
1090 /* Bind source to sink, mixin is always source */ 978 /* Bind source to sink, mixin is always source */
1091 ret = skl_bind_modules(ctx, src_mconfig, sink_mconfig); 979 ret = skl_bind_modules(skl, src_mconfig, sink_mconfig);
1092 if (ret) 980 if (ret)
1093 return ret; 981 return ret;
1094 982
1095 /* set module params after bind */ 983 /* set module params after bind */
1096 skl_tplg_set_module_bind_params(src_w, src_mconfig, ctx); 984 skl_tplg_set_module_bind_params(src_w,
1097 skl_tplg_set_module_bind_params(sink, sink_mconfig, ctx); 985 src_mconfig, skl);
986 skl_tplg_set_module_bind_params(sink,
987 sink_mconfig, skl);
1098 988
1099 /* Start sinks pipe first */ 989 /* Start sinks pipe first */
1100 if (sink_mconfig->pipe->state != SKL_PIPE_STARTED) { 990 if (sink_mconfig->pipe->state != SKL_PIPE_STARTED) {
1101 if (sink_mconfig->pipe->conn_type != 991 if (sink_mconfig->pipe->conn_type !=
1102 SKL_PIPE_CONN_TYPE_FE) 992 SKL_PIPE_CONN_TYPE_FE)
1103 ret = skl_run_pipe(ctx, 993 ret = skl_run_pipe(skl,
1104 sink_mconfig->pipe); 994 sink_mconfig->pipe);
1105 if (ret) 995 if (ret)
1106 return ret; 996 return ret;
@@ -1125,10 +1015,9 @@ static int skl_tplg_bind_sinks(struct snd_soc_dapm_widget *w,
1125 * - Then run current pipe 1015 * - Then run current pipe
1126 */ 1016 */
1127static int skl_tplg_pga_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w, 1017static int skl_tplg_pga_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w,
1128 struct skl *skl) 1018 struct skl_dev *skl)
1129{ 1019{
1130 struct skl_module_cfg *src_mconfig; 1020 struct skl_module_cfg *src_mconfig;
1131 struct skl_sst *ctx = skl->skl_sst;
1132 int ret = 0; 1021 int ret = 0;
1133 1022
1134 src_mconfig = w->priv; 1023 src_mconfig = w->priv;
@@ -1144,25 +1033,24 @@ static int skl_tplg_pga_dapm_pre_pmu_event(struct snd_soc_dapm_widget *w,
1144 1033
1145 /* Start source pipe last after starting all sinks */ 1034 /* Start source pipe last after starting all sinks */
1146 if (src_mconfig->pipe->conn_type != SKL_PIPE_CONN_TYPE_FE) 1035 if (src_mconfig->pipe->conn_type != SKL_PIPE_CONN_TYPE_FE)
1147 return skl_run_pipe(ctx, src_mconfig->pipe); 1036 return skl_run_pipe(skl, src_mconfig->pipe);
1148 1037
1149 return 0; 1038 return 0;
1150} 1039}
1151 1040
1152static struct snd_soc_dapm_widget *skl_get_src_dsp_widget( 1041static struct snd_soc_dapm_widget *skl_get_src_dsp_widget(
1153 struct snd_soc_dapm_widget *w, struct skl *skl) 1042 struct snd_soc_dapm_widget *w, struct skl_dev *skl)
1154{ 1043{
1155 struct snd_soc_dapm_path *p; 1044 struct snd_soc_dapm_path *p;
1156 struct snd_soc_dapm_widget *src_w = NULL; 1045 struct snd_soc_dapm_widget *src_w = NULL;
1157 struct skl_sst *ctx = skl->skl_sst;
1158 1046
1159 snd_soc_dapm_widget_for_each_source_path(w, p) { 1047 snd_soc_dapm_widget_for_each_source_path(w, p) {
1160 src_w = p->source; 1048 src_w = p->source;
1161 if (!p->connect) 1049 if (!p->connect)
1162 continue; 1050 continue;
1163 1051
1164 dev_dbg(ctx->dev, "sink widget=%s\n", w->name); 1052 dev_dbg(skl->dev, "sink widget=%s\n", w->name);
1165 dev_dbg(ctx->dev, "src widget=%s\n", p->source->name); 1053 dev_dbg(skl->dev, "src widget=%s\n", p->source->name);
1166 1054
1167 /* 1055 /*
1168 * here we will check widgets in sink pipelines, so that can 1056 * here we will check widgets in sink pipelines, so that can
@@ -1170,7 +1058,7 @@ static struct snd_soc_dapm_widget *skl_get_src_dsp_widget(
1170 * ones used for SKL so check that first 1058 * ones used for SKL so check that first
1171 */ 1059 */
1172 if ((p->source->priv != NULL) && 1060 if ((p->source->priv != NULL) &&
1173 is_skl_dsp_widget_type(p->source, ctx->dev)) { 1061 is_skl_dsp_widget_type(p->source, skl->dev)) {
1174 return p->source; 1062 return p->source;
1175 } 1063 }
1176 } 1064 }
@@ -1191,12 +1079,11 @@ static struct snd_soc_dapm_widget *skl_get_src_dsp_widget(
1191 * - start this pipeline 1079 * - start this pipeline
1192 */ 1080 */
1193static int skl_tplg_mixer_dapm_post_pmu_event(struct snd_soc_dapm_widget *w, 1081static int skl_tplg_mixer_dapm_post_pmu_event(struct snd_soc_dapm_widget *w,
1194 struct skl *skl) 1082 struct skl_dev *skl)
1195{ 1083{
1196 int ret = 0; 1084 int ret = 0;
1197 struct snd_soc_dapm_widget *source, *sink; 1085 struct snd_soc_dapm_widget *source, *sink;
1198 struct skl_module_cfg *src_mconfig, *sink_mconfig; 1086 struct skl_module_cfg *src_mconfig, *sink_mconfig;
1199 struct skl_sst *ctx = skl->skl_sst;
1200 int src_pipe_started = 0; 1087 int src_pipe_started = 0;
1201 1088
1202 sink = w; 1089 sink = w;
@@ -1222,16 +1109,16 @@ static int skl_tplg_mixer_dapm_post_pmu_event(struct snd_soc_dapm_widget *w,
1222 } 1109 }
1223 1110
1224 if (src_pipe_started) { 1111 if (src_pipe_started) {
1225 ret = skl_bind_modules(ctx, src_mconfig, sink_mconfig); 1112 ret = skl_bind_modules(skl, src_mconfig, sink_mconfig);
1226 if (ret) 1113 if (ret)
1227 return ret; 1114 return ret;
1228 1115
1229 /* set module params after bind */ 1116 /* set module params after bind */
1230 skl_tplg_set_module_bind_params(source, src_mconfig, ctx); 1117 skl_tplg_set_module_bind_params(source, src_mconfig, skl);
1231 skl_tplg_set_module_bind_params(sink, sink_mconfig, ctx); 1118 skl_tplg_set_module_bind_params(sink, sink_mconfig, skl);
1232 1119
1233 if (sink_mconfig->pipe->conn_type != SKL_PIPE_CONN_TYPE_FE) 1120 if (sink_mconfig->pipe->conn_type != SKL_PIPE_CONN_TYPE_FE)
1234 ret = skl_run_pipe(ctx, sink_mconfig->pipe); 1121 ret = skl_run_pipe(skl, sink_mconfig->pipe);
1235 } 1122 }
1236 1123
1237 return ret; 1124 return ret;
@@ -1244,16 +1131,15 @@ static int skl_tplg_mixer_dapm_post_pmu_event(struct snd_soc_dapm_widget *w,
1244 * - unbind with source pipelines if still connected 1131 * - unbind with source pipelines if still connected
1245 */ 1132 */
1246static int skl_tplg_mixer_dapm_pre_pmd_event(struct snd_soc_dapm_widget *w, 1133static int skl_tplg_mixer_dapm_pre_pmd_event(struct snd_soc_dapm_widget *w,
1247 struct skl *skl) 1134 struct skl_dev *skl)
1248{ 1135{
1249 struct skl_module_cfg *src_mconfig, *sink_mconfig; 1136 struct skl_module_cfg *src_mconfig, *sink_mconfig;
1250 int ret = 0, i; 1137 int ret = 0, i;
1251 struct skl_sst *ctx = skl->skl_sst;
1252 1138
1253 sink_mconfig = w->priv; 1139 sink_mconfig = w->priv;
1254 1140
1255 /* Stop the pipe */ 1141 /* Stop the pipe */
1256 ret = skl_stop_pipe(ctx, sink_mconfig->pipe); 1142 ret = skl_stop_pipe(skl, sink_mconfig->pipe);
1257 if (ret) 1143 if (ret)
1258 return ret; 1144 return ret;
1259 1145
@@ -1263,7 +1149,7 @@ static int skl_tplg_mixer_dapm_pre_pmd_event(struct snd_soc_dapm_widget *w,
1263 if (!src_mconfig) 1149 if (!src_mconfig)
1264 continue; 1150 continue;
1265 1151
1266 ret = skl_unbind_modules(ctx, 1152 ret = skl_unbind_modules(skl,
1267 src_mconfig, sink_mconfig); 1153 src_mconfig, sink_mconfig);
1268 } 1154 }
1269 } 1155 }
@@ -1273,28 +1159,22 @@ static int skl_tplg_mixer_dapm_pre_pmd_event(struct snd_soc_dapm_widget *w,
1273 1159
1274/* 1160/*
1275 * in the Post-PMD event of mixer we need to do following: 1161 * in the Post-PMD event of mixer we need to do following:
1276 * - Free the mcps used
1277 * - Free the mem used
1278 * - Unbind the modules within the pipeline 1162 * - Unbind the modules within the pipeline
1279 * - Delete the pipeline (modules are not required to be explicitly 1163 * - Delete the pipeline (modules are not required to be explicitly
1280 * deleted, pipeline delete is enough here 1164 * deleted, pipeline delete is enough here
1281 */ 1165 */
1282static int skl_tplg_mixer_dapm_post_pmd_event(struct snd_soc_dapm_widget *w, 1166static int skl_tplg_mixer_dapm_post_pmd_event(struct snd_soc_dapm_widget *w,
1283 struct skl *skl) 1167 struct skl_dev *skl)
1284{ 1168{
1285 struct skl_module_cfg *mconfig = w->priv; 1169 struct skl_module_cfg *mconfig = w->priv;
1286 struct skl_pipe_module *w_module; 1170 struct skl_pipe_module *w_module;
1287 struct skl_module_cfg *src_module = NULL, *dst_module; 1171 struct skl_module_cfg *src_module = NULL, *dst_module;
1288 struct skl_sst *ctx = skl->skl_sst;
1289 struct skl_pipe *s_pipe = mconfig->pipe; 1172 struct skl_pipe *s_pipe = mconfig->pipe;
1290 struct skl_module_deferred_bind *modules, *tmp; 1173 struct skl_module_deferred_bind *modules, *tmp;
1291 1174
1292 if (s_pipe->state == SKL_PIPE_INVALID) 1175 if (s_pipe->state == SKL_PIPE_INVALID)
1293 return -EINVAL; 1176 return -EINVAL;
1294 1177
1295 skl_tplg_free_pipe_mcps(skl, mconfig);
1296 skl_tplg_free_pipe_mem(skl, mconfig);
1297
1298 list_for_each_entry(w_module, &s_pipe->w_list, node) { 1178 list_for_each_entry(w_module, &s_pipe->w_list, node) {
1299 if (list_empty(&skl->bind_list)) 1179 if (list_empty(&skl->bind_list))
1300 break; 1180 break;
@@ -1307,7 +1187,7 @@ static int skl_tplg_mixer_dapm_post_pmd_event(struct snd_soc_dapm_widget *w,
1307 * modules from deferred bind list. 1187 * modules from deferred bind list.
1308 */ 1188 */
1309 if (modules->dst == src_module) { 1189 if (modules->dst == src_module) {
1310 skl_unbind_modules(ctx, modules->src, 1190 skl_unbind_modules(skl, modules->src,
1311 modules->dst); 1191 modules->dst);
1312 } 1192 }
1313 1193
@@ -1327,44 +1207,40 @@ static int skl_tplg_mixer_dapm_post_pmd_event(struct snd_soc_dapm_widget *w,
1327 list_for_each_entry(w_module, &s_pipe->w_list, node) { 1207 list_for_each_entry(w_module, &s_pipe->w_list, node) {
1328 dst_module = w_module->w->priv; 1208 dst_module = w_module->w->priv;
1329 1209
1330 if (mconfig->m_state >= SKL_MODULE_INIT_DONE)
1331 skl_tplg_free_pipe_mcps(skl, dst_module);
1332 if (src_module == NULL) { 1210 if (src_module == NULL) {
1333 src_module = dst_module; 1211 src_module = dst_module;
1334 continue; 1212 continue;
1335 } 1213 }
1336 1214
1337 skl_unbind_modules(ctx, src_module, dst_module); 1215 skl_unbind_modules(skl, src_module, dst_module);
1338 src_module = dst_module; 1216 src_module = dst_module;
1339 } 1217 }
1340 1218
1341 skl_delete_pipe(ctx, mconfig->pipe); 1219 skl_delete_pipe(skl, mconfig->pipe);
1342 1220
1343 list_for_each_entry(w_module, &s_pipe->w_list, node) { 1221 list_for_each_entry(w_module, &s_pipe->w_list, node) {
1344 src_module = w_module->w->priv; 1222 src_module = w_module->w->priv;
1345 src_module->m_state = SKL_MODULE_UNINIT; 1223 src_module->m_state = SKL_MODULE_UNINIT;
1346 } 1224 }
1347 1225
1348 return skl_tplg_unload_pipe_modules(ctx, s_pipe); 1226 return skl_tplg_unload_pipe_modules(skl, s_pipe);
1349} 1227}
1350 1228
1351/* 1229/*
1352 * in the Post-PMD event of PGA we need to do following: 1230 * in the Post-PMD event of PGA we need to do following:
1353 * - Free the mcps used
1354 * - Stop the pipeline 1231 * - Stop the pipeline
1355 * - In source pipe is connected, unbind with source pipelines 1232 * - In source pipe is connected, unbind with source pipelines
1356 */ 1233 */
1357static int skl_tplg_pga_dapm_post_pmd_event(struct snd_soc_dapm_widget *w, 1234static int skl_tplg_pga_dapm_post_pmd_event(struct snd_soc_dapm_widget *w,
1358 struct skl *skl) 1235 struct skl_dev *skl)
1359{ 1236{
1360 struct skl_module_cfg *src_mconfig, *sink_mconfig; 1237 struct skl_module_cfg *src_mconfig, *sink_mconfig;
1361 int ret = 0, i; 1238 int ret = 0, i;
1362 struct skl_sst *ctx = skl->skl_sst;
1363 1239
1364 src_mconfig = w->priv; 1240 src_mconfig = w->priv;
1365 1241
1366 /* Stop the pipe since this is a mixin module */ 1242 /* Stop the pipe since this is a mixin module */
1367 ret = skl_stop_pipe(ctx, src_mconfig->pipe); 1243 ret = skl_stop_pipe(skl, src_mconfig->pipe);
1368 if (ret) 1244 if (ret)
1369 return ret; 1245 return ret;
1370 1246
@@ -1377,7 +1253,7 @@ static int skl_tplg_pga_dapm_post_pmd_event(struct snd_soc_dapm_widget *w,
1377 * This is a connecter and if path is found that means 1253 * This is a connecter and if path is found that means
1378 * unbind between source and sink has not happened yet 1254 * unbind between source and sink has not happened yet
1379 */ 1255 */
1380 ret = skl_unbind_modules(ctx, src_mconfig, 1256 ret = skl_unbind_modules(skl, src_mconfig,
1381 sink_mconfig); 1257 sink_mconfig);
1382 } 1258 }
1383 } 1259 }
@@ -1395,7 +1271,7 @@ static int skl_tplg_mixer_event(struct snd_soc_dapm_widget *w,
1395 struct snd_kcontrol *k, int event) 1271 struct snd_kcontrol *k, int event)
1396{ 1272{
1397 struct snd_soc_dapm_context *dapm = w->dapm; 1273 struct snd_soc_dapm_context *dapm = w->dapm;
1398 struct skl *skl = get_skl_ctx(dapm->dev); 1274 struct skl_dev *skl = get_skl_ctx(dapm->dev);
1399 1275
1400 switch (event) { 1276 switch (event) {
1401 case SND_SOC_DAPM_PRE_PMU: 1277 case SND_SOC_DAPM_PRE_PMU:
@@ -1425,7 +1301,7 @@ static int skl_tplg_pga_event(struct snd_soc_dapm_widget *w,
1425 1301
1426{ 1302{
1427 struct snd_soc_dapm_context *dapm = w->dapm; 1303 struct snd_soc_dapm_context *dapm = w->dapm;
1428 struct skl *skl = get_skl_ctx(dapm->dev); 1304 struct skl_dev *skl = get_skl_ctx(dapm->dev);
1429 1305
1430 switch (event) { 1306 switch (event) {
1431 case SND_SOC_DAPM_PRE_PMU: 1307 case SND_SOC_DAPM_PRE_PMU:
@@ -1446,10 +1322,10 @@ static int skl_tplg_tlv_control_get(struct snd_kcontrol *kcontrol,
1446 struct skl_algo_data *bc = (struct skl_algo_data *)sb->dobj.private; 1322 struct skl_algo_data *bc = (struct skl_algo_data *)sb->dobj.private;
1447 struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_widget(kcontrol); 1323 struct snd_soc_dapm_widget *w = snd_soc_dapm_kcontrol_widget(kcontrol);
1448 struct skl_module_cfg *mconfig = w->priv; 1324 struct skl_module_cfg *mconfig = w->priv;
1449 struct skl *skl = get_skl_ctx(w->dapm->dev); 1325 struct skl_dev *skl = get_skl_ctx(w->dapm->dev);
1450 1326
1451 if (w->power) 1327 if (w->power)
1452 skl_get_module_params(skl->skl_sst, (u32 *)bc->params, 1328 skl_get_module_params(skl, (u32 *)bc->params,
1453 bc->size, bc->param_id, mconfig); 1329 bc->size, bc->param_id, mconfig);
1454 1330
1455 /* decrement size for TLV header */ 1331 /* decrement size for TLV header */
@@ -1481,7 +1357,7 @@ static int skl_tplg_tlv_control_set(struct snd_kcontrol *kcontrol,
1481 struct soc_bytes_ext *sb = 1357 struct soc_bytes_ext *sb =
1482 (struct soc_bytes_ext *)kcontrol->private_value; 1358 (struct soc_bytes_ext *)kcontrol->private_value;
1483 struct skl_algo_data *ac = (struct skl_algo_data *)sb->dobj.private; 1359 struct skl_algo_data *ac = (struct skl_algo_data *)sb->dobj.private;
1484 struct skl *skl = get_skl_ctx(w->dapm->dev); 1360 struct skl_dev *skl = get_skl_ctx(w->dapm->dev);
1485 1361
1486 if (ac->params) { 1362 if (ac->params) {
1487 /* 1363 /*
@@ -1498,7 +1374,7 @@ static int skl_tplg_tlv_control_set(struct snd_kcontrol *kcontrol,
1498 return -EFAULT; 1374 return -EFAULT;
1499 1375
1500 if (w->power) 1376 if (w->power)
1501 return skl_set_module_params(skl->skl_sst, 1377 return skl_set_module_params(skl,
1502 (u32 *)ac->params, ac->size, 1378 (u32 *)ac->params, ac->size,
1503 ac->param_id, mconfig); 1379 ac->param_id, mconfig);
1504 } 1380 }
@@ -1659,7 +1535,7 @@ int skl_tplg_update_pipe_params(struct device *dev,
1659 struct skl_pipe_params *params) 1535 struct skl_pipe_params *params)
1660{ 1536{
1661 struct skl_module_res *res = &mconfig->module->resources[0]; 1537 struct skl_module_res *res = &mconfig->module->resources[0];
1662 struct skl *skl = get_skl_ctx(dev); 1538 struct skl_dev *skl = get_skl_ctx(dev);
1663 struct skl_module_fmt *format = NULL; 1539 struct skl_module_fmt *format = NULL;
1664 u8 cfg_idx = mconfig->pipe->cur_config_idx; 1540 u8 cfg_idx = mconfig->pipe->cur_config_idx;
1665 1541
@@ -1856,7 +1732,7 @@ static int skl_tplg_be_fill_pipe_params(struct snd_soc_dai *dai,
1856 struct skl_pipe_params *params) 1732 struct skl_pipe_params *params)
1857{ 1733{
1858 struct nhlt_specific_cfg *cfg; 1734 struct nhlt_specific_cfg *cfg;
1859 struct skl *skl = get_skl_ctx(dai->dev); 1735 struct skl_dev *skl = get_skl_ctx(dai->dev);
1860 int link_type = skl_tplg_be_link_type(mconfig->dev_type); 1736 int link_type = skl_tplg_be_link_type(mconfig->dev_type);
1861 u8 dev_type = skl_tplg_be_dev_type(mconfig->dev_type); 1737 u8 dev_type = skl_tplg_be_dev_type(mconfig->dev_type);
1862 1738
@@ -2070,7 +1946,7 @@ static int skl_tplg_fill_pipe_tkn(struct device *dev,
2070 * Return an existing pipe if the pipe already exists. 1946 * Return an existing pipe if the pipe already exists.
2071 */ 1947 */
2072static int skl_tplg_add_pipe(struct device *dev, 1948static int skl_tplg_add_pipe(struct device *dev,
2073 struct skl_module_cfg *mconfig, struct skl *skl, 1949 struct skl_module_cfg *mconfig, struct skl_dev *skl,
2074 struct snd_soc_tplg_vendor_value_elem *tkn_elem) 1950 struct snd_soc_tplg_vendor_value_elem *tkn_elem)
2075{ 1951{
2076 struct skl_pipeline *ppl; 1952 struct skl_pipeline *ppl;
@@ -2330,10 +2206,6 @@ static int skl_tplg_fill_res_tkn(struct device *dev,
2330 return -EINVAL; 2206 return -EINVAL;
2331 2207
2332 switch (tkn_elem->token) { 2208 switch (tkn_elem->token) {
2333 case SKL_TKN_MM_U32_CPS:
2334 res->cps = tkn_elem->value;
2335 break;
2336
2337 case SKL_TKN_MM_U32_DMA_SIZE: 2209 case SKL_TKN_MM_U32_DMA_SIZE:
2338 res->dma_buffer_size = tkn_elem->value; 2210 res->dma_buffer_size = tkn_elem->value;
2339 break; 2211 break;
@@ -2354,10 +2226,6 @@ static int skl_tplg_fill_res_tkn(struct device *dev,
2354 res->ibs = tkn_elem->value; 2226 res->ibs = tkn_elem->value;
2355 break; 2227 break;
2356 2228
2357 case SKL_TKN_U32_MAX_MCPS:
2358 res->cps = tkn_elem->value;
2359 break;
2360
2361 case SKL_TKN_MM_U32_RES_PIN_ID: 2229 case SKL_TKN_MM_U32_RES_PIN_ID:
2362 case SKL_TKN_MM_U32_PIN_BUF: 2230 case SKL_TKN_MM_U32_PIN_BUF:
2363 ret = skl_tplg_manifest_pin_res_tkn(dev, tkn_elem, res, 2231 ret = skl_tplg_manifest_pin_res_tkn(dev, tkn_elem, res,
@@ -2366,6 +2234,11 @@ static int skl_tplg_fill_res_tkn(struct device *dev,
2366 return ret; 2234 return ret;
2367 break; 2235 break;
2368 2236
2237 case SKL_TKN_MM_U32_CPS:
2238 case SKL_TKN_U32_MAX_MCPS:
2239 /* ignore unused tokens */
2240 break;
2241
2369 default: 2242 default:
2370 dev_err(dev, "Not a res type token: %d", tkn_elem->token); 2243 dev_err(dev, "Not a res type token: %d", tkn_elem->token);
2371 return -EINVAL; 2244 return -EINVAL;
@@ -2381,7 +2254,7 @@ static int skl_tplg_fill_res_tkn(struct device *dev,
2381 */ 2254 */
2382static int skl_tplg_get_token(struct device *dev, 2255static int skl_tplg_get_token(struct device *dev,
2383 struct snd_soc_tplg_vendor_value_elem *tkn_elem, 2256 struct snd_soc_tplg_vendor_value_elem *tkn_elem,
2384 struct skl *skl, struct skl_module_cfg *mconfig) 2257 struct skl_dev *skl, struct skl_module_cfg *mconfig)
2385{ 2258{
2386 int tkn_count = 0; 2259 int tkn_count = 0;
2387 int ret; 2260 int ret;
@@ -2631,7 +2504,7 @@ static int skl_tplg_get_token(struct device *dev,
2631 * module private data 2504 * module private data
2632 */ 2505 */
2633static int skl_tplg_get_tokens(struct device *dev, 2506static int skl_tplg_get_tokens(struct device *dev,
2634 char *pvt_data, struct skl *skl, 2507 char *pvt_data, struct skl_dev *skl,
2635 struct skl_module_cfg *mconfig, int block_size) 2508 struct skl_module_cfg *mconfig, int block_size)
2636{ 2509{
2637 struct snd_soc_tplg_vendor_array *array; 2510 struct snd_soc_tplg_vendor_array *array;
@@ -2727,8 +2600,8 @@ static int skl_tplg_get_desc_blocks(struct device *dev,
2727 * Otherwise we create a new instance and add into driver list 2600 * Otherwise we create a new instance and add into driver list
2728 */ 2601 */
2729static int skl_tplg_add_pipe_v4(struct device *dev, 2602static int skl_tplg_add_pipe_v4(struct device *dev,
2730 struct skl_module_cfg *mconfig, struct skl *skl, 2603 struct skl_module_cfg *mconfig, struct skl_dev *skl,
2731 struct skl_dfw_v4_pipe *dfw_pipe) 2604 struct skl_dfw_v4_pipe *dfw_pipe)
2732{ 2605{
2733 struct skl_pipeline *ppl; 2606 struct skl_pipeline *ppl;
2734 struct skl_pipe *pipe; 2607 struct skl_pipe *pipe;
@@ -2804,7 +2677,7 @@ static void skl_tplg_fill_fmt_v4(struct skl_module_pin_fmt *dst_fmt,
2804} 2677}
2805 2678
2806static int skl_tplg_get_pvt_data_v4(struct snd_soc_tplg_dapm_widget *tplg_w, 2679static int skl_tplg_get_pvt_data_v4(struct snd_soc_tplg_dapm_widget *tplg_w,
2807 struct skl *skl, struct device *dev, 2680 struct skl_dev *skl, struct device *dev,
2808 struct skl_module_cfg *mconfig) 2681 struct skl_module_cfg *mconfig)
2809{ 2682{
2810 struct skl_dfw_v4_module *dfw = 2683 struct skl_dfw_v4_module *dfw =
@@ -2818,7 +2691,7 @@ static int skl_tplg_get_pvt_data_v4(struct snd_soc_tplg_dapm_widget *tplg_w,
2818 return ret; 2691 return ret;
2819 mconfig->id.module_id = -1; 2692 mconfig->id.module_id = -1;
2820 mconfig->id.instance_id = dfw->instance_id; 2693 mconfig->id.instance_id = dfw->instance_id;
2821 mconfig->module->resources[0].cps = dfw->max_mcps; 2694 mconfig->module->resources[0].cpc = dfw->max_mcps / 1000;
2822 mconfig->module->resources[0].ibs = dfw->ibs; 2695 mconfig->module->resources[0].ibs = dfw->ibs;
2823 mconfig->module->resources[0].obs = dfw->obs; 2696 mconfig->module->resources[0].obs = dfw->obs;
2824 mconfig->core_id = dfw->core_id; 2697 mconfig->core_id = dfw->core_id;
@@ -2886,7 +2759,7 @@ static int skl_tplg_get_pvt_data_v4(struct snd_soc_tplg_dapm_widget *tplg_w,
2886 * for the type and size of the suceeding data block. 2759 * for the type and size of the suceeding data block.
2887 */ 2760 */
2888static int skl_tplg_get_pvt_data(struct snd_soc_tplg_dapm_widget *tplg_w, 2761static int skl_tplg_get_pvt_data(struct snd_soc_tplg_dapm_widget *tplg_w,
2889 struct skl *skl, struct device *dev, 2762 struct skl_dev *skl, struct device *dev,
2890 struct skl_module_cfg *mconfig) 2763 struct skl_module_cfg *mconfig)
2891{ 2764{
2892 struct snd_soc_tplg_vendor_array *array; 2765 struct snd_soc_tplg_vendor_array *array;
@@ -2981,9 +2854,8 @@ static void skl_clear_pin_config(struct snd_soc_component *component,
2981 } 2854 }
2982} 2855}
2983 2856
2984void skl_cleanup_resources(struct skl *skl) 2857void skl_cleanup_resources(struct skl_dev *skl)
2985{ 2858{
2986 struct skl_sst *ctx = skl->skl_sst;
2987 struct snd_soc_component *soc_component = skl->component; 2859 struct snd_soc_component *soc_component = skl->component;
2988 struct snd_soc_dapm_widget *w; 2860 struct snd_soc_dapm_widget *w;
2989 struct snd_soc_card *card; 2861 struct snd_soc_card *card;
@@ -2995,15 +2867,12 @@ void skl_cleanup_resources(struct skl *skl)
2995 if (!card || !card->instantiated) 2867 if (!card || !card->instantiated)
2996 return; 2868 return;
2997 2869
2998 skl->resource.mem = 0;
2999 skl->resource.mcps = 0;
3000
3001 list_for_each_entry(w, &card->widgets, list) { 2870 list_for_each_entry(w, &card->widgets, list) {
3002 if (is_skl_dsp_widget_type(w, ctx->dev) && w->priv != NULL) 2871 if (is_skl_dsp_widget_type(w, skl->dev) && w->priv != NULL)
3003 skl_clear_pin_config(soc_component, w); 2872 skl_clear_pin_config(soc_component, w);
3004 } 2873 }
3005 2874
3006 skl_clear_module_cnt(ctx->dsp); 2875 skl_clear_module_cnt(skl->dsp);
3007} 2876}
3008 2877
3009/* 2878/*
@@ -3019,7 +2888,7 @@ static int skl_tplg_widget_load(struct snd_soc_component *cmpnt, int index,
3019{ 2888{
3020 int ret; 2889 int ret;
3021 struct hdac_bus *bus = snd_soc_component_get_drvdata(cmpnt); 2890 struct hdac_bus *bus = snd_soc_component_get_drvdata(cmpnt);
3022 struct skl *skl = bus_to_skl(bus); 2891 struct skl_dev *skl = bus_to_skl(bus);
3023 struct skl_module_cfg *mconfig; 2892 struct skl_module_cfg *mconfig;
3024 2893
3025 if (!tplg_w->priv.size) 2894 if (!tplg_w->priv.size)
@@ -3163,21 +3032,21 @@ static int skl_tplg_control_load(struct snd_soc_component *cmpnt,
3163 3032
3164static int skl_tplg_fill_str_mfest_tkn(struct device *dev, 3033static int skl_tplg_fill_str_mfest_tkn(struct device *dev,
3165 struct snd_soc_tplg_vendor_string_elem *str_elem, 3034 struct snd_soc_tplg_vendor_string_elem *str_elem,
3166 struct skl *skl) 3035 struct skl_dev *skl)
3167{ 3036{
3168 int tkn_count = 0; 3037 int tkn_count = 0;
3169 static int ref_count; 3038 static int ref_count;
3170 3039
3171 switch (str_elem->token) { 3040 switch (str_elem->token) {
3172 case SKL_TKN_STR_LIB_NAME: 3041 case SKL_TKN_STR_LIB_NAME:
3173 if (ref_count > skl->skl_sst->lib_count - 1) { 3042 if (ref_count > skl->lib_count - 1) {
3174 ref_count = 0; 3043 ref_count = 0;
3175 return -EINVAL; 3044 return -EINVAL;
3176 } 3045 }
3177 3046
3178 strncpy(skl->skl_sst->lib_info[ref_count].name, 3047 strncpy(skl->lib_info[ref_count].name,
3179 str_elem->string, 3048 str_elem->string,
3180 ARRAY_SIZE(skl->skl_sst->lib_info[ref_count].name)); 3049 ARRAY_SIZE(skl->lib_info[ref_count].name));
3181 ref_count++; 3050 ref_count++;
3182 break; 3051 break;
3183 3052
@@ -3192,7 +3061,7 @@ static int skl_tplg_fill_str_mfest_tkn(struct device *dev,
3192 3061
3193static int skl_tplg_get_str_tkn(struct device *dev, 3062static int skl_tplg_get_str_tkn(struct device *dev,
3194 struct snd_soc_tplg_vendor_array *array, 3063 struct snd_soc_tplg_vendor_array *array,
3195 struct skl *skl) 3064 struct skl_dev *skl)
3196{ 3065{
3197 int tkn_count = 0, ret; 3066 int tkn_count = 0, ret;
3198 struct snd_soc_tplg_vendor_string_elem *str_elem; 3067 struct snd_soc_tplg_vendor_string_elem *str_elem;
@@ -3299,7 +3168,7 @@ static int skl_tplg_fill_mod_info(struct device *dev,
3299 3168
3300static int skl_tplg_get_int_tkn(struct device *dev, 3169static int skl_tplg_get_int_tkn(struct device *dev,
3301 struct snd_soc_tplg_vendor_value_elem *tkn_elem, 3170 struct snd_soc_tplg_vendor_value_elem *tkn_elem,
3302 struct skl *skl) 3171 struct skl_dev *skl)
3303{ 3172{
3304 int tkn_count = 0, ret; 3173 int tkn_count = 0, ret;
3305 static int mod_idx, res_val_idx, intf_val_idx, dir, pin_idx; 3174 static int mod_idx, res_val_idx, intf_val_idx, dir, pin_idx;
@@ -3319,7 +3188,7 @@ static int skl_tplg_get_int_tkn(struct device *dev,
3319 3188
3320 switch (tkn_elem->token) { 3189 switch (tkn_elem->token) {
3321 case SKL_TKN_U32_LIB_COUNT: 3190 case SKL_TKN_U32_LIB_COUNT:
3322 skl->skl_sst->lib_count = tkn_elem->value; 3191 skl->lib_count = tkn_elem->value;
3323 break; 3192 break;
3324 3193
3325 case SKL_TKN_U8_NUM_MOD: 3194 case SKL_TKN_U8_NUM_MOD:
@@ -3465,35 +3334,17 @@ static int skl_tplg_get_int_tkn(struct device *dev,
3465 return tkn_count; 3334 return tkn_count;
3466} 3335}
3467 3336
3468static int skl_tplg_get_manifest_uuid(struct device *dev,
3469 struct skl *skl,
3470 struct snd_soc_tplg_vendor_uuid_elem *uuid_tkn)
3471{
3472 static int ref_count;
3473 struct skl_module *mod;
3474
3475 if (uuid_tkn->token == SKL_TKN_UUID) {
3476 mod = skl->modules[ref_count];
3477 guid_copy(&mod->uuid, (guid_t *)&uuid_tkn->uuid);
3478 ref_count++;
3479 } else {
3480 dev_err(dev, "Not an UUID token tkn %d\n", uuid_tkn->token);
3481 return -EINVAL;
3482 }
3483
3484 return 0;
3485}
3486
3487/* 3337/*
3488 * Fill the manifest structure by parsing the tokens based on the 3338 * Fill the manifest structure by parsing the tokens based on the
3489 * type. 3339 * type.
3490 */ 3340 */
3491static int skl_tplg_get_manifest_tkn(struct device *dev, 3341static int skl_tplg_get_manifest_tkn(struct device *dev,
3492 char *pvt_data, struct skl *skl, 3342 char *pvt_data, struct skl_dev *skl,
3493 int block_size) 3343 int block_size)
3494{ 3344{
3495 int tkn_count = 0, ret; 3345 int tkn_count = 0, ret;
3496 int off = 0, tuple_size = 0; 3346 int off = 0, tuple_size = 0;
3347 u8 uuid_index = 0;
3497 struct snd_soc_tplg_vendor_array *array; 3348 struct snd_soc_tplg_vendor_array *array;
3498 struct snd_soc_tplg_vendor_value_elem *tkn_elem; 3349 struct snd_soc_tplg_vendor_value_elem *tkn_elem;
3499 3350
@@ -3516,9 +3367,17 @@ static int skl_tplg_get_manifest_tkn(struct device *dev,
3516 continue; 3367 continue;
3517 3368
3518 case SND_SOC_TPLG_TUPLE_TYPE_UUID: 3369 case SND_SOC_TPLG_TUPLE_TYPE_UUID:
3519 ret = skl_tplg_get_manifest_uuid(dev, skl, array->uuid); 3370 if (array->uuid->token != SKL_TKN_UUID) {
3520 if (ret < 0) 3371 dev_err(dev, "Not an UUID token: %d\n",
3521 return ret; 3372 array->uuid->token);
3373 return -EINVAL;
3374 }
3375 if (uuid_index >= skl->nr_modules) {
3376 dev_err(dev, "Too many UUID tokens\n");
3377 return -EINVAL;
3378 }
3379 guid_copy(&skl->modules[uuid_index++]->uuid,
3380 (guid_t *)&array->uuid->uuid);
3522 3381
3523 tuple_size += sizeof(*array->uuid); 3382 tuple_size += sizeof(*array->uuid);
3524 continue; 3383 continue;
@@ -3550,7 +3409,7 @@ static int skl_tplg_get_manifest_tkn(struct device *dev,
3550 * preceded by descriptors for type and size of data block. 3409 * preceded by descriptors for type and size of data block.
3551 */ 3410 */
3552static int skl_tplg_get_manifest_data(struct snd_soc_tplg_manifest *manifest, 3411static int skl_tplg_get_manifest_data(struct snd_soc_tplg_manifest *manifest,
3553 struct device *dev, struct skl *skl) 3412 struct device *dev, struct skl_dev *skl)
3554{ 3413{
3555 struct snd_soc_tplg_vendor_array *array; 3414 struct snd_soc_tplg_vendor_array *array;
3556 int num_blocks, block_size = 0, block_type, off = 0; 3415 int num_blocks, block_size = 0, block_type, off = 0;
@@ -3612,7 +3471,7 @@ static int skl_manifest_load(struct snd_soc_component *cmpnt, int index,
3612 struct snd_soc_tplg_manifest *manifest) 3471 struct snd_soc_tplg_manifest *manifest)
3613{ 3472{
3614 struct hdac_bus *bus = snd_soc_component_get_drvdata(cmpnt); 3473 struct hdac_bus *bus = snd_soc_component_get_drvdata(cmpnt);
3615 struct skl *skl = bus_to_skl(bus); 3474 struct skl_dev *skl = bus_to_skl(bus);
3616 3475
3617 /* proceed only if we have private data defined */ 3476 /* proceed only if we have private data defined */
3618 if (manifest->priv.size == 0) 3477 if (manifest->priv.size == 0)
@@ -3620,9 +3479,9 @@ static int skl_manifest_load(struct snd_soc_component *cmpnt, int index,
3620 3479
3621 skl_tplg_get_manifest_data(manifest, bus->dev, skl); 3480 skl_tplg_get_manifest_data(manifest, bus->dev, skl);
3622 3481
3623 if (skl->skl_sst->lib_count > SKL_MAX_LIB) { 3482 if (skl->lib_count > SKL_MAX_LIB) {
3624 dev_err(bus->dev, "Exceeding max Library count. Got:%d\n", 3483 dev_err(bus->dev, "Exceeding max Library count. Got:%d\n",
3625 skl->skl_sst->lib_count); 3484 skl->lib_count);
3626 return -EINVAL; 3485 return -EINVAL;
3627 } 3486 }
3628 3487
@@ -3671,7 +3530,7 @@ static int skl_tplg_create_pipe_widget_list(struct snd_soc_component *component)
3671 return 0; 3530 return 0;
3672} 3531}
3673 3532
3674static void skl_tplg_set_pipe_type(struct skl *skl, struct skl_pipe *pipe) 3533static void skl_tplg_set_pipe_type(struct skl_dev *skl, struct skl_pipe *pipe)
3675{ 3534{
3676 struct skl_pipe_module *w_module; 3535 struct skl_pipe_module *w_module;
3677 struct snd_soc_dapm_widget *w; 3536 struct snd_soc_dapm_widget *w;
@@ -3694,10 +3553,6 @@ static void skl_tplg_set_pipe_type(struct skl *skl, struct skl_pipe *pipe)
3694 pipe->passthru = false; 3553 pipe->passthru = false;
3695} 3554}
3696 3555
3697/* This will be read from topology manifest, currently defined here */
3698#define SKL_MAX_MCPS 30000000
3699#define SKL_FW_MAX_MEM 1000000
3700
3701/* 3556/*
3702 * SKL topology init routine 3557 * SKL topology init routine
3703 */ 3558 */
@@ -3705,7 +3560,7 @@ int skl_tplg_init(struct snd_soc_component *component, struct hdac_bus *bus)
3705{ 3560{
3706 int ret; 3561 int ret;
3707 const struct firmware *fw; 3562 const struct firmware *fw;
3708 struct skl *skl = bus_to_skl(bus); 3563 struct skl_dev *skl = bus_to_skl(bus);
3709 struct skl_pipeline *ppl; 3564 struct skl_pipeline *ppl;
3710 3565
3711 ret = request_firmware(&fw, skl->tplg_name, bus->dev); 3566 ret = request_firmware(&fw, skl->tplg_name, bus->dev);
@@ -3724,31 +3579,30 @@ int skl_tplg_init(struct snd_soc_component *component, struct hdac_bus *bus)
3724 * The complete tplg for SKL is loaded as index 0, we don't use 3579 * The complete tplg for SKL is loaded as index 0, we don't use
3725 * any other index 3580 * any other index
3726 */ 3581 */
3727 ret = snd_soc_tplg_component_load(component, 3582 ret = snd_soc_tplg_component_load(component, &skl_tplg_ops, fw, 0);
3728 &skl_tplg_ops, fw, 0);
3729 if (ret < 0) { 3583 if (ret < 0) {
3730 dev_err(bus->dev, "tplg component load failed%d\n", ret); 3584 dev_err(bus->dev, "tplg component load failed%d\n", ret);
3731 release_firmware(fw); 3585 goto err;
3732 return -EINVAL;
3733 } 3586 }
3734 3587
3735 skl->resource.max_mcps = SKL_MAX_MCPS;
3736 skl->resource.max_mem = SKL_FW_MAX_MEM;
3737
3738 skl->tplg = fw;
3739 ret = skl_tplg_create_pipe_widget_list(component); 3588 ret = skl_tplg_create_pipe_widget_list(component);
3740 if (ret < 0) 3589 if (ret < 0) {
3741 return ret; 3590 dev_err(bus->dev, "tplg create pipe widget list failed%d\n",
3591 ret);
3592 goto err;
3593 }
3742 3594
3743 list_for_each_entry(ppl, &skl->ppl_list, node) 3595 list_for_each_entry(ppl, &skl->ppl_list, node)
3744 skl_tplg_set_pipe_type(skl, ppl->pipe); 3596 skl_tplg_set_pipe_type(skl, ppl->pipe);
3745 3597
3746 return 0; 3598err:
3599 release_firmware(fw);
3600 return ret;
3747} 3601}
3748 3602
3749void skl_tplg_exit(struct snd_soc_component *component, struct hdac_bus *bus) 3603void skl_tplg_exit(struct snd_soc_component *component, struct hdac_bus *bus)
3750{ 3604{
3751 struct skl *skl = bus_to_skl(bus); 3605 struct skl_dev *skl = bus_to_skl(bus);
3752 struct skl_pipeline *ppl, *tmp; 3606 struct skl_pipeline *ppl, *tmp;
3753 3607
3754 if (!list_empty(&skl->ppl_list)) 3608 if (!list_empty(&skl->ppl_list))
@@ -3757,6 +3611,4 @@ void skl_tplg_exit(struct snd_soc_component *component, struct hdac_bus *bus)
3757 3611
3758 /* clean up topology */ 3612 /* clean up topology */
3759 snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL); 3613 snd_soc_tplg_component_remove(component, SND_SOC_TPLG_INDEX_ALL);
3760
3761 release_firmware(skl->tplg);
3762} 3614}
diff --git a/sound/soc/intel/skylake/skl-topology.h b/sound/soc/intel/skylake/skl-topology.h
index 665e35cee50d..e967800dbb62 100644
--- a/sound/soc/intel/skylake/skl-topology.h
+++ b/sound/soc/intel/skylake/skl-topology.h
@@ -101,7 +101,7 @@ struct skl_audio_data_format {
101} __packed; 101} __packed;
102 102
103struct skl_base_cfg { 103struct skl_base_cfg {
104 u32 cps; 104 u32 cpc;
105 u32 ibs; 105 u32 ibs;
106 u32 obs; 106 u32 obs;
107 u32 is_pages; 107 u32 is_pages;
@@ -140,11 +140,6 @@ struct skl_src_module_cfg {
140 enum skl_s_freq src_cfg; 140 enum skl_s_freq src_cfg;
141} __packed; 141} __packed;
142 142
143struct notification_mask {
144 u32 notify;
145 u32 enable;
146} __packed;
147
148struct skl_up_down_mixer_cfg { 143struct skl_up_down_mixer_cfg {
149 struct skl_base_cfg base_cfg; 144 struct skl_base_cfg base_cfg;
150 enum skl_ch_cfg out_ch_cfg; 145 enum skl_ch_cfg out_ch_cfg;
@@ -348,7 +343,6 @@ struct skl_module_pin_resources {
348struct skl_module_res { 343struct skl_module_res {
349 u8 id; 344 u8 id;
350 u32 is_pages; 345 u32 is_pages;
351 u32 cps;
352 u32 ibs; 346 u32 ibs;
353 u32 obs; 347 u32 obs;
354 u32 dma_buffer_size; 348 u32 dma_buffer_size;
@@ -389,9 +383,6 @@ struct skl_module_cfg {
389 u8 out_queue_mask; 383 u8 out_queue_mask;
390 u8 in_queue; 384 u8 in_queue;
391 u8 out_queue; 385 u8 out_queue;
392 u32 mcps;
393 u32 ibs;
394 u32 obs;
395 u8 is_loadable; 386 u8 is_loadable;
396 u8 core_id; 387 u8 core_id;
397 u8 dev_type; 388 u8 dev_type;
@@ -447,7 +438,7 @@ enum skl_channel {
447 SKL_CH_QUATRO = 4, 438 SKL_CH_QUATRO = 4,
448}; 439};
449 440
450static inline struct skl *get_skl_ctx(struct device *dev) 441static inline struct skl_dev *get_skl_ctx(struct device *dev)
451{ 442{
452 struct hdac_bus *bus = dev_get_drvdata(dev); 443 struct hdac_bus *bus = dev_get_drvdata(dev);
453 444
@@ -456,7 +447,7 @@ static inline struct skl *get_skl_ctx(struct device *dev)
456 447
457int skl_tplg_be_update_params(struct snd_soc_dai *dai, 448int skl_tplg_be_update_params(struct snd_soc_dai *dai,
458 struct skl_pipe_params *params); 449 struct skl_pipe_params *params);
459int skl_dsp_set_dma_control(struct skl_sst *ctx, u32 *caps, 450int skl_dsp_set_dma_control(struct skl_dev *skl, u32 *caps,
460 u32 caps_size, u32 node_id); 451 u32 caps_size, u32 node_id);
461void skl_tplg_set_be_dmic_config(struct snd_soc_dai *dai, 452void skl_tplg_set_be_dmic_config(struct snd_soc_dai *dai,
462 struct skl_pipe_params *params, int stream); 453 struct skl_pipe_params *params, int stream);
@@ -469,32 +460,32 @@ struct skl_module_cfg *skl_tplg_fe_get_cpr_module(
469int skl_tplg_update_pipe_params(struct device *dev, 460int skl_tplg_update_pipe_params(struct device *dev,
470 struct skl_module_cfg *mconfig, struct skl_pipe_params *params); 461 struct skl_module_cfg *mconfig, struct skl_pipe_params *params);
471 462
472void skl_tplg_d0i3_get(struct skl *skl, enum d0i3_capability caps); 463void skl_tplg_d0i3_get(struct skl_dev *skl, enum d0i3_capability caps);
473void skl_tplg_d0i3_put(struct skl *skl, enum d0i3_capability caps); 464void skl_tplg_d0i3_put(struct skl_dev *skl, enum d0i3_capability caps);
474 465
475int skl_create_pipeline(struct skl_sst *ctx, struct skl_pipe *pipe); 466int skl_create_pipeline(struct skl_dev *skl, struct skl_pipe *pipe);
476 467
477int skl_run_pipe(struct skl_sst *ctx, struct skl_pipe *pipe); 468int skl_run_pipe(struct skl_dev *skl, struct skl_pipe *pipe);
478 469
479int skl_pause_pipe(struct skl_sst *ctx, struct skl_pipe *pipe); 470int skl_pause_pipe(struct skl_dev *skl, struct skl_pipe *pipe);
480 471
481int skl_delete_pipe(struct skl_sst *ctx, struct skl_pipe *pipe); 472int skl_delete_pipe(struct skl_dev *skl, struct skl_pipe *pipe);
482 473
483int skl_stop_pipe(struct skl_sst *ctx, struct skl_pipe *pipe); 474int skl_stop_pipe(struct skl_dev *skl, struct skl_pipe *pipe);
484 475
485int skl_reset_pipe(struct skl_sst *ctx, struct skl_pipe *pipe); 476int skl_reset_pipe(struct skl_dev *skl, struct skl_pipe *pipe);
486 477
487int skl_init_module(struct skl_sst *ctx, struct skl_module_cfg *module_config); 478int skl_init_module(struct skl_dev *skl, struct skl_module_cfg *module_config);
488 479
489int skl_bind_modules(struct skl_sst *ctx, struct skl_module_cfg 480int skl_bind_modules(struct skl_dev *skl, struct skl_module_cfg
490 *src_module, struct skl_module_cfg *dst_module); 481 *src_module, struct skl_module_cfg *dst_module);
491 482
492int skl_unbind_modules(struct skl_sst *ctx, struct skl_module_cfg 483int skl_unbind_modules(struct skl_dev *skl, struct skl_module_cfg
493 *src_module, struct skl_module_cfg *dst_module); 484 *src_module, struct skl_module_cfg *dst_module);
494 485
495int skl_set_module_params(struct skl_sst *ctx, u32 *params, int size, 486int skl_set_module_params(struct skl_dev *skl, u32 *params, int size,
496 u32 param_id, struct skl_module_cfg *mcfg); 487 u32 param_id, struct skl_module_cfg *mcfg);
497int skl_get_module_params(struct skl_sst *ctx, u32 *params, int size, 488int skl_get_module_params(struct skl_dev *skl, u32 *params, int size,
498 u32 param_id, struct skl_module_cfg *mcfg); 489 u32 param_id, struct skl_module_cfg *mcfg);
499 490
500struct skl_module_cfg *skl_tplg_be_get_cpr_module(struct snd_soc_dai *dai, 491struct skl_module_cfg *skl_tplg_be_get_cpr_module(struct snd_soc_dai *dai,
@@ -508,6 +499,6 @@ int skl_pcm_link_dma_prepare(struct device *dev,
508int skl_dai_load(struct snd_soc_component *cmp, int index, 499int skl_dai_load(struct snd_soc_component *cmp, int index,
509 struct snd_soc_dai_driver *dai_drv, 500 struct snd_soc_dai_driver *dai_drv,
510 struct snd_soc_tplg_pcm *pcm, struct snd_soc_dai *dai); 501 struct snd_soc_tplg_pcm *pcm, struct snd_soc_dai *dai);
511void skl_tplg_add_moduleid_in_bind_params(struct skl *skl, 502void skl_tplg_add_moduleid_in_bind_params(struct skl_dev *skl,
512 struct snd_soc_dapm_widget *w); 503 struct snd_soc_dapm_widget *w);
513#endif 504#endif
diff --git a/sound/soc/intel/skylake/skl.c b/sound/soc/intel/skylake/skl.c
index 3362e71b4563..141dbbf975ac 100644
--- a/sound/soc/intel/skylake/skl.c
+++ b/sound/soc/intel/skylake/skl.c
@@ -26,9 +26,11 @@
26#include <sound/hdaudio.h> 26#include <sound/hdaudio.h>
27#include <sound/hda_i915.h> 27#include <sound/hda_i915.h>
28#include <sound/hda_codec.h> 28#include <sound/hda_codec.h>
29#include <sound/intel-nhlt.h>
29#include "skl.h" 30#include "skl.h"
30#include "skl-sst-dsp.h" 31#include "skl-sst-dsp.h"
31#include "skl-sst-ipc.h" 32#include "skl-sst-ipc.h"
33
32#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC) 34#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC)
33#include "../../../soc/codecs/hdac_hda.h" 35#include "../../../soc/codecs/hdac_hda.h"
34#endif 36#endif
@@ -50,7 +52,7 @@ static void skl_update_pci_byte(struct pci_dev *pci, unsigned int reg,
50 pci_write_config_byte(pci, reg, data); 52 pci_write_config_byte(pci, reg, data);
51} 53}
52 54
53static void skl_init_pci(struct skl *skl) 55static void skl_init_pci(struct skl_dev *skl)
54{ 56{
55 struct hdac_bus *bus = skl_to_bus(skl); 57 struct hdac_bus *bus = skl_to_bus(skl);
56 58
@@ -132,7 +134,7 @@ static int skl_init_chip(struct hdac_bus *bus, bool full_reset)
132 134
133 /* Reset stream-to-link mapping */ 135 /* Reset stream-to-link mapping */
134 list_for_each_entry(hlink, &bus->hlink_list, list) 136 list_for_each_entry(hlink, &bus->hlink_list, list)
135 bus->io_ops->reg_writel(0, hlink->ml_addr + AZX_REG_ML_LOSIDV); 137 writel(0, hlink->ml_addr + AZX_REG_ML_LOSIDV);
136 138
137 skl_enable_miscbdcge(bus->dev, true); 139 skl_enable_miscbdcge(bus->dev, true);
138 140
@@ -252,7 +254,7 @@ static irqreturn_t skl_threaded_handler(int irq, void *dev_id)
252 254
253static int skl_acquire_irq(struct hdac_bus *bus, int do_disconnect) 255static int skl_acquire_irq(struct hdac_bus *bus, int do_disconnect)
254{ 256{
255 struct skl *skl = bus_to_skl(bus); 257 struct skl_dev *skl = bus_to_skl(bus);
256 int ret; 258 int ret;
257 259
258 ret = request_threaded_irq(skl->pci->irq, skl_interrupt, 260 ret = request_threaded_irq(skl->pci->irq, skl_interrupt,
@@ -276,7 +278,7 @@ static int skl_suspend_late(struct device *dev)
276{ 278{
277 struct pci_dev *pci = to_pci_dev(dev); 279 struct pci_dev *pci = to_pci_dev(dev);
278 struct hdac_bus *bus = pci_get_drvdata(pci); 280 struct hdac_bus *bus = pci_get_drvdata(pci);
279 struct skl *skl = bus_to_skl(bus); 281 struct skl_dev *skl = bus_to_skl(bus);
280 282
281 return skl_suspend_late_dsp(skl); 283 return skl_suspend_late_dsp(skl);
282} 284}
@@ -284,7 +286,7 @@ static int skl_suspend_late(struct device *dev)
284#ifdef CONFIG_PM 286#ifdef CONFIG_PM
285static int _skl_suspend(struct hdac_bus *bus) 287static int _skl_suspend(struct hdac_bus *bus)
286{ 288{
287 struct skl *skl = bus_to_skl(bus); 289 struct skl_dev *skl = bus_to_skl(bus);
288 struct pci_dev *pci = to_pci_dev(bus->dev); 290 struct pci_dev *pci = to_pci_dev(bus->dev);
289 int ret; 291 int ret;
290 292
@@ -307,7 +309,7 @@ static int _skl_suspend(struct hdac_bus *bus)
307 309
308static int _skl_resume(struct hdac_bus *bus) 310static int _skl_resume(struct hdac_bus *bus)
309{ 311{
310 struct skl *skl = bus_to_skl(bus); 312 struct skl_dev *skl = bus_to_skl(bus);
311 313
312 skl_init_pci(skl); 314 skl_init_pci(skl);
313 skl_dum_set(bus); 315 skl_dum_set(bus);
@@ -325,7 +327,7 @@ static int skl_suspend(struct device *dev)
325{ 327{
326 struct pci_dev *pci = to_pci_dev(dev); 328 struct pci_dev *pci = to_pci_dev(dev);
327 struct hdac_bus *bus = pci_get_drvdata(pci); 329 struct hdac_bus *bus = pci_get_drvdata(pci);
328 struct skl *skl = bus_to_skl(bus); 330 struct skl_dev *skl = bus_to_skl(bus);
329 int ret; 331 int ret;
330 332
331 /* 333 /*
@@ -345,7 +347,7 @@ static int skl_suspend(struct device *dev)
345 ret = _skl_suspend(bus); 347 ret = _skl_suspend(bus);
346 if (ret < 0) 348 if (ret < 0)
347 return ret; 349 return ret;
348 skl->skl_sst->fw_loaded = false; 350 skl->fw_loaded = false;
349 } 351 }
350 352
351 return 0; 353 return 0;
@@ -355,7 +357,7 @@ static int skl_resume(struct device *dev)
355{ 357{
356 struct pci_dev *pci = to_pci_dev(dev); 358 struct pci_dev *pci = to_pci_dev(dev);
357 struct hdac_bus *bus = pci_get_drvdata(pci); 359 struct hdac_bus *bus = pci_get_drvdata(pci);
358 struct skl *skl = bus_to_skl(bus); 360 struct skl_dev *skl = bus_to_skl(bus);
359 struct hdac_ext_link *hlink = NULL; 361 struct hdac_ext_link *hlink = NULL;
360 int ret; 362 int ret;
361 363
@@ -430,7 +432,7 @@ static const struct dev_pm_ops skl_pm = {
430 */ 432 */
431static int skl_free(struct hdac_bus *bus) 433static int skl_free(struct hdac_bus *bus)
432{ 434{
433 struct skl *skl = bus_to_skl(bus); 435 struct skl_dev *skl = bus_to_skl(bus);
434 436
435 skl->init_done = 0; /* to be sure */ 437 skl->init_done = 0; /* to be sure */
436 438
@@ -475,7 +477,7 @@ static struct skl_ssp_clk skl_ssp_clks[] = {
475 {.name = "ssp5_sclkfs"}, 477 {.name = "ssp5_sclkfs"},
476}; 478};
477 479
478static struct snd_soc_acpi_mach *skl_find_hda_machine(struct skl *skl, 480static struct snd_soc_acpi_mach *skl_find_hda_machine(struct skl_dev *skl,
479 struct snd_soc_acpi_mach *machines) 481 struct snd_soc_acpi_mach *machines)
480{ 482{
481 struct hdac_bus *bus = skl_to_bus(skl); 483 struct hdac_bus *bus = skl_to_bus(skl);
@@ -494,7 +496,7 @@ static struct snd_soc_acpi_mach *skl_find_hda_machine(struct skl *skl,
494 return mach; 496 return mach;
495} 497}
496 498
497static int skl_find_machine(struct skl *skl, void *driver_data) 499static int skl_find_machine(struct skl_dev *skl, void *driver_data)
498{ 500{
499 struct hdac_bus *bus = skl_to_bus(skl); 501 struct hdac_bus *bus = skl_to_bus(skl);
500 struct snd_soc_acpi_mach *mach = driver_data; 502 struct snd_soc_acpi_mach *mach = driver_data;
@@ -516,13 +518,15 @@ static int skl_find_machine(struct skl *skl, void *driver_data)
516 518
517 if (pdata) { 519 if (pdata) {
518 skl->use_tplg_pcm = pdata->use_tplg_pcm; 520 skl->use_tplg_pcm = pdata->use_tplg_pcm;
519 mach->mach_params.dmic_num = skl_get_dmic_geo(skl); 521 mach->mach_params.dmic_num =
522 intel_nhlt_get_dmic_geo(&skl->pci->dev,
523 skl->nhlt);
520 } 524 }
521 525
522 return 0; 526 return 0;
523} 527}
524 528
525static int skl_machine_device_register(struct skl *skl) 529static int skl_machine_device_register(struct skl_dev *skl)
526{ 530{
527 struct snd_soc_acpi_mach *mach = skl->mach; 531 struct snd_soc_acpi_mach *mach = skl->mach;
528 struct hdac_bus *bus = skl_to_bus(skl); 532 struct hdac_bus *bus = skl_to_bus(skl);
@@ -558,13 +562,13 @@ static int skl_machine_device_register(struct skl *skl)
558 return 0; 562 return 0;
559} 563}
560 564
561static void skl_machine_device_unregister(struct skl *skl) 565static void skl_machine_device_unregister(struct skl_dev *skl)
562{ 566{
563 if (skl->i2s_dev) 567 if (skl->i2s_dev)
564 platform_device_unregister(skl->i2s_dev); 568 platform_device_unregister(skl->i2s_dev);
565} 569}
566 570
567static int skl_dmic_device_register(struct skl *skl) 571static int skl_dmic_device_register(struct skl_dev *skl)
568{ 572{
569 struct hdac_bus *bus = skl_to_bus(skl); 573 struct hdac_bus *bus = skl_to_bus(skl);
570 struct platform_device *pdev; 574 struct platform_device *pdev;
@@ -588,7 +592,7 @@ static int skl_dmic_device_register(struct skl *skl)
588 return 0; 592 return 0;
589} 593}
590 594
591static void skl_dmic_device_unregister(struct skl *skl) 595static void skl_dmic_device_unregister(struct skl_dev *skl)
592{ 596{
593 if (skl->dmic_dev) 597 if (skl->dmic_dev)
594 platform_device_unregister(skl->dmic_dev); 598 platform_device_unregister(skl->dmic_dev);
@@ -626,7 +630,7 @@ static void init_skl_xtal_rate(int pci_id)
626 } 630 }
627} 631}
628 632
629static int skl_clock_device_register(struct skl *skl) 633static int skl_clock_device_register(struct skl_dev *skl)
630{ 634{
631 struct platform_device_info pdevinfo = {NULL}; 635 struct platform_device_info pdevinfo = {NULL};
632 struct skl_clk_pdata *clk_pdata; 636 struct skl_clk_pdata *clk_pdata;
@@ -656,7 +660,7 @@ static int skl_clock_device_register(struct skl *skl)
656 return PTR_ERR_OR_ZERO(skl->clk_dev); 660 return PTR_ERR_OR_ZERO(skl->clk_dev);
657} 661}
658 662
659static void skl_clock_device_unregister(struct skl *skl) 663static void skl_clock_device_unregister(struct skl_dev *skl)
660{ 664{
661 if (skl->clk_dev) 665 if (skl->clk_dev)
662 platform_device_unregister(skl->clk_dev); 666 platform_device_unregister(skl->clk_dev);
@@ -692,7 +696,7 @@ static int probe_codec(struct hdac_bus *bus, int addr)
692 unsigned int cmd = (addr << 28) | (AC_NODE_ROOT << 20) | 696 unsigned int cmd = (addr << 28) | (AC_NODE_ROOT << 20) |
693 (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID; 697 (AC_VERB_PARAMETERS << 8) | AC_PAR_VENDOR_ID;
694 unsigned int res = -1; 698 unsigned int res = -1;
695 struct skl *skl = bus_to_skl(bus); 699 struct skl_dev *skl = bus_to_skl(bus);
696#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC) 700#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC)
697 struct hdac_hda_priv *hda_codec; 701 struct hdac_hda_priv *hda_codec;
698 int err; 702 int err;
@@ -792,7 +796,7 @@ static int skl_i915_init(struct hdac_bus *bus)
792 796
793static void skl_probe_work(struct work_struct *work) 797static void skl_probe_work(struct work_struct *work)
794{ 798{
795 struct skl *skl = container_of(work, struct skl, probe_work); 799 struct skl_dev *skl = container_of(work, struct skl_dev, probe_work);
796 struct hdac_bus *bus = skl_to_bus(skl); 800 struct hdac_bus *bus = skl_to_bus(skl);
797 struct hdac_ext_link *hlink = NULL; 801 struct hdac_ext_link *hlink = NULL;
798 int err; 802 int err;
@@ -854,11 +858,10 @@ out_err:
854 * constructor 858 * constructor
855 */ 859 */
856static int skl_create(struct pci_dev *pci, 860static int skl_create(struct pci_dev *pci,
857 const struct hdac_io_ops *io_ops, 861 struct skl_dev **rskl)
858 struct skl **rskl)
859{ 862{
860 struct hdac_ext_bus_ops *ext_ops = NULL; 863 struct hdac_ext_bus_ops *ext_ops = NULL;
861 struct skl *skl; 864 struct skl_dev *skl;
862 struct hdac_bus *bus; 865 struct hdac_bus *bus;
863 struct hda_bus *hbus; 866 struct hda_bus *hbus;
864 int err; 867 int err;
@@ -884,7 +887,7 @@ static int skl_create(struct pci_dev *pci,
884#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC) 887#if IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC)
885 ext_ops = snd_soc_hdac_hda_get_ops(); 888 ext_ops = snd_soc_hdac_hda_get_ops();
886#endif 889#endif
887 snd_hdac_ext_bus_init(bus, &pci->dev, &bus_core_ops, io_ops, ext_ops); 890 snd_hdac_ext_bus_init(bus, &pci->dev, &bus_core_ops, ext_ops);
888 bus->use_posbuf = 1; 891 bus->use_posbuf = 1;
889 skl->pci = pci; 892 skl->pci = pci;
890 INIT_WORK(&skl->probe_work, skl_probe_work); 893 INIT_WORK(&skl->probe_work, skl_probe_work);
@@ -902,7 +905,7 @@ static int skl_create(struct pci_dev *pci,
902 905
903static int skl_first_init(struct hdac_bus *bus) 906static int skl_first_init(struct hdac_bus *bus)
904{ 907{
905 struct skl *skl = bus_to_skl(bus); 908 struct skl_dev *skl = bus_to_skl(bus);
906 struct pci_dev *pci = skl->pci; 909 struct pci_dev *pci = skl->pci;
907 int err; 910 int err;
908 unsigned short gcap; 911 unsigned short gcap;
@@ -978,7 +981,7 @@ static int skl_first_init(struct hdac_bus *bus)
978static int skl_probe(struct pci_dev *pci, 981static int skl_probe(struct pci_dev *pci,
979 const struct pci_device_id *pci_id) 982 const struct pci_device_id *pci_id)
980{ 983{
981 struct skl *skl; 984 struct skl_dev *skl;
982 struct hdac_bus *bus = NULL; 985 struct hdac_bus *bus = NULL;
983 int err; 986 int err;
984 987
@@ -1013,7 +1016,7 @@ static int skl_probe(struct pci_dev *pci,
1013 } 1016 }
1014 1017
1015 /* we use ext core ops, so provide NULL for ops here */ 1018 /* we use ext core ops, so provide NULL for ops here */
1016 err = skl_create(pci, NULL, &skl); 1019 err = skl_create(pci, &skl);
1017 if (err < 0) 1020 if (err < 0)
1018 return err; 1021 return err;
1019 1022
@@ -1029,7 +1032,7 @@ static int skl_probe(struct pci_dev *pci,
1029 1032
1030 device_disable_async_suspend(bus->dev); 1033 device_disable_async_suspend(bus->dev);
1031 1034
1032 skl->nhlt = skl_nhlt_init(bus->dev); 1035 skl->nhlt = intel_nhlt_init(bus->dev);
1033 1036
1034 if (skl->nhlt == NULL) { 1037 if (skl->nhlt == NULL) {
1035#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC) 1038#if !IS_ENABLED(CONFIG_SND_SOC_INTEL_SKYLAKE_HDAUDIO_CODEC)
@@ -1071,8 +1074,8 @@ static int skl_probe(struct pci_dev *pci,
1071 dev_dbg(bus->dev, "error failed to register dsp\n"); 1074 dev_dbg(bus->dev, "error failed to register dsp\n");
1072 goto out_nhlt_free; 1075 goto out_nhlt_free;
1073 } 1076 }
1074 skl->skl_sst->enable_miscbdcge = skl_enable_miscbdcge; 1077 skl->enable_miscbdcge = skl_enable_miscbdcge;
1075 skl->skl_sst->clock_power_gating = skl_clock_power_gating; 1078 skl->clock_power_gating = skl_clock_power_gating;
1076 1079
1077 if (bus->mlcap) 1080 if (bus->mlcap)
1078 snd_hdac_ext_bus_get_ml_capabilities(bus); 1081 snd_hdac_ext_bus_get_ml_capabilities(bus);
@@ -1095,7 +1098,7 @@ out_dsp_free:
1095out_clk_free: 1098out_clk_free:
1096 skl_clock_device_unregister(skl); 1099 skl_clock_device_unregister(skl);
1097out_nhlt_free: 1100out_nhlt_free:
1098 skl_nhlt_free(skl->nhlt); 1101 intel_nhlt_free(skl->nhlt);
1099out_free: 1102out_free:
1100 skl_free(bus); 1103 skl_free(bus);
1101 1104
@@ -1107,7 +1110,7 @@ static void skl_shutdown(struct pci_dev *pci)
1107 struct hdac_bus *bus = pci_get_drvdata(pci); 1110 struct hdac_bus *bus = pci_get_drvdata(pci);
1108 struct hdac_stream *s; 1111 struct hdac_stream *s;
1109 struct hdac_ext_stream *stream; 1112 struct hdac_ext_stream *stream;
1110 struct skl *skl; 1113 struct skl_dev *skl;
1111 1114
1112 if (!bus) 1115 if (!bus)
1113 return; 1116 return;
@@ -1129,7 +1132,7 @@ static void skl_shutdown(struct pci_dev *pci)
1129static void skl_remove(struct pci_dev *pci) 1132static void skl_remove(struct pci_dev *pci)
1130{ 1133{
1131 struct hdac_bus *bus = pci_get_drvdata(pci); 1134 struct hdac_bus *bus = pci_get_drvdata(pci);
1132 struct skl *skl = bus_to_skl(bus); 1135 struct skl_dev *skl = bus_to_skl(bus);
1133 1136
1134 cancel_work_sync(&skl->probe_work); 1137 cancel_work_sync(&skl->probe_work);
1135 1138
@@ -1144,7 +1147,7 @@ static void skl_remove(struct pci_dev *pci)
1144 skl_dmic_device_unregister(skl); 1147 skl_dmic_device_unregister(skl);
1145 skl_clock_device_unregister(skl); 1148 skl_clock_device_unregister(skl);
1146 skl_nhlt_remove_sysfs(skl); 1149 skl_nhlt_remove_sysfs(skl);
1147 skl_nhlt_free(skl->nhlt); 1150 intel_nhlt_free(skl->nhlt);
1148 skl_free(bus); 1151 skl_free(bus);
1149 dev_set_drvdata(&pci->dev, NULL); 1152 dev_set_drvdata(&pci->dev, NULL);
1150} 1153}
diff --git a/sound/soc/intel/skylake/skl.h b/sound/soc/intel/skylake/skl.h
index 6070666a6392..2bfbf59277c4 100644
--- a/sound/soc/intel/skylake/skl.h
+++ b/sound/soc/intel/skylake/skl.h
@@ -16,8 +16,8 @@
16#include <sound/hdaudio_ext.h> 16#include <sound/hdaudio_ext.h>
17#include <sound/hda_codec.h> 17#include <sound/hda_codec.h>
18#include <sound/soc.h> 18#include <sound/soc.h>
19#include "skl-nhlt.h"
20#include "skl-ssp-clk.h" 19#include "skl-ssp-clk.h"
20#include "skl-sst-ipc.h"
21 21
22#define SKL_SUSPEND_DELAY 2000 22#define SKL_SUSPEND_DELAY 2000
23 23
@@ -40,13 +40,6 @@
40#define AZX_VS_EM2_DUM BIT(23) 40#define AZX_VS_EM2_DUM BIT(23)
41#define AZX_REG_VS_EM2_L1SEN BIT(13) 41#define AZX_REG_VS_EM2_L1SEN BIT(13)
42 42
43struct skl_dsp_resource {
44 u32 max_mcps;
45 u32 max_mem;
46 u32 mcps;
47 u32 mem;
48};
49
50struct skl_debug; 43struct skl_debug;
51 44
52struct skl_astate_param { 45struct skl_astate_param {
@@ -63,7 +56,7 @@ struct skl_fw_config {
63 struct skl_astate_config *astate_cfg; 56 struct skl_astate_config *astate_cfg;
64}; 57};
65 58
66struct skl { 59struct skl_dev {
67 struct hda_bus hbus; 60 struct hda_bus hbus;
68 struct pci_dev *pci; 61 struct pci_dev *pci;
69 62
@@ -75,16 +68,13 @@ struct skl {
75 struct snd_soc_dai_driver *dais; 68 struct snd_soc_dai_driver *dais;
76 69
77 struct nhlt_acpi_table *nhlt; /* nhlt ptr */ 70 struct nhlt_acpi_table *nhlt; /* nhlt ptr */
78 struct skl_sst *skl_sst; /* sst skl ctx */
79 71
80 struct skl_dsp_resource resource;
81 struct list_head ppl_list; 72 struct list_head ppl_list;
82 struct list_head bind_list; 73 struct list_head bind_list;
83 74
84 const char *fw_name; 75 const char *fw_name;
85 char tplg_name[64]; 76 char tplg_name[64];
86 unsigned short pci_id; 77 unsigned short pci_id;
87 const struct firmware *tplg;
88 78
89 int supend_active; 79 int supend_active;
90 80
@@ -96,13 +86,59 @@ struct skl {
96 bool use_tplg_pcm; 86 bool use_tplg_pcm;
97 struct skl_fw_config cfg; 87 struct skl_fw_config cfg;
98 struct snd_soc_acpi_mach *mach; 88 struct snd_soc_acpi_mach *mach;
89
90 struct device *dev;
91 struct sst_dsp *dsp;
92
93 /* boot */
94 wait_queue_head_t boot_wait;
95 bool boot_complete;
96
97 /* module load */
98 wait_queue_head_t mod_load_wait;
99 bool mod_load_complete;
100 bool mod_load_status;
101
102 /* IPC messaging */
103 struct sst_generic_ipc ipc;
104
105 /* callback for miscbdge */
106 void (*enable_miscbdcge)(struct device *dev, bool enable);
107 /* Is CGCTL.MISCBDCGE disabled */
108 bool miscbdcg_disabled;
109
110 /* Populate module information */
111 struct list_head uuid_list;
112
113 /* Is firmware loaded */
114 bool fw_loaded;
115
116 /* first boot ? */
117 bool is_first_boot;
118
119 /* multi-core */
120 struct skl_dsp_cores cores;
121
122 /* library info */
123 struct skl_lib_info lib_info[SKL_MAX_LIB];
124 int lib_count;
125
126 /* Callback to update D0i3C register */
127 void (*update_d0i3c)(struct device *dev, bool enable);
128
129 struct skl_d0i3_data d0i3;
130
131 const struct skl_dsp_ops *dsp_ops;
132
133 /* Callback to update dynamic clock and power gating registers */
134 void (*clock_power_gating)(struct device *dev, bool enable);
99}; 135};
100 136
101#define skl_to_bus(s) (&(s)->hbus.core) 137#define skl_to_bus(s) (&(s)->hbus.core)
102#define bus_to_skl(bus) container_of(bus, struct skl, hbus.core) 138#define bus_to_skl(bus) container_of(bus, struct skl_dev, hbus.core)
103 139
104#define skl_to_hbus(s) (&(s)->hbus) 140#define skl_to_hbus(s) (&(s)->hbus)
105#define hbus_to_skl(hbus) container_of((hbus), struct skl, (hbus)) 141#define hbus_to_skl(hbus) container_of((hbus), struct skl_dev, (hbus))
106 142
107/* to pass dai dma data */ 143/* to pass dai dma data */
108struct skl_dma_params { 144struct skl_dma_params {
@@ -121,52 +157,49 @@ struct skl_dsp_ops {
121 int (*init)(struct device *dev, void __iomem *mmio_base, 157 int (*init)(struct device *dev, void __iomem *mmio_base,
122 int irq, const char *fw_name, 158 int irq, const char *fw_name,
123 struct skl_dsp_loader_ops loader_ops, 159 struct skl_dsp_loader_ops loader_ops,
124 struct skl_sst **skl_sst); 160 struct skl_dev **skl_sst);
125 int (*init_fw)(struct device *dev, struct skl_sst *ctx); 161 int (*init_fw)(struct device *dev, struct skl_dev *skl);
126 void (*cleanup)(struct device *dev, struct skl_sst *ctx); 162 void (*cleanup)(struct device *dev, struct skl_dev *skl);
127}; 163};
128 164
129int skl_platform_unregister(struct device *dev); 165int skl_platform_unregister(struct device *dev);
130int skl_platform_register(struct device *dev); 166int skl_platform_register(struct device *dev);
131 167
132struct nhlt_acpi_table *skl_nhlt_init(struct device *dev); 168struct nhlt_specific_cfg *skl_get_ep_blob(struct skl_dev *skl, u32 instance,
133void skl_nhlt_free(struct nhlt_acpi_table *addr);
134struct nhlt_specific_cfg *skl_get_ep_blob(struct skl *skl, u32 instance,
135 u8 link_type, u8 s_fmt, u8 no_ch, 169 u8 link_type, u8 s_fmt, u8 no_ch,
136 u32 s_rate, u8 dirn, u8 dev_type); 170 u32 s_rate, u8 dirn, u8 dev_type);
137 171
138int skl_get_dmic_geo(struct skl *skl); 172int skl_nhlt_update_topology_bin(struct skl_dev *skl);
139int skl_nhlt_update_topology_bin(struct skl *skl); 173int skl_init_dsp(struct skl_dev *skl);
140int skl_init_dsp(struct skl *skl); 174int skl_free_dsp(struct skl_dev *skl);
141int skl_free_dsp(struct skl *skl); 175int skl_suspend_late_dsp(struct skl_dev *skl);
142int skl_suspend_late_dsp(struct skl *skl); 176int skl_suspend_dsp(struct skl_dev *skl);
143int skl_suspend_dsp(struct skl *skl); 177int skl_resume_dsp(struct skl_dev *skl);
144int skl_resume_dsp(struct skl *skl); 178void skl_cleanup_resources(struct skl_dev *skl);
145void skl_cleanup_resources(struct skl *skl);
146const struct skl_dsp_ops *skl_get_dsp_ops(int pci_id); 179const struct skl_dsp_ops *skl_get_dsp_ops(int pci_id);
147void skl_update_d0i3c(struct device *dev, bool enable); 180void skl_update_d0i3c(struct device *dev, bool enable);
148int skl_nhlt_create_sysfs(struct skl *skl); 181int skl_nhlt_create_sysfs(struct skl_dev *skl);
149void skl_nhlt_remove_sysfs(struct skl *skl); 182void skl_nhlt_remove_sysfs(struct skl_dev *skl);
150void skl_get_clks(struct skl *skl, struct skl_ssp_clk *ssp_clks); 183void skl_get_clks(struct skl_dev *skl, struct skl_ssp_clk *ssp_clks);
151struct skl_clk_parent_src *skl_get_parent_clk(u8 clk_id); 184struct skl_clk_parent_src *skl_get_parent_clk(u8 clk_id);
152int skl_dsp_set_dma_control(struct skl_sst *ctx, u32 *caps, 185int skl_dsp_set_dma_control(struct skl_dev *skl, u32 *caps,
153 u32 caps_size, u32 node_id); 186 u32 caps_size, u32 node_id);
154 187
155struct skl_module_cfg; 188struct skl_module_cfg;
156 189
157#ifdef CONFIG_DEBUG_FS 190#ifdef CONFIG_DEBUG_FS
158struct skl_debug *skl_debugfs_init(struct skl *skl); 191struct skl_debug *skl_debugfs_init(struct skl_dev *skl);
159void skl_debugfs_exit(struct skl *skl); 192void skl_debugfs_exit(struct skl_dev *skl);
160void skl_debug_init_module(struct skl_debug *d, 193void skl_debug_init_module(struct skl_debug *d,
161 struct snd_soc_dapm_widget *w, 194 struct snd_soc_dapm_widget *w,
162 struct skl_module_cfg *mconfig); 195 struct skl_module_cfg *mconfig);
163#else 196#else
164static inline struct skl_debug *skl_debugfs_init(struct skl *skl) 197static inline struct skl_debug *skl_debugfs_init(struct skl_dev *skl)
165{ 198{
166 return NULL; 199 return NULL;
167} 200}
168 201
169static inline void skl_debugfs_exit(struct skl *skl) 202static inline void skl_debugfs_exit(struct skl_dev *skl)
170{} 203{}
171 204
172static inline void skl_debug_init_module(struct skl_debug *d, 205static inline void skl_debug_init_module(struct skl_debug *d,