Index: head/sys/dev/dpaa/bman_fdt.c =================================================================== --- head/sys/dev/dpaa/bman_fdt.c (revision 308535) +++ head/sys/dev/dpaa/bman_fdt.c (revision 308536) @@ -1,221 +1,219 @@ /*- * Copyright (c) 2011-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 "opt_platform.h" #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include -#include - #include #include #include #include "bman.h" #include "portals.h" #define FBMAN_DEVSTR "Freescale Buffer Manager" static int bman_fdt_probe(device_t); static device_method_t bman_methods[] = { /* Device interface */ DEVMETHOD(device_probe, bman_fdt_probe), DEVMETHOD(device_attach, bman_attach), DEVMETHOD(device_detach, bman_detach), DEVMETHOD(device_suspend, bman_suspend), DEVMETHOD(device_resume, bman_resume), DEVMETHOD(device_shutdown, bman_shutdown), { 0, 0 } }; static driver_t bman_driver = { "bman", bman_methods, sizeof(struct bman_softc), }; static devclass_t bman_devclass; DRIVER_MODULE(bman, simplebus, bman_driver, bman_devclass, 0, 0); static int bman_fdt_probe(device_t dev) { if (!ofw_bus_is_compatible(dev, "fsl,bman")) return (ENXIO); device_set_desc(dev, FBMAN_DEVSTR); return (BUS_PROBE_DEFAULT); } /* * BMAN Portals */ #define BMAN_PORT_DEVSTR "Freescale Buffer Manager - Portals" static device_probe_t bman_portals_fdt_probe; static device_attach_t bman_portals_fdt_attach; static device_method_t bm_portals_methods[] = { /* Device interface */ DEVMETHOD(device_probe, bman_portals_fdt_probe), DEVMETHOD(device_attach, bman_portals_fdt_attach), DEVMETHOD(device_detach, bman_portals_detach), { 0, 0 } }; static driver_t bm_portals_driver = { "bman-portals", bm_portals_methods, sizeof(struct dpaa_portals_softc), }; static devclass_t bm_portals_devclass; DRIVER_MODULE(bman_portals, ofwbus, bm_portals_driver, bm_portals_devclass, 0, 0); static void get_addr_props(phandle_t node, uint32_t *addrp, uint32_t *sizep) { *addrp = 2; *sizep = 1; OF_getencprop(node, "#address-cells", addrp, sizeof(*addrp)); OF_getencprop(node, "#size-cells", sizep, sizeof(*sizep)); } static int bman_portals_fdt_probe(device_t dev) { if (!ofw_bus_is_compatible(dev, "bman-portals")) return (ENXIO); device_set_desc(dev, BMAN_PORT_DEVSTR); return (BUS_PROBE_DEFAULT); } static int bman_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_size_t portal_size; uint32_t addr, size; ihandle_t cpu; int cpu_num, cpus, intr_rid; struct dpaa_portals_devinfo di; struct ofw_bus_devinfo ofw_di = {}; cpus = 0; sc = device_get_softc(dev); sc->sc_dev = dev; node = ofw_bus_get_node(dev); get_addr_props(node, &addr, &size); /* Find portals tied to CPUs */ for (child = OF_child(node); child != 0; child = OF_peer(child)) { - if (!fdt_is_compatible(child, "fsl,bman-portal")) { + 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; } /* Acquire cpu number */ cpu_node = OF_instance_to_package(cpu); if (OF_getencprop(cpu_node, "reg", &cpu_num, sizeof(cpu_num)) <= 0) { device_printf(dev, "Could not retrieve CPU number.\n"); return (ENXIO); } 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; } resource_list_init(&di.di_res); if (ofw_bus_reg_to_rl(dev, child, addr, size, &di.di_res)) { device_printf(dev, "%s: could not process 'reg' " "property\n", ofw_di.obd_name); ofw_bus_gen_destroy_devinfo(&ofw_di); continue; } if (ofw_bus_intr_to_rl(dev, child, &di.di_res, &intr_rid)) { device_printf(dev, "%s: could not process " "'interrupts' property\n", ofw_di.obd_name); resource_list_free(&di.di_res); ofw_bus_gen_destroy_devinfo(&ofw_di); 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; } ofw_bus_gen_destroy_devinfo(&ofw_di); return (bman_portals_attach(dev)); err: resource_list_free(&di.di_res); ofw_bus_gen_destroy_devinfo(&ofw_di); bman_portals_detach(dev); return (ENXIO); } Index: head/sys/dev/dpaa/if_dtsec_fdt.c =================================================================== --- head/sys/dev/dpaa/if_dtsec_fdt.c (revision 308535) +++ head/sys/dev/dpaa/if_dtsec_fdt.c (revision 308536) @@ -1,237 +1,238 @@ /*- * 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 __FBSDID("$FreeBSD$"); #include #include #include #include #include #include #include #include #include #include #include -#include #include #include #include #include "miibus_if.h" #include #include #include "if_dtsec.h" #include "fman.h" static int dtsec_fdt_probe(device_t dev); static int dtsec_fdt_attach(device_t dev); static device_method_t dtsec_methods[] = { /* Device interface */ DEVMETHOD(device_probe, dtsec_fdt_probe), DEVMETHOD(device_attach, dtsec_fdt_attach), DEVMETHOD(device_detach, dtsec_detach), DEVMETHOD(device_shutdown, dtsec_shutdown), DEVMETHOD(device_suspend, dtsec_suspend), DEVMETHOD(device_resume, dtsec_resume), /* Bus interface */ DEVMETHOD(bus_print_child, bus_generic_print_child), DEVMETHOD(bus_driver_added, bus_generic_driver_added), /* MII interface */ DEVMETHOD(miibus_readreg, dtsec_miibus_readreg), DEVMETHOD(miibus_writereg, dtsec_miibus_writereg), DEVMETHOD(miibus_statchg, dtsec_miibus_statchg), { 0, 0 } }; static driver_t dtsec_driver = { "dtsec", dtsec_methods, sizeof(struct dtsec_softc), }; static devclass_t dtsec_devclass; DRIVER_MODULE(dtsec, dpaa, 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); static int dtsec_fdt_probe(device_t dev) { if (!ofw_bus_is_compatible(dev, "fsl,dpa-ethernet")) return (ENXIO); device_set_desc(dev, "Freescale Data Path Triple Speed Ethernet " "Controller"); return (BUS_PROBE_DEFAULT); } static int find_mdio(phandle_t phy_node, device_t mac, device_t *mdio_dev) { device_t bus; while (phy_node > 0) { if (ofw_bus_node_is_compatible(phy_node, "fsl,fman-mdio")) break; phy_node = OF_parent(phy_node); } if (phy_node <= 0) return (ENOENT); if (fman_get_dev(&bus) < 0) return (ENOENT); *mdio_dev = ofw_bus_find_child_device_by_phandle(bus, phy_node); return (0); } static int dtsec_fdt_attach(device_t dev) { struct dtsec_softc *sc; phandle_t node, enet_node, phy_node; phandle_t fman_rxtx_node[2]; char phy_type[6]; 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); if (OF_getprop(enet_node, "local-mac-address", (void *)sc->sc_mac_addr, 6) == -1) { device_printf(dev, "Could not load local-mac-addr property from DTS\n"); return (ENXIO); } /* Get link speed */ - if (fdt_is_compatible(enet_node, "fsl,fman-1g-mac") != 0) + if (ofw_bus_node_is_compatible(enet_node, "fsl,fman-1g-mac") != 0) sc->sc_eth_dev_type = ETH_DTSEC; - else if (fdt_is_compatible(enet_node, "fsl,fman-10g-mac") != 0) + else if (ofw_bus_node_is_compatible(enet_node, "fsl,fman-10g-mac") != 0) sc->sc_eth_dev_type = ETH_10GSEC; else return(ENXIO); /* Get MAC memory offset in SoC */ if (OF_getprop(enet_node, "reg", (void *)&sc->sc_mac_mem_offset, sizeof(sc->sc_mac_mem_offset)) <= 0) return (ENXIO); /* Get PHY address */ if (OF_getprop(enet_node, "phy-handle", (void *)&phy_node, sizeof(phy_node)) <= 0) return (ENXIO); phy_node = OF_instance_to_package(phy_node); if (OF_getprop(phy_node, "reg", (void *)&sc->sc_phy_addr, sizeof(sc->sc_phy_addr)) <= 0) return (ENXIO); if (find_mdio(phy_node, dev, &sc->sc_mdio) != 0) return (ENXIO); /* Get PHY connection type */ if (OF_getprop(enet_node, "phy-connection-type", (void *)phy_type, sizeof(phy_type)) <= 0) return (ENXIO); if (!strcmp(phy_type, "sgmii")) sc->sc_mac_enet_mode = e_ENET_MODE_SGMII_1000; else if (!strcmp(phy_type, "rgmii")) sc->sc_mac_enet_mode = e_ENET_MODE_RGMII_1000; else if (!strcmp(phy_type, "xgmii")) /* We set 10 Gigabit mode flag however we don't support it */ sc->sc_mac_enet_mode = e_ENET_MODE_XGMII_10000; else return (ENXIO); /* Get RX/TX port handles */ if (OF_getprop(enet_node, "fsl,port-handles", (void *)fman_rxtx_node, sizeof(fman_rxtx_node)) <= 0) return (ENXIO); if (fman_rxtx_node[0] == 0) return (ENXIO); if (fman_rxtx_node[1] == 0) return (ENXIO); fman_rxtx_node[0] = OF_instance_to_package(fman_rxtx_node[0]); fman_rxtx_node[1] = OF_instance_to_package(fman_rxtx_node[1]); - if (fdt_is_compatible(fman_rxtx_node[0], "fsl,fman-port-1g-rx") == 0) + if (ofw_bus_node_is_compatible(fman_rxtx_node[0], + "fsl,fman-port-1g-rx") == 0) return (ENXIO); - if (fdt_is_compatible(fman_rxtx_node[1], "fsl,fman-port-1g-tx") == 0) + if (ofw_bus_node_is_compatible(fman_rxtx_node[1], + "fsl,fman-port-1g-tx") == 0) return (ENXIO); /* Get RX port HW id */ if (OF_getprop(fman_rxtx_node[0], "reg", (void *)&sc->sc_port_rx_hw_id, sizeof(sc->sc_port_rx_hw_id)) <= 0) return (ENXIO); /* Get TX port HW id */ if (OF_getprop(fman_rxtx_node[1], "reg", (void *)&sc->sc_port_tx_hw_id, 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) return (ENXIO); return (dtsec_attach(dev)); } Index: head/sys/dev/dpaa/qman_fdt.c =================================================================== --- head/sys/dev/dpaa/qman_fdt.c (revision 308535) +++ head/sys/dev/dpaa/qman_fdt.c (revision 308536) @@ -1,221 +1,219 @@ /*- * Copyright (c) 2011-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 "opt_platform.h" #include __FBSDID("$FreeBSD$"); #include #include #include #include #include #include -#include - #include #include #include #include "qman.h" #include "portals.h" #define FBMAN_DEVSTR "Freescale Queue Manager" static int qman_fdt_probe(device_t); static device_method_t qman_methods[] = { /* Device interface */ DEVMETHOD(device_probe, qman_fdt_probe), DEVMETHOD(device_attach, qman_attach), DEVMETHOD(device_detach, qman_detach), DEVMETHOD(device_suspend, qman_suspend), DEVMETHOD(device_resume, qman_resume), DEVMETHOD(device_shutdown, qman_shutdown), { 0, 0 } }; static driver_t qman_driver = { "qman", qman_methods, sizeof(struct qman_softc), }; static devclass_t qman_devclass; DRIVER_MODULE(qman, simplebus, qman_driver, qman_devclass, 0, 0); static int qman_fdt_probe(device_t dev) { if (!ofw_bus_is_compatible(dev, "fsl,qman")) return (ENXIO); device_set_desc(dev, FBMAN_DEVSTR); return (BUS_PROBE_DEFAULT); } /* * BMAN Portals */ #define BMAN_PORT_DEVSTR "Freescale Queue Manager - Portals" static device_probe_t qman_portals_fdt_probe; static device_attach_t qman_portals_fdt_attach; static device_method_t qm_portals_methods[] = { /* Device interface */ DEVMETHOD(device_probe, qman_portals_fdt_probe), DEVMETHOD(device_attach, qman_portals_fdt_attach), DEVMETHOD(device_detach, qman_portals_detach), { 0, 0 } }; static driver_t qm_portals_driver = { "qman-portals", qm_portals_methods, sizeof(struct dpaa_portals_softc), }; static devclass_t qm_portals_devclass; DRIVER_MODULE(qman_portals, ofwbus, qm_portals_driver, qm_portals_devclass, 0, 0); static void get_addr_props(phandle_t node, uint32_t *addrp, uint32_t *sizep) { *addrp = 2; *sizep = 1; OF_getencprop(node, "#address-cells", addrp, sizeof(*addrp)); OF_getencprop(node, "#size-cells", sizep, sizeof(*sizep)); } static int qman_portals_fdt_probe(device_t dev) { if (!ofw_bus_is_compatible(dev, "qman-portals")) return (ENXIO); device_set_desc(dev, BMAN_PORT_DEVSTR); return (BUS_PROBE_DEFAULT); } 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_size_t portal_size; uint32_t addr, size; ihandle_t cpu; int cpu_num, cpus, intr_rid; struct dpaa_portals_devinfo di; struct ofw_bus_devinfo ofw_di = {}; cpus = 0; sc = device_get_softc(dev); sc->sc_dev = dev; node = ofw_bus_get_node(dev); get_addr_props(node, &addr, &size); /* Find portals tied to CPUs */ for (child = OF_child(node); child != 0; child = OF_peer(child)) { - if (!fdt_is_compatible(child, "fsl,qman-portal")) { + 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; } /* Acquire cpu number */ cpu_node = OF_instance_to_package(cpu); if (OF_getencprop(cpu_node, "reg", &cpu_num, sizeof(cpu_num)) <= 0) { device_printf(dev, "Could not retrieve CPU number.\n"); return (ENXIO); } 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; } resource_list_init(&di.di_res); if (ofw_bus_reg_to_rl(dev, child, addr, size, &di.di_res)) { device_printf(dev, "%s: could not process 'reg' " "property\n", ofw_di.obd_name); ofw_bus_gen_destroy_devinfo(&ofw_di); continue; } if (ofw_bus_intr_to_rl(dev, child, &di.di_res, &intr_rid)) { device_printf(dev, "%s: could not process " "'interrupts' property\n", ofw_di.obd_name); resource_list_free(&di.di_res); ofw_bus_gen_destroy_devinfo(&ofw_di); 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; } ofw_bus_gen_destroy_devinfo(&ofw_di); return (qman_portals_attach(dev)); err: resource_list_free(&di.di_res); ofw_bus_gen_destroy_devinfo(&ofw_di); qman_portals_detach(dev); return (ENXIO); }