18b98491aSRanjani Sridharan // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) 28b98491aSRanjani Sridharan // 38b98491aSRanjani Sridharan // Copyright(c) 2020 Intel Corporation. All rights reserved. 48b98491aSRanjani Sridharan // 58b98491aSRanjani Sridharan // Authors: Ranjani Sridharan <ranjani.sridharan@linux.intel.com> 68b98491aSRanjani Sridharan // 78b98491aSRanjani Sridharan 88b98491aSRanjani Sridharan /* 98b98491aSRanjani Sridharan * Hardware interface for audio DSP on Tigerlake. 108b98491aSRanjani Sridharan */ 118b98491aSRanjani Sridharan 128b98491aSRanjani Sridharan #include "../ops.h" 138b98491aSRanjani Sridharan #include "hda.h" 148b98491aSRanjani Sridharan #include "hda-ipc.h" 158b98491aSRanjani Sridharan #include "../sof-audio.h" 168b98491aSRanjani Sridharan 178b98491aSRanjani Sridharan static const struct snd_sof_debugfs_map tgl_dsp_debugfs[] = { 188b98491aSRanjani Sridharan {"hda", HDA_DSP_HDA_BAR, 0, 0x4000, SOF_DEBUGFS_ACCESS_ALWAYS}, 198b98491aSRanjani Sridharan {"pp", HDA_DSP_PP_BAR, 0, 0x1000, SOF_DEBUGFS_ACCESS_ALWAYS}, 208b98491aSRanjani Sridharan {"dsp", HDA_DSP_BAR, 0, 0x10000, SOF_DEBUGFS_ACCESS_ALWAYS}, 218b98491aSRanjani Sridharan }; 228b98491aSRanjani Sridharan 2341dd63ccSRanjani Sridharan static int tgl_dsp_core_get(struct snd_sof_dev *sdev, int core) 2441dd63ccSRanjani Sridharan { 2541dd63ccSRanjani Sridharan struct sof_ipc_pm_core_config pm_core_config = { 2641dd63ccSRanjani Sridharan .hdr = { 2741dd63ccSRanjani Sridharan .cmd = SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_CORE_ENABLE, 2841dd63ccSRanjani Sridharan .size = sizeof(pm_core_config), 2941dd63ccSRanjani Sridharan }, 3041dd63ccSRanjani Sridharan .enable_mask = sdev->enabled_cores_mask | BIT(core), 3141dd63ccSRanjani Sridharan }; 3241dd63ccSRanjani Sridharan 3341dd63ccSRanjani Sridharan /* power up primary core if not already powered up and return */ 3441dd63ccSRanjani Sridharan if (core == SOF_DSP_PRIMARY_CORE) 3541dd63ccSRanjani Sridharan return hda_dsp_enable_core(sdev, BIT(core)); 3641dd63ccSRanjani Sridharan 3741dd63ccSRanjani Sridharan /* notify DSP for secondary cores */ 3841dd63ccSRanjani Sridharan return sof_ipc_tx_message(sdev->ipc, pm_core_config.hdr.cmd, 3941dd63ccSRanjani Sridharan &pm_core_config, sizeof(pm_core_config), 4041dd63ccSRanjani Sridharan &pm_core_config, sizeof(pm_core_config)); 4141dd63ccSRanjani Sridharan } 4241dd63ccSRanjani Sridharan 4341dd63ccSRanjani Sridharan static int tgl_dsp_core_put(struct snd_sof_dev *sdev, int core) 4441dd63ccSRanjani Sridharan { 4541dd63ccSRanjani Sridharan struct sof_ipc_pm_core_config pm_core_config = { 4641dd63ccSRanjani Sridharan .hdr = { 4741dd63ccSRanjani Sridharan .cmd = SOF_IPC_GLB_PM_MSG | SOF_IPC_PM_CORE_ENABLE, 4841dd63ccSRanjani Sridharan .size = sizeof(pm_core_config), 4941dd63ccSRanjani Sridharan }, 5041dd63ccSRanjani Sridharan .enable_mask = sdev->enabled_cores_mask & ~BIT(core), 5141dd63ccSRanjani Sridharan }; 5241dd63ccSRanjani Sridharan 5341dd63ccSRanjani Sridharan /* power down primary core and return */ 5441dd63ccSRanjani Sridharan if (core == SOF_DSP_PRIMARY_CORE) 5541dd63ccSRanjani Sridharan return hda_dsp_core_reset_power_down(sdev, BIT(core)); 5641dd63ccSRanjani Sridharan 5741dd63ccSRanjani Sridharan /* notify DSP for secondary cores */ 5841dd63ccSRanjani Sridharan return sof_ipc_tx_message(sdev->ipc, pm_core_config.hdr.cmd, 5941dd63ccSRanjani Sridharan &pm_core_config, sizeof(pm_core_config), 6041dd63ccSRanjani Sridharan &pm_core_config, sizeof(pm_core_config)); 6141dd63ccSRanjani Sridharan } 6241dd63ccSRanjani Sridharan 638b98491aSRanjani Sridharan /* Tigerlake ops */ 648b98491aSRanjani Sridharan const struct snd_sof_dsp_ops sof_tgl_ops = { 6544a4cfadSKeyon Jie /* probe/remove/shutdown */ 668b98491aSRanjani Sridharan .probe = hda_dsp_probe, 678b98491aSRanjani Sridharan .remove = hda_dsp_remove, 6822aa9e02SLibin Yang .shutdown = hda_dsp_shutdown, 698b98491aSRanjani Sridharan 708b98491aSRanjani Sridharan /* Register IO */ 718b98491aSRanjani Sridharan .write = sof_io_write, 728b98491aSRanjani Sridharan .read = sof_io_read, 738b98491aSRanjani Sridharan .write64 = sof_io_write64, 748b98491aSRanjani Sridharan .read64 = sof_io_read64, 758b98491aSRanjani Sridharan 768b98491aSRanjani Sridharan /* Block IO */ 778b98491aSRanjani Sridharan .block_read = sof_block_read, 788b98491aSRanjani Sridharan .block_write = sof_block_write, 798b98491aSRanjani Sridharan 80f71f59ddSDaniel Baluta /* Mailbox IO */ 81f71f59ddSDaniel Baluta .mailbox_read = sof_mailbox_read, 82f71f59ddSDaniel Baluta .mailbox_write = sof_mailbox_write, 83f71f59ddSDaniel Baluta 848b98491aSRanjani Sridharan /* doorbell */ 858b98491aSRanjani Sridharan .irq_thread = cnl_ipc_irq_thread, 868b98491aSRanjani Sridharan 878b98491aSRanjani Sridharan /* ipc */ 888b98491aSRanjani Sridharan .send_msg = cnl_ipc_send_msg, 898b98491aSRanjani Sridharan .fw_ready = sof_fw_ready, 908b98491aSRanjani Sridharan .get_mailbox_offset = hda_dsp_ipc_get_mailbox_offset, 918b98491aSRanjani Sridharan .get_window_offset = hda_dsp_ipc_get_window_offset, 928b98491aSRanjani Sridharan 938b98491aSRanjani Sridharan .ipc_msg_data = hda_ipc_msg_data, 948b98491aSRanjani Sridharan .ipc_pcm_params = hda_ipc_pcm_params, 958b98491aSRanjani Sridharan 968b98491aSRanjani Sridharan /* machine driver */ 978b98491aSRanjani Sridharan .machine_select = hda_machine_select, 988b98491aSRanjani Sridharan .machine_register = sof_machine_register, 998b98491aSRanjani Sridharan .machine_unregister = sof_machine_unregister, 1008b98491aSRanjani Sridharan .set_mach_params = hda_set_mach_params, 1018b98491aSRanjani Sridharan 1028b98491aSRanjani Sridharan /* debug */ 1038b98491aSRanjani Sridharan .debug_map = tgl_dsp_debugfs, 1048b98491aSRanjani Sridharan .debug_map_count = ARRAY_SIZE(tgl_dsp_debugfs), 1058b98491aSRanjani Sridharan .dbg_dump = hda_dsp_dump, 1068b98491aSRanjani Sridharan .ipc_dump = cnl_ipc_dump, 107fe509b34SPeter Ujfalusi .debugfs_add_region_item = snd_sof_debugfs_add_region_item_iomem, 1088b98491aSRanjani Sridharan 1098b98491aSRanjani Sridharan /* stream callbacks */ 1108b98491aSRanjani Sridharan .pcm_open = hda_dsp_pcm_open, 1118b98491aSRanjani Sridharan .pcm_close = hda_dsp_pcm_close, 1128b98491aSRanjani Sridharan .pcm_hw_params = hda_dsp_pcm_hw_params, 1138b98491aSRanjani Sridharan .pcm_hw_free = hda_dsp_stream_hw_free, 1148b98491aSRanjani Sridharan .pcm_trigger = hda_dsp_pcm_trigger, 1158b98491aSRanjani Sridharan .pcm_pointer = hda_dsp_pcm_pointer, 116*6c26b505SRanjani Sridharan .pcm_ack = hda_dsp_pcm_ack, 1178b98491aSRanjani Sridharan 1188b98491aSRanjani Sridharan #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_PROBES) 1198b98491aSRanjani Sridharan /* probe callbacks */ 1208b98491aSRanjani Sridharan .probe_assign = hda_probe_compr_assign, 1218b98491aSRanjani Sridharan .probe_free = hda_probe_compr_free, 1228b98491aSRanjani Sridharan .probe_set_params = hda_probe_compr_set_params, 1238b98491aSRanjani Sridharan .probe_trigger = hda_probe_compr_trigger, 1248b98491aSRanjani Sridharan .probe_pointer = hda_probe_compr_pointer, 1258b98491aSRanjani Sridharan #endif 1268b98491aSRanjani Sridharan 1278b98491aSRanjani Sridharan /* firmware loading */ 1288b98491aSRanjani Sridharan .load_firmware = snd_sof_load_firmware_raw, 1298b98491aSRanjani Sridharan 1308b98491aSRanjani Sridharan /* pre/post fw run */ 1318b98491aSRanjani Sridharan .pre_fw_run = hda_dsp_pre_fw_run, 1328b98491aSRanjani Sridharan .post_fw_run = hda_dsp_post_fw_run, 1338b98491aSRanjani Sridharan 134edbaaadaSFred Oh /* parse platform specific extended manifest */ 135edbaaadaSFred Oh .parse_platform_ext_manifest = hda_dsp_ext_man_get_cavs_config_data, 136edbaaadaSFred Oh 1379ea80748SRanjani Sridharan /* dsp core get/put */ 13841dd63ccSRanjani Sridharan .core_get = tgl_dsp_core_get, 13941dd63ccSRanjani Sridharan .core_put = tgl_dsp_core_put, 1408b98491aSRanjani Sridharan 1418b98491aSRanjani Sridharan /* firmware run */ 1428b98491aSRanjani Sridharan .run = hda_dsp_cl_boot_firmware_iccmax, 1438b98491aSRanjani Sridharan 1448b98491aSRanjani Sridharan /* trace callback */ 1458b98491aSRanjani Sridharan .trace_init = hda_dsp_trace_init, 1468b98491aSRanjani Sridharan .trace_release = hda_dsp_trace_release, 1478b98491aSRanjani Sridharan .trace_trigger = hda_dsp_trace_trigger, 1488b98491aSRanjani Sridharan 1498b98491aSRanjani Sridharan /* DAI drivers */ 1508b98491aSRanjani Sridharan .drv = skl_dai, 1518b98491aSRanjani Sridharan .num_drv = SOF_SKL_NUM_DAIS, 1528b98491aSRanjani Sridharan 1538b98491aSRanjani Sridharan /* PM */ 1548b98491aSRanjani Sridharan .suspend = hda_dsp_suspend, 1558b98491aSRanjani Sridharan .resume = hda_dsp_resume, 1568b98491aSRanjani Sridharan .runtime_suspend = hda_dsp_runtime_suspend, 1578b98491aSRanjani Sridharan .runtime_resume = hda_dsp_runtime_resume, 1588b98491aSRanjani Sridharan .runtime_idle = hda_dsp_runtime_idle, 1598b98491aSRanjani Sridharan .set_hw_params_upon_resume = hda_dsp_set_hw_params_upon_resume, 1608b98491aSRanjani Sridharan .set_power_state = hda_dsp_set_power_state, 1618b98491aSRanjani Sridharan 1628b98491aSRanjani Sridharan /* ALSA HW info flags */ 1638b98491aSRanjani Sridharan .hw_info = SNDRV_PCM_INFO_MMAP | 1648b98491aSRanjani Sridharan SNDRV_PCM_INFO_MMAP_VALID | 1658b98491aSRanjani Sridharan SNDRV_PCM_INFO_INTERLEAVED | 1668b98491aSRanjani Sridharan SNDRV_PCM_INFO_PAUSE | 1678b98491aSRanjani Sridharan SNDRV_PCM_INFO_NO_PERIOD_WAKEUP, 1688b98491aSRanjani Sridharan 1690ed66cb7SPeter Ujfalusi .dsp_arch_ops = &sof_xtensa_arch_ops, 1708b98491aSRanjani Sridharan }; 1718b98491aSRanjani Sridharan EXPORT_SYMBOL_NS(sof_tgl_ops, SND_SOC_SOF_INTEL_HDA_COMMON); 1728b98491aSRanjani Sridharan 1738b98491aSRanjani Sridharan const struct sof_intel_dsp_desc tgl_chip_info = { 1744ad03f89SSathya Prakash M R /* Tigerlake , Alderlake */ 1758b98491aSRanjani Sridharan .cores_num = 4, 1768b98491aSRanjani Sridharan .init_core_mask = 1, 177fde10655SRanjani Sridharan .host_managed_cores_mask = BIT(0), 1788b98491aSRanjani Sridharan .ipc_req = CNL_DSP_REG_HIPCIDR, 1798b98491aSRanjani Sridharan .ipc_req_mask = CNL_DSP_REG_HIPCIDR_BUSY, 1808b98491aSRanjani Sridharan .ipc_ack = CNL_DSP_REG_HIPCIDA, 1818b98491aSRanjani Sridharan .ipc_ack_mask = CNL_DSP_REG_HIPCIDA_DONE, 1828b98491aSRanjani Sridharan .ipc_ctl = CNL_DSP_REG_HIPCCTL, 1838b98491aSRanjani Sridharan .rom_init_timeout = 300, 1848b98491aSRanjani Sridharan .ssp_count = ICL_SSP_COUNT, 1858b98491aSRanjani Sridharan .ssp_base_offset = CNL_SSP_BASE_OFFSET, 1861cbf6443SBard Liao .sdw_shim_base = SDW_SHIM_BASE, 1871cbf6443SBard Liao .sdw_alh_base = SDW_ALH_BASE, 188198fa4bcSBard Liao .check_sdw_irq = hda_common_check_sdw_irq, 1898b98491aSRanjani Sridharan }; 1908b98491aSRanjani Sridharan EXPORT_SYMBOL_NS(tgl_chip_info, SND_SOC_SOF_INTEL_HDA_COMMON); 19130ee3738SRander Wang 19230ee3738SRander Wang const struct sof_intel_dsp_desc tglh_chip_info = { 19330ee3738SRander Wang /* Tigerlake-H */ 19430ee3738SRander Wang .cores_num = 2, 19530ee3738SRander Wang .init_core_mask = 1, 19630ee3738SRander Wang .host_managed_cores_mask = BIT(0), 19730ee3738SRander Wang .ipc_req = CNL_DSP_REG_HIPCIDR, 19830ee3738SRander Wang .ipc_req_mask = CNL_DSP_REG_HIPCIDR_BUSY, 19930ee3738SRander Wang .ipc_ack = CNL_DSP_REG_HIPCIDA, 20030ee3738SRander Wang .ipc_ack_mask = CNL_DSP_REG_HIPCIDA_DONE, 20130ee3738SRander Wang .ipc_ctl = CNL_DSP_REG_HIPCCTL, 20230ee3738SRander Wang .rom_init_timeout = 300, 20330ee3738SRander Wang .ssp_count = ICL_SSP_COUNT, 20430ee3738SRander Wang .ssp_base_offset = CNL_SSP_BASE_OFFSET, 2051cbf6443SBard Liao .sdw_shim_base = SDW_SHIM_BASE, 2061cbf6443SBard Liao .sdw_alh_base = SDW_ALH_BASE, 207198fa4bcSBard Liao .check_sdw_irq = hda_common_check_sdw_irq, 20830ee3738SRander Wang }; 20930ee3738SRander Wang EXPORT_SYMBOL_NS(tglh_chip_info, SND_SOC_SOF_INTEL_HDA_COMMON); 2106c2b6bb0SKai Vehmanen 2118bb84ca8SPierre-Louis Bossart const struct sof_intel_dsp_desc ehl_chip_info = { 2128bb84ca8SPierre-Louis Bossart /* Elkhartlake */ 2138bb84ca8SPierre-Louis Bossart .cores_num = 4, 2148bb84ca8SPierre-Louis Bossart .init_core_mask = 1, 2158bb84ca8SPierre-Louis Bossart .host_managed_cores_mask = BIT(0), 2168bb84ca8SPierre-Louis Bossart .ipc_req = CNL_DSP_REG_HIPCIDR, 2178bb84ca8SPierre-Louis Bossart .ipc_req_mask = CNL_DSP_REG_HIPCIDR_BUSY, 2188bb84ca8SPierre-Louis Bossart .ipc_ack = CNL_DSP_REG_HIPCIDA, 2198bb84ca8SPierre-Louis Bossart .ipc_ack_mask = CNL_DSP_REG_HIPCIDA_DONE, 2208bb84ca8SPierre-Louis Bossart .ipc_ctl = CNL_DSP_REG_HIPCCTL, 2218bb84ca8SPierre-Louis Bossart .rom_init_timeout = 300, 2228bb84ca8SPierre-Louis Bossart .ssp_count = ICL_SSP_COUNT, 2238bb84ca8SPierre-Louis Bossart .ssp_base_offset = CNL_SSP_BASE_OFFSET, 2241cbf6443SBard Liao .sdw_shim_base = SDW_SHIM_BASE, 2251cbf6443SBard Liao .sdw_alh_base = SDW_ALH_BASE, 226198fa4bcSBard Liao .check_sdw_irq = hda_common_check_sdw_irq, 2278bb84ca8SPierre-Louis Bossart }; 2288bb84ca8SPierre-Louis Bossart EXPORT_SYMBOL_NS(ehl_chip_info, SND_SOC_SOF_INTEL_HDA_COMMON); 2298bb84ca8SPierre-Louis Bossart 2306c2b6bb0SKai Vehmanen const struct sof_intel_dsp_desc adls_chip_info = { 2316c2b6bb0SKai Vehmanen /* Alderlake-S */ 2326c2b6bb0SKai Vehmanen .cores_num = 2, 2336c2b6bb0SKai Vehmanen .init_core_mask = BIT(0), 2346c2b6bb0SKai Vehmanen .host_managed_cores_mask = BIT(0), 2356c2b6bb0SKai Vehmanen .ipc_req = CNL_DSP_REG_HIPCIDR, 2366c2b6bb0SKai Vehmanen .ipc_req_mask = CNL_DSP_REG_HIPCIDR_BUSY, 2376c2b6bb0SKai Vehmanen .ipc_ack = CNL_DSP_REG_HIPCIDA, 2386c2b6bb0SKai Vehmanen .ipc_ack_mask = CNL_DSP_REG_HIPCIDA_DONE, 2396c2b6bb0SKai Vehmanen .ipc_ctl = CNL_DSP_REG_HIPCCTL, 2406c2b6bb0SKai Vehmanen .rom_init_timeout = 300, 2416c2b6bb0SKai Vehmanen .ssp_count = ICL_SSP_COUNT, 2426c2b6bb0SKai Vehmanen .ssp_base_offset = CNL_SSP_BASE_OFFSET, 2431cbf6443SBard Liao .sdw_shim_base = SDW_SHIM_BASE, 2441cbf6443SBard Liao .sdw_alh_base = SDW_ALH_BASE, 245198fa4bcSBard Liao .check_sdw_irq = hda_common_check_sdw_irq, 2466c2b6bb0SKai Vehmanen }; 2476c2b6bb0SKai Vehmanen EXPORT_SYMBOL_NS(adls_chip_info, SND_SOC_SOF_INTEL_HDA_COMMON); 248