From nobody Tue Oct 15 11:01:18 2024 X-Original-To: dev-commits-src-all@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 4XSWPC0wJbz5Ylhb; Tue, 15 Oct 2024 11:01:19 +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 4XSWPB6Mhxz4Wy8; Tue, 15 Oct 2024 11:01:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728990078; 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=1BEJakSBML6Sc9KYPFEQjY0Cdl9VjGg2uayeBn1QMTI=; b=tWHW5rse8ZEH6L/9oUMGmzVbTIKZonf20OupHmfCpT8/FWaAL0jefoMJbJdL9e4MKvKLRm Ng4O2V6xVJgCBB6ZhFfp3anW9doEhEllg1HdnaylKkdRi+t7sWEsSKEWk21s7JEaao3CZu U/uGjzAQ3LtvpK1g9uAeX5GH9fEXZ5ahM7DLM4anwdrNVDyZIc/OToQ3sqoudO3JMPGM6d NEYQbQRn86w1t9w6rleRRdmvcx0ttBfSCkhUKoegJZtiNq4LYJNe6DOSC5HM4NdJCcJx1R Z0clqiOPhuYiT5DiulCNqSZOigYvboRjiA5MnvBJm6nZIjhkYf13fGS9JIXg+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1728990078; 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=1BEJakSBML6Sc9KYPFEQjY0Cdl9VjGg2uayeBn1QMTI=; b=KEJyH7MRpAi9W9ewZzDZbfkXxif2dVU0/1EIu8UTx/qPn8QD6UItdA2nN4L070ryLu1AOv pvRRtyqmFKlIe9oqyFczfP1oZ79JXokQyNC3T58dtUmwDGRcfcKgCcLnSeUUbPyv3b0xUn sZF/QphCMdwCofNDsuC9k1PK97v4aIwA9s3O0XAeAWJz3YQwzIvDWRWZm/SsATGDCsFAxS wzhG4C3SZCf3WBOm12ZdjUrOc3w2J1CHdEpGe1xOoxiCymJlVQYHNp/wYWi6OX8/CZDSZ7 zsASS7GwC7A19pAn6qgUrW020Fcx18thKevrV2W7eNA+rvp/CHcIu7MuGfnmNQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1728990078; a=rsa-sha256; cv=none; b=UrDt/VNqLVI4Hplvjxpm5zzD3rX7Px/IabtWSUaJjNHKQC1zOXjjo97j0K5tgu6vYoBI// q9OgS8mQbZwTa9+YupZ+HurC6/n3Vs3nOmhqAvKQ/0daBCqDbNRRgOl+nsnTpwmoa4kOdy ygX1YSeIXSUHccjAcvMZr2usNpODFI28eHWDd4/07+qlwSGQ5xy/nO3Vs4mQlwSmufdKU5 mytphEmCxcjpAYzuySuxGF3mtKsSwyUEzm3xLL+q5D3p/5MPfHiDygDtAg4EOugSP+rii+ gAWqSpMm/C8oRIinlKpvRYSzjsF5q/CmMloInlVpUPM0ABdPTX2wUMTHmJljlg== 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 4XSWPB5hpRzKS4; Tue, 15 Oct 2024 11:01:18 +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 49FB1ItO077486; Tue, 15 Oct 2024 11:01:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 49FB1ICj077483; Tue, 15 Oct 2024 11:01:18 GMT (envelope-from git) Date: Tue, 15 Oct 2024 11:01:18 GMT Message-Id: <202410151101.49FB1ICj077483@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: 987dc68e66b7 - main - uart: Implement SPCR rev 3 and 4 for PreciseBaudrate and UartClkFreq List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@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: 987dc68e66b747815c7a78e3c3e2b5f64e885791 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=987dc68e66b747815c7a78e3c3e2b5f64e885791 commit 987dc68e66b747815c7a78e3c3e2b5f64e885791 Author: Warner Losh AuthorDate: 2024-10-15 11:00:11 +0000 Commit: Warner Losh CommitDate: 2024-10-15 11:00:11 +0000 uart: Implement SPCR rev 3 and 4 for PreciseBaudrate and UartClkFreq If we have a new enough SPCR, then use it when it provides a PreciseBaudrate and/or a UartClkFreq. Sponsored by: Netflix Reviewed by: andrew,adrian Differential Revision: https://reviews.freebsd.org/D47097 --- sys/dev/uart/uart_cpu_acpi.c | 60 ++++++++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 21 deletions(-) diff --git a/sys/dev/uart/uart_cpu_acpi.c b/sys/dev/uart/uart_cpu_acpi.c index 816738ec31d5..ce00a09fee33 100644 --- a/sys/dev/uart/uart_cpu_acpi.c +++ b/sys/dev/uart/uart_cpu_acpi.c @@ -167,28 +167,46 @@ uart_cpu_acpi_spcr(int devtype, struct uart_devinfo *di) if (error != 0) goto out; - switch (spcr->BaudRate) { - case 0: - /* Special value; means "keep current value unchanged". */ - di->baudrate = 0; - break; - case 3: - di->baudrate = 9600; - break; - case 4: - di->baudrate = 19200; - break; - case 6: - di->baudrate = 57600; - break; - case 7: - di->baudrate = 115200; - break; - default: - printf("SPCR has reserved BaudRate value: %d!\n", - (int)spcr->BaudRate); - goto out; + /* + * SPCR Rev 4 and newer allow a precise baudrate to be passed in for + * things like 1.5M or 2.0M. If we have that, then use that value, + * otherwise try to decode the older enumeration. + */ + if (spcr->Header.Revision >= 4 && spcr->PreciseBaudrate != 0) { + di->baudrate = spcr->PreciseBaudrate; + } else { + switch (spcr->BaudRate) { + case 0: + /* Special value; means "keep current value unchanged". */ + di->baudrate = 0; + break; + case 3: + di->baudrate = 9600; + break; + case 4: + di->baudrate = 19200; + break; + case 6: + di->baudrate = 57600; + break; + case 7: + di->baudrate = 115200; + break; + default: + printf("SPCR has reserved BaudRate value: %d!\n", + (int)spcr->BaudRate); + goto out; + } } + + /* + * Rev 3 and newer can specify a rclk, use it if it's there. It's + * defined to be 0 when it's not known, and we've initialized rclk to 0 + * in uart_cpu_acpi_init_devinfo, so we don't have to test for it. + */ + if (spcr->Header.Revision >= 3) + di->bas.rclk = spcr->UartClkFreq; + /* * If no rclk is set, then we will assume the BIOS has configured the * hardware at the stated baudrate, so we can use it to guess the rclk