CVS commit: src/sys/arch/arm/acpi

2023-11-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 25 20:17:52 UTC 2023

Modified Files:
src/sys/arch/arm/acpi: gic_acpi.c

Log Message:
gicv2: Fix truncation of GICC / GICD base addresses above 4GB.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/acpi/gic_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2023-11-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 25 20:17:52 UTC 2023

Modified Files:
src/sys/arch/arm/acpi: gic_acpi.c

Log Message:
gicv2: Fix truncation of GICC / GICD base addresses above 4GB.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/acpi/gic_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/gic_acpi.c
diff -u src/sys/arch/arm/acpi/gic_acpi.c:1.7 src/sys/arch/arm/acpi/gic_acpi.c:1.8
--- src/sys/arch/arm/acpi/gic_acpi.c:1.7	Sat Aug  7 16:18:42 2021
+++ src/sys/arch/arm/acpi/gic_acpi.c	Sat Nov 25 20:17:52 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_acpi.c,v 1.7 2021/08/07 16:18:42 thorpej Exp $ */
+/* $NetBSD: gic_acpi.c,v 1.8 2023/11/25 20:17:52 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic_acpi.c,v 1.7 2021/08/07 16:18:42 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic_acpi.c,v 1.8 2023/11/25 20:17:52 jmcneill Exp $");
 
 #include 
 #include 
@@ -102,8 +102,8 @@ gic_acpi_attach(device_t parent, device_
 		return;
 	}
 
-	const bus_addr_t addr = uimin(gicd->BaseAddress, gicc->BaseAddress);
-	const bus_size_t end = uimax(gicd->BaseAddress + GICD_SIZE, gicc->BaseAddress + GICC_SIZE);
+	const bus_addr_t addr = ulmin(gicd->BaseAddress, gicc->BaseAddress);
+	const bus_size_t end = ulmax(gicd->BaseAddress + GICD_SIZE, gicc->BaseAddress + GICC_SIZE);
 	const bus_size_t size = end - addr;
 
 	error = bus_space_map(_generic_bs_tag, addr, size, 0, );



CVS commit: src/sys/arch/arm/acpi

2022-11-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Nov 16 11:54:26 UTC 2022

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2022-11-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Nov 16 11:54:26 UTC 2022

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
typo in comment


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_platform.c
diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.33 src/sys/arch/arm/acpi/acpi_platform.c:1.34
--- src/sys/arch/arm/acpi/acpi_platform.c:1.33	Tue Sep  6 11:55:51 2022
+++ src/sys/arch/arm/acpi/acpi_platform.c	Wed Nov 16 11:54:26 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.33 2022/09/06 11:55:51 skrll Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.34 2022/11/16 11:54:26 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.33 2022/09/06 11:55:51 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.34 2022/11/16 11:54:26 skrll Exp $");
 
 #include 
 #include 
@@ -250,7 +250,7 @@ acpi_platform_attach_uart(ACPI_TABLE_SPC
 	/*
 	 * UEFI firmware may leave the console in an undesireable state (wrong
 	 * foreground/background colour, etc). Reset the terminal and clear
-	 * text from the cursor to the end of the screne.
+	 * text from the cursor to the end of the screen.
 	 */
 printf_flags(TOCONS|NOTSTAMP, "\033[0m");
 printf_flags(TOCONS|NOTSTAMP, "\033[0J");



CVS commit: src/sys/arch/arm/acpi

2022-10-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 15 10:45:40 UTC 2022

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_smccc.c

Log Message:
fix indentation


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/acpi/acpi_pci_smccc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2022-10-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 15 10:45:40 UTC 2022

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_smccc.c

Log Message:
fix indentation


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/acpi/acpi_pci_smccc.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_pci_smccc.c
diff -u src/sys/arch/arm/acpi/acpi_pci_smccc.c:1.1 src/sys/arch/arm/acpi/acpi_pci_smccc.c:1.2
--- src/sys/arch/arm/acpi/acpi_pci_smccc.c:1.1	Sat Aug  7 21:27:53 2021
+++ src/sys/arch/arm/acpi/acpi_pci_smccc.c	Sat Oct 15 10:45:40 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_smccc.c,v 1.1 2021/08/07 21:27:53 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_smccc.c,v 1.2 2022/10/15 10:45:40 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2021 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_smccc.c,v 1.1 2021/08/07 21:27:53 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_smccc.c,v 1.2 2022/10/15 10:45:40 jmcneill Exp $");
 
 #include 
 #include 
@@ -84,7 +84,7 @@ acpi_pci_smccc_conf_write(pci_chipset_ta
 	}
 
 	status = pci_smccc_write(PCI_SMCCC_SBDF(ap->ap_seg, b, d, f), reg,
-PCI_SMCCC_ACCESS_32BIT, data);
+ PCI_SMCCC_ACCESS_32BIT, data);
 	if (!PCI_SMCCC_SUCCESS(status)) {
 		return EINVAL;
 	}



CVS commit: src/sys/arch/arm/acpi

2022-09-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Sep  6 11:55:52 UTC 2022

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
Use the ACPICA define ACPI_DBG2_16550_WITH_GAS


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2022-09-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Sep  6 11:55:52 UTC 2022

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
Use the ACPICA define ACPI_DBG2_16550_WITH_GAS


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_platform.c
diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.32 src/sys/arch/arm/acpi/acpi_platform.c:1.33
--- src/sys/arch/arm/acpi/acpi_platform.c:1.32	Sun Oct 24 11:58:23 2021
+++ src/sys/arch/arm/acpi/acpi_platform.c	Tue Sep  6 11:55:51 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.32 2021/10/24 11:58:23 jmcneill Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.33 2022/09/06 11:55:51 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.32 2021/10/24 11:58:23 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.33 2022/09/06 11:55:51 skrll Exp $");
 
 #include 
 #include 
@@ -83,8 +83,6 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_platfor
 
 #include 
 
-#define	ACPI_DBG2_16550_GAS			0x0012
-
 #define	SPCR_BAUD_DEFAULT			0
 #define	SPCR_BAUD_96003
 #define	SPCR_BAUD_192004
