From: kettenis Date: Tue, 16 Feb 2021 21:58:14 +0000 (+0000) Subject: Add support for the UART found on the Apple M1 SoC. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=af61f688ab2423cfe3fc5cf91a6dd1cbe2510122;p=openbsd Add support for the UART found on the Apple M1 SoC. ok patrick@ --- diff --git a/sys/dev/fdt/exuart.c b/sys/dev/fdt/exuart.c index df6ec34cd6d..f298bc153f7 100644 --- a/sys/dev/fdt/exuart.c +++ b/sys/dev/fdt/exuart.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exuart.c,v 1.6 2021/02/14 13:39:24 kettenis Exp $ */ +/* $OpenBSD: exuart.c,v 1.7 2021/02/16 21:58:14 kettenis Exp $ */ /* * Copyright (c) 2005 Dale Rahn * @@ -143,7 +143,8 @@ exuart_init_cons(void) struct fdt_reg reg; void *node, *root; - if ((node = fdt_find_cons("samsung,exynos4210-uart")) == NULL) + if ((node = fdt_find_cons("apple,s5l-uart")) == NULL && + (node = fdt_find_cons("samsung,exynos4210-uart")) == NULL) return; /* dtb uses serial2, qemu uses serial0 */ @@ -160,9 +161,15 @@ exuart_init_cons(void) if (fdt_get_reg(node, 0, ®)) return; - exuart_rx_fifo_cnt_mask = EXUART_UFSTAT_RX_FIFO_CNT_MASK; - exuart_rx_fifo_full = EXUART_UFSTAT_RX_FIFO_FULL; - exuart_tx_fifo_full = EXUART_UFSTAT_TX_FIFO_FULL; + if (fdt_is_compatible(node, "apple,s5l-uart")) { + exuart_rx_fifo_cnt_mask = EXUART_S5L_UFSTAT_RX_FIFO_CNT_MASK; + exuart_rx_fifo_full = EXUART_S5L_UFSTAT_RX_FIFO_FULL; + exuart_tx_fifo_full = EXUART_S5L_UFSTAT_TX_FIFO_FULL; + } else { + exuart_rx_fifo_cnt_mask = EXUART_UFSTAT_RX_FIFO_CNT_MASK; + exuart_rx_fifo_full = EXUART_UFSTAT_RX_FIFO_FULL; + exuart_tx_fifo_full = EXUART_UFSTAT_TX_FIFO_FULL; + } exuartcnattach(fdt_cons_bs_tag, reg.addr, B115200, TTYDEF_CFLAG); } @@ -172,7 +179,8 @@ exuart_match(struct device *parent, void *self, void *aux) { struct fdt_attach_args *faa = aux; - return OF_is_compatible(faa->fa_node, "samsung,exynos4210-uart"); + return (OF_is_compatible(faa->fa_node, "apple,s5l-uart") || + OF_is_compatible(faa->fa_node, "samsung,exynos4210-uart")); } void @@ -203,9 +211,15 @@ exuart_attach(struct device *parent, struct device *self, void *aux) printf(": console"); } - sc->sc_rx_fifo_cnt_mask = EXUART_UFSTAT_RX_FIFO_CNT_MASK; - sc->sc_rx_fifo_full = EXUART_UFSTAT_RX_FIFO_FULL; - sc->sc_tx_fifo_full = EXUART_UFSTAT_TX_FIFO_FULL; + if (OF_is_compatible(faa->fa_node, "apple,s5l-uart")) { + sc->sc_rx_fifo_cnt_mask = EXUART_S5L_UFSTAT_RX_FIFO_CNT_MASK; + sc->sc_rx_fifo_full = EXUART_S5L_UFSTAT_RX_FIFO_FULL; + sc->sc_tx_fifo_full = EXUART_S5L_UFSTAT_TX_FIFO_FULL; + } else { + sc->sc_rx_fifo_cnt_mask = EXUART_UFSTAT_RX_FIFO_CNT_MASK; + sc->sc_rx_fifo_full = EXUART_UFSTAT_RX_FIFO_FULL; + sc->sc_tx_fifo_full = EXUART_UFSTAT_TX_FIFO_FULL; + } /* Mask and clear interrupts. */ bus_space_write_4(sc->sc_iot, sc->sc_ioh, EXUART_UINTM, diff --git a/sys/dev/fdt/exuartreg.h b/sys/dev/fdt/exuartreg.h index fb13a96fa18..200323a1ed8 100644 --- a/sys/dev/fdt/exuartreg.h +++ b/sys/dev/fdt/exuartreg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: exuartreg.h,v 1.2 2021/02/05 00:25:19 patrick Exp $ */ +/* $OpenBSD: exuartreg.h,v 1.3 2021/02/16 21:58:14 kettenis Exp $ */ /* * Copyright (c) 2013 Patrick Wildt * @@ -86,6 +86,12 @@ #define EXUART_UFSTAT_TX_FIFO_CNT(x) (((x) >> 16) & 0xff) /* 0 when full */ #define EXUART_UFSTAT_TX_FIFO_CNT_MASK (0xff << 16) /* 0 when full */ #define EXUART_UFSTAT_TX_FIFO_FULL (0x1 << 24) +#define EXUART_S5L_UFSTAT_RX_FIFO_CNT(x) (((x) >> 0) & 0xf) /* 0 when full */ +#define EXUART_S5L_UFSTAT_RX_FIFO_CNT_MASK (0xf << 0) /* 0 when full */ +#define EXUART_S5L_UFSTAT_RX_FIFO_FULL (0x1 << 8) +#define EXUART_S5L_UFSTAT_TX_FIFO_CNT(x) (((x) >> 4) & 0xf) /* 0 when full */ +#define EXUART_S5L_UFSTAT_TX_FIFO_CNT_MASK (0xf << 4) /* 0 when full */ +#define EXUART_S5L_UFSTAT_TX_FIFO_FULL (0x1 << 9) #define EXUART_UMSTAT 0x1c #define EXUART_UMSTAT_CTS (0x1 << 0) #define EXUART_UMSTAT_DELTA_CTS (0x1 << 4)