1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) 2 // 3 // Copyright(c) 2020 Intel Corporation. All rights reserved. 4 // 5 // Authors: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> 6 // 7 8 /* 9 * Hardware interface for audio DSP on Tigerlake. 10 */ 11 12 #include <sound/sof/ext_manifest4.h> 13 #include "../ipc4-priv.h" 14 #include "../ops.h" 15 #include "hda.h" 16 #include "hda-ipc.h" 17 #include "../sof-audio.h" 18 19 static const struct snd_sof_debugfs_map tgl_dsp_debugfs[] = { 20 {"hda", HDA_DSP_HDA_BAR, 0, 0x4000, SOF_DEBUGFS_ACCESS_ALWAYS}, 21 {"pp", HDA_DSP_PP_BAR, 0, 0x1000, SOF_DEBUGFS_ACCESS_ALWAYS}, 22 {"dsp", HDA_DSP_BAR, 0, 0x10000, SOF_DEBUGFS_ACCESS_ALWAYS}, 23 }; 24 25 static int tgl_dsp_core_get(struct snd_sof_dev *sdev, int core) 26 { 27 const struct sof_ipc_pm_ops *pm_ops = sdev->ipc->ops->pm; 28 29 /* power up primary core if not already powered up and return */ 30 if (core == SOF_DSP_PRIMARY_CORE) 31 return hda_dsp_enable_core(sdev, BIT(core)); 32 33 if (pm_ops->set_core_state) 34 return pm_ops->set_core_state(sdev, core, true); 35 36 return 0; 37 } 38 39 static int tgl_dsp_core_put(struct snd_sof_dev *sdev, int core) 40 { 41 const struct sof_ipc_pm_ops *pm_ops = sdev->ipc->ops->pm; 42 43 /* power down primary core and return */ 44 if (core == SOF_DSP_PRIMARY_CORE) 45 return hda_dsp_core_reset_power_down(sdev, BIT(core)); 46 47 if (pm_ops->set_core_state) 48 return pm_ops->set_core_state(sdev, core, false); 49 50 return 0; 51 } 52 53 /* Tigerlake ops */ 54 struct snd_sof_dsp_ops sof_tgl_ops; 55 EXPORT_SYMBOL_NS(sof_tgl_ops, SND_SOC_SOF_INTEL_HDA_COMMON); 56 57 int sof_tgl_ops_init(struct snd_sof_dev *sdev) 58 { 59 /* common defaults */ 60 memcpy(&sof_tgl_ops, &sof_hda_common_ops, sizeof(struct snd_sof_dsp_ops)); 61 62 /* probe/remove/shutdown */ 63 sof_tgl_ops.shutdown = hda_dsp_shutdown_dma_flush; 64 65 if (sdev->pdata->ipc_type == SOF_IPC) { 66 /* doorbell */ 67 sof_tgl_ops.irq_thread = cnl_ipc_irq_thread; 68 69 /* ipc */ 70 sof_tgl_ops.send_msg = cnl_ipc_send_msg; 71 72 /* debug */ 73 sof_tgl_ops.ipc_dump = cnl_ipc_dump; 74 75 sof_tgl_ops.set_power_state = hda_dsp_set_power_state_ipc3; 76 } 77 78 if (sdev->pdata->ipc_type == SOF_INTEL_IPC4) { 79 struct sof_ipc4_fw_data *ipc4_data; 80 81 sdev->private = devm_kzalloc(sdev->dev, sizeof(*ipc4_data), GFP_KERNEL); 82 if (!sdev->private) 83 return -ENOMEM; 84 85 ipc4_data = sdev->private; 86 ipc4_data->manifest_fw_hdr_offset = SOF_MAN4_FW_HDR_OFFSET; 87 88 ipc4_data->mtrace_type = SOF_IPC4_MTRACE_INTEL_CAVS_2; 89 90 /* External library loading support */ 91 ipc4_data->load_library = hda_dsp_ipc4_load_library; 92 93 /* doorbell */ 94 sof_tgl_ops.irq_thread = cnl_ipc4_irq_thread; 95 96 /* ipc */ 97 sof_tgl_ops.send_msg = cnl_ipc4_send_msg; 98 99 /* debug */ 100 sof_tgl_ops.ipc_dump = cnl_ipc4_dump; 101 102 sof_tgl_ops.set_power_state = hda_dsp_set_power_state_ipc4; 103 } 104 105 /* set DAI driver ops */ 106 hda_set_dai_drv_ops(sdev, &sof_tgl_ops); 107 108 /* debug */ 109 sof_tgl_ops.debug_map = tgl_dsp_debugfs; 110 sof_tgl_ops.debug_map_count = ARRAY_SIZE(tgl_dsp_debugfs); 111 112 /* pre/post fw run */ 113 sof_tgl_ops.post_fw_run = hda_dsp_post_fw_run; 114 115 /* firmware run */ 116 sof_tgl_ops.run = hda_dsp_cl_boot_firmware_iccmax; 117 118 /* dsp core get/put */ 119 sof_tgl_ops.core_get = tgl_dsp_core_get; 120 sof_tgl_ops.core_put = tgl_dsp_core_put; 121 122 return 0; 123 }; 124 EXPORT_SYMBOL_NS(sof_tgl_ops_init, SND_SOC_SOF_INTEL_HDA_COMMON); 125 126 const struct sof_intel_dsp_desc tgl_chip_info = { 127 /* Tigerlake , Alderlake */ 128 .cores_num = 4, 129 .init_core_mask = 1, 130 .host_managed_cores_mask = BIT(0), 131 .ipc_req = CNL_DSP_REG_HIPCIDR, 132 .ipc_req_mask = CNL_DSP_REG_HIPCIDR_BUSY, 133 .ipc_ack = CNL_DSP_REG_HIPCIDA, 134 .ipc_ack_mask = CNL_DSP_REG_HIPCIDA_DONE, 135 .ipc_ctl = CNL_DSP_REG_HIPCCTL, 136 .rom_status_reg = HDA_DSP_SRAM_REG_ROM_STATUS, 137 .rom_init_timeout = 300, 138 .ssp_count = TGL_SSP_COUNT, 139 .ssp_base_offset = CNL_SSP_BASE_OFFSET, 140 .sdw_shim_base = SDW_SHIM_BASE, 141 .sdw_alh_base = SDW_ALH_BASE, 142 .d0i3_offset = SOF_HDA_VS_D0I3C, 143 .read_sdw_lcount = hda_sdw_check_lcount_common, 144 .enable_sdw_irq = hda_common_enable_sdw_irq, 145 .check_sdw_irq = hda_common_check_sdw_irq, 146 .check_ipc_irq = hda_dsp_check_ipc_irq, 147 .cl_init = cl_dsp_init, 148 .power_down_dsp = hda_power_down_dsp, 149 .disable_interrupts = hda_dsp_disable_interrupts, 150 .hw_ip_version = SOF_INTEL_CAVS_2_5, 151 }; 152 EXPORT_SYMBOL_NS(tgl_chip_info, SND_SOC_SOF_INTEL_HDA_COMMON); 153 154 const struct sof_intel_dsp_desc tglh_chip_info = { 155 /* Tigerlake-H */ 156 .cores_num = 2, 157 .init_core_mask = 1, 158 .host_managed_cores_mask = BIT(0), 159 .ipc_req = CNL_DSP_REG_HIPCIDR, 160 .ipc_req_mask = CNL_DSP_REG_HIPCIDR_BUSY, 161 .ipc_ack = CNL_DSP_REG_HIPCIDA, 162 .ipc_ack_mask = CNL_DSP_REG_HIPCIDA_DONE, 163 .ipc_ctl = CNL_DSP_REG_HIPCCTL, 164 .rom_status_reg = HDA_DSP_SRAM_REG_ROM_STATUS, 165 .rom_init_timeout = 300, 166 .ssp_count = TGL_SSP_COUNT, 167 .ssp_base_offset = CNL_SSP_BASE_OFFSET, 168 .sdw_shim_base = SDW_SHIM_BASE, 169 .sdw_alh_base = SDW_ALH_BASE, 170 .d0i3_offset = SOF_HDA_VS_D0I3C, 171 .read_sdw_lcount = hda_sdw_check_lcount_common, 172 .enable_sdw_irq = hda_common_enable_sdw_irq, 173 .check_sdw_irq = hda_common_check_sdw_irq, 174 .check_ipc_irq = hda_dsp_check_ipc_irq, 175 .cl_init = cl_dsp_init, 176 .power_down_dsp = hda_power_down_dsp, 177 .disable_interrupts = hda_dsp_disable_interrupts, 178 .hw_ip_version = SOF_INTEL_CAVS_2_5, 179 }; 180 EXPORT_SYMBOL_NS(tglh_chip_info, SND_SOC_SOF_INTEL_HDA_COMMON); 181 182 const struct sof_intel_dsp_desc ehl_chip_info = { 183 /* Elkhartlake */ 184 .cores_num = 4, 185 .init_core_mask = 1, 186 .host_managed_cores_mask = BIT(0), 187 .ipc_req = CNL_DSP_REG_HIPCIDR, 188 .ipc_req_mask = CNL_DSP_REG_HIPCIDR_BUSY, 189 .ipc_ack = CNL_DSP_REG_HIPCIDA, 190 .ipc_ack_mask = CNL_DSP_REG_HIPCIDA_DONE, 191 .ipc_ctl = CNL_DSP_REG_HIPCCTL, 192 .rom_status_reg = HDA_DSP_SRAM_REG_ROM_STATUS, 193 .rom_init_timeout = 300, 194 .ssp_count = TGL_SSP_COUNT, 195 .ssp_base_offset = CNL_SSP_BASE_OFFSET, 196 .sdw_shim_base = SDW_SHIM_BASE, 197 .sdw_alh_base = SDW_ALH_BASE, 198 .d0i3_offset = SOF_HDA_VS_D0I3C, 199 .read_sdw_lcount = hda_sdw_check_lcount_common, 200 .enable_sdw_irq = hda_common_enable_sdw_irq, 201 .check_sdw_irq = hda_common_check_sdw_irq, 202 .check_ipc_irq = hda_dsp_check_ipc_irq, 203 .cl_init = cl_dsp_init, 204 .power_down_dsp = hda_power_down_dsp, 205 .disable_interrupts = hda_dsp_disable_interrupts, 206 .hw_ip_version = SOF_INTEL_CAVS_2_5, 207 }; 208 EXPORT_SYMBOL_NS(ehl_chip_info, SND_SOC_SOF_INTEL_HDA_COMMON); 209 210 const struct sof_intel_dsp_desc adls_chip_info = { 211 /* Alderlake-S */ 212 .cores_num = 2, 213 .init_core_mask = BIT(0), 214 .host_managed_cores_mask = BIT(0), 215 .ipc_req = CNL_DSP_REG_HIPCIDR, 216 .ipc_req_mask = CNL_DSP_REG_HIPCIDR_BUSY, 217 .ipc_ack = CNL_DSP_REG_HIPCIDA, 218 .ipc_ack_mask = CNL_DSP_REG_HIPCIDA_DONE, 219 .ipc_ctl = CNL_DSP_REG_HIPCCTL, 220 .rom_status_reg = HDA_DSP_SRAM_REG_ROM_STATUS, 221 .rom_init_timeout = 300, 222 .ssp_count = TGL_SSP_COUNT, 223 .ssp_base_offset = CNL_SSP_BASE_OFFSET, 224 .sdw_shim_base = SDW_SHIM_BASE, 225 .sdw_alh_base = SDW_ALH_BASE, 226 .d0i3_offset = SOF_HDA_VS_D0I3C, 227 .read_sdw_lcount = hda_sdw_check_lcount_common, 228 .enable_sdw_irq = hda_common_enable_sdw_irq, 229 .check_sdw_irq = hda_common_check_sdw_irq, 230 .check_ipc_irq = hda_dsp_check_ipc_irq, 231 .cl_init = cl_dsp_init, 232 .power_down_dsp = hda_power_down_dsp, 233 .disable_interrupts = hda_dsp_disable_interrupts, 234 .hw_ip_version = SOF_INTEL_CAVS_2_5, 235 }; 236 EXPORT_SYMBOL_NS(adls_chip_info, SND_SOC_SOF_INTEL_HDA_COMMON); 237