From 90a129c14c25d1f1112f3aac180daf9ef2fa305f Mon Sep 17 00:00:00 2001
From: =?utf8?q?Duje=20Mihanovi=C4=87?= <duje.mihanovic@skole.hr>
Date: Tue, 24 Dec 2024 20:01:25 +0100
Subject: [PATCH] increase baudrate to max, don't use embedded DT

---
 arch/arm/mach-mmp/Makefile       |  2 +-
 arch/arm/mach-mmp/board.c        | 34 ++++++++++++++++++++++++++++++++
 configs/coreprimevelte_defconfig |  3 ++-
 3 files changed, 37 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/mach-mmp/board.c

diff --git a/arch/arm/mach-mmp/Makefile b/arch/arm/mach-mmp/Makefile
index 294e6c518f..99beaed05c 100644
--- a/arch/arm/mach-mmp/Makefile
+++ b/arch/arm/mach-mmp/Makefile
@@ -1 +1 @@
-obj-y += mmu.o
+obj-y += board.o mmu.o
diff --git a/arch/arm/mach-mmp/board.c b/arch/arm/mach-mmp/board.c
new file mode 100644
index 0000000000..21059444c4
--- /dev/null
+++ b/arch/arm/mach-mmp/board.c
@@ -0,0 +1,34 @@
+#include <init.h>
+#include <fdt_support.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* Stolen from arch/arm/mach-snapdragon/board.c */
+void *board_fdt_blob_setup(int *err)
+{
+	struct fdt_header *fdt;
+	bool internal_valid, external_valid;
+
+	*err = 0;
+	fdt = (struct fdt_header *)get_prev_bl_fdt_addr();
+	external_valid = fdt && !fdt_check_header(fdt);
+	internal_valid = !fdt_check_header(gd->fdt_blob);
+
+	/*
+	 * There is no point returning an error here, U-Boot can't do anything useful in this situation.
+	 * Bail out while we can still print a useful error message.
+	 */
+	if (!internal_valid && !external_valid)
+		panic("Internal FDT is invalid and no external FDT was provided! (fdt=%#llx)\n",
+		      (phys_addr_t)fdt);
+
+	if (internal_valid) {
+		debug("Using built in FDT\n");
+	} else {
+		debug("Using external FDT\n");
+		/* So we can use it before returning */
+		gd->fdt_blob = fdt;
+	}
+
+	return (void *)gd->fdt_blob;
+}
diff --git a/configs/coreprimevelte_defconfig b/configs/coreprimevelte_defconfig
index 8ca5e2b1cd..7c2bdd9a57 100644
--- a/configs/coreprimevelte_defconfig
+++ b/configs/coreprimevelte_defconfig
@@ -20,11 +20,12 @@ CONFIG_LOGF_LINE=y
 CONFIG_LOGF_FUNC=y
 # CONFIG_DISPLAY_CPUINFO is not set
 CONFIG_OF_CONTROL=y
-CONFIG_OF_EMBED=y
+CONFIG_OF_BOARD=y
 CONFIG_NO_NET=y
 CONFIG_CLK=y
 CONFIG_CPU=y
 CONFIG_CPU_ARMV8=y
+CONFIG_BAUDRATE=921600
 CONFIG_SYS_NS16550=y
 CONFIG_SYS_NS16550_MEM32=y
 CONFIG_MBEDTLS_LIB=y
-- 
2.39.5