Lines Matching refs:sdev
32 static void mtl_ipc_host_done(struct snd_sof_dev *sdev) in mtl_ipc_host_done() argument
38 snd_sof_dsp_update_bits_forced(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXTDR, in mtl_ipc_host_done()
43 snd_sof_dsp_update_bits_forced(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXTDA, in mtl_ipc_host_done()
47 static void mtl_ipc_dsp_done(struct snd_sof_dev *sdev) in mtl_ipc_dsp_done() argument
53 snd_sof_dsp_update_bits_forced(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXIDA, in mtl_ipc_dsp_done()
57 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXCTL, in mtl_ipc_dsp_done()
62 bool mtl_dsp_check_ipc_irq(struct snd_sof_dev *sdev) in mtl_dsp_check_ipc_irq() argument
67 if (sdev->dspless_mode_selected) in mtl_dsp_check_ipc_irq()
71 hfintipptr = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_HFINTIPPTR) & MTL_HFINTIPPTR_PTR_MASK; in mtl_dsp_check_ipc_irq()
72 irq_status = snd_sof_dsp_read(sdev, HDA_DSP_BAR, hfintipptr + MTL_DSP_IRQSTS); in mtl_dsp_check_ipc_irq()
74 trace_sof_intel_hda_irq_ipc_check(sdev, irq_status); in mtl_dsp_check_ipc_irq()
84 static bool mtl_dsp_check_sdw_irq(struct snd_sof_dev *sdev) in mtl_dsp_check_sdw_irq() argument
90 hfintipptr = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_HFINTIPPTR) & MTL_HFINTIPPTR_PTR_MASK; in mtl_dsp_check_sdw_irq()
91 irq_status = snd_sof_dsp_read(sdev, HDA_DSP_BAR, hfintipptr + MTL_DSP_IRQSTS); in mtl_dsp_check_sdw_irq()
99 static int mtl_ipc_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg) in mtl_ipc_send_msg() argument
101 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in mtl_ipc_send_msg()
104 if (hda_ipc4_tx_is_busy(sdev)) { in mtl_ipc_send_msg()
113 sof_mailbox_write(sdev, sdev->host_box.offset, msg_data->data_ptr, in mtl_ipc_send_msg()
116 snd_sof_dsp_write(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXIDDY, in mtl_ipc_send_msg()
118 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 static 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()
301 static int mtl_dsp_post_fw_run(struct snd_sof_dev *sdev) in mtl_dsp_post_fw_run() argument
305 if (sdev->first_boot) { in mtl_dsp_post_fw_run()
306 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in mtl_dsp_post_fw_run()
308 ret = hda_sdw_startup(sdev); in mtl_dsp_post_fw_run()
310 dev_err(sdev->dev, "could not startup SoundWire links\n"); in mtl_dsp_post_fw_run()
318 0644, sdev->debugfs_root, in mtl_dsp_post_fw_run()
323 hda_sdw_int_enable(sdev, true); in mtl_dsp_post_fw_run()
327 static void mtl_dsp_dump(struct snd_sof_dev *sdev, u32 flags) in mtl_dsp_dump() argument
333 hda_dsp_get_state(sdev, level); in mtl_dsp_dump()
334 fwsts = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_ROM_STS); in mtl_dsp_dump()
335 fwlec = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_ROM_ERROR); in mtl_dsp_dump()
338 dev_err(sdev->dev, "Firmware state: %#x, status/error code: %#x\n", in mtl_dsp_dump()
341 sof_ipc4_intel_dump_telemetry_state(sdev, flags); in mtl_dsp_dump()
344 static bool mtl_dsp_primary_core_is_enabled(struct snd_sof_dev *sdev) in mtl_dsp_primary_core_is_enabled() argument
348 val = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP2CXCTL_PRIMARY_CORE); in mtl_dsp_primary_core_is_enabled()
355 static int mtl_dsp_core_power_up(struct snd_sof_dev *sdev, int core) in mtl_dsp_core_power_up() argument
362 if (core != SOF_DSP_PRIMARY_CORE || mtl_dsp_primary_core_is_enabled(sdev)) in mtl_dsp_core_power_up()
366 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_DSP2CXCTL_PRIMARY_CORE, in mtl_dsp_core_power_up()
371 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_DSP2CXCTL_PRIMARY_CORE, in mtl_dsp_core_power_up()
380 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, MTL_DSP2CXCTL_PRIMARY_CORE, dspcxctl, in mtl_dsp_core_power_up()
384 dev_err(sdev->dev, "%s: timeout on MTL_DSP2CXCTL_PRIMARY_CORE read\n", in mtl_dsp_core_power_up()
390 sdev->enabled_cores_mask = BIT(SOF_DSP_PRIMARY_CORE); in mtl_dsp_core_power_up()
391 sdev->dsp_core_ref_count[SOF_DSP_PRIMARY_CORE] = 1; in mtl_dsp_core_power_up()
396 static int mtl_dsp_core_power_down(struct snd_sof_dev *sdev, int core) in mtl_dsp_core_power_down() argument
402 if (core != SOF_DSP_PRIMARY_CORE || !mtl_dsp_primary_core_is_enabled(sdev)) in mtl_dsp_core_power_down()
406 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_DSP2CXCTL_PRIMARY_CORE, in mtl_dsp_core_power_down()
412 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, MTL_DSP2CXCTL_PRIMARY_CORE, dspcxctl, in mtl_dsp_core_power_down()
417 dev_err(sdev->dev, "failed to power down primary core\n"); in mtl_dsp_core_power_down()
421 sdev->enabled_cores_mask = 0; in mtl_dsp_core_power_down()
422 sdev->dsp_core_ref_count[SOF_DSP_PRIMARY_CORE] = 0; in mtl_dsp_core_power_down()
427 int mtl_power_down_dsp(struct snd_sof_dev *sdev) in mtl_power_down_dsp() argument
433 ret = mtl_dsp_core_power_down(sdev, SOF_DSP_PRIMARY_CORE); in mtl_power_down_dsp()
435 dev_err(sdev->dev, "mtl dsp power down error, %d\n", ret); in mtl_power_down_dsp()
440 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_HFDSSCS, in mtl_power_down_dsp()
448 dsphfdsscs = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_HFDSSCS); in mtl_power_down_dsp()
449 return snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, MTL_HFDSSCS, dsphfdsscs, in mtl_power_down_dsp()
455 int mtl_dsp_cl_init(struct snd_sof_dev *sdev, int stream_tag, bool imr_boot) in mtl_dsp_cl_init() argument
457 struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; in mtl_dsp_cl_init()
469 snd_sof_dsp_write(sdev, HDA_DSP_BAR, chip->ipc_req, ipc_hdr); in mtl_dsp_cl_init()
472 ret = mtl_dsp_core_power_up(sdev, SOF_DSP_PRIMARY_CORE); in mtl_dsp_cl_init()
475 dev_err(sdev->dev, "dsp core 0/1 power up failed\n"); in mtl_dsp_cl_init()
479 dev_dbg(sdev->dev, "Primary core power up successful\n"); in mtl_dsp_cl_init()
482 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, chip->ipc_ack, status, in mtl_dsp_cl_init()
487 dev_err(sdev->dev, "timeout waiting for purge IPC done\n"); in mtl_dsp_cl_init()
492 snd_sof_dsp_update_bits_forced(sdev, HDA_DSP_BAR, chip->ipc_ack, chip->ipc_ack_mask, in mtl_dsp_cl_init()
496 ret = mtl_enable_interrupts(sdev, true); in mtl_dsp_cl_init()
499 dev_err(sdev->dev, "%s: failed to enable interrupts\n", __func__); in mtl_dsp_cl_init()
503 mtl_enable_ipc_interrupts(sdev); in mtl_dsp_cl_init()
525 ret = snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, in mtl_dsp_cl_init()
536 dev_err(sdev->dev, in mtl_dsp_cl_init()
549 snd_sof_dsp_dbg_dump(sdev, dump_msg, flags); in mtl_dsp_cl_init()
550 mtl_enable_interrupts(sdev, false); in mtl_dsp_cl_init()
551 mtl_dsp_core_power_down(sdev, SOF_DSP_PRIMARY_CORE); in mtl_dsp_cl_init()
561 struct snd_sof_dev *sdev = context; in mtl_ipc_irq_thread() local
567 hipcida = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXIDA); in mtl_ipc_irq_thread()
568 hipctdr = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXTDR); in mtl_ipc_irq_thread()
573 snd_sof_dsp_update_bits(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXCTL, in mtl_ipc_irq_thread()
576 mtl_ipc_dsp_done(sdev); in mtl_ipc_irq_thread()
584 u32 extension = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXTDDY); in mtl_ipc_irq_thread()
593 if (likely(sdev->fw_state == SOF_FW_BOOT_COMPLETE)) { in mtl_ipc_irq_thread()
594 struct sof_ipc4_msg *data = sdev->ipc->msg.reply_data; in mtl_ipc_irq_thread()
599 spin_lock_irq(&sdev->ipc_lock); in mtl_ipc_irq_thread()
601 snd_sof_ipc_get_reply(sdev); in mtl_ipc_irq_thread()
602 mtl_ipc_host_done(sdev); in mtl_ipc_irq_thread()
603 snd_sof_ipc_reply(sdev, data->primary); in mtl_ipc_irq_thread()
605 spin_unlock_irq(&sdev->ipc_lock); in mtl_ipc_irq_thread()
607 dev_dbg_ratelimited(sdev->dev, in mtl_ipc_irq_thread()
616 sdev->ipc->msg.rx_data = ¬ification_data; in mtl_ipc_irq_thread()
617 snd_sof_ipc_msgs_rx(sdev); in mtl_ipc_irq_thread()
618 sdev->ipc->msg.rx_data = NULL; in mtl_ipc_irq_thread()
620 mtl_ipc_host_done(sdev); in mtl_ipc_irq_thread()
628 dev_dbg_ratelimited(sdev->dev, "nothing to do in IPC IRQ thread\n"); in mtl_ipc_irq_thread()
632 struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; in mtl_ipc_irq_thread()
635 mtl_ipc_send_msg(sdev, hdev->delayed_ipc_tx_msg); in mtl_ipc_irq_thread()
641 static int mtl_dsp_ipc_get_mailbox_offset(struct snd_sof_dev *sdev) in mtl_dsp_ipc_get_mailbox_offset() argument
646 static int mtl_dsp_ipc_get_window_offset(struct snd_sof_dev *sdev, u32 id) in mtl_dsp_ipc_get_window_offset() argument
651 static void mtl_ipc_dump(struct snd_sof_dev *sdev) in mtl_ipc_dump() argument
655 hipcidr = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXIDR); in mtl_ipc_dump()
656 hipcidd = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXIDDY); in mtl_ipc_dump()
657 hipcida = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXIDA); in mtl_ipc_dump()
658 hipctdr = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXTDR); in mtl_ipc_dump()
659 hipctdd = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXTDDY); in mtl_ipc_dump()
660 hipctda = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXTDA); in mtl_ipc_dump()
661 hipcctl = snd_sof_dsp_read(sdev, HDA_DSP_BAR, MTL_DSP_REG_HFIPCXCTL); in mtl_ipc_dump()
663 dev_err(sdev->dev, in mtl_ipc_dump()
668 static int mtl_dsp_disable_interrupts(struct snd_sof_dev *sdev) in mtl_dsp_disable_interrupts() argument
670 mtl_enable_sdw_irq(sdev, false); in mtl_dsp_disable_interrupts()
671 mtl_disable_ipc_interrupts(sdev); in mtl_dsp_disable_interrupts()
672 return mtl_enable_interrupts(sdev, false); in mtl_dsp_disable_interrupts()
675 static int mtl_dsp_core_get(struct snd_sof_dev *sdev, int core) in mtl_dsp_core_get() argument
677 const struct sof_ipc_pm_ops *pm_ops = sdev->ipc->ops->pm; in mtl_dsp_core_get()
680 return mtl_dsp_core_power_up(sdev, SOF_DSP_PRIMARY_CORE); in mtl_dsp_core_get()
683 return pm_ops->set_core_state(sdev, core, true); in mtl_dsp_core_get()
688 static int mtl_dsp_core_put(struct snd_sof_dev *sdev, int core) in mtl_dsp_core_put() argument
690 const struct sof_ipc_pm_ops *pm_ops = sdev->ipc->ops->pm; in mtl_dsp_core_put()
694 ret = pm_ops->set_core_state(sdev, core, false); in mtl_dsp_core_put()
700 return mtl_dsp_core_power_down(sdev, SOF_DSP_PRIMARY_CORE); in mtl_dsp_core_put()
705 int sof_mtl_set_ops(struct snd_sof_dev *sdev, struct snd_sof_dsp_ops *dsp_ops) in sof_mtl_set_ops() argument
740 sdev->private = kzalloc(sizeof(struct sof_ipc4_fw_data), GFP_KERNEL); in sof_mtl_set_ops()
741 if (!sdev->private) in sof_mtl_set_ops()
744 ipc4_data = sdev->private; in sof_mtl_set_ops()
757 hda_set_dai_drv_ops(sdev, dsp_ops); in sof_mtl_set_ops()