git: a9fc9d6d15f0 - main - dev/uart: Support 8-byte register access

From: Andrew Turner <andrew_at_FreeBSD.org>
Date: Tue, 13 Feb 2024 11:51:54 UTC
The branch main has been updated by andrew:

URL: https://cgit.FreeBSD.org/src/commit/?id=a9fc9d6d15f006feb6d7ddb036e020d5f9d19fce

commit a9fc9d6d15f006feb6d7ddb036e020d5f9d19fce
Author:     Andrew Turner <andrew@FreeBSD.org>
AuthorDate: 2024-01-09 13:29:47 +0000
Commit:     Andrew Turner <andrew@FreeBSD.org>
CommitDate: 2024-02-13 11:48:53 +0000

    dev/uart: Support 8-byte register access
    
    While we only support 4-byte registers in the uart code the physical
    access may be to an 8-byte register. Support this as an option on
    non-i386. On i386 we lack the needed 8-byte bus_space functions.
    
    ACPI has an option for 8-byte register io width, and FDT can be given
    any size. Support these sizes, even if we don't expect to see hardware
    with an 8-byte io width.
    
    Reviewed by:    imp
    Sponsored by:   Arm Ltd
    Differential Revision:  https://reviews.freebsd.org/D43374
---
 sys/dev/uart/uart.h | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/sys/dev/uart/uart.h b/sys/dev/uart/uart.h
index 987152283c81..4cdec00c9829 100644
--- a/sys/dev/uart/uart.h
+++ b/sys/dev/uart/uart.h
@@ -56,6 +56,11 @@ uart_getreg(struct uart_bas *bas, int reg)
 	uint32_t ret;
 
 	switch (uart_regiowidth(bas)) {
+#if !defined(__i386__)
+	case 8:
+		ret = bus_space_read_8(bas->bst, bas->bsh, uart_regofs(bas, reg));
+		break;
+#endif
 	case 4:
 		ret = bus_space_read_4(bas->bst, bas->bsh, uart_regofs(bas, reg));
 		break;
@@ -71,10 +76,15 @@ uart_getreg(struct uart_bas *bas, int reg)
 }
 
 static inline void
-uart_setreg(struct uart_bas *bas, int reg, int value)
+uart_setreg(struct uart_bas *bas, int reg, uint32_t value)
 {
 
 	switch (uart_regiowidth(bas)) {
+#if !defined(__i386__)
+	case 8:
+		bus_space_write_8(bas->bst, bas->bsh, uart_regofs(bas, reg), value);
+		break;
+#endif
 	case 4:
 		bus_space_write_4(bas->bst, bas->bsh, uart_regofs(bas, reg), value);
 		break;