1e149ca29SPierre-Louis Bossart /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */ 2c16211d6SLiam Girdwood /* 3c16211d6SLiam Girdwood * This file is provided under a dual BSD/GPLv2 license. When using or 4c16211d6SLiam Girdwood * redistributing this file, you may do so under either license. 5c16211d6SLiam Girdwood * 6ea89a742SPierre-Louis Bossart * Copyright(c) 2018 Intel Corporation 7c16211d6SLiam Girdwood * 8c16211d6SLiam Girdwood * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com> 9c16211d6SLiam Girdwood */ 10c16211d6SLiam Girdwood 11c16211d6SLiam Girdwood #ifndef __INCLUDE_SOUND_SOF_H 12c16211d6SLiam Girdwood #define __INCLUDE_SOUND_SOF_H 13c16211d6SLiam Girdwood 14c16211d6SLiam Girdwood #include <linux/pci.h> 158017b8fdSLiam Girdwood #include <sound/soc.h> 16c16211d6SLiam Girdwood #include <sound/soc-acpi.h> 17c16211d6SLiam Girdwood 18c16211d6SLiam Girdwood struct snd_sof_dsp_ops; 19856601e5SPierre-Louis Bossart struct snd_sof_dev; 20c16211d6SLiam Girdwood 21fc179420SPeter Ujfalusi /** 22d41607d3SPeter Ujfalusi * enum sof_fw_state - DSP firmware state definitions 23fc179420SPeter Ujfalusi * @SOF_FW_BOOT_NOT_STARTED: firmware boot is not yet started 2459611370SPeter Ujfalusi * @SOF_DSPLESS_MODE: DSP is not used 25fc179420SPeter Ujfalusi * @SOF_FW_BOOT_PREPARE: preparing for boot (firmware loading for exaqmple) 26fc179420SPeter Ujfalusi * @SOF_FW_BOOT_IN_PROGRESS: firmware boot is in progress 27fc179420SPeter Ujfalusi * @SOF_FW_BOOT_FAILED: firmware boot failed 28fc179420SPeter Ujfalusi * @SOF_FW_BOOT_READY_FAILED: firmware booted but fw_ready op failed 29fc179420SPeter Ujfalusi * @SOF_FW_BOOT_READY_OK: firmware booted and fw_ready op passed 30fc179420SPeter Ujfalusi * @SOF_FW_BOOT_COMPLETE: firmware is booted up and functional 31fc179420SPeter Ujfalusi * @SOF_FW_CRASHED: firmware crashed after successful boot 32fc179420SPeter Ujfalusi */ 33d41607d3SPeter Ujfalusi enum sof_fw_state { 34fc179420SPeter Ujfalusi SOF_FW_BOOT_NOT_STARTED = 0, 3559611370SPeter Ujfalusi SOF_DSPLESS_MODE, 36fc179420SPeter Ujfalusi SOF_FW_BOOT_PREPARE, 37fc179420SPeter Ujfalusi SOF_FW_BOOT_IN_PROGRESS, 38fc179420SPeter Ujfalusi SOF_FW_BOOT_FAILED, 39fc179420SPeter Ujfalusi SOF_FW_BOOT_READY_FAILED, 40fc179420SPeter Ujfalusi SOF_FW_BOOT_READY_OK, 41fc179420SPeter Ujfalusi SOF_FW_BOOT_COMPLETE, 42fc179420SPeter Ujfalusi SOF_FW_CRASHED, 43fc179420SPeter Ujfalusi }; 44fc179420SPeter Ujfalusi 455fdc1242SPeter Ujfalusi /* DSP power states */ 465fdc1242SPeter Ujfalusi enum sof_dsp_power_states { 475fdc1242SPeter Ujfalusi SOF_DSP_PM_D0, 485fdc1242SPeter Ujfalusi SOF_DSP_PM_D1, 495fdc1242SPeter Ujfalusi SOF_DSP_PM_D2, 505fdc1242SPeter Ujfalusi SOF_DSP_PM_D3, 515fdc1242SPeter Ujfalusi }; 525fdc1242SPeter Ujfalusi 5315527feeSPierre-Louis Bossart /* Definitions for multiple IPCs */ 5415527feeSPierre-Louis Bossart enum sof_ipc_type { 556974f2cdSPeter Ujfalusi SOF_IPC_TYPE_3, 566974f2cdSPeter Ujfalusi SOF_IPC_TYPE_4, 5715527feeSPierre-Louis Bossart SOF_IPC_TYPE_COUNT 5815527feeSPierre-Louis Bossart }; 5915527feeSPierre-Louis Bossart 601162d267SPeter Ujfalusi struct sof_loadable_file_profile { 611162d267SPeter Ujfalusi enum sof_ipc_type ipc_type; 621162d267SPeter Ujfalusi 631162d267SPeter Ujfalusi const char *fw_path; 641162d267SPeter Ujfalusi const char *fw_path_postfix; 651162d267SPeter Ujfalusi const char *fw_name; 661162d267SPeter Ujfalusi const char *fw_lib_path; 671162d267SPeter Ujfalusi const char *fw_lib_path_postfix; 681162d267SPeter Ujfalusi const char *tplg_path; 691162d267SPeter Ujfalusi const char *tplg_name; 701162d267SPeter Ujfalusi }; 711162d267SPeter Ujfalusi 72c16211d6SLiam Girdwood /* 73c16211d6SLiam Girdwood * SOF Platform data. 74c16211d6SLiam Girdwood */ 75c16211d6SLiam Girdwood struct snd_sof_pdata { 76c16211d6SLiam Girdwood const char *name; 77c16211d6SLiam Girdwood const char *platform; 78c16211d6SLiam Girdwood 79ba2de401SRichard Fitzgerald /* 80ba2de401SRichard Fitzgerald * PCI SSID. As PCI does not define 0 as invalid, the subsystem_id_set 81ba2de401SRichard Fitzgerald * flag indicates that a value has been written to these members. 82ba2de401SRichard Fitzgerald */ 83ba2de401SRichard Fitzgerald unsigned short subsystem_vendor; 84ba2de401SRichard Fitzgerald unsigned short subsystem_device; 85ba2de401SRichard Fitzgerald bool subsystem_id_set; 86ba2de401SRichard Fitzgerald 87c16211d6SLiam Girdwood struct device *dev; 88c16211d6SLiam Girdwood 89c16211d6SLiam Girdwood /* 90c16211d6SLiam Girdwood * notification callback used if the hardware initialization 91c16211d6SLiam Girdwood * can take time or is handled in a workqueue. This callback 92c16211d6SLiam Girdwood * can be used by the caller to e.g. enable runtime_pm 93c16211d6SLiam Girdwood * or limit functionality until all low-level inits are 94c16211d6SLiam Girdwood * complete. 95c16211d6SLiam Girdwood */ 96c16211d6SLiam Girdwood void (*sof_probe_complete)(struct device *dev); 97c16211d6SLiam Girdwood 98c16211d6SLiam Girdwood /* descriptor */ 99c16211d6SLiam Girdwood const struct sof_dev_desc *desc; 100c16211d6SLiam Girdwood 1011162d267SPeter Ujfalusi /* platform's preferred IPC type and path overrides */ 1021162d267SPeter Ujfalusi struct sof_loadable_file_profile ipc_file_profile_base; 1031162d267SPeter Ujfalusi 104c16211d6SLiam Girdwood /* firmware and topology filenames */ 105c16211d6SLiam Girdwood const char *fw_filename_prefix; 106c16211d6SLiam Girdwood const char *fw_filename; 107c16211d6SLiam Girdwood const char *tplg_filename_prefix; 108c16211d6SLiam Girdwood const char *tplg_filename; 109c16211d6SLiam Girdwood 11025bbc0c5SPeter Ujfalusi /* loadable external libraries available under this directory */ 11125bbc0c5SPeter Ujfalusi const char *fw_lib_prefix; 11225bbc0c5SPeter Ujfalusi 113c16211d6SLiam Girdwood /* machine */ 114c16211d6SLiam Girdwood struct platform_device *pdev_mach; 115c16211d6SLiam Girdwood const struct snd_soc_acpi_mach *machine; 1166ace85b9SChunxu Li const struct snd_sof_of_mach *of_machine; 117c16211d6SLiam Girdwood 118c16211d6SLiam Girdwood void *hw_pdata; 11915527feeSPierre-Louis Bossart 12015527feeSPierre-Louis Bossart enum sof_ipc_type ipc_type; 121c16211d6SLiam Girdwood }; 122c16211d6SLiam Girdwood 123c16211d6SLiam Girdwood /* 124c16211d6SLiam Girdwood * Descriptor used for setting up SOF platform data. This is used when 125c16211d6SLiam Girdwood * ACPI/PCI data is missing or mapped differently. 126c16211d6SLiam Girdwood */ 127c16211d6SLiam Girdwood struct sof_dev_desc { 128c16211d6SLiam Girdwood /* list of machines using this configuration */ 129c16211d6SLiam Girdwood struct snd_soc_acpi_mach *machines; 1306ace85b9SChunxu Li struct snd_sof_of_mach *of_machines; 131c16211d6SLiam Girdwood 1321466327eSPierre-Louis Bossart /* alternate list of machines using this configuration */ 1331466327eSPierre-Louis Bossart struct snd_soc_acpi_mach *alt_machines; 1341466327eSPierre-Louis Bossart 13543437d04SDaniel Baluta bool use_acpi_target_states; 13643437d04SDaniel Baluta 137c16211d6SLiam Girdwood /* Platform resource indexes in BAR / ACPI resources. */ 138c16211d6SLiam Girdwood /* Must set to -1 if not used - add new items to end */ 139c16211d6SLiam Girdwood int resindex_lpe_base; 140c16211d6SLiam Girdwood int resindex_pcicfg_base; 141c16211d6SLiam Girdwood int resindex_imr_base; 142c16211d6SLiam Girdwood int irqindex_host_ipc; 143c16211d6SLiam Girdwood 144c16211d6SLiam Girdwood /* IPC timeouts in ms */ 145c16211d6SLiam Girdwood int ipc_timeout; 146c16211d6SLiam Girdwood int boot_timeout; 147c16211d6SLiam Girdwood 148c16211d6SLiam Girdwood /* chip information for dsp */ 149c16211d6SLiam Girdwood const void *chip_info; 150c16211d6SLiam Girdwood 151c16211d6SLiam Girdwood /* defaults for no codec mode */ 152c16211d6SLiam Girdwood const char *nocodec_tplg_filename; 153c16211d6SLiam Girdwood 1540cf8ff05SPierre-Louis Bossart /* information on supported IPCs */ 1550cf8ff05SPierre-Louis Bossart unsigned int ipc_supported_mask; 1560cf8ff05SPierre-Louis Bossart enum sof_ipc_type ipc_default; 1570cf8ff05SPierre-Louis Bossart 15859611370SPeter Ujfalusi /* The platform supports DSPless mode */ 15959611370SPeter Ujfalusi bool dspless_mode_supported; 16059611370SPeter Ujfalusi 16125bbc0c5SPeter Ujfalusi /* defaults paths for firmware, library and topology files */ 162a3757915SPierre-Louis Bossart const char *default_fw_path[SOF_IPC_TYPE_COUNT]; 16325bbc0c5SPeter Ujfalusi const char *default_lib_path[SOF_IPC_TYPE_COUNT]; 164a3757915SPierre-Louis Bossart const char *default_tplg_path[SOF_IPC_TYPE_COUNT]; 165c16211d6SLiam Girdwood 16603eec9b4SRanjani Sridharan /* default firmware name */ 167a97abb3cSPierre-Louis Bossart const char *default_fw_filename[SOF_IPC_TYPE_COUNT]; 16803eec9b4SRanjani Sridharan 1698bbc692dSKrzysztof Kozlowski const struct snd_sof_dsp_ops *ops; 170856601e5SPierre-Louis Bossart int (*ops_init)(struct snd_sof_dev *sdev); 171bc433fd7SRanjani Sridharan void (*ops_free)(struct snd_sof_dev *sdev); 172c16211d6SLiam Girdwood }; 173c16211d6SLiam Girdwood 174b951b51eSKeyon Jie int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd); 175bc619cfcSBrent Lu int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd); 176*1deba6e2SBrent Lu int sof_dai_get_tdm_slots(struct snd_soc_pcm_runtime *rtd); 177f805e7e0SRanjani Sridharan 178c16211d6SLiam Girdwood #endif 179