From owner-svn-src-head@freebsd.org Wed Feb 28 15:02:28 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 88D20F2C812; Wed, 28 Feb 2018 15:02:28 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 3D2997AFD0; Wed, 28 Feb 2018 15:02:28 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1E72D1B0D6; Wed, 28 Feb 2018 15:02:28 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1SF2Sp0063680; Wed, 28 Feb 2018 15:02:28 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1SF2R0X063679; Wed, 28 Feb 2018 15:02:27 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201802281502.w1SF2R0X063679@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Wed, 28 Feb 2018 15:02:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r330111 - head/sys/dev/uart X-SVN-Group: head X-SVN-Commit-Author: andrew X-SVN-Commit-Paths: head/sys/dev/uart X-SVN-Commit-Revision: 330111 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Feb 2018 15:02:28 -0000 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 #include #include + #include +#include #include #include @@ -56,6 +58,14 @@ __FBSDID("$FreeBSD$"); #include +#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;