From nobody Mon Sep 02 08:50:36 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 4Wy2XF2N9kz5MnlQ; Mon, 02 Sep 2024 08:50:37 +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 4Wy2XD5tmXz428H; Mon, 2 Sep 2024 08:50:36 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725267036; 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=Vkuo2mZiVYRL2/tx9RNoNpiSdDA/ISRIOEdrJFh/ins=; b=r2tfVnr5ncwLCcUpepOUVVc2fBYMagVjwb0SMw+jQszhaaYt/0LVcuifeeIsB3+ysoSJ7+ N8M9rKGhh7Y+1uVcSc9SVEXzUZ0A4NeXR8UsUC2Qc0/3bM2SXbCJlbnB9Ba9hpPLs5e9Me Yd2li9JtYE0lH+n8Z5XtmFNOOmp/31N0cfzEX9vLpqKPWtzyEBbzPYwxI11Yjh8QNgj8MV z7FzxEqqBOI14bi0VIU9/RdBHHVGN5qRiQO1/YcwAucBREw7q7gFm6QYlPfGc/zz3JUbHn 1l3iDBdt51W8KqT48IdA+xidW/dU85l5krlLjWUEsmx90noUNSrVvFogT4xXtg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1725267036; a=rsa-sha256; cv=none; b=WOFHRpWep6q33opu+Tc7miMd9Yj+aOek2nECW9dpBir1uBeY7+zvIMSm4SXWZrAhmVE+Og RnF3GW7X8HdENGUHxhGmtzqHCVddH1B4sLLdQS2nZSuUmif8sH768VAsRZkK7JIxinPpSE E/5lz63cFJb1z/lHBY1MVbtzWVe3zX/PD/AU7NyzSexlCCN42w0LqPHHaekPsw3R8UktB7 bNzj/1N0BkeH8mTubDv8w3E3YjK8ezz84SSPofxFHTyjCvN9xwS0BNGavnLh6ProQAZazq A5f/6ZZgTw5bG1ojfVl+wMyxYTq5EgTG6FgVEI7RiOHTCffmZuwmx9/ybR71XA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1725267036; 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=Vkuo2mZiVYRL2/tx9RNoNpiSdDA/ISRIOEdrJFh/ins=; b=B37eKo0eWItJTkVWx5riQ9WxPCr+FvEEZs2vpQzE7Zl5aGjgHOJ2q8q+gN8gHP0Qdse3D7 HoUxlueIgC+HKnqh6LZYisRwpVs4pnzhGIu3Jh3yeTWoMTi05zbHbQiZyaBXFWsssm95wn +AvnyRhD2XJwHeN3ghYsiK40QkSCzv9xISg4CjELdAQAJtVJOIkOJ1ofC4ic659w/+Q0Ib tm+weyI/wDxmbar8laIMGiW3t4i3z5qjV4nsaMgZkTsyePPU7/VE+IJHE30d5iD0oyLBwo IJvWpq4XvTzY2Dh1Ksu3W/B5YZ/aGUZkFEJn5JlUfvbawIQBi3tQBmjArD6JFA== 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 4Wy2XD5Q9qz14qK; Mon, 2 Sep 2024 08:50:36 +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 4828oahC006856; Mon, 2 Sep 2024 08:50:36 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4828oao9006853; Mon, 2 Sep 2024 08:50:36 GMT (envelope-from git) Date: Mon, 2 Sep 2024 08:50:36 GMT Message-Id: <202409020850.4828oao9006853@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Andrew Turner Subject: git: f48bd7527bba - stable/14 - uart: Split out initilisation of the acpi devinfo 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: andrew X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: f48bd7527bba62d4d8019fd4bbdb966aecdbac0b Auto-Submitted: auto-generated The branch stable/14 has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=f48bd7527bba62d4d8019fd4bbdb966aecdbac0b commit f48bd7527bba62d4d8019fd4bbdb966aecdbac0b Author: Andrew Turner AuthorDate: 2024-03-12 18:06:18 +0000 Commit: Andrew Turner CommitDate: 2024-09-02 08:43:42 +0000 uart: Split out initilisation of the acpi devinfo Split out the common parts of building the uart devinfo from ACPI tables from the SPCR parser. This will be used when we support the DBG2 table to find the debug uart to be used by the kernel gdb stub. Reviewed by: imp Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D44357 (cherry picked from commit 473c0b44ae8c51b2aebc51887714b2ed14de50bf) --- sys/dev/uart/uart_cpu_acpi.c | 86 +++++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 37 deletions(-) diff --git a/sys/dev/uart/uart_cpu_acpi.c b/sys/dev/uart/uart_cpu_acpi.c index a0534c7af230..6805d187cb99 100644 --- a/sys/dev/uart/uart_cpu_acpi.c +++ b/sys/dev/uart/uart_cpu_acpi.c @@ -70,35 +70,10 @@ uart_cpu_acpi_scan(uint8_t interface_type) return (NULL); } -int -uart_cpu_acpi_spcr(int devtype, struct uart_devinfo *di) +static int +uart_cpu_acpi_init_devinfo(struct uart_devinfo *di, struct uart_class *class, + ACPI_GENERIC_ADDRESS *addr) { - vm_paddr_t spcr_physaddr; - ACPI_TABLE_SPCR *spcr; - struct acpi_uart_compat_data *cd; - struct uart_class *class; - int error = ENXIO; - - /* SPCR only tells us about consoles. */ - if (devtype != UART_DEV_CONSOLE) - return (error); - - /* Look for the SPCR table. */ - spcr_physaddr = acpi_find_table(ACPI_SIG_SPCR); - if (spcr_physaddr == 0) - return (error); - spcr = acpi_map_table(spcr_physaddr, ACPI_SIG_SPCR); - if (spcr == NULL) { - printf("Unable to map the SPCR table!\n"); - return (error); - } - - /* Search for information about this SPCR interface type. */ - cd = uart_cpu_acpi_scan(spcr->InterfaceType); - if (cd == NULL) - goto out; - class = cd->cd_class; - /* Fill in some fixed details. */ di->bas.chan = 0; di->bas.rclk = 0; @@ -108,7 +83,7 @@ uart_cpu_acpi_spcr(int devtype, struct uart_devinfo *di) di->ops = uart_getops(class); /* Fill in details from SPCR table. */ - switch (spcr->SerialPort.SpaceId) { + switch (addr->SpaceId) { case 0: di->bas.bst = uart_bus_space_mem; break; @@ -117,10 +92,10 @@ uart_cpu_acpi_spcr(int devtype, struct uart_devinfo *di) break; default: printf("UART in unrecognized address space: %d!\n", - (int)spcr->SerialPort.SpaceId); - goto out; + (int)addr->SpaceId); + return (ENXIO); } - switch (spcr->SerialPort.AccessWidth) { + switch (addr->AccessWidth) { case 0: /* EFI_ACPI_6_0_UNDEFINED */ /* FALLTHROUGH */ case 1: /* EFI_ACPI_6_0_BYTE */ @@ -137,10 +112,10 @@ uart_cpu_acpi_spcr(int devtype, struct uart_devinfo *di) break; default: printf("UART unsupported access width: %d!\n", - (int)spcr->SerialPort.AccessWidth); - goto out; + (int)addr->AccessWidth); + return (ENXIO); } - switch (spcr->SerialPort.BitWidth) { + switch (addr->BitWidth) { case 0: /* FALLTHROUGH */ case 8: @@ -157,9 +132,46 @@ uart_cpu_acpi_spcr(int devtype, struct uart_devinfo *di) break; default: printf("UART unsupported bit width: %d!\n", - (int)spcr->SerialPort.BitWidth); - goto out; + (int)addr->BitWidth); + return (ENXIO); } + + return (0); +} + +int +uart_cpu_acpi_spcr(int devtype, struct uart_devinfo *di) +{ + vm_paddr_t spcr_physaddr; + ACPI_TABLE_SPCR *spcr; + struct acpi_uart_compat_data *cd; + struct uart_class *class; + int error = ENXIO; + + /* SPCR only tells us about consoles. */ + if (devtype != UART_DEV_CONSOLE) + return (error); + + /* Look for the SPCR table. */ + spcr_physaddr = acpi_find_table(ACPI_SIG_SPCR); + if (spcr_physaddr == 0) + return (error); + spcr = acpi_map_table(spcr_physaddr, ACPI_SIG_SPCR); + if (spcr == NULL) { + printf("Unable to map the SPCR table!\n"); + return (error); + } + + /* Search for information about this SPCR interface type. */ + cd = uart_cpu_acpi_scan(spcr->InterfaceType); + if (cd == NULL) + goto out; + class = cd->cd_class; + + error = uart_cpu_acpi_init_devinfo(di, class, &spcr->SerialPort); + if (error != 0) + goto out; + switch (spcr->BaudRate) { case 0: /* Special value; means "keep current value unchanged". */