Debian Codegraph @

sound/soc/intel/avs/tgl.c

raw
1 // SPDX-License-Identifier: GPL-2.0-only
2 //
3 // Copyright(c) 2021-2024 Intel Corporation
4 //
5 // Authors: Cezary Rojewski <[email protected]>
6 // Amadeusz Slawinski <[email protected]>
7 //
8
9 #include <linux/pci.h>
10 #include <asm/cpuid/api.h>
11 #include "avs.h"
12 #include "debug.h"
13 #include "messages.h"
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 /*
43 * Succeed if CPUID(0x15) is not available, or if the nominal core crystal clock
44 * frequency cannot be enumerated from it. There is nothing to do in both cases.
45 */
46 static int avs_tgl_set_xtal_freq(struct avs_dev *adev)
47 {
48 unsigned int freq;
49 int ret;
50
51 if (boot_cpu_data.cpuid_level < CPUID_LEAF_TSC)
52 return 0;
53
54 freq = cpuid_ecx(CPUID_LEAF_TSC);
55 if (freq) {
56 ret = avs_ipc_set_fw_config(adev, 1, AVS_FW_CFG_XTAL_FREQ_HZ, sizeof(freq), &freq);
57 if (ret)
58 return AVS_IPC_RET(ret);
59 }
60
61 return 0;
62 }
63
64 static int avs_tgl_config_basefw(struct avs_dev *adev)
65 {
66 struct pci_dev *pci = adev->base.pci;
67 struct avs_bus_hwid hwid;
68 int ret;
69
70 ret = avs_tgl_set_xtal_freq(adev);
71 if (ret)
72 return ret;
73
74 hwid.device = pci->device;
75 hwid.subsystem = pci->subsystem_vendor | (pci->subsystem_device << 16);
76 hwid.revision = pci->revision;
77
78 ret = avs_ipc_set_fw_config(adev, 1, AVS_FW_CFG_BUS_HARDWARE_ID, sizeof(hwid), &hwid);
79 if (ret)
80 return AVS_IPC_RET(ret);
81
82 return 0;
83 }
84
85 const struct avs_dsp_ops avs_tgl_dsp_ops = {
86 .power = avs_tgl_dsp_core_power,
87 .reset = avs_tgl_dsp_core_reset,
88 .stall = avs_tgl_dsp_core_stall,
89 .dsp_interrupt = avs_cnl_dsp_interrupt,
90 .int_control = avs_dsp_interrupt_control,
91 .load_basefw = avs_icl_load_basefw,
92 .load_lib = avs_hda_load_library,
93 .transfer_mods = avs_hda_transfer_modules,
94 .config_basefw = avs_tgl_config_basefw,
95 .log_buffer_offset = avs_icl_log_buffer_offset,
96 .log_buffer_status = avs_apl_log_buffer_status,
97 .coredump = avs_apl_coredump,
98 .d0ix_toggle = avs_icl_d0ix_toggle,
99 .set_d0ix = avs_icl_set_d0ix,
100 AVS_SET_ENABLE_LOGS_OP(icl)
101 };