162306a36Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license. When using or 462306a36Sopenharmony_ci * redistributing this file, you may do so under either license. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Copyright(c) 2020-2022 Intel Corporation. All rights reserved. 762306a36Sopenharmony_ci */ 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci/* HDA Registers */ 1062306a36Sopenharmony_ci#define MTL_PPLCLLPL_BASE 0x948 1162306a36Sopenharmony_ci#define MTL_PPLCLLPU_STRIDE 0x10 1262306a36Sopenharmony_ci#define MTL_PPLCLLPL(x) (MTL_PPLCLLPL_BASE + (x) * MTL_PPLCLLPU_STRIDE) 1362306a36Sopenharmony_ci#define MTL_PPLCLLPU(x) (MTL_PPLCLLPL_BASE + 0x4 + (x) * MTL_PPLCLLPU_STRIDE) 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_ci/* DSP Registers */ 1662306a36Sopenharmony_ci#define MTL_HFDSSCS 0x1000 1762306a36Sopenharmony_ci#define MTL_HFDSSCS_SPA_MASK BIT(16) 1862306a36Sopenharmony_ci#define MTL_HFDSSCS_CPA_MASK BIT(24) 1962306a36Sopenharmony_ci#define MTL_HFSNDWIE 0x114C 2062306a36Sopenharmony_ci#define MTL_HFPWRCTL 0x1D18 2162306a36Sopenharmony_ci#define MTL_HfPWRCTL_WPIOXPG(x) BIT((x) + 8) 2262306a36Sopenharmony_ci#define MTL_HFPWRCTL_WPDSPHPXPG BIT(0) 2362306a36Sopenharmony_ci#define MTL_HFPWRSTS 0x1D1C 2462306a36Sopenharmony_ci#define MTL_HFPWRSTS_DSPHPXPGS_MASK BIT(0) 2562306a36Sopenharmony_ci#define MTL_HFINTIPPTR 0x1108 2662306a36Sopenharmony_ci#define MTL_IRQ_INTEN_L_HOST_IPC_MASK BIT(0) 2762306a36Sopenharmony_ci#define MTL_IRQ_INTEN_L_SOUNDWIRE_MASK BIT(6) 2862306a36Sopenharmony_ci#define MTL_HFINTIPPTR_PTR_MASK GENMASK(20, 0) 2962306a36Sopenharmony_ci 3062306a36Sopenharmony_ci#define MTL_HDA_VS_D0I3C 0x1D4A 3162306a36Sopenharmony_ci 3262306a36Sopenharmony_ci#define MTL_DSP2CXCAP_PRIMARY_CORE 0x178D00 3362306a36Sopenharmony_ci#define MTL_DSP2CXCTL_PRIMARY_CORE 0x178D04 3462306a36Sopenharmony_ci#define MTL_DSP2CXCTL_PRIMARY_CORE_SPA_MASK BIT(0) 3562306a36Sopenharmony_ci#define MTL_DSP2CXCTL_PRIMARY_CORE_CPA_MASK BIT(8) 3662306a36Sopenharmony_ci#define MTL_DSP2CXCTL_PRIMARY_CORE_OSEL GENMASK(25, 24) 3762306a36Sopenharmony_ci#define MTL_DSP2CXCTL_PRIMARY_CORE_OSEL_SHIFT 24 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci/* IPC Registers */ 4062306a36Sopenharmony_ci#define MTL_DSP_REG_HFIPCXTDR 0x73200 4162306a36Sopenharmony_ci#define MTL_DSP_REG_HFIPCXTDR_BUSY BIT(31) 4262306a36Sopenharmony_ci#define MTL_DSP_REG_HFIPCXTDR_MSG_MASK GENMASK(30, 0) 4362306a36Sopenharmony_ci#define MTL_DSP_REG_HFIPCXTDA 0x73204 4462306a36Sopenharmony_ci#define MTL_DSP_REG_HFIPCXTDA_BUSY BIT(31) 4562306a36Sopenharmony_ci#define MTL_DSP_REG_HFIPCXIDR 0x73210 4662306a36Sopenharmony_ci#define MTL_DSP_REG_HFIPCXIDR_BUSY BIT(31) 4762306a36Sopenharmony_ci#define MTL_DSP_REG_HFIPCXIDR_MSG_MASK GENMASK(30, 0) 4862306a36Sopenharmony_ci#define MTL_DSP_REG_HFIPCXIDA 0x73214 4962306a36Sopenharmony_ci#define MTL_DSP_REG_HFIPCXIDA_DONE BIT(31) 5062306a36Sopenharmony_ci#define MTL_DSP_REG_HFIPCXIDA_MSG_MASK GENMASK(30, 0) 5162306a36Sopenharmony_ci#define MTL_DSP_REG_HFIPCXCTL 0x73228 5262306a36Sopenharmony_ci#define MTL_DSP_REG_HFIPCXCTL_BUSY BIT(0) 5362306a36Sopenharmony_ci#define MTL_DSP_REG_HFIPCXCTL_DONE BIT(1) 5462306a36Sopenharmony_ci#define MTL_DSP_REG_HFIPCXTDDY 0x73300 5562306a36Sopenharmony_ci#define MTL_DSP_REG_HFIPCXIDDY 0x73380 5662306a36Sopenharmony_ci#define MTL_DSP_REG_HfHIPCIE 0x1140 5762306a36Sopenharmony_ci#define MTL_DSP_REG_HfHIPCIE_IE_MASK BIT(0) 5862306a36Sopenharmony_ci#define MTL_DSP_REG_HfSNDWIE 0x114C 5962306a36Sopenharmony_ci#define MTL_DSP_REG_HfSNDWIE_IE_MASK GENMASK(3, 0) 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci#define MTL_DSP_IRQSTS 0x20 6262306a36Sopenharmony_ci#define MTL_DSP_IRQSTS_IPC BIT(0) 6362306a36Sopenharmony_ci#define MTL_DSP_IRQSTS_SDW BIT(6) 6462306a36Sopenharmony_ci 6562306a36Sopenharmony_ci#define MTL_DSP_REG_POLL_INTERVAL_US 10 /* 10 us */ 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci/* Memory windows */ 6862306a36Sopenharmony_ci#define MTL_SRAM_WINDOW_OFFSET(x) (0x180000 + 0x8000 * (x)) 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci#define MTL_DSP_MBOX_UPLINK_OFFSET (MTL_SRAM_WINDOW_OFFSET(0) + 0x1000) 7162306a36Sopenharmony_ci#define MTL_DSP_MBOX_UPLINK_SIZE 0x1000 7262306a36Sopenharmony_ci#define MTL_DSP_MBOX_DOWNLINK_OFFSET MTL_SRAM_WINDOW_OFFSET(1) 7362306a36Sopenharmony_ci#define MTL_DSP_MBOX_DOWNLINK_SIZE 0x1000 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci/* FW registers */ 7662306a36Sopenharmony_ci#define MTL_DSP_ROM_STS MTL_SRAM_WINDOW_OFFSET(0) /* ROM status */ 7762306a36Sopenharmony_ci#define MTL_DSP_ROM_ERROR (MTL_SRAM_WINDOW_OFFSET(0) + 0x4) /* ROM error code */ 7862306a36Sopenharmony_ci 7962306a36Sopenharmony_ci#define MTL_DSP_REG_HFFLGPXQWY 0x163200 /* ROM debug status */ 8062306a36Sopenharmony_ci#define MTL_DSP_REG_HFFLGPXQWY_ERROR 0x163204 /* ROM debug error code */ 8162306a36Sopenharmony_ci#define MTL_DSP_REG_HfIMRIS1 0x162088 8262306a36Sopenharmony_ci#define MTL_DSP_REG_HfIMRIS1_IU_MASK BIT(0) 8362306a36Sopenharmony_ci 8462306a36Sopenharmony_cibool mtl_dsp_check_ipc_irq(struct snd_sof_dev *sdev); 8562306a36Sopenharmony_ciint mtl_ipc_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg); 8662306a36Sopenharmony_ci 8762306a36Sopenharmony_civoid mtl_enable_ipc_interrupts(struct snd_sof_dev *sdev); 8862306a36Sopenharmony_civoid mtl_disable_ipc_interrupts(struct snd_sof_dev *sdev); 8962306a36Sopenharmony_ci 9062306a36Sopenharmony_ciint mtl_enable_interrupts(struct snd_sof_dev *sdev, bool enable); 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ciint mtl_dsp_pre_fw_run(struct snd_sof_dev *sdev); 9362306a36Sopenharmony_ciint mtl_dsp_post_fw_run(struct snd_sof_dev *sdev); 9462306a36Sopenharmony_civoid mtl_dsp_dump(struct snd_sof_dev *sdev, u32 flags); 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ciint mtl_power_down_dsp(struct snd_sof_dev *sdev); 9762306a36Sopenharmony_ciint mtl_dsp_cl_init(struct snd_sof_dev *sdev, int stream_tag, bool imr_boot); 9862306a36Sopenharmony_ci 9962306a36Sopenharmony_ciirqreturn_t mtl_ipc_irq_thread(int irq, void *context); 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ciint mtl_dsp_ipc_get_mailbox_offset(struct snd_sof_dev *sdev); 10262306a36Sopenharmony_ciint mtl_dsp_ipc_get_window_offset(struct snd_sof_dev *sdev, u32 id); 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_civoid mtl_ipc_dump(struct snd_sof_dev *sdev); 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_ciu64 mtl_dsp_get_stream_hda_link_position(struct snd_sof_dev *sdev, 10762306a36Sopenharmony_ci struct snd_soc_component *component, 10862306a36Sopenharmony_ci struct snd_pcm_substream *substream); 109