Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2015-2016, ARM Limited and Contributors. All rights reserved. |
| 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #ifndef __PLATFORM_DEF_H__ |
| 8 | #define __PLATFORM_DEF_H__ |
| 9 | |
| 10 | #include <arch.h> |
| 11 | #include <common_def.h> |
| 12 | #include <tbbr_img_def.h> |
| 13 | |
| 14 | /* Special value used to verify platform parameters from BL2 to BL3-1 */ |
| 15 | #define QEMU_BL31_PLAT_PARAM_VAL 0x0f1e2d3c4b5a6978ULL |
| 16 | |
| 17 | #define PLATFORM_STACK_SIZE 0x1000 |
| 18 | |
| 19 | #define PLATFORM_MAX_CPUS_PER_CLUSTER 4 |
| 20 | #define PLATFORM_CLUSTER_COUNT 2 |
| 21 | #define PLATFORM_CLUSTER0_CORE_COUNT PLATFORM_MAX_CPUS_PER_CLUSTER |
| 22 | #define PLATFORM_CLUSTER1_CORE_COUNT PLATFORM_MAX_CPUS_PER_CLUSTER |
| 23 | #define PLATFORM_CORE_COUNT (PLATFORM_CLUSTER0_CORE_COUNT + \ |
| 24 | PLATFORM_CLUSTER1_CORE_COUNT) |
| 25 | |
| 26 | #define QEMU_PRIMARY_CPU 0 |
| 27 | |
| 28 | #define PLAT_NUM_PWR_DOMAINS (PLATFORM_CLUSTER_COUNT + \ |
| 29 | PLATFORM_CORE_COUNT) |
| 30 | #define PLAT_MAX_PWR_LVL MPIDR_AFFLVL1 |
| 31 | |
| 32 | #define PLAT_MAX_RET_STATE 1 |
| 33 | #define PLAT_MAX_OFF_STATE 2 |
| 34 | |
| 35 | /* Local power state for power domains in Run state. */ |
| 36 | #define PLAT_LOCAL_STATE_RUN 0 |
| 37 | /* Local power state for retention. Valid only for CPU power domains */ |
| 38 | #define PLAT_LOCAL_STATE_RET 1 |
| 39 | /* |
| 40 | * Local power state for OFF/power-down. Valid for CPU and cluster power |
| 41 | * domains. |
| 42 | */ |
| 43 | #define PLAT_LOCAL_STATE_OFF 2 |
| 44 | |
| 45 | /* |
| 46 | * Macros used to parse state information from State-ID if it is using the |
| 47 | * recommended encoding for State-ID. |
| 48 | */ |
| 49 | #define PLAT_LOCAL_PSTATE_WIDTH 4 |
| 50 | #define PLAT_LOCAL_PSTATE_MASK ((1 << PLAT_LOCAL_PSTATE_WIDTH) - 1) |
| 51 | |
| 52 | /* |
| 53 | * Some data must be aligned on the biggest cache line size in the platform. |
| 54 | * This is known only to the platform as it might have a combination of |
| 55 | * integrated and external caches. |
| 56 | */ |
| 57 | #define CACHE_WRITEBACK_SHIFT 6 |
| 58 | #define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT) |
| 59 | |
| 60 | /* |
| 61 | * Partition memory into secure ROM, non-secure DRAM, secure "SRAM", |
| 62 | * and secure DRAM. |
| 63 | */ |
| 64 | #define SEC_ROM_BASE 0x00000000 |
| 65 | #define SEC_ROM_SIZE 0x00020000 |
| 66 | |
| 67 | #define NS_DRAM0_BASE 0x40000000 |
| 68 | #define NS_DRAM0_SIZE 0x3de00000 |
| 69 | |
| 70 | #define SEC_SRAM_BASE 0x0e000000 |
| 71 | #define SEC_SRAM_SIZE 0x00040000 |
| 72 | |
| 73 | #define SEC_DRAM_BASE 0x0e100000 |
| 74 | #define SEC_DRAM_SIZE 0x00f00000 |
| 75 | |
| 76 | /* |
| 77 | * ARM-TF lives in SRAM, partition it here |
| 78 | */ |
| 79 | |
| 80 | #define SHARED_RAM_BASE SEC_SRAM_BASE |
| 81 | #define SHARED_RAM_SIZE 0x00001000 |
| 82 | |
| 83 | #define PLAT_QEMU_TRUSTED_MAILBOX_BASE SHARED_RAM_BASE |
| 84 | #define PLAT_QEMU_TRUSTED_MAILBOX_SIZE (8 + PLAT_QEMU_HOLD_SIZE) |
| 85 | #define PLAT_QEMU_HOLD_BASE (PLAT_QEMU_TRUSTED_MAILBOX_BASE + 8) |
| 86 | #define PLAT_QEMU_HOLD_SIZE (PLATFORM_CORE_COUNT * \ |
| 87 | PLAT_QEMU_HOLD_ENTRY_SIZE) |
| 88 | #define PLAT_QEMU_HOLD_ENTRY_SIZE 8 |
| 89 | #define PLAT_QEMU_HOLD_STATE_WAIT 0 |
| 90 | #define PLAT_QEMU_HOLD_STATE_GO 1 |
| 91 | |
| 92 | #define BL_RAM_BASE (SHARED_RAM_BASE + SHARED_RAM_SIZE) |
| 93 | #define BL_RAM_SIZE (SEC_SRAM_SIZE - SHARED_RAM_SIZE) |
| 94 | |
| 95 | /* |
| 96 | * BL1 specific defines. |
| 97 | * |
| 98 | * BL1 RW data is relocated from ROM to RAM at runtime so we need 2 sets of |
| 99 | * addresses. |
| 100 | * Put BL1 RW at the top of the Secure SRAM. BL1_RW_BASE is calculated using |
| 101 | * the current BL1 RW debug size plus a little space for growth. |
| 102 | */ |
| 103 | #define BL1_RO_BASE SEC_ROM_BASE |
| 104 | #define BL1_RO_LIMIT (SEC_ROM_BASE + SEC_ROM_SIZE) |
| 105 | #define BL1_RW_BASE (BL1_RW_LIMIT - 0x12000) |
| 106 | #define BL1_RW_LIMIT (BL_RAM_BASE + BL_RAM_SIZE) |
| 107 | |
| 108 | /* |
| 109 | * BL2 specific defines. |
| 110 | * |
| 111 | * Put BL2 just below BL3-1. BL2_BASE is calculated using the current BL2 debug |
| 112 | * size plus a little space for growth. |
| 113 | */ |
| 114 | #define BL2_BASE (BL31_BASE - 0x1D000) |
| 115 | #define BL2_LIMIT BL31_BASE |
| 116 | |
| 117 | /* |
| 118 | * BL3-1 specific defines. |
| 119 | * |
| 120 | * Put BL3-1 at the top of the Trusted SRAM. BL31_BASE is calculated using the |
| 121 | * current BL3-1 debug size plus a little space for growth. |
| 122 | */ |
| 123 | #define BL31_BASE (BL31_LIMIT - 0x20000) |
| 124 | #define BL31_LIMIT (BL_RAM_BASE + BL_RAM_SIZE) |
| 125 | #define BL31_PROGBITS_LIMIT BL1_RW_BASE |
| 126 | |
| 127 | |
| 128 | /* |
| 129 | * BL3-2 specific defines. |
| 130 | * |
| 131 | * BL3-2 can execute from Secure SRAM, or Secure DRAM. |
| 132 | */ |
| 133 | #define BL32_SRAM_BASE BL_RAM_BASE |
| 134 | #define BL32_SRAM_LIMIT BL31_BASE |
| 135 | #define BL32_DRAM_BASE SEC_DRAM_BASE |
| 136 | #define BL32_DRAM_LIMIT (SEC_DRAM_BASE + SEC_DRAM_SIZE) |
| 137 | |
| 138 | #define SEC_SRAM_ID 0 |
| 139 | #define SEC_DRAM_ID 1 |
| 140 | |
| 141 | #if BL32_RAM_LOCATION_ID == SEC_SRAM_ID |
| 142 | # define BL32_MEM_BASE BL_RAM_BASE |
| 143 | # define BL32_MEM_SIZE BL_RAM_SIZE |
| 144 | # define BL32_BASE BL32_SRAM_BASE |
| 145 | # define BL32_LIMIT BL32_SRAM_LIMIT |
| 146 | #elif BL32_RAM_LOCATION_ID == SEC_DRAM_ID |
| 147 | # define BL32_MEM_BASE SEC_DRAM_BASE |
| 148 | # define BL32_MEM_SIZE SEC_DRAM_SIZE |
| 149 | # define BL32_BASE BL32_DRAM_BASE |
| 150 | # define BL32_LIMIT BL32_DRAM_LIMIT |
| 151 | #else |
| 152 | # error "Unsupported BL32_RAM_LOCATION_ID value" |
| 153 | #endif |
Jens Wiklander | 52c798e | 2015-12-07 14:37:10 +0100 | [diff] [blame] | 154 | |
| 155 | #define NS_IMAGE_OFFSET 0x60000000 |
| 156 | |
| 157 | #define ADDR_SPACE_SIZE (1ull << 32) |
| 158 | #define MAX_MMAP_REGIONS 8 |
| 159 | #define MAX_XLAT_TABLES 6 |
| 160 | #define MAX_IO_DEVICES 3 |
| 161 | #define MAX_IO_HANDLES 4 |
| 162 | |
| 163 | /* |
| 164 | * PL011 related constants |
| 165 | */ |
| 166 | #define UART0_BASE 0x09000000 |
| 167 | #define UART1_BASE 0x09040000 |
| 168 | #define UART0_CLK_IN_HZ 1 |
| 169 | #define UART1_CLK_IN_HZ 1 |
| 170 | |
| 171 | #define PLAT_QEMU_BOOT_UART_BASE UART0_BASE |
| 172 | #define PLAT_QEMU_BOOT_UART_CLK_IN_HZ UART0_CLK_IN_HZ |
| 173 | |
| 174 | #define PLAT_QEMU_CRASH_UART_BASE UART1_BASE |
| 175 | #define PLAT_QEMU_CRASH_UART_CLK_IN_HZ UART1_CLK_IN_HZ |
| 176 | |
| 177 | #define PLAT_QEMU_CONSOLE_BAUDRATE 115200 |
| 178 | |
| 179 | #define QEMU_FLASH0_BASE 0x04000000 |
| 180 | #define QEMU_FLASH0_SIZE 0x04000000 |
| 181 | |
| 182 | #define PLAT_QEMU_FIP_BASE QEMU_FLASH0_BASE |
| 183 | #define PLAT_QEMU_FIP_MAX_SIZE QEMU_FLASH0_SIZE |
| 184 | |
| 185 | #define DEVICE0_BASE 0x08000000 |
| 186 | #define DEVICE0_SIZE 0x00021000 |
| 187 | #define DEVICE1_BASE 0x09000000 |
| 188 | #define DEVICE1_SIZE 0x00011000 |
| 189 | |
| 190 | /* |
| 191 | * GIC related constants |
| 192 | */ |
| 193 | |
| 194 | #define GICD_BASE 0x8000000 |
| 195 | #define GICC_BASE 0x8010000 |
| 196 | #define GICR_BASE 0 |
| 197 | |
| 198 | |
| 199 | #define QEMU_IRQ_SEC_SGI_0 8 |
| 200 | #define QEMU_IRQ_SEC_SGI_1 9 |
| 201 | #define QEMU_IRQ_SEC_SGI_2 10 |
| 202 | #define QEMU_IRQ_SEC_SGI_3 11 |
| 203 | #define QEMU_IRQ_SEC_SGI_4 12 |
| 204 | #define QEMU_IRQ_SEC_SGI_5 13 |
| 205 | #define QEMU_IRQ_SEC_SGI_6 14 |
| 206 | #define QEMU_IRQ_SEC_SGI_7 15 |
| 207 | |
| 208 | /* |
| 209 | * DT related constants |
| 210 | */ |
| 211 | #define PLAT_QEMU_DT_BASE NS_DRAM0_BASE |
| 212 | #define PLAT_QEMU_DT_MAX_SIZE 0x10000 |
| 213 | |
| 214 | /* |
| 215 | * System counter |
| 216 | */ |
| 217 | #define SYS_COUNTER_FREQ_IN_TICKS ((1000 * 1000 * 1000) / 16) |
| 218 | |
| 219 | #endif /* __PLATFORM_DEF_H__ */ |