Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F108303776
D5285.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
9 KB
Referenced Files
None
Subscribers
None
D5285.diff
View Options
Index: head/sys/arm64/cavium/thunder_pcie_common.h
===================================================================
--- head/sys/arm64/cavium/thunder_pcie_common.h
+++ head/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);
Index: head/sys/arm64/cavium/thunder_pcie_pem.h
===================================================================
--- head/sys/arm64/cavium/thunder_pcie_pem.h
+++ head/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
Index: head/sys/arm64/cavium/thunder_pcie_pem.c
===================================================================
--- head/sys/arm64/cavium/thunder_pcie_pem.c
+++ head/sys/arm64/cavium/thunder_pcie_pem.c
@@ -49,12 +49,12 @@
#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 @@
#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 @@
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)
@@ -526,6 +514,8 @@
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 @@
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 @@
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 @@
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);
Index: head/sys/arm64/cavium/thunder_pcie_pem_fdt.c
===================================================================
--- head/sys/arm64/cavium/thunder_pcie_pem_fdt.c
+++ head/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);
+}
Index: head/sys/conf/files.arm64
===================================================================
--- head/sys/conf/files.arm64
+++ head/sys/conf/files.arm64
@@ -52,10 +52,11 @@
arm64/arm64/unwind.c optional ddb | kdtrace_hooks | stack
arm64/arm64/vfp.c standard
arm64/arm64/vm_machdep.c standard
-arm64/cavium/thunder_pcie.c optional soc_cavm_thunderx pci
-arm64/cavium/thunder_pcie_fdt.c optional soc_cavm_thunderx pci fdt
-arm64/cavium/thunder_pcie_pem.c optional soc_cavm_thunderx pci
-arm64/cavium/thunder_pcie_common.c optional soc_cavm_thunderx pci
+arm64/cavium/thunder_pcie.c optional soc_cavm_thunderx pci
+arm64/cavium/thunder_pcie_fdt.c optional soc_cavm_thunderx pci fdt
+arm64/cavium/thunder_pcie_pem.c optional soc_cavm_thunderx pci
+arm64/cavium/thunder_pcie_pem_fdt.c optional soc_cavm_thunderx pci fdt
+arm64/cavium/thunder_pcie_common.c optional soc_cavm_thunderx pci
arm64/cloudabi64/cloudabi64_sysvec.c optional compat_cloudabi64
crypto/blowfish/bf_enc.c optional crypto | ipsec
crypto/des/des_enc.c optional crypto | ipsec | netsmb
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Jan 24, 5:21 PM (20 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
16093577
Default Alt Text
D5285.diff (9 KB)
Attached To
Mode
D5285: Support PEM that is not a PCI endpoint on ThunderX
Attached
Detach File
Event Timeline
Log In to Comment