1 /*- 2 * Copyright (c) 2016 Stanislav Galabov. 3 * Copyright (c) 2011-2012 Stefan Bethke. 4 * Copyright (c) 2012 Adrian Chadd. 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 * SUCH DAMAGE. 27 * 28 * $FreeBSD$ 29 */ 30 31 #include <sys/param.h> 32 #include <sys/bus.h> 33 #include <sys/errno.h> 34 #include <sys/kernel.h> 35 #include <sys/lock.h> 36 #include <sys/malloc.h> 37 #include <sys/module.h> 38 #include <sys/mutex.h> 39 #include <sys/socket.h> 40 #include <sys/sockio.h> 41 #include <sys/sysctl.h> 42 #include <sys/systm.h> 43 44 #include <net/if.h> 45 #include <net/if_var.h> 46 #include <net/ethernet.h> 47 #include <net/if_media.h> 48 #include <net/if_types.h> 49 50 #include <machine/bus.h> 51 #include <dev/mii/mii.h> 52 #include <dev/mii/miivar.h> 53 #include <dev/mdio/mdio.h> 54 55 #include <dev/etherswitch/etherswitch.h> 56 #include <dev/etherswitch/mtkswitch/mtkswitchvar.h> 57 58 #include <dev/ofw/ofw_bus_subr.h> 59 60 #include "mdio_if.h" 61 #include "miibus_if.h" 62 #include "etherswitch_if.h" 63 64 #define DEBUG 65 66 #if defined(DEBUG) 67 static SYSCTL_NODE(_debug, OID_AUTO, mtkswitch, CTLFLAG_RD, 0, "mtkswitch"); 68 #endif 69 70 static inline int mtkswitch_portforphy(int phy); 71 static int mtkswitch_ifmedia_upd(struct ifnet *ifp); 72 static void mtkswitch_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr); 73 static void mtkswitch_tick(void *arg); 74 75 static const struct ofw_compat_data compat_data[] = { 76 { "ralink,rt3050-esw", MTK_SWITCH_RT3050 }, 77 { "ralink,rt3352-esw", MTK_SWITCH_RT3352 }, 78 { "ralink,rt5350-esw", MTK_SWITCH_RT5350 }, 79 { "mediatek,mt7620-gsw", MTK_SWITCH_MT7620 }, 80 { "mediatek,mt7621-gsw", MTK_SWITCH_MT7621 }, 81 { "mediatek,mt7628-esw", MTK_SWITCH_MT7628 }, 82 83 /* Sentinel */ 84 { NULL, MTK_SWITCH_NONE } 85 }; 86 87 static int 88 mtkswitch_probe(device_t dev) 89 { 90 struct mtkswitch_softc *sc; 91 mtk_switch_type switch_type; 92 93 if (!ofw_bus_status_okay(dev)) 94 return (ENXIO); 95 96 switch_type = ofw_bus_search_compatible(dev, compat_data)->ocd_data; 97 if (switch_type == MTK_SWITCH_NONE) 98 return (ENXIO); 99 100 sc = device_get_softc(dev); 101 bzero(sc, sizeof(*sc)); 102 sc->sc_switchtype = switch_type; 103 104 device_set_desc_copy(dev, "MTK Switch Driver"); 105 106 return (0); 107 } 108 109 static int 110 mtkswitch_attach_phys(struct mtkswitch_softc *sc) 111 { 112 int phy, err = 0; 113 char name[IFNAMSIZ]; 114 115 /* PHYs need an interface, so we generate a dummy one */ 116 snprintf(name, IFNAMSIZ, "%sport", device_get_nameunit(sc->sc_dev)); 117 for (phy = 0; phy < sc->numphys; phy++) { 118 if ((sc->phymap & (1u << phy)) == 0) { 119 sc->ifp[phy] = NULL; 120 sc->ifname[phy] = NULL; 121 sc->miibus[phy] = NULL; 122 continue; 123 } 124 sc->ifp[phy] = if_alloc(IFT_ETHER); 125 sc->ifp[phy]->if_softc = sc; 126 sc->ifp[phy]->if_flags |= IFF_UP | IFF_BROADCAST | 127 IFF_DRV_RUNNING | IFF_SIMPLEX; 128 sc->ifname[phy] = malloc(strlen(name) + 1, M_DEVBUF, M_WAITOK); 129 bcopy(name, sc->ifname[phy], strlen(name) + 1); 130 if_initname(sc->ifp[phy], sc->ifname[phy], 131 mtkswitch_portforphy(phy)); 132 err = mii_attach(sc->sc_dev, &sc->miibus[phy], sc->ifp[phy], 133 mtkswitch_ifmedia_upd, mtkswitch_ifmedia_sts, 134 BMSR_DEFCAPMASK, phy, MII_OFFSET_ANY, 0); 135 if (err != 0) { 136 device_printf(sc->sc_dev, 137 "attaching PHY %d failed\n", 138 phy); 139 } else { 140 DPRINTF(sc->sc_dev, "%s attached to pseudo interface " 141 "%s\n", device_get_nameunit(sc->miibus[phy]), 142 sc->ifp[phy]->if_xname); 143 } 144 } 145 return (err); 146 } 147 148 static int 149 mtkswitch_set_vlan_mode(struct mtkswitch_softc *sc, uint32_t mode) 150 { 151 152 /* Check for invalid modes. */ 153 if ((mode & sc->info.es_vlan_caps) != mode) 154 return (EINVAL); 155 156 sc->vlan_mode = mode; 157 158 /* Reset VLANs. */ 159 sc->hal.mtkswitch_vlan_init_hw(sc); 160 161 return (0); 162 } 163 164 static int 165 mtkswitch_attach(device_t dev) 166 { 167 struct mtkswitch_softc *sc; 168 int err = 0; 169 int port, rid; 170 171 sc = device_get_softc(dev); 172 173 /* sc->sc_switchtype is already decided in mtkswitch_probe() */ 174 sc->numports = MTKSWITCH_MAX_PORTS; 175 sc->numphys = MTKSWITCH_MAX_PHYS; 176 sc->cpuport = MTKSWITCH_CPU_PORT; 177 sc->sc_dev = dev; 178 179 /* Attach switch related functions */ 180 if (sc->sc_switchtype == MTK_SWITCH_NONE) { 181 device_printf(dev, "Unknown switch type\n"); 182 return (ENXIO); 183 } 184 185 if (sc->sc_switchtype == MTK_SWITCH_MT7620 || 186 sc->sc_switchtype == MTK_SWITCH_MT7621) 187 mtk_attach_switch_mt7620(sc); 188 else 189 mtk_attach_switch_rt3050(sc); 190 191 /* Allocate resources */ 192 rid = 0; 193 sc->sc_res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, 194 RF_ACTIVE); 195 if (sc->sc_res == NULL) { 196 device_printf(dev, "could not map memory\n"); 197 return (ENXIO); 198 } 199 200 mtx_init(&sc->sc_mtx, "mtkswitch", NULL, MTX_DEF); 201 202 /* Reset the switch */ 203 if (sc->hal.mtkswitch_reset(sc)) { 204 DPRINTF(dev, "%s: mtkswitch_reset: failed\n", __func__); 205 return (ENXIO); 206 } 207 208 err = sc->hal.mtkswitch_hw_setup(sc); 209 DPRINTF(dev, "%s: hw_setup: err=%d\n", __func__, err); 210 if (err != 0) 211 return (err); 212 213 err = sc->hal.mtkswitch_hw_global_setup(sc); 214 DPRINTF(dev, "%s: hw_global_setup: err=%d\n", __func__, err); 215 if (err != 0) 216 return (err); 217 218 /* Initialize the switch ports */ 219 for (port = 0; port < sc->numports; port++) { 220 sc->hal.mtkswitch_port_init(sc, port); 221 } 222 223 /* Attach the PHYs and complete the bus enumeration */ 224 err = mtkswitch_attach_phys(sc); 225 DPRINTF(dev, "%s: attach_phys: err=%d\n", __func__, err); 226 if (err != 0) 227 return (err); 228 229 /* Default to ingress filters off. */ 230 err = mtkswitch_set_vlan_mode(sc, ETHERSWITCH_VLAN_DOT1Q); 231 DPRINTF(dev, "%s: set_vlan_mode: err=%d\n", __func__, err); 232 if (err != 0) 233 return (err); 234 235 bus_generic_probe(dev); 236 bus_enumerate_hinted_children(dev); 237 err = bus_generic_attach(dev); 238 DPRINTF(dev, "%s: bus_generic_attach: err=%d\n", __func__, err); 239 if (err != 0) 240 return (err); 241 242 callout_init_mtx(&sc->callout_tick, &sc->sc_mtx, 0); 243 244 MTKSWITCH_LOCK(sc); 245 mtkswitch_tick(sc); 246 MTKSWITCH_UNLOCK(sc); 247 248 return (0); 249 } 250 251 static int 252 mtkswitch_detach(device_t dev) 253 { 254 struct mtkswitch_softc *sc = device_get_softc(dev); 255 int phy; 256 257 callout_drain(&sc->callout_tick); 258 259 for (phy = 0; phy < MTKSWITCH_MAX_PHYS; phy++) { 260 if (sc->miibus[phy] != NULL) 261 device_delete_child(dev, sc->miibus[phy]); 262 if (sc->ifp[phy] != NULL) 263 if_free(sc->ifp[phy]); 264 free(sc->ifname[phy], M_DEVBUF); 265 } 266 267 bus_generic_detach(dev); 268 mtx_destroy(&sc->sc_mtx); 269 270 return (0); 271 } 272 273 /* PHY <-> port mapping is currently 1:1 */ 274 static inline int 275 mtkswitch_portforphy(int phy) 276 { 277 278 return (phy); 279 } 280 281 static inline int 282 mtkswitch_phyforport(int port) 283 { 284 285 return (port); 286 } 287 288 static inline struct mii_data * 289 mtkswitch_miiforport(struct mtkswitch_softc *sc, int port) 290 { 291 int phy = mtkswitch_phyforport(port); 292 293 if (phy < 0 || phy >= MTKSWITCH_MAX_PHYS || sc->miibus[phy] == NULL) 294 return (NULL); 295 296 return (device_get_softc(sc->miibus[phy])); 297 } 298 299 static inline struct ifnet * 300 mtkswitch_ifpforport(struct mtkswitch_softc *sc, int port) 301 { 302 int phy = mtkswitch_phyforport(port); 303 304 if (phy < 0 || phy >= MTKSWITCH_MAX_PHYS) 305 return (NULL); 306 307 return (sc->ifp[phy]); 308 } 309 310 /* 311 * Convert port status to ifmedia. 312 */ 313 static void 314 mtkswitch_update_ifmedia(uint32_t portstatus, u_int *media_status, 315 u_int *media_active) 316 { 317 *media_active = IFM_ETHER; 318 *media_status = IFM_AVALID; 319 320 if ((portstatus & MTKSWITCH_LINK_UP) != 0) 321 *media_status |= IFM_ACTIVE; 322 else { 323 *media_active |= IFM_NONE; 324 return; 325 } 326 327 switch (portstatus & MTKSWITCH_SPEED_MASK) { 328 case MTKSWITCH_SPEED_10: 329 *media_active |= IFM_10_T; 330 break; 331 case MTKSWITCH_SPEED_100: 332 *media_active |= IFM_100_TX; 333 break; 334 case MTKSWITCH_SPEED_1000: 335 *media_active |= IFM_1000_T; 336 break; 337 } 338 339 if ((portstatus & MTKSWITCH_DUPLEX) != 0) 340 *media_active |= IFM_FDX; 341 else 342 *media_active |= IFM_HDX; 343 344 if ((portstatus & MTKSWITCH_TXFLOW) != 0) 345 *media_active |= IFM_ETH_TXPAUSE; 346 if ((portstatus & MTKSWITCH_RXFLOW) != 0) 347 *media_active |= IFM_ETH_RXPAUSE; 348 } 349 350 static void 351 mtkswitch_miipollstat(struct mtkswitch_softc *sc) 352 { 353 struct mii_data *mii; 354 struct mii_softc *miisc; 355 uint32_t portstatus; 356 int i, port_flap = 0; 357 358 MTKSWITCH_LOCK_ASSERT(sc, MA_OWNED); 359 360 for (i = 0; i < sc->numphys; i++) { 361 if (sc->miibus[i] == NULL) 362 continue; 363 mii = device_get_softc(sc->miibus[i]); 364 portstatus = sc->hal.mtkswitch_get_port_status(sc, 365 mtkswitch_portforphy(i)); 366 367 /* If a port has flapped - mark it so we can flush the ATU */ 368 if (((mii->mii_media_status & IFM_ACTIVE) == 0 && 369 (portstatus & MTKSWITCH_LINK_UP) != 0) || 370 ((mii->mii_media_status & IFM_ACTIVE) != 0 && 371 (portstatus & MTKSWITCH_LINK_UP) == 0)) { 372 port_flap = 1; 373 } 374 375 mtkswitch_update_ifmedia(portstatus, &mii->mii_media_status, 376 &mii->mii_media_active); 377 LIST_FOREACH(miisc, &mii->mii_phys, mii_list) { 378 if (IFM_INST(mii->mii_media.ifm_cur->ifm_media) != 379 miisc->mii_inst) 380 continue; 381 mii_phy_update(miisc, MII_POLLSTAT); 382 } 383 } 384 385 if (port_flap) 386 sc->hal.mtkswitch_atu_flush(sc); 387 } 388 389 static void 390 mtkswitch_tick(void *arg) 391 { 392 struct mtkswitch_softc *sc = arg; 393 394 mtkswitch_miipollstat(sc); 395 callout_reset(&sc->callout_tick, hz, mtkswitch_tick, sc); 396 } 397 398 static void 399 mtkswitch_lock(device_t dev) 400 { 401 struct mtkswitch_softc *sc = device_get_softc(dev); 402 403 MTKSWITCH_LOCK_ASSERT(sc, MA_NOTOWNED); 404 MTKSWITCH_LOCK(sc); 405 } 406 407 static void 408 mtkswitch_unlock(device_t dev) 409 { 410 struct mtkswitch_softc *sc = device_get_softc(dev); 411 412 MTKSWITCH_LOCK_ASSERT(sc, MA_OWNED); 413 MTKSWITCH_UNLOCK(sc); 414 } 415 416 static etherswitch_info_t * 417 mtkswitch_getinfo(device_t dev) 418 { 419 struct mtkswitch_softc *sc = device_get_softc(dev); 420 421 return (&sc->info); 422 } 423 424 static inline int 425 mtkswitch_is_cpuport(struct mtkswitch_softc *sc, int port) 426 { 427 428 return (sc->cpuport == port); 429 } 430 431 static int 432 mtkswitch_getport(device_t dev, etherswitch_port_t *p) 433 { 434 struct mtkswitch_softc *sc; 435 struct mii_data *mii; 436 struct ifmediareq *ifmr; 437 int err; 438 439 sc = device_get_softc(dev); 440 if (p->es_port < 0 || p->es_port > sc->info.es_nports) 441 return (ENXIO); 442 443 err = sc->hal.mtkswitch_port_vlan_get(sc, p); 444 if (err != 0) 445 return (err); 446 447 mii = mtkswitch_miiforport(sc, p->es_port); 448 if (mtkswitch_is_cpuport(sc, p->es_port)) { 449 /* fill in fixed values for CPU port */ 450 /* XXX is this valid in all cases? */ 451 p->es_flags |= ETHERSWITCH_PORT_CPU; 452 ifmr = &p->es_ifmr; 453 ifmr->ifm_count = 0; 454 ifmr->ifm_current = ifmr->ifm_active = 455 IFM_ETHER | IFM_1000_T | IFM_FDX; 456 ifmr->ifm_mask = 0; 457 ifmr->ifm_status = IFM_ACTIVE | IFM_AVALID; 458 } else if (mii != NULL) { 459 err = ifmedia_ioctl(mii->mii_ifp, &p->es_ifr, 460 &mii->mii_media, SIOCGIFMEDIA); 461 if (err) 462 return (err); 463 } else { 464 ifmr = &p->es_ifmr; 465 ifmr->ifm_count = 0; 466 ifmr->ifm_current = ifmr->ifm_active = IFM_NONE; 467 ifmr->ifm_mask = 0; 468 ifmr->ifm_status = 0; 469 } 470 return (0); 471 } 472 473 static int 474 mtkswitch_setport(device_t dev, etherswitch_port_t *p) 475 { 476 int err; 477 struct mtkswitch_softc *sc; 478 struct ifmedia *ifm; 479 struct mii_data *mii; 480 struct ifnet *ifp; 481 482 sc = device_get_softc(dev); 483 if (p->es_port < 0 || p->es_port > sc->info.es_nports) 484 return (ENXIO); 485 486 /* Port flags. */ 487 if (sc->vlan_mode == ETHERSWITCH_VLAN_DOT1Q) { 488 err = sc->hal.mtkswitch_port_vlan_setup(sc, p); 489 if (err) 490 return (err); 491 } 492 493 /* Do not allow media changes on CPU port. */ 494 if (mtkswitch_is_cpuport(sc, p->es_port)) 495 return (0); 496 497 mii = mtkswitch_miiforport(sc, p->es_port); 498 if (mii == NULL) 499 return (ENXIO); 500 501 ifp = mtkswitch_ifpforport(sc, p->es_port); 502 503 ifm = &mii->mii_media; 504 return (ifmedia_ioctl(ifp, &p->es_ifr, ifm, SIOCSIFMEDIA)); 505 } 506 507 static void 508 mtkswitch_statchg(device_t dev) 509 { 510 511 DPRINTF(dev, "%s\n", __func__); 512 } 513 514 static int 515 mtkswitch_ifmedia_upd(struct ifnet *ifp) 516 { 517 struct mtkswitch_softc *sc = ifp->if_softc; 518 struct mii_data *mii = mtkswitch_miiforport(sc, ifp->if_dunit); 519 520 if (mii == NULL) 521 return (ENXIO); 522 mii_mediachg(mii); 523 return (0); 524 } 525 526 static void 527 mtkswitch_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) 528 { 529 struct mtkswitch_softc *sc = ifp->if_softc; 530 struct mii_data *mii = mtkswitch_miiforport(sc, ifp->if_dunit); 531 532 DPRINTF(sc->sc_dev, "%s\n", __func__); 533 534 if (mii == NULL) 535 return; 536 mii_pollstat(mii); 537 ifmr->ifm_active = mii->mii_media_active; 538 ifmr->ifm_status = mii->mii_media_status; 539 } 540 541 static int 542 mtkswitch_getconf(device_t dev, etherswitch_conf_t *conf) 543 { 544 struct mtkswitch_softc *sc; 545 546 sc = device_get_softc(dev); 547 548 /* Return the VLAN mode. */ 549 conf->cmd = ETHERSWITCH_CONF_VLAN_MODE; 550 conf->vlan_mode = sc->vlan_mode; 551 552 return (0); 553 } 554 555 static int 556 mtkswitch_setconf(device_t dev, etherswitch_conf_t *conf) 557 { 558 struct mtkswitch_softc *sc; 559 int err; 560 561 sc = device_get_softc(dev); 562 563 /* Set the VLAN mode. */ 564 if (conf->cmd & ETHERSWITCH_CONF_VLAN_MODE) { 565 err = mtkswitch_set_vlan_mode(sc, conf->vlan_mode); 566 if (err != 0) 567 return (err); 568 } 569 570 return (0); 571 } 572 573 static int 574 mtkswitch_getvgroup(device_t dev, etherswitch_vlangroup_t *e) 575 { 576 struct mtkswitch_softc *sc = device_get_softc(dev); 577 578 return (sc->hal.mtkswitch_vlan_getvgroup(sc, e)); 579 } 580 581 static int 582 mtkswitch_setvgroup(device_t dev, etherswitch_vlangroup_t *e) 583 { 584 struct mtkswitch_softc *sc = device_get_softc(dev); 585 586 return (sc->hal.mtkswitch_vlan_setvgroup(sc, e)); 587 } 588 589 static int 590 mtkswitch_readphy(device_t dev, int phy, int reg) 591 { 592 struct mtkswitch_softc *sc = device_get_softc(dev); 593 594 return (sc->hal.mtkswitch_phy_read(dev, phy, reg)); 595 } 596 597 static int 598 mtkswitch_writephy(device_t dev, int phy, int reg, int val) 599 { 600 struct mtkswitch_softc *sc = device_get_softc(dev); 601 602 return (sc->hal.mtkswitch_phy_write(dev, phy, reg, val)); 603 } 604 605 static int 606 mtkswitch_readreg(device_t dev, int addr) 607 { 608 struct mtkswitch_softc *sc = device_get_softc(dev); 609 610 return (sc->hal.mtkswitch_reg_read(dev, addr)); 611 } 612 613 static int 614 mtkswitch_writereg(device_t dev, int addr, int value) 615 { 616 struct mtkswitch_softc *sc = device_get_softc(dev); 617 618 return (sc->hal.mtkswitch_reg_write(dev, addr, value)); 619 } 620 621 static device_method_t mtkswitch_methods[] = { 622 /* Device interface */ 623 DEVMETHOD(device_probe, mtkswitch_probe), 624 DEVMETHOD(device_attach, mtkswitch_attach), 625 DEVMETHOD(device_detach, mtkswitch_detach), 626 627 /* bus interface */ 628 DEVMETHOD(bus_add_child, device_add_child_ordered), 629 630 /* MII interface */ 631 DEVMETHOD(miibus_readreg, mtkswitch_readphy), 632 DEVMETHOD(miibus_writereg, mtkswitch_writephy), 633 DEVMETHOD(miibus_statchg, mtkswitch_statchg), 634 635 /* MDIO interface */ 636 DEVMETHOD(mdio_readreg, mtkswitch_readphy), 637 DEVMETHOD(mdio_writereg, mtkswitch_writephy), 638 639 /* ehterswitch interface */ 640 DEVMETHOD(etherswitch_lock, mtkswitch_lock), 641 DEVMETHOD(etherswitch_unlock, mtkswitch_unlock), 642 DEVMETHOD(etherswitch_getinfo, mtkswitch_getinfo), 643 DEVMETHOD(etherswitch_readreg, mtkswitch_readreg), 644 DEVMETHOD(etherswitch_writereg, mtkswitch_writereg), 645 DEVMETHOD(etherswitch_readphyreg, mtkswitch_readphy), 646 DEVMETHOD(etherswitch_writephyreg, mtkswitch_writephy), 647 DEVMETHOD(etherswitch_getport, mtkswitch_getport), 648 DEVMETHOD(etherswitch_setport, mtkswitch_setport), 649 DEVMETHOD(etherswitch_getvgroup, mtkswitch_getvgroup), 650 DEVMETHOD(etherswitch_setvgroup, mtkswitch_setvgroup), 651 DEVMETHOD(etherswitch_getconf, mtkswitch_getconf), 652 DEVMETHOD(etherswitch_setconf, mtkswitch_setconf), 653 654 DEVMETHOD_END 655 }; 656 657 DEFINE_CLASS_0(mtkswitch, mtkswitch_driver, mtkswitch_methods, 658 sizeof(struct mtkswitch_softc)); 659 static devclass_t mtkswitch_devclass; 660 661 DRIVER_MODULE(mtkswitch, simplebus, mtkswitch_driver, mtkswitch_devclass, 0, 0); 662 DRIVER_MODULE(miibus, mtkswitch, miibus_driver, miibus_devclass, 0, 0); 663 DRIVER_MODULE(mdio, mtkswitch, mdio_driver, mdio_devclass, 0, 0); 664 DRIVER_MODULE(etherswitch, mtkswitch, etherswitch_driver, etherswitch_devclass, 665 0, 0); 666 MODULE_VERSION(mtkswitch, 1); 667 MODULE_DEPEND(mtkswitch, miibus, 1, 1, 1); 668 MODULE_DEPEND(mtkswitch, etherswitch, 1, 1, 1); 669