Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 1 | // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 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) 2018 Intel Corporation. All rights reserved. |
| 7 | // |
| 8 | // Author: Liam Girdwood <liam.r.girdwood@linux.intel.com> |
| 9 | // |
| 10 | |
| 11 | #include <linux/firmware.h> |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 12 | #include <linux/dmi.h> |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 13 | #include <linux/module.h> |
| 14 | #include <linux/pci.h> |
| 15 | #include <linux/pm_runtime.h> |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 16 | #include <sound/intel-dsp-config.h> |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 17 | #include <sound/soc-acpi.h> |
| 18 | #include <sound/soc-acpi-intel-match.h> |
| 19 | #include <sound/sof.h> |
| 20 | #include "ops.h" |
| 21 | |
| 22 | /* platform specific devices */ |
| 23 | #include "intel/shim.h" |
| 24 | #include "intel/hda.h" |
| 25 | |
| 26 | static char *fw_path; |
| 27 | module_param(fw_path, charp, 0444); |
| 28 | MODULE_PARM_DESC(fw_path, "alternate path for SOF firmware."); |
| 29 | |
| 30 | static char *tplg_path; |
| 31 | module_param(tplg_path, charp, 0444); |
| 32 | MODULE_PARM_DESC(tplg_path, "alternate path for SOF topology."); |
| 33 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 34 | static int sof_pci_debug; |
| 35 | module_param_named(sof_pci_debug, sof_pci_debug, int, 0444); |
| 36 | MODULE_PARM_DESC(sof_pci_debug, "SOF PCI debug options (0x0 all off)"); |
| 37 | |
| 38 | static const char *sof_override_tplg_name; |
| 39 | |
| 40 | #define SOF_PCI_DISABLE_PM_RUNTIME BIT(0) |
| 41 | |
| 42 | static int sof_tplg_cb(const struct dmi_system_id *id) |
| 43 | { |
| 44 | sof_override_tplg_name = id->driver_data; |
| 45 | return 1; |
| 46 | } |
| 47 | |
| 48 | static const struct dmi_system_id sof_tplg_table[] = { |
| 49 | { |
| 50 | .callback = sof_tplg_cb, |
| 51 | .matches = { |
| 52 | DMI_MATCH(DMI_PRODUCT_FAMILY, "Google_Volteer"), |
| 53 | DMI_MATCH(DMI_OEM_STRING, "AUDIO-MAX98373_ALC5682I_I2S_UP4"), |
| 54 | }, |
| 55 | .driver_data = "sof-tgl-rt5682-ssp0-max98373-ssp2.tplg", |
| 56 | }, |
| 57 | {} |
| 58 | }; |
| 59 | |
| 60 | static const struct dmi_system_id community_key_platforms[] = { |
| 61 | { |
| 62 | .ident = "Up Squared", |
| 63 | .matches = { |
| 64 | DMI_MATCH(DMI_SYS_VENDOR, "AAEON"), |
| 65 | DMI_MATCH(DMI_BOARD_NAME, "UP-APL01"), |
| 66 | } |
| 67 | }, |
| 68 | { |
| 69 | .ident = "Up Extreme", |
| 70 | .matches = { |
| 71 | DMI_MATCH(DMI_SYS_VENDOR, "AAEON"), |
| 72 | DMI_MATCH(DMI_BOARD_NAME, "UP-WHL01"), |
| 73 | } |
| 74 | }, |
| 75 | { |
| 76 | .ident = "Google Chromebooks", |
| 77 | .matches = { |
| 78 | DMI_MATCH(DMI_SYS_VENDOR, "Google"), |
| 79 | } |
| 80 | }, |
| 81 | {}, |
| 82 | }; |
| 83 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 84 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE) |
| 85 | static const struct sof_dev_desc bxt_desc = { |
| 86 | .machines = snd_soc_acpi_intel_bxt_machines, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 87 | .use_acpi_target_states = true, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 88 | .resindex_lpe_base = 0, |
| 89 | .resindex_pcicfg_base = -1, |
| 90 | .resindex_imr_base = -1, |
| 91 | .irqindex_host_ipc = -1, |
| 92 | .resindex_dma_base = -1, |
| 93 | .chip_info = &apl_chip_info, |
| 94 | .default_fw_path = "intel/sof", |
| 95 | .default_tplg_path = "intel/sof-tplg", |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 96 | .default_fw_filename = "sof-apl.ri", |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 97 | .nocodec_tplg_filename = "sof-apl-nocodec.tplg", |
| 98 | .ops = &sof_apl_ops, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 99 | }; |
| 100 | #endif |
| 101 | |
| 102 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_GEMINILAKE) |
| 103 | static const struct sof_dev_desc glk_desc = { |
| 104 | .machines = snd_soc_acpi_intel_glk_machines, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 105 | .use_acpi_target_states = true, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 106 | .resindex_lpe_base = 0, |
| 107 | .resindex_pcicfg_base = -1, |
| 108 | .resindex_imr_base = -1, |
| 109 | .irqindex_host_ipc = -1, |
| 110 | .resindex_dma_base = -1, |
| 111 | .chip_info = &apl_chip_info, |
| 112 | .default_fw_path = "intel/sof", |
| 113 | .default_tplg_path = "intel/sof-tplg", |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 114 | .default_fw_filename = "sof-glk.ri", |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 115 | .nocodec_tplg_filename = "sof-glk-nocodec.tplg", |
| 116 | .ops = &sof_apl_ops, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 117 | }; |
| 118 | #endif |
| 119 | |
| 120 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_MERRIFIELD) |
| 121 | static struct snd_soc_acpi_mach sof_tng_machines[] = { |
| 122 | { |
| 123 | .id = "INT343A", |
| 124 | .drv_name = "edison", |
| 125 | .sof_fw_filename = "sof-byt.ri", |
| 126 | .sof_tplg_filename = "sof-byt.tplg", |
| 127 | }, |
| 128 | {} |
| 129 | }; |
| 130 | |
| 131 | static const struct sof_dev_desc tng_desc = { |
| 132 | .machines = sof_tng_machines, |
| 133 | .resindex_lpe_base = 3, /* IRAM, but subtract IRAM offset */ |
| 134 | .resindex_pcicfg_base = -1, |
| 135 | .resindex_imr_base = 0, |
| 136 | .irqindex_host_ipc = -1, |
| 137 | .resindex_dma_base = -1, |
| 138 | .chip_info = &tng_chip_info, |
| 139 | .default_fw_path = "intel/sof", |
| 140 | .default_tplg_path = "intel/sof-tplg", |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 141 | .default_fw_filename = "sof-byt.ri", |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 142 | .nocodec_tplg_filename = "sof-byt.tplg", |
| 143 | .ops = &sof_tng_ops, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 144 | }; |
| 145 | #endif |
| 146 | |
| 147 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_CANNONLAKE) |
| 148 | static const struct sof_dev_desc cnl_desc = { |
| 149 | .machines = snd_soc_acpi_intel_cnl_machines, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 150 | .alt_machines = snd_soc_acpi_intel_cnl_sdw_machines, |
| 151 | .use_acpi_target_states = true, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 152 | .resindex_lpe_base = 0, |
| 153 | .resindex_pcicfg_base = -1, |
| 154 | .resindex_imr_base = -1, |
| 155 | .irqindex_host_ipc = -1, |
| 156 | .resindex_dma_base = -1, |
| 157 | .chip_info = &cnl_chip_info, |
| 158 | .default_fw_path = "intel/sof", |
| 159 | .default_tplg_path = "intel/sof-tplg", |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 160 | .default_fw_filename = "sof-cnl.ri", |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 161 | .nocodec_tplg_filename = "sof-cnl-nocodec.tplg", |
| 162 | .ops = &sof_cnl_ops, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 163 | }; |
| 164 | #endif |
| 165 | |
| 166 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_COFFEELAKE) |
| 167 | static const struct sof_dev_desc cfl_desc = { |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 168 | .machines = snd_soc_acpi_intel_cfl_machines, |
| 169 | .alt_machines = snd_soc_acpi_intel_cfl_sdw_machines, |
| 170 | .use_acpi_target_states = true, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 171 | .resindex_lpe_base = 0, |
| 172 | .resindex_pcicfg_base = -1, |
| 173 | .resindex_imr_base = -1, |
| 174 | .irqindex_host_ipc = -1, |
| 175 | .resindex_dma_base = -1, |
| 176 | .chip_info = &cnl_chip_info, |
| 177 | .default_fw_path = "intel/sof", |
| 178 | .default_tplg_path = "intel/sof-tplg", |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 179 | .default_fw_filename = "sof-cfl.ri", |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 180 | .nocodec_tplg_filename = "sof-cnl-nocodec.tplg", |
| 181 | .ops = &sof_cnl_ops, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 182 | }; |
| 183 | #endif |
| 184 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 185 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_COMETLAKE) |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 186 | static const struct sof_dev_desc cml_desc = { |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 187 | .machines = snd_soc_acpi_intel_cml_machines, |
| 188 | .alt_machines = snd_soc_acpi_intel_cml_sdw_machines, |
| 189 | .use_acpi_target_states = true, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 190 | .resindex_lpe_base = 0, |
| 191 | .resindex_pcicfg_base = -1, |
| 192 | .resindex_imr_base = -1, |
| 193 | .irqindex_host_ipc = -1, |
| 194 | .resindex_dma_base = -1, |
| 195 | .chip_info = &cnl_chip_info, |
| 196 | .default_fw_path = "intel/sof", |
| 197 | .default_tplg_path = "intel/sof-tplg", |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 198 | .default_fw_filename = "sof-cml.ri", |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 199 | .nocodec_tplg_filename = "sof-cnl-nocodec.tplg", |
| 200 | .ops = &sof_cnl_ops, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 201 | }; |
| 202 | #endif |
| 203 | |
| 204 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_ICELAKE) |
| 205 | static const struct sof_dev_desc icl_desc = { |
| 206 | .machines = snd_soc_acpi_intel_icl_machines, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 207 | .alt_machines = snd_soc_acpi_intel_icl_sdw_machines, |
| 208 | .use_acpi_target_states = true, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 209 | .resindex_lpe_base = 0, |
| 210 | .resindex_pcicfg_base = -1, |
| 211 | .resindex_imr_base = -1, |
| 212 | .irqindex_host_ipc = -1, |
| 213 | .resindex_dma_base = -1, |
| 214 | .chip_info = &icl_chip_info, |
| 215 | .default_fw_path = "intel/sof", |
| 216 | .default_tplg_path = "intel/sof-tplg", |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 217 | .default_fw_filename = "sof-icl.ri", |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 218 | .nocodec_tplg_filename = "sof-icl-nocodec.tplg", |
| 219 | .ops = &sof_cnl_ops, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 220 | }; |
| 221 | #endif |
| 222 | |
| 223 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_TIGERLAKE) |
| 224 | static const struct sof_dev_desc tgl_desc = { |
| 225 | .machines = snd_soc_acpi_intel_tgl_machines, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 226 | .alt_machines = snd_soc_acpi_intel_tgl_sdw_machines, |
| 227 | .use_acpi_target_states = true, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 228 | .resindex_lpe_base = 0, |
| 229 | .resindex_pcicfg_base = -1, |
| 230 | .resindex_imr_base = -1, |
| 231 | .irqindex_host_ipc = -1, |
| 232 | .resindex_dma_base = -1, |
| 233 | .chip_info = &tgl_chip_info, |
| 234 | .default_fw_path = "intel/sof", |
| 235 | .default_tplg_path = "intel/sof-tplg", |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 236 | .default_fw_filename = "sof-tgl.ri", |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 237 | .nocodec_tplg_filename = "sof-tgl-nocodec.tplg", |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 238 | .ops = &sof_tgl_ops, |
| 239 | }; |
| 240 | |
| 241 | static const struct sof_dev_desc tglh_desc = { |
| 242 | .machines = snd_soc_acpi_intel_tgl_machines, |
| 243 | .alt_machines = snd_soc_acpi_intel_tgl_sdw_machines, |
| 244 | .resindex_lpe_base = 0, |
| 245 | .resindex_pcicfg_base = -1, |
| 246 | .resindex_imr_base = -1, |
| 247 | .irqindex_host_ipc = -1, |
| 248 | .resindex_dma_base = -1, |
| 249 | .chip_info = &tglh_chip_info, |
| 250 | .default_fw_path = "intel/sof", |
| 251 | .default_tplg_path = "intel/sof-tplg", |
| 252 | .default_fw_filename = "sof-tgl-h.ri", |
| 253 | .nocodec_tplg_filename = "sof-tgl-nocodec.tplg", |
| 254 | .ops = &sof_tgl_ops, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 255 | }; |
| 256 | #endif |
| 257 | |
| 258 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_ELKHARTLAKE) |
| 259 | static const struct sof_dev_desc ehl_desc = { |
| 260 | .machines = snd_soc_acpi_intel_ehl_machines, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 261 | .use_acpi_target_states = true, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 262 | .resindex_lpe_base = 0, |
| 263 | .resindex_pcicfg_base = -1, |
| 264 | .resindex_imr_base = -1, |
| 265 | .irqindex_host_ipc = -1, |
| 266 | .resindex_dma_base = -1, |
| 267 | .chip_info = &ehl_chip_info, |
| 268 | .default_fw_path = "intel/sof", |
| 269 | .default_tplg_path = "intel/sof-tplg", |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 270 | .default_fw_filename = "sof-ehl.ri", |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 271 | .nocodec_tplg_filename = "sof-ehl-nocodec.tplg", |
| 272 | .ops = &sof_cnl_ops, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 273 | }; |
| 274 | #endif |
| 275 | |
| 276 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_JASPERLAKE) |
| 277 | static const struct sof_dev_desc jsl_desc = { |
| 278 | .machines = snd_soc_acpi_intel_jsl_machines, |
| 279 | .use_acpi_target_states = true, |
| 280 | .resindex_lpe_base = 0, |
| 281 | .resindex_pcicfg_base = -1, |
| 282 | .resindex_imr_base = -1, |
| 283 | .irqindex_host_ipc = -1, |
| 284 | .resindex_dma_base = -1, |
| 285 | .chip_info = &jsl_chip_info, |
| 286 | .default_fw_path = "intel/sof", |
| 287 | .default_tplg_path = "intel/sof-tplg", |
| 288 | .default_fw_filename = "sof-jsl.ri", |
| 289 | .nocodec_tplg_filename = "sof-jsl-nocodec.tplg", |
| 290 | .ops = &sof_cnl_ops, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 291 | }; |
| 292 | #endif |
| 293 | |
| 294 | static const struct dev_pm_ops sof_pci_pm = { |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 295 | .prepare = snd_sof_prepare, |
| 296 | .complete = snd_sof_complete, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 297 | SET_SYSTEM_SLEEP_PM_OPS(snd_sof_suspend, snd_sof_resume) |
| 298 | SET_RUNTIME_PM_OPS(snd_sof_runtime_suspend, snd_sof_runtime_resume, |
| 299 | snd_sof_runtime_idle) |
| 300 | }; |
| 301 | |
| 302 | static void sof_pci_probe_complete(struct device *dev) |
| 303 | { |
| 304 | dev_dbg(dev, "Completing SOF PCI probe"); |
| 305 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 306 | if (sof_pci_debug & SOF_PCI_DISABLE_PM_RUNTIME) |
| 307 | return; |
| 308 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 309 | /* allow runtime_pm */ |
| 310 | pm_runtime_set_autosuspend_delay(dev, SND_SOF_SUSPEND_DELAY_MS); |
| 311 | pm_runtime_use_autosuspend(dev); |
| 312 | |
| 313 | /* |
| 314 | * runtime pm for pci device is "forbidden" by default. |
| 315 | * so call pm_runtime_allow() to enable it. |
| 316 | */ |
| 317 | pm_runtime_allow(dev); |
| 318 | |
| 319 | /* mark last_busy for pm_runtime to make sure not suspend immediately */ |
| 320 | pm_runtime_mark_last_busy(dev); |
| 321 | |
| 322 | /* follow recommendation in pci-driver.c to decrement usage counter */ |
| 323 | pm_runtime_put_noidle(dev); |
| 324 | } |
| 325 | |
| 326 | static int sof_pci_probe(struct pci_dev *pci, |
| 327 | const struct pci_device_id *pci_id) |
| 328 | { |
| 329 | struct device *dev = &pci->dev; |
| 330 | const struct sof_dev_desc *desc = |
| 331 | (const struct sof_dev_desc *)pci_id->driver_data; |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 332 | struct snd_sof_pdata *sof_pdata; |
| 333 | const struct snd_sof_dsp_ops *ops; |
| 334 | int ret; |
| 335 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 336 | ret = snd_intel_dsp_driver_probe(pci); |
| 337 | if (ret != SND_INTEL_DSP_DRIVER_ANY && ret != SND_INTEL_DSP_DRIVER_SOF) { |
| 338 | dev_dbg(&pci->dev, "SOF PCI driver not selected, aborting probe\n"); |
| 339 | return -ENODEV; |
| 340 | } |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 341 | dev_dbg(&pci->dev, "PCI DSP detected"); |
| 342 | |
| 343 | /* get ops for platform */ |
| 344 | ops = desc->ops; |
| 345 | if (!ops) { |
| 346 | dev_err(dev, "error: no matching PCI descriptor ops\n"); |
| 347 | return -ENODEV; |
| 348 | } |
| 349 | |
| 350 | sof_pdata = devm_kzalloc(dev, sizeof(*sof_pdata), GFP_KERNEL); |
| 351 | if (!sof_pdata) |
| 352 | return -ENOMEM; |
| 353 | |
| 354 | ret = pcim_enable_device(pci); |
| 355 | if (ret < 0) |
| 356 | return ret; |
| 357 | |
| 358 | ret = pci_request_regions(pci, "Audio DSP"); |
| 359 | if (ret < 0) |
| 360 | return ret; |
| 361 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 362 | sof_pdata->name = pci_name(pci); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 363 | sof_pdata->desc = (struct sof_dev_desc *)pci_id->driver_data; |
| 364 | sof_pdata->dev = dev; |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 365 | sof_pdata->fw_filename = desc->default_fw_filename; |
| 366 | |
| 367 | /* |
| 368 | * for platforms using the SOF community key, change the |
| 369 | * default path automatically to pick the right files from the |
| 370 | * linux-firmware tree. This can be overridden with the |
| 371 | * fw_path kernel parameter, e.g. for developers. |
| 372 | */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 373 | |
| 374 | /* alternate fw and tplg filenames ? */ |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 375 | if (fw_path) { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 376 | sof_pdata->fw_filename_prefix = fw_path; |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 377 | |
| 378 | dev_dbg(dev, |
| 379 | "Module parameter used, changed fw path to %s\n", |
| 380 | sof_pdata->fw_filename_prefix); |
| 381 | |
| 382 | } else if (dmi_check_system(community_key_platforms)) { |
| 383 | sof_pdata->fw_filename_prefix = |
| 384 | devm_kasprintf(dev, GFP_KERNEL, "%s/%s", |
| 385 | sof_pdata->desc->default_fw_path, |
| 386 | "community"); |
| 387 | |
| 388 | dev_dbg(dev, |
| 389 | "Platform uses community key, changed fw path to %s\n", |
| 390 | sof_pdata->fw_filename_prefix); |
| 391 | } else { |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 392 | sof_pdata->fw_filename_prefix = |
| 393 | sof_pdata->desc->default_fw_path; |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 394 | } |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 395 | |
| 396 | if (tplg_path) |
| 397 | sof_pdata->tplg_filename_prefix = tplg_path; |
| 398 | else |
| 399 | sof_pdata->tplg_filename_prefix = |
| 400 | sof_pdata->desc->default_tplg_path; |
| 401 | |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 402 | dmi_check_system(sof_tplg_table); |
| 403 | if (sof_override_tplg_name) |
| 404 | sof_pdata->tplg_filename = sof_override_tplg_name; |
| 405 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 406 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE) |
| 407 | /* set callback to enable runtime_pm */ |
| 408 | sof_pdata->sof_probe_complete = sof_pci_probe_complete; |
| 409 | #endif |
| 410 | /* call sof helper for DSP hardware probe */ |
| 411 | ret = snd_sof_device_probe(dev, sof_pdata); |
| 412 | if (ret) { |
| 413 | dev_err(dev, "error: failed to probe DSP hardware!\n"); |
| 414 | goto release_regions; |
| 415 | } |
| 416 | |
| 417 | #if !IS_ENABLED(CONFIG_SND_SOC_SOF_PROBE_WORK_QUEUE) |
| 418 | sof_pci_probe_complete(dev); |
| 419 | #endif |
| 420 | |
| 421 | return ret; |
| 422 | |
| 423 | release_regions: |
| 424 | pci_release_regions(pci); |
| 425 | |
| 426 | return ret; |
| 427 | } |
| 428 | |
| 429 | static void sof_pci_remove(struct pci_dev *pci) |
| 430 | { |
| 431 | /* call sof helper for DSP hardware remove */ |
| 432 | snd_sof_device_remove(&pci->dev); |
| 433 | |
| 434 | /* follow recommendation in pci-driver.c to increment usage counter */ |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 435 | if (!(sof_pci_debug & SOF_PCI_DISABLE_PM_RUNTIME)) |
| 436 | pm_runtime_get_noresume(&pci->dev); |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 437 | |
| 438 | /* release pci regions and disable device */ |
| 439 | pci_release_regions(pci); |
| 440 | } |
| 441 | |
| 442 | /* PCI IDs */ |
| 443 | static const struct pci_device_id sof_pci_ids[] = { |
| 444 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_MERRIFIELD) |
| 445 | { PCI_DEVICE(0x8086, 0x119a), |
| 446 | .driver_data = (unsigned long)&tng_desc}, |
| 447 | #endif |
| 448 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_APOLLOLAKE) |
| 449 | /* BXT-P & Apollolake */ |
| 450 | { PCI_DEVICE(0x8086, 0x5a98), |
| 451 | .driver_data = (unsigned long)&bxt_desc}, |
| 452 | { PCI_DEVICE(0x8086, 0x1a98), |
| 453 | .driver_data = (unsigned long)&bxt_desc}, |
| 454 | #endif |
| 455 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_GEMINILAKE) |
| 456 | { PCI_DEVICE(0x8086, 0x3198), |
| 457 | .driver_data = (unsigned long)&glk_desc}, |
| 458 | #endif |
| 459 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_CANNONLAKE) |
| 460 | { PCI_DEVICE(0x8086, 0x9dc8), |
| 461 | .driver_data = (unsigned long)&cnl_desc}, |
| 462 | #endif |
| 463 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_COFFEELAKE) |
| 464 | { PCI_DEVICE(0x8086, 0xa348), |
| 465 | .driver_data = (unsigned long)&cfl_desc}, |
| 466 | #endif |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 467 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_ICELAKE) |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 468 | { PCI_DEVICE(0x8086, 0x34C8), /* ICL-LP */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 469 | .driver_data = (unsigned long)&icl_desc}, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 470 | { PCI_DEVICE(0x8086, 0x3dc8), /* ICL-H */ |
| 471 | .driver_data = (unsigned long)&icl_desc}, |
| 472 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 473 | #endif |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 474 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_JASPERLAKE) |
| 475 | { PCI_DEVICE(0x8086, 0x38c8), |
| 476 | .driver_data = (unsigned long)&jsl_desc}, |
| 477 | { PCI_DEVICE(0x8086, 0x4dc8), |
| 478 | .driver_data = (unsigned long)&jsl_desc}, |
| 479 | #endif |
| 480 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_COMETLAKE) |
| 481 | { PCI_DEVICE(0x8086, 0x02c8), /* CML-LP */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 482 | .driver_data = (unsigned long)&cml_desc}, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 483 | { PCI_DEVICE(0x8086, 0x06c8), /* CML-H */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 484 | .driver_data = (unsigned long)&cml_desc}, |
Olivier Deprez | 0e64123 | 2021-09-23 10:07:05 +0200 | [diff] [blame] | 485 | { PCI_DEVICE(0x8086, 0xa3f0), /* CML-S */ |
| 486 | .driver_data = (unsigned long)&cml_desc}, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 487 | #endif |
| 488 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_TIGERLAKE) |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 489 | { PCI_DEVICE(0x8086, 0xa0c8), /* TGL-LP */ |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 490 | .driver_data = (unsigned long)&tgl_desc}, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 491 | { PCI_DEVICE(0x8086, 0x43c8), /* TGL-H */ |
| 492 | .driver_data = (unsigned long)&tglh_desc}, |
| 493 | |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 494 | #endif |
| 495 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_ELKHARTLAKE) |
| 496 | { PCI_DEVICE(0x8086, 0x4b55), |
| 497 | .driver_data = (unsigned long)&ehl_desc}, |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 498 | { PCI_DEVICE(0x8086, 0x4b58), |
| 499 | .driver_data = (unsigned long)&ehl_desc}, |
David Brazdil | 0f672f6 | 2019-12-10 10:32:29 +0000 | [diff] [blame] | 500 | #endif |
| 501 | { 0, } |
| 502 | }; |
| 503 | MODULE_DEVICE_TABLE(pci, sof_pci_ids); |
| 504 | |
| 505 | /* pci_driver definition */ |
| 506 | static struct pci_driver snd_sof_pci_driver = { |
| 507 | .name = "sof-audio-pci", |
| 508 | .id_table = sof_pci_ids, |
| 509 | .probe = sof_pci_probe, |
| 510 | .remove = sof_pci_remove, |
| 511 | .driver = { |
| 512 | .pm = &sof_pci_pm, |
| 513 | }, |
| 514 | }; |
| 515 | module_pci_driver(snd_sof_pci_driver); |
| 516 | |
| 517 | MODULE_LICENSE("Dual BSD/GPL"); |
Olivier Deprez | 157378f | 2022-04-04 15:47:50 +0200 | [diff] [blame^] | 518 | MODULE_IMPORT_NS(SND_SOC_SOF_MERRIFIELD); |
| 519 | MODULE_IMPORT_NS(SND_SOC_SOF_INTEL_HDA_COMMON); |