Author: andrew
Date: Wed Feb 28 15:02:27 2018
New Revision: 330111
URL: https://svnweb.freebsd.org/changeset/base/330111

Log:
  The Arm pl011 driver assumes it's running a devicetree based system.
  It calls OF_* functions to check if it needs to implement workarounds.
  This may not be the case on arm64 where we support both FDT and ACPI.
  Fix this by checking if we are booting on FDT before calling these checks.
  
  Reviewed by:  ian
  Sponsored by: DARPA, AFRL
  Sponsored by: Cavium (Hardware)
  Differential Revision:        https://reviews.freebsd.org/D14515

Modified:
  head/sys/dev/uart/uart_dev_pl011.c

Modified: head/sys/dev/uart/uart_dev_pl011.c
==============================================================================
--- head/sys/dev/uart/uart_dev_pl011.c  Wed Feb 28 14:57:45 2018        
(r330110)
+++ head/sys/dev/uart/uart_dev_pl011.c  Wed Feb 28 15:02:27 2018        
(r330111)
@@ -36,7 +36,9 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/bus.h>
+
 #include <machine/bus.h>
+#include <machine/machdep.h>
 
 #include <dev/uart/uart.h>
 #include <dev/uart/uart_cpu.h>
@@ -56,6 +58,14 @@ __FBSDID("$FreeBSD$");
 
 #include <sys/kdb.h>
 
+#ifdef __aarch64__
+#define        IS_FDT  (arm64_bus_method == ARM64_BUS_FDT)
+#elif defined(FDT)
+#define        IS_FDT  1
+#else
+#error Unsupported configuration
+#endif
+
 /* PL011 UART registers and masks*/
 #define        UART_DR         0x00            /* Data register */
 #define        DR_FE           (1 << 8)        /* Framing error */
@@ -447,11 +457,10 @@ uart_pl011_bus_param(struct uart_softc *sc, int baudra
        return (0);
 }
 
+#ifdef FDT
 static int
-uart_pl011_bus_probe(struct uart_softc *sc)
+uart_pl011_bus_hwrev_fdt(struct uart_softc *sc)
 {
-       uint8_t hwrev;
-#ifdef FDT
        pcell_t node;
        uint32_t periphid;
 
@@ -467,19 +476,32 @@ uart_pl011_bus_probe(struct uart_softc *sc)
         */
        if (ofw_bus_is_compatible(sc->sc_dev, "brcm,bcm2835-pl011") ||
            ofw_bus_is_compatible(sc->sc_dev, "broadcom,bcm2835-uart")) {
-               hwrev = 2;
+               return (2);
        } else {
                node = ofw_bus_get_node(sc->sc_dev);
                if (OF_getencprop(node, "arm,primecell-periphid", &periphid,
                    sizeof(periphid)) > 0) {
-                       hwrev = (periphid >> 20) & 0x0f;
-               } else {
-                       hwrev = __uart_getreg(&sc->sc_bas, UART_PIDREG_2) >> 4;
+                       return ((periphid >> 20) & 0x0f);
                }
        }
-#else
-       hwrev = __uart_getreg(&sc->sc_bas, UART_PIDREG_2) >> 4;
+
+       return (-1);
+}
 #endif
+
+static int
+uart_pl011_bus_probe(struct uart_softc *sc)
+{
+       int hwrev;
+
+       hwrev = -1;
+#ifdef FDT
+       if (IS_FDT)
+               hwrev = uart_pl011_bus_hwrev_fdt(sc);
+#endif
+       if (hwrev < 0)
+               hwrev = __uart_getreg(&sc->sc_bas, UART_PIDREG_2) >> 4;
+
        if (hwrev <= 2) {
                sc->sc_rxfifosz = FIFO_RX_SIZE_R2;
                sc->sc_txfifosz = FIFO_TX_SIZE_R2;
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to