1 // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) 2 // 3 // This file is provided under a dual BSD/GPLv2 license. When using or 4 // redistributing this file, you may do so under either license. 5 // 6 // Copyright(c) 2021 Advanced Micro Devices, Inc. 7 // 8 // Authors: Ajit Kumar Pandey <AjitKumar.Pandey@amd.com> 9 // 10 11 /* ACP machine configuration module */ 12 13 #include <linux/acpi.h> 14 #include <linux/bits.h> 15 #include <linux/dmi.h> 16 #include <linux/module.h> 17 #include <linux/pci.h> 18 19 #include "../sof/amd/acp.h" 20 #include "mach-config.h" 21 22 static int acp_quirk_data; 23 24 static const struct config_entry config_table[] = { 25 { 26 .flags = FLAG_AMD_SOF, 27 .device = ACP_PCI_DEV_ID, 28 .dmi_table = (const struct dmi_system_id []) { 29 { 30 .matches = { 31 DMI_MATCH(DMI_SYS_VENDOR, "AMD"), 32 DMI_MATCH(DMI_PRODUCT_NAME, "Majolica-CZN"), 33 }, 34 }, 35 {} 36 }, 37 }, 38 { 39 .flags = FLAG_AMD_SOF, 40 .device = ACP_PCI_DEV_ID, 41 .dmi_table = (const struct dmi_system_id []) { 42 { 43 .matches = { 44 DMI_MATCH(DMI_SYS_VENDOR, "Google"), 45 }, 46 }, 47 {} 48 }, 49 }, 50 { 51 .flags = FLAG_AMD_SOF, 52 .device = ACP_PCI_DEV_ID, 53 .dmi_table = (const struct dmi_system_id []) { 54 { 55 .matches = { 56 DMI_MATCH(DMI_SYS_VENDOR, "Valve"), 57 DMI_MATCH(DMI_PRODUCT_NAME, "Galileo"), 58 DMI_MATCH(DMI_PRODUCT_FAMILY, "Sephiroth"), 59 }, 60 }, 61 {} 62 }, 63 }, 64 { 65 .flags = FLAG_AMD_LEGACY, 66 .device = ACP_PCI_DEV_ID, 67 .dmi_table = (const struct dmi_system_id []) { 68 { 69 .matches = { 70 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"), 71 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "KLVL-WXXW"), 72 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1010"), 73 }, 74 }, 75 {} 76 }, 77 }, 78 { 79 .flags = FLAG_AMD_LEGACY, 80 .device = ACP_PCI_DEV_ID, 81 .dmi_table = (const struct dmi_system_id []) { 82 { 83 .matches = { 84 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"), 85 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "KLVL-WXX9"), 86 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1010"), 87 }, 88 }, 89 {} 90 }, 91 }, 92 { 93 .flags = FLAG_AMD_LEGACY, 94 .device = ACP_PCI_DEV_ID, 95 .dmi_table = (const struct dmi_system_id []) { 96 { 97 .matches = { 98 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"), 99 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "BOM-WXX9"), 100 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1010"), 101 }, 102 }, 103 {} 104 }, 105 }, 106 { 107 .flags = FLAG_AMD_LEGACY, 108 .device = ACP_PCI_DEV_ID, 109 .dmi_table = (const struct dmi_system_id []) { 110 { 111 .matches = { 112 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"), 113 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HVY-WXX9"), 114 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1020"), 115 }, 116 }, 117 {} 118 }, 119 }, 120 { 121 .flags = FLAG_AMD_LEGACY, 122 .device = ACP_PCI_DEV_ID, 123 .dmi_table = (const struct dmi_system_id []) { 124 { 125 .matches = { 126 DMI_EXACT_MATCH(DMI_BOARD_VENDOR, "HUAWEI"), 127 DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "HVY-WXX9"), 128 DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "M1040"), 129 }, 130 }, 131 {} 132 }, 133 }, 134 }; 135 136 int snd_amd_acp_find_config(struct pci_dev *pci) 137 { 138 const struct config_entry *table = config_table; 139 u16 device = pci->device; 140 int i; 141 142 /* Do not enable FLAGS on older platforms with Rev id zero */ 143 if (!pci->revision) 144 return 0; 145 146 for (i = 0; i < ARRAY_SIZE(config_table); i++, table++) { 147 if (table->device != device) 148 continue; 149 if (table->dmi_table && !dmi_check_system(table->dmi_table)) 150 continue; 151 acp_quirk_data = table->flags; 152 return table->flags; 153 } 154 155 return 0; 156 } 157 EXPORT_SYMBOL(snd_amd_acp_find_config); 158 159 static struct snd_soc_acpi_codecs amp_rt1019 = { 160 .num_codecs = 1, 161 .codecs = {"10EC1019"} 162 }; 163 164 static struct snd_soc_acpi_codecs amp_max = { 165 .num_codecs = 1, 166 .codecs = {"MX98360A"} 167 }; 168 169 static struct snd_soc_acpi_codecs amp_max98388 = { 170 .num_codecs = 1, 171 .codecs = {"ADS8388"} 172 }; 173 174 struct snd_soc_acpi_mach snd_soc_acpi_amd_sof_machines[] = { 175 { 176 .id = "10EC5682", 177 .drv_name = "rt5682-rt1019", 178 .pdata = (void *)&acp_quirk_data, 179 .machine_quirk = snd_soc_acpi_codec_list, 180 .quirk_data = &_rt1019, 181 .fw_filename = "sof-rn.ri", 182 .sof_tplg_filename = "sof-rn-rt5682-rt1019.tplg", 183 }, 184 { 185 .id = "10EC5682", 186 .drv_name = "rt5682-max", 187 .pdata = (void *)&acp_quirk_data, 188 .machine_quirk = snd_soc_acpi_codec_list, 189 .quirk_data = &_max, 190 .fw_filename = "sof-rn.ri", 191 .sof_tplg_filename = "sof-rn-rt5682-max98360.tplg", 192 }, 193 { 194 .id = "RTL5682", 195 .drv_name = "rt5682s-max", 196 .pdata = (void *)&acp_quirk_data, 197 .machine_quirk = snd_soc_acpi_codec_list, 198 .quirk_data = &_max, 199 .fw_filename = "sof-rn.ri", 200 .sof_tplg_filename = "sof-rn-rt5682-max98360.tplg", 201 }, 202 { 203 .id = "RTL5682", 204 .drv_name = "rt5682s-rt1019", 205 .pdata = (void *)&acp_quirk_data, 206 .machine_quirk = snd_soc_acpi_codec_list, 207 .quirk_data = &_rt1019, 208 .fw_filename = "sof-rn.ri", 209 .sof_tplg_filename = "sof-rn-rt5682-rt1019.tplg", 210 }, 211 { 212 .id = "AMDI1019", 213 .drv_name = "renoir-dsp", 214 .pdata = (void *)&acp_quirk_data, 215 .fw_filename = "sof-rn.ri", 216 .sof_tplg_filename = "sof-acp.tplg", 217 }, 218 {}, 219 }; 220 EXPORT_SYMBOL(snd_soc_acpi_amd_sof_machines); 221 222 struct snd_soc_acpi_mach snd_soc_acpi_amd_vangogh_sof_machines[] = { 223 { 224 .id = "NVTN2020", 225 .drv_name = "nau8821-max", 226 .pdata = &acp_quirk_data, 227 .machine_quirk = snd_soc_acpi_codec_list, 228 .quirk_data = &_max98388, 229 .fw_filename = "sof-vangogh.ri", 230 .sof_tplg_filename = "sof-vangogh-nau8821-max.tplg", 231 }, 232 {}, 233 }; 234 EXPORT_SYMBOL(snd_soc_acpi_amd_vangogh_sof_machines); 235 236 struct snd_soc_acpi_mach snd_soc_acpi_amd_rmb_sof_machines[] = { 237 { 238 .id = "AMDI1019", 239 .drv_name = "rmb-dsp", 240 .pdata = &acp_quirk_data, 241 .fw_filename = "sof-rmb.ri", 242 .sof_tplg_filename = "sof-acp-rmb.tplg", 243 }, 244 { 245 .id = "10508825", 246 .drv_name = "nau8825-max", 247 .pdata = &acp_quirk_data, 248 .machine_quirk = snd_soc_acpi_codec_list, 249 .quirk_data = &_max, 250 .fw_filename = "sof-rmb.ri", 251 .sof_tplg_filename = "sof-rmb-nau8825-max98360.tplg", 252 }, 253 { 254 .id = "RTL5682", 255 .drv_name = "rt5682s-hs-rt1019", 256 .pdata = &acp_quirk_data, 257 .machine_quirk = snd_soc_acpi_codec_list, 258 .quirk_data = &_rt1019, 259 .fw_filename = "sof-rmb.ri", 260 .sof_tplg_filename = "sof-rmb-rt5682s-rt1019.tplg", 261 }, 262 {}, 263 }; 264 EXPORT_SYMBOL(snd_soc_acpi_amd_rmb_sof_machines); 265 266 struct snd_soc_acpi_mach snd_soc_acpi_amd_acp63_sof_machines[] = { 267 { 268 .id = "AMDI1019", 269 .drv_name = "acp63-dsp", 270 .pdata = &acp_quirk_data, 271 .fw_filename = "sof-acp_6_3.ri", 272 .sof_tplg_filename = "sof-acp_6_3.tplg", 273 }, 274 {}, 275 }; 276 EXPORT_SYMBOL(snd_soc_acpi_amd_acp63_sof_machines); 277 278 MODULE_LICENSE("Dual BSD/GPL"); 279