git: a931b85a0966 - main - uart: Add uart_cpu_acpi_setup to setup the uart
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 18 Mar 2024 16:37:56 UTC
The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=a931b85a0966a6efd6b6105b3e4176d2c98340de commit a931b85a0966a6efd6b6105b3e4176d2c98340de Author: Andrew Turner <andrew@FreeBSD.org> AuthorDate: 2024-03-14 16:43:28 +0000 Commit: Andrew Turner <andrew@FreeBSD.org> CommitDate: 2024-03-18 16:20:52 +0000 uart: Add uart_cpu_acpi_setup to setup the uart In preperation for adding debug port support add a generic function to setup the uart from ACPI tables. Reviewed by: imp Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D44358 --- sys/dev/uart/uart_cpu_acpi.c | 16 +++++++++++----- sys/dev/uart/uart_cpu_acpi.h | 4 ++-- sys/dev/uart/uart_cpu_arm64.c | 2 +- sys/dev/uart/uart_cpu_x86.c | 2 +- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/sys/dev/uart/uart_cpu_acpi.c b/sys/dev/uart/uart_cpu_acpi.c index 09f69e951e81..9c9ffc1e3194 100644 --- a/sys/dev/uart/uart_cpu_acpi.c +++ b/sys/dev/uart/uart_cpu_acpi.c @@ -138,7 +138,7 @@ uart_cpu_acpi_init_devinfo(struct uart_devinfo *di, struct uart_class *class, return (0); } -int +static int uart_cpu_acpi_spcr(int devtype, struct uart_devinfo *di) { vm_paddr_t spcr_physaddr; @@ -147,10 +147,6 @@ uart_cpu_acpi_spcr(int devtype, struct uart_devinfo *di) 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) @@ -213,3 +209,13 @@ out: acpi_unmap_table(spcr); return (error); } + +int +uart_cpu_acpi_setup(int devtype, struct uart_devinfo *di) +{ + switch(devtype) { + case UART_DEV_CONSOLE: + return (uart_cpu_acpi_spcr(devtype, di)); + } + return (ENXIO); +} diff --git a/sys/dev/uart/uart_cpu_acpi.h b/sys/dev/uart/uart_cpu_acpi.h index 816644eb08ba..94329e1f1349 100644 --- a/sys/dev/uart/uart_cpu_acpi.h +++ b/sys/dev/uart/uart_cpu_acpi.h @@ -64,7 +64,7 @@ SET_DECLARE(uart_acpi_class_set, struct acpi_uart_compat_data); #define UART_ACPI_CLASS(data) \ DATA_SET(uart_acpi_class_set, data) -/* Try to initialize UART device from SPCR data. */ -int uart_cpu_acpi_spcr(int devtype, struct uart_devinfo *di); +/* Try to initialize UART device from ACPI tables */ +int uart_cpu_acpi_setup(int devtype, struct uart_devinfo *di); #endif /* _DEV_UART_CPU_ACPI_H_ */ diff --git a/sys/dev/uart/uart_cpu_arm64.c b/sys/dev/uart/uart_cpu_arm64.c index 51b195783636..80e67e65697c 100644 --- a/sys/dev/uart/uart_cpu_arm64.c +++ b/sys/dev/uart/uart_cpu_arm64.c @@ -125,7 +125,7 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di) #ifdef DEV_ACPI /* Check if SPCR can tell us what console to use. */ - if (uart_cpu_acpi_spcr(devtype, di) == 0) + if (uart_cpu_acpi_setup(devtype, di) == 0) return (0); #endif #ifdef FDT diff --git a/sys/dev/uart/uart_cpu_x86.c b/sys/dev/uart/uart_cpu_x86.c index 63f68245f589..d152d5059786 100644 --- a/sys/dev/uart/uart_cpu_x86.c +++ b/sys/dev/uart/uart_cpu_x86.c @@ -70,7 +70,7 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di) * !late_console, we haven't set up our own page tables yet, so we * can't map ACPI tables to look at them. */ - if (late_console && uart_cpu_acpi_spcr(devtype, di) == 0) + if (late_console && uart_cpu_acpi_setup(devtype, di) == 0) return (0); #endif