summaryrefslogtreecommitdiffstats
path: root/sys/arm64
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arm64')
-rw-r--r--sys/arm64/arm64/gic_fdt.c2
-rw-r--r--sys/arm64/arm64/gic_v3_fdt.c3
-rw-r--r--sys/arm64/arm64/gic_v3_its.c2
-rw-r--r--sys/arm64/arm64/nexus.c11
-rw-r--r--sys/arm64/arm64/ofw_machdep.c6
-rw-r--r--sys/arm64/cavium/thunder_pcie.c2
-rw-r--r--sys/arm64/cavium/thunder_pcie_common.h1
-rw-r--r--sys/arm64/cavium/thunder_pcie_fdt.c2
-rw-r--r--sys/arm64/cavium/thunder_pcie_pem.c58
-rw-r--r--sys/arm64/cavium/thunder_pcie_pem.h53
-rw-r--r--sys/arm64/cavium/thunder_pcie_pem_fdt.c83
-rw-r--r--sys/arm64/include/devmap.h4
12 files changed, 187 insertions, 40 deletions
diff --git a/sys/arm64/arm64/gic_fdt.c b/sys/arm64/arm64/gic_fdt.c
index 075f1d6..34d8009 100644
--- a/sys/arm64/arm64/gic_fdt.c
+++ b/sys/arm64/arm64/gic_fdt.c
@@ -211,7 +211,7 @@ arm_gic_fdt_alloc_resource(device_t bus, device_t child, int type, int *rid,
* Request for the default allocation with a given rid: use resource
* list stored in the local device info.
*/
- if ((start == 0UL) && (end == ~0UL)) {
+ if (RMAN_IS_DEFAULT_RANGE(start, end)) {
if ((di = device_get_ivars(child)) == NULL)
return (NULL);
diff --git a/sys/arm64/arm64/gic_v3_fdt.c b/sys/arm64/arm64/gic_v3_fdt.c
index 6c8de49..e5d75c3 100644
--- a/sys/arm64/arm64/gic_v3_fdt.c
+++ b/sys/arm64/arm64/gic_v3_fdt.c
@@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <sys/bus.h>
#include <sys/kernel.h>
#include <sys/module.h>
+#include <sys/rman.h>
#include <machine/resource.h>
@@ -180,7 +181,7 @@ gic_v3_ofw_bus_alloc_res(device_t bus, device_t child, int type, int *rid,
struct resource_list_entry *rle;
int ranges_len;
- if ((start == 0UL) && (end == ~0UL)) {
+ if (RMAN_IS_DEFAULT_RANGE(start, end)) {
if ((di = device_get_ivars(child)) == NULL)
return (NULL);
if (type != SYS_RES_MEMORY)
diff --git a/sys/arm64/arm64/gic_v3_its.c b/sys/arm64/arm64/gic_v3_its.c
index 7a547c1..c847f95 100644
--- a/sys/arm64/arm64/gic_v3_its.c
+++ b/sys/arm64/arm64/gic_v3_its.c
@@ -59,7 +59,7 @@ __FBSDID("$FreeBSD$");
#include "gic_v3_reg.h"
#include "gic_v3_var.h"
-#define GIC_V3_ITS_QUIRK_THUNDERX_PEM_BUS_OFFSET 144
+#define GIC_V3_ITS_QUIRK_THUNDERX_PEM_BUS_OFFSET 88
#include "pic_if.h"
diff --git a/sys/arm64/arm64/nexus.c b/sys/arm64/arm64/nexus.c
index 611addd..94b9048 100644
--- a/sys/arm64/arm64/nexus.c
+++ b/sys/arm64/arm64/nexus.c
@@ -113,6 +113,7 @@ static int nexus_deactivate_resource(device_t, device_t, int, int,
static int nexus_setup_intr(device_t dev, device_t child, struct resource *res,
int flags, driver_filter_t *filt, driver_intr_t *intr, void *arg, void **cookiep);
static int nexus_teardown_intr(device_t, device_t, struct resource *, void *);
+static bus_space_tag_t nexus_get_bus_tag(device_t, device_t);
#ifdef SMP
static int nexus_bind_intr(device_t, device_t, struct resource *, int);
#endif
@@ -134,6 +135,7 @@ static device_method_t nexus_methods[] = {
DEVMETHOD(bus_deactivate_resource, nexus_deactivate_resource),
DEVMETHOD(bus_setup_intr, nexus_setup_intr),
DEVMETHOD(bus_teardown_intr, nexus_teardown_intr),
+ DEVMETHOD(bus_get_bus_tag, nexus_get_bus_tag),
#ifdef SMP
DEVMETHOD(bus_bind_intr, nexus_bind_intr),
#endif
@@ -221,7 +223,7 @@ nexus_alloc_resource(device_t bus, device_t child, int type, int *rid,
* (ie. they aren't maintained by a child bus), then work out
* the start/end values.
*/
- if ((start == 0UL) && (end == ~0UL) && (count == 1)) {
+ if (RMAN_IS_DEFAULT_RANGE(start, end) && (count == 1)) {
if (device_get_parent(child) != bus || ndev == NULL)
return(NULL);
rle = resource_list_find(&ndev->nx_resources, type, *rid);
@@ -307,6 +309,13 @@ nexus_bind_intr(device_t dev, device_t child, struct resource *irq, int cpu)
}
#endif
+static bus_space_tag_t
+nexus_get_bus_tag(device_t bus __unused, device_t child __unused)
+{
+
+ return(&memmap_bus);
+}
+
static int
nexus_activate_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)
diff --git a/sys/arm64/arm64/ofw_machdep.c b/sys/arm64/arm64/ofw_machdep.c
index 6a0b714..3941c1d 100644
--- a/sys/arm64/arm64/ofw_machdep.c
+++ b/sys/arm64/arm64/ofw_machdep.c
@@ -39,7 +39,7 @@ extern struct bus_space memmap_bus;
int
OF_decode_addr(phandle_t dev, int regno, bus_space_tag_t *tag,
- bus_space_handle_t *handle)
+ bus_space_handle_t *handle, bus_size_t *sz)
{
bus_addr_t addr;
bus_size_t size;
@@ -50,5 +50,9 @@ OF_decode_addr(phandle_t dev, int regno, bus_space_tag_t *tag,
return (err);
*tag = &memmap_bus;
+
+ if (sz != NULL)
+ *sz = size;
+
return (bus_space_map(*tag, addr, size, 0, handle));
}
diff --git a/sys/arm64/cavium/thunder_pcie.c b/sys/arm64/cavium/thunder_pcie.c
index ca2fd6f..b4ac43c 100644
--- a/sys/arm64/cavium/thunder_pcie.c
+++ b/sys/arm64/cavium/thunder_pcie.c
@@ -292,7 +292,7 @@ thunder_pcie_alloc_resource(device_t dev, device_t child, int type, int *rid,
type, rid, start, end, count, flags));
};
- if ((start == 0UL) && (end == ~0UL)) {
+ if (RMAN_IS_DEFAULT_RANGE(start, end)) {
/* Read BAR manually to get resource address and size */
pci_read_bar(child, *rid, &map, &testval, NULL);
diff --git a/sys/arm64/cavium/thunder_pcie_common.h b/sys/arm64/cavium/thunder_pcie_common.h
index 548a435..c9119bb 100644
--- a/sys/arm64/cavium/thunder_pcie_common.h
+++ b/sys/arm64/cavium/thunder_pcie_common.h
@@ -33,6 +33,7 @@
#define RANGES_TUPLES_INVALID (RANGES_TUPLES_MAX + 1)
DECLARE_CLASS(thunder_pcie_driver);
+DECLARE_CLASS(thunder_pem_driver);
MALLOC_DECLARE(M_THUNDER_PCIE);
diff --git a/sys/arm64/cavium/thunder_pcie_fdt.c b/sys/arm64/cavium/thunder_pcie_fdt.c
index f1624f6..09b5660 100644
--- a/sys/arm64/cavium/thunder_pcie_fdt.c
+++ b/sys/arm64/cavium/thunder_pcie_fdt.c
@@ -283,7 +283,7 @@ thunder_pcie_ofw_bus_alloc_res(device_t bus, device_t child, int type, int *rid,
sc = device_get_softc(bus);
- if ((start == 0UL) && (end == ~0UL)) {
+ if (RMAN_IS_DEFAULT_RANGE(start, end)) {
if ((di = device_get_ivars(child)) == NULL)
return (NULL);
if (type == SYS_RES_IOPORT)
diff --git a/sys/arm64/cavium/thunder_pcie_pem.c b/sys/arm64/cavium/thunder_pcie_pem.c
index e4406c3..0f1e6a3 100644
--- a/sys/arm64/cavium/thunder_pcie_pem.c
+++ b/sys/arm64/cavium/thunder_pcie_pem.c
@@ -49,12 +49,12 @@ __FBSDID("$FreeBSD$");
#include <machine/smp.h>
#include <machine/intr.h>
-#include "thunder_pcie_common.h"
+#include <arm64/cavium/thunder_pcie_common.h>
+#include <arm64/cavium/thunder_pcie_pem.h>
#include "pcib_if.h"
#define THUNDER_PEM_DEVICE_ID 0xa020
#define THUNDER_PEM_VENDOR_ID 0x177d
-#define THUNDER_PEM_DESC "ThunderX PEM"
/* ThunderX specific defines */
#define THUNDER_PEMn_REG_BASE(unit) (0x87e0c0000000UL | ((unit) << 24))
@@ -109,21 +109,7 @@ __FBSDID("$FreeBSD$");
#define PCI_MEMORY_BASE PCI_IO_SIZE
#define PCI_MEMORY_SIZE 0xFFF00000UL
-struct thunder_pem_softc {
- device_t dev;
- struct resource *reg;
- bus_space_tag_t reg_bst;
- bus_space_handle_t reg_bsh;
- struct pcie_range ranges[RANGES_TUPLES_MAX];
- struct rman mem_rman;
- struct rman io_rman;
- bus_space_handle_t pem_sli_base;
- uint32_t node;
- uint32_t id;
- uint32_t sli;
- uint32_t sli_group;
- uint64_t sli_window_base;
-};
+#define RID_PEM_SPACE 1
static struct resource * thunder_pem_alloc_resource(device_t, device_t, int,
int *, rman_res_t, rman_res_t, rman_res_t, u_int);
@@ -174,11 +160,13 @@ static device_method_t thunder_pem_methods[] = {
DEVMETHOD_END
};
-static driver_t thunder_pem_driver = {
- "pcib",
- thunder_pem_methods,
- sizeof(struct thunder_pem_softc),
-};
+DEFINE_CLASS_0(pcib, thunder_pem_driver, thunder_pem_methods,
+ sizeof(struct thunder_pem_softc));
+
+static devclass_t thunder_pem_devclass;
+
+DRIVER_MODULE(thunder_pem, pci, thunder_pem_driver, thunder_pem_devclass, 0, 0);
+MODULE_DEPEND(thunder_pem, pci, 1, 1, 1);
static int
thunder_pem_maxslots(device_t dev)
@@ -447,7 +435,7 @@ thunder_pem_alloc_resource(device_t dev, device_t child, int type, int *rid,
end, count, flags));
};
- if ((start == 0UL) && (end == ~0UL)) {
+ if (RMAN_IS_DEFAULT_RANGE(start, end)) {
device_printf(dev,
"Cannot allocate resource with unspecified range\n");
goto fail;
@@ -526,6 +514,8 @@ thunder_pem_probe(device_t dev)
static int
thunder_pem_attach(device_t dev)
{
+ devclass_t pci_class;
+ device_t parent;
struct thunder_pem_softc *sc;
int error;
int rid;
@@ -533,8 +523,14 @@ thunder_pem_attach(device_t dev)
sc = device_get_softc(dev);
sc->dev = dev;
- /* Allocate memory for BAR(0) */
- rid = PCIR_BAR(0);
+ /* Allocate memory for resource */
+ pci_class = devclass_find("pci");
+ parent = device_get_parent(dev);
+ if (device_get_devclass(parent) == pci_class)
+ rid = PCIR_BAR(0);
+ else
+ rid = RID_PEM_SPACE;
+
sc->reg = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
&rid, RF_ACTIVE);
if (sc->reg == NULL) {
@@ -583,6 +579,13 @@ thunder_pem_attach(device_t dev)
goto fail_mem;
}
+ /*
+ * We ignore the values that may have been provided in FDT
+ * and configure ranges according to the below formula
+ * for all types of devices. This is because some DTBs provided
+ * by EFI do not have proper ranges property or don't have them
+ * at all.
+ */
/* Fill memory window */
sc->ranges[0].pci_base = PCI_MEMORY_BASE;
sc->ranges[0].size = PCI_MEMORY_SIZE;
@@ -639,8 +642,3 @@ thunder_pem_detach(device_t dev)
return (0);
}
-
-static devclass_t thunder_pem_devclass;
-
-DRIVER_MODULE(thunder_pem, pci, thunder_pem_driver, thunder_pem_devclass, 0, 0);
-MODULE_DEPEND(thunder_pem, pci, 1, 1, 1);
diff --git a/sys/arm64/cavium/thunder_pcie_pem.h b/sys/arm64/cavium/thunder_pcie_pem.h
new file mode 100644
index 0000000..8b45cb1
--- /dev/null
+++ b/sys/arm64/cavium/thunder_pcie_pem.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2016 Cavium Inc.
+ * All rights reserved.
+ *
+ * Developed by Semihalf.
+ *
+ * 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 distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ * $FreeBSD$
+ *
+ */
+
+#ifndef __THUNDER_PCIE_PEM_H__
+#define __THUNDER_PCIE_PEM_H__
+
+#define THUNDER_PEM_DESC "ThunderX PEM"
+
+struct thunder_pem_softc {
+ device_t dev;
+ struct resource *reg;
+ bus_space_tag_t reg_bst;
+ bus_space_handle_t reg_bsh;
+ struct pcie_range ranges[RANGES_TUPLES_MAX];
+ struct rman mem_rman;
+ struct rman io_rman;
+ bus_space_handle_t pem_sli_base;
+ uint32_t node;
+ uint32_t id;
+ uint32_t sli;
+ uint32_t sli_group;
+ uint64_t sli_window_base;
+};
+
+#endif
diff --git a/sys/arm64/cavium/thunder_pcie_pem_fdt.c b/sys/arm64/cavium/thunder_pcie_pem_fdt.c
new file mode 100644
index 0000000..b423753
--- /dev/null
+++ b/sys/arm64/cavium/thunder_pcie_pem_fdt.c
@@ -0,0 +1,83 @@
+/*
+ * Copyright (C) 2016 Cavium Inc.
+ * All rights reserved.
+ *
+ * Developed by Semihalf.
+ *
+ * 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 distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD$");
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/malloc.h>
+#include <sys/types.h>
+#include <sys/sysctl.h>
+#include <sys/kernel.h>
+#include <sys/rman.h>
+#include <sys/module.h>
+#include <sys/bus.h>
+#include <sys/endian.h>
+#include <sys/cpuset.h>
+
+#include <dev/ofw/openfirm.h>
+#include <dev/ofw/ofw_bus.h>
+#include <dev/ofw/ofw_bus_subr.h>
+
+#include "thunder_pcie_common.h"
+#include "thunder_pcie_pem.h"
+
+static int thunder_pem_fdt_probe(device_t);
+
+static device_method_t thunder_pem_fdt_methods[] = {
+ /* Device interface */
+ DEVMETHOD(device_probe, thunder_pem_fdt_probe),
+
+ /* End */
+ DEVMETHOD_END
+};
+
+DEFINE_CLASS_1(pcib, thunder_pem_fdt_driver, thunder_pem_fdt_methods,
+ sizeof(struct thunder_pem_softc), thunder_pem_driver);
+
+static devclass_t thunder_pem_fdt_devclass;
+
+DRIVER_MODULE(thunder_pem, simplebus, thunder_pem_fdt_driver,
+ thunder_pem_fdt_devclass, 0, 0);
+DRIVER_MODULE(thunder_pem, ofwbus, thunder_pem_fdt_driver,
+ thunder_pem_fdt_devclass, 0, 0);
+
+static int
+thunder_pem_fdt_probe(device_t dev)
+{
+
+ if (!ofw_bus_status_okay(dev))
+ return (ENXIO);
+
+ if (ofw_bus_is_compatible(dev, "cavium,pci-host-thunder-pem")) {
+ device_set_desc(dev, THUNDER_PEM_DESC);
+ return (BUS_PROBE_DEFAULT);
+ }
+
+ return (ENXIO);
+}
diff --git a/sys/arm64/include/devmap.h b/sys/arm64/include/devmap.h
index e205d9b..4184f8b 100644
--- a/sys/arm64/include/devmap.h
+++ b/sys/arm64/include/devmap.h
@@ -37,8 +37,6 @@ struct arm_devmap_entry {
vm_offset_t pd_va; /* virtual address */
vm_paddr_t pd_pa; /* physical address */
vm_size_t pd_size; /* size of region */
- vm_prot_t pd_prot; /* protection code */
- int pd_cache; /* cache attributes */
};
/*
@@ -70,7 +68,7 @@ void arm_devmap_register_table(const struct arm_devmap_entry * _table);
* custom initarm() routines in older code. If the table pointer is NULL, this
* will use the table installed previously by arm_devmap_register_table().
*/
-void arm_devmap_bootstrap(vm_offset_t _l1pt,
+void arm_devmap_bootstrap(vm_offset_t _l1pt,
const struct arm_devmap_entry *_table);
/*
OpenPOWER on IntegriCloud