Lines Matching refs:sdev
31 static void mtl_ipc_host_done(struct snd_sof_dev *sdev) in mtl_ipc_host_done() argument
37 snd_sof_dsp_update_bits_forced(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXTDR, in mtl_ipc_host_done()
42 snd_sof_dsp_update_bits_forced(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXTDA, in mtl_ipc_host_done()
46 static void mtl_ipc_dsp_done(struct snd_sof_dev *sdev) in mtl_ipc_dsp_done() argument
52 snd_sof_dsp_update_bits_forced(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXIDA, in mtl_ipc_dsp_done()
56 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXCTL, in mtl_ipc_dsp_done()
61 bool mtl_dsp_check_ipc_irq(struct snd_sof_dev *sdev) in mtl_dsp_check_ipc_irq() argument
66 if (sdev->dspless_mode_selected) in mtl_dsp_check_ipc_irq()
70 hfintipptr = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_HFINTIPPTR) & MTL_HFINTIPPTR_PTR_MASK; in mtl_dsp_check_ipc_irq()
71 irq_status = snd_sof_dsp_read(sdev, HDA_DSP_BAR, hfintipptr + MTL_DSP_IRQSTS); in mtl_dsp_check_ipc_irq()
73 trace_sof_intel_hda_irq_ipc_check(sdev, irq_status); in mtl_dsp_check_ipc_irq()
83 static bool mtl_dsp_check_sdw_irq(struct snd_sof_dev *sdev) in mtl_dsp_check_sdw_irq() argument
89 hfintipptr = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_HFINTIPPTR) & MTL_HFINTIPPTR_PTR_MASK; in mtl_dsp_check_sdw_irq()
90 irq_status = snd_sof_dsp_read(sdev, HDA_DSP_BAR, hfintipptr + MTL_DSP_IRQSTS); in mtl_dsp_check_sdw_irq()
98 int mtl_ipc_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg) in mtl_ipc_send_msg() argument
100 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in mtl_ipc_send_msg()
103 if (hda_ipc4_tx_is_busy(sdev)) { in mtl_ipc_send_msg()
112 sof_mailbox_write(sdev, sdev->host_box.offset, msg_data->data_ptr, in mtl_ipc_send_msg()
115 snd_sof_dsp_write(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXIDDY, in mtl_ipc_send_msg()
117 snd_sof_dsp_write(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXIDR, in mtl_ipc_send_msg()
126 void mtl_enable_ipc_interrupts(struct snd_sof_dev *sdev) in mtl_enable_ipc_interrupts() argument
128 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in mtl_enable_ipc_interrupts()
131 if (sdev->dspless_mode_selected) in mtl_enable_ipc_interrupts()
135 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, chip->ipc_ctl, in mtl_enable_ipc_interrupts()
140 void mtl_disable_ipc_interrupts(struct snd_sof_dev *sdev) in mtl_disable_ipc_interrupts() argument
142 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in mtl_disable_ipc_interrupts()
145 if (sdev->dspless_mode_selected) in mtl_disable_ipc_interrupts()
149 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, chip->ipc_ctl, in mtl_disable_ipc_interrupts()
154 static void mtl_enable_sdw_irq(struct snd_sof_dev *sdev, bool enable) in mtl_enable_sdw_irq() argument
161 if (sdev->dspless_mode_selected) in mtl_enable_sdw_irq()
171 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_DSP_REG_HfSNDWIE, mask, val); in mtl_enable_sdw_irq()
174 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, MTL_DSP_REG_HfSNDWIE, hipcie, in mtl_enable_sdw_irq()
178 dev_err(sdev->dev, "failed to set SoundWire IPC interrupt %s\n", in mtl_enable_sdw_irq()
182 int mtl_enable_interrupts(struct snd_sof_dev *sdev, bool enable) in mtl_enable_interrupts() argument
191 if (sdev->dspless_mode_selected) in mtl_enable_interrupts()
195 hfintipptr = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_HFINTIPPTR) & MTL_HFINTIPPTR_PTR_MASK; in mtl_enable_interrupts()
204 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, hfintipptr, mask, val); in mtl_enable_interrupts()
207 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, hfintipptr, irqinten, in mtl_enable_interrupts()
211 dev_err(sdev->dev, "failed to %s Host IPC and/or SOUNDWIRE\n", in mtl_enable_interrupts()
223 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_DSP_REG_HfHIPCIE, mask, val); in mtl_enable_interrupts()
226 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, MTL_DSP_REG_HfHIPCIE, hipcie, in mtl_enable_interrupts()
230 dev_err(sdev->dev, "failed to set Host IPC interrupt %s\n", in mtl_enable_interrupts()
240 int mtl_dsp_pre_fw_run(struct snd_sof_dev *sdev) in mtl_dsp_pre_fw_run() argument
242 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in mtl_dsp_pre_fw_run()
252 chip = get_chip_info(sdev->pdata); in mtl_dsp_pre_fw_run()
262 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_HFDSSCS, in mtl_dsp_pre_fw_run()
270 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, MTL_HFDSSCS, dsphfdsscs, in mtl_dsp_pre_fw_run()
274 dev_err(sdev->dev, "failed to enable DSP subsystem\n"); in mtl_dsp_pre_fw_run()
279 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, dsppwrctl, in mtl_dsp_pre_fw_run()
286 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, dsppwrsts, dsphfpwrsts, in mtl_dsp_pre_fw_run()
291 dev_err(sdev->dev, "failed to power up gated DSP domain\n"); in mtl_dsp_pre_fw_run()
295 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_HFPWRCTL, in mtl_dsp_pre_fw_run()
302 int mtl_dsp_post_fw_run(struct snd_sof_dev *sdev) in mtl_dsp_post_fw_run() argument
306 if (sdev->first_boot) { in mtl_dsp_post_fw_run()
307 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in mtl_dsp_post_fw_run()
309 ret = hda_sdw_startup(sdev); in mtl_dsp_post_fw_run()
311 dev_err(sdev->dev, "could not startup SoundWire links\n"); in mtl_dsp_post_fw_run()
319 0644, sdev->debugfs_root, in mtl_dsp_post_fw_run()
324 hda_sdw_int_enable(sdev, true); in mtl_dsp_post_fw_run()
329 void mtl_dsp_dump(struct snd_sof_dev *sdev, u32 flags) in mtl_dsp_dump() argument
335 hda_dsp_get_state(sdev, level); in mtl_dsp_dump()
336 fwsts = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_ROM_STS); in mtl_dsp_dump()
337 fwlec = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_ROM_ERROR); in mtl_dsp_dump()
340 dev_err(sdev->dev, "Firmware state: %#x, status/error code: %#x\n", in mtl_dsp_dump()
343 sof_ipc4_intel_dump_telemetry_state(sdev, flags); in mtl_dsp_dump()
347 static bool mtl_dsp_primary_core_is_enabled(struct snd_sof_dev *sdev) in mtl_dsp_primary_core_is_enabled() argument
351 val = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP2CXCTL_PRIMARY_CORE); in mtl_dsp_primary_core_is_enabled()
358 static int mtl_dsp_core_power_up(struct snd_sof_dev *sdev, int core) in mtl_dsp_core_power_up() argument
365 if (core != SOF_DSP_PRIMARY_CORE || mtl_dsp_primary_core_is_enabled(sdev)) in mtl_dsp_core_power_up()
369 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_DSP2CXCTL_PRIMARY_CORE, in mtl_dsp_core_power_up()
374 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_DSP2CXCTL_PRIMARY_CORE, in mtl_dsp_core_power_up()
383 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, MTL_DSP2CXCTL_PRIMARY_CORE, dspcxctl, in mtl_dsp_core_power_up()
387 dev_err(sdev->dev, "%s: timeout on MTL_DSP2CXCTL_PRIMARY_CORE read\n", in mtl_dsp_core_power_up()
393 sdev->enabled_cores_mask = BIT(SOF_DSP_PRIMARY_CORE); in mtl_dsp_core_power_up()
394 sdev->dsp_core_ref_count[SOF_DSP_PRIMARY_CORE] = 1; in mtl_dsp_core_power_up()
399 static int mtl_dsp_core_power_down(struct snd_sof_dev *sdev, int core) in mtl_dsp_core_power_down() argument
405 if (core != SOF_DSP_PRIMARY_CORE || !mtl_dsp_primary_core_is_enabled(sdev)) in mtl_dsp_core_power_down()
409 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_DSP2CXCTL_PRIMARY_CORE, in mtl_dsp_core_power_down()
415 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, MTL_DSP2CXCTL_PRIMARY_CORE, dspcxctl, in mtl_dsp_core_power_down()
420 dev_err(sdev->dev, "failed to power down primary core\n"); in mtl_dsp_core_power_down()
424 sdev->enabled_cores_mask = 0; in mtl_dsp_core_power_down()
425 sdev->dsp_core_ref_count[SOF_DSP_PRIMARY_CORE] = 0; in mtl_dsp_core_power_down()
430 int mtl_power_down_dsp(struct snd_sof_dev *sdev) in mtl_power_down_dsp() argument
436 ret = mtl_dsp_core_power_down(sdev, SOF_DSP_PRIMARY_CORE); in mtl_power_down_dsp()
438 dev_err(sdev->dev, "mtl dsp power down error, %d\n", ret); in mtl_power_down_dsp()
443 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_HFDSSCS, in mtl_power_down_dsp()
451 dsphfdsscs = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_HFDSSCS); in mtl_power_down_dsp()
452 return snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, MTL_HFDSSCS, dsphfdsscs, in mtl_power_down_dsp()
458 int mtl_dsp_cl_init(struct snd_sof_dev *sdev, int stream_tag, bool imr_boot) in mtl_dsp_cl_init() argument
460 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in mtl_dsp_cl_init()
472 snd_sof_dsp_write(sdev, HDA_DSP_BAR, chip->ipc_req, ipc_hdr); in mtl_dsp_cl_init()
475 ret = mtl_dsp_core_power_up(sdev, SOF_DSP_PRIMARY_CORE); in mtl_dsp_cl_init()
478 dev_err(sdev->dev, "dsp core 0/1 power up failed\n"); in mtl_dsp_cl_init()
482 dev_dbg(sdev->dev, "Primary core power up successful\n"); in mtl_dsp_cl_init()
485 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, chip->ipc_ack, status, in mtl_dsp_cl_init()
490 dev_err(sdev->dev, "timeout waiting for purge IPC done\n"); in mtl_dsp_cl_init()
495 snd_sof_dsp_update_bits_forced(sdev, HDA_DSP_BAR, chip->ipc_ack, chip->ipc_ack_mask, in mtl_dsp_cl_init()
499 ret = mtl_enable_interrupts(sdev, true); in mtl_dsp_cl_init()
502 dev_err(sdev->dev, "%s: failed to enable interrupts\n", __func__); in mtl_dsp_cl_init()
506 mtl_enable_ipc_interrupts(sdev); in mtl_dsp_cl_init()
528 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in mtl_dsp_cl_init()
539 dev_err(sdev->dev, in mtl_dsp_cl_init()
552 snd_sof_dsp_dbg_dump(sdev, dump_msg, flags); in mtl_dsp_cl_init()
553 mtl_enable_interrupts(sdev, false); in mtl_dsp_cl_init()
554 mtl_dsp_core_power_down(sdev, SOF_DSP_PRIMARY_CORE); in mtl_dsp_cl_init()
564 struct snd_sof_dev *sdev = context; in mtl_ipc_irq_thread() local
570 hipcida = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXIDA); in mtl_ipc_irq_thread()
571 hipctdr = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXTDR); in mtl_ipc_irq_thread()
576 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXCTL, in mtl_ipc_irq_thread()
579 mtl_ipc_dsp_done(sdev); in mtl_ipc_irq_thread()
587 u32 extension = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXTDDY); in mtl_ipc_irq_thread()
596 if (likely(sdev->fw_state == SOF_FW_BOOT_COMPLETE)) { in mtl_ipc_irq_thread()
597 struct sof_ipc4_msg *data = sdev->ipc->msg.reply_data; in mtl_ipc_irq_thread()
602 spin_lock_irq(&sdev->ipc_lock); in mtl_ipc_irq_thread()
604 snd_sof_ipc_get_reply(sdev); in mtl_ipc_irq_thread()
605 mtl_ipc_host_done(sdev); in mtl_ipc_irq_thread()
606 snd_sof_ipc_reply(sdev, data->primary); in mtl_ipc_irq_thread()
608 spin_unlock_irq(&sdev->ipc_lock); in mtl_ipc_irq_thread()
610 dev_dbg_ratelimited(sdev->dev, in mtl_ipc_irq_thread()
619 sdev->ipc->msg.rx_data = ¬ification_data; in mtl_ipc_irq_thread()
620 snd_sof_ipc_msgs_rx(sdev); in mtl_ipc_irq_thread()
621 sdev->ipc->msg.rx_data = NULL; in mtl_ipc_irq_thread()
623 mtl_ipc_host_done(sdev); in mtl_ipc_irq_thread()
631 dev_dbg_ratelimited(sdev->dev, "nothing to do in IPC IRQ thread\n"); in mtl_ipc_irq_thread()
635 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in mtl_ipc_irq_thread()
638 mtl_ipc_send_msg(sdev, hdev->delayed_ipc_tx_msg); in mtl_ipc_irq_thread()
645 int mtl_dsp_ipc_get_mailbox_offset(struct snd_sof_dev *sdev) in mtl_dsp_ipc_get_mailbox_offset() argument
651 int mtl_dsp_ipc_get_window_offset(struct snd_sof_dev *sdev, u32 id) in mtl_dsp_ipc_get_window_offset() argument
657 void mtl_ipc_dump(struct snd_sof_dev *sdev) in mtl_ipc_dump() argument
661 hipcidr = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXIDR); in mtl_ipc_dump()
662 hipcidd = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXIDDY); in mtl_ipc_dump()
663 hipcida = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXIDA); in mtl_ipc_dump()
664 hipctdr = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXTDR); in mtl_ipc_dump()
665 hipctdd = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXTDDY); in mtl_ipc_dump()
666 hipctda = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXTDA); in mtl_ipc_dump()
667 hipcctl = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXCTL); in mtl_ipc_dump()
669 dev_err(sdev->dev, in mtl_ipc_dump()
675 static int mtl_dsp_disable_interrupts(struct snd_sof_dev *sdev) in mtl_dsp_disable_interrupts() argument
677 mtl_enable_sdw_irq(sdev, false); in mtl_dsp_disable_interrupts()
678 mtl_disable_ipc_interrupts(sdev); in mtl_dsp_disable_interrupts()
679 return mtl_enable_interrupts(sdev, false); in mtl_dsp_disable_interrupts()
682 int mtl_dsp_core_get(struct snd_sof_dev *sdev, int core) in mtl_dsp_core_get() argument
684 const struct sof_ipc_pm_ops *pm_ops = sdev->ipc->ops->pm; in mtl_dsp_core_get()
687 return mtl_dsp_core_power_up(sdev, SOF_DSP_PRIMARY_CORE); in mtl_dsp_core_get()
690 return pm_ops->set_core_state(sdev, core, true); in mtl_dsp_core_get()
696 int mtl_dsp_core_put(struct snd_sof_dev *sdev, int core) in mtl_dsp_core_put() argument
698 const struct sof_ipc_pm_ops *pm_ops = sdev->ipc->ops->pm; in mtl_dsp_core_put()
702 ret = pm_ops->set_core_state(sdev, core, false); in mtl_dsp_core_put()
708 return mtl_dsp_core_power_down(sdev, SOF_DSP_PRIMARY_CORE); in mtl_dsp_core_put()
717 int sof_mtl_ops_init(struct snd_sof_dev *sdev) in sof_mtl_ops_init() argument
752 sdev->private = kzalloc(sizeof(struct sof_ipc4_fw_data), GFP_KERNEL); in sof_mtl_ops_init()
753 if (!sdev->private) in sof_mtl_ops_init()
756 ipc4_data = sdev->private; in sof_mtl_ops_init()
767 hda_set_dai_drv_ops(sdev, &sof_mtl_ops); in sof_mtl_ops_init()