xref: /openbmc/linux/include/sound/sof.h (revision b4bd2aaf)
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 /* DSP power states */
43 enum sof_dsp_power_states {
44 	SOF_DSP_PM_D0,
45 	SOF_DSP_PM_D1,
46 	SOF_DSP_PM_D2,
47 	SOF_DSP_PM_D3,
48 };
49 
50 /*
51  * SOF Platform data.
52  */
53 struct snd_sof_pdata {
54 	const struct firmware *fw;
55 	const char *name;
56 	const char *platform;
57 
58 	struct device *dev;
59 
60 	/* indicate how many first bytes shouldn't be loaded into DSP memory. */
61 	size_t fw_offset;
62 
63 	/*
64 	 * notification callback used if the hardware initialization
65 	 * can take time or is handled in a workqueue. This callback
66 	 * can be used by the caller to e.g. enable runtime_pm
67 	 * or limit functionality until all low-level inits are
68 	 * complete.
69 	 */
70 	void (*sof_probe_complete)(struct device *dev);
71 
72 	/* descriptor */
73 	const struct sof_dev_desc *desc;
74 
75 	/* firmware and topology filenames */
76 	const char *fw_filename_prefix;
77 	const char *fw_filename;
78 	const char *tplg_filename_prefix;
79 	const char *tplg_filename;
80 
81 	/* machine */
82 	struct platform_device *pdev_mach;
83 	const struct snd_soc_acpi_mach *machine;
84 
85 	void *hw_pdata;
86 };
87 
88 /*
89  * Descriptor used for setting up SOF platform data. This is used when
90  * ACPI/PCI data is missing or mapped differently.
91  */
92 struct sof_dev_desc {
93 	/* list of machines using this configuration */
94 	struct snd_soc_acpi_mach *machines;
95 
96 	/* alternate list of machines using this configuration */
97 	struct snd_soc_acpi_mach *alt_machines;
98 
99 	bool use_acpi_target_states;
100 
101 	/* Platform resource indexes in BAR / ACPI resources. */
102 	/* Must set to -1 if not used - add new items to end */
103 	int resindex_lpe_base;
104 	int resindex_pcicfg_base;
105 	int resindex_imr_base;
106 	int irqindex_host_ipc;
107 
108 	/* IPC timeouts in ms */
109 	int ipc_timeout;
110 	int boot_timeout;
111 
112 	/* chip information for dsp */
113 	const void *chip_info;
114 
115 	/* defaults for no codec mode */
116 	const char *nocodec_tplg_filename;
117 
118 	/* defaults paths for firmware and topology files */
119 	const char *default_fw_path;
120 	const char *default_tplg_path;
121 
122 	/* default firmware name */
123 	const char *default_fw_filename;
124 
125 	const struct snd_sof_dsp_ops *ops;
126 };
127 
128 int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd);
129 int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd);
130 
131 #endif
132