Module Name: src
Committed By: jmcneill
Date: Sat May 26 22:49:03 UTC 2018
Modified Files:
src/sys/arch/arm/fdt: psci_fdt.c psci_fdt.h
Log Message:
Export a psci_fdt_reset function, usable from FDT platform code.
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/fdt/psci_fdt.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/fdt/psci_fdt.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/arm/fdt/psci_fdt.c
diff -u src/sys/arch/arm/fdt/psci_fdt.c:1.3 src/sys/arch/arm/fdt/psci_fdt.c:1.4
--- src/sys/arch/arm/fdt/psci_fdt.c:1.3 Mon Sep 11 09:21:56 2017
+++ src/sys/arch/arm/fdt/psci_fdt.c Sat May 26 22:49:03 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: psci_fdt.c,v 1.3 2017/09/11 09:21:56 jmcneill Exp $ */
+/* $NetBSD: psci_fdt.c,v 1.4 2018/05/26 22:49:03 jmcneill Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <[email protected]>
@@ -29,7 +29,7 @@
#include "opt_multiprocessor.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.3 2017/09/11 09:21:56 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psci_fdt.c,v 1.4 2018/05/26 22:49:03 jmcneill Exp $");
#include <sys/param.h>
#include <sys/bus.h>
@@ -60,22 +60,22 @@ static const char * const compatible[] =
CFATTACH_DECL_NEW(psci_fdt, 0, psci_fdt_match, psci_fdt_attach, NULL, NULL);
static void
-psci_fdt_reset(device_t dev)
+psci_fdt_power_reset(device_t dev)
{
delay(500000);
psci_system_reset();
}
static void
-psci_fdt_poweroff(device_t dev)
+psci_fdt_power_poweroff(device_t dev)
{
delay(500000);
psci_system_off();
}
static const struct fdtbus_power_controller_func psci_power_funcs = {
- .reset = psci_fdt_reset,
- .poweroff = psci_fdt_poweroff,
+ .reset = psci_fdt_power_reset,
+ .poweroff = psci_fdt_power_poweroff,
};
static int
@@ -136,6 +136,18 @@ psci_fdt_init(const int phandle)
return 0;
}
+static int
+psci_fdt_preinit(void)
+{
+ const int phandle = OF_finddevice("/psci");
+ if (phandle == -1) {
+ aprint_error("PSCI: no /psci node found\n");
+ return ENODEV;
+ }
+
+ return psci_fdt_init(phandle);
+}
+
void
psci_fdt_bootstrap(void)
{
@@ -158,13 +170,7 @@ psci_fdt_bootstrap(void)
if (fdtbus_status_okay(child))
arm_cpu_max++;
- const int phandle = OF_finddevice("/psci");
- if (phandle == -1) {
- aprint_error("PSCI: no /psci node found\n");
- return;
- }
-
- if (psci_fdt_init(phandle) != 0)
+ if (psci_fdt_preinit() != 0)
return;
/* MPIDR affinity levels of boot processor. */
@@ -200,3 +206,14 @@ psci_fdt_bootstrap(void)
}
#endif
}
+
+void
+psci_fdt_reset(void)
+{
+ if (psci_fdt_preinit() != 0) {
+ aprint_error("PSCI: reset failed\n");
+ return;
+ }
+
+ psci_system_reset();
+}
Index: src/sys/arch/arm/fdt/psci_fdt.h
diff -u src/sys/arch/arm/fdt/psci_fdt.h:1.1 src/sys/arch/arm/fdt/psci_fdt.h:1.2
--- src/sys/arch/arm/fdt/psci_fdt.h:1.1 Wed Jun 28 23:48:22 2017
+++ src/sys/arch/arm/fdt/psci_fdt.h Sat May 26 22:49:03 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: psci_fdt.h,v 1.1 2017/06/28 23:48:22 jmcneill Exp $ */
+/* $NetBSD: psci_fdt.h,v 1.2 2018/05/26 22:49:03 jmcneill Exp $ */
/*-
* Copyright (c) 2017 Jared McNeill <[email protected]>
@@ -32,4 +32,7 @@
/* Initialize PSCI and boot APs */
void psci_fdt_bootstrap(void);
+/* Board reset */
+void psci_fdt_reset(void);
+
#endif /* !_ARM_PSCI_FDT_H */