xref: /openbmc/linux/include/sound/sof.h (revision e0d77d0f38aa60ca61b3ce6e60d64fad2aa0853d)
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  *
6c16211d6SLiam Girdwood  * Copyright(c) 2018 Intel Corporation. All rights reserved.
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 {
55*180ffe22SPeter Ujfalusi 	SOF_IPC_TYPE_3,
56*180ffe22SPeter Ujfalusi 	SOF_IPC_TYPE_4,
5715527feeSPierre-Louis Bossart 	SOF_IPC_TYPE_COUNT
5815527feeSPierre-Louis Bossart };
5915527feeSPierre-Louis Bossart 
60*180ffe22SPeter Ujfalusi #define SOF_IPC		SOF_IPC_TYPE_3
61*180ffe22SPeter Ujfalusi #define SOF_INTEL_IPC4	SOF_IPC_TYPE_4
62*180ffe22SPeter Ujfalusi 
63c16211d6SLiam Girdwood /*
64c16211d6SLiam Girdwood  * SOF Platform data.
65c16211d6SLiam Girdwood  */
66c16211d6SLiam Girdwood struct snd_sof_pdata {
67c16211d6SLiam Girdwood 	const char *name;
68c16211d6SLiam Girdwood 	const char *platform;
69c16211d6SLiam Girdwood 
7017560515SRichard Fitzgerald 	/*
7117560515SRichard Fitzgerald 	 * PCI SSID. As PCI does not define 0 as invalid, the subsystem_id_set
7217560515SRichard Fitzgerald 	 * flag indicates that a value has been written to these members.
7317560515SRichard Fitzgerald 	 */
7417560515SRichard Fitzgerald 	unsigned short subsystem_vendor;
7517560515SRichard Fitzgerald 	unsigned short subsystem_device;
7617560515SRichard Fitzgerald 	bool subsystem_id_set;
7717560515SRichard Fitzgerald 
78c16211d6SLiam Girdwood 	struct device *dev;
79c16211d6SLiam Girdwood 
80c16211d6SLiam Girdwood 	/*
81c16211d6SLiam Girdwood 	 * notification callback used if the hardware initialization
82c16211d6SLiam Girdwood 	 * can take time or is handled in a workqueue. This callback
83c16211d6SLiam Girdwood 	 * can be used by the caller to e.g. enable runtime_pm
84c16211d6SLiam Girdwood 	 * or limit functionality until all low-level inits are
85c16211d6SLiam Girdwood 	 * complete.
86c16211d6SLiam Girdwood 	 */
87c16211d6SLiam Girdwood 	void (*sof_probe_complete)(struct device *dev);
88c16211d6SLiam Girdwood 
89c16211d6SLiam Girdwood 	/* descriptor */
90c16211d6SLiam Girdwood 	const struct sof_dev_desc *desc;
91c16211d6SLiam Girdwood 
92c16211d6SLiam Girdwood 	/* firmware and topology filenames */
93c16211d6SLiam Girdwood 	const char *fw_filename_prefix;
94c16211d6SLiam Girdwood 	const char *fw_filename;
95c16211d6SLiam Girdwood 	const char *tplg_filename_prefix;
96c16211d6SLiam Girdwood 	const char *tplg_filename;
97c16211d6SLiam Girdwood 
9825bbc0c5SPeter Ujfalusi 	/* loadable external libraries available under this directory */
9925bbc0c5SPeter Ujfalusi 	const char *fw_lib_prefix;
10025bbc0c5SPeter Ujfalusi 
101c16211d6SLiam Girdwood 	/* machine */
102c16211d6SLiam Girdwood 	struct platform_device *pdev_mach;
103c16211d6SLiam Girdwood 	const struct snd_soc_acpi_mach *machine;
1046ace85b9SChunxu Li 	const struct snd_sof_of_mach *of_machine;
105c16211d6SLiam Girdwood 
106c16211d6SLiam Girdwood 	void *hw_pdata;
10715527feeSPierre-Louis Bossart 
10815527feeSPierre-Louis Bossart 	enum sof_ipc_type ipc_type;
109c16211d6SLiam Girdwood };
110c16211d6SLiam Girdwood 
111c16211d6SLiam Girdwood /*
112c16211d6SLiam Girdwood  * Descriptor used for setting up SOF platform data. This is used when
113c16211d6SLiam Girdwood  * ACPI/PCI data is missing or mapped differently.
114c16211d6SLiam Girdwood  */
115c16211d6SLiam Girdwood struct sof_dev_desc {
116c16211d6SLiam Girdwood 	/* list of machines using this configuration */
117c16211d6SLiam Girdwood 	struct snd_soc_acpi_mach *machines;
1186ace85b9SChunxu Li 	struct snd_sof_of_mach *of_machines;
119c16211d6SLiam Girdwood 
1201466327eSPierre-Louis Bossart 	/* alternate list of machines using this configuration */
1211466327eSPierre-Louis Bossart 	struct snd_soc_acpi_mach *alt_machines;
1221466327eSPierre-Louis Bossart 
12343437d04SDaniel Baluta 	bool use_acpi_target_states;
12443437d04SDaniel Baluta 
125c16211d6SLiam Girdwood 	/* Platform resource indexes in BAR / ACPI resources. */
126c16211d6SLiam Girdwood 	/* Must set to -1 if not used - add new items to end */
127c16211d6SLiam Girdwood 	int resindex_lpe_base;
128c16211d6SLiam Girdwood 	int resindex_pcicfg_base;
129c16211d6SLiam Girdwood 	int resindex_imr_base;
130c16211d6SLiam Girdwood 	int irqindex_host_ipc;
131c16211d6SLiam Girdwood 
132c16211d6SLiam Girdwood 	/* IPC timeouts in ms */
133c16211d6SLiam Girdwood 	int ipc_timeout;
134c16211d6SLiam Girdwood 	int boot_timeout;
135c16211d6SLiam Girdwood 
136c16211d6SLiam Girdwood 	/* chip information for dsp */
137c16211d6SLiam Girdwood 	const void *chip_info;
138c16211d6SLiam Girdwood 
139c16211d6SLiam Girdwood 	/* defaults for no codec mode */
140c16211d6SLiam Girdwood 	const char *nocodec_tplg_filename;
141c16211d6SLiam Girdwood 
1420cf8ff05SPierre-Louis Bossart 	/* information on supported IPCs */
1430cf8ff05SPierre-Louis Bossart 	unsigned int ipc_supported_mask;
1440cf8ff05SPierre-Louis Bossart 	enum sof_ipc_type ipc_default;
1450cf8ff05SPierre-Louis Bossart 
14659611370SPeter Ujfalusi 	/* The platform supports DSPless mode */
14759611370SPeter Ujfalusi 	bool dspless_mode_supported;
14859611370SPeter Ujfalusi 
14925bbc0c5SPeter Ujfalusi 	/* defaults paths for firmware, library and topology files */
150a3757915SPierre-Louis Bossart 	const char *default_fw_path[SOF_IPC_TYPE_COUNT];
15125bbc0c5SPeter Ujfalusi 	const char *default_lib_path[SOF_IPC_TYPE_COUNT];
152a3757915SPierre-Louis Bossart 	const char *default_tplg_path[SOF_IPC_TYPE_COUNT];
153c16211d6SLiam Girdwood 
15403eec9b4SRanjani Sridharan 	/* default firmware name */
155a97abb3cSPierre-Louis Bossart 	const char *default_fw_filename[SOF_IPC_TYPE_COUNT];
15603eec9b4SRanjani Sridharan 
157856601e5SPierre-Louis Bossart 	struct snd_sof_dsp_ops *ops;
158856601e5SPierre-Louis Bossart 	int (*ops_init)(struct snd_sof_dev *sdev);
159bc433fd7SRanjani Sridharan 	void (*ops_free)(struct snd_sof_dev *sdev);
160c16211d6SLiam Girdwood };
161c16211d6SLiam Girdwood 
162b951b51eSKeyon Jie int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd);
163bc619cfcSBrent Lu int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd);
164f805e7e0SRanjani Sridharan 
165c16211d6SLiam Girdwood #endif
166