skl-sst-ipc.h 5.0 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
/*
 * Intel SKL IPC Support
 *
 * Copyright (C) 2014-15, Intel Corporation.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as version 2, as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 */

#ifndef __SKL_IPC_H
#define __SKL_IPC_H

#include <linux/irqreturn.h>
#include "../common/sst-ipc.h"

struct sst_dsp;
struct skl_sst;
struct sst_generic_ipc;

enum skl_ipc_pipeline_state {
	PPL_INVALID_STATE =	0,
	PPL_UNINITIALIZED =	1,
	PPL_RESET =		2,
	PPL_PAUSED =		3,
	PPL_RUNNING =		4,
	PPL_ERROR_STOP =	5,
	PPL_SAVED =		6,
	PPL_RESTORED =		7
};

struct skl_ipc_dxstate_info {
	u32 core_mask;
	u32 dx_mask;
};

struct skl_ipc_header {
	u32 primary;
	u32 extension;
};

47 48 49 50 51 52 53 54
#define SKL_DSP_CORES_MAX  2

struct skl_dsp_cores {
	unsigned int count;
	enum skl_dsp_states state[SKL_DSP_CORES_MAX];
	int usage_count[SKL_DSP_CORES_MAX];
};

55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
/**
 * skl_d0i3_data: skl D0i3 counters data struct
 *
 * @streaming: Count of usecases that can attempt streaming D0i3
 * @non_streaming: Count of usecases that can attempt non-streaming D0i3
 * @non_d0i3: Count of usecases that cannot attempt D0i3
 * @state: current state
 * @work: D0i3 worker thread
 */
struct skl_d0i3_data {
	int streaming;
	int non_streaming;
	int non_d0i3;
	enum skl_dsp_d0i3_states state;
	struct delayed_work work;
};

72 73 74 75 76 77 78 79
#define SKL_LIB_NAME_LENGTH 128
#define SKL_MAX_LIB 16

struct skl_lib_info {
	char name[SKL_LIB_NAME_LENGTH];
	const struct firmware *fw;
};

80 81 82 83 84 85 86 87
struct skl_sst {
	struct device *dev;
	struct sst_dsp *dsp;

	/* boot */
	wait_queue_head_t boot_wait;
	bool boot_complete;

88 89 90 91 92
	/* module load */
	wait_queue_head_t mod_load_wait;
	bool mod_load_complete;
	bool mod_load_status;

93 94
	/* IPC messaging */
	struct sst_generic_ipc ipc;
95 96 97

	/* callback for miscbdge */
	void (*enable_miscbdcge)(struct device *dev, bool enable);
98
	/* Is CGCTL.MISCBDCGE disabled */
99
	bool miscbdcg_disabled;
100 101 102

	/* Populate module information */
	struct list_head uuid_list;
103 104 105

	/* Is firmware loaded */
	bool fw_loaded;
106

107 108 109
	/* first boot ? */
	bool is_first_boot;

110 111
	/* multi-core */
	struct skl_dsp_cores cores;
112

113 114 115
	/* library info */
	struct skl_lib_info  lib_info[SKL_MAX_LIB];
	int lib_count;
116 117 118

	/* Callback to update D0i3C register */
	void (*update_d0i3c)(struct device *dev, bool enable);
119 120

	struct skl_d0i3_data d0i3;
121 122

	const struct skl_dsp_ops *dsp_ops;
123 124 125 126 127 128 129 130
};

struct skl_ipc_init_instance_msg {
	u32 module_id;
	u32 instance_id;
	u16 param_data_size;
	u8 ppl_instance_id;
	u8 core_id;
131
	u8 domain;
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
};

struct skl_ipc_bind_unbind_msg {
	u32 module_id;
	u32 instance_id;
	u32 dst_module_id;
	u32 dst_instance_id;
	u8 src_queue;
	u8 dst_queue;
	bool bind;
};

struct skl_ipc_large_config_msg {
	u32 module_id;
	u32 instance_id;
	u32 large_param_id;
	u32 param_data_size;
};

151 152 153 154 155 156 157
struct skl_ipc_d0ix_msg {
	u32 module_id;
	u32 instance_id;
	u8 streaming;
	u8 wake;
};

158 159 160 161 162 163 164 165
#define SKL_IPC_BOOT_MSECS		3000

#define SKL_IPC_D3_MASK	0
#define SKL_IPC_D0_MASK	3

irqreturn_t skl_dsp_irq_thread_handler(int irq, void *context);

int skl_ipc_create_pipeline(struct sst_generic_ipc *sst_ipc,
166
		u16 ppl_mem_size, u8 ppl_type, u8 instance_id, u8 lp_mode);
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183

int skl_ipc_delete_pipeline(struct sst_generic_ipc *sst_ipc, u8 instance_id);

int skl_ipc_set_pipeline_state(struct sst_generic_ipc *sst_ipc,
		u8 instance_id,	enum skl_ipc_pipeline_state state);

int skl_ipc_save_pipeline(struct sst_generic_ipc *ipc,
		u8 instance_id, int dma_id);

int skl_ipc_restore_pipeline(struct sst_generic_ipc *ipc, u8 instance_id);

int skl_ipc_init_instance(struct sst_generic_ipc *sst_ipc,
		struct skl_ipc_init_instance_msg *msg, void *param_data);

int skl_ipc_bind_unbind(struct sst_generic_ipc *sst_ipc,
		struct skl_ipc_bind_unbind_msg *msg);

184 185 186 187 188 189
int skl_ipc_load_modules(struct sst_generic_ipc *ipc,
				u8 module_cnt, void *data);

int skl_ipc_unload_modules(struct sst_generic_ipc *ipc,
				u8 module_cnt, void *data);

190 191 192 193 194 195
int skl_ipc_set_dx(struct sst_generic_ipc *ipc,
		u8 instance_id, u16 module_id, struct skl_ipc_dxstate_info *dx);

int skl_ipc_set_large_config(struct sst_generic_ipc *ipc,
		struct skl_ipc_large_config_msg *msg, u32 *param);

196 197 198
int skl_ipc_get_large_config(struct sst_generic_ipc *ipc,
		struct skl_ipc_large_config_msg *msg, u32 *param);

199
int skl_sst_ipc_load_library(struct sst_generic_ipc *ipc,
200
			u8 dma_id, u8 table_id, bool wait);
201

202 203 204
int skl_ipc_set_d0ix(struct sst_generic_ipc *ipc,
		struct skl_ipc_d0ix_msg *msg);

205 206
int skl_ipc_check_D0i0(struct sst_dsp *dsp, bool state);

207 208
void skl_ipc_int_enable(struct sst_dsp *dsp);
void skl_ipc_op_int_enable(struct sst_dsp *ctx);
209
void skl_ipc_op_int_disable(struct sst_dsp *ctx);
210 211 212 213 214
void skl_ipc_int_disable(struct sst_dsp *dsp);

bool skl_ipc_int_status(struct sst_dsp *dsp);
void skl_ipc_free(struct sst_generic_ipc *ipc);
int skl_ipc_init(struct device *dev, struct skl_sst *skl);
215
void skl_clear_module_cnt(struct sst_dsp *ctx);
216 217

#endif /* __SKL_IPC_H */