From nobody Mon Mar 18 16:37:55 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 4Tz0rz3FP2z5F3f4; Mon, 18 Mar 2024 16:37:55 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Tz0rz2NfFz4lFd; Mon, 18 Mar 2024 16:37:55 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1710779875; 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=cu78NRKMWoh+VMMLt+rsDfNPw29BK7matrt3ZRPq3Ic=; b=GtoRIb4ALKSjRwAqAu40fR3K9IioUkGlOstFeETbJQbM93DpP3MM1aMjmqb+B7hiOjhLJs C6Or3AYHhvCJli2dQHrKTV9/qB+iy+4EwjnA9ykDvS5bQPatMOelJkpSnno1HMDkV/I4V+ phRgVBqQNgOTQsmlugX5AfPXs2bHlEIuXUzbHcDiGLS8VgbkXP6P2F8C/KRYvVHh5VWoeZ lxeq9EbF9wHZahrGotRwWltBx8/sQTYBGvA7Iv8BX4uFCRkWw2ye7ryiMpRcXq6TriRb0J XT2HvYqdB09lghiH40OY5hdyY0leNbBV5j8+Nk42RZgk4yssX0ZhzmUGm5Bgcw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1710779875; a=rsa-sha256; cv=none; b=SQOGp3tHDbTQv7a9zuhq3Ug3zzFeofuyGwJRwhU2bTx6FTKtq5oXsC79ocMz8axa0m25pJ pVukkJ4ItnZyp36AjvDM1JHgl6MCNShjXAyAne4dQgtqGXS8WvsfO66Q4aZWNbKqZB5I8q 3yOhAuN7piDpS6qjIDv/SHTzi7yIoNutF+hu3tbcnRVRAvHPdARa49BkMxcV9un8/GcPql uTFDT+y2Uikxv/k8utiG4uTbbckAtcyq8vBpqNT1cEm8XrRFHWOsFDY7EjuczG/JzaynHq IiEsr/qtT1QO3mP3R+KQcXWUxgbRXnlPVjTUCVmVMfKDKWiCUeFALXI+xNRc3Q== 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=1710779875; 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=cu78NRKMWoh+VMMLt+rsDfNPw29BK7matrt3ZRPq3Ic=; b=Ide3skeqtKYtJZSMxOaOiqAfC2l4sij6uTyilc/thmNCxUqicV72Lydl9QPQIVmqk4HKvL tHxzZYQA/OhRPMENbdBjr+pqxoUoZAOUoXWQcueJMtLP2ZSXmDP2OHysPxGW9HYLZgVL9C 5OqIChjc3dLh/UJlcB9Y2NNZBDkbGLvLGPv9YPWpSKsFuxH2gp6d9NqFF/UfiuiEUV+Emj 5QHhLHqnjEZf3DdBjMfEFRjVRQDVUgSTuyJGpMDW8N/Rv+Z2nakmnBz4yXNI4IHHIbFslG roRUrMr+TXGY+njikUCGCqsTYcUXIjkdZZn25Ogv8m1RLj4d7crIyyqvPYyvSQ== 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 4Tz0rz1zzMzWPp; Mon, 18 Mar 2024 16:37:55 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 42IGbtok071030; Mon, 18 Mar 2024 16:37:55 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 42IGbt1T071027; Mon, 18 Mar 2024 16:37:55 GMT (envelope-from git) Date: Mon, 18 Mar 2024 16:37:55 GMT Message-Id: <202403181637.42IGbt1T071027@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Andrew Turner Subject: git: 473c0b44ae8c - main - 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: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: 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/main X-Git-Reftype: branch X-Git-Commit: 473c0b44ae8c51b2aebc51887714b2ed14de50bf Auto-Submitted: auto-generated The branch main has been updated by andrew: URL: https://cgit.FreeBSD.org/src/commit/?id=473c0b44ae8c51b2aebc51887714b2ed14de50bf commit 473c0b44ae8c51b2aebc51887714b2ed14de50bf Author: Andrew Turner AuthorDate: 2024-03-12 18:06:18 +0000 Commit: Andrew Turner CommitDate: 2024-03-18 16:20:52 +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 --- 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 9bac5a0df170..09f69e951e81 100644 --- a/sys/dev/uart/uart_cpu_acpi.c +++ b/sys/dev/uart/uart_cpu_acpi.c @@ -69,35 +69,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; @@ -107,7 +82,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; @@ -116,10 +91,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 */ @@ -136,10 +111,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: @@ -156,9 +131,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". */