1 // SPDX-License-Identifier: GPL-2.0-only 2 // 3 // Copyright(c) 2021-2024 Intel Corporation 4 // 5 // Authors: Cezary Rojewski <cezary.rojewski@intel.com> 6 // Amadeusz Slawinski <amadeuszx.slawinski@linux.intel.com> 7 // 8 9 #include <linux/pci.h> 10 #include "avs.h" 11 #include "messages.h" 12 13 #define CPUID_TSC_LEAF 0x15 14 15 static int avs_tgl_dsp_core_power(struct avs_dev *adev, u32 core_mask, bool power) 16 { 17 core_mask &= AVS_MAIN_CORE_MASK; 18 19 if (!core_mask) 20 return 0; 21 return avs_dsp_core_power(adev, core_mask, power); 22 } 23 24 static int avs_tgl_dsp_core_reset(struct avs_dev *adev, u32 core_mask, bool reset) 25 { 26 core_mask &= AVS_MAIN_CORE_MASK; 27 28 if (!core_mask) 29 return 0; 30 return avs_dsp_core_reset(adev, core_mask, reset); 31 } 32 33 static int avs_tgl_dsp_core_stall(struct avs_dev *adev, u32 core_mask, bool stall) 34 { 35 core_mask &= AVS_MAIN_CORE_MASK; 36 37 if (!core_mask) 38 return 0; 39 return avs_dsp_core_stall(adev, core_mask, stall); 40 } 41 42 static int avs_tgl_config_basefw(struct avs_dev *adev) 43 { 44 struct pci_dev *pci = adev->base.pci; 45 struct avs_bus_hwid hwid; 46 int ret; 47 #ifdef CONFIG_X86 48 unsigned int ecx; 49 50 #include <asm/cpuid.h> 51 ecx = cpuid_ecx(CPUID_TSC_LEAF); 52 if (ecx) { 53 ret = avs_ipc_set_fw_config(adev, 1, AVS_FW_CFG_XTAL_FREQ_HZ, sizeof(ecx), &ecx); 54 if (ret) 55 return AVS_IPC_RET(ret); 56 } 57 #endif 58 59 hwid.device = pci->device; 60 hwid.subsystem = pci->subsystem_vendor | (pci->subsystem_device << 16); 61 hwid.revision = pci->revision; 62 63 ret = avs_ipc_set_fw_config(adev, 1, AVS_FW_CFG_BUS_HARDWARE_ID, sizeof(hwid), &hwid); 64 if (ret) 65 return AVS_IPC_RET(ret); 66 67 return 0; 68 } 69 70 const struct avs_dsp_ops avs_tgl_dsp_ops = { 71 .power = avs_tgl_dsp_core_power, 72 .reset = avs_tgl_dsp_core_reset, 73 .stall = avs_tgl_dsp_core_stall, 74 .dsp_interrupt = avs_cnl_dsp_interrupt, 75 .int_control = avs_dsp_interrupt_control, 76 .load_basefw = avs_icl_load_basefw, 77 .load_lib = avs_hda_load_library, 78 .transfer_mods = avs_hda_transfer_modules, 79 .config_basefw = avs_tgl_config_basefw, 80 .log_buffer_offset = avs_icl_log_buffer_offset, 81 .log_buffer_status = avs_apl_log_buffer_status, 82 .coredump = avs_apl_coredump, 83 .d0ix_toggle = avs_icl_d0ix_toggle, 84 .set_d0ix = avs_icl_set_d0ix, 85 AVS_SET_ENABLE_LOGS_OP(icl) 86 }; 87