xref: /kernel/linux/linux-6.6/sound/soc/sof/intel/hda.h (revision 62306a36)
162306a36Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license.  When using or
462306a36Sopenharmony_ci * redistributing this file, you may do so under either license.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Copyright(c) 2017 Intel Corporation. All rights reserved.
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
962306a36Sopenharmony_ci */
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci#ifndef __SOF_INTEL_HDA_H
1262306a36Sopenharmony_ci#define __SOF_INTEL_HDA_H
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci#include <linux/soundwire/sdw.h>
1562306a36Sopenharmony_ci#include <linux/soundwire/sdw_intel.h>
1662306a36Sopenharmony_ci#include <sound/compress_driver.h>
1762306a36Sopenharmony_ci#include <sound/hda_codec.h>
1862306a36Sopenharmony_ci#include <sound/hdaudio_ext.h>
1962306a36Sopenharmony_ci#include "../sof-client-probes.h"
2062306a36Sopenharmony_ci#include "../sof-audio.h"
2162306a36Sopenharmony_ci#include "shim.h"
2262306a36Sopenharmony_ci
2362306a36Sopenharmony_ci/* PCI registers */
2462306a36Sopenharmony_ci#define PCI_TCSEL			0x44
2562306a36Sopenharmony_ci#define PCI_PGCTL			PCI_TCSEL
2662306a36Sopenharmony_ci#define PCI_CGCTL			0x48
2762306a36Sopenharmony_ci
2862306a36Sopenharmony_ci/* PCI_PGCTL bits */
2962306a36Sopenharmony_ci#define PCI_PGCTL_ADSPPGD               BIT(2)
3062306a36Sopenharmony_ci#define PCI_PGCTL_LSRMD_MASK		BIT(4)
3162306a36Sopenharmony_ci
3262306a36Sopenharmony_ci/* PCI_CGCTL bits */
3362306a36Sopenharmony_ci#define PCI_CGCTL_MISCBDCGE_MASK	BIT(6)
3462306a36Sopenharmony_ci#define PCI_CGCTL_ADSPDCGE              BIT(1)
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ci/* Legacy HDA registers and bits used - widths are variable */
3762306a36Sopenharmony_ci#define SOF_HDA_GCAP			0x0
3862306a36Sopenharmony_ci#define SOF_HDA_GCTL			0x8
3962306a36Sopenharmony_ci/* accept unsol. response enable */
4062306a36Sopenharmony_ci#define SOF_HDA_GCTL_UNSOL		BIT(8)
4162306a36Sopenharmony_ci#define SOF_HDA_LLCH			0x14
4262306a36Sopenharmony_ci#define SOF_HDA_INTCTL			0x20
4362306a36Sopenharmony_ci#define SOF_HDA_INTSTS			0x24
4462306a36Sopenharmony_ci#define SOF_HDA_WAKESTS			0x0E
4562306a36Sopenharmony_ci#define SOF_HDA_WAKESTS_INT_MASK	((1 << 8) - 1)
4662306a36Sopenharmony_ci#define SOF_HDA_RIRBSTS			0x5d
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci/* SOF_HDA_GCTL register bist */
4962306a36Sopenharmony_ci#define SOF_HDA_GCTL_RESET		BIT(0)
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ci/* SOF_HDA_INCTL regs */
5262306a36Sopenharmony_ci#define SOF_HDA_INT_GLOBAL_EN		BIT(31)
5362306a36Sopenharmony_ci#define SOF_HDA_INT_CTRL_EN		BIT(30)
5462306a36Sopenharmony_ci#define SOF_HDA_INT_ALL_STREAM		0xff
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/* SOF_HDA_INTSTS regs */
5762306a36Sopenharmony_ci#define SOF_HDA_INTSTS_GIS		BIT(31)
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ci#define SOF_HDA_MAX_CAPS		10
6062306a36Sopenharmony_ci#define SOF_HDA_CAP_ID_OFF		16
6162306a36Sopenharmony_ci#define SOF_HDA_CAP_ID_MASK		GENMASK(SOF_HDA_CAP_ID_OFF + 11,\
6262306a36Sopenharmony_ci						SOF_HDA_CAP_ID_OFF)
6362306a36Sopenharmony_ci#define SOF_HDA_CAP_NEXT_MASK		0xFFFF
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci#define SOF_HDA_GTS_CAP_ID			0x1
6662306a36Sopenharmony_ci#define SOF_HDA_ML_CAP_ID			0x2
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci#define SOF_HDA_PP_CAP_ID		0x3
6962306a36Sopenharmony_ci#define SOF_HDA_REG_PP_PPCH		0x10
7062306a36Sopenharmony_ci#define SOF_HDA_REG_PP_PPCTL		0x04
7162306a36Sopenharmony_ci#define SOF_HDA_REG_PP_PPSTS		0x08
7262306a36Sopenharmony_ci#define SOF_HDA_PPCTL_PIE		BIT(31)
7362306a36Sopenharmony_ci#define SOF_HDA_PPCTL_GPROCEN		BIT(30)
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci/*Vendor Specific Registers*/
7662306a36Sopenharmony_ci#define SOF_HDA_VS_D0I3C		0x104A
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci/* D0I3C Register fields */
7962306a36Sopenharmony_ci#define SOF_HDA_VS_D0I3C_CIP		BIT(0) /* Command-In-Progress */
8062306a36Sopenharmony_ci#define SOF_HDA_VS_D0I3C_I3		BIT(2) /* D0i3 enable bit */
8162306a36Sopenharmony_ci
8262306a36Sopenharmony_ci/* DPIB entry size: 8 Bytes = 2 DWords */
8362306a36Sopenharmony_ci#define SOF_HDA_DPIB_ENTRY_SIZE	0x8
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci#define SOF_HDA_SPIB_CAP_ID		0x4
8662306a36Sopenharmony_ci#define SOF_HDA_DRSM_CAP_ID		0x5
8762306a36Sopenharmony_ci
8862306a36Sopenharmony_ci#define SOF_HDA_SPIB_BASE		0x08
8962306a36Sopenharmony_ci#define SOF_HDA_SPIB_INTERVAL		0x08
9062306a36Sopenharmony_ci#define SOF_HDA_SPIB_SPIB		0x00
9162306a36Sopenharmony_ci#define SOF_HDA_SPIB_MAXFIFO		0x04
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci#define SOF_HDA_PPHC_BASE		0x10
9462306a36Sopenharmony_ci#define SOF_HDA_PPHC_INTERVAL		0x10
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci#define SOF_HDA_PPLC_BASE		0x10
9762306a36Sopenharmony_ci#define SOF_HDA_PPLC_MULTI		0x10
9862306a36Sopenharmony_ci#define SOF_HDA_PPLC_INTERVAL		0x10
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ci#define SOF_HDA_DRSM_BASE		0x08
10162306a36Sopenharmony_ci#define SOF_HDA_DRSM_INTERVAL		0x08
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci/* Descriptor error interrupt */
10462306a36Sopenharmony_ci#define SOF_HDA_CL_DMA_SD_INT_DESC_ERR		0x10
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ci/* FIFO error interrupt */
10762306a36Sopenharmony_ci#define SOF_HDA_CL_DMA_SD_INT_FIFO_ERR		0x08
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ci/* Buffer completion interrupt */
11062306a36Sopenharmony_ci#define SOF_HDA_CL_DMA_SD_INT_COMPLETE		0x04
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci#define SOF_HDA_CL_DMA_SD_INT_MASK \
11362306a36Sopenharmony_ci	(SOF_HDA_CL_DMA_SD_INT_DESC_ERR | \
11462306a36Sopenharmony_ci	SOF_HDA_CL_DMA_SD_INT_FIFO_ERR | \
11562306a36Sopenharmony_ci	SOF_HDA_CL_DMA_SD_INT_COMPLETE)
11662306a36Sopenharmony_ci#define SOF_HDA_SD_CTL_DMA_START		0x02 /* Stream DMA start bit */
11762306a36Sopenharmony_ci
11862306a36Sopenharmony_ci/* Intel HD Audio Code Loader DMA Registers */
11962306a36Sopenharmony_ci#define SOF_HDA_ADSP_LOADER_BASE		0x80
12062306a36Sopenharmony_ci#define SOF_HDA_ADSP_DPLBASE			0x70
12162306a36Sopenharmony_ci#define SOF_HDA_ADSP_DPUBASE			0x74
12262306a36Sopenharmony_ci#define SOF_HDA_ADSP_DPLBASE_ENABLE		0x01
12362306a36Sopenharmony_ci
12462306a36Sopenharmony_ci/* Stream Registers */
12562306a36Sopenharmony_ci#define SOF_HDA_ADSP_REG_SD_CTL			0x00
12662306a36Sopenharmony_ci#define SOF_HDA_ADSP_REG_SD_STS			0x03
12762306a36Sopenharmony_ci#define SOF_HDA_ADSP_REG_SD_LPIB		0x04
12862306a36Sopenharmony_ci#define SOF_HDA_ADSP_REG_SD_CBL			0x08
12962306a36Sopenharmony_ci#define SOF_HDA_ADSP_REG_SD_LVI			0x0C
13062306a36Sopenharmony_ci#define SOF_HDA_ADSP_REG_SD_FIFOW		0x0E
13162306a36Sopenharmony_ci#define SOF_HDA_ADSP_REG_SD_FIFOSIZE		0x10
13262306a36Sopenharmony_ci#define SOF_HDA_ADSP_REG_SD_FORMAT		0x12
13362306a36Sopenharmony_ci#define SOF_HDA_ADSP_REG_SD_FIFOL		0x14
13462306a36Sopenharmony_ci#define SOF_HDA_ADSP_REG_SD_BDLPL		0x18
13562306a36Sopenharmony_ci#define SOF_HDA_ADSP_REG_SD_BDLPU		0x1C
13662306a36Sopenharmony_ci#define SOF_HDA_ADSP_SD_ENTRY_SIZE		0x20
13762306a36Sopenharmony_ci
13862306a36Sopenharmony_ci/* CL: Software Position Based FIFO Capability Registers */
13962306a36Sopenharmony_ci#define SOF_DSP_REG_CL_SPBFIFO \
14062306a36Sopenharmony_ci	(SOF_HDA_ADSP_LOADER_BASE + 0x20)
14162306a36Sopenharmony_ci#define SOF_HDA_ADSP_REG_CL_SPBFIFO_SPBFCH	0x0
14262306a36Sopenharmony_ci#define SOF_HDA_ADSP_REG_CL_SPBFIFO_SPBFCCTL	0x4
14362306a36Sopenharmony_ci#define SOF_HDA_ADSP_REG_CL_SPBFIFO_SPIB	0x8
14462306a36Sopenharmony_ci#define SOF_HDA_ADSP_REG_CL_SPBFIFO_MAXFIFOS	0xc
14562306a36Sopenharmony_ci
14662306a36Sopenharmony_ci/* Stream Number */
14762306a36Sopenharmony_ci#define SOF_HDA_CL_SD_CTL_STREAM_TAG_SHIFT	20
14862306a36Sopenharmony_ci#define SOF_HDA_CL_SD_CTL_STREAM_TAG_MASK \
14962306a36Sopenharmony_ci	GENMASK(SOF_HDA_CL_SD_CTL_STREAM_TAG_SHIFT + 3,\
15062306a36Sopenharmony_ci		SOF_HDA_CL_SD_CTL_STREAM_TAG_SHIFT)
15162306a36Sopenharmony_ci
15262306a36Sopenharmony_ci#define HDA_DSP_HDA_BAR				0
15362306a36Sopenharmony_ci#define HDA_DSP_PP_BAR				1
15462306a36Sopenharmony_ci#define HDA_DSP_SPIB_BAR			2
15562306a36Sopenharmony_ci#define HDA_DSP_DRSM_BAR			3
15662306a36Sopenharmony_ci#define HDA_DSP_BAR				4
15762306a36Sopenharmony_ci
15862306a36Sopenharmony_ci#define SRAM_WINDOW_OFFSET(x)			(0x80000 + (x) * 0x20000)
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_ci#define HDA_DSP_MBOX_OFFSET			SRAM_WINDOW_OFFSET(0)
16162306a36Sopenharmony_ci
16262306a36Sopenharmony_ci#define HDA_DSP_PANIC_OFFSET(x) \
16362306a36Sopenharmony_ci	(((x) & 0xFFFFFF) + HDA_DSP_MBOX_OFFSET)
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci/* SRAM window 0 FW "registers" */
16662306a36Sopenharmony_ci#define HDA_DSP_SRAM_REG_ROM_STATUS		(HDA_DSP_MBOX_OFFSET + 0x0)
16762306a36Sopenharmony_ci#define HDA_DSP_SRAM_REG_ROM_ERROR		(HDA_DSP_MBOX_OFFSET + 0x4)
16862306a36Sopenharmony_ci/* FW and ROM share offset 4 */
16962306a36Sopenharmony_ci#define HDA_DSP_SRAM_REG_FW_STATUS		(HDA_DSP_MBOX_OFFSET + 0x4)
17062306a36Sopenharmony_ci#define HDA_DSP_SRAM_REG_FW_TRACEP		(HDA_DSP_MBOX_OFFSET + 0x8)
17162306a36Sopenharmony_ci#define HDA_DSP_SRAM_REG_FW_END			(HDA_DSP_MBOX_OFFSET + 0xc)
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_ci#define HDA_DSP_MBOX_UPLINK_OFFSET		0x81000
17462306a36Sopenharmony_ci
17562306a36Sopenharmony_ci#define HDA_DSP_STREAM_RESET_TIMEOUT		300
17662306a36Sopenharmony_ci/*
17762306a36Sopenharmony_ci * Timeout in us, for setting the stream RUN bit, during
17862306a36Sopenharmony_ci * start/stop the stream. The timeout expires if new RUN bit
17962306a36Sopenharmony_ci * value cannot be read back within the specified time.
18062306a36Sopenharmony_ci */
18162306a36Sopenharmony_ci#define HDA_DSP_STREAM_RUN_TIMEOUT		300
18262306a36Sopenharmony_ci
18362306a36Sopenharmony_ci#define HDA_DSP_SPIB_ENABLE			1
18462306a36Sopenharmony_ci#define HDA_DSP_SPIB_DISABLE			0
18562306a36Sopenharmony_ci
18662306a36Sopenharmony_ci#define SOF_HDA_MAX_BUFFER_SIZE			(32 * PAGE_SIZE)
18762306a36Sopenharmony_ci
18862306a36Sopenharmony_ci#define HDA_DSP_STACK_DUMP_SIZE			32
18962306a36Sopenharmony_ci
19062306a36Sopenharmony_ci/* ROM/FW status register */
19162306a36Sopenharmony_ci#define FSR_STATE_MASK				GENMASK(23, 0)
19262306a36Sopenharmony_ci#define FSR_WAIT_STATE_MASK			GENMASK(27, 24)
19362306a36Sopenharmony_ci#define FSR_MODULE_MASK				GENMASK(30, 28)
19462306a36Sopenharmony_ci#define FSR_HALTED				BIT(31)
19562306a36Sopenharmony_ci#define FSR_TO_STATE_CODE(x)			((x) & FSR_STATE_MASK)
19662306a36Sopenharmony_ci#define FSR_TO_WAIT_STATE_CODE(x)		(((x) & FSR_WAIT_STATE_MASK) >> 24)
19762306a36Sopenharmony_ci#define FSR_TO_MODULE_CODE(x)			(((x) & FSR_MODULE_MASK) >> 28)
19862306a36Sopenharmony_ci
19962306a36Sopenharmony_ci/* Wait states */
20062306a36Sopenharmony_ci#define FSR_WAIT_FOR_IPC_BUSY			0x1
20162306a36Sopenharmony_ci#define FSR_WAIT_FOR_IPC_DONE			0x2
20262306a36Sopenharmony_ci#define FSR_WAIT_FOR_CACHE_INVALIDATION		0x3
20362306a36Sopenharmony_ci#define FSR_WAIT_FOR_LP_SRAM_OFF		0x4
20462306a36Sopenharmony_ci#define FSR_WAIT_FOR_DMA_BUFFER_FULL		0x5
20562306a36Sopenharmony_ci#define FSR_WAIT_FOR_CSE_CSR			0x6
20662306a36Sopenharmony_ci
20762306a36Sopenharmony_ci/* Module codes */
20862306a36Sopenharmony_ci#define FSR_MOD_ROM				0x0
20962306a36Sopenharmony_ci#define FSR_MOD_ROM_BYP				0x1
21062306a36Sopenharmony_ci#define FSR_MOD_BASE_FW				0x2
21162306a36Sopenharmony_ci#define FSR_MOD_LP_BOOT				0x3
21262306a36Sopenharmony_ci#define FSR_MOD_BRNGUP				0x4
21362306a36Sopenharmony_ci#define FSR_MOD_ROM_EXT				0x5
21462306a36Sopenharmony_ci
21562306a36Sopenharmony_ci/* State codes (module dependent) */
21662306a36Sopenharmony_ci/* Module independent states */
21762306a36Sopenharmony_ci#define FSR_STATE_INIT				0x0
21862306a36Sopenharmony_ci#define FSR_STATE_INIT_DONE			0x1
21962306a36Sopenharmony_ci#define FSR_STATE_FW_ENTERED			0x5
22062306a36Sopenharmony_ci
22162306a36Sopenharmony_ci/* ROM states */
22262306a36Sopenharmony_ci#define FSR_STATE_ROM_INIT			FSR_STATE_INIT
22362306a36Sopenharmony_ci#define FSR_STATE_ROM_INIT_DONE			FSR_STATE_INIT_DONE
22462306a36Sopenharmony_ci#define FSR_STATE_ROM_CSE_MANIFEST_LOADED	0x2
22562306a36Sopenharmony_ci#define FSR_STATE_ROM_FW_MANIFEST_LOADED	0x3
22662306a36Sopenharmony_ci#define FSR_STATE_ROM_FW_FW_LOADED		0x4
22762306a36Sopenharmony_ci#define FSR_STATE_ROM_FW_ENTERED		FSR_STATE_FW_ENTERED
22862306a36Sopenharmony_ci#define FSR_STATE_ROM_VERIFY_FEATURE_MASK	0x6
22962306a36Sopenharmony_ci#define FSR_STATE_ROM_GET_LOAD_OFFSET		0x7
23062306a36Sopenharmony_ci#define FSR_STATE_ROM_FETCH_ROM_EXT		0x8
23162306a36Sopenharmony_ci#define FSR_STATE_ROM_FETCH_ROM_EXT_DONE	0x9
23262306a36Sopenharmony_ci#define FSR_STATE_ROM_BASEFW_ENTERED		0xf /* SKL */
23362306a36Sopenharmony_ci
23462306a36Sopenharmony_ci/* (ROM) CSE states */
23562306a36Sopenharmony_ci#define FSR_STATE_ROM_CSE_IMR_REQUEST			0x10
23662306a36Sopenharmony_ci#define FSR_STATE_ROM_CSE_IMR_GRANTED			0x11
23762306a36Sopenharmony_ci#define FSR_STATE_ROM_CSE_VALIDATE_IMAGE_REQUEST	0x12
23862306a36Sopenharmony_ci#define FSR_STATE_ROM_CSE_IMAGE_VALIDATED		0x13
23962306a36Sopenharmony_ci
24062306a36Sopenharmony_ci#define FSR_STATE_ROM_CSE_IPC_IFACE_INIT	0x20
24162306a36Sopenharmony_ci#define FSR_STATE_ROM_CSE_IPC_RESET_PHASE_1	0x21
24262306a36Sopenharmony_ci#define FSR_STATE_ROM_CSE_IPC_OPERATIONAL_ENTRY	0x22
24362306a36Sopenharmony_ci#define FSR_STATE_ROM_CSE_IPC_OPERATIONAL	0x23
24462306a36Sopenharmony_ci#define FSR_STATE_ROM_CSE_IPC_DOWN		0x24
24562306a36Sopenharmony_ci
24662306a36Sopenharmony_ci/* BRINGUP (or BRNGUP) states */
24762306a36Sopenharmony_ci#define FSR_STATE_BRINGUP_INIT			FSR_STATE_INIT
24862306a36Sopenharmony_ci#define FSR_STATE_BRINGUP_INIT_DONE		FSR_STATE_INIT_DONE
24962306a36Sopenharmony_ci#define FSR_STATE_BRINGUP_HPSRAM_LOAD		0x2
25062306a36Sopenharmony_ci#define FSR_STATE_BRINGUP_UNPACK_START		0X3
25162306a36Sopenharmony_ci#define FSR_STATE_BRINGUP_IMR_RESTORE		0x4
25262306a36Sopenharmony_ci#define FSR_STATE_BRINGUP_FW_ENTERED		FSR_STATE_FW_ENTERED
25362306a36Sopenharmony_ci
25462306a36Sopenharmony_ci/* ROM  status/error values */
25562306a36Sopenharmony_ci#define HDA_DSP_ROM_CSE_ERROR			40
25662306a36Sopenharmony_ci#define HDA_DSP_ROM_CSE_WRONG_RESPONSE		41
25762306a36Sopenharmony_ci#define HDA_DSP_ROM_IMR_TO_SMALL		42
25862306a36Sopenharmony_ci#define HDA_DSP_ROM_BASE_FW_NOT_FOUND		43
25962306a36Sopenharmony_ci#define HDA_DSP_ROM_CSE_VALIDATION_FAILED	44
26062306a36Sopenharmony_ci#define HDA_DSP_ROM_IPC_FATAL_ERROR		45
26162306a36Sopenharmony_ci#define HDA_DSP_ROM_L2_CACHE_ERROR		46
26262306a36Sopenharmony_ci#define HDA_DSP_ROM_LOAD_OFFSET_TO_SMALL	47
26362306a36Sopenharmony_ci#define HDA_DSP_ROM_API_PTR_INVALID		50
26462306a36Sopenharmony_ci#define HDA_DSP_ROM_BASEFW_INCOMPAT		51
26562306a36Sopenharmony_ci#define HDA_DSP_ROM_UNHANDLED_INTERRUPT		0xBEE00000
26662306a36Sopenharmony_ci#define HDA_DSP_ROM_MEMORY_HOLE_ECC		0xECC00000
26762306a36Sopenharmony_ci#define HDA_DSP_ROM_KERNEL_EXCEPTION		0xCAFE0000
26862306a36Sopenharmony_ci#define HDA_DSP_ROM_USER_EXCEPTION		0xBEEF0000
26962306a36Sopenharmony_ci#define HDA_DSP_ROM_UNEXPECTED_RESET		0xDECAF000
27062306a36Sopenharmony_ci#define HDA_DSP_ROM_NULL_FW_ENTRY		0x4c4c4e55
27162306a36Sopenharmony_ci
27262306a36Sopenharmony_ci#define HDA_DSP_ROM_IPC_CONTROL			0x01000000
27362306a36Sopenharmony_ci#define HDA_DSP_ROM_IPC_PURGE_FW		0x00004000
27462306a36Sopenharmony_ci
27562306a36Sopenharmony_ci/* various timeout values */
27662306a36Sopenharmony_ci#define HDA_DSP_PU_TIMEOUT		50
27762306a36Sopenharmony_ci#define HDA_DSP_PD_TIMEOUT		50
27862306a36Sopenharmony_ci#define HDA_DSP_RESET_TIMEOUT_US	50000
27962306a36Sopenharmony_ci#define HDA_DSP_BASEFW_TIMEOUT_US       3000000
28062306a36Sopenharmony_ci#define HDA_DSP_INIT_TIMEOUT_US	500000
28162306a36Sopenharmony_ci#define HDA_DSP_CTRL_RESET_TIMEOUT		100
28262306a36Sopenharmony_ci#define HDA_DSP_WAIT_TIMEOUT		500	/* 500 msec */
28362306a36Sopenharmony_ci#define HDA_DSP_REG_POLL_INTERVAL_US		500	/* 0.5 msec */
28462306a36Sopenharmony_ci#define HDA_DSP_REG_POLL_RETRY_COUNT		50
28562306a36Sopenharmony_ci
28662306a36Sopenharmony_ci#define HDA_DSP_ADSPIC_IPC			BIT(0)
28762306a36Sopenharmony_ci#define HDA_DSP_ADSPIS_IPC			BIT(0)
28862306a36Sopenharmony_ci
28962306a36Sopenharmony_ci/* Intel HD Audio General DSP Registers */
29062306a36Sopenharmony_ci#define HDA_DSP_GEN_BASE		0x0
29162306a36Sopenharmony_ci#define HDA_DSP_REG_ADSPCS		(HDA_DSP_GEN_BASE + 0x04)
29262306a36Sopenharmony_ci#define HDA_DSP_REG_ADSPIC		(HDA_DSP_GEN_BASE + 0x08)
29362306a36Sopenharmony_ci#define HDA_DSP_REG_ADSPIS		(HDA_DSP_GEN_BASE + 0x0C)
29462306a36Sopenharmony_ci#define HDA_DSP_REG_ADSPIC2		(HDA_DSP_GEN_BASE + 0x10)
29562306a36Sopenharmony_ci#define HDA_DSP_REG_ADSPIS2		(HDA_DSP_GEN_BASE + 0x14)
29662306a36Sopenharmony_ci
29762306a36Sopenharmony_ci#define HDA_DSP_REG_ADSPIC2_SNDW	BIT(5)
29862306a36Sopenharmony_ci#define HDA_DSP_REG_ADSPIS2_SNDW	BIT(5)
29962306a36Sopenharmony_ci
30062306a36Sopenharmony_ci/* Intel HD Audio Inter-Processor Communication Registers */
30162306a36Sopenharmony_ci#define HDA_DSP_IPC_BASE		0x40
30262306a36Sopenharmony_ci#define HDA_DSP_REG_HIPCT		(HDA_DSP_IPC_BASE + 0x00)
30362306a36Sopenharmony_ci#define HDA_DSP_REG_HIPCTE		(HDA_DSP_IPC_BASE + 0x04)
30462306a36Sopenharmony_ci#define HDA_DSP_REG_HIPCI		(HDA_DSP_IPC_BASE + 0x08)
30562306a36Sopenharmony_ci#define HDA_DSP_REG_HIPCIE		(HDA_DSP_IPC_BASE + 0x0C)
30662306a36Sopenharmony_ci#define HDA_DSP_REG_HIPCCTL		(HDA_DSP_IPC_BASE + 0x10)
30762306a36Sopenharmony_ci
30862306a36Sopenharmony_ci/* Intel Vendor Specific Registers */
30962306a36Sopenharmony_ci#define HDA_VS_INTEL_EM2		0x1030
31062306a36Sopenharmony_ci#define HDA_VS_INTEL_EM2_L1SEN		BIT(13)
31162306a36Sopenharmony_ci#define HDA_VS_INTEL_LTRP		0x1048
31262306a36Sopenharmony_ci#define HDA_VS_INTEL_LTRP_GB_MASK	0x3F
31362306a36Sopenharmony_ci
31462306a36Sopenharmony_ci/*  HIPCI */
31562306a36Sopenharmony_ci#define HDA_DSP_REG_HIPCI_BUSY		BIT(31)
31662306a36Sopenharmony_ci#define HDA_DSP_REG_HIPCI_MSG_MASK	0x7FFFFFFF
31762306a36Sopenharmony_ci
31862306a36Sopenharmony_ci/* HIPCIE */
31962306a36Sopenharmony_ci#define HDA_DSP_REG_HIPCIE_DONE	BIT(30)
32062306a36Sopenharmony_ci#define HDA_DSP_REG_HIPCIE_MSG_MASK	0x3FFFFFFF
32162306a36Sopenharmony_ci
32262306a36Sopenharmony_ci/* HIPCCTL */
32362306a36Sopenharmony_ci#define HDA_DSP_REG_HIPCCTL_DONE	BIT(1)
32462306a36Sopenharmony_ci#define HDA_DSP_REG_HIPCCTL_BUSY	BIT(0)
32562306a36Sopenharmony_ci
32662306a36Sopenharmony_ci/* HIPCT */
32762306a36Sopenharmony_ci#define HDA_DSP_REG_HIPCT_BUSY		BIT(31)
32862306a36Sopenharmony_ci#define HDA_DSP_REG_HIPCT_MSG_MASK	0x7FFFFFFF
32962306a36Sopenharmony_ci
33062306a36Sopenharmony_ci/* HIPCTE */
33162306a36Sopenharmony_ci#define HDA_DSP_REG_HIPCTE_MSG_MASK	0x3FFFFFFF
33262306a36Sopenharmony_ci
33362306a36Sopenharmony_ci#define HDA_DSP_ADSPIC_CL_DMA		BIT(1)
33462306a36Sopenharmony_ci#define HDA_DSP_ADSPIS_CL_DMA		BIT(1)
33562306a36Sopenharmony_ci
33662306a36Sopenharmony_ci/* Delay before scheduling D0i3 entry */
33762306a36Sopenharmony_ci#define BXT_D0I3_DELAY 5000
33862306a36Sopenharmony_ci
33962306a36Sopenharmony_ci#define FW_CL_STREAM_NUMBER		0x1
34062306a36Sopenharmony_ci#define HDA_FW_BOOT_ATTEMPTS		3
34162306a36Sopenharmony_ci
34262306a36Sopenharmony_ci/* ADSPCS - Audio DSP Control & Status */
34362306a36Sopenharmony_ci
34462306a36Sopenharmony_ci/*
34562306a36Sopenharmony_ci * Core Reset - asserted high
34662306a36Sopenharmony_ci * CRST Mask for a given core mask pattern, cm
34762306a36Sopenharmony_ci */
34862306a36Sopenharmony_ci#define HDA_DSP_ADSPCS_CRST_SHIFT	0
34962306a36Sopenharmony_ci#define HDA_DSP_ADSPCS_CRST_MASK(cm)	((cm) << HDA_DSP_ADSPCS_CRST_SHIFT)
35062306a36Sopenharmony_ci
35162306a36Sopenharmony_ci/*
35262306a36Sopenharmony_ci * Core run/stall - when set to '1' core is stalled
35362306a36Sopenharmony_ci * CSTALL Mask for a given core mask pattern, cm
35462306a36Sopenharmony_ci */
35562306a36Sopenharmony_ci#define HDA_DSP_ADSPCS_CSTALL_SHIFT	8
35662306a36Sopenharmony_ci#define HDA_DSP_ADSPCS_CSTALL_MASK(cm)	((cm) << HDA_DSP_ADSPCS_CSTALL_SHIFT)
35762306a36Sopenharmony_ci
35862306a36Sopenharmony_ci/*
35962306a36Sopenharmony_ci * Set Power Active - when set to '1' turn cores on
36062306a36Sopenharmony_ci * SPA Mask for a given core mask pattern, cm
36162306a36Sopenharmony_ci */
36262306a36Sopenharmony_ci#define HDA_DSP_ADSPCS_SPA_SHIFT	16
36362306a36Sopenharmony_ci#define HDA_DSP_ADSPCS_SPA_MASK(cm)	((cm) << HDA_DSP_ADSPCS_SPA_SHIFT)
36462306a36Sopenharmony_ci
36562306a36Sopenharmony_ci/*
36662306a36Sopenharmony_ci * Current Power Active - power status of cores, set by hardware
36762306a36Sopenharmony_ci * CPA Mask for a given core mask pattern, cm
36862306a36Sopenharmony_ci */
36962306a36Sopenharmony_ci#define HDA_DSP_ADSPCS_CPA_SHIFT	24
37062306a36Sopenharmony_ci#define HDA_DSP_ADSPCS_CPA_MASK(cm)	((cm) << HDA_DSP_ADSPCS_CPA_SHIFT)
37162306a36Sopenharmony_ci
37262306a36Sopenharmony_ci/*
37362306a36Sopenharmony_ci * Mask for a given number of cores
37462306a36Sopenharmony_ci * nc = number of supported cores
37562306a36Sopenharmony_ci */
37662306a36Sopenharmony_ci#define SOF_DSP_CORES_MASK(nc)	GENMASK(((nc) - 1), 0)
37762306a36Sopenharmony_ci
37862306a36Sopenharmony_ci/* Intel HD Audio Inter-Processor Communication Registers for Cannonlake*/
37962306a36Sopenharmony_ci#define CNL_DSP_IPC_BASE		0xc0
38062306a36Sopenharmony_ci#define CNL_DSP_REG_HIPCTDR		(CNL_DSP_IPC_BASE + 0x00)
38162306a36Sopenharmony_ci#define CNL_DSP_REG_HIPCTDA		(CNL_DSP_IPC_BASE + 0x04)
38262306a36Sopenharmony_ci#define CNL_DSP_REG_HIPCTDD		(CNL_DSP_IPC_BASE + 0x08)
38362306a36Sopenharmony_ci#define CNL_DSP_REG_HIPCIDR		(CNL_DSP_IPC_BASE + 0x10)
38462306a36Sopenharmony_ci#define CNL_DSP_REG_HIPCIDA		(CNL_DSP_IPC_BASE + 0x14)
38562306a36Sopenharmony_ci#define CNL_DSP_REG_HIPCIDD		(CNL_DSP_IPC_BASE + 0x18)
38662306a36Sopenharmony_ci#define CNL_DSP_REG_HIPCCTL		(CNL_DSP_IPC_BASE + 0x28)
38762306a36Sopenharmony_ci
38862306a36Sopenharmony_ci/*  HIPCI */
38962306a36Sopenharmony_ci#define CNL_DSP_REG_HIPCIDR_BUSY		BIT(31)
39062306a36Sopenharmony_ci#define CNL_DSP_REG_HIPCIDR_MSG_MASK	0x7FFFFFFF
39162306a36Sopenharmony_ci
39262306a36Sopenharmony_ci/* HIPCIE */
39362306a36Sopenharmony_ci#define CNL_DSP_REG_HIPCIDA_DONE	BIT(31)
39462306a36Sopenharmony_ci#define CNL_DSP_REG_HIPCIDA_MSG_MASK	0x7FFFFFFF
39562306a36Sopenharmony_ci
39662306a36Sopenharmony_ci/* HIPCCTL */
39762306a36Sopenharmony_ci#define CNL_DSP_REG_HIPCCTL_DONE	BIT(1)
39862306a36Sopenharmony_ci#define CNL_DSP_REG_HIPCCTL_BUSY	BIT(0)
39962306a36Sopenharmony_ci
40062306a36Sopenharmony_ci/* HIPCT */
40162306a36Sopenharmony_ci#define CNL_DSP_REG_HIPCTDR_BUSY		BIT(31)
40262306a36Sopenharmony_ci#define CNL_DSP_REG_HIPCTDR_MSG_MASK	0x7FFFFFFF
40362306a36Sopenharmony_ci
40462306a36Sopenharmony_ci/* HIPCTDA */
40562306a36Sopenharmony_ci#define CNL_DSP_REG_HIPCTDA_DONE	BIT(31)
40662306a36Sopenharmony_ci#define CNL_DSP_REG_HIPCTDA_MSG_MASK	0x7FFFFFFF
40762306a36Sopenharmony_ci
40862306a36Sopenharmony_ci/* HIPCTDD */
40962306a36Sopenharmony_ci#define CNL_DSP_REG_HIPCTDD_MSG_MASK	0x7FFFFFFF
41062306a36Sopenharmony_ci
41162306a36Sopenharmony_ci/* BDL */
41262306a36Sopenharmony_ci#define HDA_DSP_BDL_SIZE			4096
41362306a36Sopenharmony_ci#define HDA_DSP_MAX_BDL_ENTRIES			\
41462306a36Sopenharmony_ci	(HDA_DSP_BDL_SIZE / sizeof(struct sof_intel_dsp_bdl))
41562306a36Sopenharmony_ci
41662306a36Sopenharmony_ci/* Number of DAIs */
41762306a36Sopenharmony_ci#define SOF_SKL_NUM_DAIS_NOCODEC	8
41862306a36Sopenharmony_ci
41962306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
42062306a36Sopenharmony_ci#define SOF_SKL_NUM_DAIS		15
42162306a36Sopenharmony_ci#else
42262306a36Sopenharmony_ci#define SOF_SKL_NUM_DAIS		SOF_SKL_NUM_DAIS_NOCODEC
42362306a36Sopenharmony_ci#endif
42462306a36Sopenharmony_ci
42562306a36Sopenharmony_ci/* Intel HD Audio SRAM Window 0*/
42662306a36Sopenharmony_ci#define HDA_DSP_SRAM_REG_ROM_STATUS_SKL	0x8000
42762306a36Sopenharmony_ci#define HDA_ADSP_SRAM0_BASE_SKL		0x8000
42862306a36Sopenharmony_ci
42962306a36Sopenharmony_ci/* Firmware status window */
43062306a36Sopenharmony_ci#define HDA_ADSP_FW_STATUS_SKL		HDA_ADSP_SRAM0_BASE_SKL
43162306a36Sopenharmony_ci#define HDA_ADSP_ERROR_CODE_SKL		(HDA_ADSP_FW_STATUS_SKL + 0x4)
43262306a36Sopenharmony_ci
43362306a36Sopenharmony_ci/* Host Device Memory Space */
43462306a36Sopenharmony_ci#define APL_SSP_BASE_OFFSET	0x2000
43562306a36Sopenharmony_ci#define CNL_SSP_BASE_OFFSET	0x10000
43662306a36Sopenharmony_ci
43762306a36Sopenharmony_ci/* Host Device Memory Size of a Single SSP */
43862306a36Sopenharmony_ci#define SSP_DEV_MEM_SIZE	0x1000
43962306a36Sopenharmony_ci
44062306a36Sopenharmony_ci/* SSP Count of the Platform */
44162306a36Sopenharmony_ci#define APL_SSP_COUNT		6
44262306a36Sopenharmony_ci#define CNL_SSP_COUNT		3
44362306a36Sopenharmony_ci#define ICL_SSP_COUNT		6
44462306a36Sopenharmony_ci#define TGL_SSP_COUNT		3
44562306a36Sopenharmony_ci#define MTL_SSP_COUNT		3
44662306a36Sopenharmony_ci
44762306a36Sopenharmony_ci/* SSP Registers */
44862306a36Sopenharmony_ci#define SSP_SSC1_OFFSET		0x4
44962306a36Sopenharmony_ci#define SSP_SET_SCLK_CONSUMER	BIT(25)
45062306a36Sopenharmony_ci#define SSP_SET_SFRM_CONSUMER	BIT(24)
45162306a36Sopenharmony_ci#define SSP_SET_CBP_CFP		(SSP_SET_SCLK_CONSUMER | SSP_SET_SFRM_CONSUMER)
45262306a36Sopenharmony_ci
45362306a36Sopenharmony_ci#define HDA_IDISP_ADDR		2
45462306a36Sopenharmony_ci#define HDA_IDISP_CODEC(x) ((x) & BIT(HDA_IDISP_ADDR))
45562306a36Sopenharmony_ci
45662306a36Sopenharmony_cistruct sof_intel_dsp_bdl {
45762306a36Sopenharmony_ci	__le32 addr_l;
45862306a36Sopenharmony_ci	__le32 addr_h;
45962306a36Sopenharmony_ci	__le32 size;
46062306a36Sopenharmony_ci	__le32 ioc;
46162306a36Sopenharmony_ci} __attribute((packed));
46262306a36Sopenharmony_ci
46362306a36Sopenharmony_ci#define SOF_HDA_PLAYBACK_STREAMS	16
46462306a36Sopenharmony_ci#define SOF_HDA_CAPTURE_STREAMS		16
46562306a36Sopenharmony_ci#define SOF_HDA_PLAYBACK		0
46662306a36Sopenharmony_ci#define SOF_HDA_CAPTURE			1
46762306a36Sopenharmony_ci
46862306a36Sopenharmony_ci/* stream flags */
46962306a36Sopenharmony_ci#define SOF_HDA_STREAM_DMI_L1_COMPATIBLE	1
47062306a36Sopenharmony_ci
47162306a36Sopenharmony_ci/*
47262306a36Sopenharmony_ci * Time in ms for opportunistic D0I3 entry delay.
47362306a36Sopenharmony_ci * This has been deliberately chosen to be long to avoid race conditions.
47462306a36Sopenharmony_ci * Could be optimized in future.
47562306a36Sopenharmony_ci */
47662306a36Sopenharmony_ci#define SOF_HDA_D0I3_WORK_DELAY_MS	5000
47762306a36Sopenharmony_ci
47862306a36Sopenharmony_ci/* HDA DSP D0 substate */
47962306a36Sopenharmony_cienum sof_hda_D0_substate {
48062306a36Sopenharmony_ci	SOF_HDA_DSP_PM_D0I0,	/* default D0 substate */
48162306a36Sopenharmony_ci	SOF_HDA_DSP_PM_D0I3,	/* low power D0 substate */
48262306a36Sopenharmony_ci};
48362306a36Sopenharmony_ci
48462306a36Sopenharmony_ci/* represents DSP HDA controller frontend - i.e. host facing control */
48562306a36Sopenharmony_cistruct sof_intel_hda_dev {
48662306a36Sopenharmony_ci	bool imrboot_supported;
48762306a36Sopenharmony_ci	bool skip_imr_boot;
48862306a36Sopenharmony_ci	bool booted_from_imr;
48962306a36Sopenharmony_ci
49062306a36Sopenharmony_ci	int boot_iteration;
49162306a36Sopenharmony_ci
49262306a36Sopenharmony_ci	struct hda_bus hbus;
49362306a36Sopenharmony_ci
49462306a36Sopenharmony_ci	/* hw config */
49562306a36Sopenharmony_ci	const struct sof_intel_dsp_desc *desc;
49662306a36Sopenharmony_ci
49762306a36Sopenharmony_ci	/* trace */
49862306a36Sopenharmony_ci	struct hdac_ext_stream *dtrace_stream;
49962306a36Sopenharmony_ci
50062306a36Sopenharmony_ci	/* if position update IPC needed */
50162306a36Sopenharmony_ci	u32 no_ipc_position;
50262306a36Sopenharmony_ci
50362306a36Sopenharmony_ci	/* the maximum number of streams (playback + capture) supported */
50462306a36Sopenharmony_ci	u32 stream_max;
50562306a36Sopenharmony_ci
50662306a36Sopenharmony_ci	/* PM related */
50762306a36Sopenharmony_ci	bool l1_disabled;/* is DMI link L1 disabled? */
50862306a36Sopenharmony_ci
50962306a36Sopenharmony_ci	/* DMIC device */
51062306a36Sopenharmony_ci	struct platform_device *dmic_dev;
51162306a36Sopenharmony_ci
51262306a36Sopenharmony_ci	/* delayed work to enter D0I3 opportunistically */
51362306a36Sopenharmony_ci	struct delayed_work d0i3_work;
51462306a36Sopenharmony_ci
51562306a36Sopenharmony_ci	/* ACPI information stored between scan and probe steps */
51662306a36Sopenharmony_ci	struct sdw_intel_acpi_info info;
51762306a36Sopenharmony_ci
51862306a36Sopenharmony_ci	/* sdw context allocated by SoundWire driver */
51962306a36Sopenharmony_ci	struct sdw_intel_ctx *sdw;
52062306a36Sopenharmony_ci
52162306a36Sopenharmony_ci	/* FW clock config, 0:HPRO, 1:LPRO */
52262306a36Sopenharmony_ci	bool clk_config_lpro;
52362306a36Sopenharmony_ci
52462306a36Sopenharmony_ci	wait_queue_head_t waitq;
52562306a36Sopenharmony_ci	bool code_loading;
52662306a36Sopenharmony_ci
52762306a36Sopenharmony_ci	/* Intel NHLT information */
52862306a36Sopenharmony_ci	struct nhlt_acpi_table *nhlt;
52962306a36Sopenharmony_ci
53062306a36Sopenharmony_ci	/*
53162306a36Sopenharmony_ci	 * Pointing to the IPC message if immediate sending was not possible
53262306a36Sopenharmony_ci	 * because the downlink communication channel was BUSY at the time.
53362306a36Sopenharmony_ci	 * The message will be re-tried when the channel becomes free (the ACK
53462306a36Sopenharmony_ci	 * is received from the DSP for the previous message)
53562306a36Sopenharmony_ci	 */
53662306a36Sopenharmony_ci	struct snd_sof_ipc_msg *delayed_ipc_tx_msg;
53762306a36Sopenharmony_ci};
53862306a36Sopenharmony_ci
53962306a36Sopenharmony_cistatic inline struct hdac_bus *sof_to_bus(struct snd_sof_dev *s)
54062306a36Sopenharmony_ci{
54162306a36Sopenharmony_ci	struct sof_intel_hda_dev *hda = s->pdata->hw_pdata;
54262306a36Sopenharmony_ci
54362306a36Sopenharmony_ci	return &hda->hbus.core;
54462306a36Sopenharmony_ci}
54562306a36Sopenharmony_ci
54662306a36Sopenharmony_cistatic inline struct hda_bus *sof_to_hbus(struct snd_sof_dev *s)
54762306a36Sopenharmony_ci{
54862306a36Sopenharmony_ci	struct sof_intel_hda_dev *hda = s->pdata->hw_pdata;
54962306a36Sopenharmony_ci
55062306a36Sopenharmony_ci	return &hda->hbus;
55162306a36Sopenharmony_ci}
55262306a36Sopenharmony_ci
55362306a36Sopenharmony_cistruct sof_intel_hda_stream {
55462306a36Sopenharmony_ci	struct snd_sof_dev *sdev;
55562306a36Sopenharmony_ci	struct hdac_ext_stream hext_stream;
55662306a36Sopenharmony_ci	struct sof_intel_stream sof_intel_stream;
55762306a36Sopenharmony_ci	int host_reserved; /* reserve host DMA channel */
55862306a36Sopenharmony_ci	u32 flags;
55962306a36Sopenharmony_ci};
56062306a36Sopenharmony_ci
56162306a36Sopenharmony_ci#define hstream_to_sof_hda_stream(hstream) \
56262306a36Sopenharmony_ci	container_of(hstream, struct sof_intel_hda_stream, hext_stream)
56362306a36Sopenharmony_ci
56462306a36Sopenharmony_ci#define bus_to_sof_hda(bus) \
56562306a36Sopenharmony_ci	container_of(bus, struct sof_intel_hda_dev, hbus.core)
56662306a36Sopenharmony_ci
56762306a36Sopenharmony_ci#define SOF_STREAM_SD_OFFSET(s) \
56862306a36Sopenharmony_ci	(SOF_HDA_ADSP_SD_ENTRY_SIZE * ((s)->index) \
56962306a36Sopenharmony_ci	 + SOF_HDA_ADSP_LOADER_BASE)
57062306a36Sopenharmony_ci
57162306a36Sopenharmony_ci#define SOF_STREAM_SD_OFFSET_CRST 0x1
57262306a36Sopenharmony_ci
57362306a36Sopenharmony_ci/*
57462306a36Sopenharmony_ci * DSP Core services.
57562306a36Sopenharmony_ci */
57662306a36Sopenharmony_ciint hda_dsp_probe(struct snd_sof_dev *sdev);
57762306a36Sopenharmony_ciint hda_dsp_remove(struct snd_sof_dev *sdev);
57862306a36Sopenharmony_ciint hda_dsp_core_power_up(struct snd_sof_dev *sdev, unsigned int core_mask);
57962306a36Sopenharmony_ciint hda_dsp_core_run(struct snd_sof_dev *sdev, unsigned int core_mask);
58062306a36Sopenharmony_ciint hda_dsp_enable_core(struct snd_sof_dev *sdev, unsigned int core_mask);
58162306a36Sopenharmony_ciint hda_dsp_core_reset_power_down(struct snd_sof_dev *sdev,
58262306a36Sopenharmony_ci				  unsigned int core_mask);
58362306a36Sopenharmony_ciint hda_power_down_dsp(struct snd_sof_dev *sdev);
58462306a36Sopenharmony_ciint hda_dsp_core_get(struct snd_sof_dev *sdev, int core);
58562306a36Sopenharmony_civoid hda_dsp_ipc_int_enable(struct snd_sof_dev *sdev);
58662306a36Sopenharmony_civoid hda_dsp_ipc_int_disable(struct snd_sof_dev *sdev);
58762306a36Sopenharmony_cibool hda_dsp_core_is_enabled(struct snd_sof_dev *sdev, unsigned int core_mask);
58862306a36Sopenharmony_ci
58962306a36Sopenharmony_ciint hda_dsp_set_power_state_ipc3(struct snd_sof_dev *sdev,
59062306a36Sopenharmony_ci				 const struct sof_dsp_power_state *target_state);
59162306a36Sopenharmony_ciint hda_dsp_set_power_state_ipc4(struct snd_sof_dev *sdev,
59262306a36Sopenharmony_ci				 const struct sof_dsp_power_state *target_state);
59362306a36Sopenharmony_ci
59462306a36Sopenharmony_ciint hda_dsp_suspend(struct snd_sof_dev *sdev, u32 target_state);
59562306a36Sopenharmony_ciint hda_dsp_resume(struct snd_sof_dev *sdev);
59662306a36Sopenharmony_ciint hda_dsp_runtime_suspend(struct snd_sof_dev *sdev);
59762306a36Sopenharmony_ciint hda_dsp_runtime_resume(struct snd_sof_dev *sdev);
59862306a36Sopenharmony_ciint hda_dsp_runtime_idle(struct snd_sof_dev *sdev);
59962306a36Sopenharmony_ciint hda_dsp_shutdown_dma_flush(struct snd_sof_dev *sdev);
60062306a36Sopenharmony_ciint hda_dsp_shutdown(struct snd_sof_dev *sdev);
60162306a36Sopenharmony_ciint hda_dsp_set_hw_params_upon_resume(struct snd_sof_dev *sdev);
60262306a36Sopenharmony_civoid hda_dsp_dump(struct snd_sof_dev *sdev, u32 flags);
60362306a36Sopenharmony_civoid hda_ipc_dump(struct snd_sof_dev *sdev);
60462306a36Sopenharmony_civoid hda_ipc_irq_dump(struct snd_sof_dev *sdev);
60562306a36Sopenharmony_civoid hda_dsp_d0i3_work(struct work_struct *work);
60662306a36Sopenharmony_ciint hda_dsp_disable_interrupts(struct snd_sof_dev *sdev);
60762306a36Sopenharmony_ci
60862306a36Sopenharmony_ci/*
60962306a36Sopenharmony_ci * DSP PCM Operations.
61062306a36Sopenharmony_ci */
61162306a36Sopenharmony_ciu32 hda_dsp_get_mult_div(struct snd_sof_dev *sdev, int rate);
61262306a36Sopenharmony_ciu32 hda_dsp_get_bits(struct snd_sof_dev *sdev, int sample_bits);
61362306a36Sopenharmony_ciint hda_dsp_pcm_open(struct snd_sof_dev *sdev,
61462306a36Sopenharmony_ci		     struct snd_pcm_substream *substream);
61562306a36Sopenharmony_ciint hda_dsp_pcm_close(struct snd_sof_dev *sdev,
61662306a36Sopenharmony_ci		      struct snd_pcm_substream *substream);
61762306a36Sopenharmony_ciint hda_dsp_pcm_hw_params(struct snd_sof_dev *sdev,
61862306a36Sopenharmony_ci			  struct snd_pcm_substream *substream,
61962306a36Sopenharmony_ci			  struct snd_pcm_hw_params *params,
62062306a36Sopenharmony_ci			  struct snd_sof_platform_stream_params *platform_params);
62162306a36Sopenharmony_ciint hda_dsp_stream_hw_free(struct snd_sof_dev *sdev,
62262306a36Sopenharmony_ci			   struct snd_pcm_substream *substream);
62362306a36Sopenharmony_ciint hda_dsp_pcm_trigger(struct snd_sof_dev *sdev,
62462306a36Sopenharmony_ci			struct snd_pcm_substream *substream, int cmd);
62562306a36Sopenharmony_cisnd_pcm_uframes_t hda_dsp_pcm_pointer(struct snd_sof_dev *sdev,
62662306a36Sopenharmony_ci				      struct snd_pcm_substream *substream);
62762306a36Sopenharmony_ciint hda_dsp_pcm_ack(struct snd_sof_dev *sdev, struct snd_pcm_substream *substream);
62862306a36Sopenharmony_ci
62962306a36Sopenharmony_ci/*
63062306a36Sopenharmony_ci * DSP Stream Operations.
63162306a36Sopenharmony_ci */
63262306a36Sopenharmony_ci
63362306a36Sopenharmony_ciint hda_dsp_stream_init(struct snd_sof_dev *sdev);
63462306a36Sopenharmony_civoid hda_dsp_stream_free(struct snd_sof_dev *sdev);
63562306a36Sopenharmony_ciint hda_dsp_stream_hw_params(struct snd_sof_dev *sdev,
63662306a36Sopenharmony_ci			     struct hdac_ext_stream *hext_stream,
63762306a36Sopenharmony_ci			     struct snd_dma_buffer *dmab,
63862306a36Sopenharmony_ci			     struct snd_pcm_hw_params *params);
63962306a36Sopenharmony_ciint hda_dsp_iccmax_stream_hw_params(struct snd_sof_dev *sdev,
64062306a36Sopenharmony_ci				    struct hdac_ext_stream *hext_stream,
64162306a36Sopenharmony_ci				    struct snd_dma_buffer *dmab,
64262306a36Sopenharmony_ci				    struct snd_pcm_hw_params *params);
64362306a36Sopenharmony_ciint hda_dsp_stream_trigger(struct snd_sof_dev *sdev,
64462306a36Sopenharmony_ci			   struct hdac_ext_stream *hext_stream, int cmd);
64562306a36Sopenharmony_ciirqreturn_t hda_dsp_stream_threaded_handler(int irq, void *context);
64662306a36Sopenharmony_ciint hda_dsp_stream_setup_bdl(struct snd_sof_dev *sdev,
64762306a36Sopenharmony_ci			     struct snd_dma_buffer *dmab,
64862306a36Sopenharmony_ci			     struct hdac_stream *hstream);
64962306a36Sopenharmony_cibool hda_dsp_check_ipc_irq(struct snd_sof_dev *sdev);
65062306a36Sopenharmony_cibool hda_dsp_check_stream_irq(struct snd_sof_dev *sdev);
65162306a36Sopenharmony_ci
65262306a36Sopenharmony_cisnd_pcm_uframes_t hda_dsp_stream_get_position(struct hdac_stream *hstream,
65362306a36Sopenharmony_ci					      int direction, bool can_sleep);
65462306a36Sopenharmony_ci
65562306a36Sopenharmony_cistruct hdac_ext_stream *
65662306a36Sopenharmony_ci	hda_dsp_stream_get(struct snd_sof_dev *sdev, int direction, u32 flags);
65762306a36Sopenharmony_ciint hda_dsp_stream_put(struct snd_sof_dev *sdev, int direction, int stream_tag);
65862306a36Sopenharmony_ciint hda_dsp_stream_spib_config(struct snd_sof_dev *sdev,
65962306a36Sopenharmony_ci			       struct hdac_ext_stream *hext_stream,
66062306a36Sopenharmony_ci			       int enable, u32 size);
66162306a36Sopenharmony_ci
66262306a36Sopenharmony_ciint hda_ipc_msg_data(struct snd_sof_dev *sdev,
66362306a36Sopenharmony_ci		     struct snd_sof_pcm_stream *sps,
66462306a36Sopenharmony_ci		     void *p, size_t sz);
66562306a36Sopenharmony_ciint hda_set_stream_data_offset(struct snd_sof_dev *sdev,
66662306a36Sopenharmony_ci			       struct snd_sof_pcm_stream *sps,
66762306a36Sopenharmony_ci			       size_t posn_offset);
66862306a36Sopenharmony_ci
66962306a36Sopenharmony_ci/*
67062306a36Sopenharmony_ci * DSP IPC Operations.
67162306a36Sopenharmony_ci */
67262306a36Sopenharmony_ciint hda_dsp_ipc_send_msg(struct snd_sof_dev *sdev,
67362306a36Sopenharmony_ci			 struct snd_sof_ipc_msg *msg);
67462306a36Sopenharmony_civoid hda_dsp_ipc_get_reply(struct snd_sof_dev *sdev);
67562306a36Sopenharmony_ciint hda_dsp_ipc_get_mailbox_offset(struct snd_sof_dev *sdev);
67662306a36Sopenharmony_ciint hda_dsp_ipc_get_window_offset(struct snd_sof_dev *sdev, u32 id);
67762306a36Sopenharmony_ci
67862306a36Sopenharmony_ciirqreturn_t hda_dsp_ipc_irq_thread(int irq, void *context);
67962306a36Sopenharmony_ciint hda_dsp_ipc_cmd_done(struct snd_sof_dev *sdev, int dir);
68062306a36Sopenharmony_ci
68162306a36Sopenharmony_ci/*
68262306a36Sopenharmony_ci * DSP Code loader.
68362306a36Sopenharmony_ci */
68462306a36Sopenharmony_ciint hda_dsp_cl_boot_firmware(struct snd_sof_dev *sdev);
68562306a36Sopenharmony_ciint hda_dsp_cl_boot_firmware_iccmax(struct snd_sof_dev *sdev);
68662306a36Sopenharmony_ciint hda_cl_copy_fw(struct snd_sof_dev *sdev, struct hdac_ext_stream *hext_stream);
68762306a36Sopenharmony_cistruct hdac_ext_stream *hda_cl_stream_prepare(struct snd_sof_dev *sdev, unsigned int format,
68862306a36Sopenharmony_ci					      unsigned int size, struct snd_dma_buffer *dmab,
68962306a36Sopenharmony_ci					      int direction);
69062306a36Sopenharmony_ciint hda_cl_cleanup(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab,
69162306a36Sopenharmony_ci		   struct hdac_ext_stream *hext_stream);
69262306a36Sopenharmony_ciint cl_dsp_init(struct snd_sof_dev *sdev, int stream_tag, bool imr_boot);
69362306a36Sopenharmony_ci#define HDA_CL_STREAM_FORMAT 0x40
69462306a36Sopenharmony_ci
69562306a36Sopenharmony_ci/* pre and post fw run ops */
69662306a36Sopenharmony_ciint hda_dsp_pre_fw_run(struct snd_sof_dev *sdev);
69762306a36Sopenharmony_ciint hda_dsp_post_fw_run(struct snd_sof_dev *sdev);
69862306a36Sopenharmony_ci
69962306a36Sopenharmony_ci/* parse platform specific ext manifest ops */
70062306a36Sopenharmony_ciint hda_dsp_ext_man_get_cavs_config_data(struct snd_sof_dev *sdev,
70162306a36Sopenharmony_ci					 const struct sof_ext_man_elem_header *hdr);
70262306a36Sopenharmony_ci
70362306a36Sopenharmony_ci/*
70462306a36Sopenharmony_ci * HDA Controller Operations.
70562306a36Sopenharmony_ci */
70662306a36Sopenharmony_ciint hda_dsp_ctrl_get_caps(struct snd_sof_dev *sdev);
70762306a36Sopenharmony_civoid hda_dsp_ctrl_ppcap_enable(struct snd_sof_dev *sdev, bool enable);
70862306a36Sopenharmony_civoid hda_dsp_ctrl_ppcap_int_enable(struct snd_sof_dev *sdev, bool enable);
70962306a36Sopenharmony_ciint hda_dsp_ctrl_link_reset(struct snd_sof_dev *sdev, bool reset);
71062306a36Sopenharmony_civoid hda_dsp_ctrl_misc_clock_gating(struct snd_sof_dev *sdev, bool enable);
71162306a36Sopenharmony_ciint hda_dsp_ctrl_clock_power_gating(struct snd_sof_dev *sdev, bool enable);
71262306a36Sopenharmony_ciint hda_dsp_ctrl_init_chip(struct snd_sof_dev *sdev);
71362306a36Sopenharmony_civoid hda_dsp_ctrl_stop_chip(struct snd_sof_dev *sdev);
71462306a36Sopenharmony_ci/*
71562306a36Sopenharmony_ci * HDA bus operations.
71662306a36Sopenharmony_ci */
71762306a36Sopenharmony_civoid sof_hda_bus_init(struct snd_sof_dev *sdev, struct device *dev);
71862306a36Sopenharmony_civoid sof_hda_bus_exit(struct snd_sof_dev *sdev);
71962306a36Sopenharmony_ci
72062306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC)
72162306a36Sopenharmony_ci/*
72262306a36Sopenharmony_ci * HDA Codec operations.
72362306a36Sopenharmony_ci */
72462306a36Sopenharmony_civoid hda_codec_probe_bus(struct snd_sof_dev *sdev);
72562306a36Sopenharmony_civoid hda_codec_jack_wake_enable(struct snd_sof_dev *sdev, bool enable);
72662306a36Sopenharmony_civoid hda_codec_jack_check(struct snd_sof_dev *sdev);
72762306a36Sopenharmony_civoid hda_codec_check_for_state_change(struct snd_sof_dev *sdev);
72862306a36Sopenharmony_civoid hda_codec_init_cmd_io(struct snd_sof_dev *sdev);
72962306a36Sopenharmony_civoid hda_codec_resume_cmd_io(struct snd_sof_dev *sdev);
73062306a36Sopenharmony_civoid hda_codec_stop_cmd_io(struct snd_sof_dev *sdev);
73162306a36Sopenharmony_civoid hda_codec_suspend_cmd_io(struct snd_sof_dev *sdev);
73262306a36Sopenharmony_civoid hda_codec_detect_mask(struct snd_sof_dev *sdev);
73362306a36Sopenharmony_civoid hda_codec_rirb_status_clear(struct snd_sof_dev *sdev);
73462306a36Sopenharmony_cibool hda_codec_check_rirb_status(struct snd_sof_dev *sdev);
73562306a36Sopenharmony_civoid hda_codec_set_codec_wakeup(struct snd_sof_dev *sdev, bool status);
73662306a36Sopenharmony_civoid hda_codec_device_remove(struct snd_sof_dev *sdev);
73762306a36Sopenharmony_ci
73862306a36Sopenharmony_ci#else
73962306a36Sopenharmony_ci
74062306a36Sopenharmony_cistatic inline void hda_codec_probe_bus(struct snd_sof_dev *sdev) { }
74162306a36Sopenharmony_cistatic inline void hda_codec_jack_wake_enable(struct snd_sof_dev *sdev, bool enable) { }
74262306a36Sopenharmony_cistatic inline void hda_codec_jack_check(struct snd_sof_dev *sdev) { }
74362306a36Sopenharmony_cistatic inline void hda_codec_check_for_state_change(struct snd_sof_dev *sdev) { }
74462306a36Sopenharmony_cistatic inline void hda_codec_init_cmd_io(struct snd_sof_dev *sdev) { }
74562306a36Sopenharmony_cistatic inline void hda_codec_resume_cmd_io(struct snd_sof_dev *sdev) { }
74662306a36Sopenharmony_cistatic inline void hda_codec_stop_cmd_io(struct snd_sof_dev *sdev) { }
74762306a36Sopenharmony_cistatic inline void hda_codec_suspend_cmd_io(struct snd_sof_dev *sdev) { }
74862306a36Sopenharmony_cistatic inline void hda_codec_detect_mask(struct snd_sof_dev *sdev) { }
74962306a36Sopenharmony_cistatic inline void hda_codec_rirb_status_clear(struct snd_sof_dev *sdev) { }
75062306a36Sopenharmony_cistatic inline bool hda_codec_check_rirb_status(struct snd_sof_dev *sdev) { return false; }
75162306a36Sopenharmony_cistatic inline void hda_codec_set_codec_wakeup(struct snd_sof_dev *sdev, bool status) { }
75262306a36Sopenharmony_cistatic inline void hda_codec_device_remove(struct snd_sof_dev *sdev) { }
75362306a36Sopenharmony_ci
75462306a36Sopenharmony_ci#endif /* CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC */
75562306a36Sopenharmony_ci
75662306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_AUDIO_CODEC) && IS_ENABLED(CONFIG_SND_HDA_CODEC_HDMI)
75762306a36Sopenharmony_ci
75862306a36Sopenharmony_civoid hda_codec_i915_display_power(struct snd_sof_dev *sdev, bool enable);
75962306a36Sopenharmony_ciint hda_codec_i915_init(struct snd_sof_dev *sdev);
76062306a36Sopenharmony_ciint hda_codec_i915_exit(struct snd_sof_dev *sdev);
76162306a36Sopenharmony_ci
76262306a36Sopenharmony_ci#else
76362306a36Sopenharmony_ci
76462306a36Sopenharmony_cistatic inline void hda_codec_i915_display_power(struct snd_sof_dev *sdev, bool enable) { }
76562306a36Sopenharmony_cistatic inline int hda_codec_i915_init(struct snd_sof_dev *sdev) { return 0; }
76662306a36Sopenharmony_cistatic inline int hda_codec_i915_exit(struct snd_sof_dev *sdev) { return 0; }
76762306a36Sopenharmony_ci
76862306a36Sopenharmony_ci#endif
76962306a36Sopenharmony_ci
77062306a36Sopenharmony_ci/*
77162306a36Sopenharmony_ci * Trace Control.
77262306a36Sopenharmony_ci */
77362306a36Sopenharmony_ciint hda_dsp_trace_init(struct snd_sof_dev *sdev, struct snd_dma_buffer *dmab,
77462306a36Sopenharmony_ci		       struct sof_ipc_dma_trace_params_ext *dtrace_params);
77562306a36Sopenharmony_ciint hda_dsp_trace_release(struct snd_sof_dev *sdev);
77662306a36Sopenharmony_ciint hda_dsp_trace_trigger(struct snd_sof_dev *sdev, int cmd);
77762306a36Sopenharmony_ci
77862306a36Sopenharmony_ci/*
77962306a36Sopenharmony_ci * SoundWire support
78062306a36Sopenharmony_ci */
78162306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_SND_SOC_SOF_INTEL_SOUNDWIRE)
78262306a36Sopenharmony_ci
78362306a36Sopenharmony_ciint hda_sdw_check_lcount_common(struct snd_sof_dev *sdev);
78462306a36Sopenharmony_ciint hda_sdw_check_lcount_ext(struct snd_sof_dev *sdev);
78562306a36Sopenharmony_ciint hda_sdw_startup(struct snd_sof_dev *sdev);
78662306a36Sopenharmony_civoid hda_common_enable_sdw_irq(struct snd_sof_dev *sdev, bool enable);
78762306a36Sopenharmony_civoid hda_sdw_int_enable(struct snd_sof_dev *sdev, bool enable);
78862306a36Sopenharmony_cibool hda_sdw_check_wakeen_irq_common(struct snd_sof_dev *sdev);
78962306a36Sopenharmony_civoid hda_sdw_process_wakeen(struct snd_sof_dev *sdev);
79062306a36Sopenharmony_cibool hda_common_check_sdw_irq(struct snd_sof_dev *sdev);
79162306a36Sopenharmony_ci
79262306a36Sopenharmony_ci#else
79362306a36Sopenharmony_ci
79462306a36Sopenharmony_cistatic inline int hda_sdw_check_lcount_common(struct snd_sof_dev *sdev)
79562306a36Sopenharmony_ci{
79662306a36Sopenharmony_ci	return 0;
79762306a36Sopenharmony_ci}
79862306a36Sopenharmony_ci
79962306a36Sopenharmony_cistatic inline int hda_sdw_check_lcount_ext(struct snd_sof_dev *sdev)
80062306a36Sopenharmony_ci{
80162306a36Sopenharmony_ci	return 0;
80262306a36Sopenharmony_ci}
80362306a36Sopenharmony_ci
80462306a36Sopenharmony_cistatic inline int hda_sdw_startup(struct snd_sof_dev *sdev)
80562306a36Sopenharmony_ci{
80662306a36Sopenharmony_ci	return 0;
80762306a36Sopenharmony_ci}
80862306a36Sopenharmony_ci
80962306a36Sopenharmony_cistatic inline void hda_common_enable_sdw_irq(struct snd_sof_dev *sdev, bool enable)
81062306a36Sopenharmony_ci{
81162306a36Sopenharmony_ci}
81262306a36Sopenharmony_ci
81362306a36Sopenharmony_cistatic inline void hda_sdw_int_enable(struct snd_sof_dev *sdev, bool enable)
81462306a36Sopenharmony_ci{
81562306a36Sopenharmony_ci}
81662306a36Sopenharmony_ci
81762306a36Sopenharmony_cistatic inline bool hda_sdw_check_wakeen_irq_common(struct snd_sof_dev *sdev)
81862306a36Sopenharmony_ci{
81962306a36Sopenharmony_ci	return false;
82062306a36Sopenharmony_ci}
82162306a36Sopenharmony_ci
82262306a36Sopenharmony_cistatic inline void hda_sdw_process_wakeen(struct snd_sof_dev *sdev)
82362306a36Sopenharmony_ci{
82462306a36Sopenharmony_ci}
82562306a36Sopenharmony_ci
82662306a36Sopenharmony_cistatic inline bool hda_common_check_sdw_irq(struct snd_sof_dev *sdev)
82762306a36Sopenharmony_ci{
82862306a36Sopenharmony_ci	return false;
82962306a36Sopenharmony_ci}
83062306a36Sopenharmony_ci
83162306a36Sopenharmony_ci#endif
83262306a36Sopenharmony_ci
83362306a36Sopenharmony_ciint sdw_hda_dai_hw_params(struct snd_pcm_substream *substream,
83462306a36Sopenharmony_ci			  struct snd_pcm_hw_params *params,
83562306a36Sopenharmony_ci			  struct snd_soc_dai *cpu_dai,
83662306a36Sopenharmony_ci			  int link_id);
83762306a36Sopenharmony_ci
83862306a36Sopenharmony_ciint sdw_hda_dai_hw_free(struct snd_pcm_substream *substream,
83962306a36Sopenharmony_ci			struct snd_soc_dai *cpu_dai,
84062306a36Sopenharmony_ci			int link_id);
84162306a36Sopenharmony_ci
84262306a36Sopenharmony_ciint sdw_hda_dai_trigger(struct snd_pcm_substream *substream, int cmd,
84362306a36Sopenharmony_ci			struct snd_soc_dai *cpu_dai);
84462306a36Sopenharmony_ci
84562306a36Sopenharmony_ci/* common dai driver */
84662306a36Sopenharmony_ciextern struct snd_soc_dai_driver skl_dai[];
84762306a36Sopenharmony_ciint hda_dsp_dais_suspend(struct snd_sof_dev *sdev);
84862306a36Sopenharmony_ci
84962306a36Sopenharmony_ci/*
85062306a36Sopenharmony_ci * Platform Specific HW abstraction Ops.
85162306a36Sopenharmony_ci */
85262306a36Sopenharmony_ciextern struct snd_sof_dsp_ops sof_hda_common_ops;
85362306a36Sopenharmony_ci
85462306a36Sopenharmony_ciextern struct snd_sof_dsp_ops sof_skl_ops;
85562306a36Sopenharmony_ciint sof_skl_ops_init(struct snd_sof_dev *sdev);
85662306a36Sopenharmony_ciextern struct snd_sof_dsp_ops sof_apl_ops;
85762306a36Sopenharmony_ciint sof_apl_ops_init(struct snd_sof_dev *sdev);
85862306a36Sopenharmony_ciextern struct snd_sof_dsp_ops sof_cnl_ops;
85962306a36Sopenharmony_ciint sof_cnl_ops_init(struct snd_sof_dev *sdev);
86062306a36Sopenharmony_ciextern struct snd_sof_dsp_ops sof_tgl_ops;
86162306a36Sopenharmony_ciint sof_tgl_ops_init(struct snd_sof_dev *sdev);
86262306a36Sopenharmony_ciextern struct snd_sof_dsp_ops sof_icl_ops;
86362306a36Sopenharmony_ciint sof_icl_ops_init(struct snd_sof_dev *sdev);
86462306a36Sopenharmony_ciextern struct snd_sof_dsp_ops sof_mtl_ops;
86562306a36Sopenharmony_ciint sof_mtl_ops_init(struct snd_sof_dev *sdev);
86662306a36Sopenharmony_ciextern struct snd_sof_dsp_ops sof_lnl_ops;
86762306a36Sopenharmony_ciint sof_lnl_ops_init(struct snd_sof_dev *sdev);
86862306a36Sopenharmony_ci
86962306a36Sopenharmony_ciextern const struct sof_intel_dsp_desc skl_chip_info;
87062306a36Sopenharmony_ciextern const struct sof_intel_dsp_desc apl_chip_info;
87162306a36Sopenharmony_ciextern const struct sof_intel_dsp_desc cnl_chip_info;
87262306a36Sopenharmony_ciextern const struct sof_intel_dsp_desc icl_chip_info;
87362306a36Sopenharmony_ciextern const struct sof_intel_dsp_desc tgl_chip_info;
87462306a36Sopenharmony_ciextern const struct sof_intel_dsp_desc tglh_chip_info;
87562306a36Sopenharmony_ciextern const struct sof_intel_dsp_desc ehl_chip_info;
87662306a36Sopenharmony_ciextern const struct sof_intel_dsp_desc jsl_chip_info;
87762306a36Sopenharmony_ciextern const struct sof_intel_dsp_desc adls_chip_info;
87862306a36Sopenharmony_ciextern const struct sof_intel_dsp_desc mtl_chip_info;
87962306a36Sopenharmony_ciextern const struct sof_intel_dsp_desc lnl_chip_info;
88062306a36Sopenharmony_ci
88162306a36Sopenharmony_ci/* Probes support */
88262306a36Sopenharmony_ci#if IS_ENABLED(CONFIG_SND_SOC_SOF_HDA_PROBES)
88362306a36Sopenharmony_ciint hda_probes_register(struct snd_sof_dev *sdev);
88462306a36Sopenharmony_civoid hda_probes_unregister(struct snd_sof_dev *sdev);
88562306a36Sopenharmony_ci#else
88662306a36Sopenharmony_cistatic inline int hda_probes_register(struct snd_sof_dev *sdev)
88762306a36Sopenharmony_ci{
88862306a36Sopenharmony_ci	return 0;
88962306a36Sopenharmony_ci}
89062306a36Sopenharmony_ci
89162306a36Sopenharmony_cistatic inline void hda_probes_unregister(struct snd_sof_dev *sdev)
89262306a36Sopenharmony_ci{
89362306a36Sopenharmony_ci}
89462306a36Sopenharmony_ci#endif /* CONFIG_SND_SOC_SOF_HDA_PROBES */
89562306a36Sopenharmony_ci
89662306a36Sopenharmony_ci/* SOF client registration for HDA platforms */
89762306a36Sopenharmony_ciint hda_register_clients(struct snd_sof_dev *sdev);
89862306a36Sopenharmony_civoid hda_unregister_clients(struct snd_sof_dev *sdev);
89962306a36Sopenharmony_ci
90062306a36Sopenharmony_ci/* machine driver select */
90162306a36Sopenharmony_cistruct snd_soc_acpi_mach *hda_machine_select(struct snd_sof_dev *sdev);
90262306a36Sopenharmony_civoid hda_set_mach_params(struct snd_soc_acpi_mach *mach,
90362306a36Sopenharmony_ci			 struct snd_sof_dev *sdev);
90462306a36Sopenharmony_ci
90562306a36Sopenharmony_ci/* PCI driver selection and probe */
90662306a36Sopenharmony_ciint hda_pci_intel_probe(struct pci_dev *pci, const struct pci_device_id *pci_id);
90762306a36Sopenharmony_ci
90862306a36Sopenharmony_cistruct snd_sof_dai;
90962306a36Sopenharmony_cistruct sof_ipc_dai_config;
91062306a36Sopenharmony_ci
91162306a36Sopenharmony_ci#define SOF_HDA_POSITION_QUIRK_USE_SKYLAKE_LEGACY	(0) /* previous implementation */
91262306a36Sopenharmony_ci#define SOF_HDA_POSITION_QUIRK_USE_DPIB_REGISTERS	(1) /* recommended if VC0 only */
91362306a36Sopenharmony_ci#define SOF_HDA_POSITION_QUIRK_USE_DPIB_DDR_UPDATE	(2) /* recommended with VC0 or VC1 */
91462306a36Sopenharmony_ci
91562306a36Sopenharmony_ciextern int sof_hda_position_quirk;
91662306a36Sopenharmony_ci
91762306a36Sopenharmony_civoid hda_set_dai_drv_ops(struct snd_sof_dev *sdev, struct snd_sof_dsp_ops *ops);
91862306a36Sopenharmony_civoid hda_ops_free(struct snd_sof_dev *sdev);
91962306a36Sopenharmony_ci
92062306a36Sopenharmony_ci/* SKL/KBL */
92162306a36Sopenharmony_ciint hda_dsp_cl_boot_firmware_skl(struct snd_sof_dev *sdev);
92262306a36Sopenharmony_ciint hda_dsp_core_stall_reset(struct snd_sof_dev *sdev, unsigned int core_mask);
92362306a36Sopenharmony_ci
92462306a36Sopenharmony_ci/* IPC4 */
92562306a36Sopenharmony_ciirqreturn_t cnl_ipc4_irq_thread(int irq, void *context);
92662306a36Sopenharmony_ciint cnl_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg);
92762306a36Sopenharmony_ciirqreturn_t hda_dsp_ipc4_irq_thread(int irq, void *context);
92862306a36Sopenharmony_cibool hda_ipc4_tx_is_busy(struct snd_sof_dev *sdev);
92962306a36Sopenharmony_civoid hda_dsp_ipc4_schedule_d0i3_work(struct sof_intel_hda_dev *hdev,
93062306a36Sopenharmony_ci				     struct snd_sof_ipc_msg *msg);
93162306a36Sopenharmony_ciint hda_dsp_ipc4_send_msg(struct snd_sof_dev *sdev, struct snd_sof_ipc_msg *msg);
93262306a36Sopenharmony_civoid hda_ipc4_dump(struct snd_sof_dev *sdev);
93362306a36Sopenharmony_ciextern struct sdw_intel_ops sdw_callback;
93462306a36Sopenharmony_ci
93562306a36Sopenharmony_cistruct sof_ipc4_fw_library;
93662306a36Sopenharmony_ciint hda_dsp_ipc4_load_library(struct snd_sof_dev *sdev,
93762306a36Sopenharmony_ci			      struct sof_ipc4_fw_library *fw_lib, bool reload);
93862306a36Sopenharmony_ci
93962306a36Sopenharmony_ci/**
94062306a36Sopenharmony_ci * struct hda_dai_widget_dma_ops - DAI DMA ops optional by default unless specified otherwise
94162306a36Sopenharmony_ci * @get_hext_stream: Mandatory function pointer to get the saved pointer to struct hdac_ext_stream
94262306a36Sopenharmony_ci * @assign_hext_stream: Function pointer to assign a hdac_ext_stream
94362306a36Sopenharmony_ci * @release_hext_stream: Function pointer to release the hdac_ext_stream
94462306a36Sopenharmony_ci * @setup_hext_stream: Function pointer for hdac_ext_stream setup
94562306a36Sopenharmony_ci * @reset_hext_stream: Function pointer for hdac_ext_stream reset
94662306a36Sopenharmony_ci * @pre_trigger: Function pointer for DAI DMA pre-trigger actions
94762306a36Sopenharmony_ci * @trigger: Function pointer for DAI DMA trigger actions
94862306a36Sopenharmony_ci * @post_trigger: Function pointer for DAI DMA post-trigger actions
94962306a36Sopenharmony_ci * @codec_dai_set_stream: Function pointer to set codec-side stream information
95062306a36Sopenharmony_ci * @calc_stream_format: Function pointer to determine stream format from hw_params and
95162306a36Sopenharmony_ci * for HDaudio codec DAI from the .sig bits
95262306a36Sopenharmony_ci * @get_hlink: Mandatory function pointer to retrieve hlink, mainly to program LOSIDV
95362306a36Sopenharmony_ci * for legacy HDaudio links or program HDaudio Extended Link registers.
95462306a36Sopenharmony_ci */
95562306a36Sopenharmony_cistruct hda_dai_widget_dma_ops {
95662306a36Sopenharmony_ci	struct hdac_ext_stream *(*get_hext_stream)(struct snd_sof_dev *sdev,
95762306a36Sopenharmony_ci						   struct snd_soc_dai *cpu_dai,
95862306a36Sopenharmony_ci						   struct snd_pcm_substream *substream);
95962306a36Sopenharmony_ci	struct hdac_ext_stream *(*assign_hext_stream)(struct snd_sof_dev *sdev,
96062306a36Sopenharmony_ci						      struct snd_soc_dai *cpu_dai,
96162306a36Sopenharmony_ci						      struct snd_pcm_substream *substream);
96262306a36Sopenharmony_ci	void (*release_hext_stream)(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai,
96362306a36Sopenharmony_ci				    struct snd_pcm_substream *substream);
96462306a36Sopenharmony_ci	void (*setup_hext_stream)(struct snd_sof_dev *sdev, struct hdac_ext_stream *hext_stream,
96562306a36Sopenharmony_ci				  unsigned int format_val);
96662306a36Sopenharmony_ci	void (*reset_hext_stream)(struct snd_sof_dev *sdev, struct hdac_ext_stream *hext_sream);
96762306a36Sopenharmony_ci	int (*pre_trigger)(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai,
96862306a36Sopenharmony_ci			   struct snd_pcm_substream *substream, int cmd);
96962306a36Sopenharmony_ci	int (*trigger)(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai,
97062306a36Sopenharmony_ci		       struct snd_pcm_substream *substream, int cmd);
97162306a36Sopenharmony_ci	int (*post_trigger)(struct snd_sof_dev *sdev, struct snd_soc_dai *cpu_dai,
97262306a36Sopenharmony_ci			    struct snd_pcm_substream *substream, int cmd);
97362306a36Sopenharmony_ci	void (*codec_dai_set_stream)(struct snd_sof_dev *sdev,
97462306a36Sopenharmony_ci				     struct snd_pcm_substream *substream,
97562306a36Sopenharmony_ci				     struct hdac_stream *hstream);
97662306a36Sopenharmony_ci	unsigned int (*calc_stream_format)(struct snd_sof_dev *sdev,
97762306a36Sopenharmony_ci					   struct snd_pcm_substream *substream,
97862306a36Sopenharmony_ci					   struct snd_pcm_hw_params *params);
97962306a36Sopenharmony_ci	struct hdac_ext_link * (*get_hlink)(struct snd_sof_dev *sdev,
98062306a36Sopenharmony_ci					    struct snd_pcm_substream *substream);
98162306a36Sopenharmony_ci};
98262306a36Sopenharmony_ci
98362306a36Sopenharmony_ciconst struct hda_dai_widget_dma_ops *
98462306a36Sopenharmony_cihda_select_dai_widget_ops(struct snd_sof_dev *sdev, struct snd_sof_widget *swidget);
98562306a36Sopenharmony_ciint hda_dai_config(struct snd_soc_dapm_widget *w, unsigned int flags,
98662306a36Sopenharmony_ci		   struct snd_sof_dai_config_data *data);
98762306a36Sopenharmony_ciint hda_link_dma_cleanup(struct snd_pcm_substream *substream, struct hdac_ext_stream *hext_stream,
98862306a36Sopenharmony_ci			 struct snd_soc_dai *cpu_dai);
98962306a36Sopenharmony_ci
99062306a36Sopenharmony_ci#endif
991