162306a36Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci/*
462306a36Sopenharmony_ci * Copyright (c) 2022 MediaTek Corporation. All rights reserved.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci *  Header file for the mt8186 DSP register definition
762306a36Sopenharmony_ci */
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#ifndef __MT8186_H
1062306a36Sopenharmony_ci#define __MT8186_H
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_cistruct mtk_adsp_chip_info;
1362306a36Sopenharmony_cistruct snd_sof_dev;
1462306a36Sopenharmony_ci
1562306a36Sopenharmony_ci#define DSP_REG_BAR			4
1662306a36Sopenharmony_ci#define DSP_SECREG_BAR			5
1762306a36Sopenharmony_ci#define DSP_BUSREG_BAR			6
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci/*****************************************************************************
2062306a36Sopenharmony_ci *                  R E G I S T E R       TABLE
2162306a36Sopenharmony_ci *****************************************************************************/
2262306a36Sopenharmony_ci/* dsp cfg */
2362306a36Sopenharmony_ci#define ADSP_CFGREG_SW_RSTN		0x0000
2462306a36Sopenharmony_ci#define SW_DBG_RSTN_C0			BIT(0)
2562306a36Sopenharmony_ci#define SW_RSTN_C0			BIT(4)
2662306a36Sopenharmony_ci#define ADSP_HIFI_IO_CONFIG		0x000C
2762306a36Sopenharmony_ci#define TRACEMEMREADY			BIT(15)
2862306a36Sopenharmony_ci#define RUNSTALL			BIT(31)
2962306a36Sopenharmony_ci#define ADSP_IRQ_MASK			0x0030
3062306a36Sopenharmony_ci#define ADSP_DVFSRC_REQ			0x0040
3162306a36Sopenharmony_ci#define ADSP_DDREN_REQ_0		0x0044
3262306a36Sopenharmony_ci#define ADSP_SEMAPHORE			0x0064
3362306a36Sopenharmony_ci#define ADSP_WDT_CON_C0			0x007C
3462306a36Sopenharmony_ci#define ADSP_MBOX_IRQ_EN		0x009C
3562306a36Sopenharmony_ci#define DSP_MBOX0_IRQ_EN		BIT(0)
3662306a36Sopenharmony_ci#define DSP_MBOX1_IRQ_EN		BIT(1)
3762306a36Sopenharmony_ci#define DSP_MBOX2_IRQ_EN		BIT(2)
3862306a36Sopenharmony_ci#define DSP_MBOX3_IRQ_EN		BIT(3)
3962306a36Sopenharmony_ci#define DSP_MBOX4_IRQ_EN		BIT(4)
4062306a36Sopenharmony_ci#define DSP_PDEBUGPC			0x013C
4162306a36Sopenharmony_ci#define DSP_PDEBUGDATA			0x0140
4262306a36Sopenharmony_ci#define DSP_PDEBUGINST			0x0144
4362306a36Sopenharmony_ci#define DSP_PDEBUGLS0STAT		0x0148
4462306a36Sopenharmony_ci#define DSP_PDEBUGSTATUS		0x014C
4562306a36Sopenharmony_ci#define DSP_PFAULTINFO			0x0150
4662306a36Sopenharmony_ci#define ADSP_CK_EN			0x1000
4762306a36Sopenharmony_ci#define CORE_CLK_EN			BIT(0)
4862306a36Sopenharmony_ci#define COREDBG_EN			BIT(1)
4962306a36Sopenharmony_ci#define TIMER_EN			BIT(3)
5062306a36Sopenharmony_ci#define DMA_EN				BIT(4)
5162306a36Sopenharmony_ci#define UART_EN				BIT(5)
5262306a36Sopenharmony_ci#define ADSP_UART_CTRL			0x1010
5362306a36Sopenharmony_ci#define UART_BCLK_CG			BIT(0)
5462306a36Sopenharmony_ci#define UART_RSTN			BIT(3)
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/* dsp sec */
5762306a36Sopenharmony_ci#define ADSP_PRID			0x0
5862306a36Sopenharmony_ci#define ADSP_ALTVEC_C0			0x04
5962306a36Sopenharmony_ci#define ADSP_ALTVECSEL			0x0C
6062306a36Sopenharmony_ci#define MT8188_ADSP_ALTVECSEL_C0	BIT(0)
6162306a36Sopenharmony_ci#define MT8186_ADSP_ALTVECSEL_C0	BIT(1)
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci/*
6462306a36Sopenharmony_ci * On MT8188, BIT(1) is not evaluated and on MT8186 BIT(0) is not evaluated:
6562306a36Sopenharmony_ci * We can simplify the driver by safely setting both bits regardless of the SoC.
6662306a36Sopenharmony_ci */
6762306a36Sopenharmony_ci#define ADSP_ALTVECSEL_C0		(MT8188_ADSP_ALTVECSEL_C0 | \
6862306a36Sopenharmony_ci					 MT8186_ADSP_ALTVECSEL_C0)
6962306a36Sopenharmony_ci
7062306a36Sopenharmony_ci/* dsp bus */
7162306a36Sopenharmony_ci#define ADSP_SRAM_POOL_CON		0x190
7262306a36Sopenharmony_ci#define DSP_SRAM_POOL_PD_MASK		0xF00F /* [0:3] and [12:15] */
7362306a36Sopenharmony_ci#define DSP_C0_EMI_MAP_ADDR		0xA00  /* ADSP Core0 To EMI Address Remap */
7462306a36Sopenharmony_ci#define DSP_C0_DMAEMI_MAP_ADDR		0xA08  /* DMA0 To EMI Address Remap */
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci/* DSP memories */
7762306a36Sopenharmony_ci#define MBOX_OFFSET			0x500000 /* DRAM */
7862306a36Sopenharmony_ci#define MBOX_SIZE			0x1000   /* consistent with which in memory.h of sof fw */
7962306a36Sopenharmony_ci#define DSP_DRAM_SIZE			0xA00000 /* 16M */
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ci/*remap dram between AP and DSP view, 4KB aligned*/
8262306a36Sopenharmony_ci#define SRAM_PHYS_BASE_FROM_DSP_VIEW	0x4E100000 /* MT8186 DSP view */
8362306a36Sopenharmony_ci#define DRAM_PHYS_BASE_FROM_DSP_VIEW	0x60000000 /* MT8186 DSP view */
8462306a36Sopenharmony_ci#define DRAM_REMAP_SHIFT		12
8562306a36Sopenharmony_ci#define DRAM_REMAP_MASK			0xFFF
8662306a36Sopenharmony_ci
8762306a36Sopenharmony_ci#define SIZE_SHARED_DRAM_DL			0x40000 /*Shared buffer for Downlink*/
8862306a36Sopenharmony_ci#define SIZE_SHARED_DRAM_UL			0x40000 /*Shared buffer for Uplink*/
8962306a36Sopenharmony_ci#define TOTAL_SIZE_SHARED_DRAM_FROM_TAIL	(SIZE_SHARED_DRAM_DL + SIZE_SHARED_DRAM_UL)
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_civoid mt8186_sof_hifixdsp_boot_sequence(struct snd_sof_dev *sdev, u32 boot_addr);
9262306a36Sopenharmony_civoid mt8186_sof_hifixdsp_shutdown(struct snd_sof_dev *sdev);
9362306a36Sopenharmony_ci#endif
94