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 struct catpt_ipc_msg
{
28 union catpt_global_msg rsp
;
37 struct catpt_ipc_msg rx
;
38 struct catpt_fw_ready config
;
44 struct completion done_completion
;
45 struct completion busy_completion
;
48 void catpt_ipc_init(struct catpt_ipc
*ipc
, struct device
*dev
);
50 struct catpt_module_type
{
55 /* DRAM, initial module state */
59 struct list_head node
;
63 struct snd_soc_acpi_mach
*machines
;
68 u32 host_dma_offset
[CATPT_DMA_COUNT
];
69 u32 host_ssp_offset
[CATPT_SSP_COUNT
];
74 void (*pll_shutdown
)(struct catpt_dev
*cdev
, bool enable
);
79 struct dw_dma_chip
*dmac
;
87 const struct catpt_spec
*spec
;
88 struct completion fw_ready
;
92 struct resource
*scratch
;
94 struct catpt_mixer_stream_info mixer
;
95 struct catpt_module_type modules
[CATPT_MODULE_COUNT
];
96 struct catpt_ssp_device_format devfmt
[CATPT_SSP_COUNT
];
97 struct list_head stream_list
;
99 struct mutex clk_mutex
;
101 struct catpt_dx_context dx_ctx
;
103 dma_addr_t dxbuf_paddr
;
106 int catpt_dmac_probe(struct catpt_dev
*cdev
);
107 void catpt_dmac_remove(struct catpt_dev
*cdev
);
108 struct dma_chan
*catpt_dma_request_config_chan(struct catpt_dev
*cdev
);
109 int catpt_dma_memcpy_todsp(struct catpt_dev
*cdev
, struct dma_chan
*chan
,
110 dma_addr_t dst_addr
, dma_addr_t src_addr
,
112 int catpt_dma_memcpy_fromdsp(struct catpt_dev
*cdev
, struct dma_chan
*chan
,
113 dma_addr_t dst_addr
, dma_addr_t src_addr
,
116 void lpt_dsp_pll_shutdown(struct catpt_dev
*cdev
, bool enable
);
117 void wpt_dsp_pll_shutdown(struct catpt_dev
*cdev
, bool enable
);
118 int catpt_dsp_power_up(struct catpt_dev
*cdev
);
119 int catpt_dsp_power_down(struct catpt_dev
*cdev
);
120 int catpt_dsp_stall(struct catpt_dev
*cdev
, bool stall
);
121 void catpt_dsp_update_srampge(struct catpt_dev
*cdev
, struct resource
*sram
,
123 int catpt_dsp_update_lpclock(struct catpt_dev
*cdev
);
124 irqreturn_t
catpt_dsp_irq_handler(int irq
, void *dev_id
);
125 irqreturn_t
catpt_dsp_irq_thread(int irq
, void *dev_id
);
128 * IPC handlers may return positive values which denote successful
129 * HOST <-> DSP communication yet failure to process specific request.
130 * Use below macro to convert returned non-zero values appropriately
132 #define CATPT_IPC_ERROR(err) (((err) < 0) ? (err) : -EREMOTEIO)
134 int catpt_dsp_send_msg_timeout(struct catpt_dev
*cdev
,
135 struct catpt_ipc_msg request
,
136 struct catpt_ipc_msg
*reply
, int timeout
);
137 int catpt_dsp_send_msg(struct catpt_dev
*cdev
, struct catpt_ipc_msg request
,
138 struct catpt_ipc_msg
*reply
);
140 int catpt_first_boot_firmware(struct catpt_dev
*cdev
);
141 int catpt_boot_firmware(struct catpt_dev
*cdev
, bool restore
);
142 int catpt_store_streams_context(struct catpt_dev
*cdev
, struct dma_chan
*chan
);
143 int catpt_store_module_states(struct catpt_dev
*cdev
, struct dma_chan
*chan
);
144 int catpt_store_memdumps(struct catpt_dev
*cdev
, struct dma_chan
*chan
);
145 int catpt_coredump(struct catpt_dev
*cdev
);
147 #include <sound/memalloc.h>
148 #include <uapi/sound/asound.h>
150 struct snd_pcm_substream
;
151 struct catpt_stream_template
;
153 struct catpt_stream_runtime
{
154 struct snd_pcm_substream
*substream
;
156 struct catpt_stream_template
*template;
157 struct catpt_stream_info info
;
158 struct resource
*persistent
;
159 struct snd_dma_buffer pgtbl
;
164 struct list_head node
;
167 int catpt_register_plat_component(struct catpt_dev
*cdev
);
168 void catpt_stream_update_position(struct catpt_dev
*cdev
,
169 struct catpt_stream_runtime
*stream
,
170 struct catpt_notify_position
*pos
);
171 struct catpt_stream_runtime
*
172 catpt_stream_find(struct catpt_dev
*cdev
, u8 stream_hw_id
);
173 int catpt_arm_stream_templates(struct catpt_dev
*cdev
);