Module Name: src Committed By: jmcneill Date: Sun Oct 24 11:58:23 UTC 2021
Modified Files: src/sys/arch/arm/acpi: acpi_platform.c Log Message: More SPCR cleanup: - For 16550 style UARTs, always honour GAS if BitWidth != 0 - Use BitWidth instead of AccessWidth to determine register stride - For baud rate ID of 0, assume 115200 until we have a way of probing the baud rate configured by firmware. To generate a diff of this commit: cvs rdiff -u -r1.31 -r1.32 src/sys/arch/arm/acpi/acpi_platform.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/acpi/acpi_platform.c diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.31 src/sys/arch/arm/acpi/acpi_platform.c:1.32 --- src/sys/arch/arm/acpi/acpi_platform.c:1.31 Sat Oct 23 17:45:55 2021 +++ src/sys/arch/arm/acpi/acpi_platform.c Sun Oct 24 11:58:23 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_platform.c,v 1.31 2021/10/23 17:45:55 jmcneill Exp $ */ +/* $NetBSD: acpi_platform.c,v 1.32 2021/10/24 11:58:23 jmcneill Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include "opt_multiprocessor.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.31 2021/10/23 17:45:55 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.32 2021/10/24 11:58:23 jmcneill Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -95,7 +95,20 @@ static const struct acpi_spcr_baud_rate uint8_t id; int baud_rate; } acpi_spcr_baud_rates[] = { - { SPCR_BAUD_DEFAULT, -1 }, + /* + * SPCR_BAUD_DEFAULT means: + * "As is, operating system relies on the current configuration + * of serial port until the full featured driver will be + * initialized." + * + * We don't currently have a good way of telling the UART driver + * to detect the currently configured baud rate, so just pick + * something sensible here. + * + * In the past we have tried baud_rate values of 0 and -1, but + * these cause problems with the com(4) driver. + */ + { SPCR_BAUD_DEFAULT, 115200 }, { SPCR_BAUD_9600, 9600 }, { SPCR_BAUD_19200, 19200 }, { SPCR_BAUD_57600, 57600 }, @@ -192,16 +205,27 @@ acpi_platform_attach_uart(ACPI_TABLE_SPC case ACPI_DBG2_16550_SUBSET: case ACPI_DBG2_16550_GAS: memset(&dummy_bsh, 0, sizeof(dummy_bsh)); - if (spcr->InterfaceType == ACPI_DBG2_16550_COMPATIBLE) { + switch (spcr->SerialPort.BitWidth) { + case 8: reg_shift = 0; - } else if (spcr->InterfaceType == ACPI_DBG2_16550_SUBSET) { + break; + case 16: + reg_shift = 1; + break; + case 32: reg_shift = 2; - } else { - if (ACPI_ACCESS_BIT_WIDTH(spcr->SerialPort.AccessWidth) == 8) { + break; + default: + /* + * Bit width 0 is possible for types 0 and 1. Otherwise, + * possibly buggy firmware. + */ + if (spcr->InterfaceType == ACPI_DBG2_16550_COMPATIBLE) { reg_shift = 0; } else { reg_shift = 2; } + break; } com_init_regs_stride(®s, &arm_generic_bs_tag, dummy_bsh, le64toh(spcr->SerialPort.Address), reg_shift);