platform: mtk: add mt8186 memory layout and register definitions

Add memory layout and register address for mtk mt8186

Cache
  I-Cache: 64KB, 4-way Associativity
  D-Cache: 128KB, 4-way Associativity

External Memory
  DRAM: DSP can access DRAM shared with CPU
  L2TCM: 512KB DSP SRAM POOL

Currently, use
phy addr:0x60000000, size:0x1000000
dma phy addr: 0x61000000, size: 0x0100000

Signed-off-by: Tinghan Shen <tinghan.shen@mediatek.com>
Signed-off-by: Allen-KH Cheng <allen-kh.cheng@mediatek.com>
This commit is contained in:
Tinghan Shen 2022-01-10 14:39:51 +08:00 committed by Liam Girdwood
parent c6ea9b9c20
commit 24e1b7f6ca
2 changed files with 336 additions and 0 deletions

View File

@ -0,0 +1,116 @@
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2022 Mediatek. All rights reserved.
//
// Author: Allen-KH Cheng <allen-kh.cheng@mediatek.com>
// Tinghan Shen <tinghan.shen@mediatek.com>
#ifndef MT_REG_BASE_H
#define MT_REG_BASE_H
#define MTK_REG_TOPCKGEN_BASE 0x10000000
#define MTK_REG_TOPCKGEN_SIZE 0x1000
#define MTK_REG_APMIXDSYS_BASE 0x1000C000
#define MTK_REG_APMIXDSYS_SIZE 0x1000
#define MTK_DSP_REG_BASE 0x10680000 /* DSP Register base */
#define MTK_DSP_CFGREG_BASE 0x10680000
#define MTK_DSP_CFGREG_SIZE 0x1000
#define MTK_DSP_CKCTRL_BASE 0x10681000
#define MTK_DSP_CKCTRL_SIZE 0x1000
#define MTK_DSP_OS_TIMER_BASE 0x10683000
#define MTK_DSP_OS_TIMER_SIZE 0x1000
#define MTK_DSP_UART0_BASE 0x10684000
#define MTK_DSP_UART0_SIZE 0x1000
#define MTK_DSP_TIMER_BASE 0x1068E000
#define MTK_DSP_TIMER_SIZE 0x1000
#define MTK_DSP_BUS_BASE 0x1068F000
#define MTK_DSP_BUS_SIZE 0x1000
#define MTK_DSP_AFE_BASE 0x11210000
#define MTK_DSP_AFE_SIZE 0xF000 /* register 8k, compacted sram 52k */
#define MTK_ADSP_CFGREG_SW_RSTN (MTK_DSP_REG_BASE + 0x0000)
#define MTK_ADSP_HIFI_IO_CONFIG (MTK_DSP_REG_BASE + 0x000c)
#define MTK_ADSP_IRQ_STATUS (MTK_DSP_REG_BASE + 0x0010)
#define MTK_ADSP_SW_INT_SET (MTK_DSP_REG_BASE + 0x0018)
#define MTK_ADSP_SW_INT_CLR (MTK_DSP_REG_BASE + 0x001c)
#define MTK_ADSP_SW_INT_32A (MTK_DSP_REG_BASE + 0x0020)
#define MTK_ADSP_IRQ_MASK (MTK_DSP_REG_BASE + 0x0030)
#define MTK_ADSP_GENERAL_IRQ_SET (MTK_DSP_REG_BASE + 0x0034)
#define MTK_ADSP_GENERAL_IRQ_CLR (MTK_DSP_REG_BASE + 0x0038)
#define MTK_ADSP_DVFSRC_STATE (MTK_DSP_REG_BASE + 0x003c)
#define MTK_ADSP_DVFSRC_REQ (MTK_DSP_REG_BASE + 0x0040)
#define MTK_ADSP_DDREN_REQ_0 (MTK_DSP_REG_BASE + 0x0044)
#define MTK_ADSP_SPM_ACK (MTK_DSP_REG_BASE + 0x004c)
#define MTK_ADSP_IRQ_EN (MTK_DSP_REG_BASE + 0x0050)
#define MTK_ADSP_IRQ_POL_FIX (MTK_DSP_REG_BASE + 0x0054)
#define MTK_ADSP_SPM_WAKEUPSRC_CORE0 (MTK_DSP_REG_BASE + 0x005c)
#define MTK_ADSP_SEMAPHORE (MTK_DSP_REG_BASE + 0x0064)
#define MTK_ADSP_DBG_SEL (MTK_DSP_REG_BASE + 0x0074)
#define MTK_ADSP_DBG_INFO (MTK_DSP_REG_BASE + 0x0078)
#define MTK_ADSP_WDT_CON_C0 (MTK_DSP_REG_BASE + 0x007c)
#define MTK_ADSP_WDT_INIT_VALUE_C0 (MTK_DSP_REG_BASE + 0x0080)
#define MTK_ADSP_WDT_CNT_C0 (MTK_DSP_REG_BASE + 0x0084)
#define MTK_ADSP_WAKEUPSRC_MASK_C0 (MTK_DSP_REG_BASE + 0x00a0)
#define MTK_ADSP_WAKEUPSRC_IRQ_C0 (MTK_DSP_REG_BASE + 0x00a4)
#define MTK_ADSP2SPM_MBOX (MTK_DSP_REG_BASE + 0x00bc)
#define MTK_SPM2ADSP_MBOX (MTK_DSP_REG_BASE + 0x00c0)
#define MTK_GPR_RW_REG0 (MTK_DSP_REG_BASE + 0x0440)
#define MTK_GPR_RW_REG1 (MTK_DSP_REG_BASE + 0x0444)
#define MTK_GPR_RW_REG2 (MTK_DSP_REG_BASE + 0x0448)
#define MTK_GPR_RW_REG3 (MTK_DSP_REG_BASE + 0x044c)
#define MTK_GPR_RW_REG4 (MTK_DSP_REG_BASE + 0x0450)
#define MTK_GPR_RW_REG5 (MTK_DSP_REG_BASE + 0x0454)
#define MTK_GPR_RW_REG6 (MTK_DSP_REG_BASE + 0x0458)
#define MTK_GPR_RW_REG7 (MTK_DSP_REG_BASE + 0x045c)
#define MTK_GPR_RW_REG8 (MTK_DSP_REG_BASE + 0x0460)
#define MTK_GPR_RW_REG9 (MTK_DSP_REG_BASE + 0x0464)
#define MTK_GPR_RW_REG10 (MTK_DSP_REG_BASE + 0x0468)
#define MTK_GPR_RW_REG11 (MTK_DSP_REG_BASE + 0x046c)
#define MTK_GPR_RW_REG12 (MTK_DSP_REG_BASE + 0x0470)
#define MTK_GPR_RW_REG13 (MTK_DSP_REG_BASE + 0x0474)
#define MTK_GPR_RW_REG14 (MTK_DSP_REG_BASE + 0x0478)
#define MTK_GPR_RW_REG15 (MTK_DSP_REG_BASE + 0x047c)
#define MTK_GPR_RW_REG16 (MTK_DSP_REG_BASE + 0x0480)
#define MTK_GPR_RW_REG17 (MTK_DSP_REG_BASE + 0x0484)
#define MTK_GPR_RW_REG18 (MTK_DSP_REG_BASE + 0x0488)
#define MTK_GPR_RW_REG19 (MTK_DSP_REG_BASE + 0x048c)
#define MTK_GPR_RW_REG20 (MTK_DSP_REG_BASE + 0x0490)
#define MTK_GPR_RW_REG21 (MTK_DSP_REG_BASE + 0x0494)
#define MTK_GPR_RW_REG22 (MTK_DSP_REG_BASE + 0x0498)
#define MTK_GPR_RW_REG23 (MTK_DSP_REG_BASE + 0x049c)
#define MTK_GPR_RW_REG24 (MTK_DSP_REG_BASE + 0x04a0)
#define MTK_GPR_RW_REG25 (MTK_DSP_REG_BASE + 0x04a4)
#define MTK_GPR_RW_REG26 (MTK_DSP_REG_BASE + 0x04a8)
#define MTK_GPR_RW_REG27 (MTK_DSP_REG_BASE + 0x04ac)
#define MTK_GPR_RW_REG28 (MTK_DSP_REG_BASE + 0x04b0) /* use for tickless status */
#define MTK_GPR_RW_REG29 (MTK_DSP_REG_BASE + 0x04b4)
#define MTK_ADSP_CLK_BUS_UPDATE (MTK_DSP_REG_BASE + 0x04c0)
#define MTK_ADSP_IRQ_OUT_MASK (MTK_DSP_REG_BASE + 0x0500)
#define MTK_MBOX_IRQ_IN (MTK_DSP_REG_BASE + 0xB070)
#define MTK_ADSP_BUS_SRC (MTK_DSP_BUS_BASE + 0x140)
#define MTK_ADSPPLL_CON0 (MTK_REG_APMIXDSYS_BASE + 0x304)
#define MTK_ADSPPLL_CON1 (MTK_REG_APMIXDSYS_BASE + 0x308)
#define MTK_ADSPPLL_CON2 (MTK_REG_APMIXDSYS_BASE + 0x30C)
#define MTK_ADSPPLL_CON3 (MTK_REG_APMIXDSYS_BASE + 0x310)
#define MTK_CLK_MODE (MTK_REG_TOPCKGEN_BASE + 0x0)
#define MTK_CLK_CFG_UPDATE (MTK_REG_TOPCKGEN_BASE + 0x8)
#define MTK_CLK_CFG_11 (MTK_REG_TOPCKGEN_BASE + 0x0EC)
#define MTK_CLK_CFG_11_SET (MTK_REG_TOPCKGEN_BASE + 0x0F0)
#define MTK_CLK_CFG_11_CLR (MTK_REG_TOPCKGEN_BASE + 0x0F4)
#define MTK_CLK_CFG_15 (MTK_REG_TOPCKGEN_BASE + 0x180)
#define MTK_CLK_CFG_15_SET (MTK_REG_TOPCKGEN_BASE + 0x184)
#define MTK_CLK_CFG_15_CLR (MTK_REG_TOPCKGEN_BASE + 0x188)
/* MBOX registers */
#define MTK_ADSP_MBOX_REG_BASE(x) (0x10686000 + (0x1000 * (x)))
#define MTK_ADSP_MBOX_REG_SIZE (0x5000)
#define MTK_ADSP_MBOX_IN_CMD(x) (MTK_ADSP_MBOX_REG_BASE(x) + 0x100)
#define MTK_ADSP_MBOX_IN_CMD_CLR(x) (MTK_ADSP_MBOX_REG_BASE(x) + 0x108)
#define MTK_ADSP_MBOX_OUT_CMD(x) (MTK_ADSP_MBOX_REG_BASE(x) + 0x104)
#define MTK_ADSP_MBOX_OUT_CMD_CLR(x) (MTK_ADSP_MBOX_REG_BASE(x) + 0x10c)
#endif /* MT_REG_BASE_H */

