Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/fdt Export a psci_fdt_reset function, usable fr...



details:   https://anonhg.NetBSD.org/src/rev/ef44546e71ce
branches:  trunk
changeset: 319340:ef44546e71ce
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sat May 26 22:49:03 2018 +0000

description:
Export a psci_fdt_reset function, usable from FDT platform code.

diffstat:

 sys/arch/arm/fdt/psci_fdt.c |  43 ++++++++++++++++++++++++++++++-------------
 sys/arch/arm/fdt/psci_fdt.h |   5 ++++-
 2 files changed, 34 insertions(+), 14 deletions(-)

diffs (111 lines):

diff -r f63472e13163 -r ef44546e71ce sys/arch/arm/fdt/psci_fdt.c
--- a/sys/arch/arm/fdt/psci_fdt.c       Sat May 26 21:15:46 2018 +0000
+++ b/sys/arch/arm/fdt/psci_fdt.c       Sat May 26 22:49:03 2018 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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 @@
 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 @@
        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 @@
                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 @@
        }
 #endif
 }
+
+void
+psci_fdt_reset(void)
+{
+       if (psci_fdt_preinit() != 0) {
+               aprint_error("PSCI: reset failed\n");
+               return;
+       }
+
+       psci_system_reset();
+}
diff -r f63472e13163 -r ef44546e71ce sys/arch/arm/fdt/psci_fdt.h
--- a/sys/arch/arm/fdt/psci_fdt.h       Sat May 26 21:15:46 2018 +0000
+++ b/sys/arch/arm/fdt/psci_fdt.h       Sat May 26 22:49:03 2018 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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 */



Home | Main Index | Thread Index | Old Index