162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci/*
462306a36Sopenharmony_ci * Copyright (c) 2021 MediaTek Corporation. All rights reserved.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci *  Header file for the mt8195 DSP register definition
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#ifndef __MT8195_H
1062306a36Sopenharmony_ci#define __MT8195_H
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_cistruct mtk_adsp_chip_info;
1362306a36Sopenharmony_cistruct snd_sof_dev;
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#define DSP_REG_BASE			0x10803000
1662306a36Sopenharmony_ci#define SCP_CFGREG_BASE			0x10724000
1762306a36Sopenharmony_ci#define DSP_SYSAO_BASE			0x1080C000
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci/*****************************************************************************
2062306a36Sopenharmony_ci *                  R E G I S T E R       TABLE
2162306a36Sopenharmony_ci *****************************************************************************/
2262306a36Sopenharmony_ci#define DSP_JTAGMUX			0x0000
2362306a36Sopenharmony_ci#define DSP_ALTRESETVEC			0x0004
2462306a36Sopenharmony_ci#define DSP_PDEBUGDATA			0x0008
2562306a36Sopenharmony_ci#define DSP_PDEBUGBUS0			0x000c
2662306a36Sopenharmony_ci#define PDEBUG_ENABLE			BIT(0)
2762306a36Sopenharmony_ci#define DSP_PDEBUGBUS1			0x0010
2862306a36Sopenharmony_ci#define DSP_PDEBUGINST			0x0014
2962306a36Sopenharmony_ci#define DSP_PDEBUGLS0STAT		0x0018
3062306a36Sopenharmony_ci#define DSP_PDEBUGLS1STAT		0x001c
3162306a36Sopenharmony_ci#define DSP_PDEBUGPC			0x0020
3262306a36Sopenharmony_ci#define DSP_RESET_SW			0x0024 /*reset sw*/
3362306a36Sopenharmony_ci#define ADSP_BRESET_SW			BIT(0)
3462306a36Sopenharmony_ci#define ADSP_DRESET_SW			BIT(1)
3562306a36Sopenharmony_ci#define ADSP_RUNSTALL			BIT(3)
3662306a36Sopenharmony_ci#define STATVECTOR_SEL			BIT(4)
3762306a36Sopenharmony_ci#define ADSP_PWAIT			BIT(16)
3862306a36Sopenharmony_ci#define DSP_PFAULTBUS			0x0028
3962306a36Sopenharmony_ci#define DSP_PFAULTINFO			0x002c
4062306a36Sopenharmony_ci#define DSP_GPR00			0x0030
4162306a36Sopenharmony_ci#define DSP_GPR01			0x0034
4262306a36Sopenharmony_ci#define DSP_GPR02			0x0038
4362306a36Sopenharmony_ci#define DSP_GPR03			0x003c
4462306a36Sopenharmony_ci#define DSP_GPR04			0x0040
4562306a36Sopenharmony_ci#define DSP_GPR05			0x0044
4662306a36Sopenharmony_ci#define DSP_GPR06			0x0048
4762306a36Sopenharmony_ci#define DSP_GPR07			0x004c
4862306a36Sopenharmony_ci#define DSP_GPR08			0x0050
4962306a36Sopenharmony_ci#define DSP_GPR09			0x0054
5062306a36Sopenharmony_ci#define DSP_GPR0A			0x0058
5162306a36Sopenharmony_ci#define DSP_GPR0B			0x005c
5262306a36Sopenharmony_ci#define DSP_GPR0C			0x0060
5362306a36Sopenharmony_ci#define DSP_GPR0D			0x0064
5462306a36Sopenharmony_ci#define DSP_GPR0E			0x0068
5562306a36Sopenharmony_ci#define DSP_GPR0F			0x006c
5662306a36Sopenharmony_ci#define DSP_GPR10			0x0070
5762306a36Sopenharmony_ci#define DSP_GPR11			0x0074
5862306a36Sopenharmony_ci#define DSP_GPR12			0x0078
5962306a36Sopenharmony_ci#define DSP_GPR13			0x007c
6062306a36Sopenharmony_ci#define DSP_GPR14			0x0080
6162306a36Sopenharmony_ci#define DSP_GPR15			0x0084
6262306a36Sopenharmony_ci#define DSP_GPR16			0x0088
6362306a36Sopenharmony_ci#define DSP_GPR17			0x008c
6462306a36Sopenharmony_ci#define DSP_GPR18			0x0090
6562306a36Sopenharmony_ci#define DSP_GPR19			0x0094
6662306a36Sopenharmony_ci#define DSP_GPR1A			0x0098
6762306a36Sopenharmony_ci#define DSP_GPR1B			0x009c
6862306a36Sopenharmony_ci#define DSP_GPR1C			0x00a0
6962306a36Sopenharmony_ci#define DSP_GPR1D			0x00a4
7062306a36Sopenharmony_ci#define DSP_GPR1E			0x00a8
7162306a36Sopenharmony_ci#define DSP_GPR1F			0x00ac
7262306a36Sopenharmony_ci#define DSP_TCM_OFFSET			0x00b0    /* not used */
7362306a36Sopenharmony_ci#define DSP_DDR_OFFSET			0x00b4    /* not used */
7462306a36Sopenharmony_ci#define DSP_INTFDSP			0x00d0
7562306a36Sopenharmony_ci#define DSP_INTFDSP_CLR			0x00d4
7662306a36Sopenharmony_ci#define DSP_SRAM_PD_SW1			0x00d8
7762306a36Sopenharmony_ci#define DSP_SRAM_PD_SW2			0x00dc
7862306a36Sopenharmony_ci#define DSP_OCD				0x00e0
7962306a36Sopenharmony_ci#define DSP_RG_DSP_IRQ_POL		0x00f0    /* not used */
8062306a36Sopenharmony_ci#define DSP_DSP_IRQ_EN			0x00f4    /* not used */
8162306a36Sopenharmony_ci#define DSP_DSP_IRQ_LEVEL		0x00f8    /* not used */
8262306a36Sopenharmony_ci#define DSP_DSP_IRQ_STATUS		0x00fc    /* not used */
8362306a36Sopenharmony_ci#define DSP_RG_INT2CIRQ			0x0114
8462306a36Sopenharmony_ci#define DSP_RG_INT_POL_CTL0		0x0120
8562306a36Sopenharmony_ci#define DSP_RG_INT_EN_CTL0		0x0130
8662306a36Sopenharmony_ci#define DSP_RG_INT_LV_CTL0		0x0140
8762306a36Sopenharmony_ci#define DSP_RG_INT_STATUS0		0x0150
8862306a36Sopenharmony_ci#define DSP_PDEBUGSTATUS0		0x0200
8962306a36Sopenharmony_ci#define DSP_PDEBUGSTATUS1		0x0204
9062306a36Sopenharmony_ci#define DSP_PDEBUGSTATUS2		0x0208
9162306a36Sopenharmony_ci#define DSP_PDEBUGSTATUS3		0x020c
9262306a36Sopenharmony_ci#define DSP_PDEBUGSTATUS4		0x0210
9362306a36Sopenharmony_ci#define DSP_PDEBUGSTATUS5		0x0214
9462306a36Sopenharmony_ci#define DSP_PDEBUGSTATUS6		0x0218
9562306a36Sopenharmony_ci#define DSP_PDEBUGSTATUS7		0x021c
9662306a36Sopenharmony_ci#define DSP_DSP2PSRAM_PRIORITY		0x0220  /* not used */
9762306a36Sopenharmony_ci#define DSP_AUDIO_DSP2SPM_INT		0x0224
9862306a36Sopenharmony_ci#define DSP_AUDIO_DSP2SPM_INT_ACK	0x0228
9962306a36Sopenharmony_ci#define DSP_AUDIO_DSP_DEBUG_SEL		0x022C
10062306a36Sopenharmony_ci#define DSP_AUDIO_DSP_EMI_BASE_ADDR	0x02E0  /* not used */
10162306a36Sopenharmony_ci#define DSP_AUDIO_DSP_SHARED_IRAM	0x02E4
10262306a36Sopenharmony_ci#define DSP_AUDIO_DSP_CKCTRL_P2P_CK_CON	0x02F0
10362306a36Sopenharmony_ci#define DSP_RG_SEMAPHORE00		0x0300
10462306a36Sopenharmony_ci#define DSP_RG_SEMAPHORE01		0x0304
10562306a36Sopenharmony_ci#define DSP_RG_SEMAPHORE02		0x0308
10662306a36Sopenharmony_ci#define DSP_RG_SEMAPHORE03		0x030C
10762306a36Sopenharmony_ci#define DSP_RG_SEMAPHORE04		0x0310
10862306a36Sopenharmony_ci#define DSP_RG_SEMAPHORE05		0x0314
10962306a36Sopenharmony_ci#define DSP_RG_SEMAPHORE06		0x0318
11062306a36Sopenharmony_ci#define DSP_RG_SEMAPHORE07		0x031C
11162306a36Sopenharmony_ci#define DSP_RESERVED_0			0x03F0
11262306a36Sopenharmony_ci#define DSP_RESERVED_1			0x03F4
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ci/* dsp wdt */
11562306a36Sopenharmony_ci#define DSP_WDT_MODE			0x0400
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ci/* dsp mbox */
11862306a36Sopenharmony_ci#define DSP_MBOX_IN_CMD			0x00
11962306a36Sopenharmony_ci#define DSP_MBOX_IN_CMD_CLR		0x04
12062306a36Sopenharmony_ci#define DSP_MBOX_OUT_CMD		0x1c
12162306a36Sopenharmony_ci#define DSP_MBOX_OUT_CMD_CLR		0x20
12262306a36Sopenharmony_ci#define DSP_MBOX_IN_MSG0		0x08
12362306a36Sopenharmony_ci#define DSP_MBOX_IN_MSG1		0x0C
12462306a36Sopenharmony_ci#define DSP_MBOX_OUT_MSG0		0x24
12562306a36Sopenharmony_ci#define DSP_MBOX_OUT_MSG1		0x28
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci/*dsp sys ao*/
12862306a36Sopenharmony_ci#define ADSP_SRAM_POOL_CON		(DSP_SYSAO_BASE + 0x30)
12962306a36Sopenharmony_ci#define DSP_SRAM_POOL_PD_MASK		0xf
13062306a36Sopenharmony_ci#define DSP_EMI_MAP_ADDR		(DSP_SYSAO_BASE + 0x81c)
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ci/* DSP memories */
13362306a36Sopenharmony_ci#define MBOX_OFFSET	0x800000 /* DRAM */
13462306a36Sopenharmony_ci#define MBOX_SIZE	0x1000 /* consistent with which in memory.h of sof fw */
13562306a36Sopenharmony_ci#define DSP_DRAM_SIZE	0x1000000 /* 16M */
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ci#define DSP_REG_BAR	4
13862306a36Sopenharmony_ci#define DSP_MBOX0_BAR	5
13962306a36Sopenharmony_ci#define DSP_MBOX1_BAR	6
14062306a36Sopenharmony_ci#define DSP_MBOX2_BAR	7
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ci#define SIZE_SHARED_DRAM_DL 0x40000 /*Shared buffer for Downlink*/
14362306a36Sopenharmony_ci#define SIZE_SHARED_DRAM_UL 0x40000 /*Shared buffer for Uplink*/
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ci#define TOTAL_SIZE_SHARED_DRAM_FROM_TAIL  \
14662306a36Sopenharmony_ci	(SIZE_SHARED_DRAM_DL + SIZE_SHARED_DRAM_UL)
14762306a36Sopenharmony_ci
14862306a36Sopenharmony_ci#define SRAM_PHYS_BASE_FROM_DSP_VIEW	0x40000000 /* MT8195 DSP view */
14962306a36Sopenharmony_ci#define DRAM_PHYS_BASE_FROM_DSP_VIEW	0x60000000 /* MT8195 DSP view */
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci/*remap dram between AP and DSP view, 4KB aligned*/
15262306a36Sopenharmony_ci#define DRAM_REMAP_SHIFT	12
15362306a36Sopenharmony_ci#define DRAM_REMAP_MASK		(BIT(DRAM_REMAP_SHIFT) - 1)
15462306a36Sopenharmony_ci
15562306a36Sopenharmony_ci/* suspend dsp idle check interval and timeout */
15662306a36Sopenharmony_ci#define SUSPEND_DSP_IDLE_TIMEOUT_US		1000000	/* timeout to wait dsp idle, 1 sec */
15762306a36Sopenharmony_ci#define SUSPEND_DSP_IDLE_POLL_INTERVAL_US	500	/* 0.5 msec */
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_civoid sof_hifixdsp_boot_sequence(struct snd_sof_dev *sdev, u32 boot_addr);
16062306a36Sopenharmony_civoid sof_hifixdsp_shutdown(struct snd_sof_dev *sdev);
16162306a36Sopenharmony_ci#endif
162