15d43fd68SRuslan Bukin /*- 25d43fd68SRuslan Bukin * Copyright (c) 2014 Ruslan Bukin <br@bsdpad.com> 35d43fd68SRuslan Bukin * 45d43fd68SRuslan Bukin * This software was developed by SRI International and the University of 55d43fd68SRuslan Bukin * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) 65d43fd68SRuslan Bukin * ("CTSRD"), as part of the DARPA CRASH research programme. 75d43fd68SRuslan Bukin * 85d43fd68SRuslan Bukin * Redistribution and use in source and binary forms, with or without 95d43fd68SRuslan Bukin * modification, are permitted provided that the following conditions 105d43fd68SRuslan Bukin * are met: 115d43fd68SRuslan Bukin * 1. Redistributions of source code must retain the above copyright 125d43fd68SRuslan Bukin * notice, this list of conditions and the following disclaimer. 135d43fd68SRuslan Bukin * 2. Redistributions in binary form must reproduce the above copyright 145d43fd68SRuslan Bukin * notice, this list of conditions and the following disclaimer in the 155d43fd68SRuslan Bukin * documentation and/or other materials provided with the distribution. 165d43fd68SRuslan Bukin * 175d43fd68SRuslan Bukin * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 185d43fd68SRuslan Bukin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 195d43fd68SRuslan Bukin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 205d43fd68SRuslan Bukin * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 215d43fd68SRuslan Bukin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 225d43fd68SRuslan Bukin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 235d43fd68SRuslan Bukin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 245d43fd68SRuslan Bukin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 255d43fd68SRuslan Bukin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 265d43fd68SRuslan Bukin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 275d43fd68SRuslan Bukin * SUCH DAMAGE. 285d43fd68SRuslan Bukin */ 295d43fd68SRuslan Bukin 305d43fd68SRuslan Bukin /* 315d43fd68SRuslan Bukin * Ethernet media access controller (EMAC) 325d43fd68SRuslan Bukin * Chapter 17, Altera Cyclone V Device Handbook (CV-5V2 2014.07.22) 335d43fd68SRuslan Bukin * 345d43fd68SRuslan Bukin * EMAC is an instance of the Synopsys DesignWare 3504-0 355d43fd68SRuslan Bukin * Universal 10/100/1000 Ethernet MAC (DWC_gmac). 365d43fd68SRuslan Bukin */ 375d43fd68SRuslan Bukin 385d43fd68SRuslan Bukin #include <sys/cdefs.h> 395d43fd68SRuslan Bukin #include <sys/param.h> 405d43fd68SRuslan Bukin #include <sys/systm.h> 415d43fd68SRuslan Bukin #include <sys/bus.h> 42d7acb49aSJared McNeill #include <sys/gpio.h> 435d43fd68SRuslan Bukin #include <sys/kernel.h> 445d43fd68SRuslan Bukin #include <sys/lock.h> 45da9a326bSLuiz Otavio O Souza #include <sys/malloc.h> 465d43fd68SRuslan Bukin #include <sys/mbuf.h> 47da9a326bSLuiz Otavio O Souza #include <sys/module.h> 485d43fd68SRuslan Bukin #include <sys/mutex.h> 49da9a326bSLuiz Otavio O Souza #include <sys/rman.h> 505d43fd68SRuslan Bukin #include <sys/socket.h> 515d43fd68SRuslan Bukin #include <sys/sockio.h> 525d43fd68SRuslan Bukin 535d43fd68SRuslan Bukin #include <net/bpf.h> 545d43fd68SRuslan Bukin #include <net/if.h> 555d43fd68SRuslan Bukin #include <net/ethernet.h> 565d43fd68SRuslan Bukin #include <net/if_dl.h> 575d43fd68SRuslan Bukin #include <net/if_media.h> 585d43fd68SRuslan Bukin #include <net/if_types.h> 595d43fd68SRuslan Bukin #include <net/if_var.h> 605d43fd68SRuslan Bukin 615d43fd68SRuslan Bukin #include <machine/bus.h> 625d43fd68SRuslan Bukin 6350059a60SEmmanuel Vadot #include <dev/extres/clk/clk.h> 6450059a60SEmmanuel Vadot #include <dev/extres/hwreset/hwreset.h> 6550059a60SEmmanuel Vadot 665d43fd68SRuslan Bukin #include <dev/mii/mii.h> 675d43fd68SRuslan Bukin #include <dev/mii/miivar.h> 68da9a326bSLuiz Otavio O Souza #include <dev/ofw/ofw_bus.h> 69da9a326bSLuiz Otavio O Souza #include <dev/ofw/ofw_bus_subr.h> 70f77d8d10SEmmanuel Vadot #include <dev/mii/mii_fdt.h> 71da9a326bSLuiz Otavio O Souza 72c36125f6SEmmanuel Vadot #include <dev/dwc/if_dwcvar.h> 7362519d5aSEmmanuel Vadot #include <dev/dwc/dwc1000_core.h> 74972adf0fSEmmanuel Vadot #include <dev/dwc/dwc1000_dma.h> 75c36125f6SEmmanuel Vadot 765df53927SLuiz Otavio O Souza #include "if_dwc_if.h" 77d7acb49aSJared McNeill #include "gpio_if.h" 785d43fd68SRuslan Bukin #include "miibus_if.h" 795d43fd68SRuslan Bukin 805d43fd68SRuslan Bukin static struct resource_spec dwc_spec[] = { 815d43fd68SRuslan Bukin { SYS_RES_MEMORY, 0, RF_ACTIVE }, 825d43fd68SRuslan Bukin { SYS_RES_IRQ, 0, RF_ACTIVE }, 835d43fd68SRuslan Bukin { -1, 0 } 845d43fd68SRuslan Bukin }; 855d43fd68SRuslan Bukin 865d43fd68SRuslan Bukin static void dwc_stop_locked(struct dwc_softc *sc); 875d43fd68SRuslan Bukin 882a35d391SEmmanuel Vadot static void dwc_tick(void *arg); 892a35d391SEmmanuel Vadot 902a35d391SEmmanuel Vadot /* 912a35d391SEmmanuel Vadot * Media functions 922a35d391SEmmanuel Vadot */ 932a35d391SEmmanuel Vadot 942a35d391SEmmanuel Vadot static void 95ca018790SMitchell Horne dwc_media_status(if_t ifp, struct ifmediareq *ifmr) 962a35d391SEmmanuel Vadot { 972a35d391SEmmanuel Vadot struct dwc_softc *sc; 982a35d391SEmmanuel Vadot struct mii_data *mii; 992a35d391SEmmanuel Vadot 100ca018790SMitchell Horne sc = if_getsoftc(ifp); 1012a35d391SEmmanuel Vadot mii = sc->mii_softc; 1022a35d391SEmmanuel Vadot DWC_LOCK(sc); 1032a35d391SEmmanuel Vadot mii_pollstat(mii); 1042a35d391SEmmanuel Vadot ifmr->ifm_active = mii->mii_media_active; 1052a35d391SEmmanuel Vadot ifmr->ifm_status = mii->mii_media_status; 1062a35d391SEmmanuel Vadot DWC_UNLOCK(sc); 1072a35d391SEmmanuel Vadot } 1082a35d391SEmmanuel Vadot 1092a35d391SEmmanuel Vadot static int 1102a35d391SEmmanuel Vadot dwc_media_change_locked(struct dwc_softc *sc) 1112a35d391SEmmanuel Vadot { 1122a35d391SEmmanuel Vadot 1132a35d391SEmmanuel Vadot return (mii_mediachg(sc->mii_softc)); 1142a35d391SEmmanuel Vadot } 1152a35d391SEmmanuel Vadot 1162a35d391SEmmanuel Vadot static int 117ca018790SMitchell Horne dwc_media_change(if_t ifp) 1182a35d391SEmmanuel Vadot { 1192a35d391SEmmanuel Vadot struct dwc_softc *sc; 1202a35d391SEmmanuel Vadot int error; 1212a35d391SEmmanuel Vadot 122ca018790SMitchell Horne sc = if_getsoftc(ifp); 1232a35d391SEmmanuel Vadot 1242a35d391SEmmanuel Vadot DWC_LOCK(sc); 1252a35d391SEmmanuel Vadot error = dwc_media_change_locked(sc); 1262a35d391SEmmanuel Vadot DWC_UNLOCK(sc); 1272a35d391SEmmanuel Vadot return (error); 1282a35d391SEmmanuel Vadot } 1292a35d391SEmmanuel Vadot 1302a35d391SEmmanuel Vadot /* 1312a35d391SEmmanuel Vadot * if_ functions 1322a35d391SEmmanuel Vadot */ 1332a35d391SEmmanuel Vadot 134f88e0af6SEmmanuel Vadot static void 1352a35d391SEmmanuel Vadot dwc_txstart_locked(struct dwc_softc *sc) 1365d43fd68SRuslan Bukin { 137ca018790SMitchell Horne if_t ifp; 1382a35d391SEmmanuel Vadot 1392a35d391SEmmanuel Vadot DWC_ASSERT_LOCKED(sc); 1402a35d391SEmmanuel Vadot 1412a35d391SEmmanuel Vadot if (!sc->link_is_up) 1422a35d391SEmmanuel Vadot return; 1432a35d391SEmmanuel Vadot 1442a35d391SEmmanuel Vadot ifp = sc->ifp; 1452a35d391SEmmanuel Vadot 1463bbd11eeSEmmanuel Vadot if ((if_getdrvflags(ifp) & (IFF_DRV_RUNNING|IFF_DRV_OACTIVE)) != 1473bbd11eeSEmmanuel Vadot IFF_DRV_RUNNING) 1482a35d391SEmmanuel Vadot return; 149afa0f66eSEmmanuel Vadot dma1000_txstart(sc); 1502a35d391SEmmanuel Vadot } 1512a35d391SEmmanuel Vadot 1522a35d391SEmmanuel Vadot static void 153ca018790SMitchell Horne dwc_txstart(if_t ifp) 1542a35d391SEmmanuel Vadot { 155ca018790SMitchell Horne struct dwc_softc *sc = if_getsoftc(ifp); 1562a35d391SEmmanuel Vadot 1572a35d391SEmmanuel Vadot DWC_LOCK(sc); 1582a35d391SEmmanuel Vadot dwc_txstart_locked(sc); 1592a35d391SEmmanuel Vadot DWC_UNLOCK(sc); 1602a35d391SEmmanuel Vadot } 1612a35d391SEmmanuel Vadot 1622a35d391SEmmanuel Vadot static void 1632a35d391SEmmanuel Vadot dwc_init_locked(struct dwc_softc *sc) 1642a35d391SEmmanuel Vadot { 165ca018790SMitchell Horne if_t ifp = sc->ifp; 1662a35d391SEmmanuel Vadot 1672a35d391SEmmanuel Vadot DWC_ASSERT_LOCKED(sc); 1682a35d391SEmmanuel Vadot 1693bbd11eeSEmmanuel Vadot if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) 1702a35d391SEmmanuel Vadot return; 1712a35d391SEmmanuel Vadot 1726501fcdcSJiahao LI /* 17362519d5aSEmmanuel Vadot * Call mii_mediachg() which will call back into dwc1000_miibus_statchg() 1746501fcdcSJiahao LI * to set up the remaining config registers based on current media. 1756501fcdcSJiahao LI */ 1766501fcdcSJiahao LI mii_mediachg(sc->mii_softc); 1776501fcdcSJiahao LI 17862519d5aSEmmanuel Vadot dwc1000_setup_rxfilter(sc); 17962519d5aSEmmanuel Vadot dwc1000_core_setup(sc); 18062519d5aSEmmanuel Vadot dwc1000_enable_mac(sc, true); 18162519d5aSEmmanuel Vadot dwc1000_enable_csum_offload(sc); 182972adf0fSEmmanuel Vadot dma1000_start(sc); 1832a35d391SEmmanuel Vadot 1842a35d391SEmmanuel Vadot if_setdrvflagbits(ifp, IFF_DRV_RUNNING, IFF_DRV_OACTIVE); 1855d43fd68SRuslan Bukin 1862a35d391SEmmanuel Vadot callout_reset(&sc->dwc_callout, hz, dwc_tick, sc); 1872a35d391SEmmanuel Vadot } 1882a35d391SEmmanuel Vadot 1892a35d391SEmmanuel Vadot static void 1902a35d391SEmmanuel Vadot dwc_init(void *if_softc) 1912a35d391SEmmanuel Vadot { 1922a35d391SEmmanuel Vadot struct dwc_softc *sc = if_softc; 1932a35d391SEmmanuel Vadot 1942a35d391SEmmanuel Vadot DWC_LOCK(sc); 1952a35d391SEmmanuel Vadot dwc_init_locked(sc); 1962a35d391SEmmanuel Vadot DWC_UNLOCK(sc); 1972a35d391SEmmanuel Vadot } 1982a35d391SEmmanuel Vadot 1992a35d391SEmmanuel Vadot static void 2002a35d391SEmmanuel Vadot dwc_stop_locked(struct dwc_softc *sc) 2012a35d391SEmmanuel Vadot { 202ca018790SMitchell Horne if_t ifp; 2032a35d391SEmmanuel Vadot 2042a35d391SEmmanuel Vadot DWC_ASSERT_LOCKED(sc); 2052a35d391SEmmanuel Vadot 2062a35d391SEmmanuel Vadot ifp = sc->ifp; 2073bbd11eeSEmmanuel Vadot if_setdrvflagbits(ifp, 0, IFF_DRV_RUNNING | IFF_DRV_OACTIVE); 2082a35d391SEmmanuel Vadot sc->tx_watchdog_count = 0; 2092a35d391SEmmanuel Vadot sc->stats_harvest_count = 0; 2102a35d391SEmmanuel Vadot 2112a35d391SEmmanuel Vadot callout_stop(&sc->dwc_callout); 2122a35d391SEmmanuel Vadot 213972adf0fSEmmanuel Vadot dma1000_stop(sc); 21462519d5aSEmmanuel Vadot dwc1000_enable_mac(sc, false); 2152a35d391SEmmanuel Vadot } 2162a35d391SEmmanuel Vadot 2172a35d391SEmmanuel Vadot static int 218ca018790SMitchell Horne dwc_ioctl(if_t ifp, u_long cmd, caddr_t data) 2192a35d391SEmmanuel Vadot { 2202a35d391SEmmanuel Vadot struct dwc_softc *sc; 2212a35d391SEmmanuel Vadot struct mii_data *mii; 2222a35d391SEmmanuel Vadot struct ifreq *ifr; 2233bbd11eeSEmmanuel Vadot int flags, mask, error; 2242a35d391SEmmanuel Vadot 225ca018790SMitchell Horne sc = if_getsoftc(ifp); 2262a35d391SEmmanuel Vadot ifr = (struct ifreq *)data; 2272a35d391SEmmanuel Vadot 2282a35d391SEmmanuel Vadot error = 0; 2292a35d391SEmmanuel Vadot switch (cmd) { 2302a35d391SEmmanuel Vadot case SIOCSIFFLAGS: 2312a35d391SEmmanuel Vadot DWC_LOCK(sc); 2323bbd11eeSEmmanuel Vadot if (if_getflags(ifp) & IFF_UP) { 2333bbd11eeSEmmanuel Vadot if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { 2343bbd11eeSEmmanuel Vadot flags = if_getflags(ifp) ^ sc->if_flags; 2353bbd11eeSEmmanuel Vadot if ((flags & (IFF_PROMISC|IFF_ALLMULTI)) != 0) 23662519d5aSEmmanuel Vadot dwc1000_setup_rxfilter(sc); 2375d43fd68SRuslan Bukin } else { 2382a35d391SEmmanuel Vadot if (!sc->is_detaching) 2392a35d391SEmmanuel Vadot dwc_init_locked(sc); 2402a35d391SEmmanuel Vadot } 2412a35d391SEmmanuel Vadot } else { 2423bbd11eeSEmmanuel Vadot if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) 2432a35d391SEmmanuel Vadot dwc_stop_locked(sc); 2442a35d391SEmmanuel Vadot } 2453bbd11eeSEmmanuel Vadot sc->if_flags = if_getflags(ifp); 2462a35d391SEmmanuel Vadot DWC_UNLOCK(sc); 2472a35d391SEmmanuel Vadot break; 2482a35d391SEmmanuel Vadot case SIOCADDMULTI: 2492a35d391SEmmanuel Vadot case SIOCDELMULTI: 2503bbd11eeSEmmanuel Vadot if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { 2512a35d391SEmmanuel Vadot DWC_LOCK(sc); 25262519d5aSEmmanuel Vadot dwc1000_setup_rxfilter(sc); 2532a35d391SEmmanuel Vadot DWC_UNLOCK(sc); 2542a35d391SEmmanuel Vadot } 2552a35d391SEmmanuel Vadot break; 2562a35d391SEmmanuel Vadot case SIOCSIFMEDIA: 2572a35d391SEmmanuel Vadot case SIOCGIFMEDIA: 2582a35d391SEmmanuel Vadot mii = sc->mii_softc; 2592a35d391SEmmanuel Vadot error = ifmedia_ioctl(ifp, ifr, &mii->mii_media, cmd); 2602a35d391SEmmanuel Vadot break; 2612a35d391SEmmanuel Vadot case SIOCSIFCAP: 2623bbd11eeSEmmanuel Vadot mask = ifr->ifr_reqcap ^ if_getcapenable(ifp); 2632a35d391SEmmanuel Vadot if (mask & IFCAP_VLAN_MTU) { 2642a35d391SEmmanuel Vadot /* No work to do except acknowledge the change took */ 2653bbd11eeSEmmanuel Vadot if_togglecapenable(ifp, IFCAP_VLAN_MTU); 2662a35d391SEmmanuel Vadot } 26798ea5a7bSEmmanuel Vadot if (mask & IFCAP_RXCSUM) 26898ea5a7bSEmmanuel Vadot if_togglecapenable(ifp, IFCAP_RXCSUM); 26998ea5a7bSEmmanuel Vadot if (mask & IFCAP_TXCSUM) 27098ea5a7bSEmmanuel Vadot if_togglecapenable(ifp, IFCAP_TXCSUM); 27198ea5a7bSEmmanuel Vadot if ((if_getcapenable(ifp) & IFCAP_TXCSUM) != 0) 27298ea5a7bSEmmanuel Vadot if_sethwassistbits(ifp, CSUM_IP | CSUM_UDP | CSUM_TCP, 0); 27398ea5a7bSEmmanuel Vadot else 27498ea5a7bSEmmanuel Vadot if_sethwassistbits(ifp, 0, CSUM_IP | CSUM_UDP | CSUM_TCP); 27535c9edabSJiahao Li 27635c9edabSJiahao Li if (if_getdrvflags(ifp) & IFF_DRV_RUNNING) { 27735c9edabSJiahao Li DWC_LOCK(sc); 27862519d5aSEmmanuel Vadot dwc1000_enable_csum_offload(sc); 27935c9edabSJiahao Li DWC_UNLOCK(sc); 28035c9edabSJiahao Li } 2812a35d391SEmmanuel Vadot break; 2822a35d391SEmmanuel Vadot 2832a35d391SEmmanuel Vadot default: 2842a35d391SEmmanuel Vadot error = ether_ioctl(ifp, cmd, data); 2852a35d391SEmmanuel Vadot break; 2862a35d391SEmmanuel Vadot } 2872a35d391SEmmanuel Vadot 2882a35d391SEmmanuel Vadot return (error); 2892a35d391SEmmanuel Vadot } 2902a35d391SEmmanuel Vadot 2912a35d391SEmmanuel Vadot /* 2922a35d391SEmmanuel Vadot * Interrupts functions 2932a35d391SEmmanuel Vadot */ 2942a35d391SEmmanuel Vadot 2952a35d391SEmmanuel Vadot 2962a35d391SEmmanuel Vadot static void 2972a35d391SEmmanuel Vadot dwc_intr(void *arg) 2982a35d391SEmmanuel Vadot { 2992a35d391SEmmanuel Vadot struct dwc_softc *sc; 30029776aa4SEmmanuel Vadot int rv; 3012a35d391SEmmanuel Vadot 3022a35d391SEmmanuel Vadot sc = arg; 3032a35d391SEmmanuel Vadot DWC_LOCK(sc); 30429776aa4SEmmanuel Vadot dwc1000_intr(sc); 30529776aa4SEmmanuel Vadot rv = dma1000_intr(sc); 30629776aa4SEmmanuel Vadot if (rv == EIO) { 3072a35d391SEmmanuel Vadot device_printf(sc->dev, 3082a35d391SEmmanuel Vadot "Ethernet DMA error, restarting controller.\n"); 3092a35d391SEmmanuel Vadot dwc_stop_locked(sc); 3102a35d391SEmmanuel Vadot dwc_init_locked(sc); 3112a35d391SEmmanuel Vadot } 3122a35d391SEmmanuel Vadot DWC_UNLOCK(sc); 3132a35d391SEmmanuel Vadot } 3142a35d391SEmmanuel Vadot 3152a35d391SEmmanuel Vadot static void 3162a35d391SEmmanuel Vadot dwc_tick(void *arg) 3172a35d391SEmmanuel Vadot { 3182a35d391SEmmanuel Vadot struct dwc_softc *sc; 319ca018790SMitchell Horne if_t ifp; 3202a35d391SEmmanuel Vadot int link_was_up; 3212a35d391SEmmanuel Vadot 3222a35d391SEmmanuel Vadot sc = arg; 3232a35d391SEmmanuel Vadot 3242a35d391SEmmanuel Vadot DWC_ASSERT_LOCKED(sc); 3252a35d391SEmmanuel Vadot 3262a35d391SEmmanuel Vadot ifp = sc->ifp; 3272a35d391SEmmanuel Vadot 3283bbd11eeSEmmanuel Vadot if ((if_getdrvflags(ifp) & IFF_DRV_RUNNING) == 0) 3292a35d391SEmmanuel Vadot return; 3302a35d391SEmmanuel Vadot 3312a35d391SEmmanuel Vadot /* 3322a35d391SEmmanuel Vadot * Typical tx watchdog. If this fires it indicates that we enqueued 3332a35d391SEmmanuel Vadot * packets for output and never got a txdone interrupt for them. Maybe 3342a35d391SEmmanuel Vadot * it's a missed interrupt somehow, just pretend we got one. 3352a35d391SEmmanuel Vadot */ 3362a35d391SEmmanuel Vadot if (sc->tx_watchdog_count > 0) { 3372a35d391SEmmanuel Vadot if (--sc->tx_watchdog_count == 0) { 338972adf0fSEmmanuel Vadot dma1000_txfinish_locked(sc); 3392a35d391SEmmanuel Vadot } 3402a35d391SEmmanuel Vadot } 3412a35d391SEmmanuel Vadot 3422a35d391SEmmanuel Vadot /* Gather stats from hardware counters. */ 34362519d5aSEmmanuel Vadot dwc1000_harvest_stats(sc); 3442a35d391SEmmanuel Vadot 3452a35d391SEmmanuel Vadot /* Check the media status. */ 3462a35d391SEmmanuel Vadot link_was_up = sc->link_is_up; 3472a35d391SEmmanuel Vadot mii_tick(sc->mii_softc); 3482a35d391SEmmanuel Vadot if (sc->link_is_up && !link_was_up) 3492a35d391SEmmanuel Vadot dwc_txstart_locked(sc); 3502a35d391SEmmanuel Vadot 3512a35d391SEmmanuel Vadot /* Schedule another check one second from now. */ 3522a35d391SEmmanuel Vadot callout_reset(&sc->dwc_callout, hz, dwc_tick, sc); 3532a35d391SEmmanuel Vadot } 3542a35d391SEmmanuel Vadot 355d7acb49aSJared McNeill static int 356f114aaddSEmmanuel Vadot dwc_reset_phy(struct dwc_softc *sc) 357d7acb49aSJared McNeill { 358d7acb49aSJared McNeill pcell_t gpio_prop[4]; 359d7acb49aSJared McNeill pcell_t delay_prop[3]; 360f114aaddSEmmanuel Vadot phandle_t gpio_node; 361d7acb49aSJared McNeill device_t gpio; 362d7acb49aSJared McNeill uint32_t pin, flags; 363d7acb49aSJared McNeill uint32_t pin_value; 364d7acb49aSJared McNeill 365f114aaddSEmmanuel Vadot /* 366f114aaddSEmmanuel Vadot * All those properties are deprecated but still used in some DTS. 367f114aaddSEmmanuel Vadot * The new way to deal with this is to use the generic bindings 368f114aaddSEmmanuel Vadot * present in the ethernet-phy node. 369f114aaddSEmmanuel Vadot */ 370f114aaddSEmmanuel Vadot if (OF_getencprop(sc->node, "snps,reset-gpio", 371d7acb49aSJared McNeill gpio_prop, sizeof(gpio_prop)) <= 0) 372d7acb49aSJared McNeill return (0); 373d7acb49aSJared McNeill 374f114aaddSEmmanuel Vadot if (OF_getencprop(sc->node, "snps,reset-delays-us", 375d7acb49aSJared McNeill delay_prop, sizeof(delay_prop)) <= 0) { 376f114aaddSEmmanuel Vadot device_printf(sc->dev, 377d7acb49aSJared McNeill "Wrong property for snps,reset-delays-us"); 378d7acb49aSJared McNeill return (ENXIO); 379d7acb49aSJared McNeill } 380d7acb49aSJared McNeill 381d7acb49aSJared McNeill gpio_node = OF_node_from_xref(gpio_prop[0]); 382d7acb49aSJared McNeill if ((gpio = OF_device_from_xref(gpio_prop[0])) == NULL) { 383f114aaddSEmmanuel Vadot device_printf(sc->dev, 384d7acb49aSJared McNeill "Can't find gpio controller for phy reset\n"); 385d7acb49aSJared McNeill return (ENXIO); 386d7acb49aSJared McNeill } 387d7acb49aSJared McNeill 388f114aaddSEmmanuel Vadot if (GPIO_MAP_GPIOS(gpio, sc->node, gpio_node, 38973a1170aSPedro F. Giffuni nitems(gpio_prop) - 1, 390d7acb49aSJared McNeill gpio_prop + 1, &pin, &flags) != 0) { 391f114aaddSEmmanuel Vadot device_printf(sc->dev, "Can't map gpio for phy reset\n"); 392d7acb49aSJared McNeill return (ENXIO); 393d7acb49aSJared McNeill } 394d7acb49aSJared McNeill 395d7acb49aSJared McNeill pin_value = GPIO_PIN_LOW; 396f114aaddSEmmanuel Vadot if (OF_hasprop(sc->node, "snps,reset-active-low")) 397d7acb49aSJared McNeill pin_value = GPIO_PIN_HIGH; 398d7acb49aSJared McNeill 399d7acb49aSJared McNeill GPIO_PIN_SETFLAGS(gpio, pin, GPIO_PIN_OUTPUT); 400d7acb49aSJared McNeill GPIO_PIN_SET(gpio, pin, pin_value); 401c069412eSEmmanuel Vadot DELAY(delay_prop[0] * 5); 402d7acb49aSJared McNeill GPIO_PIN_SET(gpio, pin, !pin_value); 403c069412eSEmmanuel Vadot DELAY(delay_prop[1] * 5); 404d7acb49aSJared McNeill GPIO_PIN_SET(gpio, pin, pin_value); 405c069412eSEmmanuel Vadot DELAY(delay_prop[2] * 5); 406d7acb49aSJared McNeill 407d7acb49aSJared McNeill return (0); 408d7acb49aSJared McNeill } 409d7acb49aSJared McNeill 4106a05f063SJared McNeill static int 41150059a60SEmmanuel Vadot dwc_clock_init(struct dwc_softc *sc) 4126a05f063SJared McNeill { 41350059a60SEmmanuel Vadot int rv; 414824cfb47SOleksandr Tymoshenko int64_t freq; 4156a05f063SJared McNeill 41650059a60SEmmanuel Vadot /* Required clock */ 41750059a60SEmmanuel Vadot rv = clk_get_by_ofw_name(sc->dev, 0, "stmmaceth", &sc->clk_stmmaceth); 41850059a60SEmmanuel Vadot if (rv != 0) { 41950059a60SEmmanuel Vadot device_printf(sc->dev, "Cannot get GMAC main clock\n"); 42050059a60SEmmanuel Vadot return (ENXIO); 4216a05f063SJared McNeill } 42250059a60SEmmanuel Vadot if ((rv = clk_enable(sc->clk_stmmaceth)) != 0) { 42350059a60SEmmanuel Vadot device_printf(sc->dev, "could not enable main clock\n"); 42450059a60SEmmanuel Vadot return (rv); 4256a05f063SJared McNeill } 4266a05f063SJared McNeill 42750059a60SEmmanuel Vadot /* Optional clock */ 42850059a60SEmmanuel Vadot rv = clk_get_by_ofw_name(sc->dev, 0, "pclk", &sc->clk_pclk); 42950059a60SEmmanuel Vadot if (rv != 0) 43050059a60SEmmanuel Vadot return (0); 43150059a60SEmmanuel Vadot if ((rv = clk_enable(sc->clk_pclk)) != 0) { 43250059a60SEmmanuel Vadot device_printf(sc->dev, "could not enable peripheral clock\n"); 43350059a60SEmmanuel Vadot return (rv); 4346a05f063SJared McNeill } 43550059a60SEmmanuel Vadot 43650059a60SEmmanuel Vadot if (bootverbose) { 43750059a60SEmmanuel Vadot clk_get_freq(sc->clk_stmmaceth, &freq); 43850059a60SEmmanuel Vadot device_printf(sc->dev, "MAC clock(%s) freq: %jd\n", 43950059a60SEmmanuel Vadot clk_get_name(sc->clk_stmmaceth), (intmax_t)freq); 44050059a60SEmmanuel Vadot } 44150059a60SEmmanuel Vadot 44250059a60SEmmanuel Vadot return (0); 44350059a60SEmmanuel Vadot } 44450059a60SEmmanuel Vadot 44550059a60SEmmanuel Vadot static int 44650059a60SEmmanuel Vadot dwc_reset_deassert(struct dwc_softc *sc) 44750059a60SEmmanuel Vadot { 44850059a60SEmmanuel Vadot int rv; 44950059a60SEmmanuel Vadot 45050059a60SEmmanuel Vadot /* Required reset */ 45150059a60SEmmanuel Vadot rv = hwreset_get_by_ofw_name(sc->dev, 0, "stmmaceth", &sc->rst_stmmaceth); 45250059a60SEmmanuel Vadot if (rv != 0) { 45350059a60SEmmanuel Vadot device_printf(sc->dev, "Cannot get GMAC reset\n"); 45450059a60SEmmanuel Vadot return (ENXIO); 45550059a60SEmmanuel Vadot } 45650059a60SEmmanuel Vadot rv = hwreset_deassert(sc->rst_stmmaceth); 45750059a60SEmmanuel Vadot if (rv != 0) { 45850059a60SEmmanuel Vadot device_printf(sc->dev, "could not de-assert GMAC reset\n"); 45950059a60SEmmanuel Vadot return (rv); 46050059a60SEmmanuel Vadot } 46150059a60SEmmanuel Vadot 46250059a60SEmmanuel Vadot /* Optional reset */ 46350059a60SEmmanuel Vadot rv = hwreset_get_by_ofw_name(sc->dev, 0, "ahb", &sc->rst_ahb); 46450059a60SEmmanuel Vadot if (rv != 0) 46550059a60SEmmanuel Vadot return (0); 46650059a60SEmmanuel Vadot rv = hwreset_deassert(sc->rst_ahb); 46750059a60SEmmanuel Vadot if (rv != 0) { 46850059a60SEmmanuel Vadot device_printf(sc->dev, "could not de-assert AHB reset\n"); 46950059a60SEmmanuel Vadot return (rv); 4706a05f063SJared McNeill } 4716a05f063SJared McNeill 4726a05f063SJared McNeill return (0); 4736a05f063SJared McNeill } 4746a05f063SJared McNeill 47527f03f16SEmmanuel Vadot /* 47627f03f16SEmmanuel Vadot * Probe/Attach functions 47727f03f16SEmmanuel Vadot */ 47827f03f16SEmmanuel Vadot 4795d43fd68SRuslan Bukin static int 4805d43fd68SRuslan Bukin dwc_probe(device_t dev) 4815d43fd68SRuslan Bukin { 4825d43fd68SRuslan Bukin 4835d43fd68SRuslan Bukin if (!ofw_bus_status_okay(dev)) 4845d43fd68SRuslan Bukin return (ENXIO); 4855d43fd68SRuslan Bukin 4865d43fd68SRuslan Bukin if (!ofw_bus_is_compatible(dev, "snps,dwmac")) 4875d43fd68SRuslan Bukin return (ENXIO); 4885d43fd68SRuslan Bukin 4895d43fd68SRuslan Bukin device_set_desc(dev, "Gigabit Ethernet Controller"); 4905d43fd68SRuslan Bukin return (BUS_PROBE_DEFAULT); 4915d43fd68SRuslan Bukin } 4925d43fd68SRuslan Bukin 4935d43fd68SRuslan Bukin static int 4945d43fd68SRuslan Bukin dwc_attach(device_t dev) 4955d43fd68SRuslan Bukin { 4965d43fd68SRuslan Bukin uint8_t macaddr[ETHER_ADDR_LEN]; 4975d43fd68SRuslan Bukin struct dwc_softc *sc; 498ca018790SMitchell Horne if_t ifp; 499363b7c39SEmmanuel Vadot int error; 5005d88a52bSEmmanuel Vadot uint32_t pbl; 5015d43fd68SRuslan Bukin 5025d43fd68SRuslan Bukin sc = device_get_softc(dev); 5035d43fd68SRuslan Bukin sc->dev = dev; 5045d43fd68SRuslan Bukin sc->rx_idx = 0; 505e5232621SOleksandr Tymoshenko sc->tx_desccount = TX_DESC_COUNT; 506e5232621SOleksandr Tymoshenko sc->tx_mapcount = 0; 5075df53927SLuiz Otavio O Souza sc->mii_clk = IF_DWC_MII_CLK(dev); 5085df53927SLuiz Otavio O Souza sc->mactype = IF_DWC_MAC_TYPE(dev); 5095df53927SLuiz Otavio O Souza 510f114aaddSEmmanuel Vadot sc->node = ofw_bus_get_node(dev); 511801fb66aSEmmanuel Vadot sc->phy_mode = mii_fdt_get_contype(sc->node); 512801fb66aSEmmanuel Vadot switch (sc->phy_mode) { 513f77d8d10SEmmanuel Vadot case MII_CONTYPE_RGMII: 514f77d8d10SEmmanuel Vadot case MII_CONTYPE_RGMII_ID: 515f77d8d10SEmmanuel Vadot case MII_CONTYPE_RGMII_RXID: 516f77d8d10SEmmanuel Vadot case MII_CONTYPE_RGMII_TXID: 517f77d8d10SEmmanuel Vadot case MII_CONTYPE_RMII: 518da6252a6SEmmanuel Vadot case MII_CONTYPE_MII: 519da6252a6SEmmanuel Vadot break; 520f77d8d10SEmmanuel Vadot default: 521f77d8d10SEmmanuel Vadot device_printf(dev, "Unsupported MII type\n"); 522f77d8d10SEmmanuel Vadot return (ENXIO); 523824cfb47SOleksandr Tymoshenko } 524824cfb47SOleksandr Tymoshenko 525f114aaddSEmmanuel Vadot if (OF_getencprop(sc->node, "snps,pbl", &pbl, sizeof(uint32_t)) <= 0) 526*cef444d0SEmmanuel Vadot pbl = DMA_DEFAULT_PBL; 5275d88a52bSEmmanuel Vadot if (OF_getencprop(sc->node, "snps,txpbl", &sc->txpbl, sizeof(uint32_t)) <= 0) 5285d88a52bSEmmanuel Vadot sc->txpbl = pbl; 5295d88a52bSEmmanuel Vadot if (OF_getencprop(sc->node, "snps,rxpbl", &sc->rxpbl, sizeof(uint32_t)) <= 0) 5305d88a52bSEmmanuel Vadot sc->rxpbl = pbl; 531f114aaddSEmmanuel Vadot if (OF_hasprop(sc->node, "snps,no-pbl-x8") == 1) 5325d88a52bSEmmanuel Vadot sc->nopblx8 = true; 533f114aaddSEmmanuel Vadot if (OF_hasprop(sc->node, "snps,fixed-burst") == 1) 5345d88a52bSEmmanuel Vadot sc->fixed_burst = true; 535f4bb6ea5SEmmanuel Vadot if (OF_hasprop(sc->node, "snps,mixed-burst") == 1) 5365d88a52bSEmmanuel Vadot sc->mixed_burst = true; 537b69c49d1SEmmanuel Vadot if (OF_hasprop(sc->node, "snps,aal") == 1) 5385d88a52bSEmmanuel Vadot sc->aal = true; 5395e38d9e4SEmmanuel Vadot 54050059a60SEmmanuel Vadot error = clk_set_assigned(dev, ofw_bus_get_node(dev)); 54150059a60SEmmanuel Vadot if (error != 0) { 54250059a60SEmmanuel Vadot device_printf(dev, "clk_set_assigned failed\n"); 54350059a60SEmmanuel Vadot return (error); 54450059a60SEmmanuel Vadot } 5455d43fd68SRuslan Bukin 54650059a60SEmmanuel Vadot /* Enable main clock */ 54750059a60SEmmanuel Vadot if ((error = dwc_clock_init(sc)) != 0) 54850059a60SEmmanuel Vadot return (error); 54950059a60SEmmanuel Vadot /* De-assert main reset */ 55050059a60SEmmanuel Vadot if ((error = dwc_reset_deassert(sc)) != 0) 55150059a60SEmmanuel Vadot return (error); 55250059a60SEmmanuel Vadot 55350059a60SEmmanuel Vadot if (IF_DWC_INIT(dev) != 0) 5546a05f063SJared McNeill return (ENXIO); 5556a05f063SJared McNeill 5565d43fd68SRuslan Bukin if (bus_alloc_resources(dev, dwc_spec, sc->res)) { 5575d43fd68SRuslan Bukin device_printf(dev, "could not allocate resources\n"); 5585d43fd68SRuslan Bukin return (ENXIO); 5595d43fd68SRuslan Bukin } 5605d43fd68SRuslan Bukin 5615d43fd68SRuslan Bukin /* Read MAC before reset */ 56262519d5aSEmmanuel Vadot dwc1000_get_hwaddr(sc, macaddr); 5635d43fd68SRuslan Bukin 564d7acb49aSJared McNeill /* Reset the PHY if needed */ 565f114aaddSEmmanuel Vadot if (dwc_reset_phy(sc) != 0) { 566d7acb49aSJared McNeill device_printf(dev, "Can't reset the PHY\n"); 56730f16ad4SEmmanuel Vadot bus_release_resources(dev, dwc_spec, sc->res); 568d7acb49aSJared McNeill return (ENXIO); 569d7acb49aSJared McNeill } 570d7acb49aSJared McNeill 5715d43fd68SRuslan Bukin /* Reset */ 572363b7c39SEmmanuel Vadot if ((error = dma1000_reset(sc)) != 0) { 573363b7c39SEmmanuel Vadot device_printf(sc->dev, "Can't reset DMA controller.\n"); 574363b7c39SEmmanuel Vadot bus_release_resources(sc->dev, dwc_spec, sc->res); 575363b7c39SEmmanuel Vadot return (error); 5765d43fd68SRuslan Bukin } 5775d43fd68SRuslan Bukin 578972adf0fSEmmanuel Vadot if (dma1000_init(sc)) { 57930f16ad4SEmmanuel Vadot bus_release_resources(dev, dwc_spec, sc->res); 5805d43fd68SRuslan Bukin return (ENXIO); 58130f16ad4SEmmanuel Vadot } 5825d43fd68SRuslan Bukin 583d8e5258dSRuslan Bukin mtx_init(&sc->mtx, device_get_nameunit(sc->dev), 584d8e5258dSRuslan Bukin MTX_NETWORK_LOCK, MTX_DEF); 585d8e5258dSRuslan Bukin 586d8e5258dSRuslan Bukin callout_init_mtx(&sc->dwc_callout, &sc->mtx, 0); 587d8e5258dSRuslan Bukin 588d8e5258dSRuslan Bukin /* Setup interrupt handler. */ 589d8e5258dSRuslan Bukin error = bus_setup_intr(dev, sc->res[1], INTR_TYPE_NET | INTR_MPSAFE, 590d8e5258dSRuslan Bukin NULL, dwc_intr, sc, &sc->intr_cookie); 591d8e5258dSRuslan Bukin if (error != 0) { 592d8e5258dSRuslan Bukin device_printf(dev, "could not setup interrupt handler.\n"); 59330f16ad4SEmmanuel Vadot bus_release_resources(dev, dwc_spec, sc->res); 594d8e5258dSRuslan Bukin return (ENXIO); 595d8e5258dSRuslan Bukin } 596d8e5258dSRuslan Bukin 5975d43fd68SRuslan Bukin /* Set up the ethernet interface. */ 5985d43fd68SRuslan Bukin sc->ifp = ifp = if_alloc(IFT_ETHER); 5995d43fd68SRuslan Bukin 600ca018790SMitchell Horne if_setsoftc(ifp, sc); 6015d43fd68SRuslan Bukin if_initname(ifp, device_get_name(dev), device_get_unit(dev)); 6023bbd11eeSEmmanuel Vadot if_setflags(sc->ifp, IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST); 6033bbd11eeSEmmanuel Vadot if_setstartfn(ifp, dwc_txstart); 6043bbd11eeSEmmanuel Vadot if_setioctlfn(ifp, dwc_ioctl); 6053bbd11eeSEmmanuel Vadot if_setinitfn(ifp, dwc_init); 606e5232621SOleksandr Tymoshenko if_setsendqlen(ifp, TX_MAP_COUNT - 1); 6073bbd11eeSEmmanuel Vadot if_setsendqready(sc->ifp); 60898ea5a7bSEmmanuel Vadot if_sethwassist(sc->ifp, CSUM_IP | CSUM_UDP | CSUM_TCP); 60998ea5a7bSEmmanuel Vadot if_setcapabilities(sc->ifp, IFCAP_VLAN_MTU | IFCAP_HWCSUM); 6103bbd11eeSEmmanuel Vadot if_setcapenable(sc->ifp, if_getcapabilities(sc->ifp)); 6115d43fd68SRuslan Bukin 6125d43fd68SRuslan Bukin /* Attach the mii driver. */ 6135d43fd68SRuslan Bukin error = mii_attach(dev, &sc->miibus, ifp, dwc_media_change, 6145d43fd68SRuslan Bukin dwc_media_status, BMSR_DEFCAPMASK, MII_PHY_ANY, 6155d43fd68SRuslan Bukin MII_OFFSET_ANY, 0); 6165d43fd68SRuslan Bukin 6175d43fd68SRuslan Bukin if (error != 0) { 6185d43fd68SRuslan Bukin device_printf(dev, "PHY attach failed\n"); 61930f16ad4SEmmanuel Vadot bus_teardown_intr(dev, sc->res[1], sc->intr_cookie); 62030f16ad4SEmmanuel Vadot bus_release_resources(dev, dwc_spec, sc->res); 6215d43fd68SRuslan Bukin return (ENXIO); 6225d43fd68SRuslan Bukin } 6235d43fd68SRuslan Bukin sc->mii_softc = device_get_softc(sc->miibus); 6245d43fd68SRuslan Bukin 6255d43fd68SRuslan Bukin /* All ready to run, attach the ethernet interface. */ 6265d43fd68SRuslan Bukin ether_ifattach(ifp, macaddr); 6275d43fd68SRuslan Bukin sc->is_attached = true; 6285d43fd68SRuslan Bukin 6295d43fd68SRuslan Bukin return (0); 6305d43fd68SRuslan Bukin } 6315d43fd68SRuslan Bukin 63227b39e58SMitchell Horne static int 63327b39e58SMitchell Horne dwc_detach(device_t dev) 63427b39e58SMitchell Horne { 63527b39e58SMitchell Horne struct dwc_softc *sc; 63627b39e58SMitchell Horne 63727b39e58SMitchell Horne sc = device_get_softc(dev); 63827b39e58SMitchell Horne 63927b39e58SMitchell Horne /* 64027b39e58SMitchell Horne * Disable and tear down interrupts before anything else, so we don't 64127b39e58SMitchell Horne * race with the handler. 64227b39e58SMitchell Horne */ 64329776aa4SEmmanuel Vadot dwc1000_intr_disable(sc); 64427b39e58SMitchell Horne if (sc->intr_cookie != NULL) { 64527b39e58SMitchell Horne bus_teardown_intr(dev, sc->res[1], sc->intr_cookie); 64627b39e58SMitchell Horne } 64727b39e58SMitchell Horne 64827b39e58SMitchell Horne if (sc->is_attached) { 64927b39e58SMitchell Horne DWC_LOCK(sc); 65027b39e58SMitchell Horne sc->is_detaching = true; 65127b39e58SMitchell Horne dwc_stop_locked(sc); 65227b39e58SMitchell Horne DWC_UNLOCK(sc); 65327b39e58SMitchell Horne callout_drain(&sc->dwc_callout); 65427b39e58SMitchell Horne ether_ifdetach(sc->ifp); 65527b39e58SMitchell Horne } 65627b39e58SMitchell Horne 65727b39e58SMitchell Horne if (sc->miibus != NULL) { 65827b39e58SMitchell Horne device_delete_child(dev, sc->miibus); 65927b39e58SMitchell Horne sc->miibus = NULL; 66027b39e58SMitchell Horne } 66127b39e58SMitchell Horne bus_generic_detach(dev); 66227b39e58SMitchell Horne 66327b39e58SMitchell Horne /* Free DMA descriptors */ 664972adf0fSEmmanuel Vadot dma1000_free(sc); 66527b39e58SMitchell Horne 66627b39e58SMitchell Horne if (sc->ifp != NULL) { 66727b39e58SMitchell Horne if_free(sc->ifp); 66827b39e58SMitchell Horne sc->ifp = NULL; 66927b39e58SMitchell Horne } 67027b39e58SMitchell Horne 67127b39e58SMitchell Horne bus_release_resources(dev, dwc_spec, sc->res); 67227b39e58SMitchell Horne 67327b39e58SMitchell Horne mtx_destroy(&sc->mtx); 67427b39e58SMitchell Horne return (0); 67527b39e58SMitchell Horne } 67627b39e58SMitchell Horne 6775d43fd68SRuslan Bukin static device_method_t dwc_methods[] = { 6785d43fd68SRuslan Bukin DEVMETHOD(device_probe, dwc_probe), 6795d43fd68SRuslan Bukin DEVMETHOD(device_attach, dwc_attach), 68027b39e58SMitchell Horne DEVMETHOD(device_detach, dwc_detach), 6815d43fd68SRuslan Bukin 6825d43fd68SRuslan Bukin /* MII Interface */ 68362519d5aSEmmanuel Vadot DEVMETHOD(miibus_readreg, dwc1000_miibus_read_reg), 68462519d5aSEmmanuel Vadot DEVMETHOD(miibus_writereg, dwc1000_miibus_write_reg), 68562519d5aSEmmanuel Vadot DEVMETHOD(miibus_statchg, dwc1000_miibus_statchg), 6865d43fd68SRuslan Bukin 6875d43fd68SRuslan Bukin { 0, 0 } 6885d43fd68SRuslan Bukin }; 6895d43fd68SRuslan Bukin 6905df53927SLuiz Otavio O Souza driver_t dwc_driver = { 6915d43fd68SRuslan Bukin "dwc", 6925d43fd68SRuslan Bukin dwc_methods, 6935d43fd68SRuslan Bukin sizeof(struct dwc_softc), 6945d43fd68SRuslan Bukin }; 6955d43fd68SRuslan Bukin 696e55d0536SJohn Baldwin DRIVER_MODULE(dwc, simplebus, dwc_driver, 0, 0); 6973e38757dSJohn Baldwin DRIVER_MODULE(miibus, dwc, miibus_driver, 0, 0); 6985d43fd68SRuslan Bukin 6995d43fd68SRuslan Bukin MODULE_DEPEND(dwc, ether, 1, 1, 1); 7005d43fd68SRuslan Bukin MODULE_DEPEND(dwc, miibus, 1, 1, 1); 701