aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/dpaa
diff options
context:
space:
mode:
authorJustin Hibbits <jhibbits@FreeBSD.org>2016-11-12 20:45:03 +0000
committerJustin Hibbits <jhibbits@FreeBSD.org>2016-11-12 20:45:03 +0000
commit3e7ddf02dc6f279532bd49619804851fd648d091 (patch)
tree1a7b041a1da834e4a2572b1b24eedec7d69b7abf /sys/dev/dpaa
parentfbc19213d5385bb9833b5c2685d88600a6291a02 (diff)
Notes
Diffstat (limited to 'sys/dev/dpaa')
-rw-r--r--sys/dev/dpaa/bman_fdt.c34
-rw-r--r--sys/dev/dpaa/dpaa.c184
-rw-r--r--sys/dev/dpaa/fman.c30
-rw-r--r--sys/dev/dpaa/fman.h3
-rw-r--r--sys/dev/dpaa/if_dtsec.c2
-rw-r--r--sys/dev/dpaa/if_dtsec_fdt.c42
-rw-r--r--sys/dev/dpaa/if_dtsec_rm.c1
-rw-r--r--sys/dev/dpaa/qman_fdt.c79
8 files changed, 137 insertions, 238 deletions
diff --git a/sys/dev/dpaa/bman_fdt.c b/sys/dev/dpaa/bman_fdt.c
index 992b4eaa57bd1..454af67ae6b11 100644
--- a/sys/dev/dpaa/bman_fdt.c
+++ b/sys/dev/dpaa/bman_fdt.c
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/module.h>
+#include <sys/smp.h>
#include <machine/bus.h>
@@ -105,7 +106,8 @@ static driver_t bm_portals_driver = {
};
static devclass_t bm_portals_devclass;
-DRIVER_MODULE(bman_portals, ofwbus, bm_portals_driver, bm_portals_devclass, 0, 0);
+EARLY_DRIVER_MODULE(bman_portals, ofwbus, bm_portals_driver,
+ bm_portals_devclass, 0, 0, BUS_PASS_BUS);
static void
get_addr_props(phandle_t node, uint32_t *addrp, uint32_t *sizep)
@@ -121,7 +123,7 @@ static int
bman_portals_fdt_probe(device_t dev)
{
- if (!ofw_bus_is_compatible(dev, "bman-portals"))
+ if (!ofw_bus_is_compatible(dev, "fsl,bman-portals"))
return (ENXIO);
device_set_desc(dev, BMAN_PORT_DEVSTR);
@@ -129,6 +131,25 @@ bman_portals_fdt_probe(device_t dev)
return (BUS_PROBE_DEFAULT);
}
+static phandle_t
+bman_portal_find_cpu(int cpu)
+{
+ phandle_t node;
+ pcell_t reg;
+
+ node = OF_finddevice("/cpus");
+ if (node == -1)
+ return (node);
+
+ for (node = OF_child(node); node != 0; node = OF_peer(node)) {
+ if (OF_getprop(node, "reg", &reg, sizeof(reg)) <= 0)
+ continue;
+ if (reg == cpu)
+ return (node);
+ }
+ return (-1);
+}
+
static int
bman_portals_fdt_attach(device_t dev)
{
@@ -152,13 +173,17 @@ bman_portals_fdt_attach(device_t dev)
/* Find portals tied to CPUs */
for (child = OF_child(node); child != 0; child = OF_peer(child)) {
+ if (cpus >= mp_ncpus)
+ break;
if (!ofw_bus_node_is_compatible(child, "fsl,bman-portal")) {
continue;
}
/* Checkout related cpu */
if (OF_getprop(child, "cpu-handle", (void *)&cpu,
sizeof(cpu)) <= 0) {
- continue;
+ cpu = bman_portal_find_cpu(cpus);
+ if (cpu <= 0)
+ continue;
}
/* Acquire cpu number */
cpu_node = OF_instance_to_package(cpu);
@@ -169,9 +194,6 @@ bman_portals_fdt_attach(device_t dev)
cpus++;
- if (cpus > MAXCPU)
- break;
-
if (ofw_bus_gen_setup_devinfo(&ofw_di, child) != 0) {
device_printf(dev, "could not set up devinfo\n");
continue;
diff --git a/sys/dev/dpaa/dpaa.c b/sys/dev/dpaa/dpaa.c
deleted file mode 100644
index 95c04b4d59605..0000000000000
--- a/sys/dev/dpaa/dpaa.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*-
- * Copyright (c) 2012 Semihalf.
- * All rights reserved.
- *
- * 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/ktr.h>
-#include <sys/kernel.h>
-#include <sys/module.h>
-#include <sys/bus.h>
-#include <sys/rman.h>
-#include <sys/malloc.h>
-
-#include <dev/fdt/fdt_common.h>
-#include <dev/ofw/ofw_bus.h>
-#include <dev/ofw/ofw_bus_subr.h>
-#include <dev/ofw/openfirm.h>
-
-#include "opt_platform.h"
-
-static MALLOC_DEFINE(M_DPAA, "dpaa", "dpaa devices information");
-
-static int dpaa_probe(device_t dev);
-static int dpaa_attach(device_t dev);
-
-static const struct ofw_bus_devinfo *dpaa_get_devinfo(device_t bus,
- device_t child);
-
-struct dpaa_softc {
-
-};
-
-struct dpaa_devinfo {
- struct ofw_bus_devinfo di_ofw;
-};
-
-static device_method_t dpaa_methods[] = {
- /* Device interface */
- DEVMETHOD(device_probe, dpaa_probe),
- DEVMETHOD(device_attach, dpaa_attach),
- DEVMETHOD(device_detach, bus_generic_detach),
- DEVMETHOD(device_shutdown, bus_generic_shutdown),
- DEVMETHOD(device_suspend, bus_generic_suspend),
- DEVMETHOD(device_resume, bus_generic_resume),
-
- /* OFW bus interface */
- DEVMETHOD(ofw_bus_get_devinfo, dpaa_get_devinfo),
- DEVMETHOD(ofw_bus_get_compat, ofw_bus_gen_get_compat),
- DEVMETHOD(ofw_bus_get_model, ofw_bus_gen_get_model),
- DEVMETHOD(ofw_bus_get_name, ofw_bus_gen_get_name),
- DEVMETHOD(ofw_bus_get_node, ofw_bus_gen_get_node),
- DEVMETHOD(ofw_bus_get_type, ofw_bus_gen_get_type),
-
- {0, 0}
-};
-
-static driver_t dpaa_driver = {
- "dpaa",
- dpaa_methods,
- sizeof(struct dpaa_softc),
-};
-
-static devclass_t dpaa_devclass;
-DRIVER_MODULE_ORDERED(dpaa, ofwbus, dpaa_driver, dpaa_devclass, 0, 0,
- SI_ORDER_ANY);
-
-static int
-dpaa_probe(device_t dev)
-{
-
- if (!ofw_bus_is_compatible(dev, "fsl,dpaa"))
- return (ENXIO);
-
- device_set_desc(dev, "Freescale Data Path Acceleration Architecture");
-
- return (BUS_PROBE_DEFAULT);
-}
-
-static int
-dpaa_attach(device_t dev)
-{
- device_t dev_child;
- phandle_t dt_node, dt_child, enet_node;
- struct dpaa_devinfo *di;
- pcell_t cell_index;
-
- cell_index = 0;
- /*
- * Walk dpaa and add direct subordinates as our children.
- */
- dt_node = ofw_bus_get_node(dev);
- dt_child = OF_child(dt_node);
-
- for (; dt_child != 0; dt_child = OF_peer(dt_child)) {
-
- /* Check and process 'status' property. */
- if (!(fdt_is_enabled(dt_child)))
- continue;
-
- di = (struct dpaa_devinfo *)malloc(sizeof(*di), M_DPAA,
- M_WAITOK | M_ZERO);
-
- if (ofw_bus_gen_setup_devinfo(&di->di_ofw, dt_child) != 0) {
- free(di, M_DPAA);
- device_printf(dev, "could not set up devinfo\n");
- continue;
- }
-
- /*
- * dTSEC number from SoC is equal to number get from
- * dts file.
- */
- if (OF_getprop(dt_child, "fsl,fman-mac",
- (void *)&enet_node, sizeof(enet_node)) == -1) {
- device_printf(dev, "Could not get fsl,fman-mac "
- "from dts\n");
- continue;
- }
-
- if ((enet_node = OF_instance_to_package(enet_node)) == -1) {
- device_printf(dev, "Could not get enet node\n");
- continue;
- }
-
- if (OF_getprop(enet_node, "cell-index",
- (void *)&cell_index, sizeof(cell_index)) == -1) {
- device_printf(dev, "Could not get cell-index from enet "
- "node\n");
- continue;
- }
-
- /* Add newbus device for this FDT node */
- dev_child = device_add_child(dev, "dtsec", (int)cell_index);
- if (dev_child == NULL) {
- device_printf(dev, "could not add child: %s\n",
- di->di_ofw.obd_name);
- ofw_bus_gen_destroy_devinfo(&di->di_ofw);
- free(di, M_DPAA);
- continue;
- }
-
-#ifdef DEBUG
- device_printf(dev, "added child: %s\n\n", di->di_ofw.obd_name);
-#endif
-
- device_set_ivars(dev_child, di);
- }
-
- return (bus_generic_attach(dev));
-}
-
-static const struct ofw_bus_devinfo *
-dpaa_get_devinfo(device_t bus, device_t child)
-{
- struct dpaa_devinfo *di;
-
- di = device_get_ivars(child);
- return (&di->di_ofw);
-}
diff --git a/sys/dev/dpaa/fman.c b/sys/dev/dpaa/fman.c
index ee1f0cd8bf2e3..fca65f33429c8 100644
--- a/sys/dev/dpaa/fman.c
+++ b/sys/dev/dpaa/fman.c
@@ -35,7 +35,6 @@ __FBSDID("$FreeBSD$");
#include <sys/rman.h>
#include <sys/malloc.h>
-#include <dev/fdt/fdt_common.h>
#include <dev/fdt/simplebus.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_bus_subr.h>
@@ -50,6 +49,8 @@ __FBSDID("$FreeBSD$");
#include "fman.h"
+static MALLOC_DEFINE(M_FMAN, "fman", "fman devices information");
+
/**
* @group FMan private defines.
* @{
@@ -259,6 +260,8 @@ fman_attach(device_t dev)
{
struct fman_softc *sc;
struct fman_config cfg;
+ pcell_t qchan_range[2];
+ phandle_t node;
sc = device_get_softc(dev);
sc->sc_base.dev = dev;
@@ -272,6 +275,14 @@ fman_attach(device_t dev)
XX_TrackInit();
+ node = ofw_bus_get_node(dev);
+ if (OF_getencprop(node, "fsl,qman-channel-range", qchan_range,
+ sizeof(qchan_range)) <= 0) {
+ device_printf(dev, "Missing QMan channel range property!\n");
+ return (ENXIO);
+ }
+ sc->qman_chan_base = qchan_range[0];
+ sc->qman_chan_count = qchan_range[1];
sc->mem_rid = 0;
sc->mem_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &sc->mem_rid,
RF_ACTIVE | RF_SHAREABLE);
@@ -379,4 +390,21 @@ fman_shutdown(device_t dev)
return (0);
}
+int
+fman_qman_channel_id(device_t dev, int port)
+{
+ struct fman_softc *sc;
+ int qman_port_id[] = {0x31, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e,
+ 0x2f, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07};
+ int i;
+
+ sc = device_get_softc(dev);
+ for (i = 0; i < sc->qman_chan_count; i++) {
+ if (qman_port_id[i] == port)
+ return (sc->qman_chan_base + i);
+ }
+
+ return (0);
+}
+
/** @} */
diff --git a/sys/dev/dpaa/fman.h b/sys/dev/dpaa/fman.h
index 52bc61762c2b9..96cdd86b03626 100644
--- a/sys/dev/dpaa/fman.h
+++ b/sys/dev/dpaa/fman.h
@@ -42,6 +42,8 @@ struct fman_softc {
int mem_rid;
int irq_rid;
int err_irq_rid;
+ int qman_chan_base;
+ int qman_chan_count;
t_Handle fm_handle;
t_Handle muram_handle;
@@ -59,6 +61,7 @@ int fman_resume(device_t dev);
int fman_shutdown(device_t dev);
int fman_read_ivar(device_t dev, device_t child, int index,
uintptr_t *result);
+int fman_qman_channel_id(device_t, int);
/** @} */
uint32_t fman_get_clock(struct fman_softc *sc);
diff --git a/sys/dev/dpaa/if_dtsec.c b/sys/dev/dpaa/if_dtsec.c
index d5f771251e3e1..e29d89adb6247 100644
--- a/sys/dev/dpaa/if_dtsec.c
+++ b/sys/dev/dpaa/if_dtsec.c
@@ -49,8 +49,6 @@ __FBSDID("$FreeBSD$");
#include <net/if_types.h>
#include <net/if_arp.h>
-#include <dev/fdt/fdt_common.h>
-#include <dev/fdt/simplebus.h>
#include <dev/mii/mii.h>
#include <dev/mii/miivar.h>
#include <dev/ofw/ofw_bus.h>
diff --git a/sys/dev/dpaa/if_dtsec_fdt.c b/sys/dev/dpaa/if_dtsec_fdt.c
index c9f98efa09f2e..b653fbd5f0c1d 100644
--- a/sys/dev/dpaa/if_dtsec_fdt.c
+++ b/sys/dev/dpaa/if_dtsec_fdt.c
@@ -87,7 +87,7 @@ static driver_t dtsec_driver = {
};
static devclass_t dtsec_devclass;
-DRIVER_MODULE(dtsec, dpaa, dtsec_driver, dtsec_devclass, 0, 0);
+DRIVER_MODULE(dtsec, fman, dtsec_driver, dtsec_devclass, 0, 0);
DRIVER_MODULE(miibus, dtsec, miibus_driver, miibus_devclass, 0, 0);
MODULE_DEPEND(dtsec, ether, 1, 1, 1);
MODULE_DEPEND(dtsec, miibus, 1, 1, 1);
@@ -96,7 +96,8 @@ static int
dtsec_fdt_probe(device_t dev)
{
- if (!ofw_bus_is_compatible(dev, "fsl,dpa-ethernet"))
+ if (!ofw_bus_is_compatible(dev, "fsl,fman-dtsec") &&
+ !ofw_bus_is_compatible(dev, "fsl,fman-xgec"))
return (ENXIO);
device_set_desc(dev, "Freescale Data Path Triple Speed Ethernet "
@@ -119,9 +120,7 @@ find_mdio(phandle_t phy_node, device_t mac, device_t *mdio_dev)
if (phy_node <= 0)
return (ENOENT);
- if (fman_get_dev(&bus) < 0)
- return (ENOENT);
-
+ bus = device_get_parent(mac);
*mdio_dev = ofw_bus_find_child_device_by_phandle(bus, phy_node);
return (0);
@@ -131,21 +130,13 @@ static int
dtsec_fdt_attach(device_t dev)
{
struct dtsec_softc *sc;
- phandle_t node, enet_node, phy_node;
+ phandle_t enet_node, phy_node;
phandle_t fman_rxtx_node[2];
char phy_type[6];
+ pcell_t fman_tx_cell;
sc = device_get_softc(dev);
- node = ofw_bus_get_node(dev);
-
- if (OF_getprop(node, "fsl,fman-mac", (void *)&enet_node,
- sizeof(enet_node)) == -1) {
- device_printf(dev, "Could not load fsl,fman-mac property "
- "from DTS\n");
- return (ENXIO);
- }
-
- enet_node = OF_instance_to_package(enet_node);
+ enet_node = ofw_bus_get_node(dev);
if (OF_getprop(enet_node, "local-mac-address",
(void *)sc->sc_mac_addr, 6) == -1) {
@@ -155,9 +146,9 @@ dtsec_fdt_attach(device_t dev)
}
/* Get link speed */
- if (ofw_bus_node_is_compatible(enet_node, "fsl,fman-1g-mac") != 0)
+ if (ofw_bus_is_compatible(dev, "fsl,fman-dtsec") != 0)
sc->sc_eth_dev_type = ETH_DTSEC;
- else if (ofw_bus_node_is_compatible(enet_node, "fsl,fman-10g-mac") != 0)
+ else if (ofw_bus_is_compatible(dev, "fsl,fman-xgec") != 0)
sc->sc_eth_dev_type = ETH_10GSEC;
else
return(ENXIO);
@@ -197,7 +188,7 @@ dtsec_fdt_attach(device_t dev)
return (ENXIO);
/* Get RX/TX port handles */
- if (OF_getprop(enet_node, "fsl,port-handles", (void *)fman_rxtx_node,
+ if (OF_getprop(enet_node, "fsl,fman-ports", (void *)fman_rxtx_node,
sizeof(fman_rxtx_node)) <= 0)
return (ENXIO);
@@ -211,11 +202,11 @@ dtsec_fdt_attach(device_t dev)
fman_rxtx_node[1] = OF_instance_to_package(fman_rxtx_node[1]);
if (ofw_bus_node_is_compatible(fman_rxtx_node[0],
- "fsl,fman-port-1g-rx") == 0)
+ "fsl,fman-v2-port-rx") == 0)
return (ENXIO);
if (ofw_bus_node_is_compatible(fman_rxtx_node[1],
- "fsl,fman-port-1g-tx") == 0)
+ "fsl,fman-v2-port-tx") == 0)
return (ENXIO);
/* Get RX port HW id */
@@ -228,11 +219,12 @@ dtsec_fdt_attach(device_t dev)
sizeof(sc->sc_port_tx_hw_id)) <= 0)
return (ENXIO);
- /* Get QMan channel */
- if (OF_getprop(fman_rxtx_node[1], "fsl,qman-channel-id",
- (void *)&sc->sc_port_tx_qman_chan,
- sizeof(sc->sc_port_tx_qman_chan)) <= 0)
+ if (OF_getprop(fman_rxtx_node[1], "cell-index", &fman_tx_cell,
+ sizeof(fman_tx_cell)) <= 0)
return (ENXIO);
+ /* Get QMan channel */
+ sc->sc_port_tx_qman_chan = fman_qman_channel_id(device_get_parent(dev),
+ fman_tx_cell);
return (dtsec_attach(dev));
}
diff --git a/sys/dev/dpaa/if_dtsec_rm.c b/sys/dev/dpaa/if_dtsec_rm.c
index 06e9f0165ed24..50ef2be1ac6cd 100644
--- a/sys/dev/dpaa/if_dtsec_rm.c
+++ b/sys/dev/dpaa/if_dtsec_rm.c
@@ -323,6 +323,7 @@ dtsec_rm_pool_rx_init(struct dtsec_softc *sc)
DTSEC_RM_POOL_RX_HIGH_MARK, 0, 0, dtsec_rm_pool_rx_depleted, sc, NULL,
NULL);
if (sc->sc_rx_pool == NULL) {
+ device_printf(sc->sc_dev, "NULL rx pool somehow\n");
dtsec_rm_pool_rx_free(sc);
return (EIO);
}
diff --git a/sys/dev/dpaa/qman_fdt.c b/sys/dev/dpaa/qman_fdt.c
index 4c23c5fc4bd8c..e37196d54aaca 100644
--- a/sys/dev/dpaa/qman_fdt.c
+++ b/sys/dev/dpaa/qman_fdt.c
@@ -33,6 +33,7 @@ __FBSDID("$FreeBSD$");
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/module.h>
+#include <sys/smp.h>
#include <machine/bus.h>
@@ -105,7 +106,8 @@ static driver_t qm_portals_driver = {
};
static devclass_t qm_portals_devclass;
-DRIVER_MODULE(qman_portals, ofwbus, qm_portals_driver, qm_portals_devclass, 0, 0);
+EARLY_DRIVER_MODULE(qman_portals, ofwbus, qm_portals_driver,
+ qm_portals_devclass, 0, 0, BUS_PASS_BUS);
static void
get_addr_props(phandle_t node, uint32_t *addrp, uint32_t *sizep)
@@ -121,7 +123,7 @@ static int
qman_portals_fdt_probe(device_t dev)
{
- if (!ofw_bus_is_compatible(dev, "qman-portals"))
+ if (!ofw_bus_is_compatible(dev, "fsl,qman-portals"))
return (ENXIO);
device_set_desc(dev, BMAN_PORT_DEVSTR);
@@ -129,36 +131,87 @@ qman_portals_fdt_probe(device_t dev)
return (BUS_PROBE_DEFAULT);
}
+static phandle_t
+qman_portal_find_cpu(int cpu)
+{
+ phandle_t node;
+ pcell_t reg;
+
+ node = OF_finddevice("/cpus");
+ if (node == -1)
+ return (-1);
+
+ for (node = OF_child(node); node != 0; node = OF_peer(node)) {
+ if (OF_getprop(node, "reg", &reg, sizeof(reg)) <= 0)
+ continue;
+ if (reg == cpu)
+ return (node);
+ }
+ return (-1);
+}
+
static int
qman_portals_fdt_attach(device_t dev)
{
struct dpaa_portals_softc *sc;
- struct resource_list_entry *rle;
phandle_t node, child, cpu_node;
- vm_paddr_t portal_pa;
+ vm_paddr_t portal_pa, portal_par_pa;
vm_size_t portal_size;
- uint32_t addr, size;
+ uint32_t addr, paddr, size;
ihandle_t cpu;
int cpu_num, cpus, intr_rid;
struct dpaa_portals_devinfo di;
struct ofw_bus_devinfo ofw_di = {};
+ cell_t *range;
+ int nrange;
+ int i;
cpus = 0;
sc = device_get_softc(dev);
sc->sc_dev = dev;
node = ofw_bus_get_node(dev);
+
+ /* Get this node's range */
+ get_addr_props(ofw_bus_get_node(device_get_parent(dev)), &paddr, &size);
get_addr_props(node, &addr, &size);
+ nrange = OF_getencprop_alloc(node, "ranges",
+ sizeof(*range), (void **)&range);
+ if (nrange < addr + paddr + size)
+ return (ENXIO);
+ portal_pa = portal_par_pa = 0;
+ portal_size = 0;
+ for (i = 0; i < addr; i++) {
+ portal_pa <<= 32;
+ portal_pa |= range[i];
+ }
+ for (; i < paddr + addr; i++) {
+ portal_par_pa <<= 32;
+ portal_par_pa |= range[i];
+ }
+ portal_pa += portal_par_pa;
+ for (; i < size + paddr + addr; i++) {
+ portal_size = (uintmax_t)portal_size << 32;
+ portal_size |= range[i];
+ }
+ OF_prop_free(range);
+ sc->sc_dp_size = portal_size;
+ sc->sc_dp_pa = portal_pa;
+
/* Find portals tied to CPUs */
for (child = OF_child(node); child != 0; child = OF_peer(child)) {
+ if (cpus >= mp_ncpus)
+ break;
if (!ofw_bus_node_is_compatible(child, "fsl,qman-portal")) {
continue;
}
/* Checkout related cpu */
if (OF_getprop(child, "cpu-handle", (void *)&cpu,
sizeof(cpu)) <= 0) {
- continue;
+ cpu = qman_portal_find_cpu(cpus);
+ if (cpu <= 0)
+ continue;
}
/* Acquire cpu number */
cpu_node = OF_instance_to_package(cpu);
@@ -169,9 +222,6 @@ qman_portals_fdt_attach(device_t dev)
cpus++;
- if (cpus > MAXCPU)
- break;
-
if (ofw_bus_gen_setup_devinfo(&ofw_di, child) != 0) {
device_printf(dev, "could not set up devinfo\n");
continue;
@@ -192,17 +242,6 @@ qman_portals_fdt_attach(device_t dev)
continue;
}
di.di_intr_rid = intr_rid;
-
- ofw_reg_to_paddr(child, 0, &portal_pa, &portal_size, NULL);
- rle = resource_list_find(&di.di_res, SYS_RES_MEMORY, 0);
-
- if (sc->sc_dp_pa == 0)
- sc->sc_dp_pa = portal_pa - rle->start;
-
- portal_size = rle->end + 1;
- rle = resource_list_find(&di.di_res, SYS_RES_MEMORY, 1);
- portal_size = ulmax(rle->end + 1, portal_size);
- sc->sc_dp_size = ulmax(sc->sc_dp_size, portal_size);
if (dpaa_portal_alloc_res(dev, &di, cpu_num))
goto err;