Module Name: src Committed By: jmcneill Date: Fri Oct 19 11:40:27 UTC 2018
Modified Files: src/sys/arch/arm/acpi: acpi_pci_machdep.c acpi_pci_machdep.h acpipchb.c Log Message: Add support for PCI Segment Groups. To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/acpi/acpi_pci_machdep.c \ src/sys/arch/arm/acpi/acpi_pci_machdep.h 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.1 src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.2 --- src/sys/arch/arm/acpi/acpi_pci_machdep.c:1.1 Mon Oct 15 11:35:03 2018 +++ src/sys/arch/arm/acpi/acpi_pci_machdep.c Fri Oct 19 11:40:27 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_pci_machdep.c,v 1.1 2018/10/15 11:35:03 jmcneill Exp $ */ +/* $NetBSD: acpi_pci_machdep.c,v 1.2 2018/10/19 11:40:27 jmcneill Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.1 2018/10/15 11:35:03 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpi_pci_machdep.c,v 1.2 2018/10/19 11:40:27 jmcneill Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -55,6 +55,8 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_pci_mac #include <dev/acpi/acpi_mcfg.h> #include <dev/acpi/acpi_pci.h> +#include <arm/acpi/acpi_pci_machdep.h> + #define IH_INDEX_MASK 0x0000ffff #define IH_MPSAFE 0x80000000 @@ -150,12 +152,13 @@ static void acpi_pci_md_attach_hook(device_t parent, device_t self, struct pcibus_attach_args *pba) { + struct acpi_pci_context *ap = pba->pba_pc->pc_conf_v; struct acpi_pci_prt *prt, *prtp; struct acpi_devnode *ad; ACPI_HANDLE handle; int seg, bus, dev, func; - seg = 0; /* XXX segment */ + seg = ap->ap_seg; handle = NULL; if (pba->pba_bridgetag) { @@ -228,12 +231,13 @@ acpi_pci_md_decompose_tag(void *v, pcita static pcireg_t acpi_pci_md_conf_read(void *v, pcitag_t tag, int offset) { + struct acpi_pci_context * const ap = v; pcireg_t val; if (offset < 0 || offset >= PCI_EXTCONF_SIZE) return (pcireg_t) -1; - acpimcfg_conf_read(&arm_acpi_pci_chipset, tag, offset, &val); + acpimcfg_conf_read(&ap->ap_pc, tag, offset, &val); return val; } @@ -241,10 +245,12 @@ acpi_pci_md_conf_read(void *v, pcitag_t static void acpi_pci_md_conf_write(void *v, pcitag_t tag, int offset, pcireg_t val) { + struct acpi_pci_context * const ap = v; + if (offset < 0 || offset >= PCI_EXTCONF_SIZE) return; - acpimcfg_conf_write(&arm_acpi_pci_chipset, tag, offset, val); + acpimcfg_conf_write(&ap->ap_pc, tag, offset, val); } static int Index: src/sys/arch/arm/acpi/acpi_pci_machdep.h diff -u src/sys/arch/arm/acpi/acpi_pci_machdep.h:1.1 src/sys/arch/arm/acpi/acpi_pci_machdep.h:1.2 --- src/sys/arch/arm/acpi/acpi_pci_machdep.h:1.1 Mon Oct 15 11:35:03 2018 +++ src/sys/arch/arm/acpi/acpi_pci_machdep.h Fri Oct 19 11:40:27 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: acpi_pci_machdep.h,v 1.1 2018/10/15 11:35:03 jmcneill Exp $ */ +/* $NetBSD: acpi_pci_machdep.h,v 1.2 2018/10/19 11:40:27 jmcneill Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -34,4 +34,9 @@ extern struct arm32_pci_chipset arm_acpi_pci_chipset; +struct acpi_pci_context { + struct arm32_pci_chipset ap_pc; + u_int ap_seg; +}; + #endif /* !_ARM_ACPI_PCI_MACHDEP_H */ Index: src/sys/arch/arm/acpi/acpipchb.c diff -u src/sys/arch/arm/acpi/acpipchb.c:1.1 src/sys/arch/arm/acpi/acpipchb.c:1.2 --- src/sys/arch/arm/acpi/acpipchb.c:1.1 Mon Oct 15 11:35:03 2018 +++ src/sys/arch/arm/acpi/acpipchb.c Fri Oct 19 11:40:27 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: acpipchb.c,v 1.1 2018/10/15 11:35:03 jmcneill Exp $ */ +/* $NetBSD: acpipchb.c,v 1.2 2018/10/19 11:40:27 jmcneill Exp $ */ /*- * Copyright (c) 2018 The NetBSD Foundation, Inc. @@ -30,7 +30,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.1 2018/10/15 11:35:03 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v 1.2 2018/10/19 11:40:27 jmcneill Exp $"); #include <sys/param.h> #include <sys/bus.h> @@ -54,12 +54,15 @@ __KERNEL_RCSID(0, "$NetBSD: acpipchb.c,v #include <dev/acpi/acpivar.h> #include <dev/acpi/acpi_mcfg.h> +#include <arm/acpi/acpi_pci_machdep.h> + #define PCIHOST_CACHELINE_SIZE arm_dcache_align struct acpipchb_softc { device_t sc_dev; struct arm32_bus_dma_tag sc_dmat; + struct acpi_pci_context sc_ap; ACPI_HANDLE sc_handle; ACPI_INTEGER sc_bus; @@ -102,7 +105,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 cca; + ACPI_INTEGER cca, seg; sc->sc_dev = self; sc->sc_handle = aa->aa_node->ad_handle; @@ -110,23 +113,30 @@ acpipchb_attach(device_t parent, device_ if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_BBN", &sc->sc_bus))) sc->sc_bus = 0; + if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_SEG", &seg))) + seg = 0; + if (ACPI_FAILURE(acpi_eval_integer(sc->sc_handle, "_CCA", &cca))) cca = 0; aprint_naive("\n"); aprint_normal(": PCI Express Host Bridge\n"); - 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 PCI bus\n"); - return; - } - sc->sc_dmat = *aa->aa_dmat; if (cca) { sc->sc_dmat._ranges = ahcipchb_coherent_ranges; sc->sc_dmat._nranges = __arraycount(ahcipchb_coherent_ranges); } + sc->sc_ap.ap_pc = *aa->aa_pc; + sc->sc_ap.ap_pc.pc_conf_v = &sc->sc_ap; + sc->sc_ap.ap_seg = seg; + + if (acpimcfg_configure_bus(self, &sc->sc_ap.ap_pc, sc->sc_handle, sc->sc_bus, PCIHOST_CACHELINE_SIZE) != 0) { + aprint_error_dev(self, "failed to configure PCI bus\n"); + return; + } + memset(&pba, 0, sizeof(pba)); pba.pba_flags = aa->aa_pciflags; pba.pba_iot = aa->aa_iot; @@ -135,7 +145,7 @@ acpipchb_attach(device_t parent, device_ #ifdef _PCI_HAVE_DMA64 pba.pba_dmat64 = &sc->sc_dmat; #endif - pba.pba_pc = aa->aa_pc; + pba.pba_pc = &sc->sc_ap.ap_pc; pba.pba_bus = sc->sc_bus; config_found_ia(self, "pcibus", &pba, pcibusprint);