Module Name: src Committed By: jmcneill Date: Sat Oct 13 00:15:11 UTC 2018
Modified Files: src/sys/arch/arm/fdt: acpi_fdt.c Log Message: Support poweroff via PSCI To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/fdt/acpi_fdt.c 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/acpi_fdt.c diff -u src/sys/arch/arm/fdt/acpi_fdt.c:1.1 src/sys/arch/arm/fdt/acpi_fdt.c:1.2 --- src/sys/arch/arm/fdt/acpi_fdt.c:1.1 Fri Oct 12 22:20:48 2018 +++ src/sys/arch/arm/fdt/acpi_fdt.c Sat Oct 13 00:15:10 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_fdt.c,v 1.1 2018/10/12 22:20:48 jmcneill Exp $ */ +/* $NetBSD: acpi_fdt.c,v 1.2 2018/10/13 00:15:10 jmcneill Exp $ */ /*- * Copyright (c) 2015-2017 Jared McNeill <jmcne...@invisible.ca> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.1 2018/10/12 22:20:48 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.2 2018/10/13 00:15:10 jmcneill Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -44,14 +44,22 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v #include <dev/acpi/acpivar.h> #include <dev/pci/pcivar.h> +#include <arm/arm/psci.h> + static int acpi_fdt_match(device_t, cfdata_t, void *); static void acpi_fdt_attach(device_t, device_t, void *); +static void acpi_fdt_poweroff(device_t); + static const char * const compatible[] = { "netbsd,acpi", NULL }; +static const struct fdtbus_power_controller_func acpi_fdt_power_funcs = { + .poweroff = acpi_fdt_poweroff, +}; + CFATTACH_DECL_NEW(acpi_fdt, 0, acpi_fdt_match, acpi_fdt_attach, NULL, NULL); static int @@ -71,6 +79,9 @@ acpi_fdt_attach(device_t parent, device_ aprint_naive("\n"); aprint_normal(": ACPI Platform support\n"); + fdtbus_register_power_controller(self, faa->faa_phandle, + &acpi_fdt_power_funcs); + if (!acpi_probe()) aprint_error_dev(self, "failed to probe ACPI\n"); @@ -88,3 +99,11 @@ acpi_fdt_attach(device_t parent, device_ #endif config_found_ia(self, "acpibus", &aa, 0); } + +static void +acpi_fdt_poweroff(device_t dev) +{ + delay(500000); + if (psci_available()) + psci_system_off(); +}