Loading...
1/* SPDX-License-Identifier: (GPL-2.0 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
18struct snd_sof_dsp_ops;
19
20/*
21 * SOF Platform data.
22 */
23struct snd_sof_pdata {
24 const struct firmware *fw;
25 const char *drv_name;
26 const char *name;
27 const char *platform;
28
29 struct device *dev;
30
31 /*
32 * notification callback used if the hardware initialization
33 * can take time or is handled in a workqueue. This callback
34 * can be used by the caller to e.g. enable runtime_pm
35 * or limit functionality until all low-level inits are
36 * complete.
37 */
38 void (*sof_probe_complete)(struct device *dev);
39
40 /* descriptor */
41 const struct sof_dev_desc *desc;
42
43 /* firmware and topology filenames */
44 const char *fw_filename_prefix;
45 const char *fw_filename;
46 const char *tplg_filename_prefix;
47 const char *tplg_filename;
48
49 /* machine */
50 struct platform_device *pdev_mach;
51 const struct snd_soc_acpi_mach *machine;
52
53 void *hw_pdata;
54};
55
56/*
57 * Descriptor used for setting up SOF platform data. This is used when
58 * ACPI/PCI data is missing or mapped differently.
59 */
60struct sof_dev_desc {
61 /* list of machines using this configuration */
62 struct snd_soc_acpi_mach *machines;
63
64 /* Platform resource indexes in BAR / ACPI resources. */
65 /* Must set to -1 if not used - add new items to end */
66 int resindex_lpe_base;
67 int resindex_pcicfg_base;
68 int resindex_imr_base;
69 int irqindex_host_ipc;
70 int resindex_dma_base;
71
72 /* DMA only valid when resindex_dma_base != -1*/
73 int dma_engine;
74 int dma_size;
75
76 /* IPC timeouts in ms */
77 int ipc_timeout;
78 int boot_timeout;
79
80 /* chip information for dsp */
81 const void *chip_info;
82
83 /* defaults for no codec mode */
84 const char *nocodec_fw_filename;
85 const char *nocodec_tplg_filename;
86
87 /* defaults paths for firmware and topology files */
88 const char *default_fw_path;
89 const char *default_tplg_path;
90
91 const struct snd_sof_dsp_ops *ops;
92 const struct sof_arch_ops *arch_ops;
93};
94
95int sof_nocodec_setup(struct device *dev,
96 struct snd_sof_pdata *sof_pdata,
97 struct snd_soc_acpi_mach *mach,
98 const struct sof_dev_desc *desc,
99 const struct snd_sof_dsp_ops *ops);
100#endif
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
18struct snd_sof_dsp_ops;
19struct snd_sof_dev;
20
21/**
22 * enum sof_fw_state - DSP firmware state definitions
23 * @SOF_FW_BOOT_NOT_STARTED: firmware boot is not yet started
24 * @SOF_DSPLESS_MODE: DSP is not used
25 * @SOF_FW_BOOT_PREPARE: preparing for boot (firmware loading for exaqmple)
26 * @SOF_FW_BOOT_IN_PROGRESS: firmware boot is in progress
27 * @SOF_FW_BOOT_FAILED: firmware boot failed
28 * @SOF_FW_BOOT_READY_FAILED: firmware booted but fw_ready op failed
29 * @SOF_FW_BOOT_READY_OK: firmware booted and fw_ready op passed
30 * @SOF_FW_BOOT_COMPLETE: firmware is booted up and functional
31 * @SOF_FW_CRASHED: firmware crashed after successful boot
32 */
33enum sof_fw_state {
34 SOF_FW_BOOT_NOT_STARTED = 0,
35 SOF_DSPLESS_MODE,
36 SOF_FW_BOOT_PREPARE,
37 SOF_FW_BOOT_IN_PROGRESS,
38 SOF_FW_BOOT_FAILED,
39 SOF_FW_BOOT_READY_FAILED,
40 SOF_FW_BOOT_READY_OK,
41 SOF_FW_BOOT_COMPLETE,
42 SOF_FW_CRASHED,
43};
44
45/* DSP power states */
46enum sof_dsp_power_states {
47 SOF_DSP_PM_D0,
48 SOF_DSP_PM_D1,
49 SOF_DSP_PM_D2,
50 SOF_DSP_PM_D3,
51};
52
53/* Definitions for multiple IPCs */
54enum sof_ipc_type {
55 SOF_IPC_TYPE_3,
56 SOF_IPC_TYPE_4,
57 SOF_IPC_TYPE_COUNT
58};
59
60struct sof_loadable_file_profile {
61 enum sof_ipc_type ipc_type;
62
63 const char *fw_path;
64 const char *fw_path_postfix;
65 const char *fw_name;
66 const char *fw_lib_path;
67 const char *fw_lib_path_postfix;
68 const char *tplg_path;
69 const char *tplg_name;
70};
71
72/*
73 * SOF Platform data.
74 */
75struct snd_sof_pdata {
76 const char *name;
77 const char *platform;
78
79 /*
80 * PCI SSID. As PCI does not define 0 as invalid, the subsystem_id_set
81 * flag indicates that a value has been written to these members.
82 */
83 unsigned short subsystem_vendor;
84 unsigned short subsystem_device;
85 bool subsystem_id_set;
86
87 struct device *dev;
88
89 /*
90 * notification callback used if the hardware initialization
91 * can take time or is handled in a workqueue. This callback
92 * can be used by the caller to e.g. enable runtime_pm
93 * or limit functionality until all low-level inits are
94 * complete.
95 */
96 void (*sof_probe_complete)(struct device *dev);
97
98 /* descriptor */
99 const struct sof_dev_desc *desc;
100
101 /* platform's preferred IPC type and path overrides */
102 struct sof_loadable_file_profile ipc_file_profile_base;
103
104 /* firmware and topology filenames */
105 const char *fw_filename_prefix;
106 const char *fw_filename;
107 const char *tplg_filename_prefix;
108 const char *tplg_filename;
109
110 /* loadable external libraries available under this directory */
111 const char *fw_lib_prefix;
112
113 /* machine */
114 struct platform_device *pdev_mach;
115 const struct snd_soc_acpi_mach *machine;
116 const struct snd_sof_of_mach *of_machine;
117
118 void *hw_pdata;
119
120 enum sof_ipc_type ipc_type;
121};
122
123/*
124 * Descriptor used for setting up SOF platform data. This is used when
125 * ACPI/PCI data is missing or mapped differently.
126 */
127struct sof_dev_desc {
128 /* list of machines using this configuration */
129 struct snd_soc_acpi_mach *machines;
130 struct snd_sof_of_mach *of_machines;
131
132 /* alternate list of machines using this configuration */
133 struct snd_soc_acpi_mach *alt_machines;
134
135 bool use_acpi_target_states;
136
137 /* Platform resource indexes in BAR / ACPI resources. */
138 /* Must set to -1 if not used - add new items to end */
139 int resindex_lpe_base;
140 int resindex_pcicfg_base;
141 int resindex_imr_base;
142 int irqindex_host_ipc;
143
144 /* IPC timeouts in ms */
145 int ipc_timeout;
146 int boot_timeout;
147
148 /* chip information for dsp */
149 const void *chip_info;
150
151 /* defaults for no codec mode */
152 const char *nocodec_tplg_filename;
153
154 /* information on supported IPCs */
155 unsigned int ipc_supported_mask;
156 enum sof_ipc_type ipc_default;
157
158 /* The platform supports DSPless mode */
159 bool dspless_mode_supported;
160
161 /* defaults paths for firmware, library and topology files */
162 const char *default_fw_path[SOF_IPC_TYPE_COUNT];
163 const char *default_lib_path[SOF_IPC_TYPE_COUNT];
164 const char *default_tplg_path[SOF_IPC_TYPE_COUNT];
165
166 /* default firmware name */
167 const char *default_fw_filename[SOF_IPC_TYPE_COUNT];
168
169 struct snd_sof_dsp_ops *ops;
170 int (*ops_init)(struct snd_sof_dev *sdev);
171 void (*ops_free)(struct snd_sof_dev *sdev);
172};
173
174int sof_dai_get_mclk(struct snd_soc_pcm_runtime *rtd);
175int sof_dai_get_bclk(struct snd_soc_pcm_runtime *rtd);
176
177#endif