Home | History | Annotate | Line # | Download | only in acpi
acpi_platform.c revision 1.21.2.2
      1  1.21.2.2   thorpej /* $NetBSD: acpi_platform.c,v 1.21.2.2 2021/04/03 22:28:15 thorpej Exp $ */
      2       1.1  jmcneill 
      3       1.1  jmcneill /*-
      4       1.1  jmcneill  * Copyright (c) 2018 The NetBSD Foundation, Inc.
      5       1.1  jmcneill  * All rights reserved.
      6       1.1  jmcneill  *
      7       1.1  jmcneill  * This code is derived from software contributed to The NetBSD Foundation
      8       1.1  jmcneill  * by Jared McNeill <jmcneill (at) invisible.ca>.
      9       1.1  jmcneill  *
     10       1.1  jmcneill  * Redistribution and use in source and binary forms, with or without
     11       1.1  jmcneill  * modification, are permitted provided that the following conditions
     12       1.1  jmcneill  * are met:
     13       1.1  jmcneill  * 1. Redistributions of source code must retain the above copyright
     14       1.1  jmcneill  *    notice, this list of conditions and the following disclaimer.
     15       1.1  jmcneill  * 2. Redistributions in binary form must reproduce the above copyright
     16       1.1  jmcneill  *    notice, this list of conditions and the following disclaimer in the
     17       1.1  jmcneill  *    documentation and/or other materials provided with the distribution.
     18       1.1  jmcneill  *
     19       1.1  jmcneill  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20       1.1  jmcneill  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21       1.1  jmcneill  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22       1.1  jmcneill  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23       1.1  jmcneill  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24       1.1  jmcneill  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25       1.1  jmcneill  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26       1.1  jmcneill  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27       1.1  jmcneill  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28       1.1  jmcneill  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29       1.1  jmcneill  * POSSIBILITY OF SUCH DAMAGE.
     30       1.1  jmcneill  */
     31       1.1  jmcneill 
     32       1.4  jmcneill #include "com.h"
     33       1.4  jmcneill #include "plcom.h"
     34       1.5  jmcneill #include "opt_efi.h"
     35      1.12       ryo #include "opt_multiprocessor.h"
     36       1.4  jmcneill 
     37       1.1  jmcneill #include <sys/cdefs.h>
     38  1.21.2.2   thorpej __KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.21.2.2 2021/04/03 22:28:15 thorpej Exp $");
     39       1.1  jmcneill 
     40       1.1  jmcneill #include <sys/param.h>
     41       1.1  jmcneill #include <sys/bus.h>
     42       1.1  jmcneill #include <sys/cpu.h>
     43       1.1  jmcneill #include <sys/device.h>
     44       1.1  jmcneill #include <sys/termios.h>
     45  1.21.2.2   thorpej #include <sys/kprintf.h>
     46       1.1  jmcneill 
     47       1.1  jmcneill #include <dev/fdt/fdtvar.h>
     48       1.1  jmcneill #include <arm/fdt/arm_fdtvar.h>
     49       1.1  jmcneill 
     50       1.1  jmcneill #include <uvm/uvm_extern.h>
     51       1.1  jmcneill 
     52       1.1  jmcneill #include <machine/bootconfig.h>
     53       1.1  jmcneill #include <arm/cpufunc.h>
     54       1.1  jmcneill #include <arm/locore.h>
     55       1.1  jmcneill 
     56       1.1  jmcneill #include <arm/cortex/gtmr_var.h>
     57       1.1  jmcneill 
     58       1.1  jmcneill #include <arm/arm/psci.h>
     59       1.1  jmcneill #include <arm/fdt/psci_fdtvar.h>
     60       1.1  jmcneill 
     61       1.1  jmcneill #include <evbarm/fdt/platform.h>
     62       1.1  jmcneill 
     63       1.1  jmcneill #include <evbarm/dev/plcomreg.h>
     64       1.1  jmcneill #include <evbarm/dev/plcomvar.h>
     65       1.1  jmcneill #include <dev/ic/ns16550reg.h>
     66       1.1  jmcneill #include <dev/ic/comreg.h>
     67       1.4  jmcneill #include <dev/ic/comvar.h>
     68       1.1  jmcneill 
     69      1.10  jmcneill #if NCOM > 0
     70      1.10  jmcneill #include <dev/pci/pcireg.h>
     71      1.10  jmcneill #include <dev/pci/pcivar.h>
     72      1.10  jmcneill #include <dev/pci/pucvar.h>
     73      1.10  jmcneill #endif
     74      1.10  jmcneill 
     75       1.5  jmcneill #ifdef EFI_RUNTIME
     76       1.5  jmcneill #include <arm/arm/efi_runtime.h>
     77       1.5  jmcneill #endif
     78       1.5  jmcneill 
     79       1.1  jmcneill #include <dev/acpi/acpireg.h>
     80       1.1  jmcneill #include <dev/acpi/acpivar.h>
     81       1.5  jmcneill #include <arm/acpi/acpi_table.h>
     82       1.5  jmcneill 
     83       1.5  jmcneill #include <libfdt.h>
     84       1.1  jmcneill 
     85  1.21.2.1   thorpej #define	SPCR_BAUD_DEFAULT			0
     86       1.3  jmcneill #define	SPCR_BAUD_9600				3
     87       1.3  jmcneill #define	SPCR_BAUD_19200				4
     88       1.3  jmcneill #define	SPCR_BAUD_57600				6
     89       1.3  jmcneill #define	SPCR_BAUD_115200			7
     90       1.1  jmcneill 
     91  1.21.2.1   thorpej static const struct acpi_spcr_baud_rate {
     92  1.21.2.1   thorpej 	uint8_t		id;
     93  1.21.2.1   thorpej 	uint32_t	baud_rate;
     94  1.21.2.1   thorpej } acpi_spcr_baud_rates[] = {
     95  1.21.2.1   thorpej 	{ SPCR_BAUD_DEFAULT,	0 },
     96  1.21.2.1   thorpej 	{ SPCR_BAUD_9600,	9600 },
     97  1.21.2.1   thorpej 	{ SPCR_BAUD_19200,	19200 },
     98  1.21.2.1   thorpej 	{ SPCR_BAUD_57600,	57600 },
     99  1.21.2.1   thorpej 	{ SPCR_BAUD_115200,	115200 },
    100  1.21.2.1   thorpej };
    101  1.21.2.1   thorpej 
    102       1.1  jmcneill extern struct bus_space arm_generic_bs_tag;
    103       1.1  jmcneill 
    104       1.7       rjs #if NPLCOM > 0
    105       1.1  jmcneill static struct plcom_instance plcom_console;
    106       1.7       rjs #endif
    107       1.1  jmcneill 
    108      1.14  jmcneill struct arm32_bus_dma_tag acpi_coherent_dma_tag;
    109      1.14  jmcneill static struct arm32_dma_range acpi_coherent_ranges[] = {
    110      1.13  jmcneill 	[0] = {
    111      1.13  jmcneill 		.dr_sysbase = 0,
    112      1.13  jmcneill 		.dr_busbase = 0,
    113      1.13  jmcneill 		.dr_len = UINTPTR_MAX,
    114      1.13  jmcneill 	 	.dr_flags = _BUS_DMAMAP_COHERENT,
    115      1.13  jmcneill 	}
    116      1.13  jmcneill };
    117      1.13  jmcneill 
    118       1.1  jmcneill static const struct pmap_devmap *
    119       1.1  jmcneill acpi_platform_devmap(void)
    120       1.1  jmcneill {
    121       1.1  jmcneill 	static const struct pmap_devmap devmap[] = {
    122       1.1  jmcneill 		DEVMAP_ENTRY_END
    123       1.1  jmcneill 	};
    124       1.1  jmcneill 
    125       1.1  jmcneill 	return devmap;
    126       1.1  jmcneill }
    127       1.1  jmcneill 
    128       1.1  jmcneill static void
    129       1.1  jmcneill acpi_platform_bootstrap(void)
    130       1.1  jmcneill {
    131      1.13  jmcneill 	extern struct arm32_bus_dma_tag arm_generic_dma_tag;
    132      1.13  jmcneill 
    133      1.14  jmcneill 	acpi_coherent_dma_tag = arm_generic_dma_tag;
    134      1.14  jmcneill 	acpi_coherent_dma_tag._ranges = acpi_coherent_ranges;
    135      1.14  jmcneill 	acpi_coherent_dma_tag._nranges = __arraycount(acpi_coherent_ranges);
    136       1.1  jmcneill }
    137       1.1  jmcneill 
    138       1.1  jmcneill static void
    139  1.21.2.1   thorpej acpi_platform_attach_uart(ACPI_TABLE_SPCR *spcr)
    140       1.1  jmcneill {
    141  1.21.2.1   thorpej #if NCOM > 0
    142  1.21.2.1   thorpej 	struct com_regs regs;
    143  1.21.2.1   thorpej 	bus_space_handle_t dummy_bsh;
    144  1.21.2.1   thorpej 	u_int reg_shift;
    145      1.12       ryo #endif
    146  1.21.2.1   thorpej 	int baud_rate, n;
    147       1.1  jmcneill 
    148       1.1  jmcneill 	/*
    149  1.21.2.1   thorpej 	 * Only MMIO access is supported today.
    150       1.1  jmcneill 	 */
    151  1.21.2.1   thorpej 	if (spcr->SerialPort.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) {
    152  1.21.2.1   thorpej 		return;
    153  1.21.2.1   thorpej 	}
    154  1.21.2.1   thorpej 	if (le64toh(spcr->SerialPort.Address) == 0) {
    155  1.21.2.1   thorpej 		return;
    156  1.21.2.1   thorpej 	}
    157       1.4  jmcneill 
    158  1.21.2.1   thorpej 	/*
    159  1.21.2.1   thorpej 	 * Lookup SPCR baud rate.
    160  1.21.2.1   thorpej 	 */
    161  1.21.2.1   thorpej 	baud_rate = 0;
    162  1.21.2.1   thorpej 	for (n = 0; n < __arraycount(acpi_spcr_baud_rates); n++) {
    163  1.21.2.1   thorpej 		if (acpi_spcr_baud_rates[n].id == spcr->BaudRate) {
    164  1.21.2.1   thorpej 			baud_rate = acpi_spcr_baud_rates[n].baud_rate;
    165       1.4  jmcneill 			break;
    166       1.4  jmcneill 		}
    167  1.21.2.1   thorpej 	}
    168       1.4  jmcneill 
    169  1.21.2.1   thorpej 	/*
    170  1.21.2.1   thorpej 	 * Attach console device.
    171  1.21.2.1   thorpej 	 */
    172  1.21.2.1   thorpej 	switch (spcr->InterfaceType) {
    173       1.4  jmcneill #if NPLCOM > 0
    174  1.21.2.1   thorpej 	case ACPI_DBG2_ARM_PL011:
    175  1.21.2.1   thorpej 	case ACPI_DBG2_ARM_SBSA_32BIT:
    176  1.21.2.1   thorpej 	case ACPI_DBG2_ARM_SBSA_GENERIC:
    177  1.21.2.1   thorpej 		plcom_console.pi_type = PLCOM_TYPE_PL011;
    178  1.21.2.1   thorpej 		plcom_console.pi_iot = &arm_generic_bs_tag;
    179  1.21.2.1   thorpej 		plcom_console.pi_iobase = le64toh(spcr->SerialPort.Address);
    180  1.21.2.1   thorpej 		plcom_console.pi_size = PL011COM_UART_SIZE;
    181  1.21.2.1   thorpej 		plcom_console.pi_flags = PLC_FLAG_32BIT_ACCESS;
    182       1.1  jmcneill 
    183  1.21.2.1   thorpej 		plcomcnattach(&plcom_console, baud_rate, 0, TTYDEF_CFLAG, -1);
    184  1.21.2.1   thorpej 		break;
    185       1.4  jmcneill #endif
    186  1.21.2.1   thorpej 
    187       1.4  jmcneill #if NCOM > 0
    188  1.21.2.1   thorpej 	case ACPI_DBG2_16550_COMPATIBLE:
    189  1.21.2.1   thorpej 	case ACPI_DBG2_16550_SUBSET:
    190  1.21.2.1   thorpej 		memset(&dummy_bsh, 0, sizeof(dummy_bsh));
    191  1.21.2.1   thorpej 		if (ACPI_ACCESS_BIT_WIDTH(spcr->SerialPort.AccessWidth) == 8) {
    192  1.21.2.1   thorpej 			reg_shift = 0;
    193  1.21.2.1   thorpej 		} else {
    194  1.21.2.1   thorpej 			reg_shift = 2;
    195       1.1  jmcneill 		}
    196  1.21.2.1   thorpej 		com_init_regs_stride(&regs, &arm_generic_bs_tag, dummy_bsh,
    197  1.21.2.1   thorpej 		    le64toh(spcr->SerialPort.Address), reg_shift);
    198  1.21.2.1   thorpej 		comcnattach1(&regs, baud_rate, -1, COM_TYPE_NORMAL,
    199  1.21.2.1   thorpej 		    TTYDEF_CFLAG);
    200  1.21.2.1   thorpej 		break;
    201  1.21.2.1   thorpej 
    202  1.21.2.1   thorpej 	case ACPI_DBG2_BCM2835:
    203  1.21.2.1   thorpej 		memset(&dummy_bsh, 0, sizeof(dummy_bsh));
    204  1.21.2.1   thorpej 		com_init_regs_stride(&regs, &arm_generic_bs_tag, dummy_bsh,
    205  1.21.2.1   thorpej 		    le64toh(spcr->SerialPort.Address) + 0x40, 2);
    206  1.21.2.1   thorpej 		comcnattach1(&regs, baud_rate, -1, COM_TYPE_BCMAUXUART,
    207  1.21.2.1   thorpej 		    TTYDEF_CFLAG);
    208  1.21.2.1   thorpej 		cn_set_magic("+++++");
    209  1.21.2.1   thorpej 		break;
    210  1.21.2.1   thorpej #endif
    211  1.21.2.1   thorpej 
    212  1.21.2.1   thorpej 	default:
    213  1.21.2.1   thorpej 		printf("SPCR: kernel does not support interface type %#x\n",
    214  1.21.2.1   thorpej 		    spcr->InterfaceType);
    215  1.21.2.1   thorpej 		break;
    216  1.21.2.1   thorpej 	}
    217  1.21.2.1   thorpej 
    218  1.21.2.2   thorpej 	/*
    219  1.21.2.2   thorpej 	 * UEFI firmware may leave the console in an undesireable state (wrong
    220  1.21.2.2   thorpej 	 * foreground/background colour, etc). Reset the terminal and clear
    221  1.21.2.2   thorpej 	 * text from the cursor to the end of the screne.
    222  1.21.2.2   thorpej 	 */
    223  1.21.2.2   thorpej         printf_flags(TOCONS|NOTSTAMP, "\033[0m");
    224  1.21.2.2   thorpej         printf_flags(TOCONS|NOTSTAMP, "\033[0J");
    225  1.21.2.1   thorpej }
    226  1.21.2.1   thorpej 
    227  1.21.2.1   thorpej static void
    228  1.21.2.1   thorpej acpi_platform_startup(void)
    229  1.21.2.1   thorpej {
    230  1.21.2.1   thorpej 	ACPI_TABLE_SPCR *spcr;
    231  1.21.2.1   thorpej 	ACPI_TABLE_FADT *fadt;
    232  1.21.2.1   thorpej #ifdef MULTIPROCESSOR
    233  1.21.2.1   thorpej 	ACPI_TABLE_MADT *madt;
    234  1.21.2.1   thorpej #endif
    235  1.21.2.1   thorpej 
    236  1.21.2.1   thorpej 	/*
    237  1.21.2.1   thorpej 	 * Setup serial console device
    238  1.21.2.1   thorpej 	 */
    239  1.21.2.1   thorpej 	if (ACPI_SUCCESS(acpi_table_find(ACPI_SIG_SPCR, (void **)&spcr))) {
    240  1.21.2.1   thorpej 		acpi_platform_attach_uart(spcr);
    241       1.1  jmcneill 		acpi_table_unmap((ACPI_TABLE_HEADER *)spcr);
    242       1.1  jmcneill 	}
    243       1.1  jmcneill 
    244       1.1  jmcneill 	/*
    245       1.1  jmcneill 	 * Initialize PSCI 0.2+ if implemented
    246       1.1  jmcneill 	 */
    247       1.1  jmcneill 	if (ACPI_SUCCESS(acpi_table_find(ACPI_SIG_FADT, (void **)&fadt))) {
    248  1.21.2.1   thorpej 		const uint16_t boot_flags = le16toh(fadt->ArmBootFlags);
    249  1.21.2.1   thorpej 		if ((boot_flags & ACPI_FADT_PSCI_COMPLIANT) != 0) {
    250  1.21.2.1   thorpej 			if ((boot_flags & ACPI_FADT_PSCI_USE_HVC) != 0) {
    251       1.1  jmcneill 				psci_init(psci_call_hvc);
    252       1.1  jmcneill 			} else {
    253       1.1  jmcneill 				psci_init(psci_call_smc);
    254       1.1  jmcneill 			}
    255       1.1  jmcneill 		}
    256       1.1  jmcneill 		acpi_table_unmap((ACPI_TABLE_HEADER *)fadt);
    257       1.1  jmcneill 	}
    258       1.1  jmcneill 
    259      1.12       ryo #ifdef MULTIPROCESSOR
    260       1.1  jmcneill 	/*
    261       1.1  jmcneill 	 * Count CPUs
    262       1.1  jmcneill 	 */
    263       1.1  jmcneill 	if (ACPI_SUCCESS(acpi_table_find(ACPI_SIG_MADT, (void **)&madt))) {
    264      1.19  jmcneill 		char *end = (char *)madt + le32toh(madt->Header.Length);
    265       1.1  jmcneill 		char *where = (char *)madt + sizeof(ACPI_TABLE_MADT);
    266       1.1  jmcneill 		while (where < end) {
    267  1.21.2.1   thorpej 			ACPI_SUBTABLE_HEADER *subtable =
    268  1.21.2.1   thorpej 			    (ACPI_SUBTABLE_HEADER *)where;
    269       1.1  jmcneill 			if (subtable->Type == ACPI_MADT_TYPE_GENERIC_INTERRUPT)
    270       1.1  jmcneill 				arm_cpu_max++;
    271       1.1  jmcneill 			where += subtable->Length;
    272       1.1  jmcneill 		}
    273       1.1  jmcneill 		acpi_table_unmap((ACPI_TABLE_HEADER *)madt);
    274       1.1  jmcneill 	}
    275      1.12       ryo #endif /* MULTIPROCESSOR */
    276       1.1  jmcneill }
    277       1.1  jmcneill 
    278       1.1  jmcneill static void
    279       1.1  jmcneill acpi_platform_init_attach_args(struct fdt_attach_args *faa)
    280       1.1  jmcneill {
    281       1.1  jmcneill 	extern struct bus_space arm_generic_bs_tag;
    282       1.1  jmcneill 
    283       1.1  jmcneill 	faa->faa_bst = &arm_generic_bs_tag;
    284      1.14  jmcneill 	faa->faa_dmat = &acpi_coherent_dma_tag;
    285       1.1  jmcneill }
    286       1.1  jmcneill 
    287       1.1  jmcneill static void
    288       1.1  jmcneill acpi_platform_device_register(device_t self, void *aux)
    289       1.1  jmcneill {
    290  1.21.2.2   thorpej 	/* XXX Not ideal, but the only reasonable solution atm. */
    291  1.21.2.2   thorpej 	acpi_device_register(self, aux);
    292  1.21.2.2   thorpej 	fdtbus_device_register(self, aux);
    293  1.21.2.2   thorpej 
    294      1.10  jmcneill #if NCOM > 0
    295      1.10  jmcneill 	prop_dictionary_t prop = device_properties(self);
    296  1.21.2.1   thorpej 	ACPI_STATUS rv;
    297      1.10  jmcneill 
    298      1.11  jmcneill 	if (device_is_a(self, "com")) {
    299      1.10  jmcneill 		ACPI_TABLE_SPCR *spcr;
    300      1.10  jmcneill 
    301  1.21.2.1   thorpej 		rv = acpi_table_find(ACPI_SIG_SPCR, (void **)&spcr);
    302  1.21.2.1   thorpej 		if (ACPI_FAILURE(rv)) {
    303      1.10  jmcneill 			return;
    304  1.21.2.1   thorpej 		}
    305      1.11  jmcneill 
    306  1.21.2.1   thorpej 		if (spcr->SerialPort.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) {
    307      1.10  jmcneill 			goto spcr_unmap;
    308  1.21.2.1   thorpej 		}
    309  1.21.2.1   thorpej 		if (le64toh(spcr->SerialPort.Address) == 0) {
    310      1.10  jmcneill 			goto spcr_unmap;
    311  1.21.2.1   thorpej 		}
    312      1.10  jmcneill 		if (spcr->InterfaceType != ACPI_DBG2_16550_COMPATIBLE &&
    313  1.21.2.1   thorpej 		    spcr->InterfaceType != ACPI_DBG2_16550_SUBSET) {
    314      1.10  jmcneill 			goto spcr_unmap;
    315  1.21.2.1   thorpej 		}
    316      1.10  jmcneill 
    317      1.11  jmcneill 		if (device_is_a(device_parent(self), "puc")) {
    318      1.11  jmcneill 			const struct puc_attach_args * const paa = aux;
    319      1.11  jmcneill 			int b, d, f;
    320      1.11  jmcneill 
    321      1.11  jmcneill 			const int s = pci_get_segment(paa->pc);
    322      1.11  jmcneill 			pci_decompose_tag(paa->pc, paa->tag, &b, &d, &f);
    323      1.11  jmcneill 
    324      1.11  jmcneill 			if (spcr->PciSegment == s && spcr->PciBus == b &&
    325  1.21.2.1   thorpej 			    spcr->PciDevice == d && spcr->PciFunction == f) {
    326  1.21.2.1   thorpej 				prop_dictionary_set_bool(prop,
    327  1.21.2.1   thorpej 				    "force_console", true);
    328  1.21.2.1   thorpej 			}
    329      1.11  jmcneill 		}
    330      1.11  jmcneill 
    331      1.11  jmcneill 		if (device_is_a(device_parent(self), "acpi")) {
    332      1.11  jmcneill 			struct acpi_attach_args * const aa = aux;
    333      1.11  jmcneill 			struct acpi_resources res;
    334      1.11  jmcneill 			struct acpi_mem *mem;
    335      1.11  jmcneill 
    336  1.21.2.1   thorpej 			if (ACPI_FAILURE(acpi_resource_parse(self,
    337  1.21.2.1   thorpej 					 aa->aa_node->ad_handle, "_CRS", &res,
    338  1.21.2.1   thorpej 					 &acpi_resource_parse_ops_quiet))) {
    339      1.11  jmcneill 				goto spcr_unmap;
    340  1.21.2.1   thorpej 			}
    341      1.11  jmcneill 
    342      1.11  jmcneill 			mem = acpi_res_mem(&res, 0);
    343  1.21.2.1   thorpej 			if (mem == NULL) {
    344      1.11  jmcneill 				goto crs_cleanup;
    345  1.21.2.1   thorpej 			}
    346      1.11  jmcneill 
    347  1.21.2.1   thorpej 			if (mem->ar_base == le64toh(spcr->SerialPort.Address)) {
    348  1.21.2.1   thorpej 				prop_dictionary_set_bool(prop,
    349  1.21.2.1   thorpej 				    "force_console", true);
    350  1.21.2.1   thorpej 			}
    351      1.11  jmcneill 
    352      1.11  jmcneill crs_cleanup:
    353      1.11  jmcneill 			acpi_resource_cleanup(&res);
    354      1.11  jmcneill 		}
    355      1.10  jmcneill 
    356      1.10  jmcneill spcr_unmap:
    357      1.10  jmcneill 		acpi_table_unmap((ACPI_TABLE_HEADER *)spcr);
    358      1.10  jmcneill 	}
    359      1.10  jmcneill #endif
    360       1.1  jmcneill }
    361       1.1  jmcneill 
    362       1.2  jmcneill static void
    363       1.2  jmcneill acpi_platform_reset(void)
    364       1.2  jmcneill {
    365       1.5  jmcneill #ifdef EFI_RUNTIME
    366       1.5  jmcneill 	if (arm_efirt_reset(EFI_RESET_COLD) == 0)
    367       1.5  jmcneill 		return;
    368       1.5  jmcneill #endif
    369       1.2  jmcneill 	if (psci_available())
    370       1.2  jmcneill 		psci_system_reset();
    371       1.2  jmcneill }
    372       1.2  jmcneill 
    373       1.1  jmcneill static u_int
    374       1.1  jmcneill acpi_platform_uart_freq(void)
    375       1.1  jmcneill {
    376       1.1  jmcneill 	return 0;
    377       1.1  jmcneill }
    378       1.1  jmcneill 
    379       1.1  jmcneill static const struct arm_platform acpi_platform = {
    380       1.1  jmcneill 	.ap_devmap = acpi_platform_devmap,
    381       1.1  jmcneill 	.ap_bootstrap = acpi_platform_bootstrap,
    382       1.1  jmcneill 	.ap_startup = acpi_platform_startup,
    383       1.1  jmcneill 	.ap_init_attach_args = acpi_platform_init_attach_args,
    384       1.1  jmcneill 	.ap_device_register = acpi_platform_device_register,
    385       1.2  jmcneill 	.ap_reset = acpi_platform_reset,
    386       1.1  jmcneill 	.ap_delay = gtmr_delay,
    387       1.1  jmcneill 	.ap_uart_freq = acpi_platform_uart_freq,
    388       1.1  jmcneill };
    389       1.1  jmcneill 
    390      1.17  jmcneill ARM_PLATFORM(acpi, "netbsd,generic-acpi", &acpi_platform);
    391