@@ -203,7 +201,7 @@ acpi_platform_attach_uart(ACPI_TABLE_SPC
 #if NCOM > 0
 	case ACPI_DBG2_16550_COMPATIBLE:
 	case ACPI_DBG2_16550_SUBSET:
-	case ACPI_DBG2_16550_GAS:
+	case ACPI_DBG2_16550_WITH_GAS:
 		memset(_bsh, 0, sizeof(dummy_bsh));
 		switch (spcr->SerialPort.BitWidth) {
 		case 8:



CVS commit: src/sys/arch/arm/acpi

2022-08-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug 13 20:08:36 UTC 2022

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
Add "nopcimsi" boot option to force legacy INTx only mode.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpipchb.c
diff -u src/sys/arch/arm/acpi/acpipchb.c:1.29 src/sys/arch/arm/acpi/acpipchb.c:1.30
--- src/sys/arch/arm/acpi/acpipchb.c:1.29	Sat Aug 13 16:44:11 2022
+++ src/sys/arch/arm/acpi/acpipchb.c	Sat Aug 13 20:08:36 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.29 2022/08/13 16:44:11 jmcneill Exp $ */
+/* $NetBSD: acpipchb.c,v 1.30 2022/08/13 20:08:36 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.29 2022/08/13 16:44:11 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.30 2022/08/13 20:08:36 jmcneill Exp $");
 
 #include 
 #include 
@@ -127,6 +127,7 @@ acpipchb_attach(device_t parent, device_
 	ACPI_INTEGER seg, nomsi;
 	ACPI_STATUS rv;
 	uint16_t bus_start;
+	int val;
 
 	sc->sc_dev = self;
 	sc->sc_memt = aa->aa_memt;
@@ -153,6 +154,10 @@ acpipchb_attach(device_t parent, device_
 	))) {
 		nomsi = 0;
 	}
+	if (get_bootconf_option(boot_args, "nopcimsi",
+BOOTOPT_TYPE_BOOLEAN, ) && val) {
+		nomsi = 1;
+	}
 
 	aprint_naive("\n");
 	aprint_normal(": PCI Express Host Bridge\n");



CVS commit: src/sys/arch/arm/acpi

2022-08-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug 13 20:08:36 UTC 2022

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
Add "nopcimsi" boot option to force legacy INTx only mode.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2022-08-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug 13 20:07:13 UTC 2022

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c

Log Message:
arm: acpi: Improve legacy INTx support.

For devices on a bus with no direct _PRT, use the raw intr pin with the
parent bridge's slot number to derive a pin number that can be used to
lookup the pin -> irq mapping in the parent bus's _PRT.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/acpi/acpi_pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_pci_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.21 src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.22
--- src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.21	Tue Dec 21 11:02:38 2021
+++ src/sys/arch/arm/acpi/acpi_pci_machdep.c	Sat Aug 13 20:07:13 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.c,v 1.21 2021/12/21 11:02:38 skrll Exp $ */
+/* $NetBSD: acpi_pci_machdep.c,v 1.22 2022/08/13 20:07:13 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018, 2020 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.21 2021/12/21 11:02:38 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.22 2022/08/13 20:07:13 jmcneill Exp $");
 
 #include 
 #include 
@@ -71,6 +71,8 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_pci_mac
 struct acpi_pci_prt {
 	u_intprt_segment;
 	u_intprt_bus;
+	u_intprt_bridge_dev;
+	boolprt_derived;
 	ACPI_HANDLE			prt_handle;
 	TAILQ_ENTRY(acpi_pci_prt)	prt_list;
 };
@@ -210,6 +212,8 @@ acpi_pci_md_attach_hook(device_t parent,
 	struct acpi_devnode *ad;
 	ACPI_HANDLE handle;
 	int seg, bus, dev, func;
+	u_int bridge_dev = 0;
+	bool derived = false;
 
 	seg = ap->ap_seg;
 	handle = NULL;
@@ -225,10 +229,13 @@ acpi_pci_md_attach_hook(device_t parent,
 		if (ad != NULL) {
 			handle = ad->ad_handle;
 		} else {
-			/* No routes defined for this bus, copy from parent */
+			/* No routes defined for this bus, derive from parent */
 			TAILQ_FOREACH(prtp, _pci_irq_routes, prt_list)
-if (prtp->prt_bus == bus) {
+if (prtp->prt_bus == bus &&
+prtp->prt_segment == seg) {
 	handle = prtp->prt_handle;
+	bridge_dev = dev;
+	derived = true;
 	break;
 }
 		}
@@ -244,8 +251,10 @@ acpi_pci_md_attach_hook(device_t parent,
 	if (handle != NULL) {
 		prt = kmem_alloc(sizeof(*prt), KM_SLEEP);
 		prt->prt_bus = pba->pba_bus;
-		prt->prt_segment = ap->ap_seg;
+		prt->prt_segment = seg;
 		prt->prt_handle = handle;
+		prt->prt_bridge_dev = bridge_dev;
+		prt->prt_derived = derived;
 		TAILQ_INSERT_TAIL(_pci_irq_routes, prt, prt_list);
 	}
 
@@ -375,6 +384,7 @@ acpi_pci_md_intr_map(const struct pci_at
 	ACPI_HANDLE linksrc;
 	ACPI_BUFFER buf;
 	void *linkdev;
+	u_int pin;
 
 	if (pa->pa_intrpin == PCI_INTERRUPT_PIN_NONE)
 		return EINVAL;
@@ -386,6 +396,21 @@ acpi_pci_md_intr_map(const struct pci_at
 	if (ACPI_FAILURE(acpi_get(prt->prt_handle, , AcpiGetIrqRoutingTable)))
 		return EIO;
 
+	/*
+	 * For busses with no direct _PRT entry, derive the pin from the
+	 * parent bridge.
+	 */
+	if (prt->prt_derived) {
+		pin = (((pa->pa_rawintrpin + prt->prt_bridge_dev) - 1) % 4) + 1;
+	} else {
+		pin = pa->pa_intrpin;
+	}
+
+	aprint_debug("%s: bus=%u pin=%u pa_rawintrpin=%u pa_intrpin=%u "
+		 "pa_intrswiz=%u prt_bridge_dev=%u\n",
+   		 __func__, pa->pa_bus, pin, pa->pa_rawintrpin,
+		 pa->pa_intrpin, pa->pa_intrswiz, prt->prt_bridge_dev);
+
 	error = ENOENT;
 	for (char *p = buf.Pointer; ; p += tab->Length) {
 		tab = (ACPI_PCI_ROUTING_TABLE *)p;
@@ -393,7 +418,7 @@ acpi_pci_md_intr_map(const struct pci_at
 			break;
 
 		if (pa->pa_device == ACPI_HIWORD(tab->Address) &&
-		(pa->pa_intrpin - 1) == (tab->Pin & 3)) {
+		(pin - 1) == (tab->Pin & 3)) {
 			if (tab->Source[0] != 0) {
 if (ACPI_FAILURE(AcpiGetHandle(ACPI_ROOT_OBJECT, tab->Source, )))
 	goto done;



CVS commit: src/sys/arch/arm/acpi

2022-08-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug 13 20:07:13 UTC 2022

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c

Log Message:
arm: acpi: Improve legacy INTx support.

For devices on a bus with no direct _PRT, use the raw intr pin with the
parent bridge's slot number to derive a pin number that can be used to
lookup the pin -> irq mapping in the parent bus's _PRT.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/acpi/acpi_pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2022-08-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug 13 16:44:11 UTC 2022

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
acpipchb: Add a kernel cmdline option to skip PCI resource assignment.

Passing "nopciconf" to the kernel will force acpipchb to skip PCI
resource assignment.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2022-08-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug 13 16:44:11 UTC 2022

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
acpipchb: Add a kernel cmdline option to skip PCI resource assignment.

Passing "nopciconf" to the kernel will force acpipchb to skip PCI
resource assignment.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpipchb.c
diff -u src/sys/arch/arm/acpi/acpipchb.c:1.28 src/sys/arch/arm/acpi/acpipchb.c:1.29
--- src/sys/arch/arm/acpi/acpipchb.c:1.28	Tue Aug 10 15:31:38 2021
+++ src/sys/arch/arm/acpi/acpipchb.c	Sat Aug 13 16:44:11 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.28 2021/08/10 15:31:38 jmcneill Exp $ */
+/* $NetBSD: acpipchb.c,v 1.29 2022/08/13 16:44:11 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.28 2021/08/10 15:31:38 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.29 2022/08/13 16:44:11 jmcneill Exp $");
 
 #include 
 #include 
@@ -44,6 +44,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v
 #include 
 
 #include 
+#include 
 
 #include 
 #include 
@@ -190,11 +191,15 @@ acpipchb_configure_bus(struct acpipchb_s
 	struct acpi_pci_context *ap = md_pc->pc_conf_v;
 	struct pciconf_resources *pcires;
 	ACPI_STATUS rv;
-	int error;
+	int error, val;
 
 	if (!acpi_pci_ignore_boot_config(sc->sc_handle)) {
 		return;
 	}
+	if (get_bootconf_option(boot_args, "nopciconf",
+BOOTOPT_TYPE_BOOLEAN, ) && val) {
+		return;
+	}
 
 	if ((ap->ap_flags & ACPI_PCI_FLAG_NO_MCFG) != 0) {
 		pcires = pciconf_resource_init();



CVS commit: src/sys/arch/arm/acpi

2021-12-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 21 11:02:39 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c

Log Message:
Remove unneeded struct acpi_pci_intr forward declaration.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/acpi/acpi_pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_pci_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.20 src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.21
--- src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.20	Sun Aug  8 12:09:52 2021
+++ src/sys/arch/arm/acpi/acpi_pci_machdep.c	Tue Dec 21 11:02:38 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.c,v 1.20 2021/08/08 12:09:52 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_machdep.c,v 1.21 2021/12/21 11:02:38 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018, 2020 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.20 2021/08/08 12:09:52 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.21 2021/12/21 11:02:38 skrll Exp $");
 
 #include 
 #include 
@@ -86,8 +86,6 @@ struct acpi_pci_pct {
 static TAILQ_HEAD(, acpi_pci_pct) acpi_pci_chipset_tags =
 TAILQ_HEAD_INITIALIZER(acpi_pci_chipset_tags);
 
-struct acpi_pci_intr;
-
 struct acpi_pci_intr {
 	struct pic_softc		pi_pic;
 	intpi_irqbase;



CVS commit: src/sys/arch/arm/acpi

2021-12-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Dec 21 11:02:39 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c

Log Message:
Remove unneeded struct acpi_pci_intr forward declaration.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/acpi/acpi_pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2021-11-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Nov 24 10:01:24 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: cpu_acpi.c

Log Message:
arm64: acpi: Set capacity_dmips_mhz for CPUs

The GICC structure describes a relative power efficiency for each
processor. Use this value as-is for the capacity_dmips_mhz value of a
cpu. This makes the assumption that "more efficient" means "slower".


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/acpi/cpu_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/cpu_acpi.c
diff -u src/sys/arch/arm/acpi/cpu_acpi.c:1.11 src/sys/arch/arm/acpi/cpu_acpi.c:1.12
--- src/sys/arch/arm/acpi/cpu_acpi.c:1.11	Sun Oct 17 12:41:05 2021
+++ src/sys/arch/arm/acpi/cpu_acpi.c	Wed Nov 24 10:01:24 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_acpi.c,v 1.11 2021/10/17 12:41:05 jmcneill Exp $ */
+/* $NetBSD: cpu_acpi.c,v 1.12 2021/11/24 10:01:24 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_acpi.c,v 1.11 2021/10/17 12:41:05 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_acpi.c,v 1.12 2021/11/24 10:01:24 jmcneill Exp $");
 
 #include 
 #include 
@@ -93,6 +93,7 @@ cpu_acpi_match(device_t parent, cfdata_t
 static void
 cpu_acpi_attach(device_t parent, device_t self, void *aux)
 {
+	prop_dictionary_t dict = device_properties(self);
 	ACPI_MADT_GENERIC_INTERRUPT *gicc = aux;
 	const uint64_t mpidr = gicc->ArmMpidr;
 	const int unit = device_unit(self);
@@ -123,6 +124,10 @@ cpu_acpi_attach(device_t parent, device_
 	}
 #endif /* MULTIPROCESSOR */
 
+	/* Assume that less efficient processors are faster. */
+	prop_dictionary_set_uint32(dict, "capacity_dmips_mhz",
+	gicc->EfficiencyClass);
+
 	/* Store the ACPI Processor UID in cpu_info */
 	ci->ci_acpiid = gicc->Uid;
 



CVS commit: src/sys/arch/arm/acpi

2021-11-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Nov 24 10:01:24 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: cpu_acpi.c

Log Message:
arm64: acpi: Set capacity_dmips_mhz for CPUs

The GICC structure describes a relative power efficiency for each
processor. Use this value as-is for the capacity_dmips_mhz value of a
cpu. This makes the assumption that "more efficient" means "slower".


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/acpi/cpu_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2021-10-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 24 11:58:23 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
More SPCR cleanup:

 - For 16550 style UARTs, always honour GAS if BitWidth != 0
 - Use BitWidth instead of AccessWidth to determine register stride
 - For baud rate ID of 0, assume 115200 until we have a way of probing
   the baud rate configured by firmware.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2021-10-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 24 11:58:23 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
More SPCR cleanup:

 - For 16550 style UARTs, always honour GAS if BitWidth != 0
 - Use BitWidth instead of AccessWidth to determine register stride
 - For baud rate ID of 0, assume 115200 until we have a way of probing
   the baud rate configured by firmware.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_platform.c
diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.31 src/sys/arch/arm/acpi/acpi_platform.c:1.32
--- src/sys/arch/arm/acpi/acpi_platform.c:1.31	Sat Oct 23 17:45:55 2021
+++ src/sys/arch/arm/acpi/acpi_platform.c	Sun Oct 24 11:58:23 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.31 2021/10/23 17:45:55 jmcneill Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.32 2021/10/24 11:58:23 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.31 2021/10/23 17:45:55 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.32 2021/10/24 11:58:23 jmcneill Exp $");
 
 #include 
 #include 
@@ -95,7 +95,20 @@ static const struct acpi_spcr_baud_rate 
 	uint8_t		id;
 	int		baud_rate;
 } acpi_spcr_baud_rates[] = {
-	{ SPCR_BAUD_DEFAULT,	-1 },
+	/*
+	 * SPCR_BAUD_DEFAULT means:
+	 *   "As is, operating system relies on the current configuration
+	 *of serial port until the full featured driver will be
+	 *initialized."
+	 *
+	 * We don't currently have a good way of telling the UART driver
+	 * to detect the currently configured baud rate, so just pick
+	 * something sensible here.
+	 *
+	 * In the past we have tried baud_rate values of 0 and -1, but
+	 * these cause problems with the com(4) driver.
+	 */
+	{ SPCR_BAUD_DEFAULT,	115200 },
 	{ SPCR_BAUD_9600,	9600 },
 	{ SPCR_BAUD_19200,	19200 },
 	{ SPCR_BAUD_57600,	57600 },
@@ -192,16 +205,27 @@ acpi_platform_attach_uart(ACPI_TABLE_SPC
 	case ACPI_DBG2_16550_SUBSET:
 	case ACPI_DBG2_16550_GAS:
 		memset(_bsh, 0, sizeof(dummy_bsh));
-		if (spcr->InterfaceType == ACPI_DBG2_16550_COMPATIBLE) {
+		switch (spcr->SerialPort.BitWidth) {
+		case 8:
 			reg_shift = 0;
-		} else if (spcr->InterfaceType == ACPI_DBG2_16550_SUBSET) {
+			break;
+		case 16:
+			reg_shift = 1;
+			break;
+		case 32:
 			reg_shift = 2;
-		} else {
-			if (ACPI_ACCESS_BIT_WIDTH(spcr->SerialPort.AccessWidth) == 8) {
+			break;
+		default:
+			/*
+			 * Bit width 0 is possible for types 0 and 1. Otherwise,
+			 * possibly buggy firmware.
+			 */
+			if (spcr->InterfaceType == ACPI_DBG2_16550_COMPATIBLE) {
 reg_shift = 0;
 			} else {
 reg_shift = 2;
 			}
+			break;
 		}
 		com_init_regs_stride(, _generic_bs_tag, dummy_bsh,
 		le64toh(spcr->SerialPort.Address), reg_shift);



CVS commit: src/sys/arch/arm/acpi

2021-10-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 23 17:45:55 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
It seems that there are three 16550 types for SPCR:

 - 0x: Fully 16550-compatible (1-byte I/O)
 - 0x0001: 16550 subset compatible with DBGP Revision 1 (4-byte MMIO)
 - 0x0012: 16550-compatible with parameters defined in GAS

So assume reg_width for types 0 and 1, and only look at GAS for type 12h.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_platform.c
diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.30 src/sys/arch/arm/acpi/acpi_platform.c:1.31
--- src/sys/arch/arm/acpi/acpi_platform.c:1.30	Thu Oct 21 00:09:28 2021
+++ src/sys/arch/arm/acpi/acpi_platform.c	Sat Oct 23 17:45:55 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.30 2021/10/21 00:09:28 jmcneill Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.31 2021/10/23 17:45:55 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.30 2021/10/21 00:09:28 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.31 2021/10/23 17:45:55 jmcneill Exp $");
 
 #include 
 #include 
@@ -83,6 +83,8 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_platfor
 
 #include 
 
+#define	ACPI_DBG2_16550_GAS			0x0012
+
 #define	SPCR_BAUD_DEFAULT			0
 #define	SPCR_BAUD_96003
 #define	SPCR_BAUD_192004
@@ -188,11 +190,18 @@ acpi_platform_attach_uart(ACPI_TABLE_SPC
 #if NCOM > 0
 	case ACPI_DBG2_16550_COMPATIBLE:
 	case ACPI_DBG2_16550_SUBSET:
+	case ACPI_DBG2_16550_GAS:
 		memset(_bsh, 0, sizeof(dummy_bsh));
-		if (ACPI_ACCESS_BIT_WIDTH(spcr->SerialPort.AccessWidth) == 8) {
+		if (spcr->InterfaceType == ACPI_DBG2_16550_COMPATIBLE) {
 			reg_shift = 0;
-		} else {
+		} else if (spcr->InterfaceType == ACPI_DBG2_16550_SUBSET) {
 			reg_shift = 2;
+		} else {
+			if (ACPI_ACCESS_BIT_WIDTH(spcr->SerialPort.AccessWidth) == 8) {
+reg_shift = 0;
+			} else {
+reg_shift = 2;
+			}
 		}
 		com_init_regs_stride(, _generic_bs_tag, dummy_bsh,
 		le64toh(spcr->SerialPort.Address), reg_shift);



CVS commit: src/sys/arch/arm/acpi

2021-10-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 23 17:45:55 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
It seems that there are three 16550 types for SPCR:

 - 0x: Fully 16550-compatible (1-byte I/O)
 - 0x0001: 16550 subset compatible with DBGP Revision 1 (4-byte MMIO)
 - 0x0012: 16550-compatible with parameters defined in GAS

So assume reg_width for types 0 and 1, and only look at GAS for type 12h.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2021-10-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 21 00:09:28 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
baud_rate is signed now


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_platform.c
diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.29 src/sys/arch/arm/acpi/acpi_platform.c:1.30
--- src/sys/arch/arm/acpi/acpi_platform.c:1.29	Wed Oct 20 23:03:40 2021
+++ src/sys/arch/arm/acpi/acpi_platform.c	Thu Oct 21 00:09:28 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.29 2021/10/20 23:03:40 jakllsch Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.30 2021/10/21 00:09:28 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.29 2021/10/20 23:03:40 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.30 2021/10/21 00:09:28 jmcneill Exp $");
 
 #include 
 #include 
@@ -91,7 +91,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_platfor
 
 static const struct acpi_spcr_baud_rate {
 	uint8_t		id;
-	uint32_t	baud_rate;
+	int		baud_rate;
 } acpi_spcr_baud_rates[] = {
 	{ SPCR_BAUD_DEFAULT,	-1 },
 	{ SPCR_BAUD_9600,	9600 },



CVS commit: src/sys/arch/arm/acpi

2021-10-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 21 00:09:28 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
baud_rate is signed now


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2021-10-20 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Wed Oct 20 23:03:40 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
SPCR_BAUD_DEFAULT maps better to -1 than 0

Suggested by jmcneill@


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_platform.c
diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.28 src/sys/arch/arm/acpi/acpi_platform.c:1.29
--- src/sys/arch/arm/acpi/acpi_platform.c:1.28	Sat Aug  7 21:24:56 2021
+++ src/sys/arch/arm/acpi/acpi_platform.c	Wed Oct 20 23:03:40 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.28 2021/08/07 21:24:56 jmcneill Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.29 2021/10/20 23:03:40 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.28 2021/08/07 21:24:56 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.29 2021/10/20 23:03:40 jakllsch Exp $");
 
 #include 
 #include 
@@ -93,7 +93,7 @@ static const struct acpi_spcr_baud_rate 
 	uint8_t		id;
 	uint32_t	baud_rate;
 } acpi_spcr_baud_rates[] = {
-	{ SPCR_BAUD_DEFAULT,	0 },
+	{ SPCR_BAUD_DEFAULT,	-1 },
 	{ SPCR_BAUD_9600,	9600 },
 	{ SPCR_BAUD_19200,	19200 },
 	{ SPCR_BAUD_57600,	57600 },



CVS commit: src/sys/arch/arm/acpi

2021-10-20 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Wed Oct 20 23:03:40 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
SPCR_BAUD_DEFAULT maps better to -1 than 0

Suggested by jmcneill@


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2021-10-17 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 17 12:41:06 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: cpu_acpi.c

Log Message:
Fix primary CPU detection in cpu_acpi_tprof_intr_establish


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/acpi/cpu_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/cpu_acpi.c
diff -u src/sys/arch/arm/acpi/cpu_acpi.c:1.10 src/sys/arch/arm/acpi/cpu_acpi.c:1.11
--- src/sys/arch/arm/acpi/cpu_acpi.c:1.10	Sat Jan 23 12:34:19 2021
+++ src/sys/arch/arm/acpi/cpu_acpi.c	Sun Oct 17 12:41:05 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_acpi.c,v 1.10 2021/01/23 12:34:19 jmcneill Exp $ */
+/* $NetBSD: cpu_acpi.c,v 1.11 2021/10/17 12:41:05 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_acpi.c,v 1.10 2021/01/23 12:34:19 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_acpi.c,v 1.11 2021/10/17 12:41:05 jmcneill Exp $");
 
 #include 
 #include 
@@ -168,7 +168,7 @@ cpu_acpi_tprof_intr_establish(ACPI_SUBTA
 	if ((gicc->Flags & ACPI_MADT_ENABLED) == 0)
 		return AE_OK;
 
-	const bool cpu_primary_p = cpu_mpidr_aff_read() == gicc->ArmMpidr;
+	const bool cpu_primary_p = cpu_info_store[0].ci_cpuid == gicc->ArmMpidr;
 	const bool intr_ppi_p = gicc->PerformanceInterrupt < 32;
 	const int type = (gicc->Flags & ACPI_MADT_PERFORMANCE_IRQ_MODE) ?
 	IST_EDGE : IST_LEVEL;



CVS commit: src/sys/arch/arm/acpi

2021-10-17 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 17 12:41:06 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: cpu_acpi.c

Log Message:
Fix primary CPU detection in cpu_acpi_tprof_intr_establish


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/acpi/cpu_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2021-08-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Aug 10 15:31:38 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
Disable MSI if the linux,pcie-nomsi flag is present


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2021-08-10 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Aug 10 15:31:38 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
Disable MSI if the linux,pcie-nomsi flag is present


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpipchb.c
diff -u src/sys/arch/arm/acpi/acpipchb.c:1.27 src/sys/arch/arm/acpi/acpipchb.c:1.28
--- src/sys/arch/arm/acpi/acpipchb.c:1.27	Sat Aug  7 21:27:53 2021
+++ src/sys/arch/arm/acpi/acpipchb.c	Tue Aug 10 15:31:38 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.27 2021/08/07 21:27:53 jmcneill Exp $ */
+/* $NetBSD: acpipchb.c,v 1.28 2021/08/10 15:31:38 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.27 2021/08/07 21:27:53 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.28 2021/08/10 15:31:38 jmcneill Exp $");
 
 #include 
 #include 
@@ -123,7 +123,7 @@ acpipchb_attach(device_t parent, device_
 	struct acpipchb_softc * const sc = device_private(self);
 	struct acpi_attach_args *aa = aux;
 	struct pcibus_attach_args pba;
-	ACPI_INTEGER seg;
+	ACPI_INTEGER seg, nomsi;
 	ACPI_STATUS rv;
 	uint16_t bus_start;
 
@@ -148,6 +148,11 @@ acpipchb_attach(device_t parent, device_
 		seg = 0;
 	}
 
+	if (ACPI_FAILURE(acpi_dsd_integer(sc->sc_handle, "linux,pcie-nomsi",
+	))) {
+		nomsi = 0;
+	}
+
 	aprint_naive("\n");
 	aprint_normal(": PCI Express Host Bridge\n");
 
@@ -156,6 +161,9 @@ acpipchb_attach(device_t parent, device_
 	memset(, 0, sizeof(pba));
 	pba.pba_flags = aa->aa_pciflags &
 			~(PCI_FLAGS_MEM_OKAY | PCI_FLAGS_IO_OKAY);
+	if (nomsi) {
+		pba.pba_flags &= ~(PCI_FLAGS_MSI_OKAY | PCI_FLAGS_MSIX_OKAY);
+	}
 	pba.pba_memt = 0;
 	pba.pba_iot = 0;
 	pba.pba_dmat = aa->aa_dmat;



CVS commit: src/sys/arch/arm/acpi

2021-08-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug  8 12:09:52 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c

Log Message:
Install the shared PCI INTx interrupt handler at IPL_VM to workaround a
possible interrupt storm at boot. Need to revisit this.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/acpi/acpi_pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2021-08-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug  8 12:09:52 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c

Log Message:
Install the shared PCI INTx interrupt handler at IPL_VM to workaround a
possible interrupt storm at boot. Need to revisit this.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/acpi/acpi_pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_pci_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.19 src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.20
--- src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.19	Sat Aug  7 21:27:53 2021
+++ src/sys/arch/arm/acpi/acpi_pci_machdep.c	Sun Aug  8 12:09:52 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.c,v 1.19 2021/08/07 21:27:53 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_machdep.c,v 1.20 2021/08/08 12:09:52 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018, 2020 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.19 2021/08/07 21:27:53 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.20 2021/08/08 12:09:52 jmcneill Exp $");
 
 #include 
 #include 
@@ -536,7 +536,7 @@ acpi_pci_md_intr_establish(void *v, pci_
 		pi->pi_pic.pic_ops = _pci_pic_ops;
 		pi->pi_irqbase = pic_add(>pi_pic, PIC_IRQBASE_ALLOC);
 		TAILQ_INSERT_TAIL(_pci_intrs, pi, pi_list);
-		pi->pi_ih = intr_establish_xname(irq, IPL_SCHED, IST_LEVEL | IST_MPSAFE,
+		pi->pi_ih = intr_establish_xname(irq, IPL_VM, IST_LEVEL | IST_MPSAFE,
 		pic_handle_intr, >pi_pic, device_xname(ap->ap_dev));
 	}
 	if (pi->pi_ih == NULL)



CVS commit: src/sys/arch/arm/acpi

2021-08-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug  8 10:28:26 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_machdep.c

Log Message:
arm: ACPI: Add support for simple sharing of platform interrupts

Allow sharing of platform interrupts provided that the type, ipl, and
mpsafe-ness are the same.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/acpi/acpi_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_machdep.c:1.24 src/sys/arch/arm/acpi/acpi_machdep.c:1.25
--- src/sys/arch/arm/acpi/acpi_machdep.c:1.24	Sat Aug  7 18:40:45 2021
+++ src/sys/arch/arm/acpi/acpi_machdep.c	Sun Aug  8 10:28:26 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.24 2021/08/07 18:40:45 jmcneill Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.25 2021/08/08 10:28:26 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.24 2021/08/07 18:40:45 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.25 2021/08/08 10:28:26 jmcneill Exp $");
 
 #include 
 #include 
@@ -63,6 +63,27 @@ extern struct bus_space arm_generic_bs_t
 extern struct arm32_bus_dma_tag acpi_coherent_dma_tag;
 extern struct arm32_bus_dma_tag arm_generic_dma_tag;
 
+struct acpi_intrhandler {
+	int(*ah_fn)(void *);
+	void*ah_arg;
+	TAILQ_ENTRY(acpi_intrhandler)	ah_list;
+};
+
+struct acpi_intrvec {
+	intai_irq;
+	intai_ipl;
+	intai_type;
+	boolai_mpsafe;
+	intai_refcnt;
+	void*ai_arg;
+	void*ai_ih;
+	TAILQ_HEAD(, acpi_intrhandler)	ai_handlers;
+	TAILQ_ENTRY(acpi_intrvec)	ai_list;
+};
+
+static TAILQ_HEAD(, acpi_intrvec) acpi_intrvecs =
+TAILQ_HEAD_INITIALIZER(acpi_intrvecs);
+
 bus_dma_tag_t	arm_acpi_dma32_tag(struct acpi_softc *, struct acpi_devnode *);
 bus_dma_tag_t	arm_acpi_dma64_tag(struct acpi_softc *, struct acpi_devnode *);
 
@@ -256,28 +277,128 @@ acpi_md_OsDisableInterrupt(void)
 	cpsid(I32_bit);
 }
 
+static struct acpi_intrvec *
+acpi_md_intr_lookup(int irq)
+{
+	struct acpi_intrvec *ai;
+
+	TAILQ_FOREACH(ai, _intrvecs, ai_list) {
+		if (ai->ai_irq == irq) {
+			return ai;
+		}
+	}
+
+	return NULL;
+}
+
+static int
+acpi_md_intr(void *arg)
+{
+	struct acpi_intrvec *ai = arg;
+	struct acpi_intrhandler *ah;
+	int rv = 0;
+
+	TAILQ_FOREACH(ah, >ai_handlers, ah_list) {
+		rv += ah->ah_fn(ah->ah_arg);
+	}
+
+	return rv;
+}
+
 void *
 acpi_md_intr_establish(uint32_t irq, int ipl, int type, int (*handler)(void *), void *arg, bool mpsafe, const char *xname)
 {
-	return intr_establish_xname(irq, ipl, type | (mpsafe ? IST_MPSAFE : 0), handler, arg, xname);
+	struct acpi_intrvec *ai;
+	struct acpi_intrhandler *ah;
+
+	ai = acpi_md_intr_lookup(irq);
+	if (ai == NULL) {
+		ai = kmem_zalloc(sizeof(*ai), KM_SLEEP);
+		ai->ai_refcnt = 0;
+		ai->ai_irq = irq;
+		ai->ai_ipl = ipl;
+		ai->ai_type = type;
+		ai->ai_mpsafe = mpsafe;
+		ai->ai_arg = arg;
+		TAILQ_INIT(>ai_handlers);
+		if (arg == NULL) {
+			ai->ai_ih = intr_establish_xname(irq, ipl,
+			type | (mpsafe ? IST_MPSAFE : 0), handler, NULL,
+			xname);
+		} else {
+			ai->ai_ih = intr_establish_xname(irq, ipl,
+			type | (mpsafe ? IST_MPSAFE : 0), acpi_md_intr, ai,
+			xname);
+		}
+		if (ai->ai_ih == NULL) {
+			kmem_free(ai, sizeof(*ai));
+			return NULL;
+		}
+		TAILQ_INSERT_TAIL(_intrvecs, ai, ai_list);
+	} else {
+		if (ai->ai_arg == NULL) {
+			printf("ACPI: cannot share irq with NULL arg\n");
+			return NULL;
+		}
+		if (ai->ai_ipl != ipl) {
+			printf("ACPI: cannot share irq with different ipl\n");
+			return NULL;
+		}
+		if (ai->ai_type != type) {
+			printf("ACPI: cannot share edge and level interrupts\n");
+			return NULL;
+		}
+		if (ai->ai_mpsafe != mpsafe) {
+			printf("ACPI: cannot share between mpsafe/non-mpsafe\n");
+			return NULL;
+		}
+	}
+
+	ai->ai_refcnt++;
+
+	ah = kmem_zalloc(sizeof(*ah), KM_SLEEP);
+	ah->ah_fn = handler;
+	ah->ah_arg = arg;
+	TAILQ_INSERT_TAIL(>ai_handlers, ah, ah_list);
+
+	return ai->ai_ih;
 }
 
 void
-acpi_md_intr_mask(void *ih)
+acpi_md_intr_disestablish(void *ih)
 {
-	intr_mask(ih);
+	struct acpi_intrvec *ai;
+	struct acpi_intrhandler *ah;
+
+	TAILQ_FOREACH(ai, _intrvecs, ai_list) {
+		if (ai->ai_ih == ih) {
+			KASSERT(ai->ai_refcnt > 0);
+			if (ai->ai_refcnt > 1) {
+panic("%s: cannot disestablish shared irq", __func__);
+			}
+
+			TAILQ_REMOVE(_intrvecs, ai, ai_list);
+			ah = TAILQ_FIRST(>ai_handlers);
+			kmem_free(ah, sizeof(*ah));
+			intr_disestablish(ai->ai_ih);
+			kmem_free(ai, sizeof(*ai));
+			return;
+		}
+	}
+
+	panic("%s: interrupt not established", __func__);
 }
 
 void
-acpi_md_intr_unmask(void *ih)
+acpi_md_intr_mask(void *ih)
 {
-	intr_unmask(ih);
+	intr_mask(ih);
 }
 
 void
-acpi_md_intr_disestablish(void *ih)
+acpi_md_intr_unmask(void *ih)

CVS commit: src/sys/arch/arm/acpi

2021-08-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug  8 10:28:26 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_machdep.c

Log Message:
arm: ACPI: Add support for simple sharing of platform interrupts

Allow sharing of platform interrupts provided that the type, ipl, and
mpsafe-ness are the same.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/acpi/acpi_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2021-08-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug  7 21:27:53 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c acpi_pci_machdep.h acpipchb.c
files.acpi
Added Files:
src/sys/arch/arm/acpi: acpi_pci_smccc.c

Log Message:
arm: acpi: Add support for SMCCC based PCI config access.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/acpi/acpi_pci_machdep.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/acpi/acpi_pci_machdep.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/acpi/acpi_pci_smccc.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/acpi/acpipchb.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/acpi/files.acpi

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_pci_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.18 src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.19
--- src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.18	Wed Jun 17 06:45:09 2020
+++ src/sys/arch/arm/acpi/acpi_pci_machdep.c	Sat Aug  7 21:27:53 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.c,v 1.18 2020/06/17 06:45:09 thorpej Exp $ */
+/* $NetBSD: acpi_pci_machdep.c,v 1.19 2021/08/07 21:27:53 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018, 2020 The NetBSD Foundation, Inc.
@@ -29,10 +29,12 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "opt_pci.h"
+
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.18 2020/06/17 06:45:09 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.19 2021/08/07 21:27:53 jmcneill Exp $");
 
 #include 
 #include 
@@ -60,6 +62,10 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_pci_mac
 #include 
 #include 
 
+#ifdef PCI_SMCCC
+#include 
+#endif
+
 #include 
 
 struct acpi_pci_prt {
@@ -94,7 +100,7 @@ struct acpi_pci_intr {
 static TAILQ_HEAD(, acpi_pci_intr) acpi_pci_intrs =
 TAILQ_HEAD_INITIALIZER(acpi_pci_intrs);
 
-static const struct acpi_pci_quirk acpi_pci_quirks[] = {
+static const struct acpi_pci_quirk acpi_pci_mcfg_quirks[] = {
 	/* OEM ID	OEM Table ID	Revision	Seg	Func */
 	{ "AMAZON",	"GRAVITON",	0,		-1,	acpi_pci_graviton_init },
 	{ "ARMLTD",	"ARMN1SDP",	0x20181101,	0,	acpi_pci_n1sdp_init },
@@ -102,6 +108,13 @@ static const struct acpi_pci_quirk acpi_
 	{ "NXP   ", "LX2160  ", 0,  -1,	acpi_pci_layerscape_gen4_init },
 };
 
+#ifdef PCI_SMCCC
+static const struct acpi_pci_quirk acpi_pci_smccc_quirk = {
+	.q_segment = -1,
+	.q_init = acpi_pci_smccc_init,
+};
+#endif
+
 pci_chipset_tag_t acpi_pci_md_get_chipset_tag(struct acpi_softc *, int, int);
 
 static void	acpi_pci_md_attach_hook(device_t, device_t,
@@ -554,11 +567,19 @@ acpi_pci_md_find_quirk(int seg)
 	u_int n;
 
 	rv = AcpiGetTable(ACPI_SIG_MCFG, 0, (ACPI_TABLE_HEADER **));
-	if (ACPI_FAILURE(rv))
+	if (ACPI_FAILURE(rv)) {
+#ifdef PCI_SMCCC
+		uint32_t ver = pci_smccc_version();
+		aprint_debug("%s: SMCCC version %#x\n", __func__, ver);
+		if (PCI_SMCCC_SUCCESS(ver)) {
+			return _pci_smccc_quirk;
+		}
+#endif
 		return NULL;
+	}
 
-	for (n = 0; n < __arraycount(acpi_pci_quirks); n++) {
-		const struct acpi_pci_quirk *q = _pci_quirks[n];
+	for (n = 0; n < __arraycount(acpi_pci_mcfg_quirks); n++) {
+		const struct acpi_pci_quirk *q = _pci_mcfg_quirks[n];
 		if (memcmp(q->q_oemid, mcfg->Header.OemId, ACPI_OEM_ID_SIZE) == 0 &&
 		memcmp(q->q_oemtableid, mcfg->Header.OemTableId, ACPI_OEM_TABLE_ID_SIZE) == 0 &&
 		q->q_oemrevision == mcfg->Header.OemRevision &&
@@ -589,6 +610,7 @@ acpi_pci_md_get_chipset_tag(struct acpi_
 		pct->pct_ap.ap_pc.pc_intr_v = >pct_ap;
 		pct->pct_ap.ap_seg = seg;
 		pct->pct_ap.ap_bus = bbn;
+		pct->pct_ap.ap_maxbus = -1;
 		pct->pct_ap.ap_bst = acpi_softc->sc_memt;
 
 		q = acpi_pci_md_find_quirk(seg);

Index: src/sys/arch/arm/acpi/acpi_pci_machdep.h
diff -u src/sys/arch/arm/acpi/acpi_pci_machdep.h:1.7 src/sys/arch/arm/acpi/acpi_pci_machdep.h:1.8
--- src/sys/arch/arm/acpi/acpi_pci_machdep.h:1.7	Sat Feb  1 13:26:43 2020
+++ src/sys/arch/arm/acpi/acpi_pci_machdep.h	Sat Aug  7 21:27:53 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.h,v 1.7 2020/02/01 13:26:43 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_machdep.h,v 1.8 2021/08/07 21:27:53 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -39,12 +39,15 @@ struct acpi_pci_context {
 	device_t ap_dev;
 	u_int ap_seg;
 	int ap_bus;
+	int ap_maxbus;
 	bus_space_tag_t ap_bst;
 	bus_space_handle_t ap_conf_bsh;
 	int (*ap_conf_read)(pci_chipset_tag_t, pcitag_t, int, pcireg_t *);
 	int (*ap_conf_write)(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
 	void *ap_conf_priv;
 	int ap_pciflags_clear;
+	u_int ap_flags;
+#define	ACPI_PCI_FLAG_NO_MCFG		__BIT(0)	/* ignore MCFG table */
 };
 
 struct acpi_pci_quirk {
@@ -57,6 +60,7 @@ struct acpi_pci_quirk {
 
 const struct acpi_pci_quirk *	acpi_pci_md_find_quirk(int);
 
+void	acpi_pci_smccc_init(struct acpi_pci_context *);
 void	

CVS commit: src/sys/arch/arm/acpi

2021-08-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug  7 21:27:53 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c acpi_pci_machdep.h acpipchb.c
files.acpi
Added Files:
src/sys/arch/arm/acpi: acpi_pci_smccc.c

Log Message:
arm: acpi: Add support for SMCCC based PCI config access.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/acpi/acpi_pci_machdep.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/acpi/acpi_pci_machdep.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/acpi/acpi_pci_smccc.c
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/arm/acpi/acpipchb.c
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/acpi/files.acpi

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2021-08-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug  7 21:24:56 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
acpi: call smccc_probe() after PSCI init


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_platform.c
diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.27 src/sys/arch/arm/acpi/acpi_platform.c:1.28
--- src/sys/arch/arm/acpi/acpi_platform.c:1.27	Fri Aug  6 19:38:53 2021
+++ src/sys/arch/arm/acpi/acpi_platform.c	Sat Aug  7 21:24:56 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.27 2021/08/06 19:38:53 jmcneill Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.28 2021/08/07 21:24:56 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.27 2021/08/06 19:38:53 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.28 2021/08/07 21:24:56 jmcneill Exp $");
 
 #include 
 #include 
@@ -253,6 +253,7 @@ acpi_platform_startup(void)
 			} else {
 psci_init(psci_call_smc);
 			}
+			smccc_probe();
 		}
 		acpi_table_unmap((ACPI_TABLE_HEADER *)fadt);
 	}



CVS commit: src/sys/arch/arm/acpi

2021-08-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug  7 21:24:56 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
acpi: call smccc_probe() after PSCI init


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2021-08-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug  7 18:40:45 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_machdep.c

Log Message:
acpi: DMA: Use acpi_resource_parse_any to parse _DMA resources

_DMA resources really should be marked ResourceProducer, so use
acpi_resource_parse_any to pick these up.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/acpi/acpi_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_machdep.c:1.23 src/sys/arch/arm/acpi/acpi_machdep.c:1.24
--- src/sys/arch/arm/acpi/acpi_machdep.c:1.23	Sat Aug  7 16:18:42 2021
+++ src/sys/arch/arm/acpi/acpi_machdep.c	Sat Aug  7 18:40:45 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.23 2021/08/07 16:18:42 thorpej Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.24 2021/08/07 18:40:45 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.23 2021/08/07 16:18:42 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.24 2021/08/07 18:40:45 jmcneill Exp $");
 
 #include 
 #include 
@@ -417,7 +417,7 @@ default_tag:
 		return;
 	}
 
-	rv = acpi_resource_parse(sc->sc_dev, module, "_DMA", ,
+	rv = acpi_resource_parse_any(sc->sc_dev, module, "_DMA", ,
 	_resource_parse_ops_quiet);
 	if (ACPI_FAILURE(rv)) {
 		aprint_error_dev(sc->sc_dev,



CVS commit: src/sys/arch/arm/acpi

2021-08-07 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Aug  7 18:40:45 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_machdep.c

Log Message:
acpi: DMA: Use acpi_resource_parse_any to parse _DMA resources

_DMA resources really should be marked ResourceProducer, so use
acpi_resource_parse_any to pick these up.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/acpi/acpi_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2021-05-12 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed May 12 21:56:13 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
Pass along our devhandle to the PCI bus instance we attach.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpipchb.c
diff -u src/sys/arch/arm/acpi/acpipchb.c:1.24 src/sys/arch/arm/acpi/acpipchb.c:1.25
--- src/sys/arch/arm/acpi/acpipchb.c:1.24	Sat Apr 24 23:36:25 2021
+++ src/sys/arch/arm/acpi/acpipchb.c	Wed May 12 21:56:13 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.24 2021/04/24 23:36:25 thorpej Exp $ */
+/* $NetBSD: acpipchb.c,v 1.25 2021/05/12 21:56:13 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.24 2021/04/24 23:36:25 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.25 2021/05/12 21:56:13 thorpej Exp $");
 
 #include 
 #include 
@@ -174,7 +174,9 @@ acpipchb_attach(device_t parent, device_
 	acpipchb_setup_ranges(sc, );
 	acpipchb_setup_quirks(sc, );
 
-	config_found(self, , pcibusprint, CFARG_EOL);
+	config_found(self, , pcibusprint,
+	CFARG_DEVHANDLE, device_handle(self),
+	CFARG_EOL);
 }
 
 struct acpipchb_setup_ranges_args {



CVS commit: src/sys/arch/arm/acpi

2021-05-12 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed May 12 21:56:13 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
Pass along our devhandle to the PCI bus instance we attach.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2021-02-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Feb 12 12:26:09 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
Reset serial terminal to default state at boot.

UEFI may leave the serial console in an undesireable state (incorrect
foreground and background colour, etc) when exiting. Send ANSI escape
sequences when setting up the early console attachments to turn off
character attributes and erase from the cursor to the end of the screen.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2021-02-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Feb 12 12:26:09 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
Reset serial terminal to default state at boot.

UEFI may leave the serial console in an undesireable state (incorrect
foreground and background colour, etc) when exiting. Send ANSI escape
sequences when setting up the early console attachments to turn off
character attributes and erase from the cursor to the end of the screen.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_platform.c
diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.23 src/sys/arch/arm/acpi/acpi_platform.c:1.24
--- src/sys/arch/arm/acpi/acpi_platform.c:1.23	Thu Feb  4 22:36:52 2021
+++ src/sys/arch/arm/acpi/acpi_platform.c	Fri Feb 12 12:26:09 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.23 2021/02/04 22:36:52 thorpej Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.24 2021/02/12 12:26:09 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -35,13 +35,14 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.23 2021/02/04 22:36:52 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.24 2021/02/12 12:26:09 jmcneill Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -214,6 +215,13 @@ acpi_platform_attach_uart(ACPI_TABLE_SPC
 		break;
 	}
 
+	/*
+	 * UEFI firmware may leave the console in an undesireable state (wrong
+	 * foreground/background colour, etc). Reset the terminal and clear
+	 * text from the cursor to the end of the screne.
+	 */
+printf_flags(TOCONS|NOTSTAMP, "\033[0m");
+printf_flags(TOCONS|NOTSTAMP, "\033[0J");
 }
 
 static void



CVS commit: src/sys/arch/arm/acpi

2021-01-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jan 26 00:29:22 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
acpipchb is a bus, so claim all child ACPI device nodes


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpipchb.c
diff -u src/sys/arch/arm/acpi/acpipchb.c:1.22 src/sys/arch/arm/acpi/acpipchb.c:1.23
--- src/sys/arch/arm/acpi/acpipchb.c:1.22	Sun Dec  6 12:40:58 2020
+++ src/sys/arch/arm/acpi/acpipchb.c	Tue Jan 26 00:29:22 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.22 2020/12/06 12:40:58 jmcneill Exp $ */
+/* $NetBSD: acpipchb.c,v 1.23 2021/01/26 00:29:22 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.22 2020/12/06 12:40:58 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.23 2021/01/26 00:29:22 jmcneill Exp $");
 
 #include 
 #include 
@@ -150,6 +150,8 @@ acpipchb_attach(device_t parent, device_
 	aprint_naive("\n");
 	aprint_normal(": PCI Express Host Bridge\n");
 
+	acpi_claim_childdevs(self, aa->aa_node);
+
 	if (acpi_pci_ignore_boot_config(sc->sc_handle)) {
 		if (acpimcfg_configure_bus(self, aa->aa_pc, sc->sc_handle,
 		sc->sc_bus, PCIHOST_CACHELINE_SIZE) != 0) {



CVS commit: src/sys/arch/arm/acpi

2021-01-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jan 26 00:29:22 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
acpipchb is a bus, so claim all child ACPI device nodes


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2021-01-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jan 23 12:34:19 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: cpu_acpi.c

Log Message:
fit in 80 columns


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/acpi/cpu_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2021-01-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jan 23 12:34:19 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: cpu_acpi.c

Log Message:
fit in 80 columns


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/acpi/cpu_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/cpu_acpi.c
diff -u src/sys/arch/arm/acpi/cpu_acpi.c:1.9 src/sys/arch/arm/acpi/cpu_acpi.c:1.10
--- src/sys/arch/arm/acpi/cpu_acpi.c:1.9	Thu Dec  3 07:45:51 2020
+++ src/sys/arch/arm/acpi/cpu_acpi.c	Sat Jan 23 12:34:19 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: cpu_acpi.c,v 1.9 2020/12/03 07:45:51 skrll Exp $ */
+/* $NetBSD: cpu_acpi.c,v 1.10 2021/01/23 12:34:19 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cpu_acpi.c,v 1.9 2020/12/03 07:45:51 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cpu_acpi.c,v 1.10 2021/01/23 12:34:19 jmcneill Exp $");
 
 #include 
 #include 
@@ -104,7 +104,8 @@ cpu_acpi_attach(device_t parent, device_
 		int error;
 
 		cpu_mpidr[cpuindex] = mpidr;
-		cpu_dcache_wb_range((vaddr_t)_mpidr[cpuindex], sizeof(cpu_mpidr[cpuindex]));
+		cpu_dcache_wb_range((vaddr_t)_mpidr[cpuindex],
+		sizeof(cpu_mpidr[cpuindex]));
 
 		/* XXX support spin table */
 		error = psci_cpu_on(mpidr, cpu_acpi_mpstart_pa(), 0);
@@ -169,14 +170,16 @@ cpu_acpi_tprof_intr_establish(ACPI_SUBTA
 
 	const bool cpu_primary_p = cpu_mpidr_aff_read() == gicc->ArmMpidr;
 	const bool intr_ppi_p = gicc->PerformanceInterrupt < 32;
-	const int type = (gicc->Flags & ACPI_MADT_PERFORMANCE_IRQ_MODE) ? IST_EDGE : IST_LEVEL;
+	const int type = (gicc->Flags & ACPI_MADT_PERFORMANCE_IRQ_MODE) ?
+	IST_EDGE : IST_LEVEL;
 
 	if (intr_ppi_p && !cpu_primary_p)
 		return AE_OK;
 
 	ci = cpu_acpi_find_processor(gicc->Uid);
 	if (ci == NULL) {
-		aprint_error_dev(dev, "couldn't find processor %#x\n", gicc->Uid);
+		aprint_error_dev(dev, "couldn't find processor %#x\n",
+		gicc->Uid);
 		return AE_OK;
 	}
 
@@ -186,10 +189,11 @@ cpu_acpi_tprof_intr_establish(ACPI_SUBTA
 		snprintf(xname, sizeof(xname), "pmu %s", cpu_name(ci));
 	}
 
-	ih = intr_establish_xname(gicc->PerformanceInterrupt, IPL_HIGH, type | IST_MPSAFE,
-	armv8_pmu_intr, NULL, xname);
+	ih = intr_establish_xname(gicc->PerformanceInterrupt, IPL_HIGH,
+	type | IST_MPSAFE, armv8_pmu_intr, NULL, xname);
 	if (ih == NULL) {
-		aprint_error_dev(dev, "couldn't establish %s interrupt\n", xname);
+		aprint_error_dev(dev, "couldn't establish %s interrupt\n",
+		xname);
 		return AE_OK;
 	}
 
@@ -200,13 +204,15 @@ cpu_acpi_tprof_intr_establish(ACPI_SUBTA
 		kcpuset_destroy(set);
 
 		if (error) {
-			aprint_error_dev(dev, "failed to distribute %s interrupt: %d\n",
+			aprint_error_dev(dev,
+			"failed to distribute %s interrupt: %d\n",
 			xname, error);
 			return AE_OK;
 		}
 	}
 
-	aprint_normal("%s: PMU interrupting on irq %d\n", cpu_name(ci), gicc->PerformanceInterrupt);
+	aprint_normal("%s: PMU interrupting on irq %d\n", cpu_name(ci),
+	gicc->PerformanceInterrupt);
 
 	return AE_OK;
 }
@@ -217,7 +223,8 @@ cpu_acpi_tprof_init(device_t self)
 	armv8_pmu_init();
 
 	if (acpi_madt_map() != AE_OK) {
-		aprint_error_dev(self, "failed to map MADT, performance counters not available\n");
+		aprint_error_dev(self,
+		"failed to map MADT, performance counters not available\n");
 		return;
 	}
 	acpi_madt_walk(cpu_acpi_tprof_intr_establish, self);



CVS commit: src/sys/arch/arm/acpi

2020-12-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Dec 23 11:05:08 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: gicv3_acpi.c

Log Message:
Future-proof ID_AA64PFR0_EL1.GIC test -- any value other than 0 means that
the GIC CPU interface is supported.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/acpi/gicv3_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/gicv3_acpi.c
diff -u src/sys/arch/arm/acpi/gicv3_acpi.c:1.7 src/sys/arch/arm/acpi/gicv3_acpi.c:1.8
--- src/sys/arch/arm/acpi/gicv3_acpi.c:1.7	Thu Feb 13 00:02:21 2020
+++ src/sys/arch/arm/acpi/gicv3_acpi.c	Wed Dec 23 11:05:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_acpi.c,v 1.7 2020/02/13 00:02:21 jmcneill Exp $ */
+/* $NetBSD: gicv3_acpi.c,v 1.8 2020/12/23 11:05:08 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gicv3_acpi.c,v 1.7 2020/02/13 00:02:21 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3_acpi.c,v 1.8 2020/12/23 11:05:08 jmcneill Exp $");
 
 #include 
 #include 
@@ -91,7 +91,7 @@ gicv3_acpi_match(device_t parent, cfdata
 
 	switch (gicd->Version) {
 	case ACPI_MADT_GIC_VERSION_NONE:
-		return __SHIFTOUT(reg_id_aa64pfr0_el1_read(), ID_AA64PFR0_EL1_GIC) == 1;
+		return __SHIFTOUT(reg_id_aa64pfr0_el1_read(), ID_AA64PFR0_EL1_GIC) != 0;
 	case ACPI_MADT_GIC_VERSION_V3:
 	case ACPI_MADT_GIC_VERSION_V4:
 		return 1;



CVS commit: src/sys/arch/arm/acpi

2020-12-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Dec 23 11:05:08 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: gicv3_acpi.c

Log Message:
Future-proof ID_AA64PFR0_EL1.GIC test -- any value other than 0 means that
the GIC CPU interface is supported.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/acpi/gicv3_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2020-12-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  6 14:01:40 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
acpi: Cleanup SPCR setup and style fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_platform.c
diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.21 src/sys/arch/arm/acpi/acpi_platform.c:1.22
--- src/sys/arch/arm/acpi/acpi_platform.c:1.21	Sat Oct 10 15:25:31 2020
+++ src/sys/arch/arm/acpi/acpi_platform.c	Sun Dec  6 14:01:40 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.21 2020/10/10 15:25:31 jmcneill Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.22 2020/12/06 14:01:40 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.21 2020/10/10 15:25:31 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.22 2020/12/06 14:01:40 jmcneill Exp $");
 
 #include 
 #include 
@@ -81,14 +81,24 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_platfor
 
 #include 
 
-#define	SPCR_BAUD_UNKNOWN			0
+#define	SPCR_BAUD_DEFAULT			0
 #define	SPCR_BAUD_96003
 #define	SPCR_BAUD_192004
 #define	SPCR_BAUD_576006
 #define	SPCR_BAUD_115200			7
 
+static const struct acpi_spcr_baud_rate {
+	uint8_t		id;
+	uint32_t	baud_rate;
+} acpi_spcr_baud_rates[] = {
+	{ SPCR_BAUD_DEFAULT,	0 },
+	{ SPCR_BAUD_9600,	9600 },
+	{ SPCR_BAUD_19200,	19200 },
+	{ SPCR_BAUD_57600,	57600 },
+	{ SPCR_BAUD_115200,	115200 },
+};
+
 extern struct bus_space arm_generic_bs_tag;
-extern struct bus_space arm_generic_a4x_bs_tag;
 
 #if NPLCOM > 0
 static struct plcom_instance plcom_console;
@@ -125,75 +135,101 @@ acpi_platform_bootstrap(void)
 }
 
 static void
-acpi_platform_startup(void)
+acpi_platform_attach_uart(ACPI_TABLE_SPCR *spcr)
 {
-	ACPI_TABLE_SPCR *spcr;
-	ACPI_TABLE_FADT *fadt;
-#ifdef MULTIPROCESSOR
-	ACPI_TABLE_MADT *madt;
+#if NCOM > 0
+	struct com_regs regs;
+	bus_space_handle_t dummy_bsh;
+	u_int reg_shift;
 #endif
-	int baud_rate;
+	int baud_rate, n;
 
 	/*
-	 * Setup serial console device
+	 * Only MMIO access is supported today.
 	 */
-	if (ACPI_SUCCESS(acpi_table_find(ACPI_SIG_SPCR, (void ** {
+	if (spcr->SerialPort.SpaceId != ACPI_ADR_SPACE_SYSTEM_MEMORY) {
+		return;
+	}
+	if (le64toh(spcr->SerialPort.Address) == 0) {
+		return;
+	}
 
-		switch (spcr->BaudRate) {
-		case SPCR_BAUD_9600:
-			baud_rate = 9600;
-			break;
-		case SPCR_BAUD_19200:
-			baud_rate = 19200;
-			break;
-		case SPCR_BAUD_57600:
-			baud_rate = 57600;
-			break;
-		case SPCR_BAUD_115200:
-		case SPCR_BAUD_UNKNOWN:
-		default:
-			baud_rate = 115200;
+	/*
+	 * Lookup SPCR baud rate.
+	 */
+	baud_rate = 0;
+	for (n = 0; n < __arraycount(acpi_spcr_baud_rates); n++) {
+		if (acpi_spcr_baud_rates[n].id == spcr->BaudRate) {
+			baud_rate = acpi_spcr_baud_rates[n].baud_rate;
 			break;
 		}
+	}
 
-		if (spcr->SerialPort.SpaceId == ACPI_ADR_SPACE_SYSTEM_MEMORY &&
-		le64toh(spcr->SerialPort.Address) != 0) {
-			switch (spcr->InterfaceType) {
+	/*
+	 * Attach console device.
+	 */
+	switch (spcr->InterfaceType) {
 #if NPLCOM > 0
-			case ACPI_DBG2_ARM_PL011:
-			case ACPI_DBG2_ARM_SBSA_32BIT:
-			case ACPI_DBG2_ARM_SBSA_GENERIC:
-plcom_console.pi_type = PLCOM_TYPE_PL011;
-plcom_console.pi_iot = _generic_bs_tag;
-plcom_console.pi_iobase = le64toh(spcr->SerialPort.Address);
-plcom_console.pi_size = PL011COM_UART_SIZE;
-plcom_console.pi_flags = PLC_FLAG_32BIT_ACCESS;
+	case ACPI_DBG2_ARM_PL011:
+	case ACPI_DBG2_ARM_SBSA_32BIT:
+	case ACPI_DBG2_ARM_SBSA_GENERIC:
+		plcom_console.pi_type = PLCOM_TYPE_PL011;
+		plcom_console.pi_iot = _generic_bs_tag;
+		plcom_console.pi_iobase = le64toh(spcr->SerialPort.Address);
+		plcom_console.pi_size = PL011COM_UART_SIZE;
+		plcom_console.pi_flags = PLC_FLAG_32BIT_ACCESS;
 
-plcomcnattach(_console, baud_rate, 0, TTYDEF_CFLAG, -1);
-break;
+		plcomcnattach(_console, baud_rate, 0, TTYDEF_CFLAG, -1);
+		break;
 #endif
+
 #if NCOM > 0
-			case ACPI_DBG2_16550_COMPATIBLE:
-			case ACPI_DBG2_16550_SUBSET:
-if (ACPI_ACCESS_BIT_WIDTH(spcr->SerialPort.AccessWidth) == 8) {
-	comcnattach(_generic_bs_tag, le64toh(spcr->SerialPort.Address), baud_rate, -1,
-	COM_TYPE_NORMAL, TTYDEF_CFLAG);
-} else {
-	comcnattach(_generic_a4x_bs_tag, le64toh(spcr->SerialPort.Address), baud_rate, -1,
-	COM_TYPE_NORMAL, TTYDEF_CFLAG);
-}
-break;
-			case ACPI_DBG2_BCM2835:
-comcnattach(_generic_a4x_bs_tag, le64toh(spcr->SerialPort.Address) + 0x40, baud_rate, -1,
-COM_TYPE_BCMAUXUART, TTYDEF_CFLAG);
-cn_set_magic("+");
-break;
-#endif
-			default:
-printf("SPCR: kernel does not support interface type %#x\n", spcr->InterfaceType);
-break;
-			}
+	

CVS commit: src/sys/arch/arm/acpi

2020-12-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  6 14:01:40 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
acpi: Cleanup SPCR setup and style fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/acpi/acpi_platform.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2020-12-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  6 12:40:58 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
Style fixes. NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpipchb.c
diff -u src/sys/arch/arm/acpi/acpipchb.c:1.21 src/sys/arch/arm/acpi/acpipchb.c:1.22
--- src/sys/arch/arm/acpi/acpipchb.c:1.21	Sat Oct 24 07:08:22 2020
+++ src/sys/arch/arm/acpi/acpipchb.c	Sun Dec  6 12:40:58 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.21 2020/10/24 07:08:22 skrll Exp $ */
+/* $NetBSD: acpipchb.c,v 1.22 2020/12/06 12:40:58 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.21 2020/10/24 07:08:22 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.22 2020/12/06 12:40:58 jmcneill Exp $");
 
 #include 
 #include 
@@ -92,8 +92,10 @@ struct acpipchb_softc {
 static int	acpipchb_match(device_t, cfdata_t, void *);
 static void	acpipchb_attach(device_t, device_t, void *);
 
-static void	acpipchb_setup_ranges(struct acpipchb_softc *, struct pcibus_attach_args *);
-static void	acpipchb_setup_quirks(struct acpipchb_softc *, struct pcibus_attach_args *);
+static void	acpipchb_setup_ranges(struct acpipchb_softc *,
+  struct pcibus_attach_args *);
+static void	acpipchb_setup_quirks(struct acpipchb_softc *,
+  struct pcibus_attach_args *);
 
 CFATTACH_DECL_NEW(acpipchb, sizeof(struct acpipchb_softc),
 	acpipchb_match, acpipchb_attach, NULL, NULL);
@@ -121,6 +123,7 @@ acpipchb_attach(device_t parent, device_
 	struct acpi_attach_args *aa = aux;
 	struct pcibus_attach_args pba;
 	ACPI_INTEGER seg;
+	ACPI_STATUS rv;
 	uint16_t bus_start;
 
 	sc->sc_dev = self;
@@ -134,23 +137,29 @@ acpipchb_attach(device_t parent, device_
 	if (ACPI_SUCCESS(acpi_pcidev_pciroot_bus(sc->sc_handle, _start))) {
 		sc->sc_bus = bus_start;
 	} else {
-		if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_BBN", >sc_bus)))
+		rv = acpi_eval_integer(sc->sc_handle, "_BBN", >sc_bus);
+		if (ACPI_FAILURE(rv)) {
 			sc->sc_bus = 0;
+		}
 	}
 
-	if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_SEG", )))
+	if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_SEG", ))) {
 		seg = 0;
+	}
 
 	aprint_naive("\n");
 	aprint_normal(": PCI Express Host Bridge\n");
 
 	if (acpi_pci_ignore_boot_config(sc->sc_handle)) {
-		if (acpimcfg_configure_bus(self, aa->aa_pc, sc->sc_handle, sc->sc_bus, PCIHOST_CACHELINE_SIZE) != 0)
+		if (acpimcfg_configure_bus(self, aa->aa_pc, sc->sc_handle,
+		sc->sc_bus, PCIHOST_CACHELINE_SIZE) != 0) {
 			aprint_error_dev(self, "failed to configure bus\n");
+		}
 	}
 
 	memset(, 0, sizeof(pba));
-	pba.pba_flags = aa->aa_pciflags & ~(PCI_FLAGS_MEM_OKAY | PCI_FLAGS_IO_OKAY);
+	pba.pba_flags = aa->aa_pciflags &
+			~(PCI_FLAGS_MEM_OKAY | PCI_FLAGS_IO_OKAY);
 	pba.pba_memt = 0;
 	pba.pba_iot = 0;
 	pba.pba_dmat = aa->aa_dmat;
@@ -188,8 +197,10 @@ acpipchb_bus_space_map(void *t, bus_addr
 
 	for (i = 0; i < abs->nrange; i++) {
 		struct acpipchb_bus_range * const range = >range[i];
-		if (bpa >= range->min && bpa + size - 1 <= range->max)
-			return abs->map(t, bpa + range->offset, size, flag, bshp);
+		if (bpa >= range->min && bpa + size - 1 <= range->max) {
+			return abs->map(t, bpa + range->offset, size,
+	flag, bshp);
+		}
 	}
 
 	return ERANGE;
@@ -207,8 +218,9 @@ acpipchb_setup_ranges_cb(ACPI_RESOURCE *
 	u_int pci_flags;
 
 	if (res->Type != ACPI_RESOURCE_TYPE_ADDRESS32 &&
-	res->Type != ACPI_RESOURCE_TYPE_ADDRESS64)
+	res->Type != ACPI_RESOURCE_TYPE_ADDRESS64) {
 		return AE_OK;
+	}
 
 	switch (res->Data.Address.ResourceType) {
 	case ACPI_IO_RANGE:
@@ -227,7 +239,7 @@ acpipchb_setup_ranges_cb(ACPI_RESOURCE *
 
 	if (abs->nrange == ACPIPCHB_MAX_RANGES) {
 		aprint_error_dev(sc->sc_dev,
-		"maximum number of ranges reached, increase ACPIPCHB_MAX_RANGES\n");
+		"maximum number of ranges reached (ACPIPCHB_MAX_RANGES)\n");
 		return AE_LIMIT;
 	}
 
@@ -248,7 +260,8 @@ acpipchb_setup_ranges_cb(ACPI_RESOURCE *
 	}
 	abs->nrange++;
 
-	aprint_debug_dev(sc->sc_dev, "PCI %s [%#lx-%#lx] -> %#lx\n", range_type, range->min, range->max, range->offset);
+	aprint_debug_dev(sc->sc_dev, "PCI %s [%#lx-%#lx] -> %#lx\n",
+	range_type, range->min, range->max, range->offset);
 
 	if ((pba->pba_flags & pci_flags) == 0) {
 		abs->bs = *sc->sc_memt;
@@ -256,10 +269,11 @@ acpipchb_setup_ranges_cb(ACPI_RESOURCE *
 		abs->map = abs->bs.bs_map;
 		abs->flags = pci_flags;
 		abs->bs.bs_map = acpipchb_bus_space_map;
-		if ((pci_flags & PCI_FLAGS_IO_OKAY) != 0)
+		if ((pci_flags & PCI_FLAGS_IO_OKAY) != 0) {
 			pba->pba_iot = >bs;
-		else if ((pci_flags & PCI_FLAGS_MEM_OKAY) != 0)
+		} else if ((pci_flags & PCI_FLAGS_MEM_OKAY) != 0) {
 			

CVS commit: src/sys/arch/arm/acpi

2020-12-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Dec  6 12:40:58 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
Style fixes. NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2020-10-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 24 07:08:22 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_machdep.c acpi_pci_graviton.c
acpi_pci_n1sdp.c acpipchb.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/acpi/acpi_machdep.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/acpi/acpi_pci_graviton.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/acpi/acpi_pci_n1sdp.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_machdep.c:1.19 src/sys/arch/arm/acpi/acpi_machdep.c:1.20
--- src/sys/arch/arm/acpi/acpi_machdep.c:1.19	Tue Jan 21 11:24:47 2020
+++ src/sys/arch/arm/acpi/acpi_machdep.c	Sat Oct 24 07:08:22 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.19 2020/01/21 11:24:47 jmcneill Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.20 2020/10/24 07:08:22 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.19 2020/01/21 11:24:47 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.20 2020/10/24 07:08:22 skrll Exp $");
 
 #include 
 #include 
@@ -502,7 +502,7 @@ arm_acpi_dma64_tag(struct acpi_softc *sc
 
 	if (ad->ad_dmat64 != NULL)
 		return ad->ad_dmat64;
-		
+
 	dmat = kmem_alloc(sizeof(*dmat), KM_SLEEP);
 	*dmat = arm_generic_dma_tag;
 

Index: src/sys/arch/arm/acpi/acpi_pci_graviton.c
diff -u src/sys/arch/arm/acpi/acpi_pci_graviton.c:1.3 src/sys/arch/arm/acpi/acpi_pci_graviton.c:1.4
--- src/sys/arch/arm/acpi/acpi_pci_graviton.c:1.3	Wed Jun 17 06:45:09 2020
+++ src/sys/arch/arm/acpi/acpi_pci_graviton.c	Sat Oct 24 07:08:22 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_graviton.c,v 1.3 2020/06/17 06:45:09 thorpej Exp $ */
+/* $NetBSD: acpi_pci_graviton.c,v 1.4 2020/10/24 07:08:22 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018, 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_graviton.c,v 1.3 2020/06/17 06:45:09 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_graviton.c,v 1.4 2020/10/24 07:08:22 skrll Exp $");
 
 #include 
 #include 
@@ -67,7 +67,7 @@ acpi_pci_graviton_conf_read(pci_chipset_
 		*data = bus_space_read_4(ap->ap_bst, ap->ap_conf_bsh, reg);
 		return 0;
 	}
-	
+
 	return acpimcfg_conf_read(pc, tag, reg, data);
 }
 
@@ -86,7 +86,7 @@ acpi_pci_graviton_conf_write(pci_chipset
 		bus_space_write_4(ap->ap_bst, ap->ap_conf_bsh, reg, data);
 		return 0;
 	}
-	
+
 	return acpimcfg_conf_write(pc, tag, reg, data);
 }
 

Index: src/sys/arch/arm/acpi/acpi_pci_n1sdp.c
diff -u src/sys/arch/arm/acpi/acpi_pci_n1sdp.c:1.5 src/sys/arch/arm/acpi/acpi_pci_n1sdp.c:1.6
--- src/sys/arch/arm/acpi/acpi_pci_n1sdp.c:1.5	Sun Sep 13 21:41:17 2020
+++ src/sys/arch/arm/acpi/acpi_pci_n1sdp.c	Sat Oct 24 07:08:22 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_n1sdp.c,v 1.5 2020/09/13 21:41:17 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_n1sdp.c,v 1.6 2020/10/24 07:08:22 skrll Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_n1sdp.c,v 1.5 2020/09/13 21:41:17 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_n1sdp.c,v 1.6 2020/10/24 07:08:22 skrll Exp $");
 
 #include 
 #include 
@@ -83,7 +83,7 @@ acpi_pci_n1sdp_valid(pci_chipset_tag_t p
 
 	pci_decompose_tag(pc, tag, , , );
 
-	bdfaddr = (b << N1SDP_BUS_SHIFT) + 
+	bdfaddr = (b << N1SDP_BUS_SHIFT) +
 		  (d << N1SDP_DEV_SHIFT) +
 		  (f << N1SDP_FUNC_SHIFT);
 
@@ -116,7 +116,7 @@ acpi_pci_n1sdp_conf_read(pci_chipset_tag
 		*data = -1;
 		return 0;
 	}
-	
+
 	return acpimcfg_conf_read(pc, tag, reg, data);
 }
 
@@ -138,7 +138,7 @@ acpi_pci_n1sdp_conf_write(pci_chipset_ta
 
 	if (!acpi_pci_n1sdp_valid(pc, tag))
 		return 0;
-	
+
 	return acpimcfg_conf_write(pc, tag, reg, data);
 }
 

Index: src/sys/arch/arm/acpi/acpipchb.c
diff -u src/sys/arch/arm/acpi/acpipchb.c:1.20 src/sys/arch/arm/acpi/acpipchb.c:1.21
--- src/sys/arch/arm/acpi/acpipchb.c:1.20	Wed Jun 17 06:46:09 2020
+++ src/sys/arch/arm/acpi/acpipchb.c	Sat Oct 24 07:08:22 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.20 2020/06/17 06:46:09 thorpej Exp $ */
+/* $NetBSD: acpipchb.c,v 1.21 2020/10/24 07:08:22 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.20 2020/06/17 06:46:09 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.21 2020/10/24 07:08:22 skrll Exp $");
 
 #include 
 #include 
@@ -188,7 +188,7 @@ acpipchb_bus_space_map(void *t, bus_addr
 
 	for (i = 0; i < abs->nrange; i++) {
 		struct acpipchb_bus_range * const range = >range[i];
-		if (bpa >= range->min && bpa + size - 1 <= range->max) 
+		if (bpa >= range->min 

CVS commit: src/sys/arch/arm/acpi

2020-10-24 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Oct 24 07:08:22 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_machdep.c acpi_pci_graviton.c
acpi_pci_n1sdp.c acpipchb.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/acpi/acpi_machdep.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/acpi/acpi_pci_graviton.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/acpi/acpi_pci_n1sdp.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2020-09-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Sep 13 21:41:17 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_iort.c acpi_pci_n1sdp.c acpi_platform.c
acpi_table.c

Log Message:
Make Arm MD ACPI code big endian friendly.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/acpi/acpi_iort.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/acpi/acpi_pci_n1sdp.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/acpi/acpi_platform.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/acpi/acpi_table.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2020-09-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Sep 13 21:41:17 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_iort.c acpi_pci_n1sdp.c acpi_platform.c
acpi_table.c

Log Message:
Make Arm MD ACPI code big endian friendly.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/acpi/acpi_iort.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/acpi/acpi_pci_n1sdp.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/acpi/acpi_platform.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/acpi/acpi_table.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_iort.c
diff -u src/sys/arch/arm/acpi/acpi_iort.c:1.3 src/sys/arch/arm/acpi/acpi_iort.c:1.4
--- src/sys/arch/arm/acpi/acpi_iort.c:1.3	Thu Feb 13 00:02:21 2020
+++ src/sys/arch/arm/acpi/acpi_iort.c	Sun Sep 13 21:41:17 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_iort.c,v 1.3 2020/02/13 00:02:21 jmcneill Exp $ */
+/* $NetBSD: acpi_iort.c,v 1.4 2020/09/13 21:41:17 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_iort.c,v 1.3 2020/02/13 00:02:21 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_iort.c,v 1.4 2020/09/13 21:41:17 jmcneill Exp $");
 
 #include 
 #include 
@@ -47,15 +47,15 @@ acpi_iort_id_map(ACPI_IORT_NODE *node, u
 	ACPI_IORT_ID_MAPPING *map;
 	uint32_t offset, n;
 
-	offset = node->MappingOffset;
-	for (n = 0; n < node->MappingCount; n++) {
+	offset = le32toh(node->MappingOffset);
+	for (n = 0; n < le32toh(node->MappingCount); n++) {
 		map = ACPI_ADD_PTR(ACPI_IORT_ID_MAPPING, node, offset);
-		if (map->Flags & ACPI_IORT_ID_SINGLE_MAPPING) {
-			*id = map->OutputBase;
+		if (le32toh(map->Flags) & ACPI_IORT_ID_SINGLE_MAPPING) {
+			*id = le32toh(map->OutputBase);
 			return map;
 		}
-		if (*id >= map->InputBase && *id <= map->InputBase + map->IdCount) {
-			*id = *id - map->InputBase + map->OutputBase;
+		if (*id >= le32toh(map->InputBase) && *id <= le32toh(map->InputBase) + le32toh(map->IdCount)) {
+			*id = *id - le32toh(map->InputBase) + le32toh(map->OutputBase);
 			return map;
 		}
 		offset += sizeof(ACPI_IORT_ID_MAPPING);
@@ -73,7 +73,7 @@ acpi_iort_find_ref(ACPI_TABLE_IORT *iort
 	if (map == NULL)
 		return NULL;
 
-	return ACPI_ADD_PTR(ACPI_IORT_NODE, iort, map->OutputReference);
+	return ACPI_ADD_PTR(ACPI_IORT_NODE, iort, le32toh(map->OutputReference));
 }
 
 uint32_t
@@ -89,12 +89,12 @@ acpi_iort_pci_root_map(u_int seg, uint32
 	if (ACPI_FAILURE(rv))
 		return devid;
 
-	offset = iort->NodeOffset;
-	for (n = 0; n < iort->NodeCount; n++) {
+	offset = le32toh(iort->NodeOffset);
+	for (n = 0; n < le32toh(iort->NodeCount); n++) {
 		node = ACPI_ADD_PTR(ACPI_IORT_NODE, iort, offset);
 		if (node->Type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX) {
 			root = (ACPI_IORT_ROOT_COMPLEX *)node->NodeData;
-			if (root->PciSegmentNumber == seg) {
+			if (le32toh(root->PciSegmentNumber) == seg) {
 const uint32_t odevid = devid;
 do {
 	node = acpi_iort_find_ref(iort, node, );
@@ -103,7 +103,7 @@ acpi_iort_pci_root_map(u_int seg, uint32
 return devid;
 			}
 		}
-		offset += node->Length;
+		offset += le16toh(node->Length);
 	}
 
 	return devid;
@@ -123,28 +123,28 @@ acpi_iort_its_id_map(u_int seg, uint32_t
 	if (ACPI_FAILURE(rv))
 		return 0;
 
-	offset = iort->NodeOffset;
-	for (n = 0; n < iort->NodeCount; n++) {
+	offset = le32toh(iort->NodeOffset);
+	for (n = 0; n < le32toh(iort->NodeCount); n++) {
 		node = ACPI_ADD_PTR(ACPI_IORT_NODE, iort, offset);
 		if (node->Type == ACPI_IORT_NODE_PCI_ROOT_COMPLEX) {
 			root = (ACPI_IORT_ROOT_COMPLEX *)node->NodeData;
-			if (root->PciSegmentNumber == seg) {
+			if (le32toh(root->PciSegmentNumber) == seg) {
 const uint32_t odevid = devid;
 do {
 	node = acpi_iort_find_ref(iort, node, );
 	if (node != NULL && node->Type == ACPI_IORT_NODE_ITS_GROUP) {
 		its_group = (ACPI_IORT_ITS_GROUP *)node->NodeData;
-		if (its_group->ItsCount == 0)
+		if (le32toh(its_group->ItsCount) == 0)
 			return 0;
 		aprint_debug("ACPI: IORT mapped devid %#x -> ITS %#x\n",
-		odevid, its_group->Identifiers[0]);
-		return its_group->Identifiers[0];
+		odevid, le32toh(its_group->Identifiers[0]));
+		return le32toh(its_group->Identifiers[0]);
 	}
 } while (node != NULL);
 return 0;
 			}
 		}
-		offset += node->Length;
+		offset += le16toh(node->Length);
 	}
 
 	return 0;

Index: src/sys/arch/arm/acpi/acpi_pci_n1sdp.c
diff -u src/sys/arch/arm/acpi/acpi_pci_n1sdp.c:1.4 src/sys/arch/arm/acpi/acpi_pci_n1sdp.c:1.5
--- src/sys/arch/arm/acpi/acpi_pci_n1sdp.c:1.4	Wed Jun 17 06:45:09 2020
+++ src/sys/arch/arm/acpi/acpi_pci_n1sdp.c	Sun Sep 13 21:41:17 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_n1sdp.c,v 1.4 2020/06/17 06:45:09 thorpej Exp $ */
+/* $NetBSD: acpi_pci_n1sdp.c,v 1.5 2020/09/13 21:41:17 jmcneill Exp $ */
 
 

CVS commit: src/sys/arch/arm/acpi

2020-07-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jul 27 18:38:10 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: gic_acpi.c

Log Message:
Skip v2m probe if armgic fails to attach


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/acpi/gic_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2020-07-27 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jul 27 18:38:10 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: gic_acpi.c

Log Message:
Skip v2m probe if armgic fails to attach


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/acpi/gic_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/gic_acpi.c
diff -u src/sys/arch/arm/acpi/gic_acpi.c:1.4 src/sys/arch/arm/acpi/gic_acpi.c:1.5
--- src/sys/arch/arm/acpi/gic_acpi.c:1.4	Mon Oct 14 11:00:13 2019
+++ src/sys/arch/arm/acpi/gic_acpi.c	Mon Jul 27 18:38:10 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: gic_acpi.c,v 1.4 2019/10/14 11:00:13 jmcneill Exp $ */
+/* $NetBSD: gic_acpi.c,v 1.5 2020/07/27 18:38:10 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic_acpi.c,v 1.4 2019/10/14 11:00:13 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic_acpi.c,v 1.5 2020/07/27 18:38:10 jmcneill Exp $");
 
 #include 
 #include 
@@ -124,12 +124,13 @@ gic_acpi_attach(device_t parent, device_
 	};
 
 	armgic = config_found(self, , NULL);
-	if (armgic != NULL)
+	if (armgic != NULL) {
 		arm_fdt_irq_set_handler(armgic_irq_handler);
 
 #if NPCI > 0
-	acpi_madt_walk(gic_v2m_acpi_find_msi_frame, armgic);
+		acpi_madt_walk(gic_v2m_acpi_find_msi_frame, armgic);
 #endif
+	}
 }
 
 static ACPI_STATUS



CVS commit: src/sys/arch/arm/acpi

2020-06-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Jun 17 06:46:09 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
 not needed here.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2020-06-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Jun 17 06:46:09 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
 not needed here.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpipchb.c
diff -u src/sys/arch/arm/acpi/acpipchb.c:1.19 src/sys/arch/arm/acpi/acpipchb.c:1.20
--- src/sys/arch/arm/acpi/acpipchb.c:1.19	Mon Jun 15 18:57:39 2020
+++ src/sys/arch/arm/acpi/acpipchb.c	Wed Jun 17 06:46:09 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.19 2020/06/15 18:57:39 ad Exp $ */
+/* $NetBSD: acpipchb.c,v 1.20 2020/06/17 06:46:09 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.19 2020/06/15 18:57:39 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.20 2020/06/17 06:46:09 thorpej Exp $");
 
 #include 
 #include 
@@ -38,7 +38,6 @@ __KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 



CVS commit: src/sys/arch/arm/acpi

2020-06-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Jun 17 06:45:09 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_graviton.c acpi_pci_layerscape_gen4.c
acpi_pci_machdep.c acpi_pci_n1sdp.c

Log Message:
 not needed here.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/acpi/acpi_pci_graviton.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/acpi/acpi_pci_layerscape_gen4.c \
src/sys/arch/arm/acpi/acpi_pci_n1sdp.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/acpi/acpi_pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_pci_graviton.c
diff -u src/sys/arch/arm/acpi/acpi_pci_graviton.c:1.2 src/sys/arch/arm/acpi/acpi_pci_graviton.c:1.3
--- src/sys/arch/arm/acpi/acpi_pci_graviton.c:1.2	Mon Jun 15 18:57:39 2020
+++ src/sys/arch/arm/acpi/acpi_pci_graviton.c	Wed Jun 17 06:45:09 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_graviton.c,v 1.2 2020/06/15 18:57:39 ad Exp $ */
+/* $NetBSD: acpi_pci_graviton.c,v 1.3 2020/06/17 06:45:09 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2018, 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_graviton.c,v 1.2 2020/06/15 18:57:39 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_graviton.c,v 1.3 2020/06/17 06:45:09 thorpej Exp $");
 
 #include 
 #include 
@@ -38,7 +38,6 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_pci_gra
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 

Index: src/sys/arch/arm/acpi/acpi_pci_layerscape_gen4.c
diff -u src/sys/arch/arm/acpi/acpi_pci_layerscape_gen4.c:1.3 src/sys/arch/arm/acpi/acpi_pci_layerscape_gen4.c:1.4
--- src/sys/arch/arm/acpi/acpi_pci_layerscape_gen4.c:1.3	Mon Jun 15 18:57:39 2020
+++ src/sys/arch/arm/acpi/acpi_pci_layerscape_gen4.c	Wed Jun 17 06:45:09 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_layerscape_gen4.c,v 1.3 2020/06/15 18:57:39 ad Exp $ */
+/* $NetBSD: acpi_pci_layerscape_gen4.c,v 1.4 2020/06/17 06:45:09 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_layerscape_gen4.c,v 1.3 2020/06/15 18:57:39 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_layerscape_gen4.c,v 1.4 2020/06/17 06:45:09 thorpej Exp $");
 
 #include 
 #include 
@@ -42,7 +42,6 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_pci_lay
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 
Index: src/sys/arch/arm/acpi/acpi_pci_n1sdp.c
diff -u src/sys/arch/arm/acpi/acpi_pci_n1sdp.c:1.3 src/sys/arch/arm/acpi/acpi_pci_n1sdp.c:1.4
--- src/sys/arch/arm/acpi/acpi_pci_n1sdp.c:1.3	Mon Jun 15 18:57:39 2020
+++ src/sys/arch/arm/acpi/acpi_pci_n1sdp.c	Wed Jun 17 06:45:09 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_n1sdp.c,v 1.3 2020/06/15 18:57:39 ad Exp $ */
+/* $NetBSD: acpi_pci_n1sdp.c,v 1.4 2020/06/17 06:45:09 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_n1sdp.c,v 1.3 2020/06/15 18:57:39 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_n1sdp.c,v 1.4 2020/06/17 06:45:09 thorpej Exp $");
 
 #include 
 #include 
@@ -38,7 +38,6 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_pci_n1s
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 

Index: src/sys/arch/arm/acpi/acpi_pci_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.17 src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.18
--- src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.17	Mon Jun 15 18:57:39 2020
+++ src/sys/arch/arm/acpi/acpi_pci_machdep.c	Wed Jun 17 06:45:09 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.c,v 1.17 2020/06/15 18:57:39 ad Exp $ */
+/* $NetBSD: acpi_pci_machdep.c,v 1.18 2020/06/17 06:45:09 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2018, 2020 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.17 2020/06/15 18:57:39 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.18 2020/06/17 06:45:09 thorpej Exp $");
 
 #include 
 #include 
@@ -40,7 +40,6 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_pci_mac
 #include 
 #include 
 #include 
-#include 
 #include 
 #include 
 #include 



CVS commit: src/sys/arch/arm/acpi

2020-06-17 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Jun 17 06:45:09 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_graviton.c acpi_pci_layerscape_gen4.c
acpi_pci_machdep.c acpi_pci_n1sdp.c

Log Message:
 not needed here.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/acpi/acpi_pci_graviton.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/acpi/acpi_pci_layerscape_gen4.c \
src/sys/arch/arm/acpi/acpi_pci_n1sdp.c
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/acpi/acpi_pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2020-05-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri May  8 14:44:24 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
Try to get the starting bus number from _CRS before falling back to _BBN.
There are apparently cases where the first bus in _CRS does not match the
value of _BBN, and the consensus is that _CRS should take precedence.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2020-05-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri May  8 14:44:24 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
Try to get the starting bus number from _CRS before falling back to _BBN.
There are apparently cases where the first bus in _CRS does not match the
value of _BBN, and the consensus is that _CRS should take precedence.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpipchb.c
diff -u src/sys/arch/arm/acpi/acpipchb.c:1.17 src/sys/arch/arm/acpi/acpipchb.c:1.18
--- src/sys/arch/arm/acpi/acpipchb.c:1.17	Tue Jan 21 11:24:47 2020
+++ src/sys/arch/arm/acpi/acpipchb.c	Fri May  8 14:44:23 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.17 2020/01/21 11:24:47 jmcneill Exp $ */
+/* $NetBSD: acpipchb.c,v 1.18 2020/05/08 14:44:23 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.17 2020/01/21 11:24:47 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.18 2020/05/08 14:44:23 jmcneill Exp $");
 
 #include 
 #include 
@@ -123,13 +123,22 @@ acpipchb_attach(device_t parent, device_
 	struct acpi_attach_args *aa = aux;
 	struct pcibus_attach_args pba;
 	ACPI_INTEGER seg;
+	uint16_t bus_start;
 
 	sc->sc_dev = self;
 	sc->sc_memt = aa->aa_memt;
 	sc->sc_handle = aa->aa_node->ad_handle;
 
-	if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_BBN", >sc_bus)))
-		sc->sc_bus = 0;
+	/*
+	 * First try to derive the base bus number from _CRS. If that fails,
+	 * try _BBN. If that fails too, assume bus 0.
+	 */
+	if (ACPI_SUCCESS(acpi_pcidev_pciroot_bus(sc->sc_handle, _start))) {
+		sc->sc_bus = bus_start;
+	} else {
+		if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_BBN", >sc_bus)))
+			sc->sc_bus = 0;
+	}
 
 	if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_SEG", )))
 		seg = 0;



CVS commit: src/sys/arch/arm/acpi

2020-04-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Apr 25 21:34:26 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: plcom_acpi.c

Log Message:
Enable HW FIFO


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/acpi/plcom_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2020-04-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Apr 25 21:34:26 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: plcom_acpi.c

Log Message:
Enable HW FIFO


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/acpi/plcom_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/plcom_acpi.c
diff -u src/sys/arch/arm/acpi/plcom_acpi.c:1.2 src/sys/arch/arm/acpi/plcom_acpi.c:1.3
--- src/sys/arch/arm/acpi/plcom_acpi.c:1.2	Fri Nov 16 23:18:00 2018
+++ src/sys/arch/arm/acpi/plcom_acpi.c	Sat Apr 25 21:34:26 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: plcom_acpi.c,v 1.2 2018/11/16 23:18:00 jmcneill Exp $ */
+/* $NetBSD: plcom_acpi.c,v 1.3 2020/04/25 21:34:26 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom_acpi.c,v 1.2 2018/11/16 23:18:00 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom_acpi.c,v 1.3 2020/04/25 21:34:26 jmcneill Exp $");
 
 #include 
 #include 
@@ -96,7 +96,7 @@ plcom_acpi_attach(device_t parent, devic
 		goto done;
 	}
 
-	sc->sc_hwflags = PLCOM_HW_TXFIFO_DISABLE;
+	sc->sc_hwflags = 0;
 	sc->sc_swflags = 0;
 
 	sc->sc_pi.pi_type = PLCOM_TYPE_PL011;



CVS commit: src/sys/arch/arm/acpi

2020-02-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Feb 13 00:02:40 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_n1sdp.c

Log Message:
Enable MSI and MSI-X support on N1SDP


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/acpi/acpi_pci_n1sdp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2020-02-12 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Feb 13 00:02:40 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_n1sdp.c

Log Message:
Enable MSI and MSI-X support on N1SDP


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/acpi/acpi_pci_n1sdp.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_pci_n1sdp.c
diff -u src/sys/arch/arm/acpi/acpi_pci_n1sdp.c:1.1 src/sys/arch/arm/acpi/acpi_pci_n1sdp.c:1.2
--- src/sys/arch/arm/acpi/acpi_pci_n1sdp.c:1.1	Fri Jan 17 17:06:33 2020
+++ src/sys/arch/arm/acpi/acpi_pci_n1sdp.c	Thu Feb 13 00:02:40 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_n1sdp.c,v 1.1 2020/01/17 17:06:33 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_n1sdp.c,v 1.2 2020/02/13 00:02:40 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_n1sdp.c,v 1.1 2020/01/17 17:06:33 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_n1sdp.c,v 1.2 2020/02/13 00:02:40 jmcneill Exp $");
 
 #include 
 #include 
@@ -186,8 +186,6 @@ acpi_pci_n1sdp_init(struct acpi_pci_cont
 	ap->ap_conf_read = acpi_pci_n1sdp_conf_read;
 	ap->ap_conf_write = acpi_pci_n1sdp_conf_write;
 
-	/* IO space access and MSI seems to cause async SErrors, so disable for now */
-	ap->ap_pciflags_clear = PCI_FLAGS_IO_OKAY |
-PCI_FLAGS_MSI_OKAY |
-PCI_FLAGS_MSIX_OKAY;
+	/* IO space access seems to cause async SErrors, so disable for now */
+	ap->ap_pciflags_clear = PCI_FLAGS_IO_OKAY;
 }



CVS commit: src/sys/arch/arm/acpi

2020-02-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Feb  7 00:35:00 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_iort.c

Log Message:
Single mappings are translated to OutputBase, not InputBase


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/acpi/acpi_iort.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_iort.c
diff -u src/sys/arch/arm/acpi/acpi_iort.c:1.1 src/sys/arch/arm/acpi/acpi_iort.c:1.2
--- src/sys/arch/arm/acpi/acpi_iort.c:1.1	Sat Dec  8 15:04:40 2018
+++ src/sys/arch/arm/acpi/acpi_iort.c	Fri Feb  7 00:35:00 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_iort.c,v 1.1 2018/12/08 15:04:40 jmcneill Exp $ */
+/* $NetBSD: acpi_iort.c,v 1.2 2020/02/07 00:35:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_iort.c,v 1.1 2018/12/08 15:04:40 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_iort.c,v 1.2 2020/02/07 00:35:00 jmcneill Exp $");
 
 #include 
 #include 
@@ -51,7 +51,7 @@ acpi_iort_id_map(ACPI_IORT_NODE *node, u
 	for (n = 0; n < node->MappingCount; n++) {
 		map = ACPI_ADD_PTR(ACPI_IORT_ID_MAPPING, node, offset);
 		if (map->Flags & ACPI_IORT_ID_SINGLE_MAPPING) {
-			*id = map->InputBase;
+			*id = map->OutputBase;
 			return map;
 		}
 		if (*id >= map->InputBase && *id <= map->InputBase + map->IdCount) {



CVS commit: src/sys/arch/arm/acpi

2020-02-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Feb  7 00:35:00 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_iort.c

Log Message:
Single mappings are translated to OutputBase, not InputBase


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/acpi/acpi_iort.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2020-02-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Feb  2 16:44:25 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_layerscape_gen4.c

Log Message:
Map and read MCFG space directly instead of going through acpimcfg to
simplify access through our tiny config space window.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/acpi/acpi_pci_layerscape_gen4.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_pci_layerscape_gen4.c
diff -u src/sys/arch/arm/acpi/acpi_pci_layerscape_gen4.c:1.1 src/sys/arch/arm/acpi/acpi_pci_layerscape_gen4.c:1.2
--- src/sys/arch/arm/acpi/acpi_pci_layerscape_gen4.c:1.1	Sat Feb  1 13:26:43 2020
+++ src/sys/arch/arm/acpi/acpi_pci_layerscape_gen4.c	Sun Feb  2 16:44:25 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_layerscape_gen4.c,v 1.1 2020/02/01 13:26:43 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_layerscape_gen4.c,v 1.2 2020/02/02 16:44:25 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_layerscape_gen4.c,v 1.1 2020/02/01 13:26:43 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_layerscape_gen4.c,v 1.2 2020/02/02 16:44:25 jmcneill Exp $");
 
 #include 
 #include 
@@ -78,6 +78,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_pci_lay
 struct acpi_pci_layerscape_gen4 {
 	bus_space_tag_t bst;
 	bus_space_handle_t bsh;
+	bus_space_handle_t win_bsh;
 	uint8_t rev;
 	kmutex_t lock;
 };
@@ -120,12 +121,11 @@ static void
 acpi_pci_layerscape_gen4_select_target(struct acpi_pci_layerscape_gen4 *pcie,
 pci_chipset_tag_t pc, pcitag_t tag)
 {
-	struct acpi_pci_context *ap = pc->pc_conf_v;
 	int b, d, f;
 
 	pci_decompose_tag(pc, tag, , , );
 
-	const uint32_t target = PAB_TARGET_BUS(b - ap->ap_bus) |
+	const uint32_t target = PAB_TARGET_BUS(b) |
 	PAB_TARGET_DEV(d) | PAB_TARGET_FUNC(f);
 
 	acpi_pci_layerscape_gen4_ccsr_write4(pcie, PAB_AXI_AMAP_PEX_WIN_L(0), target);
@@ -133,7 +133,7 @@ acpi_pci_layerscape_gen4_select_target(s
 }
 
 static bool
-acpi_pci_layerscape_gen4_is_tag_okay(pci_chipset_tag_t pc, pcitag_t tag)
+acpi_pci_layerscape_gen4_is_tag_okay(pci_chipset_tag_t pc, pcitag_t tag, int reg)
 {
 	struct acpi_pci_context *ap = pc->pc_conf_v;
 	int b, d, f;
@@ -143,6 +143,9 @@ acpi_pci_layerscape_gen4_is_tag_okay(pci
 	if (b <= ap->ap_bus + 1 && d > 0)
 		return false;
 
+	if (b != ap->ap_bus)
+		return acpimcfg_conf_valid(pc, tag, reg);
+
 	return true;
 }
 
@@ -152,11 +155,10 @@ acpi_pci_layerscape_gen4_conf_read(pci_c
 	struct acpi_pci_context *ap = pc->pc_conf_v;
 	struct acpi_pci_layerscape_gen4 *pcie = ap->ap_conf_priv;
 	int b, d, f;
-	int error;
 
 	pci_decompose_tag(pc, tag, , , );
 
-	if (!acpi_pci_layerscape_gen4_is_tag_okay(pc, tag)) {
+	if (!acpi_pci_layerscape_gen4_is_tag_okay(pc, tag, reg)) {
 		*data = -1;
 		return EINVAL;
 	}
@@ -168,10 +170,9 @@ acpi_pci_layerscape_gen4_conf_read(pci_c
 
 	if (b == ap->ap_bus) {
 		*data = acpi_pci_layerscape_gen4_ccsr_read4(pcie, reg);
-		error = 0;
 	} else {
 		acpi_pci_layerscape_gen4_select_target(pcie, pc, tag);
-		error = acpimcfg_conf_read(pc, pci_make_tag(pc, 0, 0, 0), reg, data);
+		*data = bus_space_read_4(pcie->bst, pcie->win_bsh, reg);
 	}
 
 	if (pcie->rev == 0x10 && reg == PCI_ID_REG)
@@ -179,7 +180,7 @@ acpi_pci_layerscape_gen4_conf_read(pci_c
 
 	mutex_exit(>lock);
 
-	return error;
+	return 0;
 }
 
 static int
@@ -188,26 +189,49 @@ acpi_pci_layerscape_gen4_conf_write(pci_
 	struct acpi_pci_context *ap = pc->pc_conf_v;
 	struct acpi_pci_layerscape_gen4 *pcie = ap->ap_conf_priv;
 	int b, d, f;
-	int error;
 
 	pci_decompose_tag(pc, tag, , , );
 
-	if (!acpi_pci_layerscape_gen4_is_tag_okay(pc, tag))
+	if (!acpi_pci_layerscape_gen4_is_tag_okay(pc, tag, reg))
 		return EINVAL;
 
 	mutex_enter(>lock);
 
 	if (b == ap->ap_bus) {
 		acpi_pci_layerscape_gen4_ccsr_write4(pcie, reg, data);
-		error = 0;
 	} else {
 		acpi_pci_layerscape_gen4_select_target(pcie, pc, tag);
-		error = acpimcfg_conf_write(pc, pci_make_tag(pc, 0, 0, 0), reg, data);
+		bus_space_write_4(pcie->bst, pcie->win_bsh, reg, data);
 	}
 
 	mutex_exit(>lock);
 
-	return error;
+	return 0;
+}
+
+static UINT64
+acpi_pci_layerscape_win_base(ACPI_INTEGER seg)
+{
+	ACPI_TABLE_MCFG *mcfg;
+	ACPI_MCFG_ALLOCATION *ama;
+	ACPI_STATUS rv;
+	uint32_t off;
+	int i;
+
+	rv = AcpiGetTable(ACPI_SIG_MCFG, 0, (ACPI_TABLE_HEADER **));
+	if (ACPI_FAILURE(rv))
+		return 0;
+
+	off = sizeof(ACPI_TABLE_MCFG);
+	ama = ACPI_ADD_PTR(ACPI_MCFG_ALLOCATION, mcfg, off);
+	for (i = 0; off + sizeof(ACPI_MCFG_ALLOCATION) <= mcfg->Header.Length; i++) {
+		if (ama->PciSegment == seg)
+			return ama->Address;
+		off += sizeof(ACPI_MCFG_ALLOCATION);
+		ama = ACPI_ADD_PTR(ACPI_MCFG_ALLOCATION, mcfg, off);
+	}
+
+	return 0;	/* not found */
 }
 
 static ACPI_STATUS
@@ -221,6 +245,7 @@ acpi_pci_layerscape_gen4_map(ACPI_HANDLE
 	

CVS commit: src/sys/arch/arm/acpi

2020-02-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Feb  2 16:44:25 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_layerscape_gen4.c

Log Message:
Map and read MCFG space directly instead of going through acpimcfg to
simplify access through our tiny config space window.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/acpi/acpi_pci_layerscape_gen4.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2020-02-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb  1 13:26:43 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c acpi_pci_machdep.h files.acpi
Added Files:
src/sys/arch/arm/acpi: acpi_pci_layerscape_gen4.c

Log Message:
Add support for NXP Layerscape PCIe Gen4 (not ECAM compliant)


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/acpi/acpi_pci_layerscape_gen4.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/acpi/acpi_pci_machdep.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/acpi/acpi_pci_machdep.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/acpi/files.acpi

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2020-02-01 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb  1 13:26:43 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c acpi_pci_machdep.h files.acpi
Added Files:
src/sys/arch/arm/acpi: acpi_pci_layerscape_gen4.c

Log Message:
Add support for NXP Layerscape PCIe Gen4 (not ECAM compliant)


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/acpi/acpi_pci_layerscape_gen4.c
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/acpi/acpi_pci_machdep.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/acpi/acpi_pci_machdep.h
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/acpi/files.acpi

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_pci_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.14 src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.15
--- src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.14	Thu Jan 23 11:59:37 2020
+++ src/sys/arch/arm/acpi/acpi_pci_machdep.c	Sat Feb  1 13:26:43 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.c,v 1.14 2020/01/23 11:59:37 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_machdep.c,v 1.15 2020/02/01 13:26:43 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.14 2020/01/23 11:59:37 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.15 2020/02/01 13:26:43 jmcneill Exp $");
 
 #include 
 #include 
@@ -101,6 +101,7 @@ static const struct acpi_pci_quirk acpi_
 	{ "AMAZON",	"GRAVITON",	0,		-1,	acpi_pci_graviton_init },
 	{ "ARMLTD",	"ARMN1SDP",	0x20181101,	0,	acpi_pci_n1sdp_init },
 	{ "ARMLTD",	"ARMN1SDP",	0x20181101,	1,	acpi_pci_n1sdp_init },
+	{ "NXP   ", "LX2160  ", 0,  -1,	acpi_pci_layerscape_gen4_init },
 };
 
 pci_chipset_tag_t acpi_pci_md_get_chipset_tag(struct acpi_softc *, int, int);

Index: src/sys/arch/arm/acpi/acpi_pci_machdep.h
diff -u src/sys/arch/arm/acpi/acpi_pci_machdep.h:1.6 src/sys/arch/arm/acpi/acpi_pci_machdep.h:1.7
--- src/sys/arch/arm/acpi/acpi_pci_machdep.h:1.6	Fri Jan 17 17:06:33 2020
+++ src/sys/arch/arm/acpi/acpi_pci_machdep.h	Sat Feb  1 13:26:43 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.h,v 1.6 2020/01/17 17:06:33 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_machdep.h,v 1.7 2020/02/01 13:26:43 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -43,6 +43,7 @@ struct acpi_pci_context {
 	bus_space_handle_t ap_conf_bsh;
 	int (*ap_conf_read)(pci_chipset_tag_t, pcitag_t, int, pcireg_t *);
 	int (*ap_conf_write)(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
+	void *ap_conf_priv;
 	int ap_pciflags_clear;
 };
 
@@ -57,6 +58,7 @@ struct acpi_pci_quirk {
 const struct acpi_pci_quirk *	acpi_pci_md_find_quirk(int);
 
 void	acpi_pci_graviton_init(struct acpi_pci_context *);
+void	acpi_pci_layerscape_gen4_init(struct acpi_pci_context *);
 void	acpi_pci_n1sdp_init(struct acpi_pci_context *);
 
 #endif /* !_ARM_ACPI_PCI_MACHDEP_H */

Index: src/sys/arch/arm/acpi/files.acpi
diff -u src/sys/arch/arm/acpi/files.acpi:1.9 src/sys/arch/arm/acpi/files.acpi:1.10
--- src/sys/arch/arm/acpi/files.acpi:1.9	Fri Jan 17 17:06:33 2020
+++ src/sys/arch/arm/acpi/files.acpi	Sat Feb  1 13:26:43 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: files.acpi,v 1.9 2020/01/17 17:06:33 jmcneill Exp $
+#	$NetBSD: files.acpi,v 1.10 2020/02/01 13:26:43 jmcneill Exp $
 #
 # Configuration info for ACPI compliant ARM boards.
 #
@@ -14,6 +14,7 @@ file	arch/arm/acpi/acpi_iort.c		acpi
 file	arch/arm/acpi/acpi_machdep.c		acpi
 file	arch/arm/acpi/acpi_pci_machdep.c	acpi & pci
 file	arch/arm/acpi/acpi_pci_graviton.c	acpi & pci
+file	arch/arm/acpi/acpi_pci_layerscape_gen4.c	acpi & pci
 file	arch/arm/acpi/acpi_pci_n1sdp.c		acpi & pci
 file	arch/arm/acpi/acpi_platform.c		acpi
 file	arch/arm/acpi/acpi_simplefb.c		acpi & wsdisplay & genfb

Added files:

Index: src/sys/arch/arm/acpi/acpi_pci_layerscape_gen4.c
diff -u /dev/null src/sys/arch/arm/acpi/acpi_pci_layerscape_gen4.c:1.1
--- /dev/null	Sat Feb  1 13:26:43 2020
+++ src/sys/arch/arm/acpi/acpi_pci_layerscape_gen4.c	Sat Feb  1 13:26:43 2020
@@ -0,0 +1,277 @@
+/* $NetBSD: acpi_pci_layerscape_gen4.c,v 1.1 2020/02/01 13:26:43 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2020 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jared McNeill .
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the 

CVS commit: src/sys/arch/arm/acpi

2020-01-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jan 24 10:49:41 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_simplefb.c

Log Message:
Do not attach simplefb if the width or height are invalid


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/acpi/acpi_simplefb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2020-01-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jan 24 10:49:41 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_simplefb.c

Log Message:
Do not attach simplefb if the width or height are invalid


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/acpi/acpi_simplefb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_simplefb.c
diff -u src/sys/arch/arm/acpi/acpi_simplefb.c:1.1 src/sys/arch/arm/acpi/acpi_simplefb.c:1.2
--- src/sys/arch/arm/acpi/acpi_simplefb.c:1.1	Sun Sep 22 18:31:59 2019
+++ src/sys/arch/arm/acpi/acpi_simplefb.c	Fri Jan 24 10:49:41 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_simplefb.c,v 1.1 2019/09/22 18:31:59 jmcneill Exp $ */
+/* $NetBSD: acpi_simplefb.c,v 1.2 2020/01/24 10:49:41 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_simplefb.c,v 1.1 2019/09/22 18:31:59 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_simplefb.c,v 1.2 2020/01/24 10:49:41 jmcneill Exp $");
 
 #include 
 #include 
@@ -166,6 +166,9 @@ acpi_simplefb_preattach(void)
 	(format = fdtbus_get_string(phandle, "format")) == NULL)
 		return;
 
+	if (width == 0 || height == 0)
+		return;
+
 	if (strcmp(format, "a8b8g8r8") == 0 ||
 	strcmp(format, "x8r8g8b8") == 0) {
 		depth = 32;
@@ -198,6 +201,9 @@ acpi_simplefb_preattach(void)
 	vcons_init_screen(_simplefb_vcons_data, _simplefb_screen, 1, );
 	acpi_simplefb_screen.scr_flags |= VCONS_SCREEN_IS_STATIC;
 
+	if (ri->ri_rows < 1 || ri->ri_cols < 1)
+		return;
+
 	acpi_simplefb_stdscreen.nrows = ri->ri_rows;
 	acpi_simplefb_stdscreen.ncols = ri->ri_cols;
 	acpi_simplefb_stdscreen.textops = >ri_ops;



CVS commit: src/sys/arch/arm/acpi

2020-01-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jan 23 11:59:37 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c

Log Message:
Add support for sharing legacy PCI interrupt sources.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/acpi/acpi_pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2020-01-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jan 23 11:59:37 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c

Log Message:
Add support for sharing legacy PCI interrupt sources.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/acpi/acpi_pci_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_pci_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.13 src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.14
--- src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.13	Fri Jan 17 17:06:33 2020
+++ src/sys/arch/arm/acpi/acpi_pci_machdep.c	Thu Jan 23 11:59:37 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.c,v 1.13 2020/01/17 17:06:33 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_machdep.c,v 1.14 2020/01/23 11:59:37 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -29,8 +29,10 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#define	_INTR_PRIVATE
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.13 2020/01/17 17:06:33 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.14 2020/01/23 11:59:37 jmcneill Exp $");
 
 #include 
 #include 
@@ -47,6 +49,8 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_pci_mac
 
 #include 
 
+#include 
+
 #include 
 #include 
 #include 
@@ -78,6 +82,20 @@ struct acpi_pci_pct {
 static TAILQ_HEAD(, acpi_pci_pct) acpi_pci_chipset_tags =
 TAILQ_HEAD_INITIALIZER(acpi_pci_chipset_tags);
 
+struct acpi_pci_intr;
+
+struct acpi_pci_intr {
+	struct pic_softc		pi_pic;
+	intpi_irqbase;
+	intpi_irq;
+	uint32_t			pi_unblocked;
+	void*pi_ih;
+	TAILQ_ENTRY(acpi_pci_intr)	pi_list;
+};
+
+static TAILQ_HEAD(, acpi_pci_intr) acpi_pci_intrs =
+TAILQ_HEAD_INITIALIZER(acpi_pci_intrs);
+
 static const struct acpi_pci_quirk acpi_pci_quirks[] = {
 	/* OEM ID	OEM Table ID	Revision	Seg	Func */
 	{ "AMAZON",	"GRAVITON",	0,		-1,	acpi_pci_graviton_init },
@@ -415,11 +433,70 @@ acpi_pci_md_intr_setattr(void *v, pci_in
 	}
 }
 
+static struct acpi_pci_intr *
+acpi_pci_md_intr_lookup(int irq)
+{
+	struct acpi_pci_intr *pi;
+
+	TAILQ_FOREACH(pi, _pci_intrs, pi_list)
+		if (pi->pi_irq == irq)
+			return pi;
+
+	return NULL;
+}
+
+static void
+acpi_pci_md_unblock_irqs(struct pic_softc *pic, size_t irqbase, uint32_t irqmask)
+{
+	struct acpi_pci_intr * const pi = (struct acpi_pci_intr *)pic;
+
+	pi->pi_unblocked |= irqmask;
+}
+
+static void
+acpi_pci_md_block_irqs(struct pic_softc *pic, size_t irqbase, uint32_t irqmask)
+{
+	struct acpi_pci_intr * const pi = (struct acpi_pci_intr *)pic;
+
+	pi->pi_unblocked &= ~irqmask;
+}
+
+static int
+acpi_pci_md_find_pending_irqs(struct pic_softc *pic)
+{
+	struct acpi_pci_intr * const pi = (struct acpi_pci_intr *)pic;
+
+	pic_mark_pending_sources(pic, 0, pi->pi_unblocked);
+
+	return 1;
+}
+
+static void
+acpi_pci_md_establish_irq(struct pic_softc *pic, struct intrsource *is)
+{
+}
+
+static void
+acpi_pci_md_source_name(struct pic_softc *pic, int irq, char *buf, size_t len)
+{
+	snprintf(buf, len, "slot %d", irq);
+}
+
+static struct pic_ops acpi_pci_pic_ops = {
+	.pic_unblock_irqs = acpi_pci_md_unblock_irqs,
+	.pic_block_irqs = acpi_pci_md_block_irqs,
+	.pic_find_pending_irqs = acpi_pci_md_find_pending_irqs,
+	.pic_establish_irq = acpi_pci_md_establish_irq,
+	.pic_source_name = acpi_pci_md_source_name,
+};
+
 static void *
 acpi_pci_md_intr_establish(void *v, pci_intr_handle_t ih, int ipl,
 int (*callback)(void *), void *arg, const char *xname)
 {
 	struct acpi_pci_context * const ap = v;
+	struct acpi_pci_intr *pi;
+	int slot;
 
 	if ((ih & (ARM_PCI_INTR_MSI | ARM_PCI_INTR_MSIX)) != 0)
 		return arm_pci_msi_intr_establish(>ap_pc, ih, ipl, callback, arg, xname);
@@ -427,7 +504,31 @@ acpi_pci_md_intr_establish(void *v, pci_
 	const int irq = (int)__SHIFTOUT(ih, ARM_PCI_INTR_IRQ);
 	const int mpsafe = (ih & ARM_PCI_INTR_MPSAFE) ? IST_MPSAFE : 0;
 
-	return intr_establish_xname(irq, ipl, IST_LEVEL | mpsafe, callback, arg, xname);
+	pi = acpi_pci_md_intr_lookup(irq);
+	if (pi == NULL) {
+		pi = kmem_zalloc(sizeof(*pi), KM_SLEEP);
+		pi->pi_irq = irq;
+		snprintf(pi->pi_pic.pic_name, sizeof(pi->pi_pic.pic_name),
+		"PCI irq %d", irq);
+		pi->pi_pic.pic_maxsources = 32;
+		pi->pi_pic.pic_ops = _pci_pic_ops;
+		pi->pi_irqbase = pic_add(>pi_pic, PIC_IRQBASE_ALLOC);
+		TAILQ_INSERT_TAIL(_pci_intrs, pi, pi_list);
+		pi->pi_ih = intr_establish_xname(irq, IPL_SCHED, IST_LEVEL | IST_MPSAFE,
+		pic_handle_intr, >pi_pic, device_xname(ap->ap_dev));
+	}
+	if (pi->pi_ih == NULL)
+		return NULL;
+
+	/* Find a free slot */
+	for (slot = 0; slot < pi->pi_pic.pic_maxsources; slot++)
+		if (pi->pi_pic.pic_sources[slot] == NULL)
+			break;
+	if (slot == pi->pi_pic.pic_maxsources)
+		return NULL;
+
+	return intr_establish_xname(pi->pi_irqbase + slot, ipl, IST_LEVEL | mpsafe,
+	callback, arg, xname);
 }
 
 static void
@@ -476,6 +577,7 @@ 

CVS commit: src/sys/arch/arm/acpi

2020-01-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jan 21 11:24:48 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_machdep.c acpipchb.c

Log Message:
Provide a properly constrained 32-bit DMA tag to ACPI.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/acpi/acpi_machdep.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_machdep.c:1.18 src/sys/arch/arm/acpi/acpi_machdep.c:1.19
--- src/sys/arch/arm/acpi/acpi_machdep.c:1.18	Tue Dec 31 17:26:04 2019
+++ src/sys/arch/arm/acpi/acpi_machdep.c	Tue Jan 21 11:24:47 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.18 2019/12/31 17:26:04 jmcneill Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.19 2020/01/21 11:24:47 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.18 2019/12/31 17:26:04 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.19 2020/01/21 11:24:47 jmcneill Exp $");
 
 #include 
 #include 
@@ -63,7 +63,8 @@ extern struct bus_space arm_generic_bs_t
 extern struct arm32_bus_dma_tag acpi_coherent_dma_tag;
 extern struct arm32_bus_dma_tag arm_generic_dma_tag;
 
-bus_dma_tag_t	arm_acpi_dma_tag(struct acpi_softc *, struct acpi_devnode *);
+bus_dma_tag_t	arm_acpi_dma32_tag(struct acpi_softc *, struct acpi_devnode *);
+bus_dma_tag_t	arm_acpi_dma64_tag(struct acpi_softc *, struct acpi_devnode *);
 
 static int
 acpi_md_pmapflags(paddr_t pa)
@@ -473,14 +474,34 @@ arm_acpi_dma_flags(struct acpi_softc *sc
 	return cca ? _BUS_DMAMAP_COHERENT : 0;
 }
 
-
 bus_dma_tag_t
-arm_acpi_dma_tag(struct acpi_softc *sc, struct acpi_devnode *ad)
+arm_acpi_dma32_tag(struct acpi_softc *sc, struct acpi_devnode *ad)
 {
-	struct arm32_bus_dma_tag *dmat;
+	bus_dma_tag_t dmat64, dmat32;
+	int error;
 
 	if (ad->ad_dmat != NULL)
 		return ad->ad_dmat;
+
+	dmat64 = arm_acpi_dma64_tag(sc, ad);
+
+	const uint32_t flags = arm_acpi_dma_flags(sc, ad);
+	error = bus_dmatag_subregion(dmat64, 0, UINT32_MAX, , flags);
+	if (error != 0)
+		panic("arm_acpi_dma32_tag: bus_dmatag_subregion returned %d",
+		error);
+
+	return dmat32;
+}
+__strong_alias(acpi_get_dma_tag,arm_acpi_dma32_tag);
+
+bus_dma_tag_t
+arm_acpi_dma64_tag(struct acpi_softc *sc, struct acpi_devnode *ad)
+{
+	struct arm32_bus_dma_tag *dmat;
+
+	if (ad->ad_dmat64 != NULL)
+		return ad->ad_dmat64;
 		
 	dmat = kmem_alloc(sizeof(*dmat), KM_SLEEP);
 	*dmat = arm_generic_dma_tag;
@@ -490,5 +511,4 @@ arm_acpi_dma_tag(struct acpi_softc *sc, 
 
 	return dmat;
 }
-__strong_alias(acpi_get_dma_tag,arm_acpi_dma_tag);
-__strong_alias(acpi_get_dma64_tag,arm_acpi_dma_tag);
+__strong_alias(acpi_get_dma64_tag,arm_acpi_dma64_tag);

Index: src/sys/arch/arm/acpi/acpipchb.c
diff -u src/sys/arch/arm/acpi/acpipchb.c:1.16 src/sys/arch/arm/acpi/acpipchb.c:1.17
--- src/sys/arch/arm/acpi/acpipchb.c:1.16	Fri Jan 17 17:06:33 2020
+++ src/sys/arch/arm/acpi/acpipchb.c	Tue Jan 21 11:24:47 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.16 2020/01/17 17:06:33 jmcneill Exp $ */
+/* $NetBSD: acpipchb.c,v 1.17 2020/01/21 11:24:47 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.16 2020/01/17 17:06:33 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.17 2020/01/21 11:24:47 jmcneill Exp $");
 
 #include 
 #include 
@@ -84,8 +84,6 @@ struct acpipchb_softc {
 
 	bus_space_tag_t		sc_memt;
 
-	struct arm32_bus_dma_tag sc_dmat;
-
 	ACPI_HANDLE		sc_handle;
 	ACPI_INTEGER		sc_bus;
 
@@ -139,8 +137,6 @@ acpipchb_attach(device_t parent, device_
 	aprint_naive("\n");
 	aprint_normal(": PCI Express Host Bridge\n");
 
-	sc->sc_dmat = *aa->aa_dmat;
-
 	if (acpi_pci_ignore_boot_config(sc->sc_handle)) {
 		if (acpimcfg_configure_bus(self, aa->aa_pc, sc->sc_handle, sc->sc_bus, PCIHOST_CACHELINE_SIZE) != 0)
 			aprint_error_dev(self, "failed to configure bus\n");
@@ -150,9 +146,9 @@ acpipchb_attach(device_t parent, device_
 	pba.pba_flags = aa->aa_pciflags & ~(PCI_FLAGS_MEM_OKAY | PCI_FLAGS_IO_OKAY);
 	pba.pba_memt = 0;
 	pba.pba_iot = 0;
-	pba.pba_dmat = >sc_dmat;
+	pba.pba_dmat = aa->aa_dmat;
 #ifdef _PCI_HAVE_DMA64
-	pba.pba_dmat64 = >sc_dmat;
+	pba.pba_dmat64 = aa->aa_dmat64;
 #endif
 	pba.pba_pc = aa->aa_pc;
 	pba.pba_bus = sc->sc_bus;



CVS commit: src/sys/arch/arm/acpi

2020-01-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jan 21 11:24:48 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: acpi_machdep.c acpipchb.c

Log Message:
Provide a properly constrained 32-bit DMA tag to ACPI.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/acpi/acpi_machdep.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2020-01-17 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jan 17 16:58:57 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: gicv3_acpi.c

Log Message:
Only attach the first ITS for now


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/acpi/gicv3_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2020-01-17 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jan 17 16:58:57 UTC 2020

Modified Files:
src/sys/arch/arm/acpi: gicv3_acpi.c

Log Message:
Only attach the first ITS for now


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/acpi/gicv3_acpi.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/gicv3_acpi.c
diff -u src/sys/arch/arm/acpi/gicv3_acpi.c:1.5 src/sys/arch/arm/acpi/gicv3_acpi.c:1.6
--- src/sys/arch/arm/acpi/gicv3_acpi.c:1.5	Mon Oct 14 11:00:13 2019
+++ src/sys/arch/arm/acpi/gicv3_acpi.c	Fri Jan 17 16:58:57 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: gicv3_acpi.c,v 1.5 2019/10/14 11:00:13 jmcneill Exp $ */
+/* $NetBSD: gicv3_acpi.c,v 1.6 2020/01/17 16:58:57 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
 #define	_INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gicv3_acpi.c,v 1.5 2019/10/14 11:00:13 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gicv3_acpi.c,v 1.6 2020/01/17 16:58:57 jmcneill Exp $");
 
 #include 
 #include 
@@ -288,6 +288,7 @@ gicv3_acpi_map_redist(struct gicv3_acpi_
 static ACPI_STATUS
 gicv3_acpi_map_gits(ACPI_SUBTABLE_HEADER *hdrp, void *aux)
 {
+	static bool its_attached;
 	struct gicv3_acpi_softc * const sc = aux;
 	ACPI_MADT_GENERIC_TRANSLATOR *gits;
 	bus_space_handle_t bsh;
@@ -303,9 +304,13 @@ gicv3_acpi_map_gits(ACPI_SUBTABLE_HEADER
 		return AE_OK;
 	}
 
-	aprint_normal_dev(sc->sc_gic.sc_dev, "ITS #%#x at 0x%" PRIx64 "\n", gits->TranslationId, gits->BaseAddress);
+	aprint_normal_dev(sc->sc_gic.sc_dev, "ITS #%d at 0x%" PRIx64 "%s\n",
+	gits->TranslationId, gits->BaseAddress, its_attached ? " (disabled)" : "");
 
-	gicv3_its_init(>sc_gic, bsh, gits->BaseAddress, gits->TranslationId);
+	if (its_attached == false) {
+		gicv3_its_init(>sc_gic, bsh, gits->BaseAddress, gits->TranslationId);
+		its_attached = true;
+	}
 
 	return AE_OK;
 }



CVS commit: src/sys/arch/arm/acpi

2019-12-31 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 31 13:54:22 UTC 2019

Modified Files:
src/sys/arch/arm/acpi: acpi_machdep.c

Log Message:
Create bus_dma tags for each device node based on _CCA and _DMA properties
found by walking up the device node tree. These tags encode range
restrictions, address translations, and whether or not the device is
cache coherent.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/acpi/acpi_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2019-12-31 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 31 13:54:22 UTC 2019

Modified Files:
src/sys/arch/arm/acpi: acpi_machdep.c

Log Message:
Create bus_dma tags for each device node based on _CCA and _DMA properties
found by walking up the device node tree. These tags encode range
restrictions, address translations, and whether or not the device is
cache coherent.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/acpi/acpi_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_machdep.c:1.16 src/sys/arch/arm/acpi/acpi_machdep.c:1.17
--- src/sys/arch/arm/acpi/acpi_machdep.c:1.16	Tue Dec 31 11:42:46 2019
+++ src/sys/arch/arm/acpi/acpi_machdep.c	Tue Dec 31 13:54:22 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.16 2019/12/31 11:42:46 jmcneill Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.17 2019/12/31 13:54:22 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,13 +32,14 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.16 2019/12/31 11:42:46 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.17 2019/12/31 13:54:22 jmcneill Exp $");
 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -372,88 +373,123 @@ static const char * const module_hid[] =
 	NULL
 };
 
-static bus_dma_tag_t
-arm_acpi_dma_tag_subregion(struct acpi_softc *sc, bus_dma_tag_t dmat,
-ACPI_HANDLE handle)
+static ACPI_HANDLE
+arm_acpi_dma_module(struct acpi_softc *sc, struct acpi_devnode *ad)
+{
+	ACPI_HANDLE tmp;
+	ACPI_STATUS rv;
+
+	/*
+	 * Search up the tree for a module device with a _DMA method.
+	 */
+	for (; ad != NULL; ad = ad->ad_parent) {
+		if (ad->ad_devinfo->Type != ACPI_TYPE_DEVICE)
+			continue;
+		if (!acpi_match_hid(ad->ad_devinfo, module_hid))
+			continue;
+		rv = AcpiGetHandle(ad->ad_handle, "_DMA", );
+		if (ACPI_SUCCESS(rv))
+			return ad->ad_handle;
+	}
+
+	return NULL;
+}
+
+static void
+arm_acpi_dma_init_ranges(struct acpi_softc *sc, struct acpi_devnode *ad,
+struct arm32_bus_dma_tag *dmat, uint32_t flags)
 {
 	struct acpi_resources res;
 	struct acpi_mem *mem;
-	bus_dma_tag_t newtag;
+	ACPI_HANDLE module;
 	ACPI_STATUS rv;
-	int error;
+	int n;
 
-	rv = acpi_resource_parse(sc->sc_dev, handle, "_DMA", ,
-	_resource_parse_ops_quiet);
-	if (ACPI_FAILURE(rv))
-		return dmat;	/* no translation required */
+	module = arm_acpi_dma_module(sc, ad->ad_parent);
+	if (module == NULL) {
+default_tag:
+		/* No translation required */
+		dmat->_nranges = 1;
+		dmat->_ranges = kmem_zalloc(sizeof(*dmat->_ranges), KM_SLEEP);
+		dmat->_ranges[0].dr_sysbase = 0;
+		dmat->_ranges[0].dr_busbase = 0;
+		dmat->_ranges[0].dr_len = UINTPTR_MAX;
+		dmat->_ranges[0].dr_flags = flags;
+		return;
+	}
 
-	mem = acpi_res_mem(, 0);
-	if (mem == NULL)
-		goto done;
-
-	aprint_debug_dev(sc->sc_dev, "_DMA range %#lx-%#lx\n",
-	mem->ar_base, mem->ar_base + mem->ar_length - 1);
-
-	error = bus_dmatag_subregion(dmat,
-	mem->ar_base, mem->ar_base + mem->ar_length - 1,
-	, BUS_DMA_WAITOK);
-	if (error != 0) {
+	rv = acpi_resource_parse(sc->sc_dev, module, "_DMA", ,
+	_resource_parse_ops_quiet);
+	if (ACPI_FAILURE(rv)) {
 		aprint_error_dev(sc->sc_dev,
-		"_DMA subregion failed: %d\n", error);
-		goto done;
+		"failed to parse _DMA on %s: %s\n",
+		acpi_name(module), AcpiFormatException(rv));
+		goto default_tag;
+	}
+	if (res.ar_nmem == 0) {
+		acpi_resource_cleanup();
+		goto default_tag;
 	}
-	dmat = newtag;
 
-done:
-	acpi_resource_cleanup();
+	dmat->_nranges = res.ar_nmem;
+	dmat->_ranges = kmem_zalloc(sizeof(*dmat->_ranges) * res.ar_nmem,
+	KM_SLEEP);
+
+	for (n = 0; n < res.ar_nmem; n++) {
+		mem = acpi_res_mem(, n);
+		dmat->_ranges[n].dr_busbase = mem->ar_base;
+		dmat->_ranges[n].dr_sysbase = mem->ar_base;
+		if (mem->ar_decode == ACPI_POS_DECODE)
+		 	dmat->_ranges[n].dr_sysbase += mem->ar_offset;
+		else
+			dmat->_ranges[n].dr_sysbase -= mem->ar_offset;
+		dmat->_ranges[n].dr_len = mem->ar_length;
+		dmat->_ranges[n].dr_flags = flags;
+
+		aprint_debug_dev(sc->sc_dev,
+		"%s: DMA sysbase %#lx busbase %#lx len %#lx%s\n",
+		acpi_name(ad->ad_handle),
+		dmat->_ranges[n].dr_sysbase,
+		dmat->_ranges[n].dr_busbase,
+		dmat->_ranges[n].dr_len,
+		flags ? " (coherent)" : "");
+	}
 
-	return dmat;
+	acpi_resource_cleanup();
 }
 
-static ACPI_HANDLE
-arm_acpi_dma_module(struct acpi_softc *sc, struct acpi_devnode *ad)
+static uint32_t
+arm_acpi_dma_flags(struct acpi_softc *sc, struct acpi_devnode *ad)
 {
-	ACPI_HANDLE tmp;
+	ACPI_INTEGER cca = 1;	/* default cache coherent */
 	ACPI_STATUS rv;
 
-	/*
-	 * Search up the tree for a module device with a _DMA method.
-	 */
 	for (; ad != NULL; ad = ad->ad_parent) {
 		if (ad->ad_devinfo->Type != ACPI_TYPE_DEVICE)
 			

CVS commit: src/sys/arch/arm/acpi

2019-12-31 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 31 11:42:46 UTC 2019

Modified Files:
src/sys/arch/arm/acpi: acpi_machdep.c

Log Message:
The DMA restrictions may not be defined in the direct parent of a device,
so search up the tree for a module device.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/acpi/acpi_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2019-12-31 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Dec 31 11:42:46 UTC 2019

Modified Files:
src/sys/arch/arm/acpi: acpi_machdep.c

Log Message:
The DMA restrictions may not be defined in the direct parent of a device,
so search up the tree for a module device.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/acpi/acpi_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_machdep.c:1.15 src/sys/arch/arm/acpi/acpi_machdep.c:1.16
--- src/sys/arch/arm/acpi/acpi_machdep.c:1.15	Mon Dec 30 19:50:29 2019
+++ src/sys/arch/arm/acpi/acpi_machdep.c	Tue Dec 31 11:42:46 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.15 2019/12/30 19:50:29 jmcneill Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.16 2019/12/31 11:42:46 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.15 2019/12/30 19:50:29 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.16 2019/12/31 11:42:46 jmcneill Exp $");
 
 #include 
 #include 
@@ -410,9 +410,32 @@ done:
 	return dmat;
 }
 
+static ACPI_HANDLE
+arm_acpi_dma_module(struct acpi_softc *sc, struct acpi_devnode *ad)
+{
+	ACPI_HANDLE tmp;
+	ACPI_STATUS rv;
+
+	/*
+	 * Search up the tree for a module device with a _DMA method.
+	 */
+	for (; ad != NULL; ad = ad->ad_parent) {
+		if (ad->ad_devinfo->Type != ACPI_TYPE_DEVICE)
+			continue;
+		if (!acpi_match_hid(ad->ad_devinfo, module_hid))
+			continue;
+		rv = AcpiGetHandle(ad->ad_handle, "_DMA", );
+		if (ACPI_SUCCESS(rv))
+			return ad->ad_handle;
+	}
+
+	return NULL;
+}
+
 bus_dma_tag_t
 arm_acpi_dma_tag(struct acpi_softc *sc, struct acpi_devnode *ad)
 {
+	ACPI_HANDLE module;
 	ACPI_INTEGER cca;
 	bus_dma_tag_t dmat;
 
@@ -425,14 +448,12 @@ arm_acpi_dma_tag(struct acpi_softc *sc, 
 		dmat = _generic_dma_tag;
 
 	/*
-	 * If the parent device is a bus, it may define valid DMA ranges
+	 * If a parent device is a bus, it may define valid DMA ranges
 	 * and translations for child nodes.
 	 */
-	if (ad->ad_parent != NULL &&
-	acpi_match_hid(ad->ad_parent->ad_devinfo, module_hid)) {
-		dmat = arm_acpi_dma_tag_subregion(sc, dmat,
-		ad->ad_parent->ad_handle);
-	}
+	module = arm_acpi_dma_module(sc, ad);
+	if (module != NULL)
+		dmat = arm_acpi_dma_tag_subregion(sc, dmat, module);
 
 	return dmat;
 }



CVS commit: src/sys/arch/arm/acpi

2019-12-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Dec 30 19:50:29 UTC 2019

Modified Files:
src/sys/arch/arm/acpi: acpi_machdep.c

Log Message:
If a device node is a child of a module device, and the module device declares 
DMA range restrictions, use them.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/acpi/acpi_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2019-12-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Dec 30 19:50:29 UTC 2019

Modified Files:
src/sys/arch/arm/acpi: acpi_machdep.c

Log Message:
If a device node is a child of a module device, and the module device declares 
DMA range restrictions, use them.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/acpi/acpi_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_machdep.c:1.14 src/sys/arch/arm/acpi/acpi_machdep.c:1.15
--- src/sys/arch/arm/acpi/acpi_machdep.c:1.14	Sun Dec 29 23:47:56 2019
+++ src/sys/arch/arm/acpi/acpi_machdep.c	Mon Dec 30 19:50:29 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_machdep.c,v 1.14 2019/12/29 23:47:56 jmcneill Exp $ */
+/* $NetBSD: acpi_machdep.c,v 1.15 2019/12/30 19:50:29 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "pci.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.14 2019/12/29 23:47:56 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_machdep.c,v 1.15 2019/12/30 19:50:29 jmcneill Exp $");
 
 #include 
 #include 
@@ -367,18 +367,74 @@ acpi_md_callback(struct acpi_softc *sc)
 		config_found_ia(sc->sc_dev, "acpisdtbus", hdrp, NULL);
 }
 
+static const char * const module_hid[] = {
+	"ACPI0004",	/* Module device */
+	NULL
+};
+
+static bus_dma_tag_t
+arm_acpi_dma_tag_subregion(struct acpi_softc *sc, bus_dma_tag_t dmat,
+ACPI_HANDLE handle)
+{
+	struct acpi_resources res;
+	struct acpi_mem *mem;
+	bus_dma_tag_t newtag;
+	ACPI_STATUS rv;
+	int error;
+
+	rv = acpi_resource_parse(sc->sc_dev, handle, "_DMA", ,
+	_resource_parse_ops_quiet);
+	if (ACPI_FAILURE(rv))
+		return dmat;	/* no translation required */
+
+	mem = acpi_res_mem(, 0);
+	if (mem == NULL)
+		goto done;
+
+	aprint_debug_dev(sc->sc_dev, "_DMA range %#lx-%#lx\n",
+	mem->ar_base, mem->ar_base + mem->ar_length - 1);
+
+	error = bus_dmatag_subregion(dmat,
+	mem->ar_base, mem->ar_base + mem->ar_length - 1,
+	, BUS_DMA_WAITOK);
+	if (error != 0) {
+		aprint_error_dev(sc->sc_dev,
+		"_DMA subregion failed: %d\n", error);
+		goto done;
+	}
+	dmat = newtag;
+
+done:
+	acpi_resource_cleanup();
+
+	return dmat;
+}
+
 bus_dma_tag_t
 arm_acpi_dma_tag(struct acpi_softc *sc, struct acpi_devnode *ad)
 {
 	ACPI_INTEGER cca;
+	bus_dma_tag_t dmat;
 
 	if (ACPI_FAILURE(acpi_eval_integer(ad->ad_handle, "_CCA", )))
 		cca = 1;
 
 	if (cca)
-		return _coherent_dma_tag;
+		dmat = _coherent_dma_tag;
 	else
-		return _generic_dma_tag;
+		dmat = _generic_dma_tag;
+
+	/*
+	 * If the parent device is a bus, it may define valid DMA ranges
+	 * and translations for child nodes.
+	 */
+	if (ad->ad_parent != NULL &&
+	acpi_match_hid(ad->ad_parent->ad_devinfo, module_hid)) {
+		dmat = arm_acpi_dma_tag_subregion(sc, dmat,
+		ad->ad_parent->ad_handle);
+	}
+
+	return dmat;
 }
 __strong_alias(acpi_get_dma_tag,arm_acpi_dma_tag);
 __strong_alias(acpi_get_dma64_tag,arm_acpi_dma_tag);



CVS commit: src/sys/arch/arm/acpi

2019-10-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Oct 15 13:27:51 UTC 2019

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c acpi_pci_machdep.h acpipchb.c

Log Message:
Amazon Graviton maxdevs quirk no longer required as of pci.c r1.155


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/acpi/acpi_pci_machdep.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/acpi/acpi_pci_machdep.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_pci_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.11 src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.12
--- src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.11	Mon Oct 14 22:59:15 2019
+++ src/sys/arch/arm/acpi/acpi_pci_machdep.c	Tue Oct 15 13:27:50 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.c,v 1.11 2019/10/14 22:59:15 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_machdep.c,v 1.12 2019/10/15 13:27:50 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.11 2019/10/14 22:59:15 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.12 2019/10/15 13:27:50 jmcneill Exp $");
 
 #include 
 #include 
@@ -215,11 +215,6 @@ acpi_pci_md_attach_hook(device_t parent,
 static int
 acpi_pci_md_bus_maxdevs(void *v, int busno)
 {
-	struct acpi_pci_context * const ap = v;
-
-	if (ap->ap_bus_maxdevs != NULL)
-		return ap->ap_bus_maxdevs(ap, busno);
-
 	return 32;
 }
 

Index: src/sys/arch/arm/acpi/acpi_pci_machdep.h
diff -u src/sys/arch/arm/acpi/acpi_pci_machdep.h:1.4 src/sys/arch/arm/acpi/acpi_pci_machdep.h:1.5
--- src/sys/arch/arm/acpi/acpi_pci_machdep.h:1.4	Mon Oct 14 22:59:15 2019
+++ src/sys/arch/arm/acpi/acpi_pci_machdep.h	Tue Oct 15 13:27:50 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.h,v 1.4 2019/10/14 22:59:15 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_machdep.h,v 1.5 2019/10/15 13:27:50 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -44,7 +44,6 @@ struct acpi_pci_context {
 	bus_space_handle_t ap_conf_bsh;
 	int (*ap_conf_read)(pci_chipset_tag_t, pcitag_t, int, pcireg_t *);
 	int (*ap_conf_write)(pci_chipset_tag_t, pcitag_t, int, pcireg_t);
-	int (*ap_bus_maxdevs)(struct acpi_pci_context *, int);
 };
 
 #endif /* !_ARM_ACPI_PCI_MACHDEP_H */

Index: src/sys/arch/arm/acpi/acpipchb.c
diff -u src/sys/arch/arm/acpi/acpipchb.c:1.12 src/sys/arch/arm/acpi/acpipchb.c:1.13
--- src/sys/arch/arm/acpi/acpipchb.c:1.12	Tue Oct 15 00:23:44 2019
+++ src/sys/arch/arm/acpi/acpipchb.c	Tue Oct 15 13:27:50 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.12 2019/10/15 00:23:44 jmcneill Exp $ */
+/* $NetBSD: acpipchb.c,v 1.13 2019/10/15 13:27:50 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.12 2019/10/15 00:23:44 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.13 2019/10/15 13:27:50 jmcneill Exp $");
 
 #include 
 #include 
@@ -131,15 +131,6 @@ acpipchb_amazon_graviton_conf_write(pci_
 	return acpimcfg_conf_write(pc, tag, reg, data);
 }
 
-static int
-acpipchb_amazon_graviton_bus_maxdevs(struct acpi_pci_context *ap, int busno)
-{
-	if (busno == ap->ap_bus + 1)
-		return 1;
-
-	return 32;
-}
-
 static ACPI_STATUS
 acpipchb_amazon_graviton_map(ACPI_HANDLE handle, UINT32 level, void *ctx, void **retval)
 {
@@ -172,7 +163,6 @@ acpipchb_amazon_graviton_map(ACPI_HANDLE
 
 	ap->ap_conf_read = acpipchb_amazon_graviton_conf_read;
 	ap->ap_conf_write = acpipchb_amazon_graviton_conf_write;
-	ap->ap_bus_maxdevs = acpipchb_amazon_graviton_bus_maxdevs;
 
 	return AE_CTRL_TERMINATE;
 }



CVS commit: src/sys/arch/arm/acpi

2019-10-15 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Oct 15 13:27:51 UTC 2019

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c acpi_pci_machdep.h acpipchb.c

Log Message:
Amazon Graviton maxdevs quirk no longer required as of pci.c r1.155


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/acpi/acpi_pci_machdep.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/acpi/acpi_pci_machdep.h
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2019-10-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Oct 15 00:23:44 UTC 2019

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
Fix detection of root port resources for Graviton and remove no longer required 
bridge fixup


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpipchb.c
diff -u src/sys/arch/arm/acpi/acpipchb.c:1.11 src/sys/arch/arm/acpi/acpipchb.c:1.12
--- src/sys/arch/arm/acpi/acpipchb.c:1.11	Mon Oct 14 22:59:15 2019
+++ src/sys/arch/arm/acpi/acpipchb.c	Tue Oct 15 00:23:44 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: acpipchb.c,v 1.11 2019/10/14 22:59:15 jmcneill Exp $ */
+/* $NetBSD: acpipchb.c,v 1.12 2019/10/15 00:23:44 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.11 2019/10/14 22:59:15 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.12 2019/10/15 00:23:44 jmcneill Exp $");
 
 #include 
 #include 
@@ -146,9 +146,16 @@ acpipchb_amazon_graviton_map(ACPI_HANDLE
 	struct acpi_pci_context *ap = ctx;
 	struct acpi_resources res;
 	struct acpi_mem *mem;
+	ACPI_HANDLE parent;
 	ACPI_STATUS rv;
 	int error;
 
+	rv = AcpiGetParent(handle, );
+	if (ACPI_FAILURE(rv))
+		return rv;
+	if (ap->ap_handle != parent)
+		return AE_OK;
+
 	rv = acpi_resource_parse(ap->ap_dev, handle, "_CRS", , _resource_parse_ops_quiet);
 	if (ACPI_FAILURE(rv))
 		return rv;
@@ -163,18 +170,10 @@ acpipchb_amazon_graviton_map(ACPI_HANDLE
 	if (error != 0)
 		return AE_NO_MEMORY;
 
-	return AE_CTRL_TERMINATE;
-}
-
-static ACPI_STATUS
-acpipchb_amazon_graviton_busres(ACPI_RESOURCE *res, void *context)
-{
-	if (res->Type != ACPI_RESOURCE_TYPE_ADDRESS16)
-		return AE_OK;
-	if (res->Data.Address16.ResourceType != ACPI_BUS_NUMBER_RANGE)
-		return AE_OK;
+	ap->ap_conf_read = acpipchb_amazon_graviton_conf_read;
+	ap->ap_conf_write = acpipchb_amazon_graviton_conf_write;
+	ap->ap_bus_maxdevs = acpipchb_amazon_graviton_bus_maxdevs;
 
-	*(ACPI_RESOURCE *)context = *res;
 	return AE_CTRL_TERMINATE;
 }
 
@@ -182,51 +181,10 @@ static void
 acpipchb_amazon_graviton_init(struct acpi_pci_context *ap)
 {
 	ACPI_STATUS rv;
-	ACPI_RESOURCE res;
-	pcitag_t tag;
-	pcireg_t busdata;
 
 	rv = AcpiGetDevices(__UNCONST("AMZN0001"), acpipchb_amazon_graviton_map, ap, NULL);
 	if (ACPI_FAILURE(rv))
 		return;
-
-	ap->ap_conf_read = acpipchb_amazon_graviton_conf_read;
-	ap->ap_conf_write = acpipchb_amazon_graviton_conf_write;
-	ap->ap_bus_maxdevs = acpipchb_amazon_graviton_bus_maxdevs;
-
-	/*
-	 * The root port's may not have the correct bus information. Fix this up...
-	 */
-	/* Find bus number range */
-	memset(, 0, sizeof(res));
-	rv = AcpiWalkResources(ap->ap_handle, "_CRS", acpipchb_amazon_graviton_busres, );
-	if (ACPI_FAILURE(rv) || res.Type != ACPI_RESOURCE_TYPE_ADDRESS16)
-		return;
-
-	const int bus_primary = res.Data.Address16.Address.Minimum;
-	const int bus_secondary = bus_primary + 1;
-	const int bus_subordinate = res.Data.Address16.Address.Maximum;
-
-	tag = pci_make_tag(>ap_pc, ap->ap_bus, 0, 0);
-	busdata = pci_conf_read(>ap_pc, tag, PCI_BRIDGE_BUS_REG);
-	if (PCI_BRIDGE_BUS_NUM_PRIMARY(busdata) != bus_primary ||
-	PCI_BRIDGE_BUS_NUM_SECONDARY(busdata) != bus_secondary ||
-	PCI_BRIDGE_BUS_NUM_SUBORDINATE(busdata) != bus_subordinate) {
-
-		aprint_normal_dev(ap->ap_dev,
-		"fixup bridge bus numbers %#x/%#x/%#x -> %#x/%#x/%#x\n",
-		PCI_BRIDGE_BUS_NUM_PRIMARY(busdata),
-		PCI_BRIDGE_BUS_NUM_SECONDARY(busdata),
-		PCI_BRIDGE_BUS_NUM_SUBORDINATE(busdata),
-		bus_primary, bus_secondary, bus_subordinate);
-		busdata &= ~PCI_BRIDGE_BUS_PRIMARY;
-		busdata |= __SHIFTIN(bus_primary, PCI_BRIDGE_BUS_PRIMARY);
-		busdata &= ~PCI_BRIDGE_BUS_SECONDARY;
-		busdata |= __SHIFTIN(bus_secondary, PCI_BRIDGE_BUS_SECONDARY);
-		busdata &= ~PCI_BRIDGE_BUS_SUBORDINATE;
-		busdata |= __SHIFTIN(bus_subordinate, PCI_BRIDGE_BUS_SUBORDINATE);
-		pci_conf_write(>ap_pc, tag, PCI_BRIDGE_BUS_REG, busdata);
-	}
 }
 
 static const struct acpipchb_quirk {



CVS commit: src/sys/arch/arm/acpi

2019-10-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Oct 15 00:23:44 UTC 2019

Modified Files:
src/sys/arch/arm/acpi: acpipchb.c

Log Message:
Fix detection of root port resources for Graviton and remove no longer required 
bridge fixup


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/acpi/acpipchb.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2019-10-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 14 22:59:15 UTC 2019

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c acpi_pci_machdep.h acpipchb.c

Log Message:
More Amazon Graviton quirks:
 - Ignore devno > 0 on the PCIe root port.
 - Fixup PCIe bridge bus number register on the root port.
 - Move quirk handling to acpipchb so it can be applied before the bus
   is configured.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/acpi/acpi_pci_machdep.c \
src/sys/arch/arm/acpi/acpipchb.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/acpi/acpi_pci_machdep.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2019-10-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 14 22:59:15 UTC 2019

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c acpi_pci_machdep.h acpipchb.c

Log Message:
More Amazon Graviton quirks:
 - Ignore devno > 0 on the PCIe root port.
 - Fixup PCIe bridge bus number register on the root port.
 - Move quirk handling to acpipchb so it can be applied before the bus
   is configured.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/acpi/acpi_pci_machdep.c \
src/sys/arch/arm/acpi/acpipchb.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/acpi/acpi_pci_machdep.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_pci_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.10 src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.11
--- src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.10	Mon Oct 14 00:16:29 2019
+++ src/sys/arch/arm/acpi/acpi_pci_machdep.c	Mon Oct 14 22:59:15 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.c,v 1.10 2019/10/14 00:16:29 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_machdep.c,v 1.11 2019/10/14 22:59:15 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.10 2019/10/14 00:16:29 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.11 2019/10/14 22:59:15 jmcneill Exp $");
 
 #include 
 #include 
@@ -60,120 +60,6 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_pci_mac
 
 #include 
 
-static int
-acpi_pci_amazon_graviton_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t *data)
-{
-	struct acpi_pci_context *ap = pc->pc_conf_v;
-	bus_size_t off;
-	int b, d, f;
-
-	pci_decompose_tag(pc, tag, , , );
-
-	if (ap->ap_bus == b) {
-		if (d > 0) {
-			*data = -1;
-			return EINVAL;
-		}
-		off = f * PCI_EXTCONF_SIZE + reg;
-		*data = bus_space_read_4(ap->ap_bst, ap->ap_conf_bsh, off);
-		return 0;
-	}
-	
-	return acpimcfg_conf_read(pc, tag, reg, data);
-}
-
-static int
-acpi_pci_amazon_graviton_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t data)
-{
-	struct acpi_pci_context *ap = pc->pc_conf_v;
-	bus_size_t off;
-	int b, d, f;
-
-	pci_decompose_tag(pc, tag, , , );
-
-	if (ap->ap_bus == b) {
-		if (d > 0) {
-			return EINVAL;
-		}
-		off = f * PCI_EXTCONF_SIZE + reg;
-		bus_space_write_4(ap->ap_bst, ap->ap_conf_bsh, off, data);
-		return 0;
-	}
-	
-	return acpimcfg_conf_write(pc, tag, reg, data);
-}
-
-static ACPI_STATUS
-acpi_pci_amazon_graviton_map(ACPI_HANDLE handle, UINT32 level, void *ctx, void **retval)
-{
-	struct acpi_pci_context *ap = ctx;
-	struct acpi_resources res;
-	struct acpi_mem *mem;
-	ACPI_STATUS rv;
-	int error;
-
-	rv = acpi_resource_parse(ap->ap_dev, handle, "_CRS", , _resource_parse_ops_quiet);
-	if (ACPI_FAILURE(rv))
-		return rv;
-
-	mem = acpi_res_mem(, 0);
-	if (mem == NULL) {
-		acpi_resource_cleanup();
-		return AE_NOT_FOUND;
-	}
-
-	error = bus_space_map(ap->ap_bst, mem->ar_base, mem->ar_length, 0, >ap_conf_bsh);
-	if (error != 0)
-		return AE_NO_MEMORY;
-
-	return AE_CTRL_TERMINATE;
-}
-
-static void
-acpi_pci_amazon_graviton_init(struct pcibus_attach_args *pba)
-{
-	struct acpi_pci_context *ap = pba->pba_pc->pc_conf_v;
-	ACPI_STATUS rv;
-
-	rv = AcpiGetDevices(__UNCONST("AMZN0001"), acpi_pci_amazon_graviton_map, ap, NULL);
-	if (ACPI_FAILURE(rv))
-		return;
-
-	ap->ap_conf_read = acpi_pci_amazon_graviton_conf_read;
-	ap->ap_conf_write = acpi_pci_amazon_graviton_conf_write;
-}
-
-static const struct acpi_pci_quirk {
-	const char			q_oemid[ACPI_OEM_ID_SIZE+1];
-	const char			q_oemtableid[ACPI_OEM_TABLE_ID_SIZE+1];
-	uint32_t			q_oemrevision;
-	void(*q_init)(struct pcibus_attach_args *);
-} acpi_pci_quirks[] = {
-	{ "AMAZON",	"GRAVITON",	0,	acpi_pci_amazon_graviton_init },
-};
-
-static const struct acpi_pci_quirk *
-acpi_pci_find_quirk(void)
-{
-	ACPI_STATUS rv;
-	ACPI_TABLE_MCFG *mcfg;
-	u_int n;
-
-	rv = AcpiGetTable(ACPI_SIG_MCFG, 0, (ACPI_TABLE_HEADER **));
-	if (ACPI_FAILURE(rv))
-		return NULL;
-
-	for (n = 0; n < __arraycount(acpi_pci_quirks); n++) {
-		const struct acpi_pci_quirk *q = _pci_quirks[n];
-		if (memcmp(q->q_oemid, mcfg->Header.OemId, ACPI_OEM_ID_SIZE) == 0 &&
-		memcmp(q->q_oemtableid, mcfg->Header.OemTableId, ACPI_OEM_TABLE_ID_SIZE) == 0 &&
-		q->q_oemrevision == mcfg->Header.OemRevision)
-			return q;
-	}
-
-	return NULL;
-}
-
 struct acpi_pci_prt {
 	u_intprt_segment;
 	u_intprt_bus;
@@ -274,7 +160,6 @@ acpi_pci_md_attach_hook(device_t parent,
 {
 	struct acpi_pci_context *ap = pba->pba_pc->pc_conf_v;
 	struct acpi_pci_prt *prt, *prtp;
-	const struct acpi_pci_quirk *q;
 	struct acpi_devnode *ad;
 	ACPI_HANDLE handle;
 	int seg, bus, dev, func;
@@ -317,10 +202,6 @@ acpi_pci_md_attach_hook(device_t parent,
 		TAILQ_INSERT_TAIL(_pci_irq_routes, prt, prt_list);
 	}
 
-	q = acpi_pci_find_quirk();
-	if (q != NULL)
-		

CVS commit: src/sys/arch/arm/acpi

2019-10-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 14 00:16:29 UTC 2019

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c acpi_pci_machdep.h acpipchb.c

Log Message:
Add quirks for Amazon Graviton PCIe root ports. Configuration space for the
root port is found in a child AMZN0001 resource, not the MCFG table.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/acpi/acpi_pci_machdep.c \
src/sys/arch/arm/acpi/acpipchb.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/acpi/acpi_pci_machdep.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_pci_machdep.c
diff -u src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.9 src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.10
--- src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.9	Sat Dec  8 15:04:40 2018
+++ src/sys/arch/arm/acpi/acpi_pci_machdep.c	Mon Oct 14 00:16:29 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_pci_machdep.c,v 1.9 2018/12/08 15:04:40 jmcneill Exp $ */
+/* $NetBSD: acpi_pci_machdep.c,v 1.10 2019/10/14 00:16:29 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.9 2018/12/08 15:04:40 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.10 2019/10/14 00:16:29 jmcneill Exp $");
 
 #include 
 #include 
@@ -60,6 +60,120 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_pci_mac
 
 #include 
 
+static int
+acpi_pci_amazon_graviton_conf_read(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t *data)
+{
+	struct acpi_pci_context *ap = pc->pc_conf_v;
+	bus_size_t off;
+	int b, d, f;
+
+	pci_decompose_tag(pc, tag, , , );
+
+	if (ap->ap_bus == b) {
+		if (d > 0) {
+			*data = -1;
+			return EINVAL;
+		}
+		off = f * PCI_EXTCONF_SIZE + reg;
+		*data = bus_space_read_4(ap->ap_bst, ap->ap_conf_bsh, off);
+		return 0;
+	}
+	
+	return acpimcfg_conf_read(pc, tag, reg, data);
+}
+
+static int
+acpi_pci_amazon_graviton_conf_write(pci_chipset_tag_t pc, pcitag_t tag, int reg, pcireg_t data)
+{
+	struct acpi_pci_context *ap = pc->pc_conf_v;
+	bus_size_t off;
+	int b, d, f;
+
+	pci_decompose_tag(pc, tag, , , );
+
+	if (ap->ap_bus == b) {
+		if (d > 0) {
+			return EINVAL;
+		}
+		off = f * PCI_EXTCONF_SIZE + reg;
+		bus_space_write_4(ap->ap_bst, ap->ap_conf_bsh, off, data);
+		return 0;
+	}
+	
+	return acpimcfg_conf_write(pc, tag, reg, data);
+}
+
+static ACPI_STATUS
+acpi_pci_amazon_graviton_map(ACPI_HANDLE handle, UINT32 level, void *ctx, void **retval)
+{
+	struct acpi_pci_context *ap = ctx;
+	struct acpi_resources res;
+	struct acpi_mem *mem;
+	ACPI_STATUS rv;
+	int error;
+
+	rv = acpi_resource_parse(ap->ap_dev, handle, "_CRS", , _resource_parse_ops_quiet);
+	if (ACPI_FAILURE(rv))
+		return rv;
+
+	mem = acpi_res_mem(, 0);
+	if (mem == NULL) {
+		acpi_resource_cleanup();
+		return AE_NOT_FOUND;
+	}
+
+	error = bus_space_map(ap->ap_bst, mem->ar_base, mem->ar_length, 0, >ap_conf_bsh);
+	if (error != 0)
+		return AE_NO_MEMORY;
+
+	return AE_CTRL_TERMINATE;
+}
+
+static void
+acpi_pci_amazon_graviton_init(struct pcibus_attach_args *pba)
+{
+	struct acpi_pci_context *ap = pba->pba_pc->pc_conf_v;
+	ACPI_STATUS rv;
+
+	rv = AcpiGetDevices(__UNCONST("AMZN0001"), acpi_pci_amazon_graviton_map, ap, NULL);
+	if (ACPI_FAILURE(rv))
+		return;
+
+	ap->ap_conf_read = acpi_pci_amazon_graviton_conf_read;
+	ap->ap_conf_write = acpi_pci_amazon_graviton_conf_write;
+}
+
+static const struct acpi_pci_quirk {
+	const char			q_oemid[ACPI_OEM_ID_SIZE+1];
+	const char			q_oemtableid[ACPI_OEM_TABLE_ID_SIZE+1];
+	uint32_t			q_oemrevision;
+	void(*q_init)(struct pcibus_attach_args *);
+} acpi_pci_quirks[] = {
+	{ "AMAZON",	"GRAVITON",	0,	acpi_pci_amazon_graviton_init },
+};
+
+static const struct acpi_pci_quirk *
+acpi_pci_find_quirk(void)
+{
+	ACPI_STATUS rv;
+	ACPI_TABLE_MCFG *mcfg;
+	u_int n;
+
+	rv = AcpiGetTable(ACPI_SIG_MCFG, 0, (ACPI_TABLE_HEADER **));
+	if (ACPI_FAILURE(rv))
+		return NULL;
+
+	for (n = 0; n < __arraycount(acpi_pci_quirks); n++) {
+		const struct acpi_pci_quirk *q = _pci_quirks[n];
+		if (memcmp(q->q_oemid, mcfg->Header.OemId, ACPI_OEM_ID_SIZE) == 0 &&
+		memcmp(q->q_oemtableid, mcfg->Header.OemTableId, ACPI_OEM_TABLE_ID_SIZE) == 0 &&
+		q->q_oemrevision == mcfg->Header.OemRevision)
+			return q;
+	}
+
+	return NULL;
+}
+
 struct acpi_pci_prt {
 	u_intprt_segment;
 	u_intprt_bus;
@@ -160,6 +274,7 @@ acpi_pci_md_attach_hook(device_t parent,
 {
 	struct acpi_pci_context *ap = pba->pba_pc->pc_conf_v;
 	struct acpi_pci_prt *prt, *prtp;
+	const struct acpi_pci_quirk *q;
 	struct acpi_devnode *ad;
 	ACPI_HANDLE handle;
 	int seg, bus, dev, func;
@@ -202,6 +317,10 @@ acpi_pci_md_attach_hook(device_t parent,
 		TAILQ_INSERT_TAIL(_pci_irq_routes, prt, prt_list);
 	}
 
+	q = acpi_pci_find_quirk();
+	if (q != NULL)
+		q->q_init(pba);
+
 	acpimcfg_map_bus(self, pba->pba_pc, pba->pba_bus);
 
 	if (ad != 

CVS commit: src/sys/arch/arm/acpi

2019-10-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Oct 14 00:16:29 UTC 2019

Modified Files:
src/sys/arch/arm/acpi: acpi_pci_machdep.c acpi_pci_machdep.h acpipchb.c

Log Message:
Add quirks for Amazon Graviton PCIe root ports. Configuration space for the
root port is found in a child AMZN0001 resource, not the MCFG table.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/acpi/acpi_pci_machdep.c \
src/sys/arch/arm/acpi/acpipchb.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/acpi/acpi_pci_machdep.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/arm/acpi

2019-09-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Sep 22 18:31:59 UTC 2019

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c files.acpi
Added Files:
src/sys/arch/arm/acpi: acpi_simplefb.c acpi_simplefb.h

Log Message:
Use vcons for simplefb preattach to speed up early console messages.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/acpi/acpi_platform.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/acpi/acpi_simplefb.c \
src/sys/arch/arm/acpi/acpi_simplefb.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/acpi/files.acpi

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/arm/acpi/acpi_platform.c
diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.17 src/sys/arch/arm/acpi/acpi_platform.c:1.18
--- src/sys/arch/arm/acpi/acpi_platform.c:1.17	Mon Aug 19 10:53:31 2019
+++ src/sys/arch/arm/acpi/acpi_platform.c	Sun Sep 22 18:31:59 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.17 2019/08/19 10:53:31 jmcneill Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.18 2019/09/22 18:31:59 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.17 2019/08/19 10:53:31 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.18 2019/09/22 18:31:59 jmcneill Exp $");
 
 #include 
 #include 
@@ -73,12 +73,8 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_platfor
 #include 
 #endif
 
-#if NWSDISPLAY > 0
-#include 
-#include 
-#include 
-#include 
-#include 
+#if NWSDISPLAY > 0 && NGENFB > 0
+#include 
 #endif
 
 #ifdef EFI_RUNTIME
@@ -134,107 +130,6 @@ acpi_platform_bootstrap(void)
 	acpi_coherent_dma_tag._nranges = __arraycount(acpi_coherent_ranges);
 }
 
-#if NWSDISPLAY > 0 && NGENFB > 0
-static struct wsscreen_descr acpi_platform_stdscreen = {
-	.name = "std",
-	.ncols = 0,
-	.nrows = 0,
-	.textops = NULL,
-	.fontwidth = 0,
-	.fontheight = 0,
-	.capabilities = 0,
-	.modecookie = NULL
-};
-
-static struct vcons_screen acpi_platform_screen;
-
-static int
-acpi_platform_find_simplefb(void)
-{
-	static const char * simplefb_compatible[] = { "simple-framebuffer", NULL };
-	int chosen_phandle, child;
-
-	chosen_phandle = OF_finddevice("/chosen");
-	if (chosen_phandle == -1)
-		return -1;
-
-	for (child = OF_child(chosen_phandle); child; child = OF_peer(child)) {
-		if (!fdtbus_status_okay(child))
-			continue;
-		if (!of_match_compatible(child, simplefb_compatible))
-			continue;
-
-		return child;
-	}
-
-	return -1;
-}
-
-static void
-acpi_platform_wsdisplay_preattach(void)
-{
-	struct rasops_info *ri = _platform_screen.scr_ri;
-	bus_space_tag_t bst = _generic_bs_tag;
-	bus_space_handle_t bsh;
-	uint32_t width, height, stride;
-	const char *format;
-	bus_addr_t addr;
-	bus_size_t size;
-	uint16_t depth;
-	long defattr;
-
-	memset(_platform_screen, 0, sizeof(acpi_platform_screen));
-
-	const int phandle = acpi_platform_find_simplefb();
-	if (phandle == -1)
-		return;
-
-	if (fdtbus_get_reg(phandle, 0, , ) != 0 || size == 0)
-		return;
-
-	if (of_getprop_uint32(phandle, "width", ) != 0 ||
-	of_getprop_uint32(phandle, "height", ) != 0 ||
-	of_getprop_uint32(phandle, "stride", ) != 0 ||
-	(format = fdtbus_get_string(phandle, "format")) == NULL)
-		return;
-
-	if (strcmp(format, "a8b8g8r8") == 0 ||
-	strcmp(format, "x8r8g8b8") == 0) {
-		depth = 32;
-	} else if (strcmp(format, "r5g6b5") == 0) {
-		depth = 16;
-	} else {
-		return;
-	}
-
-	if (bus_space_map(bst, addr, size,
-	BUS_SPACE_MAP_LINEAR | BUS_SPACE_MAP_PREFETCHABLE, ) != 0)
-		return;
-
-	wsfont_init();
-
-	ri->ri_width = width;
-	ri->ri_height = height;
-	ri->ri_depth = depth;
-	ri->ri_stride = stride;
-	ri->ri_bits = bus_space_vaddr(bst, bsh);
-	ri->ri_flg = RI_CENTER | RI_FULLCLEAR | RI_CLEAR;
-	rasops_init(ri, ri->ri_height / 8, ri->ri_width / 8);
-	ri->ri_caps = WSSCREEN_WSCOLORS;
-	rasops_reconfig(ri, ri->ri_height / ri->ri_font->fontheight,
-	ri->ri_width / ri->ri_font->fontwidth);
-
-	acpi_platform_stdscreen.nrows = ri->ri_rows;
-	acpi_platform_stdscreen.ncols = ri->ri_cols;
-	acpi_platform_stdscreen.textops = >ri_ops;
-	acpi_platform_stdscreen.capabilities = ri->ri_caps;
-
-	ri->ri_ops.allocattr(ri, 0, 0, 0, );
-
-	wsdisplay_preattach(_platform_stdscreen, ri, 0, 0, defattr);
-}
-#endif
-
 static void
 acpi_platform_startup(void)
 {
@@ -309,13 +204,6 @@ acpi_platform_startup(void)
 	}
 
 	/*
-	 * Setup framebuffer console, if present.
-	 */
-#if NWSDISPLAY > 0 && NGENFB > 0
-	acpi_platform_wsdisplay_preattach();
-#endif
-
-	/*
 	 * Initialize PSCI 0.2+ if implemented
 	 */
 	if (ACPI_SUCCESS(acpi_table_find(ACPI_SIG_FADT, (void ** {
@@ -361,6 +249,15 @@ acpi_platform_init_attach_args(struct fd
 static void
 acpi_platform_device_register(device_t self, void *aux)
 {
+#if NWSDISPLAY > 0 && NGENFB > 0
+	if (device_is_a(self, "armfdt")) {
+		/*
+		 * Setup 

CVS commit: src/sys/arch/arm/acpi

2019-09-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Sep 22 18:31:59 UTC 2019

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c files.acpi
Added Files:
src/sys/arch/arm/acpi: acpi_simplefb.c acpi_simplefb.h

Log Message:
Use vcons for simplefb preattach to speed up early console messages.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/acpi/acpi_platform.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/acpi/acpi_simplefb.c \
src/sys/arch/arm/acpi/acpi_simplefb.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/acpi/files.acpi

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



  1   2   >