diff mbox series

[05/10] xilinx: Add support for generic board detection

Message ID 689ef0d4376fb63126820935365b9a674b2430ed.1629704273.git.michal.simek@xilinx.com
State Accepted
Commit 88232532728c91d69a1f5efb219f6cd7fc030461
Delegated to: Michal Simek
Headers show
Series xilinx: Add support for DTB reselection | expand

Commit Message

Michal Simek Aug. 23, 2021, 7:37 a.m. UTC
Add support for changing DT at run time. It is done via board_detection()
which returns platform_id and platform_version which can be used via
board_name_decode() to compose board_local_name string which corresponds
with DT which is should be used.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2: None

 board/xilinx/common/board.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)
diff mbox series

Patch

diff --git a/board/xilinx/common/board.c b/board/xilinx/common/board.c
index 2aecb14d8e27..92874272893a 100644
--- a/board/xilinx/common/board.c
+++ b/board/xilinx/common/board.c
@@ -463,3 +463,34 @@  int print_cpuinfo(void)
 	return 0;
 }
 #endif
+
+#if CONFIG_IS_ENABLED(DTB_RESELECT)
+char * __maybe_unused __weak board_name_decode(void)
+{
+	return NULL;
+}
+
+bool __maybe_unused __weak board_detection(void)
+{
+	return false;
+}
+
+int embedded_dtb_select(void)
+{
+	if (board_detection()) {
+		char *board_local_name;
+
+		board_local_name = board_name_decode();
+		if (board_local_name) {
+			board_name = board_local_name;
+			debug("Detected name: %s\n", board_name);
+
+			/* Time to change DTB on fly */
+			/* Both ways should work here */
+			/* fdtdec_resetup(&rescan); */
+			fdtdec_setup();
+		}
+	}
+	return 0;
+}
+#endif