|
@@ -1,5 +1,5 @@
|
|
|
/*
|
|
|
- * Copyright (c) 2015-2019, ARM Limited and Contributors. All rights reserved.
|
|
|
+ * Copyright (c) 2015-2024, Arm Limited and Contributors. All rights reserved.
|
|
|
*
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
|
*/
|
|
@@ -8,21 +8,15 @@
|
|
|
#include <inttypes.h>
|
|
|
#include <stdint.h>
|
|
|
|
|
|
-#include <libfdt.h>
|
|
|
-
|
|
|
-#include <platform_def.h>
|
|
|
#include <arch_helpers.h>
|
|
|
#include <common/bl_common.h>
|
|
|
+#include <drivers/arm/gicv2.h>
|
|
|
#include <lib/mmio.h>
|
|
|
#include <lib/xlat_tables/xlat_mmu_helpers.h>
|
|
|
#include <lib/xlat_tables/xlat_tables_defs.h>
|
|
|
#include <lib/xlat_tables/xlat_tables_v2.h>
|
|
|
#include <plat/common/platform.h>
|
|
|
-#include <common/fdt_fixup.h>
|
|
|
-#include <common/fdt_wrappers.h>
|
|
|
-#include <libfdt.h>
|
|
|
-
|
|
|
-#include <drivers/arm/gicv2.h>
|
|
|
+#include <platform_def.h>
|
|
|
|
|
|
#include <rpi_shared.h>
|
|
|
|
|
@@ -85,7 +79,7 @@ uintptr_t plat_get_ns_image_entrypoint(void)
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
-static uintptr_t rpi4_get_dtb_address(void)
|
|
|
+uintptr_t rpi4_get_dtb_address(void)
|
|
|
{
|
|
|
#ifdef RPI3_PRELOADED_DTB_BASE
|
|
|
return RPI3_PRELOADED_DTB_BASE;
|
|
@@ -151,7 +145,7 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
|
|
|
* r1 = machine type number, optional in DT-only platforms (~0 if so)
|
|
|
* r2 = Physical address of the device tree blob
|
|
|
*/
|
|
|
- VERBOSE("rpi4: Preparing to boot 32-bit Linux kernel\n");
|
|
|
+ VERBOSE("rpi: Preparing to boot 32-bit Linux kernel\n");
|
|
|
bl33_image_ep_info.args.arg0 = 0U;
|
|
|
bl33_image_ep_info.args.arg1 = ~0U;
|
|
|
bl33_image_ep_info.args.arg2 = rpi4_get_dtb_address();
|
|
@@ -162,7 +156,7 @@ void bl31_early_platform_setup2(u_register_t arg0, u_register_t arg1,
|
|
|
* tree blob (DTB) in x0, while x1-x3 are reserved for future use and
|
|
|
* must be 0.
|
|
|
*/
|
|
|
- VERBOSE("rpi4: Preparing to boot 64-bit Linux kernel\n");
|
|
|
+ VERBOSE("rpi: Preparing to boot 64-bit Linux kernel\n");
|
|
|
bl33_image_ep_info.args.arg0 = rpi4_get_dtb_address();
|
|
|
bl33_image_ep_info.args.arg1 = 0ULL;
|
|
|
bl33_image_ep_info.args.arg2 = 0ULL;
|
|
@@ -203,102 +197,13 @@ void bl31_plat_arch_setup(void)
|
|
|
enable_mmu_el3(0);
|
|
|
}
|
|
|
|
|
|
-/*
|
|
|
- * Remove the FDT /memreserve/ entry that covers the region at the very
|
|
|
- * beginning of memory (if that exists). This is where the secondaries
|
|
|
- * originally spin, but we pull them out there.
|
|
|
- * Having overlapping /reserved-memory and /memreserve/ regions confuses
|
|
|
- * the Linux kernel, so we need to get rid of this one.
|
|
|
- */
|
|
|
-static void remove_spintable_memreserve(void *dtb)
|
|
|
-{
|
|
|
- uint64_t addr, size;
|
|
|
- int regions = fdt_num_mem_rsv(dtb);
|
|
|
- int i;
|
|
|
-
|
|
|
- for (i = 0; i < regions; i++) {
|
|
|
- if (fdt_get_mem_rsv(dtb, i, &addr, &size) != 0) {
|
|
|
- return;
|
|
|
- }
|
|
|
- if (size == 0U) {
|
|
|
- return;
|
|
|
- }
|
|
|
- /* We only look for the region at the beginning of DRAM. */
|
|
|
- if (addr != 0U) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- /*
|
|
|
- * Currently the region in the existing DTs is exactly 4K
|
|
|
- * in size. Should this value ever change, there is probably
|
|
|
- * a reason for that, so inform the user about this.
|
|
|
- */
|
|
|
- if (size == 4096U) {
|
|
|
- fdt_del_mem_rsv(dtb, i);
|
|
|
- return;
|
|
|
- }
|
|
|
- WARN("Keeping unknown /memreserve/ region at 0, size: %" PRId64 "\n",
|
|
|
- size);
|
|
|
- }
|
|
|
-}
|
|
|
-
|
|
|
-static void rpi4_prepare_dtb(void)
|
|
|
-{
|
|
|
- void *dtb = (void *)rpi4_get_dtb_address();
|
|
|
- uint32_t gic_int_prop[3];
|
|
|
- int ret, offs;
|
|
|
-
|
|
|
- /* Return if no device tree is detected */
|
|
|
- if (fdt_check_header(dtb) != 0)
|
|
|
- return;
|
|
|
-
|
|
|
- ret = fdt_open_into(dtb, dtb, 0x100000);
|
|
|
- if (ret < 0) {
|
|
|
- ERROR("Invalid Device Tree at %p: error %d\n", dtb, ret);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (dt_add_psci_node(dtb)) {
|
|
|
- ERROR("Failed to add PSCI Device Tree node\n");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (dt_add_psci_cpu_enable_methods(dtb)) {
|
|
|
- ERROR("Failed to add PSCI cpu enable methods in Device Tree\n");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- /*
|
|
|
- * Remove the original reserved region (used for the spintable), and
|
|
|
- * replace it with a region describing the whole of Trusted Firmware.
|
|
|
- */
|
|
|
- remove_spintable_memreserve(dtb);
|
|
|
- if (fdt_add_reserved_memory(dtb, "atf@0", 0, 0x80000))
|
|
|
- WARN("Failed to add reserved memory nodes to DT.\n");
|
|
|
-
|
|
|
- offs = fdt_node_offset_by_compatible(dtb, 0, "arm,gic-400");
|
|
|
- gic_int_prop[0] = cpu_to_fdt32(1); // PPI
|
|
|
- gic_int_prop[1] = cpu_to_fdt32(9); // PPI #9
|
|
|
- gic_int_prop[2] = cpu_to_fdt32(0x0f04); // all cores, level high
|
|
|
- fdt_setprop(dtb, offs, "interrupts", gic_int_prop, 12);
|
|
|
-
|
|
|
- offs = fdt_path_offset(dtb, "/chosen");
|
|
|
- fdt_setprop_string(dtb, offs, "stdout-path", "serial0");
|
|
|
-
|
|
|
- ret = fdt_pack(dtb);
|
|
|
- if (ret < 0)
|
|
|
- ERROR("Failed to pack Device Tree at %p: error %d\n", dtb, ret);
|
|
|
-
|
|
|
- clean_dcache_range((uintptr_t)dtb, fdt_blob_size(dtb));
|
|
|
- INFO("Changed device tree to advertise PSCI.\n");
|
|
|
-}
|
|
|
-
|
|
|
void bl31_platform_setup(void)
|
|
|
{
|
|
|
- rpi4_prepare_dtb();
|
|
|
-
|
|
|
/* Configure the interrupt controller */
|
|
|
gicv2_driver_init(&rpi4_gic_data);
|
|
|
gicv2_distif_init();
|
|
|
gicv2_pcpu_distif_init();
|
|
|
gicv2_cpuif_enable();
|
|
|
+
|
|
|
+ plat_rpi_bl31_custom_setup();
|
|
|
}
|