xref: /kernel/linux/linux-5.10/sound/soc/sof/intel/shim.h (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * This file is provided under a dual BSD/GPLv2 license.  When using or
48c2ecf20Sopenharmony_ci * redistributing this file, you may do so under either license.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Copyright(c) 2017 Intel Corporation. All rights reserved.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci#ifndef __SOF_INTEL_SHIM_H
128c2ecf20Sopenharmony_ci#define __SOF_INTEL_SHIM_H
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci/*
158c2ecf20Sopenharmony_ci * SHIM registers for BYT, BSW, CHT, BDW
168c2ecf20Sopenharmony_ci */
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#define SHIM_CSR		(SHIM_OFFSET + 0x00)
198c2ecf20Sopenharmony_ci#define SHIM_PISR		(SHIM_OFFSET + 0x08)
208c2ecf20Sopenharmony_ci#define SHIM_PIMR		(SHIM_OFFSET + 0x10)
218c2ecf20Sopenharmony_ci#define SHIM_ISRX		(SHIM_OFFSET + 0x18)
228c2ecf20Sopenharmony_ci#define SHIM_ISRD		(SHIM_OFFSET + 0x20)
238c2ecf20Sopenharmony_ci#define SHIM_IMRX		(SHIM_OFFSET + 0x28)
248c2ecf20Sopenharmony_ci#define SHIM_IMRD		(SHIM_OFFSET + 0x30)
258c2ecf20Sopenharmony_ci#define SHIM_IPCX		(SHIM_OFFSET + 0x38)
268c2ecf20Sopenharmony_ci#define SHIM_IPCD		(SHIM_OFFSET + 0x40)
278c2ecf20Sopenharmony_ci#define SHIM_ISRSC		(SHIM_OFFSET + 0x48)
288c2ecf20Sopenharmony_ci#define SHIM_ISRLPESC		(SHIM_OFFSET + 0x50)
298c2ecf20Sopenharmony_ci#define SHIM_IMRSC		(SHIM_OFFSET + 0x58)
308c2ecf20Sopenharmony_ci#define SHIM_IMRLPESC		(SHIM_OFFSET + 0x60)
318c2ecf20Sopenharmony_ci#define SHIM_IPCSC		(SHIM_OFFSET + 0x68)
328c2ecf20Sopenharmony_ci#define SHIM_IPCLPESC		(SHIM_OFFSET + 0x70)
338c2ecf20Sopenharmony_ci#define SHIM_CLKCTL		(SHIM_OFFSET + 0x78)
348c2ecf20Sopenharmony_ci#define SHIM_CSR2		(SHIM_OFFSET + 0x80)
358c2ecf20Sopenharmony_ci#define SHIM_LTRC		(SHIM_OFFSET + 0xE0)
368c2ecf20Sopenharmony_ci#define SHIM_HMDC		(SHIM_OFFSET + 0xE8)
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci#define SHIM_PWMCTRL		0x1000
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci/*
418c2ecf20Sopenharmony_ci * SST SHIM register bits for BYT, BSW, CHT, BDW
428c2ecf20Sopenharmony_ci * Register bit naming and functionaility can differ between devices.
438c2ecf20Sopenharmony_ci */
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci/* CSR / CS */
468c2ecf20Sopenharmony_ci#define SHIM_CSR_RST		BIT(1)
478c2ecf20Sopenharmony_ci#define SHIM_CSR_SBCS0		BIT(2)
488c2ecf20Sopenharmony_ci#define SHIM_CSR_SBCS1		BIT(3)
498c2ecf20Sopenharmony_ci#define SHIM_CSR_DCS(x)		((x) << 4)
508c2ecf20Sopenharmony_ci#define SHIM_CSR_DCS_MASK	(0x7 << 4)
518c2ecf20Sopenharmony_ci#define SHIM_CSR_STALL		BIT(10)
528c2ecf20Sopenharmony_ci#define SHIM_CSR_S0IOCS		BIT(21)
538c2ecf20Sopenharmony_ci#define SHIM_CSR_S1IOCS		BIT(23)
548c2ecf20Sopenharmony_ci#define SHIM_CSR_LPCS		BIT(31)
558c2ecf20Sopenharmony_ci#define SHIM_CSR_24MHZ_LPCS \
568c2ecf20Sopenharmony_ci	(SHIM_CSR_SBCS0 | SHIM_CSR_SBCS1 | SHIM_CSR_LPCS)
578c2ecf20Sopenharmony_ci#define SHIM_CSR_24MHZ_NO_LPCS	(SHIM_CSR_SBCS0 | SHIM_CSR_SBCS1)
588c2ecf20Sopenharmony_ci#define SHIM_BYT_CSR_RST	BIT(0)
598c2ecf20Sopenharmony_ci#define SHIM_BYT_CSR_VECTOR_SEL	BIT(1)
608c2ecf20Sopenharmony_ci#define SHIM_BYT_CSR_STALL	BIT(2)
618c2ecf20Sopenharmony_ci#define SHIM_BYT_CSR_PWAITMODE	BIT(3)
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci/*  ISRX / ISC */
648c2ecf20Sopenharmony_ci#define SHIM_ISRX_BUSY		BIT(1)
658c2ecf20Sopenharmony_ci#define SHIM_ISRX_DONE		BIT(0)
668c2ecf20Sopenharmony_ci#define SHIM_BYT_ISRX_REQUEST	BIT(1)
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci/*  ISRD / ISD */
698c2ecf20Sopenharmony_ci#define SHIM_ISRD_BUSY		BIT(1)
708c2ecf20Sopenharmony_ci#define SHIM_ISRD_DONE		BIT(0)
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci/* IMRX / IMC */
738c2ecf20Sopenharmony_ci#define SHIM_IMRX_BUSY		BIT(1)
748c2ecf20Sopenharmony_ci#define SHIM_IMRX_DONE		BIT(0)
758c2ecf20Sopenharmony_ci#define SHIM_BYT_IMRX_REQUEST	BIT(1)
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci/* IMRD / IMD */
788c2ecf20Sopenharmony_ci#define SHIM_IMRD_DONE		BIT(0)
798c2ecf20Sopenharmony_ci#define SHIM_IMRD_BUSY		BIT(1)
808c2ecf20Sopenharmony_ci#define SHIM_IMRD_SSP0		BIT(16)
818c2ecf20Sopenharmony_ci#define SHIM_IMRD_DMAC0		BIT(21)
828c2ecf20Sopenharmony_ci#define SHIM_IMRD_DMAC1		BIT(22)
838c2ecf20Sopenharmony_ci#define SHIM_IMRD_DMAC		(SHIM_IMRD_DMAC0 | SHIM_IMRD_DMAC1)
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci/*  IPCX / IPCC */
868c2ecf20Sopenharmony_ci#define	SHIM_IPCX_DONE		BIT(30)
878c2ecf20Sopenharmony_ci#define	SHIM_IPCX_BUSY		BIT(31)
888c2ecf20Sopenharmony_ci#define SHIM_BYT_IPCX_DONE	BIT_ULL(62)
898c2ecf20Sopenharmony_ci#define SHIM_BYT_IPCX_BUSY	BIT_ULL(63)
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ci/*  IPCD */
928c2ecf20Sopenharmony_ci#define	SHIM_IPCD_DONE		BIT(30)
938c2ecf20Sopenharmony_ci#define	SHIM_IPCD_BUSY		BIT(31)
948c2ecf20Sopenharmony_ci#define SHIM_BYT_IPCD_DONE	BIT_ULL(62)
958c2ecf20Sopenharmony_ci#define SHIM_BYT_IPCD_BUSY	BIT_ULL(63)
968c2ecf20Sopenharmony_ci
978c2ecf20Sopenharmony_ci/* CLKCTL */
988c2ecf20Sopenharmony_ci#define SHIM_CLKCTL_SMOS(x)	((x) << 24)
998c2ecf20Sopenharmony_ci#define SHIM_CLKCTL_MASK	(3 << 24)
1008c2ecf20Sopenharmony_ci#define SHIM_CLKCTL_DCPLCG	BIT(18)
1018c2ecf20Sopenharmony_ci#define SHIM_CLKCTL_SCOE1	BIT(17)
1028c2ecf20Sopenharmony_ci#define SHIM_CLKCTL_SCOE0	BIT(16)
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci/* CSR2 / CS2 */
1058c2ecf20Sopenharmony_ci#define SHIM_CSR2_SDFD_SSP0	BIT(1)
1068c2ecf20Sopenharmony_ci#define SHIM_CSR2_SDFD_SSP1	BIT(2)
1078c2ecf20Sopenharmony_ci
1088c2ecf20Sopenharmony_ci/* LTRC */
1098c2ecf20Sopenharmony_ci#define SHIM_LTRC_VAL(x)	((x) << 0)
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci/* HMDC */
1128c2ecf20Sopenharmony_ci#define SHIM_HMDC_HDDA0(x)	((x) << 0)
1138c2ecf20Sopenharmony_ci#define SHIM_HMDC_HDDA1(x)	((x) << 7)
1148c2ecf20Sopenharmony_ci#define SHIM_HMDC_HDDA_E0_CH0	1
1158c2ecf20Sopenharmony_ci#define SHIM_HMDC_HDDA_E0_CH1	2
1168c2ecf20Sopenharmony_ci#define SHIM_HMDC_HDDA_E0_CH2	4
1178c2ecf20Sopenharmony_ci#define SHIM_HMDC_HDDA_E0_CH3	8
1188c2ecf20Sopenharmony_ci#define SHIM_HMDC_HDDA_E1_CH0	SHIM_HMDC_HDDA1(SHIM_HMDC_HDDA_E0_CH0)
1198c2ecf20Sopenharmony_ci#define SHIM_HMDC_HDDA_E1_CH1	SHIM_HMDC_HDDA1(SHIM_HMDC_HDDA_E0_CH1)
1208c2ecf20Sopenharmony_ci#define SHIM_HMDC_HDDA_E1_CH2	SHIM_HMDC_HDDA1(SHIM_HMDC_HDDA_E0_CH2)
1218c2ecf20Sopenharmony_ci#define SHIM_HMDC_HDDA_E1_CH3	SHIM_HMDC_HDDA1(SHIM_HMDC_HDDA_E0_CH3)
1228c2ecf20Sopenharmony_ci#define SHIM_HMDC_HDDA_E0_ALLCH	\
1238c2ecf20Sopenharmony_ci	(SHIM_HMDC_HDDA_E0_CH0 | SHIM_HMDC_HDDA_E0_CH1 | \
1248c2ecf20Sopenharmony_ci	 SHIM_HMDC_HDDA_E0_CH2 | SHIM_HMDC_HDDA_E0_CH3)
1258c2ecf20Sopenharmony_ci#define SHIM_HMDC_HDDA_E1_ALLCH	\
1268c2ecf20Sopenharmony_ci	(SHIM_HMDC_HDDA_E1_CH0 | SHIM_HMDC_HDDA_E1_CH1 | \
1278c2ecf20Sopenharmony_ci	 SHIM_HMDC_HDDA_E1_CH2 | SHIM_HMDC_HDDA_E1_CH3)
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci/* Audio DSP PCI registers */
1308c2ecf20Sopenharmony_ci#define PCI_VDRTCTL0		0xa0
1318c2ecf20Sopenharmony_ci#define PCI_VDRTCTL1		0xa4
1328c2ecf20Sopenharmony_ci#define PCI_VDRTCTL2		0xa8
1338c2ecf20Sopenharmony_ci#define PCI_VDRTCTL3		0xaC
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci/* VDRTCTL0 */
1368c2ecf20Sopenharmony_ci#define PCI_VDRTCL0_D3PGD		BIT(0)
1378c2ecf20Sopenharmony_ci#define PCI_VDRTCL0_D3SRAMPGD		BIT(1)
1388c2ecf20Sopenharmony_ci#define PCI_VDRTCL0_DSRAMPGE_SHIFT	12
1398c2ecf20Sopenharmony_ci#define PCI_VDRTCL0_DSRAMPGE_MASK	GENMASK(PCI_VDRTCL0_DSRAMPGE_SHIFT + 19,\
1408c2ecf20Sopenharmony_ci						PCI_VDRTCL0_DSRAMPGE_SHIFT)
1418c2ecf20Sopenharmony_ci#define PCI_VDRTCL0_ISRAMPGE_SHIFT	2
1428c2ecf20Sopenharmony_ci#define PCI_VDRTCL0_ISRAMPGE_MASK	GENMASK(PCI_VDRTCL0_ISRAMPGE_SHIFT + 9,\
1438c2ecf20Sopenharmony_ci						PCI_VDRTCL0_ISRAMPGE_SHIFT)
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci/* VDRTCTL2 */
1468c2ecf20Sopenharmony_ci#define PCI_VDRTCL2_DCLCGE		BIT(1)
1478c2ecf20Sopenharmony_ci#define PCI_VDRTCL2_DTCGE		BIT(10)
1488c2ecf20Sopenharmony_ci#define PCI_VDRTCL2_APLLSE_MASK		BIT(31)
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci/* PMCS */
1518c2ecf20Sopenharmony_ci#define PCI_PMCS		0x84
1528c2ecf20Sopenharmony_ci#define PCI_PMCS_PS_MASK	0x3
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci/* DSP hardware descriptor */
1558c2ecf20Sopenharmony_cistruct sof_intel_dsp_desc {
1568c2ecf20Sopenharmony_ci	int cores_num;
1578c2ecf20Sopenharmony_ci	int host_managed_cores_mask;
1588c2ecf20Sopenharmony_ci	int init_core_mask; /* cores available after fw boot */
1598c2ecf20Sopenharmony_ci	int ipc_req;
1608c2ecf20Sopenharmony_ci	int ipc_req_mask;
1618c2ecf20Sopenharmony_ci	int ipc_ack;
1628c2ecf20Sopenharmony_ci	int ipc_ack_mask;
1638c2ecf20Sopenharmony_ci	int ipc_ctl;
1648c2ecf20Sopenharmony_ci	int rom_init_timeout;
1658c2ecf20Sopenharmony_ci	int ssp_count;			/* ssp count of the platform */
1668c2ecf20Sopenharmony_ci	int ssp_base_offset;		/* base address of the SSPs */
1678c2ecf20Sopenharmony_ci};
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ciextern const struct snd_sof_dsp_ops sof_tng_ops;
1708c2ecf20Sopenharmony_ciextern const struct snd_sof_dsp_ops sof_byt_ops;
1718c2ecf20Sopenharmony_ciextern const struct snd_sof_dsp_ops sof_cht_ops;
1728c2ecf20Sopenharmony_ciextern const struct snd_sof_dsp_ops sof_bdw_ops;
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ciextern const struct sof_intel_dsp_desc byt_chip_info;
1758c2ecf20Sopenharmony_ciextern const struct sof_intel_dsp_desc cht_chip_info;
1768c2ecf20Sopenharmony_ciextern const struct sof_intel_dsp_desc bdw_chip_info;
1778c2ecf20Sopenharmony_ciextern const struct sof_intel_dsp_desc tng_chip_info;
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_cistruct sof_intel_stream {
1808c2ecf20Sopenharmony_ci	size_t posn_offset;
1818c2ecf20Sopenharmony_ci};
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ci#endif
184