Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 1 | /* |
Haojian Zhuang | 1b4b412 | 2018-01-25 16:13:05 +0800 | [diff] [blame] | 2 | * Copyright (c) 2017-2018, ARM Limited and Contributors. All rights reserved. |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
Antonio Nino Diaz | 6f3ccc5 | 2018-07-20 09:17:26 +0100 | [diff] [blame] | 7 | #ifndef PLATFORM_DEF_H |
| 8 | #define PLATFORM_DEF_H |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 9 | |
| 10 | #include <arch.h> |
Antonio Nino Diaz | 6f3ccc5 | 2018-07-20 09:17:26 +0100 | [diff] [blame] | 11 | #include <utils_def.h> |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 12 | #include "../hikey960_def.h" |
| 13 | |
Victor Chong | 2d9a42d | 2017-08-17 15:21:10 +0900 | [diff] [blame] | 14 | /* Special value used to verify platform parameters from BL2 to BL3-1 */ |
| 15 | #define HIKEY960_BL31_PLAT_PARAM_VAL 0x0f1e2d3c4b5a6978ULL |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 16 | |
| 17 | /* |
| 18 | * Generic platform constants |
| 19 | */ |
| 20 | |
| 21 | /* Size of cacheable stacks */ |
Teddy Reed | dd3f0a8 | 2018-09-03 17:38:50 -0400 | [diff] [blame] | 22 | #define PLATFORM_STACK_SIZE 0x1000 |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 23 | |
| 24 | #define FIRMWARE_WELCOME_STR "Booting Trusted Firmware\n" |
| 25 | |
| 26 | #define PLATFORM_CACHE_LINE_SIZE 64 |
| 27 | #define PLATFORM_CLUSTER_COUNT 2 |
| 28 | #define PLATFORM_CORE_COUNT_PER_CLUSTER 4 |
| 29 | #define PLATFORM_CORE_COUNT (PLATFORM_CLUSTER_COUNT * \ |
| 30 | PLATFORM_CORE_COUNT_PER_CLUSTER) |
| 31 | #define PLAT_MAX_PWR_LVL MPIDR_AFFLVL2 |
| 32 | #define PLAT_NUM_PWR_DOMAINS (PLATFORM_CORE_COUNT + \ |
| 33 | PLATFORM_CLUSTER_COUNT + 1) |
| 34 | |
Antonio Nino Diaz | 6f3ccc5 | 2018-07-20 09:17:26 +0100 | [diff] [blame] | 35 | #define PLAT_MAX_RET_STATE U(1) |
| 36 | #define PLAT_MAX_OFF_STATE U(2) |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 37 | |
| 38 | #define MAX_IO_DEVICES 3 |
| 39 | #define MAX_IO_HANDLES 4 |
| 40 | /* UFS RPMB and UFS User Data */ |
| 41 | #define MAX_IO_BLOCK_DEVICES 2 |
| 42 | |
| 43 | |
| 44 | /* |
| 45 | * Platform memory map related constants |
| 46 | */ |
| 47 | |
| 48 | /* |
| 49 | * BL1 specific defines. |
| 50 | */ |
| 51 | #define BL1_RO_BASE (0x1AC00000) |
Teddy Reed | dd3f0a8 | 2018-09-03 17:38:50 -0400 | [diff] [blame] | 52 | #define BL1_RO_LIMIT (BL1_RO_BASE + 0x20000) |
| 53 | #define BL1_RW_BASE (BL1_RO_LIMIT) /* 1AC2_0000 */ |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 54 | #define BL1_RW_SIZE (0x00188000) |
| 55 | #define BL1_RW_LIMIT (0x1B000000) |
| 56 | |
| 57 | /* |
| 58 | * BL2 specific defines. |
| 59 | */ |
Haojian Zhuang | 1b4b412 | 2018-01-25 16:13:05 +0800 | [diff] [blame] | 60 | #define BL2_BASE (0x1AC00000) |
| 61 | #define BL2_LIMIT (BL2_BASE + 0x58000) /* 1AC5_8000 */ |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 62 | |
| 63 | /* |
| 64 | * BL31 specific defines. |
| 65 | */ |
| 66 | #define BL31_BASE (BL2_LIMIT) /* 1AC5_8000 */ |
| 67 | #define BL31_LIMIT (BL31_BASE + 0x40000) /* 1AC9_8000 */ |
| 68 | |
Victor Chong | 9128768 | 2017-05-28 00:14:37 +0900 | [diff] [blame] | 69 | /* |
| 70 | * BL3-2 specific defines. |
| 71 | */ |
| 72 | |
| 73 | /* |
| 74 | * The TSP currently executes from TZC secured area of DRAM. |
| 75 | */ |
| 76 | #define BL32_DRAM_BASE DDR_SEC_BASE |
| 77 | #define BL32_DRAM_LIMIT (DDR_SEC_BASE+DDR_SEC_SIZE) |
| 78 | |
Victor Chong | 7d787f5 | 2017-08-16 13:53:56 +0900 | [diff] [blame] | 79 | #ifdef SPD_opteed |
| 80 | /* Load pageable part of OP-TEE at end of allocated DRAM space for BL32 */ |
| 81 | #define HIKEY960_OPTEE_PAGEABLE_LOAD_BASE (BL32_DRAM_LIMIT - HIKEY960_OPTEE_PAGEABLE_LOAD_SIZE) /* 0x3FC0_0000 */ |
| 82 | #define HIKEY960_OPTEE_PAGEABLE_LOAD_SIZE 0x400000 /* 4MB */ |
| 83 | #endif |
Victor Chong | 7d787f5 | 2017-08-16 13:53:56 +0900 | [diff] [blame] | 84 | |
Victor Chong | 9128768 | 2017-05-28 00:14:37 +0900 | [diff] [blame] | 85 | #if (HIKEY960_TSP_RAM_LOCATION_ID == HIKEY960_DRAM_ID) |
| 86 | #define TSP_SEC_MEM_BASE BL32_DRAM_BASE |
| 87 | #define TSP_SEC_MEM_SIZE (BL32_DRAM_LIMIT - BL32_DRAM_BASE) |
| 88 | #define BL32_BASE BL32_DRAM_BASE |
| 89 | #define BL32_LIMIT BL32_DRAM_LIMIT |
| 90 | #elif (HIKEY960_TSP_RAM_LOCATION_ID == HIKEY960_SRAM_ID) |
| 91 | #error "SRAM storage of TSP payload is currently unsupported" |
| 92 | #else |
| 93 | #error "Currently unsupported HIKEY960_TSP_LOCATION_ID value" |
| 94 | #endif |
| 95 | |
Victor Chong | 398d5d3 | 2017-09-14 01:27:19 +0900 | [diff] [blame] | 96 | /* BL32 is mandatory in AArch32 */ |
| 97 | #ifndef AARCH32 |
| 98 | #ifdef SPD_none |
| 99 | #undef BL32_BASE |
| 100 | #endif /* SPD_none */ |
| 101 | #endif |
| 102 | |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 103 | #define NS_BL1U_BASE (BL31_LIMIT) /* 1AC9_8000 */ |
| 104 | #define NS_BL1U_SIZE (0x00100000) |
| 105 | #define NS_BL1U_LIMIT (NS_BL1U_BASE + NS_BL1U_SIZE) |
| 106 | |
Teddy Reed | dd3f0a8 | 2018-09-03 17:38:50 -0400 | [diff] [blame] | 107 | #define HIKEY960_NS_IMAGE_OFFSET (0x1AC28000) /* offset in l-loader */ |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 108 | #define HIKEY960_NS_TMP_OFFSET (0x1AE00000) |
| 109 | |
Victor Chong | 2d9a42d | 2017-08-17 15:21:10 +0900 | [diff] [blame] | 110 | #define SCP_BL2_BASE (0x89C80000) |
| 111 | #define SCP_BL2_SIZE (0x00040000) |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 112 | |
| 113 | /* |
| 114 | * Platform specific page table and MMU setup constants |
| 115 | */ |
Antonio Nino Diaz | 582c2d7 | 2018-09-24 17:23:47 +0100 | [diff] [blame] | 116 | #define PLAT_VIRT_ADDR_SPACE_SIZE (1ULL << 32) |
| 117 | #define PLAT_PHY_ADDR_SPACE_SIZE (1ULL << 32) |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 118 | |
Roberto Vargas | 8247796 | 2017-10-23 08:22:17 +0100 | [diff] [blame] | 119 | #if defined(IMAGE_BL1) || defined(IMAGE_BL31) || defined(IMAGE_BL32) |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 120 | #define MAX_XLAT_TABLES 3 |
| 121 | #endif |
| 122 | |
Roberto Vargas | 8247796 | 2017-10-23 08:22:17 +0100 | [diff] [blame] | 123 | #ifdef IMAGE_BL2 |
Victor Chong | 7d787f5 | 2017-08-16 13:53:56 +0900 | [diff] [blame] | 124 | #ifdef SPD_opteed |
| 125 | #define MAX_XLAT_TABLES 4 |
| 126 | #else |
| 127 | #define MAX_XLAT_TABLES 3 |
| 128 | #endif |
Victor Chong | 7d787f5 | 2017-08-16 13:53:56 +0900 | [diff] [blame] | 129 | #endif |
| 130 | |
Haojian Zhuang | 602362d | 2017-06-01 12:15:14 +0800 | [diff] [blame] | 131 | #define MAX_MMAP_REGIONS 16 |
| 132 | |
| 133 | /* |
| 134 | * Declarations and constants to access the mailboxes safely. Each mailbox is |
| 135 | * aligned on the biggest cache line size in the platform. This is known only |
| 136 | * to the platform as it might have a combination of integrated and external |
| 137 | * caches. Such alignment ensures that two maiboxes do not sit on the same cache |
| 138 | * line at any cache level. They could belong to different cpus/clusters & |
| 139 | * get written while being protected by different locks causing corruption of |
| 140 | * a valid mailbox address. |
| 141 | */ |
| 142 | #define CACHE_WRITEBACK_SHIFT 6 |
| 143 | #define CACHE_WRITEBACK_GRANULE (1 << CACHE_WRITEBACK_SHIFT) |
| 144 | |
Antonio Nino Diaz | 6f3ccc5 | 2018-07-20 09:17:26 +0100 | [diff] [blame] | 145 | #endif /* PLATFORM_DEF_H */ |