1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright(c) 2020 Intel Corporation. All rights reserved.
5 * Author: Cezary Rojewski <cezary.rojewski@intel.com>
8 #ifndef __SND_SOC_INTEL_CATPT_CORE_H
9 #define __SND_SOC_INTEL_CATPT_CORE_H
11 #include <linux/dma/dw.h>
12 #include <linux/irqreturn.h>
14 #include "registers.h"
18 extern const struct attribute_group *catpt_attr_groups[];
20 void catpt_sram_init(struct resource *sram, u32 start, u32 size);
21 void catpt_sram_free(struct resource *sram);
23 catpt_request_region(struct resource *root, resource_size_t size);
25 static inline bool catpt_resource_overlapping(struct resource *r1,
29 if (!resource_overlaps(r1, r2))
31 ret->start = max(r1->start, r2->start);
32 ret->end = min(r1->end, r2->end);
36 struct catpt_ipc_msg {
39 union catpt_global_msg rsp;
48 struct catpt_ipc_msg rx;
49 struct catpt_fw_ready config;
55 struct completion done_completion;
56 struct completion busy_completion;
59 void catpt_ipc_init(struct catpt_ipc *ipc, struct device *dev);
61 struct catpt_module_type {
66 /* DRAM, initial module state */
70 struct list_head node;
74 struct snd_soc_acpi_mach *machines;
79 u32 host_dma_offset[CATPT_DMA_COUNT];
80 u32 host_ssp_offset[CATPT_SSP_COUNT];
83 void (*pll_shutdown)(struct catpt_dev *cdev, bool enable);
84 int (*power_up)(struct catpt_dev *cdev);
85 int (*power_down)(struct catpt_dev *cdev);
90 struct dw_dma_chip *dmac;
98 const struct catpt_spec *spec;
99 struct completion fw_ready;
101 struct resource dram;
102 struct resource iram;
103 struct resource *scratch;
105 struct catpt_mixer_stream_info mixer;
106 struct catpt_module_type modules[CATPT_MODULE_COUNT];
107 struct catpt_ssp_device_format devfmt[CATPT_SSP_COUNT];
108 struct list_head stream_list;
109 spinlock_t list_lock;
110 struct mutex clk_mutex;
112 struct catpt_dx_context dx_ctx;
114 dma_addr_t dxbuf_paddr;
117 int catpt_dmac_probe(struct catpt_dev *cdev);
118 void catpt_dmac_remove(struct catpt_dev *cdev);
119 struct dma_chan *catpt_dma_request_config_chan(struct catpt_dev *cdev);
120 int catpt_dma_memcpy_todsp(struct catpt_dev *cdev, struct dma_chan *chan,
121 dma_addr_t dst_addr, dma_addr_t src_addr,
123 int catpt_dma_memcpy_fromdsp(struct catpt_dev *cdev, struct dma_chan *chan,
124 dma_addr_t dst_addr, dma_addr_t src_addr,
127 void lpt_dsp_pll_shutdown(struct catpt_dev *cdev, bool enable);
128 void wpt_dsp_pll_shutdown(struct catpt_dev *cdev, bool enable);
129 int lpt_dsp_power_up(struct catpt_dev *cdev);
130 int lpt_dsp_power_down(struct catpt_dev *cdev);
131 int wpt_dsp_power_up(struct catpt_dev *cdev);
132 int wpt_dsp_power_down(struct catpt_dev *cdev);
133 int catpt_dsp_stall(struct catpt_dev *cdev, bool stall);
134 void catpt_dsp_update_srampge(struct catpt_dev *cdev, struct resource *sram,
136 int catpt_dsp_update_lpclock(struct catpt_dev *cdev);
137 irqreturn_t catpt_dsp_irq_handler(int irq, void *dev_id);
138 irqreturn_t catpt_dsp_irq_thread(int irq, void *dev_id);
141 * IPC handlers may return positive values which denote successful
142 * HOST <-> DSP communication yet failure to process specific request.
143 * Use below macro to convert returned non-zero values appropriately
145 #define CATPT_IPC_ERROR(err) (((err) < 0) ? (err) : -EREMOTEIO)
147 int catpt_dsp_send_msg_timeout(struct catpt_dev *cdev,
148 struct catpt_ipc_msg request,
149 struct catpt_ipc_msg *reply, int timeout);
150 int catpt_dsp_send_msg(struct catpt_dev *cdev, struct catpt_ipc_msg request,
151 struct catpt_ipc_msg *reply);
153 int catpt_first_boot_firmware(struct catpt_dev *cdev);
154 int catpt_boot_firmware(struct catpt_dev *cdev, bool restore);
155 int catpt_store_streams_context(struct catpt_dev *cdev, struct dma_chan *chan);
156 int catpt_store_module_states(struct catpt_dev *cdev, struct dma_chan *chan);
157 int catpt_store_memdumps(struct catpt_dev *cdev, struct dma_chan *chan);
158 int catpt_coredump(struct catpt_dev *cdev);
160 #include <sound/memalloc.h>
161 #include <uapi/sound/asound.h>
163 struct snd_pcm_substream;
164 struct catpt_stream_template;
166 struct catpt_stream_runtime {
167 struct snd_pcm_substream *substream;
169 struct catpt_stream_template *template;
170 struct catpt_stream_info info;
171 struct resource *persistent;
172 struct snd_dma_buffer pgtbl;
177 struct list_head node;
180 int catpt_register_plat_component(struct catpt_dev *cdev);
181 void catpt_stream_update_position(struct catpt_dev *cdev,
182 struct catpt_stream_runtime *stream,
183 struct catpt_notify_position *pos);
184 struct catpt_stream_runtime *
185 catpt_stream_find(struct catpt_dev *cdev, u8 stream_hw_id);
186 int catpt_arm_stream_templates(struct catpt_dev *cdev);