0001
0002
0003
0004
0005
0006
0007
0008 #ifndef __SND_SOC_INTEL_CATPT_CORE_H
0009 #define __SND_SOC_INTEL_CATPT_CORE_H
0010
0011 #include <linux/dma/dw.h>
0012 #include <linux/irqreturn.h>
0013 #include "messages.h"
0014 #include "registers.h"
0015
0016 struct catpt_dev;
0017
0018 extern const struct attribute_group *catpt_attr_groups[];
0019
0020 void catpt_sram_init(struct resource *sram, u32 start, u32 size);
0021 void catpt_sram_free(struct resource *sram);
0022 struct resource *
0023 catpt_request_region(struct resource *root, resource_size_t size);
0024
0025 struct catpt_ipc_msg {
0026 union {
0027 u32 header;
0028 union catpt_global_msg rsp;
0029 };
0030 void *data;
0031 size_t size;
0032 };
0033
0034 struct catpt_ipc {
0035 struct device *dev;
0036
0037 struct catpt_ipc_msg rx;
0038 struct catpt_fw_ready config;
0039 u32 default_timeout;
0040 bool ready;
0041
0042 spinlock_t lock;
0043 struct mutex mutex;
0044 struct completion done_completion;
0045 struct completion busy_completion;
0046 };
0047
0048 void catpt_ipc_init(struct catpt_ipc *ipc, struct device *dev);
0049
0050 struct catpt_module_type {
0051 bool loaded;
0052 u32 entry_point;
0053 u32 persistent_size;
0054 u32 scratch_size;
0055
0056 u32 state_offset;
0057 u32 state_size;
0058
0059 struct list_head node;
0060 };
0061
0062 struct catpt_spec {
0063 struct snd_soc_acpi_mach *machines;
0064 u8 core_id;
0065 u32 host_dram_offset;
0066 u32 host_iram_offset;
0067 u32 host_shim_offset;
0068 u32 host_dma_offset[CATPT_DMA_COUNT];
0069 u32 host_ssp_offset[CATPT_SSP_COUNT];
0070 u32 dram_mask;
0071 u32 iram_mask;
0072 u32 d3srampgd_bit;
0073 u32 d3pgd_bit;
0074 void (*pll_shutdown)(struct catpt_dev *cdev, bool enable);
0075 };
0076
0077 struct catpt_dev {
0078 struct device *dev;
0079 struct dw_dma_chip *dmac;
0080 struct catpt_ipc ipc;
0081
0082 void __iomem *pci_ba;
0083 void __iomem *lpe_ba;
0084 u32 lpe_base;
0085 int irq;
0086
0087 const struct catpt_spec *spec;
0088 struct completion fw_ready;
0089
0090 struct resource dram;
0091 struct resource iram;
0092 struct resource *scratch;
0093
0094 struct catpt_mixer_stream_info mixer;
0095 struct catpt_module_type modules[CATPT_MODULE_COUNT];
0096 struct catpt_ssp_device_format devfmt[CATPT_SSP_COUNT];
0097 struct list_head stream_list;
0098 spinlock_t list_lock;
0099 struct mutex clk_mutex;
0100
0101 struct catpt_dx_context dx_ctx;
0102 void *dxbuf_vaddr;
0103 dma_addr_t dxbuf_paddr;
0104 };
0105
0106 int catpt_dmac_probe(struct catpt_dev *cdev);
0107 void catpt_dmac_remove(struct catpt_dev *cdev);
0108 struct dma_chan *catpt_dma_request_config_chan(struct catpt_dev *cdev);
0109 int catpt_dma_memcpy_todsp(struct catpt_dev *cdev, struct dma_chan *chan,
0110 dma_addr_t dst_addr, dma_addr_t src_addr,
0111 size_t size);
0112 int catpt_dma_memcpy_fromdsp(struct catpt_dev *cdev, struct dma_chan *chan,
0113 dma_addr_t dst_addr, dma_addr_t src_addr,
0114 size_t size);
0115
0116 void lpt_dsp_pll_shutdown(struct catpt_dev *cdev, bool enable);
0117 void wpt_dsp_pll_shutdown(struct catpt_dev *cdev, bool enable);
0118 int catpt_dsp_power_up(struct catpt_dev *cdev);
0119 int catpt_dsp_power_down(struct catpt_dev *cdev);
0120 int catpt_dsp_stall(struct catpt_dev *cdev, bool stall);
0121 void catpt_dsp_update_srampge(struct catpt_dev *cdev, struct resource *sram,
0122 unsigned long mask);
0123 int catpt_dsp_update_lpclock(struct catpt_dev *cdev);
0124 irqreturn_t catpt_dsp_irq_handler(int irq, void *dev_id);
0125 irqreturn_t catpt_dsp_irq_thread(int irq, void *dev_id);
0126
0127
0128
0129
0130
0131
0132 #define CATPT_IPC_ERROR(err) (((err) < 0) ? (err) : -EREMOTEIO)
0133
0134 int catpt_dsp_send_msg_timeout(struct catpt_dev *cdev,
0135 struct catpt_ipc_msg request,
0136 struct catpt_ipc_msg *reply, int timeout);
0137 int catpt_dsp_send_msg(struct catpt_dev *cdev, struct catpt_ipc_msg request,
0138 struct catpt_ipc_msg *reply);
0139
0140 int catpt_first_boot_firmware(struct catpt_dev *cdev);
0141 int catpt_boot_firmware(struct catpt_dev *cdev, bool restore);
0142 int catpt_store_streams_context(struct catpt_dev *cdev, struct dma_chan *chan);
0143 int catpt_store_module_states(struct catpt_dev *cdev, struct dma_chan *chan);
0144 int catpt_store_memdumps(struct catpt_dev *cdev, struct dma_chan *chan);
0145 int catpt_coredump(struct catpt_dev *cdev);
0146
0147 #include <sound/memalloc.h>
0148 #include <uapi/sound/asound.h>
0149
0150 struct snd_pcm_substream;
0151 struct catpt_stream_template;
0152
0153 struct catpt_stream_runtime {
0154 struct snd_pcm_substream *substream;
0155
0156 struct catpt_stream_template *template;
0157 struct catpt_stream_info info;
0158 struct resource *persistent;
0159 struct snd_dma_buffer pgtbl;
0160
0161 bool allocated;
0162 bool prepared;
0163
0164 struct list_head node;
0165 };
0166
0167 int catpt_register_plat_component(struct catpt_dev *cdev);
0168 void catpt_stream_update_position(struct catpt_dev *cdev,
0169 struct catpt_stream_runtime *stream,
0170 struct catpt_notify_position *pos);
0171 struct catpt_stream_runtime *
0172 catpt_stream_find(struct catpt_dev *cdev, u8 stream_hw_id);
0173 int catpt_arm_stream_templates(struct catpt_dev *cdev);
0174
0175 #endif