From 0fafab9aa1109c21a074667098b5018a6c4b5315 Mon Sep 17 00:00:00 2001
From: Raptor Engineering Development Team <support@raptorengineering.com>
Date: Wed, 14 Apr 2021 13:36:15 -0500
Subject: [PATCH] Add Kestrel SoC reboot support

---
 soc/powerpc/CMakeLists.txt               | 10 +++----
 soc/powerpc/litex-kestrel/CMakeLists.txt |  9 ++++++
 soc/powerpc/litex-kestrel/soc.c          | 36 ++++++++++++++++++++++++
 3 files changed, 50 insertions(+), 5 deletions(-)
 create mode 100644 soc/powerpc/litex-kestrel/CMakeLists.txt

diff --git a/soc/powerpc/CMakeLists.txt b/soc/powerpc/CMakeLists.txt
index cc6e9318b6c..405dc077a1b 100644
--- a/soc/powerpc/CMakeLists.txt
+++ b/soc/powerpc/CMakeLists.txt
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: Apache-2.0
 
-#if(SOC_FAMILY)
-#add_subdirectory(${SOC_FAMILY})
-#else()
-#add_subdirectory(${SOC_NAME})
-#endif()
+if(SOC_FAMILY)
+add_subdirectory(${SOC_FAMILY})
+else()
+add_subdirectory(${SOC_NAME})
+endif()
diff --git a/soc/powerpc/litex-kestrel/CMakeLists.txt b/soc/powerpc/litex-kestrel/CMakeLists.txt
new file mode 100644
index 00000000000..e23bdf2629e
--- /dev/null
+++ b/soc/powerpc/litex-kestrel/CMakeLists.txt
@@ -0,0 +1,9 @@
+#
+# Copyright (c) 2021 Raptor Engineering, LLC <sales@raptorengineering.com>
+#
+# SPDX-License-Identifier: Apache-2.0
+#
+
+zephyr_sources(
+    soc.c
+)
diff --git a/soc/powerpc/litex-kestrel/soc.c b/soc/powerpc/litex-kestrel/soc.c
index e69de29bb2d..b04b7449fbf 100644
--- a/soc/powerpc/litex-kestrel/soc.c
+++ b/soc/powerpc/litex-kestrel/soc.c
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2021 Raptor Engineering, LLC <sales@raptorengineering.com>
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include <kernel.h>
+#include <init.h>
+#include <device.h>
+#include <logging/log.h>
+
+#define LOG_LEVEL CONFIG_SOC_LOG_LEVEL
+LOG_MODULE_REGISTER(soc);
+
+#ifdef CONFIG_OPENPOWER_LITEX_IRQ
+extern void microwatt_irq_set_base(void *ivt_base);
+#endif
+
+// SoC base controller information
+#define SOC_CTL_BASE		DT_REG_ADDR(DT_INST(0, litex_soc_controller))
+
+// Overrides the weak PowerPC implementation
+// Reboot SoC
+void sys_arch_reboot(int type)
+{
+	// Shut down interrupts
+	irq_lock();
+
+	// Reset IRQ vector table base address
+#ifdef CONFIG_OPENPOWER_LITEX_IRQ
+	microwatt_irq_set_base(0x0);
+#endif
+
+	// Hard reboot
+	*((uint8_t*)(SOC_CTL_BASE)) = 1;
+}
-- 
GitLab