git: f48bd7527bba - stable/14 - uart: Split out initilisation of the acpi devinfo
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 02 Sep 2024 08:50:36 UTC
The branch stable/14 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=f48bd7527bba62d4d8019fd4bbdb966aecdbac0b commit f48bd7527bba62d4d8019fd4bbdb966aecdbac0b Author: Andrew Turner <andrew@FreeBSD.org> AuthorDate: 2024-03-12 18:06:18 +0000 Commit: Andrew Turner <andrew@FreeBSD.org> CommitDate: 2024-09-02 08:43:42 +0000 uart: Split out initilisation of the acpi devinfo Split out the common parts of building the uart devinfo from ACPI tables from the SPCR parser. This will be used when we support the DBG2 table to find the debug uart to be used by the kernel gdb stub. Reviewed by: imp Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D44357 (cherry picked from commit 473c0b44ae8c51b2aebc51887714b2ed14de50bf) --- sys/dev/uart/uart_cpu_acpi.c | 86 +++++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 37 deletions(-) diff --git a/sys/dev/uart/uart_cpu_acpi.c b/sys/dev/uart/uart_cpu_acpi.c index a0534c7af230..6805d187cb99 100644 --- a/sys/dev/uart/uart_cpu_acpi.c +++ b/sys/dev/uart/uart_cpu_acpi.c @@ -70,35 +70,10 @@ uart_cpu_acpi_scan(uint8_t interface_type) return (NULL); } -int -uart_cpu_acpi_spcr(int devtype, struct uart_devinfo *di) +static int +uart_cpu_acpi_init_devinfo(struct uart_devinfo *di, struct uart_class *class, + ACPI_GENERIC_ADDRESS *addr) { - vm_paddr_t spcr_physaddr; - ACPI_TABLE_SPCR *spcr; - struct acpi_uart_compat_data *cd; - struct uart_class *class; - int error = ENXIO; - - /* SPCR only tells us about consoles. */ - if (devtype != UART_DEV_CONSOLE) - return (error); - - /* Look for the SPCR table. */ - spcr_physaddr = acpi_find_table(ACPI_SIG_SPCR); - if (spcr_physaddr == 0) - return (error); - spcr = acpi_map_table(spcr_physaddr, ACPI_SIG_SPCR); - if (spcr == NULL) { - printf("Unable to map the SPCR table!\n"); - return (error); - } - - /* Search for information about this SPCR interface type. */ - cd = uart_cpu_acpi_scan(spcr->InterfaceType); - if (cd == NULL) - goto out; - class = cd->cd_class; - /* Fill in some fixed details. */ di->bas.chan = 0; di->bas.rclk = 0; @@ -108,7 +83,7 @@ uart_cpu_acpi_spcr(int devtype, struct uart_devinfo *di) di->ops = uart_getops(class); /* Fill in details from SPCR table. */ - switch (spcr->SerialPort.SpaceId) { + switch (addr->SpaceId) { case 0: di->bas.bst = uart_bus_space_mem; break; @@ -117,10 +92,10 @@ uart_cpu_acpi_spcr(int devtype, struct uart_devinfo *di) break; default: printf("UART in unrecognized address space: %d!\n", - (int)spcr->SerialPort.SpaceId); - goto out; + (int)addr->SpaceId); + return (ENXIO); } - switch (spcr->SerialPort.AccessWidth) { + switch (addr->AccessWidth) { case 0: /* EFI_ACPI_6_0_UNDEFINED */ /* FALLTHROUGH */ case 1: /* EFI_ACPI_6_0_BYTE */ @@ -137,10 +112,10 @@ uart_cpu_acpi_spcr(int devtype, struct uart_devinfo *di) break; default: printf("UART unsupported access width: %d!\n", - (int)spcr->SerialPort.AccessWidth); - goto out; + (int)addr->AccessWidth); + return (ENXIO); } - switch (spcr->SerialPort.BitWidth) { + switch (addr->BitWidth) { case 0: /* FALLTHROUGH */ case 8: @@ -157,9 +132,46 @@ uart_cpu_acpi_spcr(int devtype, struct uart_devinfo *di) break; default: printf("UART unsupported bit width: %d!\n", - (int)spcr->SerialPort.BitWidth); - goto out; + (int)addr->BitWidth); + return (ENXIO); } + + return (0); +} + +int +uart_cpu_acpi_spcr(int devtype, struct uart_devinfo *di) +{ + vm_paddr_t spcr_physaddr; + ACPI_TABLE_SPCR *spcr; + struct acpi_uart_compat_data *cd; + struct uart_class *class; + int error = ENXIO; + + /* SPCR only tells us about consoles. */ + if (devtype != UART_DEV_CONSOLE) + return (error); + + /* Look for the SPCR table. */ + spcr_physaddr = acpi_find_table(ACPI_SIG_SPCR); + if (spcr_physaddr == 0) + return (error); + spcr = acpi_map_table(spcr_physaddr, ACPI_SIG_SPCR); + if (spcr == NULL) { + printf("Unable to map the SPCR table!\n"); + return (error); + } + + /* Search for information about this SPCR interface type. */ + cd = uart_cpu_acpi_scan(spcr->InterfaceType); + if (cd == NULL) + goto out; + class = cd->cd_class; + + error = uart_cpu_acpi_init_devinfo(di, class, &spcr->SerialPort); + if (error != 0) + goto out; + switch (spcr->BaudRate) { case 0: /* Special value; means "keep current value unchanged". */