Home | History | Annotate | Line # | Download | only in acpi
acpi_platform.c revision 1.36.6.2
      1  1.36.6.2  perseant /* $NetBSD: acpi_platform.c,v 1.36.6.2 2025/08/02 05:55:25 perseant 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.36.6.2  perseant __KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.36.6.2 2025/08/02 05:55:25 perseant 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.24  jmcneill #include <sys/kprintf.h>
     46       1.1  jmcneill 
     47       1.1  jmcneill #include <dev/fdt/fdtvar.h>
     48       1.1  jmcneill 
     49       1.1  jmcneill #include <uvm/uvm_extern.h>
     50       1.1  jmcneill 
     51       1.1  jmcneill #include <machine/bootconfig.h>
     52       1.1  jmcneill #include <arm/cpufunc.h>
     53       1.1  jmcneill #include <arm/locore.h>
     54       1.1  jmcneill 
     55       1.1  jmcneill #include <arm/cortex/gtmr_var.h>
     56       1.1  jmcneill 
     57      1.27  jmcneill #include <arm/arm/smccc.h>
     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.36.6.1  perseant #include <dev/acpi/acpi_srat.h>
     83       1.5  jmcneill 
     84       1.5  jmcneill #include <libfdt.h>
     85       1.1  jmcneill 
     86      1.22  jmcneill #define	SPCR_BAUD_DEFAULT			0
     87       1.3  jmcneill #define	SPCR_BAUD_9600				3
     88       1.3  jmcneill #define	SPCR_BAUD_19200				4
     89       1.3  jmcneill #define	SPCR_BAUD_57600				6
     90       1.3  jmcneill #define	SPCR_BAUD_115200			7
     91       1.1  jmcneill 
     92      1.22  jmcneill static const struct acpi_spcr_baud_rate {
     93      1.22  jmcneill 	uint8_t		id;
     94      1.30  jmcneill 	int		baud_rate;
     95      1.22  jmcneill } acpi_spcr_baud_rates[] = {
     96      1.32  jmcneill 	/*
     97      1.32  jmcneill 	 * SPCR_BAUD_DEFAULT means:
     98      1.32  jmcneill 	 *   "As is, operating system relies on the current configuration
     99      1.32  jmcneill 	 *    of serial port until the full featured driver will be
    100      1.32  jmcneill 	 *    initialized."
    101      1.32  jmcneill 	 *
    102      1.32  jmcneill 	 * We don't currently have a good way of telling the UART driver
    103      1.32  jmcneill 	 * to detect the currently configured baud rate, so just pick
    104      1.32  jmcneill 	 * something sensible here.
    105      1.32  jmcneill 	 *
    106      1.32  jmcneill 	 * In the past we have tried baud_rate values of 0 and -1, but
    107      1.32  jmcneill 	 * these cause problems with the com(4) driver.
    108      1.32  jmcneill 	 */
    109      1.32  jmcneill 	{ SPCR_BAUD_DEFAULT,	115200 },
    110      1.22  jmcneill 	{ SPCR_BAUD_9600,	9600 },
    111      1.22  jmcneill 	{ SPCR_BAUD_19200,	19200 },
    112      1.22  jmcneill 	{ SPCR_BAUD_57600,	57600 },
    113      1.22  jmcneill 	{ SPCR_BAUD_115200,	115200 },
    114      1.22  jmcneill };
    115      1.22  jmcneill 
    116       1.1  jmcneill extern struct bus_space arm_generic_bs_tag;
    117       1.1  jmcneill 
    118       1.7       rjs #if NPLCOM > 0
    119       1.1  jmcneill static struct plcom_instance plcom_console;
    120       1.7       rjs #endif
    121       1.1  jmcneill 
    122      1.14  jmcneill struct arm32_bus_dma_tag acpi_coherent_dma_tag;
    123      1.14  jmcneill static struct arm32_dma_range acpi_coherent_ranges[] = {
    124      1.13  jmcneill 	[0] = {
    125      1.13  jmcneill 		.dr_sysbase = 0,
    126      1.13  jmcneill 		.dr_busbase = 0,
    127      1.13  jmcneill 		.dr_len = UINTPTR_MAX,
    128      1.13  jmcneill 	 	.dr_flags = _BUS_DMAMAP_COHERENT,
    129      1.13  jmcneill 	}
    130      1.13  jmcneill };
    131      1.13  jmcneill 
    132       1.1  jmcneill static const struct pmap_devmap *
    133       1.1  jmcneill acpi_platform_devmap(void)
    134       1.1  jmcneill {
    135       1.1  jmcneill 	static const struct pmap_devmap devmap[] = {
    136       1.1  jmcneill 		DEVMAP_ENTRY_END
    137       1.1  jmcneill 	};
    138       1.1  jmcneill 
    139       1.1  jmcneill 	return devmap;
    140       1.1  jmcneill }
    141       1.1  jmcneill 
    142       1.1  jmcneill static void
    143       1.1  jmcneill acpi_platform_bootstrap(void)
    144       1.1  jmcneill {
    145      1.13  jmcneill 	extern struct arm32_bus_dma_tag arm_generic_dma_tag;
    146      1.13  jmcneill 
    147      1.14  jmcneill 	acpi_coherent_dma_tag = arm_generic_dma_tag;
    148      1.14  jmcneill 	acpi_coherent_dma_tag._ranges = acpi_coherent_ranges;
    149      1.14  jmcneill 	acpi_coherent_dma_tag._nranges = __arraycount(acpi_coherent_ranges);
    150       1.1  jmcneill }
    151       1.1  jmcneill 
    152       1.1  jmcneill static void
    153      1.22  jmcneill acpi_platform_attach_uart(ACPI_TABLE_SPCR *spcr)
    154       1.1  jmcneill {
    155      1.22  jmcneill #if NCOM > 0
    156      1.22  jmcneill 	struct com_regs regs;
    157      1.22  jmcneill 	bus_space_handle_t dummy_bsh;
    158      1.22  jmcneill 	u_int reg_shift;
    159      1.12       ryo #endif
    160      1.22  jmcneill 	int baud_rate, n;
    161       1.1  jmcneill 
    162       1.1  jmcneill 	/*
    163      1.22  jmcneill 	 * Only MMIO access is supported today.
    164       1.1  jmcneill 	 */
    165      1.22  jmcneill 	if (spcr->SerialPort.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) {
    166      1.22  jmcneill 		return;
    167      1.22  jmcneill 	}
    168      1.22  jmcneill 	if (le64toh(spcr->SerialPort.Address) == 0) {
    169      1.22  jmcneill 		return;
    170      1.22  jmcneill 	}
    171       1.4  jmcneill 
    172      1.22  jmcneill 	/*
    173      1.22  jmcneill 	 * Lookup SPCR baud rate.
    174      1.22  jmcneill 	 */
    175      1.22  jmcneill 	baud_rate = 0;
    176      1.22  jmcneill 	for (n = 0; n < __arraycount(acpi_spcr_baud_rates); n++) {
    177      1.22  jmcneill 		if (acpi_spcr_baud_rates[n].id == spcr->BaudRate) {
    178      1.22  jmcneill 			baud_rate = acpi_spcr_baud_rates[n].baud_rate;
    179       1.4  jmcneill 			break;
    180       1.4  jmcneill 		}
    181      1.22  jmcneill 	}
    182       1.4  jmcneill 
    183      1.22  jmcneill 	/*
    184      1.22  jmcneill 	 * Attach console device.
    185      1.22  jmcneill 	 */
    186      1.22  jmcneill 	switch (spcr->InterfaceType) {
    187       1.4  jmcneill #if NPLCOM > 0
    188      1.22  jmcneill 	case ACPI_DBG2_ARM_PL011:
    189      1.22  jmcneill 	case ACPI_DBG2_ARM_SBSA_32BIT:
    190      1.22  jmcneill 	case ACPI_DBG2_ARM_SBSA_GENERIC:
    191      1.35   mlelstv 		if (spcr->InterfaceType == ACPI_DBG2_ARM_PL011)
    192      1.35   mlelstv 			plcom_console.pi_type = PLCOM_TYPE_PL011;
    193      1.35   mlelstv 		else
    194      1.35   mlelstv 			plcom_console.pi_type = PLCOM_TYPE_GENERIC_UART;
    195      1.22  jmcneill 		plcom_console.pi_iot = &arm_generic_bs_tag;
    196      1.22  jmcneill 		plcom_console.pi_iobase = le64toh(spcr->SerialPort.Address);
    197      1.22  jmcneill 		plcom_console.pi_size = PL011COM_UART_SIZE;
    198      1.22  jmcneill 		plcom_console.pi_flags = PLC_FLAG_32BIT_ACCESS;
    199       1.1  jmcneill 
    200      1.22  jmcneill 		plcomcnattach(&plcom_console, baud_rate, 0, TTYDEF_CFLAG, -1);
    201      1.22  jmcneill 		break;
    202       1.4  jmcneill #endif
    203      1.22  jmcneill 
    204       1.4  jmcneill #if NCOM > 0
    205      1.22  jmcneill 	case ACPI_DBG2_16550_COMPATIBLE:
    206      1.22  jmcneill 	case ACPI_DBG2_16550_SUBSET:
    207      1.33     skrll 	case ACPI_DBG2_16550_WITH_GAS:
    208      1.22  jmcneill 		memset(&dummy_bsh, 0, sizeof(dummy_bsh));
    209      1.32  jmcneill 		switch (spcr->SerialPort.BitWidth) {
    210      1.32  jmcneill 		case 8:
    211      1.22  jmcneill 			reg_shift = 0;
    212      1.32  jmcneill 			break;
    213      1.32  jmcneill 		case 16:
    214      1.32  jmcneill 			reg_shift = 1;
    215      1.32  jmcneill 			break;
    216      1.32  jmcneill 		case 32:
    217      1.31  jmcneill 			reg_shift = 2;
    218      1.32  jmcneill 			break;
    219      1.32  jmcneill 		default:
    220      1.32  jmcneill 			/*
    221      1.32  jmcneill 			 * Bit width 0 is possible for types 0 and 1. Otherwise,
    222      1.32  jmcneill 			 * possibly buggy firmware.
    223      1.32  jmcneill 			 */
    224      1.32  jmcneill 			if (spcr->InterfaceType == ACPI_DBG2_16550_COMPATIBLE) {
    225      1.31  jmcneill 				reg_shift = 0;
    226      1.31  jmcneill 			} else {
    227      1.31  jmcneill 				reg_shift = 2;
    228      1.31  jmcneill 			}
    229      1.32  jmcneill 			break;
    230      1.22  jmcneill 		}
    231      1.22  jmcneill 		com_init_regs_stride(&regs, &arm_generic_bs_tag, dummy_bsh,
    232      1.22  jmcneill 		    le64toh(spcr->SerialPort.Address), reg_shift);
    233      1.22  jmcneill 		comcnattach1(&regs, baud_rate, -1, COM_TYPE_NORMAL,
    234      1.22  jmcneill 		    TTYDEF_CFLAG);
    235      1.22  jmcneill 		break;
    236      1.22  jmcneill 
    237      1.22  jmcneill 	case ACPI_DBG2_BCM2835:
    238      1.22  jmcneill 		memset(&dummy_bsh, 0, sizeof(dummy_bsh));
    239      1.22  jmcneill 		com_init_regs_stride(&regs, &arm_generic_bs_tag, dummy_bsh,
    240      1.22  jmcneill 		    le64toh(spcr->SerialPort.Address) + 0x40, 2);
    241      1.22  jmcneill 		comcnattach1(&regs, baud_rate, -1, COM_TYPE_BCMAUXUART,
    242      1.22  jmcneill 		    TTYDEF_CFLAG);
    243      1.22  jmcneill 		cn_set_magic("+++++");
    244      1.22  jmcneill 		break;
    245      1.22  jmcneill #endif
    246      1.22  jmcneill 
    247      1.22  jmcneill 	default:
    248      1.22  jmcneill 		printf("SPCR: kernel does not support interface type %#x\n",
    249      1.22  jmcneill 		    spcr->InterfaceType);
    250      1.22  jmcneill 		break;
    251      1.22  jmcneill 	}
    252      1.22  jmcneill 
    253      1.24  jmcneill 	/*
    254      1.24  jmcneill 	 * UEFI firmware may leave the console in an undesireable state (wrong
    255      1.24  jmcneill 	 * foreground/background colour, etc). Reset the terminal and clear
    256      1.34     skrll 	 * text from the cursor to the end of the screen.
    257      1.24  jmcneill 	 */
    258      1.24  jmcneill         printf_flags(TOCONS|NOTSTAMP, "\033[0m");
    259      1.24  jmcneill         printf_flags(TOCONS|NOTSTAMP, "\033[0J");
    260      1.22  jmcneill }
    261      1.22  jmcneill 
    262      1.22  jmcneill static void
    263      1.22  jmcneill acpi_platform_startup(void)
    264      1.22  jmcneill {
    265      1.22  jmcneill 	ACPI_TABLE_SPCR *spcr;
    266      1.22  jmcneill 	ACPI_TABLE_FADT *fadt;
    267      1.22  jmcneill #ifdef MULTIPROCESSOR
    268      1.22  jmcneill 	ACPI_TABLE_MADT *madt;
    269       1.4  jmcneill #endif
    270      1.22  jmcneill 
    271      1.22  jmcneill 	/*
    272      1.22  jmcneill 	 * Setup serial console device
    273      1.22  jmcneill 	 */
    274      1.22  jmcneill 	if (ACPI_SUCCESS(acpi_table_find(ACPI_SIG_SPCR, (void **)&spcr))) {
    275      1.22  jmcneill 		acpi_platform_attach_uart(spcr);
    276       1.1  jmcneill 		acpi_table_unmap((ACPI_TABLE_HEADER *)spcr);
    277       1.1  jmcneill 	}
    278       1.1  jmcneill 
    279       1.1  jmcneill 	/*
    280       1.1  jmcneill 	 * Initialize PSCI 0.2+ if implemented
    281       1.1  jmcneill 	 */
    282       1.1  jmcneill 	if (ACPI_SUCCESS(acpi_table_find(ACPI_SIG_FADT, (void **)&fadt))) {
    283      1.22  jmcneill 		const uint16_t boot_flags = le16toh(fadt->ArmBootFlags);
    284      1.22  jmcneill 		if ((boot_flags & ACPI_FADT_PSCI_COMPLIANT) != 0) {
    285      1.22  jmcneill 			if ((boot_flags & ACPI_FADT_PSCI_USE_HVC) != 0) {
    286       1.1  jmcneill 				psci_init(psci_call_hvc);
    287       1.1  jmcneill 			} else {
    288       1.1  jmcneill 				psci_init(psci_call_smc);
    289       1.1  jmcneill 			}
    290      1.28  jmcneill 			smccc_probe();
    291       1.1  jmcneill 		}
    292       1.1  jmcneill 		acpi_table_unmap((ACPI_TABLE_HEADER *)fadt);
    293       1.1  jmcneill 	}
    294       1.1  jmcneill 
    295      1.12       ryo #ifdef MULTIPROCESSOR
    296       1.1  jmcneill 	/*
    297       1.1  jmcneill 	 * Count CPUs
    298       1.1  jmcneill 	 */
    299       1.1  jmcneill 	if (ACPI_SUCCESS(acpi_table_find(ACPI_SIG_MADT, (void **)&madt))) {
    300      1.19  jmcneill 		char *end = (char *)madt + le32toh(madt->Header.Length);
    301       1.1  jmcneill 		char *where = (char *)madt + sizeof(ACPI_TABLE_MADT);
    302       1.1  jmcneill 		while (where < end) {
    303      1.22  jmcneill 			ACPI_SUBTABLE_HEADER *subtable =
    304      1.22  jmcneill 			    (ACPI_SUBTABLE_HEADER *)where;
    305       1.1  jmcneill 			if (subtable->Type == ACPI_MADT_TYPE_GENERIC_INTERRUPT)
    306       1.1  jmcneill 				arm_cpu_max++;
    307       1.1  jmcneill 			where += subtable->Length;
    308       1.1  jmcneill 		}
    309       1.1  jmcneill 		acpi_table_unmap((ACPI_TABLE_HEADER *)madt);
    310       1.1  jmcneill 	}
    311      1.12       ryo #endif /* MULTIPROCESSOR */
    312       1.1  jmcneill }
    313       1.1  jmcneill 
    314       1.1  jmcneill static void
    315       1.1  jmcneill acpi_platform_init_attach_args(struct fdt_attach_args *faa)
    316       1.1  jmcneill {
    317       1.1  jmcneill 	extern struct bus_space arm_generic_bs_tag;
    318       1.1  jmcneill 
    319       1.1  jmcneill 	faa->faa_bst = &arm_generic_bs_tag;
    320      1.14  jmcneill 	faa->faa_dmat = &acpi_coherent_dma_tag;
    321       1.1  jmcneill }
    322       1.1  jmcneill 
    323       1.1  jmcneill static void
    324       1.1  jmcneill acpi_platform_device_register(device_t self, void *aux)
    325       1.1  jmcneill {
    326      1.10  jmcneill #if NCOM > 0
    327      1.10  jmcneill 	prop_dictionary_t prop = device_properties(self);
    328      1.22  jmcneill 	ACPI_STATUS rv;
    329      1.10  jmcneill 
    330      1.11  jmcneill 	if (device_is_a(self, "com")) {
    331      1.10  jmcneill 		ACPI_TABLE_SPCR *spcr;
    332      1.10  jmcneill 
    333      1.22  jmcneill 		rv = acpi_table_find(ACPI_SIG_SPCR, (void **)&spcr);
    334      1.22  jmcneill 		if (ACPI_FAILURE(rv)) {
    335      1.10  jmcneill 			return;
    336      1.22  jmcneill 		}
    337      1.11  jmcneill 
    338      1.22  jmcneill 		if (spcr->SerialPort.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) {
    339      1.10  jmcneill 			goto spcr_unmap;
    340      1.22  jmcneill 		}
    341      1.22  jmcneill 		if (le64toh(spcr->SerialPort.Address) == 0) {
    342      1.10  jmcneill 			goto spcr_unmap;
    343      1.22  jmcneill 		}
    344      1.10  jmcneill 		if (spcr->InterfaceType != ACPI_DBG2_16550_COMPATIBLE &&
    345      1.22  jmcneill 		    spcr->InterfaceType != ACPI_DBG2_16550_SUBSET) {
    346      1.10  jmcneill 			goto spcr_unmap;
    347      1.22  jmcneill 		}
    348      1.10  jmcneill 
    349      1.11  jmcneill 		if (device_is_a(device_parent(self), "puc")) {
    350      1.11  jmcneill 			const struct puc_attach_args * const paa = aux;
    351      1.11  jmcneill 			int b, d, f;
    352      1.11  jmcneill 
    353      1.11  jmcneill 			const int s = pci_get_segment(paa->pc);
    354      1.11  jmcneill 			pci_decompose_tag(paa->pc, paa->tag, &b, &d, &f);
    355      1.11  jmcneill 
    356      1.11  jmcneill 			if (spcr->PciSegment == s && spcr->PciBus == b &&
    357      1.22  jmcneill 			    spcr->PciDevice == d && spcr->PciFunction == f) {
    358      1.22  jmcneill 				prop_dictionary_set_bool(prop,
    359      1.22  jmcneill 				    "force_console", true);
    360      1.22  jmcneill 			}
    361      1.11  jmcneill 		}
    362      1.11  jmcneill 
    363      1.11  jmcneill 		if (device_is_a(device_parent(self), "acpi")) {
    364      1.11  jmcneill 			struct acpi_attach_args * const aa = aux;
    365      1.11  jmcneill 			struct acpi_resources res;
    366      1.11  jmcneill 			struct acpi_mem *mem;
    367      1.11  jmcneill 
    368      1.22  jmcneill 			if (ACPI_FAILURE(acpi_resource_parse(self,
    369      1.22  jmcneill 					 aa->aa_node->ad_handle, "_CRS", &res,
    370      1.22  jmcneill 					 &acpi_resource_parse_ops_quiet))) {
    371      1.11  jmcneill 				goto spcr_unmap;
    372      1.22  jmcneill 			}
    373      1.11  jmcneill 
    374      1.11  jmcneill 			mem = acpi_res_mem(&res, 0);
    375      1.22  jmcneill 			if (mem == NULL) {
    376      1.11  jmcneill 				goto crs_cleanup;
    377      1.22  jmcneill 			}
    378      1.11  jmcneill 
    379      1.22  jmcneill 			if (mem->ar_base == le64toh(spcr->SerialPort.Address)) {
    380      1.22  jmcneill 				prop_dictionary_set_bool(prop,
    381      1.22  jmcneill 				    "force_console", true);
    382      1.22  jmcneill 			}
    383      1.11  jmcneill 
    384      1.11  jmcneill crs_cleanup:
    385      1.11  jmcneill 			acpi_resource_cleanup(&res);
    386      1.11  jmcneill 		}
    387      1.10  jmcneill 
    388      1.10  jmcneill spcr_unmap:
    389      1.10  jmcneill 		acpi_table_unmap((ACPI_TABLE_HEADER *)spcr);
    390      1.10  jmcneill 	}
    391      1.10  jmcneill #endif
    392       1.1  jmcneill }
    393       1.1  jmcneill 
    394       1.2  jmcneill static void
    395  1.36.6.1  perseant acpi_platform_device_register_post_config(device_t self, void *aux)
    396  1.36.6.1  perseant {
    397  1.36.6.1  perseant 	if (device_is_a(self, "acpi")) {
    398  1.36.6.1  perseant 		acpisrat_load_uvm();
    399  1.36.6.1  perseant 	}
    400  1.36.6.1  perseant }
    401  1.36.6.1  perseant 
    402  1.36.6.1  perseant static void
    403       1.2  jmcneill acpi_platform_reset(void)
    404       1.2  jmcneill {
    405  1.36.6.2  perseant 	if (psci_available()) {
    406  1.36.6.2  perseant 		psci_system_reset();
    407  1.36.6.2  perseant 	}
    408  1.36.6.2  perseant 
    409       1.5  jmcneill #ifdef EFI_RUNTIME
    410  1.36.6.2  perseant 	arm_efirt_reset(EFI_RESET_COLD);
    411       1.5  jmcneill #endif
    412       1.2  jmcneill }
    413       1.2  jmcneill 
    414       1.1  jmcneill static u_int
    415       1.1  jmcneill acpi_platform_uart_freq(void)
    416       1.1  jmcneill {
    417       1.1  jmcneill 	return 0;
    418       1.1  jmcneill }
    419       1.1  jmcneill 
    420      1.36     skrll static const struct fdt_platform acpi_platform = {
    421      1.36     skrll 	.fp_devmap = acpi_platform_devmap,
    422      1.36     skrll 	.fp_bootstrap = acpi_platform_bootstrap,
    423      1.36     skrll 	.fp_startup = acpi_platform_startup,
    424      1.36     skrll 	.fp_init_attach_args = acpi_platform_init_attach_args,
    425      1.36     skrll 	.fp_device_register = acpi_platform_device_register,
    426  1.36.6.1  perseant 	.fp_device_register_post_config = acpi_platform_device_register_post_config,
    427      1.36     skrll 	.fp_reset = acpi_platform_reset,
    428      1.36     skrll 	.fp_delay = gtmr_delay,
    429      1.36     skrll 	.fp_uart_freq = acpi_platform_uart_freq,
    430       1.1  jmcneill };
    431       1.1  jmcneill 
    432      1.36     skrll FDT_PLATFORM(acpi, "netbsd,generic-acpi", &acpi_platform);
    433