View File

@ -0,0 +1,220 @@
// SPDX-License-Identifier: BSD-3-Clause
//
// Copyright(c) 2022 Mediatek. All rights reserved.
//
// Author: Allen-KH Cheng <allen-kh.cheng@mediatek.com>
// Tinghan Shen <tinghan.shen@mediatek.com>
#ifdef __SOF_LIB_MEMORY_H__
#ifndef __PLATFORM_LIB_MEMORY_H__
#define __PLATFORM_LIB_MEMORY_H__
#include <sof/lib/cache.h>
/* data cache line alignment */
#define PLATFORM_DCACHE_ALIGN sizeof(void *)
/* physical DSP addresses */
#define SRAM_BASE 0x4e100000
#define SRAM_SIZE 0x100000
/* reset vector + rodata + module_init + text + data + bss */
#define SOF_DATA_SIZE 0x80000
#define VECTOR_SIZE 0x700
#define SRAM_START (SRAM_BASE + VECTOR_SIZE)
#define DRAM_BASE 0x60000000
#define DRAM0_SIZE 0x500000
#define MAILBOX_BASE (DRAM_BASE + DRAM0_SIZE)
#define DSP_SYS_SIZE 0xA00000
#define UUID_ENTRY_ELF_BASE (SRAM_BASE + SOF_DATA_SIZE)
#define UUID_ENTRY_ELF_SIZE 0x6000
#define LOG_ENTRY_ELF_BASE (UUID_ENTRY_ELF_BASE + UUID_ENTRY_ELF_SIZE)
#define LOG_ENTRY_ELF_SIZE 0x20000
#define EXT_MANIFEST_ELF_BASE (LOG_ENTRY_ELF_BASE + LOG_ENTRY_ELF_SIZE)
#define EXT_MANIFEST_ELF_SIZE (SRAM_BASE + SRAM_SIZE - EXT_MANIFEST_ELF_BASE)
/*
* The Memory Layout on MT8186 are organised like this :-
*
* +--------------------------------------------------------------------------+
* | Offset | Region | Size |
* +---------------------+----------------+-----------------------------------+
* | SRAM_START | RO Data | SOF_DATA_SIZE |
* | | text | |
* | | Data | |
* | | BSS | |
* +---------------------+----------------+-----------------------------------+
* | fw_ready |
* +---------------------+----------------+-----------------------------------+
* | static_uuid |
* +---------------------+----------------+-----------------------------------+
* | static_log |
* +---------------------+----------------+-----------------------------------+
* | fw_metadata |
* +---------------------+----------------+-----------------------------------+
*
* +---------------------+----------------+-----------------------------------+
* | HEAP_SYSTEM_BASE | System Heap | HEAP_SYSTEM_SIZE |
* +---------------------+----------------+-----------------------------------+
* | HEAP_RUNTIME_BASE | Runtime Heap | HEAP_RUNTIME_SIZE |
* +---------------------+----------------+-----------------------------------+
* | HEAP_BUFFER_BASE | Module Buffers | HEAP_BUFFER_SIZE |
* +---------------------+----------------+-----------------------------------+
* | SOF_STACK_END | Stack | SOF_STACK_SIZE |
* +---------------------+----------------+-----------------------------------+
* | SOF_STACK_BASE | | |
* +---------------------+----------------+-----------------------------------+
*/
/* Mailbox configuration */
#define SRAM_OUTBOX_BASE MAILBOX_BASE
#define SRAM_OUTBOX_SIZE 0x1000
#define SRAM_OUTBOX_OFFSET 0
#define SRAM_INBOX_BASE (SRAM_OUTBOX_BASE + SRAM_OUTBOX_SIZE)
#define SRAM_INBOX_SIZE 0x1000
#define SRAM_INBOX_OFFSET SRAM_OUTBOX_SIZE
#define SRAM_DEBUG_BASE (SRAM_INBOX_BASE + SRAM_INBOX_SIZE)
#define SRAM_DEBUG_SIZE 0x800
#define SRAM_DEBUG_OFFSET (SRAM_INBOX_OFFSET + SRAM_INBOX_SIZE)
#define SRAM_EXCEPT_BASE (SRAM_DEBUG_BASE + SRAM_DEBUG_SIZE)
#define SRAM_EXCEPT_SIZE 0x800
#define SRAM_EXCEPT_OFFSET (SRAM_DEBUG_OFFSET + SRAM_DEBUG_SIZE)
#define SRAM_STREAM_BASE (SRAM_EXCEPT_BASE + SRAM_EXCEPT_SIZE)
#define SRAM_STREAM_SIZE 0x1000
#define SRAM_STREAM_OFFSET (SRAM_EXCEPT_OFFSET + SRAM_EXCEPT_SIZE)
#define SRAM_TRACE_BASE (SRAM_STREAM_BASE + SRAM_STREAM_SIZE)
#define SRAM_TRACE_SIZE 0x1000
#define SRAM_TRACE_OFFSET (SRAM_STREAM_OFFSET + SRAM_STREAM_SIZE)
/*4K + 4K +2K + 2K + 4K + 4K = 20KB*/
#define SOF_MAILBOX_SIZE \
(SRAM_INBOX_SIZE + SRAM_OUTBOX_SIZE + SRAM_DEBUG_SIZE + \
SRAM_EXCEPT_SIZE + SRAM_STREAM_SIZE + SRAM_TRACE_SIZE)
/* Heap section sizes for module pool */
#define HEAP_RT_COUNT8 0
#define HEAP_RT_COUNT16 48
#define HEAP_RT_COUNT32 48
#define HEAP_RT_COUNT64 32
#define HEAP_RT_COUNT128 32
#define HEAP_RT_COUNT256 32
#define HEAP_RT_COUNT512 4
#define HEAP_RT_COUNT1024 4
#define HEAP_RT_COUNT2048 2
#define HEAP_RT_COUNT4096 2
/* Heap section sizes for system runtime heap */
#define HEAP_SYS_RT_COUNT64 128
#define HEAP_SYS_RT_COUNT512 16
#define HEAP_SYS_RT_COUNT1024 8
/* Heap configuration */
#define HEAP_SYSTEM_BASE DRAM_BASE
#define HEAP_SYSTEM_SIZE 0x6000
#define HEAP_SYS_RUNTIME_BASE (HEAP_SYSTEM_BASE + HEAP_SYSTEM_SIZE)
/*24KB*/
#define HEAP_SYS_RUNTIME_SIZE \
(HEAP_SYS_RT_COUNT64 * 64 + HEAP_SYS_RT_COUNT512 * 512 + \
HEAP_SYS_RT_COUNT1024 * 1024)
#define HEAP_RUNTIME_BASE (HEAP_SYS_RUNTIME_BASE + HEAP_SYS_RUNTIME_SIZE)
/*48*(16 +32) + 32*(64 128+256) + 4*(512+1024) + 1*2048 = 24832 = 24.25KB*/
#define HEAP_RUNTIME_SIZE \
(HEAP_RT_COUNT8 * 8 + HEAP_RT_COUNT16 * 16 + \
HEAP_RT_COUNT32 * 32 + HEAP_RT_COUNT64 * 64 + \
HEAP_RT_COUNT128 * 128 + HEAP_RT_COUNT256 * 256 + \
HEAP_RT_COUNT512 * 512 + HEAP_RT_COUNT1024 * 1024 + \
HEAP_RT_COUNT2048 * 2048 + HEAP_RT_COUNT4096 * 4096)
#define HEAP_BUFFER_BASE (HEAP_RUNTIME_BASE + HEAP_RUNTIME_SIZE)
#define HEAP_BUFFER_SIZE \
(DRAM0_SIZE - HEAP_RUNTIME_SIZE - SOF_STACK_TOTAL_SIZE - \
HEAP_SYS_RUNTIME_SIZE - HEAP_SYSTEM_SIZE)
#define HEAP_BUFFER_BLOCK_SIZE 0x100
#define HEAP_BUFFER_COUNT (HEAP_BUFFER_SIZE / HEAP_BUFFER_BLOCK_SIZE)
#define PLATFORM_HEAP_SYSTEM 1 /* one per core */
#define PLATFORM_HEAP_SYSTEM_RUNTIME 1 /* one per core */
#define PLATFORM_HEAP_RUNTIME 1
#define PLATFORM_HEAP_BUFFER 1
/* Stack configuration */
#define SOF_STACK_SIZE 0x8000
#define SOF_STACK_TOTAL_SIZE SOF_STACK_SIZE /*4KB*/
#define SOF_STACK_BASE (DRAM_BASE + DRAM0_SIZE)
#define SOF_STACK_END (SOF_STACK_BASE - SOF_STACK_TOTAL_SIZE)
/* Vector and literal sizes - not in core-isa.h */
#define SOF_MEM_VECT_LIT_SIZE 0x4
#define SOF_MEM_VECT_TEXT_SIZE 0x1c
#define SOF_MEM_VECT_SIZE (SOF_MEM_VECT_TEXT_SIZE + SOF_MEM_VECT_LIT_SIZE)
#define SOF_MEM_RESET_TEXT_SIZE 0x2e0
#define SOF_MEM_RESET_LIT_SIZE 0x120
#define SOF_MEM_VECBASE_LIT_SIZE 0x178
#define SOF_MEM_RO_SIZE 0x8
#define HEAP_BUF_ALIGNMENT DCACHE_LINE_SIZE
/** \brief EDF task's default stack size in bytes. */
#define PLATFORM_TASK_DEFAULT_STACK_SIZE 3072
#if !defined(__ASSEMBLER__) && !defined(LINKER)
struct sof;
/**
* \brief Data shared between different cores.
* Does nothing, since mt8186 doesn't support SMP.
*/
#define SHARED_DATA
void platform_init_memmap(struct sof *sof);
static inline void *platform_shared_get(void *ptr, int bytes)
{
return ptr;
}
#define uncache_to_cache(address) address
#define cache_to_uncache(address) address
#define is_uncached(address) 0
/**
* \brief Function for keeping shared data synchronized.
* It's used after usage of data shared by different cores.
* Such data is either statically marked with SHARED_DATA
* or dynamically allocated with SOF_MEM_FLAG_SHARED flag.
* Does nothing, since mt8186 doesn't support SMP.
*/
static inline void *platform_rfree_prepare(void *ptr)
{
return ptr;
}
#endif
#define host_to_local(addr) (addr)
#define local_to_host(addr) (addr)
#endif /* __PLATFORM_LIB_MEMORY_H__ */
#else
#error "This file shouldn't be included from outside of sof/lib/memory.h"
#endif /* __SOF_LIB_MEMORY_H__ */