]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
board: sl28: add basic PSCI implementation
authorMichael Walle <michael@walle.cc>
Mon, 25 Apr 2022 03:55:08 +0000 (09:25 +0530)
committerPriyanka Jain <priyanka.jain@nxp.com>
Tue, 26 Apr 2022 11:43:57 +0000 (17:13 +0530)
For now, this only provides reset and poweroff functions.

Signed-off-by: Michael Walle <michael@walle.cc>
[Rebased]
Signed-off-by: Priyanka Jain <priyanka.jain@nxp.com>
board/kontron/sl28/Makefile
board/kontron/sl28/psci.c [new file with mode: 0644]
configs/kontron_sl28_defconfig

index 5d220f07447e4c3b516664ff0e5e512fcebff2c8..084c11da376c179fe635d80305669d5e2892f8f2 100644 (file)
@@ -6,6 +6,8 @@ endif
 
 obj-y += common.o ddr.o
 
+obj-$(CONFIG_ARMV8_PSCI) += psci.o
+
 ifdef CONFIG_SPL_BUILD
 obj-y += spl.o
 obj-$(CONFIG_SPL_ATF) += spl_atf.o
diff --git a/board/kontron/sl28/psci.c b/board/kontron/sl28/psci.c
new file mode 100644 (file)
index 0000000..19f0ef3
--- /dev/null
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+#include <asm/secure.h>
+#include <asm/psci.h>
+#include <asm/types.h>
+#include <asm/io.h>
+#include <asm/system.h>
+
+#define GPIO2_GPDIR    0x2310000
+#define GPIO2_GPDAT    0x2310008
+#define RSTCR          0x1e60000
+#define RESET_REQ      BIT(1)
+
+u32 __secure psci_version(void)
+{
+       return ARM_PSCI_VER_0_2;
+}
+
+void __secure psci_system_reset(void)
+{
+       writel(RESET_REQ, RSTCR);
+
+       while (1)
+               wfi();
+}
+
+void __secure psci_system_off(void)
+{
+       int i;
+
+       writel(0x02000000, GPIO2_GPDIR);
+       writel(0, GPIO2_GPDAT);
+
+       /* make sure the management controller has sampled the input */
+       for (i = 0; i < (1 << 11); i++)
+               asm("nop");
+
+       writel(RESET_REQ, RSTCR);
+
+       while (1)
+               wfi();
+}
index 7a00e48ebccc18cc61943d58ac2a921f54856869..dc8c28f8cca89bd3b132aa8774de070fa14015cc 100644 (file)
@@ -20,6 +20,8 @@ CONFIG_ENV_OFFSET_REDUND=0x3f0000
 CONFIG_SPL_SPI_FLASH_SUPPORT=y
 CONFIG_SPL_SPI=y
 # CONFIG_PSCI_RESET is not set
+CONFIG_ARMV8_PSCI=y
+CONFIG_ARMV8_PSCI_RELOCATE=y
 CONFIG_SYS_LOAD_ADDR=0x82000000
 CONFIG_AHCI=y
 CONFIG_DISTRO_DEFAULTS=y