Pierre-Louis Bossart | e149ca2 | 2020-05-01 09:58:50 -0500 | [diff] [blame] | 1 | // SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [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 | // Authors: Liam Girdwood <liam.r.girdwood@linux.intel.com> |
| 9 | // Ranjani Sridharan <ranjani.sridharan@linux.intel.com> |
| 10 | // Rander Wang <rander.wang@intel.com> |
| 11 | // Keyon Jie <yang.jie@linux.intel.com> |
| 12 | // |
| 13 | |
| 14 | /* |
| 15 | * Hardware interface for generic Intel audio DSP HDA IP |
| 16 | */ |
| 17 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 18 | #include <sound/hdaudio_ext.h> |
Kai Vehmanen | f1fd9d0 | 2019-06-12 11:57:03 -0500 | [diff] [blame] | 19 | #include <sound/hda_register.h> |
| 20 | |
Pierre-Louis Bossart | 51dfed1 | 2020-03-25 16:50:18 -0500 | [diff] [blame] | 21 | #include <linux/acpi.h> |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 22 | #include <linux/module.h> |
Pierre-Louis Bossart | b9ddd81 | 2020-03-25 16:50:21 -0500 | [diff] [blame] | 23 | #include <linux/soundwire/sdw.h> |
Pierre-Louis Bossart | 51dfed1 | 2020-03-25 16:50:18 -0500 | [diff] [blame] | 24 | #include <linux/soundwire/sdw_intel.h> |
Pierre-Louis Bossart | 194fe0f | 2021-03-01 18:31:22 -0600 | [diff] [blame] | 25 | #include <sound/intel-dsp-config.h> |
Pierre-Louis Bossart | 68b953a | 2019-08-12 11:06:23 -0500 | [diff] [blame] | 26 | #include <sound/intel-nhlt.h> |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 27 | #include <sound/sof.h> |
| 28 | #include <sound/sof/xtensa.h> |
Pierre-Louis Bossart | d2c383a | 2020-03-25 16:50:20 -0500 | [diff] [blame] | 29 | #include "../sof-audio.h" |
Pierre-Louis Bossart | 194fe0f | 2021-03-01 18:31:22 -0600 | [diff] [blame] | 30 | #include "../sof-pci-dev.h" |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 31 | #include "../ops.h" |
| 32 | #include "hda.h" |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 33 | |
| 34 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) |
| 35 | #include <sound/soc-acpi-intel-match.h> |
| 36 | #endif |
| 37 | |
| 38 | /* platform specific devices */ |
| 39 | #include "shim.h" |
| 40 | |
Liam Girdwood | ff2be86 | 2019-09-27 15:05:36 -0500 | [diff] [blame] | 41 | #define EXCEPT_MAX_HDR_SIZE 0x400 |
Ranjani Sridharan | 29c8e43 | 2020-08-25 16:50:38 -0700 | [diff] [blame] | 42 | #define HDA_EXT_ROM_STATUS_SIZE 8 |
Liam Girdwood | ff2be86 | 2019-09-27 15:05:36 -0500 | [diff] [blame] | 43 | |
Ranjani Sridharan | 0acb48d | 2021-09-27 15:05:15 +0300 | [diff] [blame] | 44 | int hda_ctrl_dai_widget_setup(struct snd_soc_dapm_widget *w) |
| 45 | { |
| 46 | struct snd_sof_widget *swidget = w->dobj.private; |
| 47 | struct snd_soc_component *component = swidget->scomp; |
| 48 | struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); |
| 49 | struct sof_ipc_dai_config *config; |
| 50 | struct snd_sof_dai *sof_dai; |
| 51 | struct sof_ipc_reply reply; |
| 52 | int ret; |
| 53 | |
| 54 | sof_dai = swidget->private; |
| 55 | |
| 56 | if (!sof_dai || !sof_dai->dai_config) { |
| 57 | dev_err(sdev->dev, "No config for DAI %s\n", w->name); |
| 58 | return -EINVAL; |
| 59 | } |
| 60 | |
Ranjani Sridharan | 86f74ba | 2021-11-23 18:57:59 +0200 | [diff] [blame] | 61 | /* DAI already configured, reset it before reconfiguring it */ |
| 62 | if (sof_dai->configured) { |
| 63 | ret = hda_ctrl_dai_widget_free(w); |
| 64 | if (ret < 0) |
| 65 | return ret; |
| 66 | } |
| 67 | |
Ranjani Sridharan | 0acb48d | 2021-09-27 15:05:15 +0300 | [diff] [blame] | 68 | config = &sof_dai->dai_config[sof_dai->current_config]; |
| 69 | |
| 70 | /* |
| 71 | * For static pipelines, the DAI widget would already be set up and calling |
| 72 | * sof_widget_setup() simply returns without doing anything. |
| 73 | * For dynamic pipelines, the DAI widget will be set up now. |
| 74 | */ |
| 75 | ret = sof_widget_setup(sdev, swidget); |
| 76 | if (ret < 0) { |
| 77 | dev_err(sdev->dev, "error: failed setting up DAI widget %s\n", w->name); |
| 78 | return ret; |
| 79 | } |
| 80 | |
Pierre-Louis Bossart | b30b60a | 2021-10-04 12:14:28 -0500 | [diff] [blame] | 81 | /* set HW_PARAMS flag */ |
| 82 | config->flags = FIELD_PREP(SOF_DAI_CONFIG_FLAGS_MASK, SOF_DAI_CONFIG_FLAGS_HW_PARAMS); |
| 83 | |
Ranjani Sridharan | 0acb48d | 2021-09-27 15:05:15 +0300 | [diff] [blame] | 84 | /* send DAI_CONFIG IPC */ |
| 85 | ret = sof_ipc_tx_message(sdev->ipc, config->hdr.cmd, config, config->hdr.size, |
| 86 | &reply, sizeof(reply)); |
| 87 | if (ret < 0) { |
| 88 | dev_err(sdev->dev, "error: failed setting DAI config for %s\n", w->name); |
| 89 | return ret; |
| 90 | } |
| 91 | |
| 92 | sof_dai->configured = true; |
| 93 | |
| 94 | return 0; |
| 95 | } |
| 96 | |
| 97 | int hda_ctrl_dai_widget_free(struct snd_soc_dapm_widget *w) |
| 98 | { |
| 99 | struct snd_sof_widget *swidget = w->dobj.private; |
| 100 | struct snd_soc_component *component = swidget->scomp; |
| 101 | struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component); |
| 102 | struct sof_ipc_dai_config *config; |
| 103 | struct snd_sof_dai *sof_dai; |
| 104 | struct sof_ipc_reply reply; |
| 105 | int ret; |
| 106 | |
| 107 | sof_dai = swidget->private; |
| 108 | |
| 109 | if (!sof_dai || !sof_dai->dai_config) { |
| 110 | dev_err(sdev->dev, "error: No config to free DAI %s\n", w->name); |
| 111 | return -EINVAL; |
| 112 | } |
| 113 | |
| 114 | /* nothing to do if hw_free() is called without restarting the stream after resume. */ |
| 115 | if (!sof_dai->configured) |
| 116 | return 0; |
| 117 | |
| 118 | config = &sof_dai->dai_config[sof_dai->current_config]; |
| 119 | |
Pierre-Louis Bossart | b30b60a | 2021-10-04 12:14:28 -0500 | [diff] [blame] | 120 | /* set HW_FREE flag */ |
| 121 | config->flags = FIELD_PREP(SOF_DAI_CONFIG_FLAGS_MASK, SOF_DAI_CONFIG_FLAGS_HW_FREE); |
| 122 | |
Ranjani Sridharan | 0acb48d | 2021-09-27 15:05:15 +0300 | [diff] [blame] | 123 | ret = sof_ipc_tx_message(sdev->ipc, config->hdr.cmd, config, config->hdr.size, |
| 124 | &reply, sizeof(reply)); |
| 125 | if (ret < 0) |
| 126 | dev_err(sdev->dev, "error: failed resetting DAI config for %s\n", w->name); |
| 127 | |
| 128 | /* |
| 129 | * Reset the configured_flag and free the widget even if the IPC fails to keep |
| 130 | * the widget use_count balanced |
| 131 | */ |
| 132 | sof_dai->configured = false; |
| 133 | |
| 134 | return sof_widget_free(sdev, swidget); |
| 135 | } |
| 136 | |
Ranjani Sridharan | 5fcdbb2 | 2021-09-27 15:05:16 +0300 | [diff] [blame] | 137 | static const struct sof_intel_dsp_desc |
| 138 | *get_chip_info(struct snd_sof_pdata *pdata) |
| 139 | { |
| 140 | const struct sof_dev_desc *desc = pdata->desc; |
| 141 | const struct sof_intel_dsp_desc *chip_info; |
| 142 | |
| 143 | chip_info = desc->chip_info; |
| 144 | |
| 145 | return chip_info; |
| 146 | } |
| 147 | |
Pierre-Louis Bossart | 51dfed1 | 2020-03-25 16:50:18 -0500 | [diff] [blame] | 148 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE) |
| 149 | |
Pierre-Louis Bossart | 02df8f4 | 2020-03-25 16:50:24 -0500 | [diff] [blame] | 150 | /* |
| 151 | * The default for SoundWire clock stop quirks is to power gate the IP |
| 152 | * and do a Bus Reset, this will need to be modified when the DSP |
| 153 | * needs to remain in D0i3 so that the Master does not lose context |
| 154 | * and enumeration is not required on clock restart |
| 155 | */ |
| 156 | static int sdw_clock_stop_quirks = SDW_INTEL_CLK_STOP_BUS_RESET; |
| 157 | module_param(sdw_clock_stop_quirks, int, 0444); |
| 158 | MODULE_PARM_DESC(sdw_clock_stop_quirks, "SOF SoundWire clock stop quirks"); |
| 159 | |
Ranjani Sridharan | 0acb48d | 2021-09-27 15:05:15 +0300 | [diff] [blame] | 160 | static int sdw_dai_config_ipc(struct snd_sof_dev *sdev, |
| 161 | struct snd_soc_dapm_widget *w, |
| 162 | int link_id, int alh_stream_id, int dai_id, bool setup) |
| 163 | { |
| 164 | struct snd_sof_widget *swidget = w->dobj.private; |
| 165 | struct sof_ipc_dai_config *config; |
| 166 | struct snd_sof_dai *sof_dai; |
| 167 | |
| 168 | if (!swidget) { |
| 169 | dev_err(sdev->dev, "error: No private data for widget %s\n", w->name); |
| 170 | return -EINVAL; |
| 171 | } |
| 172 | |
| 173 | sof_dai = swidget->private; |
| 174 | |
| 175 | if (!sof_dai || !sof_dai->dai_config) { |
| 176 | dev_err(sdev->dev, "error: No config for DAI %s\n", w->name); |
| 177 | return -EINVAL; |
| 178 | } |
| 179 | |
| 180 | config = &sof_dai->dai_config[sof_dai->current_config]; |
| 181 | |
| 182 | /* update config with link and stream ID */ |
| 183 | config->dai_index = (link_id << 8) | dai_id; |
| 184 | config->alh.stream_id = alh_stream_id; |
| 185 | |
| 186 | if (setup) |
| 187 | return hda_ctrl_dai_widget_setup(w); |
| 188 | |
| 189 | return hda_ctrl_dai_widget_free(w); |
| 190 | } |
| 191 | |
Pierre-Louis Bossart | d2c383a | 2020-03-25 16:50:20 -0500 | [diff] [blame] | 192 | static int sdw_params_stream(struct device *dev, |
| 193 | struct sdw_intel_stream_params_data *params_data) |
| 194 | { |
Ranjani Sridharan | 0acb48d | 2021-09-27 15:05:15 +0300 | [diff] [blame] | 195 | struct snd_pcm_substream *substream = params_data->substream; |
Pierre-Louis Bossart | d2c383a | 2020-03-25 16:50:20 -0500 | [diff] [blame] | 196 | struct snd_sof_dev *sdev = dev_get_drvdata(dev); |
| 197 | struct snd_soc_dai *d = params_data->dai; |
Ranjani Sridharan | 0acb48d | 2021-09-27 15:05:15 +0300 | [diff] [blame] | 198 | struct snd_soc_dapm_widget *w; |
Pierre-Louis Bossart | d2c383a | 2020-03-25 16:50:20 -0500 | [diff] [blame] | 199 | |
Ranjani Sridharan | 0acb48d | 2021-09-27 15:05:15 +0300 | [diff] [blame] | 200 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
| 201 | w = d->playback_widget; |
| 202 | else |
| 203 | w = d->capture_widget; |
Pierre-Louis Bossart | d2c383a | 2020-03-25 16:50:20 -0500 | [diff] [blame] | 204 | |
Ranjani Sridharan | 0acb48d | 2021-09-27 15:05:15 +0300 | [diff] [blame] | 205 | return sdw_dai_config_ipc(sdev, w, params_data->link_id, params_data->alh_stream_id, |
| 206 | d->id, true); |
Pierre-Louis Bossart | d2c383a | 2020-03-25 16:50:20 -0500 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | static int sdw_free_stream(struct device *dev, |
| 210 | struct sdw_intel_stream_free_data *free_data) |
| 211 | { |
Ranjani Sridharan | 0acb48d | 2021-09-27 15:05:15 +0300 | [diff] [blame] | 212 | struct snd_pcm_substream *substream = free_data->substream; |
Pierre-Louis Bossart | d2c383a | 2020-03-25 16:50:20 -0500 | [diff] [blame] | 213 | struct snd_sof_dev *sdev = dev_get_drvdata(dev); |
| 214 | struct snd_soc_dai *d = free_data->dai; |
Ranjani Sridharan | 0acb48d | 2021-09-27 15:05:15 +0300 | [diff] [blame] | 215 | struct snd_soc_dapm_widget *w; |
Pierre-Louis Bossart | d2c383a | 2020-03-25 16:50:20 -0500 | [diff] [blame] | 216 | |
Ranjani Sridharan | 0acb48d | 2021-09-27 15:05:15 +0300 | [diff] [blame] | 217 | if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) |
| 218 | w = d->playback_widget; |
| 219 | else |
| 220 | w = d->capture_widget; |
Pierre-Louis Bossart | d2c383a | 2020-03-25 16:50:20 -0500 | [diff] [blame] | 221 | |
Ranjani Sridharan | 0acb48d | 2021-09-27 15:05:15 +0300 | [diff] [blame] | 222 | /* send invalid stream_id */ |
| 223 | return sdw_dai_config_ipc(sdev, w, free_data->link_id, 0xFFFF, d->id, false); |
Pierre-Louis Bossart | d2c383a | 2020-03-25 16:50:20 -0500 | [diff] [blame] | 224 | } |
| 225 | |
| 226 | static const struct sdw_intel_ops sdw_callback = { |
| 227 | .params_stream = sdw_params_stream, |
| 228 | .free_stream = sdw_free_stream, |
| 229 | }; |
| 230 | |
Pierre-Louis Bossart | 51dfed1 | 2020-03-25 16:50:18 -0500 | [diff] [blame] | 231 | void hda_sdw_int_enable(struct snd_sof_dev *sdev, bool enable) |
| 232 | { |
| 233 | sdw_intel_enable_irq(sdev->bar[HDA_DSP_BAR], enable); |
| 234 | } |
| 235 | |
| 236 | static int hda_sdw_acpi_scan(struct snd_sof_dev *sdev) |
| 237 | { |
| 238 | struct sof_intel_hda_dev *hdev; |
| 239 | acpi_handle handle; |
| 240 | int ret; |
| 241 | |
| 242 | handle = ACPI_HANDLE(sdev->dev); |
| 243 | |
| 244 | /* save ACPI info for the probe step */ |
| 245 | hdev = sdev->pdata->hw_pdata; |
| 246 | |
| 247 | ret = sdw_intel_acpi_scan(handle, &hdev->info); |
Pierre-Louis Bossart | 0d4453e | 2020-04-09 13:44:14 -0500 | [diff] [blame] | 248 | if (ret < 0) |
Pierre-Louis Bossart | 51dfed1 | 2020-03-25 16:50:18 -0500 | [diff] [blame] | 249 | return -EINVAL; |
Pierre-Louis Bossart | 51dfed1 | 2020-03-25 16:50:18 -0500 | [diff] [blame] | 250 | |
| 251 | return 0; |
| 252 | } |
| 253 | |
| 254 | static int hda_sdw_probe(struct snd_sof_dev *sdev) |
| 255 | { |
| 256 | struct sof_intel_hda_dev *hdev; |
| 257 | struct sdw_intel_res res; |
Pierre-Louis Bossart | 51dfed1 | 2020-03-25 16:50:18 -0500 | [diff] [blame] | 258 | void *sdw; |
| 259 | |
Pierre-Louis Bossart | 51dfed1 | 2020-03-25 16:50:18 -0500 | [diff] [blame] | 260 | hdev = sdev->pdata->hw_pdata; |
| 261 | |
| 262 | memset(&res, 0, sizeof(res)); |
| 263 | |
| 264 | res.mmio_base = sdev->bar[HDA_DSP_BAR]; |
Bard Liao | 60e9feb | 2021-07-23 19:54:51 +0800 | [diff] [blame] | 265 | res.shim_base = hdev->desc->sdw_shim_base; |
| 266 | res.alh_base = hdev->desc->sdw_alh_base; |
Pierre-Louis Bossart | 51dfed1 | 2020-03-25 16:50:18 -0500 | [diff] [blame] | 267 | res.irq = sdev->ipc_irq; |
| 268 | res.handle = hdev->info.handle; |
| 269 | res.parent = sdev->dev; |
Pierre-Louis Bossart | d2c383a | 2020-03-25 16:50:20 -0500 | [diff] [blame] | 270 | res.ops = &sdw_callback; |
| 271 | res.dev = sdev->dev; |
Pierre-Louis Bossart | 02df8f4 | 2020-03-25 16:50:24 -0500 | [diff] [blame] | 272 | res.clock_stop_quirks = sdw_clock_stop_quirks; |
Pierre-Louis Bossart | 51dfed1 | 2020-03-25 16:50:18 -0500 | [diff] [blame] | 273 | |
| 274 | /* |
| 275 | * ops and arg fields are not populated for now, |
| 276 | * they will be needed when the DAI callbacks are |
| 277 | * provided |
| 278 | */ |
| 279 | |
| 280 | /* we could filter links here if needed, e.g for quirks */ |
| 281 | res.count = hdev->info.count; |
| 282 | res.link_mask = hdev->info.link_mask; |
| 283 | |
| 284 | sdw = sdw_intel_probe(&res); |
| 285 | if (!sdw) { |
| 286 | dev_err(sdev->dev, "error: SoundWire probe failed\n"); |
| 287 | return -EINVAL; |
| 288 | } |
| 289 | |
| 290 | /* save context */ |
| 291 | hdev->sdw = sdw; |
| 292 | |
| 293 | return 0; |
| 294 | } |
| 295 | |
| 296 | int hda_sdw_startup(struct snd_sof_dev *sdev) |
| 297 | { |
| 298 | struct sof_intel_hda_dev *hdev; |
Pierre-Louis Bossart | 61bef9e | 2021-07-26 13:28:55 -0500 | [diff] [blame] | 299 | struct snd_sof_pdata *pdata = sdev->pdata; |
Pierre-Louis Bossart | 51dfed1 | 2020-03-25 16:50:18 -0500 | [diff] [blame] | 300 | |
| 301 | hdev = sdev->pdata->hw_pdata; |
| 302 | |
Pierre-Louis Bossart | b9ddd81 | 2020-03-25 16:50:21 -0500 | [diff] [blame] | 303 | if (!hdev->sdw) |
| 304 | return 0; |
| 305 | |
Pierre-Louis Bossart | 61bef9e | 2021-07-26 13:28:55 -0500 | [diff] [blame] | 306 | if (pdata->machine && !pdata->machine->mach_params.link_mask) |
| 307 | return 0; |
| 308 | |
Pierre-Louis Bossart | 51dfed1 | 2020-03-25 16:50:18 -0500 | [diff] [blame] | 309 | return sdw_intel_startup(hdev->sdw); |
| 310 | } |
| 311 | |
| 312 | static int hda_sdw_exit(struct snd_sof_dev *sdev) |
| 313 | { |
| 314 | struct sof_intel_hda_dev *hdev; |
| 315 | |
| 316 | hdev = sdev->pdata->hw_pdata; |
| 317 | |
| 318 | hda_sdw_int_enable(sdev, false); |
| 319 | |
| 320 | if (hdev->sdw) |
| 321 | sdw_intel_exit(hdev->sdw); |
| 322 | hdev->sdw = NULL; |
| 323 | |
| 324 | return 0; |
| 325 | } |
Bard Liao | 722ba5f | 2020-03-25 16:50:23 -0500 | [diff] [blame] | 326 | |
Bard Liao | 198fa4b | 2021-07-23 19:54:50 +0800 | [diff] [blame] | 327 | bool hda_common_check_sdw_irq(struct snd_sof_dev *sdev) |
Bard Liao | 722ba5f | 2020-03-25 16:50:23 -0500 | [diff] [blame] | 328 | { |
| 329 | struct sof_intel_hda_dev *hdev; |
| 330 | bool ret = false; |
| 331 | u32 irq_status; |
| 332 | |
| 333 | hdev = sdev->pdata->hw_pdata; |
| 334 | |
| 335 | if (!hdev->sdw) |
| 336 | return ret; |
| 337 | |
| 338 | /* store status */ |
| 339 | irq_status = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIS2); |
| 340 | |
| 341 | /* invalid message ? */ |
| 342 | if (irq_status == 0xffffffff) |
| 343 | goto out; |
| 344 | |
| 345 | /* SDW message ? */ |
| 346 | if (irq_status & HDA_DSP_REG_ADSPIS2_SNDW) |
| 347 | ret = true; |
| 348 | |
| 349 | out: |
| 350 | return ret; |
| 351 | } |
| 352 | |
Bard Liao | 198fa4b | 2021-07-23 19:54:50 +0800 | [diff] [blame] | 353 | static bool hda_dsp_check_sdw_irq(struct snd_sof_dev *sdev) |
| 354 | { |
| 355 | const struct sof_intel_dsp_desc *chip; |
| 356 | |
| 357 | chip = get_chip_info(sdev->pdata); |
| 358 | if (chip && chip->check_sdw_irq) |
| 359 | return chip->check_sdw_irq(sdev); |
| 360 | |
| 361 | return false; |
| 362 | } |
| 363 | |
Bard Liao | 722ba5f | 2020-03-25 16:50:23 -0500 | [diff] [blame] | 364 | static irqreturn_t hda_dsp_sdw_thread(int irq, void *context) |
| 365 | { |
| 366 | return sdw_intel_thread(irq, context); |
| 367 | } |
| 368 | |
Rander Wang | 90de328 | 2020-03-25 16:50:26 -0500 | [diff] [blame] | 369 | static bool hda_sdw_check_wakeen_irq(struct snd_sof_dev *sdev) |
| 370 | { |
| 371 | struct sof_intel_hda_dev *hdev; |
| 372 | |
| 373 | hdev = sdev->pdata->hw_pdata; |
| 374 | if (hdev->sdw && |
| 375 | snd_sof_dsp_read(sdev, HDA_DSP_BAR, |
Bard Liao | 781dd3c8 | 2021-07-23 19:54:48 +0800 | [diff] [blame] | 376 | hdev->desc->sdw_shim_base + SDW_SHIM_WAKESTS)) |
Rander Wang | 90de328 | 2020-03-25 16:50:26 -0500 | [diff] [blame] | 377 | return true; |
| 378 | |
| 379 | return false; |
| 380 | } |
| 381 | |
Rander Wang | bbd19cd | 2020-03-25 16:50:25 -0500 | [diff] [blame] | 382 | void hda_sdw_process_wakeen(struct snd_sof_dev *sdev) |
| 383 | { |
| 384 | struct sof_intel_hda_dev *hdev; |
| 385 | |
| 386 | hdev = sdev->pdata->hw_pdata; |
| 387 | if (!hdev->sdw) |
| 388 | return; |
| 389 | |
| 390 | sdw_intel_process_wakeen_event(hdev->sdw); |
| 391 | } |
| 392 | |
Peter Ujfalusi | 3e9d5b0 | 2021-09-15 10:18:05 +0300 | [diff] [blame] | 393 | #else /* IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE) */ |
| 394 | static inline int hda_sdw_acpi_scan(struct snd_sof_dev *sdev) |
| 395 | { |
| 396 | return 0; |
| 397 | } |
| 398 | |
| 399 | static inline int hda_sdw_probe(struct snd_sof_dev *sdev) |
| 400 | { |
| 401 | return 0; |
| 402 | } |
| 403 | |
| 404 | static inline int hda_sdw_exit(struct snd_sof_dev *sdev) |
| 405 | { |
| 406 | return 0; |
| 407 | } |
| 408 | |
| 409 | static inline bool hda_dsp_check_sdw_irq(struct snd_sof_dev *sdev) |
| 410 | { |
| 411 | return false; |
| 412 | } |
| 413 | |
| 414 | static inline irqreturn_t hda_dsp_sdw_thread(int irq, void *context) |
| 415 | { |
| 416 | return IRQ_HANDLED; |
| 417 | } |
| 418 | |
| 419 | static inline bool hda_sdw_check_wakeen_irq(struct snd_sof_dev *sdev) |
| 420 | { |
| 421 | return false; |
| 422 | } |
| 423 | |
| 424 | #endif /* IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE) */ |
Pierre-Louis Bossart | 51dfed1 | 2020-03-25 16:50:18 -0500 | [diff] [blame] | 425 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 426 | /* |
| 427 | * Debug |
| 428 | */ |
| 429 | |
| 430 | struct hda_dsp_msg_code { |
| 431 | u32 code; |
| 432 | const char *msg; |
| 433 | }; |
| 434 | |
Guennadi Liakhovetski | 672ff5e | 2019-07-22 09:13:57 -0500 | [diff] [blame] | 435 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG) |
Peter Ujfalusi | 9d5536e | 2021-05-21 12:28:04 +0300 | [diff] [blame] | 436 | static bool hda_use_msi = true; |
Guennadi Liakhovetski | 672ff5e | 2019-07-22 09:13:57 -0500 | [diff] [blame] | 437 | module_param_named(use_msi, hda_use_msi, bool, 0444); |
| 438 | MODULE_PARM_DESC(use_msi, "SOF HDA use PCI MSI mode"); |
Peter Ujfalusi | 9d5536e | 2021-05-21 12:28:04 +0300 | [diff] [blame] | 439 | #else |
| 440 | #define hda_use_msi (1) |
Guennadi Liakhovetski | 672ff5e | 2019-07-22 09:13:57 -0500 | [diff] [blame] | 441 | #endif |
| 442 | |
Jaroslav Kysela | b8d3ad5 | 2020-04-24 11:25:20 +0200 | [diff] [blame] | 443 | static char *hda_model; |
| 444 | module_param(hda_model, charp, 0444); |
| 445 | MODULE_PARM_DESC(hda_model, "Use the given HDA board model."); |
| 446 | |
Pierre-Louis Bossart | 7aecf59 | 2021-02-08 17:33:34 -0600 | [diff] [blame] | 447 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) || IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE) |
Pierre-Louis Bossart | 68b953a | 2019-08-12 11:06:23 -0500 | [diff] [blame] | 448 | static int hda_dmic_num = -1; |
| 449 | module_param_named(dmic_num, hda_dmic_num, int, 0444); |
| 450 | MODULE_PARM_DESC(dmic_num, "SOF HDA DMIC number"); |
Pierre-Louis Bossart | 7aecf59 | 2021-02-08 17:33:34 -0600 | [diff] [blame] | 451 | #endif |
Kai Vehmanen | 139c7fe | 2019-10-29 15:40:13 +0200 | [diff] [blame] | 452 | |
Pierre-Louis Bossart | 7aecf59 | 2021-02-08 17:33:34 -0600 | [diff] [blame] | 453 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) |
Kai Vehmanen | 42c6775 | 2020-03-12 14:48:53 -0500 | [diff] [blame] | 454 | static bool hda_codec_use_common_hdmi = IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI); |
Kai Vehmanen | 139c7fe | 2019-10-29 15:40:13 +0200 | [diff] [blame] | 455 | module_param_named(use_common_hdmi, hda_codec_use_common_hdmi, bool, 0444); |
| 456 | MODULE_PARM_DESC(use_common_hdmi, "SOF HDA use common HDMI codec driver"); |
Pierre-Louis Bossart | 68b953a | 2019-08-12 11:06:23 -0500 | [diff] [blame] | 457 | #endif |
| 458 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 459 | static const struct hda_dsp_msg_code hda_dsp_rom_msg[] = { |
| 460 | {HDA_DSP_ROM_FW_MANIFEST_LOADED, "status: manifest loaded"}, |
| 461 | {HDA_DSP_ROM_FW_FW_LOADED, "status: fw loaded"}, |
| 462 | {HDA_DSP_ROM_FW_ENTERED, "status: fw entered"}, |
| 463 | {HDA_DSP_ROM_CSE_ERROR, "error: cse error"}, |
| 464 | {HDA_DSP_ROM_CSE_WRONG_RESPONSE, "error: cse wrong response"}, |
| 465 | {HDA_DSP_ROM_IMR_TO_SMALL, "error: IMR too small"}, |
| 466 | {HDA_DSP_ROM_BASE_FW_NOT_FOUND, "error: base fw not found"}, |
| 467 | {HDA_DSP_ROM_CSE_VALIDATION_FAILED, "error: signature verification failed"}, |
| 468 | {HDA_DSP_ROM_IPC_FATAL_ERROR, "error: ipc fatal error"}, |
| 469 | {HDA_DSP_ROM_L2_CACHE_ERROR, "error: L2 cache error"}, |
| 470 | {HDA_DSP_ROM_LOAD_OFFSET_TO_SMALL, "error: load offset too small"}, |
| 471 | {HDA_DSP_ROM_API_PTR_INVALID, "error: API ptr invalid"}, |
Colin Ian King | 07f8045 | 2019-05-01 11:23:08 +0100 | [diff] [blame] | 472 | {HDA_DSP_ROM_BASEFW_INCOMPAT, "error: base fw incompatible"}, |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 473 | {HDA_DSP_ROM_UNHANDLED_INTERRUPT, "error: unhandled interrupt"}, |
| 474 | {HDA_DSP_ROM_MEMORY_HOLE_ECC, "error: ECC memory hole"}, |
| 475 | {HDA_DSP_ROM_KERNEL_EXCEPTION, "error: kernel exception"}, |
| 476 | {HDA_DSP_ROM_USER_EXCEPTION, "error: user exception"}, |
| 477 | {HDA_DSP_ROM_UNEXPECTED_RESET, "error: unexpected reset"}, |
| 478 | {HDA_DSP_ROM_NULL_FW_ENTRY, "error: null FW entry point"}, |
| 479 | }; |
| 480 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 481 | static void hda_dsp_get_status(struct snd_sof_dev *sdev) |
| 482 | { |
| 483 | u32 status; |
| 484 | int i; |
| 485 | |
| 486 | status = snd_sof_dsp_read(sdev, HDA_DSP_BAR, |
| 487 | HDA_DSP_SRAM_REG_ROM_STATUS); |
| 488 | |
| 489 | for (i = 0; i < ARRAY_SIZE(hda_dsp_rom_msg); i++) { |
| 490 | if (status == hda_dsp_rom_msg[i].code) { |
| 491 | dev_err(sdev->dev, "%s - code %8.8x\n", |
| 492 | hda_dsp_rom_msg[i].msg, status); |
| 493 | return; |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | /* not for us, must be generic sof message */ |
| 498 | dev_dbg(sdev->dev, "unknown ROM status value %8.8x\n", status); |
| 499 | } |
| 500 | |
| 501 | static void hda_dsp_get_registers(struct snd_sof_dev *sdev, |
| 502 | struct sof_ipc_dsp_oops_xtensa *xoops, |
| 503 | struct sof_ipc_panic_info *panic_info, |
| 504 | u32 *stack, size_t stack_words) |
| 505 | { |
Kai Vehmanen | 14104eb | 2019-06-03 11:18:15 -0500 | [diff] [blame] | 506 | u32 offset = sdev->dsp_oops_offset; |
| 507 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 508 | /* first read registers */ |
Kai Vehmanen | 14104eb | 2019-06-03 11:18:15 -0500 | [diff] [blame] | 509 | sof_mailbox_read(sdev, offset, xoops, sizeof(*xoops)); |
| 510 | |
| 511 | /* note: variable AR register array is not read */ |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 512 | |
| 513 | /* then get panic info */ |
Liam Girdwood | ff2be86 | 2019-09-27 15:05:36 -0500 | [diff] [blame] | 514 | if (xoops->arch_hdr.totalsize > EXCEPT_MAX_HDR_SIZE) { |
| 515 | dev_err(sdev->dev, "invalid header size 0x%x. FW oops is bogus\n", |
| 516 | xoops->arch_hdr.totalsize); |
| 517 | return; |
| 518 | } |
Kai Vehmanen | 14104eb | 2019-06-03 11:18:15 -0500 | [diff] [blame] | 519 | offset += xoops->arch_hdr.totalsize; |
| 520 | sof_block_read(sdev, sdev->mmio_bar, offset, |
| 521 | panic_info, sizeof(*panic_info)); |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 522 | |
| 523 | /* then get the stack */ |
Kai Vehmanen | 14104eb | 2019-06-03 11:18:15 -0500 | [diff] [blame] | 524 | offset += sizeof(*panic_info); |
| 525 | sof_block_read(sdev, sdev->mmio_bar, offset, stack, |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 526 | stack_words * sizeof(u32)); |
| 527 | } |
| 528 | |
Ranjani Sridharan | 29c8e43 | 2020-08-25 16:50:38 -0700 | [diff] [blame] | 529 | /* dump the first 8 dwords representing the extended ROM status */ |
Ranjani Sridharan | 8f7ef6f | 2020-12-11 12:07:43 +0200 | [diff] [blame] | 530 | static void hda_dsp_dump_ext_rom_status(struct snd_sof_dev *sdev, u32 flags) |
Ranjani Sridharan | 29c8e43 | 2020-08-25 16:50:38 -0700 | [diff] [blame] | 531 | { |
| 532 | char msg[128]; |
| 533 | int len = 0; |
| 534 | u32 value; |
| 535 | int i; |
| 536 | |
| 537 | for (i = 0; i < HDA_EXT_ROM_STATUS_SIZE; i++) { |
| 538 | value = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_SRAM_REG_ROM_STATUS + i * 0x4); |
| 539 | len += snprintf(msg + len, sizeof(msg) - len, " 0x%x", value); |
| 540 | } |
| 541 | |
Peter Ujfalusi | 4fade25 | 2021-10-06 14:06:41 +0300 | [diff] [blame] | 542 | dev_err(sdev->dev, "extended rom status: %s", msg); |
Pierre-Louis Bossart | 776100a | 2020-09-17 13:56:33 +0300 | [diff] [blame] | 543 | |
Ranjani Sridharan | 29c8e43 | 2020-08-25 16:50:38 -0700 | [diff] [blame] | 544 | } |
| 545 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 546 | void hda_dsp_dump(struct snd_sof_dev *sdev, u32 flags) |
| 547 | { |
| 548 | struct sof_ipc_dsp_oops_xtensa xoops; |
| 549 | struct sof_ipc_panic_info panic_info; |
| 550 | u32 stack[HDA_DSP_STACK_DUMP_SIZE]; |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 551 | |
Ranjani Sridharan | 7ff562f | 2021-05-28 19:05:50 +0300 | [diff] [blame] | 552 | /* print ROM/FW status */ |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 553 | hda_dsp_get_status(sdev); |
| 554 | |
Peter Ujfalusi | 3ad7b8f | 2021-10-06 14:06:45 +0300 | [diff] [blame] | 555 | if (flags & SOF_DBG_DUMP_REGS) { |
Ranjani Sridharan | 7ff562f | 2021-05-28 19:05:50 +0300 | [diff] [blame] | 556 | u32 status = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_SRAM_REG_FW_STATUS); |
| 557 | u32 panic = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_SRAM_REG_FW_TRACEP); |
| 558 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 559 | hda_dsp_get_registers(sdev, &xoops, &panic_info, stack, |
| 560 | HDA_DSP_STACK_DUMP_SIZE); |
| 561 | snd_sof_get_status(sdev, status, panic, &xoops, &panic_info, |
| 562 | stack, HDA_DSP_STACK_DUMP_SIZE); |
| 563 | } else { |
Ranjani Sridharan | 8f7ef6f | 2020-12-11 12:07:43 +0200 | [diff] [blame] | 564 | hda_dsp_dump_ext_rom_status(sdev, flags); |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 565 | } |
| 566 | } |
| 567 | |
Kai Vehmanen | f1fd9d0 | 2019-06-12 11:57:03 -0500 | [diff] [blame] | 568 | void hda_ipc_irq_dump(struct snd_sof_dev *sdev) |
| 569 | { |
| 570 | struct hdac_bus *bus = sof_to_bus(sdev); |
| 571 | u32 adspis; |
| 572 | u32 intsts; |
| 573 | u32 intctl; |
| 574 | u32 ppsts; |
| 575 | u8 rirbsts; |
| 576 | |
| 577 | /* read key IRQ stats and config registers */ |
| 578 | adspis = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_ADSPIS); |
| 579 | intsts = snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTSTS); |
| 580 | intctl = snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTCTL); |
| 581 | ppsts = snd_sof_dsp_read(sdev, HDA_DSP_PP_BAR, SOF_HDA_REG_PP_PPSTS); |
| 582 | rirbsts = snd_hdac_chip_readb(bus, RIRBSTS); |
| 583 | |
Peter Ujfalusi | 4fade25 | 2021-10-06 14:06:41 +0300 | [diff] [blame] | 584 | dev_err(sdev->dev, "hda irq intsts 0x%8.8x intlctl 0x%8.8x rirb %2.2x\n", |
Kai Vehmanen | f1fd9d0 | 2019-06-12 11:57:03 -0500 | [diff] [blame] | 585 | intsts, intctl, rirbsts); |
Peter Ujfalusi | 4fade25 | 2021-10-06 14:06:41 +0300 | [diff] [blame] | 586 | dev_err(sdev->dev, "dsp irq ppsts 0x%8.8x adspis 0x%8.8x\n", ppsts, adspis); |
Kai Vehmanen | f1fd9d0 | 2019-06-12 11:57:03 -0500 | [diff] [blame] | 587 | } |
| 588 | |
Pan Xiuli | f3da49f | 2019-04-30 18:09:33 -0500 | [diff] [blame] | 589 | void hda_ipc_dump(struct snd_sof_dev *sdev) |
| 590 | { |
| 591 | u32 hipcie; |
| 592 | u32 hipct; |
| 593 | u32 hipcctl; |
| 594 | |
Kai Vehmanen | f1fd9d0 | 2019-06-12 11:57:03 -0500 | [diff] [blame] | 595 | hda_ipc_irq_dump(sdev); |
| 596 | |
Pan Xiuli | f3da49f | 2019-04-30 18:09:33 -0500 | [diff] [blame] | 597 | /* read IPC status */ |
| 598 | hipcie = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCIE); |
| 599 | hipct = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCT); |
| 600 | hipcctl = snd_sof_dsp_read(sdev, HDA_DSP_BAR, HDA_DSP_REG_HIPCCTL); |
| 601 | |
| 602 | /* dump the IPC regs */ |
| 603 | /* TODO: parse the raw msg */ |
Peter Ujfalusi | 4fade25 | 2021-10-06 14:06:41 +0300 | [diff] [blame] | 604 | dev_err(sdev->dev, "host status 0x%8.8x dsp status 0x%8.8x mask 0x%8.8x\n", |
Pan Xiuli | f3da49f | 2019-04-30 18:09:33 -0500 | [diff] [blame] | 605 | hipcie, hipct, hipcctl); |
| 606 | } |
| 607 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 608 | static int hda_init(struct snd_sof_dev *sdev) |
| 609 | { |
| 610 | struct hda_bus *hbus; |
| 611 | struct hdac_bus *bus; |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 612 | struct pci_dev *pci = to_pci_dev(sdev->dev); |
| 613 | int ret; |
| 614 | |
| 615 | hbus = sof_to_hbus(sdev); |
| 616 | bus = sof_to_bus(sdev); |
| 617 | |
| 618 | /* HDA bus init */ |
Takashi Iwai | d4ff1b3 | 2019-08-07 20:50:50 +0200 | [diff] [blame] | 619 | sof_hda_bus_init(bus, &pci->dev); |
Bard Liao | 64ca9d9 | 2019-05-27 00:58:36 +0800 | [diff] [blame] | 620 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 621 | bus->use_posbuf = 1; |
| 622 | bus->bdl_pos_adj = 0; |
Kai Vehmanen | f3416e7 | 2019-10-08 11:44:35 -0500 | [diff] [blame] | 623 | bus->sync_write = 1; |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 624 | |
| 625 | mutex_init(&hbus->prepare_mutex); |
| 626 | hbus->pci = pci; |
| 627 | hbus->mixer_assigned = -1; |
Jaroslav Kysela | b8d3ad5 | 2020-04-24 11:25:20 +0200 | [diff] [blame] | 628 | hbus->modelname = hda_model; |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 629 | |
| 630 | /* initialise hdac bus */ |
| 631 | bus->addr = pci_resource_start(pci, 0); |
| 632 | bus->remap_addr = pci_ioremap_bar(pci, 0); |
| 633 | if (!bus->remap_addr) { |
| 634 | dev_err(bus->dev, "error: ioremap error\n"); |
| 635 | return -ENXIO; |
| 636 | } |
| 637 | |
| 638 | /* HDA base */ |
| 639 | sdev->bar[HDA_DSP_HDA_BAR] = bus->remap_addr; |
| 640 | |
Kai Vehmanen | af7aae1 | 2020-02-06 22:02:23 +0200 | [diff] [blame] | 641 | /* init i915 and HDMI codecs */ |
| 642 | ret = hda_codec_i915_init(sdev); |
Kai Vehmanen | 71cc8ab | 2020-02-20 19:10:28 +0200 | [diff] [blame] | 643 | if (ret < 0) |
| 644 | dev_warn(sdev->dev, "init of i915 and HDMI codec failed\n"); |
Kai Vehmanen | af7aae1 | 2020-02-06 22:02:23 +0200 | [diff] [blame] | 645 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 646 | /* get controller capabilities */ |
| 647 | ret = hda_dsp_ctrl_get_caps(sdev); |
| 648 | if (ret < 0) |
| 649 | dev_err(sdev->dev, "error: get caps error\n"); |
| 650 | |
| 651 | return ret; |
| 652 | } |
| 653 | |
Pierre-Louis Bossart | 7aecf59 | 2021-02-08 17:33:34 -0600 | [diff] [blame] | 654 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) || IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE) |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 655 | |
Pierre-Louis Bossart | 68b953a | 2019-08-12 11:06:23 -0500 | [diff] [blame] | 656 | static int check_nhlt_dmic(struct snd_sof_dev *sdev) |
| 657 | { |
| 658 | struct nhlt_acpi_table *nhlt; |
| 659 | int dmic_num; |
| 660 | |
| 661 | nhlt = intel_nhlt_init(sdev->dev); |
| 662 | if (nhlt) { |
| 663 | dmic_num = intel_nhlt_get_dmic_geo(sdev->dev, nhlt); |
| 664 | intel_nhlt_free(nhlt); |
Jaska Uimonen | 3dca35e | 2020-08-25 16:50:36 -0700 | [diff] [blame] | 665 | if (dmic_num >= 1 && dmic_num <= 4) |
Pierre-Louis Bossart | 68b953a | 2019-08-12 11:06:23 -0500 | [diff] [blame] | 666 | return dmic_num; |
| 667 | } |
| 668 | |
| 669 | return 0; |
| 670 | } |
| 671 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 672 | static const char *fixup_tplg_name(struct snd_sof_dev *sdev, |
Pierre-Louis Bossart | 68b953a | 2019-08-12 11:06:23 -0500 | [diff] [blame] | 673 | const char *sof_tplg_filename, |
| 674 | const char *idisp_str, |
| 675 | const char *dmic_str) |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 676 | { |
| 677 | const char *tplg_filename = NULL; |
Guennadi Liakhovetski | b908853 | 2021-02-08 17:33:35 -0600 | [diff] [blame] | 678 | char *filename, *tmp; |
| 679 | const char *split_ext; |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 680 | |
Guennadi Liakhovetski | b908853 | 2021-02-08 17:33:35 -0600 | [diff] [blame] | 681 | filename = kstrdup(sof_tplg_filename, GFP_KERNEL); |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 682 | if (!filename) |
| 683 | return NULL; |
| 684 | |
| 685 | /* this assumes a .tplg extension */ |
Guennadi Liakhovetski | b908853 | 2021-02-08 17:33:35 -0600 | [diff] [blame] | 686 | tmp = filename; |
| 687 | split_ext = strsep(&tmp, "."); |
| 688 | if (split_ext) |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 689 | tplg_filename = devm_kasprintf(sdev->dev, GFP_KERNEL, |
Pierre-Louis Bossart | 68b953a | 2019-08-12 11:06:23 -0500 | [diff] [blame] | 690 | "%s%s%s.tplg", |
| 691 | split_ext, idisp_str, dmic_str); |
Guennadi Liakhovetski | b908853 | 2021-02-08 17:33:35 -0600 | [diff] [blame] | 692 | kfree(filename); |
| 693 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 694 | return tplg_filename; |
| 695 | } |
| 696 | |
Pierre-Louis Bossart | 7aecf59 | 2021-02-08 17:33:34 -0600 | [diff] [blame] | 697 | static int dmic_topology_fixup(struct snd_sof_dev *sdev, |
| 698 | const char **tplg_filename, |
| 699 | const char *idisp_str, |
| 700 | int *dmic_found) |
| 701 | { |
| 702 | const char *default_tplg_filename = *tplg_filename; |
| 703 | const char *fixed_tplg_filename; |
| 704 | const char *dmic_str; |
| 705 | int dmic_num; |
| 706 | |
| 707 | /* first check NHLT for DMICs */ |
| 708 | dmic_num = check_nhlt_dmic(sdev); |
| 709 | |
| 710 | /* allow for module parameter override */ |
Pierre-Louis Bossart | 026370c | 2021-02-08 17:33:36 -0600 | [diff] [blame] | 711 | if (hda_dmic_num != -1) { |
| 712 | dev_dbg(sdev->dev, |
| 713 | "overriding DMICs detected in NHLT tables %d by kernel param %d\n", |
| 714 | dmic_num, hda_dmic_num); |
Pierre-Louis Bossart | 7aecf59 | 2021-02-08 17:33:34 -0600 | [diff] [blame] | 715 | dmic_num = hda_dmic_num; |
Pierre-Louis Bossart | 026370c | 2021-02-08 17:33:36 -0600 | [diff] [blame] | 716 | } |
Pierre-Louis Bossart | 7aecf59 | 2021-02-08 17:33:34 -0600 | [diff] [blame] | 717 | |
| 718 | switch (dmic_num) { |
| 719 | case 1: |
| 720 | dmic_str = "-1ch"; |
| 721 | break; |
| 722 | case 2: |
| 723 | dmic_str = "-2ch"; |
| 724 | break; |
| 725 | case 3: |
| 726 | dmic_str = "-3ch"; |
| 727 | break; |
| 728 | case 4: |
| 729 | dmic_str = "-4ch"; |
| 730 | break; |
| 731 | default: |
| 732 | dmic_num = 0; |
| 733 | dmic_str = ""; |
| 734 | break; |
| 735 | } |
| 736 | |
| 737 | fixed_tplg_filename = fixup_tplg_name(sdev, default_tplg_filename, |
| 738 | idisp_str, dmic_str); |
| 739 | if (!fixed_tplg_filename) |
| 740 | return -ENOMEM; |
| 741 | |
| 742 | dev_info(sdev->dev, "DMICs detected in NHLT tables: %d\n", dmic_num); |
| 743 | *dmic_found = dmic_num; |
| 744 | *tplg_filename = fixed_tplg_filename; |
| 745 | |
| 746 | return 0; |
| 747 | } |
Zhu Yingjiang | be1b577 | 2019-05-24 14:09:24 -0500 | [diff] [blame] | 748 | #endif |
| 749 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 750 | static int hda_init_caps(struct snd_sof_dev *sdev) |
| 751 | { |
| 752 | struct hdac_bus *bus = sof_to_bus(sdev); |
Pierre-Louis Bossart | 51dfed1 | 2020-03-25 16:50:18 -0500 | [diff] [blame] | 753 | struct snd_sof_pdata *pdata = sdev->pdata; |
Zhu Yingjiang | be1b577 | 2019-05-24 14:09:24 -0500 | [diff] [blame] | 754 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 755 | struct hdac_ext_link *hlink; |
Zhu Yingjiang | be1b577 | 2019-05-24 14:09:24 -0500 | [diff] [blame] | 756 | #endif |
Pierre-Louis Bossart | 51dfed1 | 2020-03-25 16:50:18 -0500 | [diff] [blame] | 757 | struct sof_intel_hda_dev *hdev = pdata->hw_pdata; |
| 758 | u32 link_mask; |
Zhu Yingjiang | be1b577 | 2019-05-24 14:09:24 -0500 | [diff] [blame] | 759 | int ret = 0; |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 760 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 761 | /* check if dsp is there */ |
| 762 | if (bus->ppcap) |
| 763 | dev_dbg(sdev->dev, "PP capability, will probe DSP later.\n"); |
| 764 | |
Ranjani Sridharan | cc35273 | 2019-08-06 15:19:58 -0700 | [diff] [blame] | 765 | /* Init HDA controller after i915 init */ |
Zhu Yingjiang | be1b577 | 2019-05-24 14:09:24 -0500 | [diff] [blame] | 766 | ret = hda_dsp_ctrl_init_chip(sdev, true); |
| 767 | if (ret < 0) { |
| 768 | dev_err(bus->dev, "error: init chip failed with ret: %d\n", |
| 769 | ret); |
| 770 | return ret; |
| 771 | } |
| 772 | |
Pierre-Louis Bossart | 51dfed1 | 2020-03-25 16:50:18 -0500 | [diff] [blame] | 773 | /* scan SoundWire capabilities exposed by DSDT */ |
| 774 | ret = hda_sdw_acpi_scan(sdev); |
| 775 | if (ret < 0) { |
Pierre-Louis Bossart | 0d4453e | 2020-04-09 13:44:14 -0500 | [diff] [blame] | 776 | dev_dbg(sdev->dev, "skipping SoundWire, not detected with ACPI scan\n"); |
Pierre-Louis Bossart | b9ddd81 | 2020-03-25 16:50:21 -0500 | [diff] [blame] | 777 | goto skip_soundwire; |
Pierre-Louis Bossart | 51dfed1 | 2020-03-25 16:50:18 -0500 | [diff] [blame] | 778 | } |
| 779 | |
| 780 | link_mask = hdev->info.link_mask; |
| 781 | if (!link_mask) { |
Pierre-Louis Bossart | b9ddd81 | 2020-03-25 16:50:21 -0500 | [diff] [blame] | 782 | dev_dbg(sdev->dev, "skipping SoundWire, no links enabled\n"); |
| 783 | goto skip_soundwire; |
Pierre-Louis Bossart | 51dfed1 | 2020-03-25 16:50:18 -0500 | [diff] [blame] | 784 | } |
| 785 | |
Pierre-Louis Bossart | b9ddd81 | 2020-03-25 16:50:21 -0500 | [diff] [blame] | 786 | /* |
| 787 | * probe/allocate SoundWire resources. |
| 788 | * The hardware configuration takes place in hda_sdw_startup |
| 789 | * after power rails are enabled. |
| 790 | * It's entirely possible to have a mix of I2S/DMIC/SoundWire |
| 791 | * devices, so we allocate the resources in all cases. |
| 792 | */ |
| 793 | ret = hda_sdw_probe(sdev); |
| 794 | if (ret < 0) { |
| 795 | dev_err(sdev->dev, "error: SoundWire probe error\n"); |
| 796 | return ret; |
| 797 | } |
| 798 | |
| 799 | skip_soundwire: |
| 800 | |
Zhu Yingjiang | be1b577 | 2019-05-24 14:09:24 -0500 | [diff] [blame] | 801 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 802 | if (bus->mlcap) |
| 803 | snd_hdac_ext_bus_get_ml_capabilities(bus); |
| 804 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 805 | /* create codec instances */ |
Ranjani Sridharan | 80acdd4 | 2019-12-04 15:15:52 -0600 | [diff] [blame] | 806 | hda_codec_probe_bus(sdev, hda_codec_use_common_hdmi); |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 807 | |
Kai Vehmanen | 0c75419 | 2020-01-20 18:01:16 +0200 | [diff] [blame] | 808 | if (!HDA_IDISP_CODEC(bus->codec_mask)) |
Kai Vehmanen | 71cc8ab | 2020-02-20 19:10:28 +0200 | [diff] [blame] | 809 | hda_codec_i915_display_power(sdev, false); |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 810 | |
| 811 | /* |
| 812 | * we are done probing so decrement link counts |
| 813 | */ |
| 814 | list_for_each_entry(hlink, &bus->hlink_list, list) |
| 815 | snd_hdac_ext_bus_link_put(bus, hlink); |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 816 | #endif |
Zhu Yingjiang | be1b577 | 2019-05-24 14:09:24 -0500 | [diff] [blame] | 817 | return 0; |
| 818 | } |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 819 | |
Kai Vehmanen | fd57239 | 2021-11-05 13:16:55 +0200 | [diff] [blame] | 820 | static void hda_check_for_state_change(struct snd_sof_dev *sdev) |
| 821 | { |
| 822 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) |
| 823 | struct hdac_bus *bus = sof_to_bus(sdev); |
| 824 | unsigned int codec_mask; |
| 825 | |
| 826 | codec_mask = snd_hdac_chip_readw(bus, STATESTS); |
| 827 | if (codec_mask) { |
| 828 | hda_codec_jack_check(sdev); |
| 829 | snd_hdac_chip_writew(bus, STATESTS, codec_mask); |
| 830 | } |
| 831 | #endif |
| 832 | } |
| 833 | |
Bard Liao | 7c11af9 | 2019-12-04 15:28:59 -0600 | [diff] [blame] | 834 | static irqreturn_t hda_dsp_interrupt_handler(int irq, void *context) |
| 835 | { |
| 836 | struct snd_sof_dev *sdev = context; |
| 837 | |
| 838 | /* |
| 839 | * Get global interrupt status. It includes all hardware interrupt |
| 840 | * sources in the Intel HD Audio controller. |
| 841 | */ |
| 842 | if (snd_sof_dsp_read(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTSTS) & |
| 843 | SOF_HDA_INTSTS_GIS) { |
| 844 | |
| 845 | /* disable GIE interrupt */ |
| 846 | snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, |
| 847 | SOF_HDA_INTCTL, |
| 848 | SOF_HDA_INT_GLOBAL_EN, |
| 849 | 0); |
| 850 | |
| 851 | return IRQ_WAKE_THREAD; |
| 852 | } |
| 853 | |
| 854 | return IRQ_NONE; |
| 855 | } |
| 856 | |
| 857 | static irqreturn_t hda_dsp_interrupt_thread(int irq, void *context) |
| 858 | { |
| 859 | struct snd_sof_dev *sdev = context; |
Bard Liao | 722ba5f | 2020-03-25 16:50:23 -0500 | [diff] [blame] | 860 | struct sof_intel_hda_dev *hdev = sdev->pdata->hw_pdata; |
Bard Liao | 7c11af9 | 2019-12-04 15:28:59 -0600 | [diff] [blame] | 861 | |
| 862 | /* deal with streams and controller first */ |
| 863 | if (hda_dsp_check_stream_irq(sdev)) |
| 864 | hda_dsp_stream_threaded_handler(irq, sdev); |
| 865 | |
| 866 | if (hda_dsp_check_ipc_irq(sdev)) |
| 867 | sof_ops(sdev)->irq_thread(irq, sdev); |
| 868 | |
Bard Liao | 722ba5f | 2020-03-25 16:50:23 -0500 | [diff] [blame] | 869 | if (hda_dsp_check_sdw_irq(sdev)) |
| 870 | hda_dsp_sdw_thread(irq, hdev->sdw); |
| 871 | |
Rander Wang | 90de328 | 2020-03-25 16:50:26 -0500 | [diff] [blame] | 872 | if (hda_sdw_check_wakeen_irq(sdev)) |
| 873 | hda_sdw_process_wakeen(sdev); |
| 874 | |
Kai Vehmanen | fd57239 | 2021-11-05 13:16:55 +0200 | [diff] [blame] | 875 | hda_check_for_state_change(sdev); |
| 876 | |
Bard Liao | 7c11af9 | 2019-12-04 15:28:59 -0600 | [diff] [blame] | 877 | /* enable GIE interrupt */ |
| 878 | snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, |
| 879 | SOF_HDA_INTCTL, |
| 880 | SOF_HDA_INT_GLOBAL_EN, |
| 881 | SOF_HDA_INT_GLOBAL_EN); |
| 882 | |
| 883 | return IRQ_HANDLED; |
| 884 | } |
| 885 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 886 | int hda_dsp_probe(struct snd_sof_dev *sdev) |
| 887 | { |
| 888 | struct pci_dev *pci = to_pci_dev(sdev->dev); |
| 889 | struct sof_intel_hda_dev *hdev; |
| 890 | struct hdac_bus *bus; |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 891 | const struct sof_intel_dsp_desc *chip; |
Zhu Yingjiang | be1b577 | 2019-05-24 14:09:24 -0500 | [diff] [blame] | 892 | int ret = 0; |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 893 | |
| 894 | /* |
| 895 | * detect DSP by checking class/subclass/prog-id information |
| 896 | * class=04 subclass 03 prog-if 00: no DSP, legacy driver is required |
| 897 | * class=04 subclass 01 prog-if 00: DSP is present |
| 898 | * (and may be required e.g. for DMIC or SSP support) |
| 899 | * class=04 subclass 03 prog-if 80: either of DSP or legacy mode works |
| 900 | */ |
| 901 | if (pci->class == 0x040300) { |
| 902 | dev_err(sdev->dev, "error: the DSP is not enabled on this platform, aborting probe\n"); |
| 903 | return -ENODEV; |
| 904 | } else if (pci->class != 0x040100 && pci->class != 0x040380) { |
| 905 | dev_err(sdev->dev, "error: unknown PCI class/subclass/prog-if 0x%06x found, aborting probe\n", pci->class); |
| 906 | return -ENODEV; |
| 907 | } |
| 908 | dev_info(sdev->dev, "DSP detected with PCI class/subclass/prog-if 0x%06x\n", pci->class); |
| 909 | |
| 910 | chip = get_chip_info(sdev->pdata); |
| 911 | if (!chip) { |
| 912 | dev_err(sdev->dev, "error: no such device supported, chip id:%x\n", |
| 913 | pci->device); |
| 914 | ret = -EIO; |
| 915 | goto err; |
| 916 | } |
| 917 | |
| 918 | hdev = devm_kzalloc(sdev->dev, sizeof(*hdev), GFP_KERNEL); |
| 919 | if (!hdev) |
| 920 | return -ENOMEM; |
| 921 | sdev->pdata->hw_pdata = hdev; |
| 922 | hdev->desc = chip; |
| 923 | |
| 924 | hdev->dmic_dev = platform_device_register_data(sdev->dev, "dmic-codec", |
| 925 | PLATFORM_DEVID_NONE, |
| 926 | NULL, 0); |
| 927 | if (IS_ERR(hdev->dmic_dev)) { |
| 928 | dev_err(sdev->dev, "error: failed to create DMIC device\n"); |
| 929 | return PTR_ERR(hdev->dmic_dev); |
| 930 | } |
| 931 | |
| 932 | /* |
| 933 | * use position update IPC if either it is forced |
| 934 | * or we don't have other choice |
| 935 | */ |
| 936 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_DEBUG_FORCE_IPC_POSITION) |
| 937 | hdev->no_ipc_position = 0; |
| 938 | #else |
| 939 | hdev->no_ipc_position = sof_ops(sdev)->pcm_pointer ? 1 : 0; |
| 940 | #endif |
| 941 | |
| 942 | /* set up HDA base */ |
| 943 | bus = sof_to_bus(sdev); |
| 944 | ret = hda_init(sdev); |
| 945 | if (ret < 0) |
| 946 | goto hdac_bus_unmap; |
| 947 | |
| 948 | /* DSP base */ |
| 949 | sdev->bar[HDA_DSP_BAR] = pci_ioremap_bar(pci, HDA_DSP_BAR); |
| 950 | if (!sdev->bar[HDA_DSP_BAR]) { |
| 951 | dev_err(sdev->dev, "error: ioremap error\n"); |
| 952 | ret = -ENXIO; |
| 953 | goto hdac_bus_unmap; |
| 954 | } |
| 955 | |
| 956 | sdev->mmio_bar = HDA_DSP_BAR; |
| 957 | sdev->mailbox_bar = HDA_DSP_BAR; |
| 958 | |
| 959 | /* allow 64bit DMA address if supported by H/W */ |
Takashi Iwai | ab152af | 2021-01-14 14:33:36 +0100 | [diff] [blame] | 960 | if (dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(64))) { |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 961 | dev_dbg(sdev->dev, "DMA mask is 32 bit\n"); |
Takashi Iwai | ab152af | 2021-01-14 14:33:36 +0100 | [diff] [blame] | 962 | dma_set_mask_and_coherent(&pci->dev, DMA_BIT_MASK(32)); |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 963 | } |
| 964 | |
| 965 | /* init streams */ |
| 966 | ret = hda_dsp_stream_init(sdev); |
| 967 | if (ret < 0) { |
| 968 | dev_err(sdev->dev, "error: failed to init streams\n"); |
| 969 | /* |
| 970 | * not all errors are due to memory issues, but trying |
| 971 | * to free everything does not harm |
| 972 | */ |
| 973 | goto free_streams; |
| 974 | } |
| 975 | |
| 976 | /* |
| 977 | * register our IRQ |
| 978 | * let's try to enable msi firstly |
| 979 | * if it fails, use legacy interrupt mode |
Guennadi Liakhovetski | 672ff5e | 2019-07-22 09:13:57 -0500 | [diff] [blame] | 980 | * TODO: support msi multiple vectors |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 981 | */ |
Pierre-Louis Bossart | bb67dd1 | 2019-08-06 12:06:03 -0500 | [diff] [blame] | 982 | if (hda_use_msi && pci_alloc_irq_vectors(pci, 1, 1, PCI_IRQ_MSI) > 0) { |
Guennadi Liakhovetski | 672ff5e | 2019-07-22 09:13:57 -0500 | [diff] [blame] | 983 | dev_info(sdev->dev, "use msi interrupt mode\n"); |
Bard Liao | 7c11af9 | 2019-12-04 15:28:59 -0600 | [diff] [blame] | 984 | sdev->ipc_irq = pci_irq_vector(pci, 0); |
Guennadi Liakhovetski | 672ff5e | 2019-07-22 09:13:57 -0500 | [diff] [blame] | 985 | /* initialised to "false" by kzalloc() */ |
| 986 | sdev->msi_enabled = true; |
| 987 | } |
| 988 | |
| 989 | if (!sdev->msi_enabled) { |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 990 | dev_info(sdev->dev, "use legacy interrupt mode\n"); |
| 991 | /* |
| 992 | * in IO-APIC mode, hda->irq and ipc_irq are using the same |
| 993 | * irq number of pci->irq |
| 994 | */ |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 995 | sdev->ipc_irq = pci->irq; |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 996 | } |
| 997 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 998 | dev_dbg(sdev->dev, "using IPC IRQ %d\n", sdev->ipc_irq); |
Bard Liao | 7c11af9 | 2019-12-04 15:28:59 -0600 | [diff] [blame] | 999 | ret = request_threaded_irq(sdev->ipc_irq, hda_dsp_interrupt_handler, |
| 1000 | hda_dsp_interrupt_thread, |
| 1001 | IRQF_SHARED, "AudioDSP", sdev); |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 1002 | if (ret < 0) { |
| 1003 | dev_err(sdev->dev, "error: failed to register IPC IRQ %d\n", |
| 1004 | sdev->ipc_irq); |
Bard Liao | 7c11af9 | 2019-12-04 15:28:59 -0600 | [diff] [blame] | 1005 | goto free_irq_vector; |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 1006 | } |
| 1007 | |
| 1008 | pci_set_master(pci); |
| 1009 | synchronize_irq(pci->irq); |
| 1010 | |
| 1011 | /* |
| 1012 | * clear TCSEL to clear playback on some HD Audio |
| 1013 | * codecs. PCI TCSEL is defined in the Intel manuals. |
| 1014 | */ |
| 1015 | snd_sof_pci_update_bits(sdev, PCI_TCSEL, 0x07, 0); |
| 1016 | |
| 1017 | /* init HDA capabilities */ |
| 1018 | ret = hda_init_caps(sdev); |
| 1019 | if (ret < 0) |
| 1020 | goto free_ipc_irq; |
| 1021 | |
Zhu Yingjiang | 1f5253b | 2019-05-22 11:21:40 -0500 | [diff] [blame] | 1022 | /* enable ppcap interrupt */ |
| 1023 | hda_dsp_ctrl_ppcap_enable(sdev, true); |
| 1024 | hda_dsp_ctrl_ppcap_int_enable(sdev, true); |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 1025 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 1026 | /* set default mailbox offset for FW ready message */ |
| 1027 | sdev->dsp_box.offset = HDA_DSP_MBOX_UPLINK_OFFSET; |
| 1028 | |
Ranjani Sridharan | 63e51fd3 | 2020-01-29 16:07:25 -0600 | [diff] [blame] | 1029 | INIT_DELAYED_WORK(&hdev->d0i3_work, hda_dsp_d0i3_work); |
| 1030 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 1031 | return 0; |
| 1032 | |
| 1033 | free_ipc_irq: |
| 1034 | free_irq(sdev->ipc_irq, sdev); |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 1035 | free_irq_vector: |
| 1036 | if (sdev->msi_enabled) |
| 1037 | pci_free_irq_vectors(pci); |
| 1038 | free_streams: |
| 1039 | hda_dsp_stream_free(sdev); |
| 1040 | /* dsp_unmap: not currently used */ |
| 1041 | iounmap(sdev->bar[HDA_DSP_BAR]); |
| 1042 | hdac_bus_unmap: |
Pierre-Louis Bossart | 5bb0ecd | 2021-03-01 18:34:10 -0600 | [diff] [blame] | 1043 | platform_device_unregister(hdev->dmic_dev); |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 1044 | iounmap(bus->remap_addr); |
Kai Vehmanen | af7aae1 | 2020-02-06 22:02:23 +0200 | [diff] [blame] | 1045 | hda_codec_i915_exit(sdev); |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 1046 | err: |
| 1047 | return ret; |
| 1048 | } |
| 1049 | |
| 1050 | int hda_dsp_remove(struct snd_sof_dev *sdev) |
| 1051 | { |
| 1052 | struct sof_intel_hda_dev *hda = sdev->pdata->hw_pdata; |
| 1053 | struct hdac_bus *bus = sof_to_bus(sdev); |
| 1054 | struct pci_dev *pci = to_pci_dev(sdev->dev); |
| 1055 | const struct sof_intel_dsp_desc *chip = hda->desc; |
| 1056 | |
Ranjani Sridharan | 63e51fd3 | 2020-01-29 16:07:25 -0600 | [diff] [blame] | 1057 | /* cancel any attempt for DSP D0I3 */ |
| 1058 | cancel_delayed_work_sync(&hda->d0i3_work); |
| 1059 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 1060 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) |
| 1061 | /* codec removal, invoke bus_device_remove */ |
| 1062 | snd_hdac_ext_bus_device_remove(bus); |
| 1063 | #endif |
| 1064 | |
Pierre-Louis Bossart | 51dfed1 | 2020-03-25 16:50:18 -0500 | [diff] [blame] | 1065 | hda_sdw_exit(sdev); |
| 1066 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 1067 | if (!IS_ERR_OR_NULL(hda->dmic_dev)) |
| 1068 | platform_device_unregister(hda->dmic_dev); |
| 1069 | |
| 1070 | /* disable DSP IRQ */ |
| 1071 | snd_sof_dsp_update_bits(sdev, HDA_DSP_PP_BAR, SOF_HDA_REG_PP_PPCTL, |
| 1072 | SOF_HDA_PPCTL_PIE, 0); |
| 1073 | |
| 1074 | /* disable CIE and GIE interrupts */ |
| 1075 | snd_sof_dsp_update_bits(sdev, HDA_DSP_HDA_BAR, SOF_HDA_INTCTL, |
| 1076 | SOF_HDA_INT_CTRL_EN | SOF_HDA_INT_GLOBAL_EN, 0); |
| 1077 | |
| 1078 | /* disable cores */ |
| 1079 | if (chip) |
Bard Liao | f6c246e | 2021-01-28 11:38:46 +0200 | [diff] [blame] | 1080 | snd_sof_dsp_core_power_down(sdev, chip->host_managed_cores_mask); |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 1081 | |
| 1082 | /* disable DSP */ |
| 1083 | snd_sof_dsp_update_bits(sdev, HDA_DSP_PP_BAR, SOF_HDA_REG_PP_PPCTL, |
| 1084 | SOF_HDA_PPCTL_GPROCEN, 0); |
| 1085 | |
| 1086 | free_irq(sdev->ipc_irq, sdev); |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 1087 | if (sdev->msi_enabled) |
| 1088 | pci_free_irq_vectors(pci); |
| 1089 | |
| 1090 | hda_dsp_stream_free(sdev); |
| 1091 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) |
| 1092 | snd_hdac_link_free_all(bus); |
| 1093 | #endif |
| 1094 | |
| 1095 | iounmap(sdev->bar[HDA_DSP_BAR]); |
| 1096 | iounmap(bus->remap_addr); |
| 1097 | |
| 1098 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) |
| 1099 | snd_hdac_ext_bus_exit(bus); |
| 1100 | #endif |
| 1101 | hda_codec_i915_exit(sdev); |
| 1102 | |
| 1103 | return 0; |
| 1104 | } |
| 1105 | |
Daniel Baluta | 285880a | 2019-12-04 15:15:53 -0600 | [diff] [blame] | 1106 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA) |
| 1107 | static int hda_generic_machine_select(struct snd_sof_dev *sdev) |
| 1108 | { |
| 1109 | struct hdac_bus *bus = sof_to_bus(sdev); |
| 1110 | struct snd_soc_acpi_mach_params *mach_params; |
| 1111 | struct snd_soc_acpi_mach *hda_mach; |
| 1112 | struct snd_sof_pdata *pdata = sdev->pdata; |
| 1113 | const char *tplg_filename; |
| 1114 | const char *idisp_str; |
Daniel Baluta | 285880a | 2019-12-04 15:15:53 -0600 | [diff] [blame] | 1115 | int dmic_num = 0; |
| 1116 | int codec_num = 0; |
Pierre-Louis Bossart | 7aecf59 | 2021-02-08 17:33:34 -0600 | [diff] [blame] | 1117 | int ret; |
Daniel Baluta | 285880a | 2019-12-04 15:15:53 -0600 | [diff] [blame] | 1118 | int i; |
| 1119 | |
| 1120 | /* codec detection */ |
| 1121 | if (!bus->codec_mask) { |
| 1122 | dev_info(bus->dev, "no hda codecs found!\n"); |
| 1123 | } else { |
| 1124 | dev_info(bus->dev, "hda codecs found, mask %lx\n", |
| 1125 | bus->codec_mask); |
| 1126 | |
| 1127 | for (i = 0; i < HDA_MAX_CODECS; i++) { |
| 1128 | if (bus->codec_mask & (1 << i)) |
| 1129 | codec_num++; |
| 1130 | } |
| 1131 | |
| 1132 | /* |
| 1133 | * If no machine driver is found, then: |
| 1134 | * |
Kai Vehmanen | 71cc8ab | 2020-02-20 19:10:28 +0200 | [diff] [blame] | 1135 | * generic hda machine driver can handle: |
| 1136 | * - one HDMI codec, and/or |
| 1137 | * - one external HDAudio codec |
Daniel Baluta | 285880a | 2019-12-04 15:15:53 -0600 | [diff] [blame] | 1138 | */ |
Kai Vehmanen | 71cc8ab | 2020-02-20 19:10:28 +0200 | [diff] [blame] | 1139 | if (!pdata->machine && codec_num <= 2) { |
Daniel Baluta | 285880a | 2019-12-04 15:15:53 -0600 | [diff] [blame] | 1140 | hda_mach = snd_soc_acpi_intel_hda_machines; |
| 1141 | |
Daniel Baluta | 285880a | 2019-12-04 15:15:53 -0600 | [diff] [blame] | 1142 | dev_info(bus->dev, "using HDA machine driver %s now\n", |
| 1143 | hda_mach->drv_name); |
| 1144 | |
Kai Vehmanen | 71cc8ab | 2020-02-20 19:10:28 +0200 | [diff] [blame] | 1145 | if (codec_num == 1 && HDA_IDISP_CODEC(bus->codec_mask)) |
Daniel Baluta | 285880a | 2019-12-04 15:15:53 -0600 | [diff] [blame] | 1146 | idisp_str = "-idisp"; |
| 1147 | else |
| 1148 | idisp_str = ""; |
| 1149 | |
Pierre-Louis Bossart | 7aecf59 | 2021-02-08 17:33:34 -0600 | [diff] [blame] | 1150 | /* topology: use the info from hda_machines */ |
| 1151 | tplg_filename = hda_mach->sof_tplg_filename; |
| 1152 | ret = dmic_topology_fixup(sdev, &tplg_filename, idisp_str, &dmic_num); |
| 1153 | if (ret < 0) |
| 1154 | return ret; |
Daniel Baluta | 285880a | 2019-12-04 15:15:53 -0600 | [diff] [blame] | 1155 | |
Pierre-Louis Bossart | 7aecf59 | 2021-02-08 17:33:34 -0600 | [diff] [blame] | 1156 | hda_mach->mach_params.dmic_num = dmic_num; |
Daniel Baluta | 285880a | 2019-12-04 15:15:53 -0600 | [diff] [blame] | 1157 | pdata->machine = hda_mach; |
| 1158 | pdata->tplg_filename = tplg_filename; |
Pierre-Louis Bossart | 61bef9e | 2021-07-26 13:28:55 -0500 | [diff] [blame] | 1159 | |
| 1160 | if (codec_num == 2) { |
| 1161 | /* |
| 1162 | * Prevent SoundWire links from starting when an external |
| 1163 | * HDaudio codec is used |
| 1164 | */ |
| 1165 | hda_mach->mach_params.link_mask = 0; |
| 1166 | } |
Daniel Baluta | 285880a | 2019-12-04 15:15:53 -0600 | [diff] [blame] | 1167 | } |
| 1168 | } |
| 1169 | |
| 1170 | /* used by hda machine driver to create dai links */ |
| 1171 | if (pdata->machine) { |
| 1172 | mach_params = (struct snd_soc_acpi_mach_params *) |
| 1173 | &pdata->machine->mach_params; |
| 1174 | mach_params->codec_mask = bus->codec_mask; |
| 1175 | mach_params->common_hdmi_codec_drv = hda_codec_use_common_hdmi; |
Daniel Baluta | 285880a | 2019-12-04 15:15:53 -0600 | [diff] [blame] | 1176 | } |
| 1177 | |
| 1178 | return 0; |
| 1179 | } |
| 1180 | #else |
| 1181 | static int hda_generic_machine_select(struct snd_sof_dev *sdev) |
| 1182 | { |
| 1183 | return 0; |
| 1184 | } |
| 1185 | #endif |
| 1186 | |
Pierre-Louis Bossart | b9ddd81 | 2020-03-25 16:50:21 -0500 | [diff] [blame] | 1187 | #if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE) |
| 1188 | /* Check if all Slaves defined on the link can be found */ |
| 1189 | static bool link_slaves_found(struct snd_sof_dev *sdev, |
| 1190 | const struct snd_soc_acpi_link_adr *link, |
| 1191 | struct sdw_intel_ctx *sdw) |
| 1192 | { |
| 1193 | struct hdac_bus *bus = sof_to_bus(sdev); |
| 1194 | struct sdw_intel_slave_id *ids = sdw->ids; |
| 1195 | int num_slaves = sdw->num_slaves; |
| 1196 | unsigned int part_id, link_id, unique_id, mfg_id; |
Pierre-Louis Bossart | 6f5d506 | 2021-02-08 17:33:33 -0600 | [diff] [blame] | 1197 | int i, j, k; |
Pierre-Louis Bossart | b9ddd81 | 2020-03-25 16:50:21 -0500 | [diff] [blame] | 1198 | |
| 1199 | for (i = 0; i < link->num_adr; i++) { |
| 1200 | u64 adr = link->adr_d[i].adr; |
Pierre-Louis Bossart | 6f5d506 | 2021-02-08 17:33:33 -0600 | [diff] [blame] | 1201 | int reported_part_count = 0; |
Pierre-Louis Bossart | b9ddd81 | 2020-03-25 16:50:21 -0500 | [diff] [blame] | 1202 | |
| 1203 | mfg_id = SDW_MFG_ID(adr); |
| 1204 | part_id = SDW_PART_ID(adr); |
| 1205 | link_id = SDW_DISCO_LINK_ID(adr); |
Pierre-Louis Bossart | 6f5d506 | 2021-02-08 17:33:33 -0600 | [diff] [blame] | 1206 | |
Pierre-Louis Bossart | b9ddd81 | 2020-03-25 16:50:21 -0500 | [diff] [blame] | 1207 | for (j = 0; j < num_slaves; j++) { |
Pierre-Louis Bossart | 6f5d506 | 2021-02-08 17:33:33 -0600 | [diff] [blame] | 1208 | /* find out how many identical parts were reported on that link */ |
| 1209 | if (ids[j].link_id == link_id && |
| 1210 | ids[j].id.part_id == part_id && |
| 1211 | ids[j].id.mfg_id == mfg_id) |
| 1212 | reported_part_count++; |
| 1213 | } |
| 1214 | |
| 1215 | for (j = 0; j < num_slaves; j++) { |
| 1216 | int expected_part_count = 0; |
| 1217 | |
Pierre-Louis Bossart | b9ddd81 | 2020-03-25 16:50:21 -0500 | [diff] [blame] | 1218 | if (ids[j].link_id != link_id || |
| 1219 | ids[j].id.part_id != part_id || |
| 1220 | ids[j].id.mfg_id != mfg_id) |
| 1221 | continue; |
Pierre-Louis Bossart | 6f5d506 | 2021-02-08 17:33:33 -0600 | [diff] [blame] | 1222 | |
| 1223 | /* find out how many identical parts are expected */ |
| 1224 | for (k = 0; k < link->num_adr; k++) { |
Pierre-Louis Bossart | ad83912 | 2021-05-11 16:36:59 -0500 | [diff] [blame] | 1225 | u64 adr2 = link->adr_d[k].adr; |
Pierre-Louis Bossart | 6f5d506 | 2021-02-08 17:33:33 -0600 | [diff] [blame] | 1226 | unsigned int part_id2, link_id2, mfg_id2; |
| 1227 | |
| 1228 | mfg_id2 = SDW_MFG_ID(adr2); |
| 1229 | part_id2 = SDW_PART_ID(adr2); |
| 1230 | link_id2 = SDW_DISCO_LINK_ID(adr2); |
| 1231 | |
| 1232 | if (link_id2 == link_id && |
| 1233 | part_id2 == part_id && |
| 1234 | mfg_id2 == mfg_id) |
| 1235 | expected_part_count++; |
| 1236 | } |
| 1237 | |
| 1238 | if (reported_part_count == expected_part_count) { |
| 1239 | /* |
| 1240 | * we have to check unique id |
| 1241 | * if there is more than one |
| 1242 | * Slave on the link |
| 1243 | */ |
| 1244 | unique_id = SDW_UNIQUE_ID(adr); |
| 1245 | if (reported_part_count == 1 || |
| 1246 | ids[j].id.unique_id == unique_id) { |
| 1247 | dev_dbg(bus->dev, "found %x at link %d\n", |
| 1248 | part_id, link_id); |
| 1249 | break; |
| 1250 | } |
| 1251 | } else { |
| 1252 | dev_dbg(bus->dev, "part %x reported %d expected %d on link %d, skipping\n", |
| 1253 | part_id, reported_part_count, expected_part_count, link_id); |
Pierre-Louis Bossart | b9ddd81 | 2020-03-25 16:50:21 -0500 | [diff] [blame] | 1254 | } |
| 1255 | } |
| 1256 | if (j == num_slaves) { |
| 1257 | dev_dbg(bus->dev, |
| 1258 | "Slave %x not found\n", |
| 1259 | part_id); |
| 1260 | return false; |
| 1261 | } |
| 1262 | } |
| 1263 | return true; |
| 1264 | } |
| 1265 | |
| 1266 | static int hda_sdw_machine_select(struct snd_sof_dev *sdev) |
| 1267 | { |
| 1268 | struct snd_sof_pdata *pdata = sdev->pdata; |
| 1269 | const struct snd_soc_acpi_link_adr *link; |
Pierre-Louis Bossart | b9ddd81 | 2020-03-25 16:50:21 -0500 | [diff] [blame] | 1270 | struct snd_soc_acpi_mach *mach; |
| 1271 | struct sof_intel_hda_dev *hdev; |
| 1272 | u32 link_mask; |
| 1273 | int i; |
| 1274 | |
| 1275 | hdev = pdata->hw_pdata; |
| 1276 | link_mask = hdev->info.link_mask; |
| 1277 | |
| 1278 | /* |
| 1279 | * Select SoundWire machine driver if needed using the |
| 1280 | * alternate tables. This case deals with SoundWire-only |
| 1281 | * machines, for mixed cases with I2C/I2S the detection relies |
| 1282 | * on the HID list. |
| 1283 | */ |
| 1284 | if (link_mask && !pdata->machine) { |
| 1285 | for (mach = pdata->desc->alt_machines; |
| 1286 | mach && mach->link_mask; mach++) { |
randerwang | 7d1952b | 2020-05-15 16:59:55 +0300 | [diff] [blame] | 1287 | /* |
| 1288 | * On some platforms such as Up Extreme all links |
| 1289 | * are enabled but only one link can be used by |
| 1290 | * external codec. Instead of exact match of two masks, |
| 1291 | * first check whether link_mask of mach is subset of |
| 1292 | * link_mask supported by hw and then go on searching |
| 1293 | * link_adr |
| 1294 | */ |
| 1295 | if (~link_mask & mach->link_mask) |
Pierre-Louis Bossart | b9ddd81 | 2020-03-25 16:50:21 -0500 | [diff] [blame] | 1296 | continue; |
| 1297 | |
| 1298 | /* No need to match adr if there is no links defined */ |
| 1299 | if (!mach->links) |
| 1300 | break; |
| 1301 | |
| 1302 | link = mach->links; |
| 1303 | for (i = 0; i < hdev->info.count && link->num_adr; |
| 1304 | i++, link++) { |
| 1305 | /* |
| 1306 | * Try next machine if any expected Slaves |
| 1307 | * are not found on this link. |
| 1308 | */ |
| 1309 | if (!link_slaves_found(sdev, link, hdev->sdw)) |
| 1310 | break; |
| 1311 | } |
| 1312 | /* Found if all Slaves are checked */ |
| 1313 | if (i == hdev->info.count || !link->num_adr) |
| 1314 | break; |
| 1315 | } |
| 1316 | if (mach && mach->link_mask) { |
Pierre-Louis Bossart | 7aecf59 | 2021-02-08 17:33:34 -0600 | [diff] [blame] | 1317 | int dmic_num = 0; |
| 1318 | |
Pierre-Louis Bossart | b9ddd81 | 2020-03-25 16:50:21 -0500 | [diff] [blame] | 1319 | pdata->machine = mach; |
| 1320 | mach->mach_params.links = mach->links; |
| 1321 | mach->mach_params.link_mask = mach->link_mask; |
| 1322 | mach->mach_params.platform = dev_name(sdev->dev); |
Libin Yang | 7da99ef | 2021-01-25 09:04:58 +0200 | [diff] [blame] | 1323 | if (mach->sof_fw_filename) |
| 1324 | pdata->fw_filename = mach->sof_fw_filename; |
| 1325 | else |
| 1326 | pdata->fw_filename = pdata->desc->default_fw_filename; |
Pierre-Louis Bossart | b9ddd81 | 2020-03-25 16:50:21 -0500 | [diff] [blame] | 1327 | pdata->tplg_filename = mach->sof_tplg_filename; |
Pierre-Louis Bossart | 7aecf59 | 2021-02-08 17:33:34 -0600 | [diff] [blame] | 1328 | |
| 1329 | /* |
| 1330 | * DMICs use up to 4 pins and are typically pin-muxed with SoundWire |
| 1331 | * link 2 and 3, thus we only try to enable dmics if all conditions |
| 1332 | * are true: |
| 1333 | * a) link 2 and 3 are not used by SoundWire |
| 1334 | * b) the NHLT table reports the presence of microphones |
| 1335 | */ |
| 1336 | if (!(mach->link_mask & GENMASK(3, 2))) { |
| 1337 | const char *tplg_filename = mach->sof_tplg_filename; |
| 1338 | int ret; |
| 1339 | |
| 1340 | ret = dmic_topology_fixup(sdev, &tplg_filename, "", &dmic_num); |
| 1341 | |
| 1342 | if (ret < 0) |
| 1343 | return ret; |
| 1344 | |
| 1345 | pdata->tplg_filename = tplg_filename; |
| 1346 | } |
| 1347 | mach->mach_params.dmic_num = dmic_num; |
| 1348 | |
| 1349 | dev_dbg(sdev->dev, |
| 1350 | "SoundWire machine driver %s topology %s\n", |
| 1351 | mach->drv_name, |
| 1352 | pdata->tplg_filename); |
Pierre-Louis Bossart | b9ddd81 | 2020-03-25 16:50:21 -0500 | [diff] [blame] | 1353 | } else { |
| 1354 | dev_info(sdev->dev, |
| 1355 | "No SoundWire machine driver found\n"); |
| 1356 | } |
| 1357 | } |
| 1358 | |
| 1359 | return 0; |
| 1360 | } |
| 1361 | #else |
| 1362 | static int hda_sdw_machine_select(struct snd_sof_dev *sdev) |
| 1363 | { |
| 1364 | return 0; |
| 1365 | } |
| 1366 | #endif |
| 1367 | |
Daniel Baluta | 285880a | 2019-12-04 15:15:53 -0600 | [diff] [blame] | 1368 | void hda_set_mach_params(const struct snd_soc_acpi_mach *mach, |
Pierre-Louis Bossart | 17e9d6b | 2021-04-09 15:01:18 -0700 | [diff] [blame] | 1369 | struct snd_sof_dev *sdev) |
Daniel Baluta | 285880a | 2019-12-04 15:15:53 -0600 | [diff] [blame] | 1370 | { |
Pierre-Louis Bossart | 974cccf | 2021-04-09 15:01:19 -0700 | [diff] [blame] | 1371 | struct snd_sof_pdata *pdata = sdev->pdata; |
| 1372 | const struct sof_dev_desc *desc = pdata->desc; |
Daniel Baluta | 285880a | 2019-12-04 15:15:53 -0600 | [diff] [blame] | 1373 | struct snd_soc_acpi_mach_params *mach_params; |
| 1374 | |
| 1375 | mach_params = (struct snd_soc_acpi_mach_params *)&mach->mach_params; |
Pierre-Louis Bossart | 17e9d6b | 2021-04-09 15:01:18 -0700 | [diff] [blame] | 1376 | mach_params->platform = dev_name(sdev->dev); |
Pierre-Louis Bossart | 974cccf | 2021-04-09 15:01:19 -0700 | [diff] [blame] | 1377 | mach_params->num_dai_drivers = desc->ops->num_drv; |
| 1378 | mach_params->dai_drivers = desc->ops->drv; |
Daniel Baluta | 285880a | 2019-12-04 15:15:53 -0600 | [diff] [blame] | 1379 | } |
| 1380 | |
| 1381 | void hda_machine_select(struct snd_sof_dev *sdev) |
| 1382 | { |
| 1383 | struct snd_sof_pdata *sof_pdata = sdev->pdata; |
| 1384 | const struct sof_dev_desc *desc = sof_pdata->desc; |
| 1385 | struct snd_soc_acpi_mach *mach; |
| 1386 | |
| 1387 | mach = snd_soc_acpi_find_machine(desc->machines); |
| 1388 | if (mach) { |
Sathyanarayana Nujella | 5253a73 | 2020-08-21 14:56:00 -0500 | [diff] [blame] | 1389 | /* |
| 1390 | * If tplg file name is overridden, use it instead of |
| 1391 | * the one set in mach table |
| 1392 | */ |
| 1393 | if (!sof_pdata->tplg_filename) |
| 1394 | sof_pdata->tplg_filename = mach->sof_tplg_filename; |
| 1395 | |
Daniel Baluta | 285880a | 2019-12-04 15:15:53 -0600 | [diff] [blame] | 1396 | sof_pdata->machine = mach; |
Pierre-Louis Bossart | b9ddd81 | 2020-03-25 16:50:21 -0500 | [diff] [blame] | 1397 | |
| 1398 | if (mach->link_mask) { |
| 1399 | mach->mach_params.links = mach->links; |
| 1400 | mach->mach_params.link_mask = mach->link_mask; |
| 1401 | } |
Daniel Baluta | 285880a | 2019-12-04 15:15:53 -0600 | [diff] [blame] | 1402 | } |
| 1403 | |
| 1404 | /* |
Pierre-Louis Bossart | b9ddd81 | 2020-03-25 16:50:21 -0500 | [diff] [blame] | 1405 | * If I2S fails, try SoundWire |
| 1406 | */ |
| 1407 | hda_sdw_machine_select(sdev); |
| 1408 | |
| 1409 | /* |
Daniel Baluta | 285880a | 2019-12-04 15:15:53 -0600 | [diff] [blame] | 1410 | * Choose HDA generic machine driver if mach is NULL. |
| 1411 | * Otherwise, set certain mach params. |
| 1412 | */ |
| 1413 | hda_generic_machine_select(sdev); |
| 1414 | |
| 1415 | if (!sof_pdata->machine) |
| 1416 | dev_warn(sdev->dev, "warning: No matching ASoC machine driver found\n"); |
| 1417 | } |
| 1418 | |
Pierre-Louis Bossart | 194fe0f | 2021-03-01 18:31:22 -0600 | [diff] [blame] | 1419 | int hda_pci_intel_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) |
| 1420 | { |
| 1421 | int ret; |
| 1422 | |
| 1423 | ret = snd_intel_dsp_driver_probe(pci); |
| 1424 | if (ret != SND_INTEL_DSP_DRIVER_ANY && ret != SND_INTEL_DSP_DRIVER_SOF) { |
| 1425 | dev_dbg(&pci->dev, "SOF PCI driver not selected, aborting probe\n"); |
| 1426 | return -ENODEV; |
| 1427 | } |
| 1428 | |
| 1429 | return sof_pci_probe(pci, pci_id); |
| 1430 | } |
| 1431 | EXPORT_SYMBOL_NS(hda_pci_intel_probe, SND_SOC_SOF_INTEL_HDA_COMMON); |
| 1432 | |
Liam Girdwood | dd96dac | 2019-04-12 11:08:47 -0500 | [diff] [blame] | 1433 | MODULE_LICENSE("Dual BSD/GPL"); |
Pierre-Louis Bossart | 194fe0f | 2021-03-01 18:31:22 -0600 | [diff] [blame] | 1434 | MODULE_IMPORT_NS(SND_SOC_SOF_PCI_DEV); |
Pierre-Louis Bossart | 5bd216c | 2019-12-17 14:22:29 -0600 | [diff] [blame] | 1435 | MODULE_IMPORT_NS(SND_SOC_SOF_HDA_AUDIO_CODEC); |
| 1436 | MODULE_IMPORT_NS(SND_SOC_SOF_HDA_AUDIO_CODEC_I915); |
Pierre-Louis Bossart | 068ac0d | 2019-12-17 14:22:31 -0600 | [diff] [blame] | 1437 | MODULE_IMPORT_NS(SND_SOC_SOF_XTENSA); |
Pierre-Louis Bossart | 08c2a4b | 2021-03-01 18:31:24 -0600 | [diff] [blame] | 1438 | MODULE_IMPORT_NS(SND_INTEL_SOUNDWIRE_ACPI); |
Pierre-Louis Bossart | 1eb6293 | 2020-08-19 20:44:04 +0800 | [diff] [blame] | 1439 | MODULE_IMPORT_NS(SOUNDWIRE_INTEL_INIT); |