From nobody Tue Oct 15 11:01:16 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4XSWP85gCrz5YlKm; Tue, 15 Oct 2024 11:01:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4XSWP84RKjz4X9V; Tue, 15 Oct 2024 11:01:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728990076; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JSfkxuLwj1vwQwA9d01TEQcrGkiRljouvPJen2bkZMM=; b=toHEpCJKWClU77OsSoE0Fku2jLbZIHgtPup+UV/xq8V7byRnhWy+B8arxJrdeC94FBhBdY k+Shgn30gW7fmBVWTzbtKLjXrvhEMxNFrr+Bi54HOhxM2ZWz+Uzgmk2sR6NZY6KX5rO4jU 9e/MUMuthi6SHyxKu0d/dnQ6OUg/8xTCkulitG9SdnA1cUO7a5jgm9MzW0utYK64K1gzCG /qzfRBaHRGawDxabYasN1ZI/HR7yPDE/VF15zNnwtS4lXHwynNgBSjfUzPSg+FM5aqU65O Hc+t0Vs410nl5vflk3RxgV5K8wbOMKsALmaUJLW1VBvlsKZNDIZsosnwxVfKMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728990076; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=JSfkxuLwj1vwQwA9d01TEQcrGkiRljouvPJen2bkZMM=; b=Bend8XxapYUo+P/vACjhS+m0vWUKzbBX0zIR/haZ0LmBJFFUEmWAn4JpC+7pPf2ix+2jN8 de5vYldYQpswhq36VxjDoSrqsR/4eQJOpqm2qpUZsCCNdKTZcAGnWzgoGkI+VFYw4zpNUn ICA6VKpICAX3kYwdOGN6WTJyz1Cr/g5EP3wi2N+LfjTqce7p0ojA2qN2OioOxFXSNU11Ui oYj5vhig86GwomHUpjYmz+Xa2WncmilqiKIGqRZinNLdob+SKLyvUeKcY9gPm/EfAK5d5U BghQfd6504Gv1QMPQGVwOfOGmrL+6aLG4rXFTxpbEJVzDQ/w9WSC3bmwxPEpEw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728990076; a=rsa-sha256; cv=none; b=nHfo88bI1xPMU986NWzqUhrtINBqT6lvsSMLbD9wiKpudA3SW01YC2uNntCVoJPz1Rqg71 4YNsxe6e4I6X0OQtXqfXIAi8gZ4jfm+vfUDfUlMwRnaVjnVdHVaWhyb6EaWsFAPhWa+X4a J0K0ycNmKhWPCLr3nW2k8bZwunC13DynuWdDn/e6RXaHjzdS6t3DMqItaUAiN4OMaaEy0Q dMLDLlES8IioVriamfIbefWL27YRE8N69dHr+rRA9Wa74dVq7SY/9H7/GJV6HXhTAtbBHy 9ZSNB8AJcRrGFdkTs/tmNA0C2n86Z7zqWuvb1r8giV7EaaUq83hIWWxwJeqmoQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4XSWP842mgzJnX; Tue, 15 Oct 2024 11:01:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 49FB1GEx077364; Tue, 15 Oct 2024 11:01:16 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49FB1Gxc077361; Tue, 15 Oct 2024 11:01:16 GMT (envelope-from git) Date: Tue, 15 Oct 2024 11:01:16 GMT Message-Id: <202410151101.49FB1Gxc077361@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 28ce46d8625d - main - uart/pl011: Add support for computing rclk List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 28ce46d8625d127a60dd4bb4fb721e5cbbd4096c Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=28ce46d8625d127a60dd4bb4fb721e5cbbd4096c commit 28ce46d8625d127a60dd4bb4fb721e5cbbd4096c Author: Warner Losh AuthorDate: 2024-10-15 10:58:49 +0000 Commit: Warner Losh CommitDate: 2024-10-15 10:58:49 +0000 uart/pl011: Add support for computing rclk When instructed to do so, compute the rclk (baud rate generator clock) based on the currently programmed divisor and the communicated baud rate. We only do this once and only for consoles that tell us the configured rate and flag we can likely safely compute rclk. Sponsored by: Netflix Reviewed by: andrew Differential Revision: https://reviews.freebsd.org/D47077 --- sys/dev/uart/uart_dev_pl011.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sys/dev/uart/uart_dev_pl011.c b/sys/dev/uart/uart_dev_pl011.c index daba9d19704c..4f946f7c5f36 100644 --- a/sys/dev/uart/uart_dev_pl011.c +++ b/sys/dev/uart/uart_dev_pl011.c @@ -231,6 +231,24 @@ uart_pl011_param(struct uart_bas *bas, int baudrate, int databits, int stopbits, __uart_setreg(bas, UART_IFLS, FIFO_IFLS_BITS); __uart_setreg(bas, UART_CR, ctrl); + + /* + * Loader tells us to infer the rclk when it sets xo to 0 in + * hw.uart.console. The APCI SPCR code does likewise. We know the + * baudrate was set by the firmware, so calculate rclk from baudrate and + * the divisor register. If 'div' is actually 0, the resulting 0 value + * will have us fall back to other rclk methods. This method should be + * good to 5% or better because the error in baud rates needs to be + * below this for devices to communicate. + */ + if (bas->rclk == 0 && baudrate > 0 && bas->rclk_guess) { + uint32_t div; + + div = ((__uart_getreg(bas, UART_IBRD) & IBRD_BDIVINT) << 6) | + (__uart_getreg(bas, UART_FBRD) & FBRD_BDIVFRAC); + bas->rclk = (div * baudrate) / 4; + } + } static void