xref: /openbmc/linux/include/sound/sof.h (revision 2f0754f2)
1 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
2 /*
3  * This file is provided under a dual BSD/GPLv2 license.  When using or
4  * redistributing this file, you may do so under either license.
5  *
6  * Copyright(c) 2018 Intel Corporation. All rights reserved.
7  *
8  * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
9  */
10 
11 #ifndef __INCLUDE_SOUND_SOF_H
12 #define __INCLUDE_SOUND_SOF_H
13 
14 #include <linux/pci.h>
15 #include <sound/soc.h>
16 #include <sound/soc-acpi.h>
17 
18 struct snd_sof_dsp_ops;
19 
20 /**
21  * enum sof_fw_state - DSP firmware state definitions
22  * @SOF_FW_BOOT_NOT_STARTED:	firmware boot is not yet started
23  * @SOF_FW_BOOT_PREPARE:	preparing for boot (firmware loading for exaqmple)
24  * @SOF_FW_BOOT_IN_PROGRESS:	firmware boot is in progress
25  * @SOF_FW_BOOT_FAILED:		firmware boot failed
26  * @SOF_FW_BOOT_READY_FAILED:	firmware booted but fw_ready op failed
27  * @SOF_FW_BOOT_READY_OK:	firmware booted and fw_ready op passed
28  * @SOF_FW_BOOT_COMPLETE:	firmware is booted up and functional
29  * @SOF_FW_CRASHED:		firmware crashed after successful boot
30  */
31 enum sof_fw_state {
32 	SOF_FW_BOOT_NOT_STARTED = 0,
33 	SOF_FW_BOOT_PREPARE,
34 	SOF_FW_BOOT_IN_PROGRESS,
35 	SOF_FW_BOOT_FAILED,
36 	SOF_FW_BOOT_READY_FAILED,
37 	SOF_FW_BOOT_READY_OK,
38 	SOF_FW_BOOT_COMPLETE,
39 	SOF_FW_CRASHED,
40 };
41 
42 /*
43  * SOF Platform data.
44  */
45 struct snd_sof_pdata {
46 	const struct firmware *fw;
47 	const char *name;
48 	const char *platform;
49 
50 	struct device *dev;
51 
52 	/* indicate how many first bytes shouldn't be loaded into DSP memory. */
53 	size_t fw_offset;
54 
55 	/*
56 	 * notification callback used if the hardware initialization
57 	 * can take time or is handled in a workqueue. This callback
58 	 * can be used by the caller to e.g. enable runtime_pm
59 	 * or limit functionality until all low-level inits are
60 	 * complete.
61 	 */
62 	void (*sof_probe_complete)(struct device *dev);
63 
64 	/* descriptor */
65 	const struct sof_dev_desc *desc;
66 
67 	/* firmware and topology filenames */
68 	const char *fw_filename_prefix;
69 	const char *fw_filename;
70 	const char *tplg_filename_prefix;
71 	const char *tplg_filename;
72 
73 	/* machine */
74 	struct platform_device *pdev_mach;
75 	const struct snd_soc_acpi_mach *machine;
76 
77 	void *hw_pdata;
78 };
79 
80 /*
81  * Descriptor used for setting up SOF platform data. This is used when
82  * ACPI/PCI data is missing or mapped differently.
83  */
84 struct sof_dev_desc {
85 	/* list of machines using this configuration */
86 	struct snd_soc_acpi_mach *machines;
87 
88 	/* alternate list of machines using this configuration */
89 	struct snd_soc_acpi_mach *alt_machines;
90 
91 	bool use_acpi_target_states;
92 
93 	/* Platform resource indexes in BAR / ACPI resources. */
94 	/* Must set to -1 if not used - add new items to end */
95 	int resindex_lpe_base;
96 	int resindex_pcicfg_base;
97 	int resindex_imr_base;
98 	int irqindex_host_ipc;
99 
100 	/* IPC timeouts in ms */
101 	int ipc_timeout;
102 	int boot_timeout;
103 
104 	/* chip information for dsp */
105 	const void *chip_info;
106 
107 	/* defaults for no codec mode */
108 	const char *nocodec_tplg_filename;
109 
110 	/* defaults paths for firmware and topology files */
111 	const char *default_fw_path;
112 	const char *default_tplg_path;
113 
114 	/* default firmware name */
115 	const char *default_fw_filename;
116 
117 	const struct snd_sof_dsp_ops *ops;
118 };
119 
120 int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd);
121 int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd);
122 
123 #endif
124