|
| 1 | +/* SPDX-License-Identifier: BSD-3-Clause */ |
| 2 | +/* |
| 3 | + * Copyright(c) 2024 MediaTek. All rights reserved. |
| 4 | + * |
| 5 | + * Author: Andrew Perepech <andrew.perepech@mediatek.com> |
| 6 | + */ |
| 7 | + |
| 8 | +#ifdef __SOF_LIB_MEMORY_H__ |
| 9 | + |
| 10 | +#ifndef __PLATFORM_LIB_MEMORY_H__ |
| 11 | +#define __PLATFORM_LIB_MEMORY_H__ |
| 12 | + |
| 13 | +#include <rtos/cache.h> |
| 14 | +#include <xtensa/config/core-isa.h> |
| 15 | + |
| 16 | +#define BOOT_WITH_DRAM /*Use DRAM as SRAM1 for heap related*/ |
| 17 | +/* data cache line alignment */ |
| 18 | +#define PLATFORM_DCACHE_ALIGN sizeof(void *) |
| 19 | + |
| 20 | +/* |
| 21 | + * +-----------------------------------+-----------------------------+ |
| 22 | + * | | AUDIO_DSP_SHARED_DRAM | |
| 23 | + * +------------+----------------------+---------+---------+---------+ |
| 24 | + * | DSP | Sys | Size | 00b | 01b *** | 11b | |
| 25 | + * +------------+------------+---------+---------+---------+---------+ |
| 26 | + * | 0x40000000 | 0x1e100000 | 0x8000 | iram0_0 | iram0_0 | iram0_0 | |
| 27 | + * | 0x40008000 | 0x1e108000 | 0x8000 | iram0_1 | iram0_1 | --- | |
| 28 | + * | 0x40010000 | 0x1e110000 | 0x8000 | iram1 | --- | --- | |
| 29 | + * +------------+------------+---------+---------+---------+---------+ |
| 30 | + * | 0x1e000000 | 0x1e000000 | 0x40000 | dram0 | dram0 | dram0 | |
| 31 | + * | 0x1e040000 | 0x1e040000 | 0x20000 | dram1 | dram1 | dram1 | |
| 32 | + * | 0x1e060000 | 0x1e060000 | 0x8000 | --- | iram1 | iram1 | |
| 33 | + * | 0x1e068000 | 0x1e068000 | 0x8000 | --- | --- | iram0_1 | |
| 34 | + * +------------+------------+---------+---------+---------+---------+ |
| 35 | + */ |
| 36 | + |
| 37 | +/* BOOT_WITH_DRAM ONLY */ |
| 38 | +/* physical DSP addresses */ |
| 39 | +#define DRAM_BASE 0x60000000 |
| 40 | +#define DRAM_AUDIO_SHARED_SIZE 0x280000 |
| 41 | +#define DRAM_SIZE 0x1000000 /*DRAM Size : 16M , need to sync with Host side*/ |
| 42 | + |
| 43 | +#define SRAM_TOTAL_SIZE 0x40000 /*256KB DSP SRAM*/ |
| 44 | +#define VECTOR_SIZE 0x628 |
| 45 | + |
| 46 | +#define SRAM0_BASE DRAM_BASE |
| 47 | +#define SRAM0_SIZE (DRAM_SIZE >> 1) |
| 48 | +#define SRAM1_BASE (DRAM_BASE + SRAM0_SIZE) |
| 49 | +#define SRAM1_SIZE \ |
| 50 | + (DRAM_SIZE - SRAM0_SIZE - DRAM_AUDIO_SHARED_SIZE - UUID_ENTRY_ELF_SIZE - \ |
| 51 | + LOG_ENTRY_ELF_SIZE - EXT_MANIFEST_ELF_SIZE) |
| 52 | + |
| 53 | +#define DMA_SIZE 0x100000 |
| 54 | + |
| 55 | +#define UUID_ENTRY_ELF_SIZE 0x6000 |
| 56 | +#define LOG_ENTRY_ELF_SIZE 0x200000 |
| 57 | +#define EXT_MANIFEST_ELF_SIZE 0x100000 |
| 58 | + |
| 59 | +#define UUID_ENTRY_ELF_BASE (SRAM1_BASE + SRAM1_SIZE) |
| 60 | +#define LOG_ENTRY_ELF_BASE (UUID_ENTRY_ELF_BASE + UUID_ENTRY_ELF_SIZE) |
| 61 | +#define EXT_MANIFEST_ELF_BASE (LOG_ENTRY_ELF_BASE + LOG_ENTRY_ELF_SIZE) |
| 62 | + |
| 63 | +/* |
| 64 | + * The Memory Layout on MT8365 are organised like this :- |
| 65 | + * |
| 66 | + * +--------------------------------------------------------------------------+ |
| 67 | + * | Offset | Region | Size | |
| 68 | + * +---------------------+----------------+-----------------------------------+ |
| 69 | + * | XCHAL_RESET_VECTOR0 | DSP Vectors | VECTOR_SIZE | |
| 70 | + * +---------------------+----------------+-----------------------------------+ |
| 71 | + * | SRAM0_BASE | fw_ready | SRAM0_SIZE | |
| 72 | + * | | RO Data | | |
| 73 | + * | | module_init | | |
| 74 | + * | | Text | | |
| 75 | + * | | Data | | |
| 76 | + * | | BSS | | |
| 77 | + * +---------------------+----------------+-----------------------------------+ |
| 78 | + * | SRAM1_BASE | MAILBOX | SOF_MAILBOX_SIZE | |
| 79 | + * +---------------------+----------------+-----------------------------------+ |
| 80 | + * | HEAP_SYSTEM_BASE | System Heap | HEAP_SYSTEM_SIZE | |
| 81 | + * +---------------------+----------------+-----------------------------------+ |
| 82 | + * | HEAP_RUNTIME_BASE | Runtime Heap | HEAP_RUNTIME_SIZE | |
| 83 | + * +---------------------+----------------+-----------------------------------+ |
| 84 | + * | HEAP_BUFFER_BASE | Module Buffers | HEAP_BUFFER_SIZE | |
| 85 | + * +---------------------+----------------+-----------------------------------+ |
| 86 | + * | SOF_STACK_END | Stack | SOF_STACK_SIZE | |
| 87 | + * +---------------------+----------------+-----------------------------------+ |
| 88 | + * | SOF_STACK_BASE | | | |
| 89 | + * +---------------------+----------------+-----------------------------------+ |
| 90 | + */ |
| 91 | + |
| 92 | +/* Mailbox configuration */ |
| 93 | +#define SRAM_OUTBOX_BASE SRAM1_BASE |
| 94 | +#define SRAM_OUTBOX_SIZE 0x1000 |
| 95 | +#define SRAM_OUTBOX_OFFSET 0 |
| 96 | + |
| 97 | +#define SRAM_INBOX_BASE (SRAM_OUTBOX_BASE + SRAM_OUTBOX_SIZE) |
| 98 | +#define SRAM_INBOX_SIZE 0x1000 |
| 99 | +#define SRAM_INBOX_OFFSET SRAM_OUTBOX_SIZE |
| 100 | + |
| 101 | +#define SRAM_DEBUG_BASE (SRAM_INBOX_BASE + SRAM_INBOX_SIZE) |
| 102 | +#define SRAM_DEBUG_SIZE 0x800 |
| 103 | +#define SRAM_DEBUG_OFFSET (SRAM_INBOX_OFFSET + SRAM_INBOX_SIZE) |
| 104 | + |
| 105 | +#define SRAM_EXCEPT_BASE (SRAM_DEBUG_BASE + SRAM_DEBUG_SIZE) |
| 106 | +#define SRAM_EXCEPT_SIZE 0x800 |
| 107 | +#define SRAM_EXCEPT_OFFSET (SRAM_DEBUG_OFFSET + SRAM_DEBUG_SIZE) |
| 108 | + |
| 109 | +#define SRAM_STREAM_BASE (SRAM_EXCEPT_BASE + SRAM_EXCEPT_SIZE) |
| 110 | +#define SRAM_STREAM_SIZE 0x1000 |
| 111 | +#define SRAM_STREAM_OFFSET (SRAM_EXCEPT_OFFSET + SRAM_EXCEPT_SIZE) |
| 112 | + |
| 113 | +#define SRAM_TRACE_BASE (SRAM_STREAM_BASE + SRAM_STREAM_SIZE) |
| 114 | +#define SRAM_TRACE_SIZE 0x1000 |
| 115 | +#define SRAM_TRACE_OFFSET (SRAM_STREAM_OFFSET + SRAM_STREAM_SIZE) |
| 116 | + |
| 117 | +/*4K + 4K +2K + 2K + 4K + 4K = 20KB*/ |
| 118 | +#define SOF_MAILBOX_SIZE \ |
| 119 | + (SRAM_INBOX_SIZE + SRAM_OUTBOX_SIZE + SRAM_DEBUG_SIZE + SRAM_EXCEPT_SIZE + \ |
| 120 | + SRAM_STREAM_SIZE + SRAM_TRACE_SIZE) |
| 121 | + |
| 122 | +/* Heap section sizes for module pool */ |
| 123 | +#define HEAP_RT_COUNT8 0 |
| 124 | +#define HEAP_RT_COUNT16 48 |
| 125 | +#define HEAP_RT_COUNT32 48 |
| 126 | +#define HEAP_RT_COUNT64 32 |
| 127 | +#define HEAP_RT_COUNT128 32 |
| 128 | +#define HEAP_RT_COUNT256 32 |
| 129 | +#define HEAP_RT_COUNT512 32 |
| 130 | +#define HEAP_RT_COUNT1024 4 |
| 131 | +#define HEAP_RT_COUNT2048 2 |
| 132 | +#define HEAP_RT_COUNT4096 2 |
| 133 | + |
| 134 | +/* Heap section sizes for system runtime heap */ |
| 135 | +#define HEAP_SYS_RT_COUNT64 128 |
| 136 | +#define HEAP_SYS_RT_COUNT512 16 |
| 137 | +#define HEAP_SYS_RT_COUNT1024 8 |
| 138 | + |
| 139 | +/* Heap configuration */ |
| 140 | + |
| 141 | +#define HEAP_SYSTEM_BASE (SRAM1_BASE + SOF_MAILBOX_SIZE) |
| 142 | +#define HEAP_SYSTEM_SIZE 0x6000 |
| 143 | + |
| 144 | +#define HEAP_SYSTEM_0_BASE HEAP_SYSTEM_BASE |
| 145 | + |
| 146 | +#define HEAP_SYS_RUNTIME_BASE (HEAP_SYSTEM_BASE + HEAP_SYSTEM_SIZE) |
| 147 | +/*24KB*/ |
| 148 | +#define HEAP_SYS_RUNTIME_SIZE \ |
| 149 | + (HEAP_SYS_RT_COUNT64 * 64 + HEAP_SYS_RT_COUNT512 * 512 + HEAP_SYS_RT_COUNT1024 * 1024) |
| 150 | + |
| 151 | +#define HEAP_RUNTIME_BASE (HEAP_SYS_RUNTIME_BASE + HEAP_SYS_RUNTIME_SIZE) |
| 152 | +/*48*(16 +32) + 32*(64 128+256) + 4*(512+1024) + 1*2048 = 24832 = 24.25KB*/ |
| 153 | +#define HEAP_RUNTIME_SIZE \ |
| 154 | + (HEAP_RT_COUNT8 * 8 + HEAP_RT_COUNT16 * 16 + HEAP_RT_COUNT32 * 32 + HEAP_RT_COUNT64 * 64 + \ |
| 155 | + HEAP_RT_COUNT128 * 128 + HEAP_RT_COUNT256 * 256 + HEAP_RT_COUNT512 * 512 + \ |
| 156 | + HEAP_RT_COUNT1024 * 1024 + HEAP_RT_COUNT2048 * 2048 + HEAP_RT_COUNT4096 * 4096) |
| 157 | + |
| 158 | +#define HEAP_BUFFER_BASE (HEAP_RUNTIME_BASE + HEAP_RUNTIME_SIZE) |
| 159 | +#define HEAP_BUFFER_SIZE \ |
| 160 | + (SRAM1_SIZE - SOF_MAILBOX_SIZE - HEAP_RUNTIME_SIZE - SOF_STACK_TOTAL_SIZE - \ |
| 161 | + HEAP_SYS_RUNTIME_SIZE - HEAP_SYSTEM_SIZE) |
| 162 | + |
| 163 | +#define HEAP_BUFFER_BLOCK_SIZE 0x100 |
| 164 | +#define HEAP_BUFFER_COUNT (HEAP_BUFFER_SIZE / HEAP_BUFFER_BLOCK_SIZE) |
| 165 | + |
| 166 | +#define PLATFORM_HEAP_SYSTEM 1 /* one per core */ |
| 167 | +#define PLATFORM_HEAP_SYSTEM_RUNTIME 1 /* one per core */ |
| 168 | +#define PLATFORM_HEAP_RUNTIME 1 |
| 169 | +#define PLATFORM_HEAP_BUFFER 1 |
| 170 | + |
| 171 | +/* Stack configuration */ |
| 172 | +#define SOF_STACK_SIZE 0x8000 |
| 173 | +#define SOF_STACK_TOTAL_SIZE SOF_STACK_SIZE /*4KB*/ |
| 174 | +#define SOF_STACK_BASE (SRAM1_BASE + SRAM1_SIZE) |
| 175 | +#define SOF_STACK_END (SOF_STACK_BASE - SOF_STACK_TOTAL_SIZE) |
| 176 | + |
| 177 | +/* Vector and literal sizes - not in core-isa.h */ |
| 178 | +#define SOF_MEM_VECT_LIT_SIZE 0x4 |
| 179 | +#define SOF_MEM_VECT_TEXT_SIZE 0x1c |
| 180 | +#define SOF_MEM_VECT_SIZE (SOF_MEM_VECT_TEXT_SIZE + SOF_MEM_VECT_LIT_SIZE) |
| 181 | + |
| 182 | +#define SOF_MEM_RESET_TEXT_SIZE 0x2e0 |
| 183 | +#define SOF_MEM_RESET_LIT_SIZE 0x120 |
| 184 | +#define SOF_MEM_VECBASE_LIT_SIZE 0x178 |
| 185 | + |
| 186 | +#define SOF_MEM_RO_SIZE 0x8 |
| 187 | + |
| 188 | +#define HEAP_BUF_ALIGNMENT DCACHE_LINE_SIZE |
| 189 | + |
| 190 | +/** \brief EDF task's default stack size in bytes. */ |
| 191 | +#ifdef CONFIG_COMP_GOOGLE_RTC_AUDIO_PROCESSING |
| 192 | +#define PLATFORM_TASK_DEFAULT_STACK_SIZE (12 * 1024) |
| 193 | +#else |
| 194 | +#define PLATFORM_TASK_DEFAULT_STACK_SIZE 3072 |
| 195 | +#endif |
| 196 | + |
| 197 | +#if !defined(__ASSEMBLER__) && !defined(LINKER) |
| 198 | + |
| 199 | +struct sof; |
| 200 | + |
| 201 | +/** |
| 202 | + * \brief Data shared between different cores. |
| 203 | + * Does nothing, since mt8195 doesn't support SMP. |
| 204 | + */ |
| 205 | +#define SHARED_DATA |
| 206 | + |
| 207 | +void platform_init_memmap(struct sof *sof); |
| 208 | + |
| 209 | +static inline void *platform_shared_get(void *ptr, int bytes) |
| 210 | +{ |
| 211 | + return ptr; |
| 212 | +} |
| 213 | + |
| 214 | +#define uncache_to_cache(address) address |
| 215 | +#define cache_to_uncache(address) address |
| 216 | +#define cache_to_uncache_init(address) address |
| 217 | +#define is_uncached(address) 0 |
| 218 | + |
| 219 | +/** |
| 220 | + * \brief Function for keeping shared data synchronized. |
| 221 | + * It's used after usage of data shared by different cores. |
| 222 | + * Such data is either statically marked with SHARED_DATA |
| 223 | + * or dynamically allocated with SOF_MEM_FLAG_SHARED flag. |
| 224 | + * Does nothing, since mt8195 doesn't support SMP. |
| 225 | + */ |
| 226 | + |
| 227 | +static inline void *platform_rfree_prepare(void *ptr) |
| 228 | +{ |
| 229 | + return ptr; |
| 230 | +} |
| 231 | + |
| 232 | +#endif |
| 233 | + |
| 234 | +#define host_to_local(addr) (addr) |
| 235 | +#define local_to_host(addr) (addr) |
| 236 | + |
| 237 | +#endif /* __PLATFORM_LIB_MEMORY_H__ */ |
| 238 | + |
| 239 | +#else |
| 240 | + |
| 241 | +#error "This file shouldn't be included from outside of sof/lib/memory.h" |
| 242 | + |
| 243 | +#endif /* __SOF_LIB_MEMORY_H__ */ |
0 commit comments