18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * ISH registers definitions
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Copyright (c) 2012-2016, Intel Corporation.
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef _ISHTP_ISH_REGS_H_
98c2ecf20Sopenharmony_ci#define _ISHTP_ISH_REGS_H_
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci/*** IPC PCI Offsets and sizes ***/
138c2ecf20Sopenharmony_ci/* ISH IPC Base Address */
148c2ecf20Sopenharmony_ci#define IPC_REG_BASE		0x0000
158c2ecf20Sopenharmony_ci/* Peripheral Interrupt Status Register */
168c2ecf20Sopenharmony_ci#define IPC_REG_PISR_CHV_AB      (IPC_REG_BASE + 0x00)
178c2ecf20Sopenharmony_ci/* Peripheral Interrupt Mask Register */
188c2ecf20Sopenharmony_ci#define IPC_REG_PIMR_CHV_AB      (IPC_REG_BASE + 0x04)
198c2ecf20Sopenharmony_ci/*BXT, CHV_K0*/
208c2ecf20Sopenharmony_ci/*Peripheral Interrupt Status Register */
218c2ecf20Sopenharmony_ci#define IPC_REG_PISR_BXT	 (IPC_REG_BASE + 0x0C)
228c2ecf20Sopenharmony_ci/*Peripheral Interrupt Mask Register */
238c2ecf20Sopenharmony_ci#define IPC_REG_PIMR_BXT	 (IPC_REG_BASE + 0x08)
248c2ecf20Sopenharmony_ci/***********************************/
258c2ecf20Sopenharmony_ci/* ISH Host Firmware status Register */
268c2ecf20Sopenharmony_ci#define IPC_REG_ISH_HOST_FWSTS	(IPC_REG_BASE + 0x34)
278c2ecf20Sopenharmony_ci/* Host Communication Register */
288c2ecf20Sopenharmony_ci#define IPC_REG_HOST_COMM	(IPC_REG_BASE + 0x38)
298c2ecf20Sopenharmony_ci/* Reset register */
308c2ecf20Sopenharmony_ci#define IPC_REG_ISH_RST		(IPC_REG_BASE + 0x44)
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci/* Inbound doorbell register Host to ISH */
338c2ecf20Sopenharmony_ci#define IPC_REG_HOST2ISH_DRBL	(IPC_REG_BASE + 0x48)
348c2ecf20Sopenharmony_ci/* Outbound doorbell register ISH to Host */
358c2ecf20Sopenharmony_ci#define IPC_REG_ISH2HOST_DRBL	(IPC_REG_BASE + 0x54)
368c2ecf20Sopenharmony_ci/* ISH to HOST message registers */
378c2ecf20Sopenharmony_ci#define IPC_REG_ISH2HOST_MSG	(IPC_REG_BASE + 0x60)
388c2ecf20Sopenharmony_ci/* HOST to ISH message registers */
398c2ecf20Sopenharmony_ci#define IPC_REG_HOST2ISH_MSG	(IPC_REG_BASE + 0xE0)
408c2ecf20Sopenharmony_ci/* REMAP2 to enable DMA (D3 RCR) */
418c2ecf20Sopenharmony_ci#define	IPC_REG_ISH_RMP2	(IPC_REG_BASE + 0x368)
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#define	IPC_REG_MAX		(IPC_REG_BASE + 0x400)
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_ci/*** register bits - HISR ***/
468c2ecf20Sopenharmony_ci/* bit corresponds HOST2ISH interrupt in PISR and PIMR registers */
478c2ecf20Sopenharmony_ci#define IPC_INT_HOST2ISH_BIT            (1<<0)
488c2ecf20Sopenharmony_ci/***********************************/
498c2ecf20Sopenharmony_ci/*CHV_A0, CHV_B0*/
508c2ecf20Sopenharmony_ci/* bit corresponds ISH2HOST interrupt in PISR and PIMR registers */
518c2ecf20Sopenharmony_ci#define IPC_INT_ISH2HOST_BIT_CHV_AB	(1<<3)
528c2ecf20Sopenharmony_ci/*BXT, CHV_K0*/
538c2ecf20Sopenharmony_ci/* bit corresponds ISH2HOST interrupt in PISR and PIMR registers */
548c2ecf20Sopenharmony_ci#define IPC_INT_ISH2HOST_BIT_BXT	(1<<0)
558c2ecf20Sopenharmony_ci/***********************************/
568c2ecf20Sopenharmony_ci
578c2ecf20Sopenharmony_ci/* bit corresponds ISH2HOST busy clear interrupt in PIMR register */
588c2ecf20Sopenharmony_ci#define IPC_INT_ISH2HOST_CLR_MASK_BIT	(1<<11)
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci/* offset of ISH2HOST busy clear interrupt in IPC_BUSY_CLR register */
618c2ecf20Sopenharmony_ci#define IPC_INT_ISH2HOST_CLR_OFFS	(0)
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci/* bit corresponds ISH2HOST busy clear interrupt in IPC_BUSY_CLR register */
648c2ecf20Sopenharmony_ci#define IPC_INT_ISH2HOST_CLR_BIT	(1<<IPC_INT_ISH2HOST_CLR_OFFS)
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ci/* bit corresponds busy bit in doorbell registers */
678c2ecf20Sopenharmony_ci#define IPC_DRBL_BUSY_OFFS		(31)
688c2ecf20Sopenharmony_ci#define IPC_DRBL_BUSY_BIT		(1<<IPC_DRBL_BUSY_OFFS)
698c2ecf20Sopenharmony_ci
708c2ecf20Sopenharmony_ci#define	IPC_HOST_OWNS_MSG_OFFS		(30)
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci/*
738c2ecf20Sopenharmony_ci * A0: bit means that host owns MSGnn registers and is reading them.
748c2ecf20Sopenharmony_ci * ISH FW may not write to them
758c2ecf20Sopenharmony_ci */
768c2ecf20Sopenharmony_ci#define	IPC_HOST_OWNS_MSG_BIT		(1<<IPC_HOST_OWNS_MSG_OFFS)
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci/*
798c2ecf20Sopenharmony_ci * Host status bits (HOSTCOMM)
808c2ecf20Sopenharmony_ci */
818c2ecf20Sopenharmony_ci/* bit corresponds host ready bit in Host Status Register (HOST_COMM) */
828c2ecf20Sopenharmony_ci#define IPC_HOSTCOMM_READY_OFFS		(7)
838c2ecf20Sopenharmony_ci#define IPC_HOSTCOMM_READY_BIT		(1<<IPC_HOSTCOMM_READY_OFFS)
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci/***********************************/
868c2ecf20Sopenharmony_ci/*CHV_A0, CHV_B0*/
878c2ecf20Sopenharmony_ci#define	IPC_HOSTCOMM_INT_EN_OFFS_CHV_AB	(31)
888c2ecf20Sopenharmony_ci#define	IPC_HOSTCOMM_INT_EN_BIT_CHV_AB		\
898c2ecf20Sopenharmony_ci	(1<<IPC_HOSTCOMM_INT_EN_OFFS_CHV_AB)
908c2ecf20Sopenharmony_ci/*BXT, CHV_K0*/
918c2ecf20Sopenharmony_ci#define IPC_PIMR_INT_EN_OFFS_BXT	(0)
928c2ecf20Sopenharmony_ci#define IPC_PIMR_INT_EN_BIT_BXT		(1<<IPC_PIMR_INT_EN_OFFS_BXT)
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ci#define IPC_HOST2ISH_BUSYCLEAR_MASK_OFFS_BXT	(8)
958c2ecf20Sopenharmony_ci#define IPC_HOST2ISH_BUSYCLEAR_MASK_BIT		\
968c2ecf20Sopenharmony_ci	(1<<IPC_HOST2ISH_BUSYCLEAR_MASK_OFFS_BXT)
978c2ecf20Sopenharmony_ci/***********************************/
988c2ecf20Sopenharmony_ci/*
998c2ecf20Sopenharmony_ci * both Host and ISH have ILUP at bit 0
1008c2ecf20Sopenharmony_ci * bit corresponds host ready bit in both status registers
1018c2ecf20Sopenharmony_ci */
1028c2ecf20Sopenharmony_ci#define IPC_ILUP_OFFS			(0)
1038c2ecf20Sopenharmony_ci#define IPC_ILUP_BIT			(1<<IPC_ILUP_OFFS)
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci/*
1068c2ecf20Sopenharmony_ci * ISH FW status bits in ISH FW Status Register
1078c2ecf20Sopenharmony_ci */
1088c2ecf20Sopenharmony_ci#define IPC_ISH_FWSTS_SHIFT		12
1098c2ecf20Sopenharmony_ci#define IPC_ISH_FWSTS_MASK		GENMASK(15, 12)
1108c2ecf20Sopenharmony_ci#define IPC_GET_ISH_FWSTS(status)	\
1118c2ecf20Sopenharmony_ci	(((status) & IPC_ISH_FWSTS_MASK) >> IPC_ISH_FWSTS_SHIFT)
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci/*
1148c2ecf20Sopenharmony_ci * FW status bits (relevant)
1158c2ecf20Sopenharmony_ci */
1168c2ecf20Sopenharmony_ci#define	IPC_FWSTS_ILUP		0x1
1178c2ecf20Sopenharmony_ci#define	IPC_FWSTS_ISHTP_UP	(1<<1)
1188c2ecf20Sopenharmony_ci#define	IPC_FWSTS_DMA0		(1<<16)
1198c2ecf20Sopenharmony_ci#define	IPC_FWSTS_DMA1		(1<<17)
1208c2ecf20Sopenharmony_ci#define	IPC_FWSTS_DMA2		(1<<18)
1218c2ecf20Sopenharmony_ci#define	IPC_FWSTS_DMA3		(1<<19)
1228c2ecf20Sopenharmony_ci
1238c2ecf20Sopenharmony_ci#define	IPC_ISH_IN_DMA		\
1248c2ecf20Sopenharmony_ci	(IPC_FWSTS_DMA0 | IPC_FWSTS_DMA1 | IPC_FWSTS_DMA2 | IPC_FWSTS_DMA3)
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ci/* bit corresponds host ready bit in ISH FW Status Register */
1278c2ecf20Sopenharmony_ci#define IPC_ISH_ISHTP_READY_OFFS		(1)
1288c2ecf20Sopenharmony_ci#define IPC_ISH_ISHTP_READY_BIT		(1<<IPC_ISH_ISHTP_READY_OFFS)
1298c2ecf20Sopenharmony_ci
1308c2ecf20Sopenharmony_ci#define	IPC_RMP2_DMA_ENABLED	0x1	/* Value to enable DMA, per D3 RCR */
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci#define IPC_MSG_MAX_SIZE	0x80
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci#define IPC_HEADER_LENGTH_MASK		0x03FF
1368c2ecf20Sopenharmony_ci#define IPC_HEADER_PROTOCOL_MASK	0x0F
1378c2ecf20Sopenharmony_ci#define IPC_HEADER_MNG_CMD_MASK		0x0F
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci#define IPC_HEADER_LENGTH_OFFSET	0
1408c2ecf20Sopenharmony_ci#define IPC_HEADER_PROTOCOL_OFFSET	10
1418c2ecf20Sopenharmony_ci#define IPC_HEADER_MNG_CMD_OFFSET	16
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci#define IPC_HEADER_GET_LENGTH(drbl_reg)		\
1448c2ecf20Sopenharmony_ci	(((drbl_reg) >> IPC_HEADER_LENGTH_OFFSET)&IPC_HEADER_LENGTH_MASK)
1458c2ecf20Sopenharmony_ci#define IPC_HEADER_GET_PROTOCOL(drbl_reg)	\
1468c2ecf20Sopenharmony_ci	(((drbl_reg) >> IPC_HEADER_PROTOCOL_OFFSET)&IPC_HEADER_PROTOCOL_MASK)
1478c2ecf20Sopenharmony_ci#define IPC_HEADER_GET_MNG_CMD(drbl_reg)	\
1488c2ecf20Sopenharmony_ci	(((drbl_reg) >> IPC_HEADER_MNG_CMD_OFFSET)&IPC_HEADER_MNG_CMD_MASK)
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci#define IPC_IS_BUSY(drbl_reg)			\
1518c2ecf20Sopenharmony_ci	(((drbl_reg)&IPC_DRBL_BUSY_BIT) == ((uint32_t)IPC_DRBL_BUSY_BIT))
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ci/***********************************/
1548c2ecf20Sopenharmony_ci/*CHV_A0, CHV_B0*/
1558c2ecf20Sopenharmony_ci#define IPC_INT_FROM_ISH_TO_HOST_CHV_AB(drbl_reg) \
1568c2ecf20Sopenharmony_ci	(((drbl_reg)&IPC_INT_ISH2HOST_BIT_CHV_AB) == \
1578c2ecf20Sopenharmony_ci	((u32)IPC_INT_ISH2HOST_BIT_CHV_AB))
1588c2ecf20Sopenharmony_ci/*BXT, CHV_K0*/
1598c2ecf20Sopenharmony_ci#define IPC_INT_FROM_ISH_TO_HOST_BXT(drbl_reg) \
1608c2ecf20Sopenharmony_ci	(((drbl_reg)&IPC_INT_ISH2HOST_BIT_BXT) == \
1618c2ecf20Sopenharmony_ci	((u32)IPC_INT_ISH2HOST_BIT_BXT))
1628c2ecf20Sopenharmony_ci/***********************************/
1638c2ecf20Sopenharmony_ci
1648c2ecf20Sopenharmony_ci#define IPC_BUILD_HEADER(length, protocol, busy)		\
1658c2ecf20Sopenharmony_ci	(((busy)<<IPC_DRBL_BUSY_OFFS) |				\
1668c2ecf20Sopenharmony_ci	((protocol) << IPC_HEADER_PROTOCOL_OFFSET) |		\
1678c2ecf20Sopenharmony_ci	((length)<<IPC_HEADER_LENGTH_OFFSET))
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ci#define IPC_BUILD_MNG_MSG(cmd, length)				\
1708c2ecf20Sopenharmony_ci	(((1)<<IPC_DRBL_BUSY_OFFS)|				\
1718c2ecf20Sopenharmony_ci	((IPC_PROTOCOL_MNG)<<IPC_HEADER_PROTOCOL_OFFSET)|	\
1728c2ecf20Sopenharmony_ci	((cmd)<<IPC_HEADER_MNG_CMD_OFFSET)|			\
1738c2ecf20Sopenharmony_ci	 ((length)<<IPC_HEADER_LENGTH_OFFSET))
1748c2ecf20Sopenharmony_ci
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci#define IPC_SET_HOST_READY(host_status)		\
1778c2ecf20Sopenharmony_ci				((host_status) |= (IPC_HOSTCOMM_READY_BIT))
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ci#define IPC_SET_HOST_ILUP(host_status)		\
1808c2ecf20Sopenharmony_ci				((host_status) |= (IPC_ILUP_BIT))
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ci#define IPC_CLEAR_HOST_READY(host_status)	\
1838c2ecf20Sopenharmony_ci				((host_status) ^= (IPC_HOSTCOMM_READY_BIT))
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci#define IPC_CLEAR_HOST_ILUP(host_status)	\
1868c2ecf20Sopenharmony_ci				((host_status) ^= (IPC_ILUP_BIT))
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ci/* todo - temp until PIMR HW ready */
1898c2ecf20Sopenharmony_ci#define IPC_HOST_BUSY_READING_OFFS	6
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci/* bit corresponds host ready bit in Host Status Register (HOST_COMM) */
1928c2ecf20Sopenharmony_ci#define IPC_HOST_BUSY_READING_BIT	(1<<IPC_HOST_BUSY_READING_OFFS)
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci#define IPC_SET_HOST_BUSY_READING(host_status)	\
1958c2ecf20Sopenharmony_ci				((host_status) |= (IPC_HOST_BUSY_READING_BIT))
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci#define IPC_CLEAR_HOST_BUSY_READING(host_status)\
1988c2ecf20Sopenharmony_ci				((host_status) ^= (IPC_HOST_BUSY_READING_BIT))
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci#define IPC_IS_ISH_ISHTP_READY(ish_status)	\
2028c2ecf20Sopenharmony_ci		(((ish_status) & IPC_ISH_ISHTP_READY_BIT) ==	\
2038c2ecf20Sopenharmony_ci			((uint32_t)IPC_ISH_ISHTP_READY_BIT))
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_ci#define IPC_IS_ISH_ILUP(ish_status)		\
2068c2ecf20Sopenharmony_ci		(((ish_status) & IPC_ILUP_BIT) == ((uint32_t)IPC_ILUP_BIT))
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci#define IPC_PROTOCOL_ISHTP		1
2108c2ecf20Sopenharmony_ci#define IPC_PROTOCOL_MNG		3
2118c2ecf20Sopenharmony_ci
2128c2ecf20Sopenharmony_ci#define MNG_RX_CMPL_ENABLE		0
2138c2ecf20Sopenharmony_ci#define MNG_RX_CMPL_DISABLE		1
2148c2ecf20Sopenharmony_ci#define MNG_RX_CMPL_INDICATION		2
2158c2ecf20Sopenharmony_ci#define MNG_RESET_NOTIFY		3
2168c2ecf20Sopenharmony_ci#define MNG_RESET_NOTIFY_ACK		4
2178c2ecf20Sopenharmony_ci#define MNG_SYNC_FW_CLOCK		5
2188c2ecf20Sopenharmony_ci#define MNG_ILLEGAL_CMD			0xFF
2198c2ecf20Sopenharmony_ci
2208c2ecf20Sopenharmony_ci#endif /* _ISHTP_ISH_REGS_H_ */
221