blob: 2cd01e417be5d37035df120aa67175f22a2f80cd [file] [log] [blame]
Dan Handley9df48042015-03-19 18:58:55 +00001/*
Tamas Banb87db072023-05-08 13:48:51 +02002 * Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved.
Dan Handley9df48042015-03-19 18:58:55 +00003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Dan Handley9df48042015-03-19 18:58:55 +00005 */
Antonio Nino Diaza320ecd2019-01-15 14:19:50 +00006
Tamas Banb87db072023-05-08 13:48:51 +02007#include <drivers/arm/css/sds.h>
Manish V Badarkhe01e9dd22020-08-04 17:13:14 +01008#include <lib/smccc.h>
Tamas Banb87db072023-05-08 13:48:51 +02009#include <lib/utils_def.h>
Manish V Badarkhe01e9dd22020-08-04 17:13:14 +010010#include <services/arm_arch_svc.h>
11
Antonio Nino Diazbd7b7402019-01-25 14:30:04 +000012#include <plat/arm/common/plat_arm.h>
Tamas Banb87db072023-05-08 13:48:51 +020013#include <platform_def.h>
Dan Handley9df48042015-03-19 18:58:55 +000014
15/*
Sandrine Bailleux4a1267a2016-05-18 16:11:47 +010016 * Table of memory regions for different BL stages to map using the MMU.
Roberto Vargas344ff022018-10-19 16:44:18 +010017 * This doesn't include Trusted SRAM as setup_page_tables() already takes care
18 * of mapping it.
Dan Handley9df48042015-03-19 18:58:55 +000019 */
Masahiro Yamada441bfdd2016-12-25 23:36:24 +090020#ifdef IMAGE_BL1
Dan Handley9df48042015-03-19 18:58:55 +000021const mmap_region_t plat_arm_mmap[] = {
22 ARM_MAP_SHARED_RAM,
Soby Mathew94273572018-03-07 11:32:04 +000023 V2M_MAP_FLASH0_RW,
Dan Handley9df48042015-03-19 18:58:55 +000024 V2M_MAP_IOFPGA,
25 CSS_MAP_DEVICE,
26 SOC_CSS_MAP_DEVICE,
Yatharth Kochar736a3bf2015-10-11 14:14:55 +010027#if TRUSTED_BOARD_BOOT
Sandrine Bailleuxd9160a52017-05-26 15:48:10 +010028 /* Map DRAM to authenticate NS_BL2U image. */
Yatharth Kochar736a3bf2015-10-11 14:14:55 +010029 ARM_MAP_NS_DRAM1,
30#endif
Dan Handley9df48042015-03-19 18:58:55 +000031 {0}
32};
33#endif
Masahiro Yamada441bfdd2016-12-25 23:36:24 +090034#ifdef IMAGE_BL2
Dan Handley9df48042015-03-19 18:58:55 +000035const mmap_region_t plat_arm_mmap[] = {
36 ARM_MAP_SHARED_RAM,
Soby Mathew94273572018-03-07 11:32:04 +000037 V2M_MAP_FLASH0_RW,
Roberto Vargasa1c16b62017-08-03 09:16:43 +010038#ifdef PLAT_ARM_MEM_PROT_ADDR
39 ARM_V2M_MAP_MEM_PROTECT,
40#endif
Dan Handley9df48042015-03-19 18:58:55 +000041 V2M_MAP_IOFPGA,
42 CSS_MAP_DEVICE,
43 SOC_CSS_MAP_DEVICE,
44 ARM_MAP_NS_DRAM1,
Julius Werner8e0ef0f2019-07-09 14:02:43 -070045#ifdef __aarch64__
Roberto Vargasf8fda102017-08-08 11:27:20 +010046 ARM_MAP_DRAM2,
47#endif
Sandrine Bailleuxb260c3a2017-08-30 10:59:22 +010048#ifdef SPD_tspd
Dan Handley9df48042015-03-19 18:58:55 +000049 ARM_MAP_TSP_SEC_MEM,
Sandrine Bailleuxb260c3a2017-08-30 10:59:22 +010050#endif
Summer Qin9db8f2e2017-04-24 16:49:28 +010051#ifdef SPD_opteed
Soby Mathew874fc9e2017-09-01 13:43:50 +010052 ARM_MAP_OPTEE_CORE_MEM,
Summer Qin9db8f2e2017-04-24 16:49:28 +010053 ARM_OPTEE_PAGEABLE_LOAD_MEM,
54#endif
Arvind Ram Prakash11b9b492022-11-22 14:41:00 -060055#if TRUSTED_BOARD_BOOT && !RESET_TO_BL2
Louis Mayencourt3e7c38a2019-07-31 15:03:44 +010056 ARM_MAP_BL1_RW,
57#endif
Rob Hughes9a2177a2023-01-17 16:10:26 +000058#ifdef JUNO_ETHOSN_TZMP1
59 JUNO_ETHOSN_PROT_FW_RW,
60#endif
Dan Handley9df48042015-03-19 18:58:55 +000061 {0}
62};
63#endif
Masahiro Yamada441bfdd2016-12-25 23:36:24 +090064#ifdef IMAGE_BL2U
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010065const mmap_region_t plat_arm_mmap[] = {
66 ARM_MAP_SHARED_RAM,
67 CSS_MAP_DEVICE,
Daniel Boulby45a2c9e2018-07-06 16:54:44 +010068 CSS_MAP_SCP_BL2U,
69 V2M_MAP_IOFPGA,
Yatharth Kochar3a11eda2015-10-14 15:28:11 +010070 SOC_CSS_MAP_DEVICE,
71 {0}
72};
73#endif
Masahiro Yamada441bfdd2016-12-25 23:36:24 +090074#ifdef IMAGE_BL31
Dan Handley9df48042015-03-19 18:58:55 +000075const mmap_region_t plat_arm_mmap[] = {
76 ARM_MAP_SHARED_RAM,
77 V2M_MAP_IOFPGA,
78 CSS_MAP_DEVICE,
Roberto Vargasa1c16b62017-08-03 09:16:43 +010079#ifdef PLAT_ARM_MEM_PROT_ADDR
80 ARM_V2M_MAP_MEM_PROTECT,
81#endif
Dan Handley9df48042015-03-19 18:58:55 +000082 SOC_CSS_MAP_DEVICE,
Mikael Olsson0232da22021-02-12 17:30:16 +010083 ARM_DTB_DRAM_NS,
Mikael Olssona7df0d62023-01-13 09:56:41 +010084#ifdef JUNO_ETHOSN_TZMP1
85 JUNO_ETHOSN_PROT_FW_RO,
86#endif
Dan Handley9df48042015-03-19 18:58:55 +000087 {0}
88};
89#endif
Masahiro Yamada441bfdd2016-12-25 23:36:24 +090090#ifdef IMAGE_BL32
Dan Handley9df48042015-03-19 18:58:55 +000091const mmap_region_t plat_arm_mmap[] = {
Julius Werner8e0ef0f2019-07-09 14:02:43 -070092#ifndef __aarch64__
Yatharth Kochar2694cba2016-11-14 12:00:41 +000093 ARM_MAP_SHARED_RAM,
Roberto Vargas550eb082018-01-05 16:00:05 +000094#ifdef PLAT_ARM_MEM_PROT_ADDR
95 ARM_V2M_MAP_MEM_PROTECT,
96#endif
Yatharth Kochar2694cba2016-11-14 12:00:41 +000097#endif
Dan Handley9df48042015-03-19 18:58:55 +000098 V2M_MAP_IOFPGA,
99 CSS_MAP_DEVICE,
100 SOC_CSS_MAP_DEVICE,
101 {0}
102};
103#endif
104
105ARM_CASSERT_MMAP
Manish V Badarkhe01e9dd22020-08-04 17:13:14 +0100106
107/*****************************************************************************
108 * plat_is_smccc_feature_available() - This function checks whether SMCCC
109 * feature is availabile for platform.
110 * @fid: SMCCC function id
111 *
112 * Return SMC_ARCH_CALL_SUCCESS if SMCCC feature is available and
113 * SMC_ARCH_CALL_NOT_SUPPORTED otherwise.
114 *****************************************************************************/
115int32_t plat_is_smccc_feature_available(u_register_t fid)
116{
117 switch (fid) {
118 case SMCCC_ARCH_SOC_ID:
119 return SMC_ARCH_CALL_SUCCESS;
120 default:
121 return SMC_ARCH_CALL_NOT_SUPPORTED;
122 }
123}
124
125/* Get SOC version */
126int32_t plat_get_soc_version(void)
127{
128 return (int32_t)
Yann Gautieree050772021-05-20 14:57:34 +0200129 (SOC_ID_SET_JEP_106(ARM_SOC_CONTINUATION_CODE,
130 ARM_SOC_IDENTIFICATION_CODE) |
131 (JUNO_SOC_ID & SOC_ID_IMPL_DEF_MASK));
Manish V Badarkhe01e9dd22020-08-04 17:13:14 +0100132}
133
134/* Get SOC revision */
135int32_t plat_get_soc_revision(void)
136{
137 unsigned int sys_id;
138
139 sys_id = mmio_read_32(V2M_SYSREGS_BASE + V2M_SYS_ID);
Yann Gautieree050772021-05-20 14:57:34 +0200140 return (int32_t)(((sys_id >> V2M_SYS_ID_REV_SHIFT) &
141 V2M_SYS_ID_REV_MASK) & SOC_ID_REV_MASK);
Manish V Badarkhe01e9dd22020-08-04 17:13:14 +0100142}
Tamas Banb87db072023-05-08 13:48:51 +0200143
144#if CSS_USE_SCMI_SDS_DRIVER
145static sds_region_desc_t juno_sds_regions[] = {
146 { .base = PLAT_ARM_SDS_MEM_BASE },
147};
148
149sds_region_desc_t *plat_sds_get_regions(unsigned int *region_count)
150{
151 *region_count = ARRAY_SIZE(juno_sds_regions);
152
153 return juno_sds_regions;
154}
155#endif /* CSS_USE_SCMI_SDS_DRIVER */