Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/acpi More SPCR cleanup:



details:   https://anonhg.NetBSD.org/src/rev/d2206e4a7f67
branches:  trunk
changeset: 1024448:d2206e4a7f67
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Oct 24 11:58:23 2021 +0000

description:
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.

diffstat:

 sys/arch/arm/acpi/acpi_platform.c |  38 +++++++++++++++++++++++++++++++-------
 1 files changed, 31 insertions(+), 7 deletions(-)

diffs (72 lines):

diff -r af6b31614187 -r d2206e4a7f67 sys/arch/arm/acpi/acpi_platform.c
--- a/sys/arch/arm/acpi/acpi_platform.c Sun Oct 24 11:42:57 2021 +0000
+++ b/sys/arch/arm/acpi/acpi_platform.c Sun Oct 24 11:58:23 2021 +0000
@@ -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 @@
        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 @@
        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(&regs, &arm_generic_bs_tag, dummy_bsh,
                    le64toh(spcr->SerialPort.Address), reg_shift);



Home | Main Index | Thread Index | Old Index