1098ca2bdSWarner Losh /*- 2a07bd003SBill Paul * Copyright (c) 2004 3a07bd003SBill Paul * Bill Paul <wpaul@windriver.com>. All rights reserved. 4a07bd003SBill Paul * 5a07bd003SBill Paul * Redistribution and use in source and binary forms, with or without 6a07bd003SBill Paul * modification, are permitted provided that the following conditions 7a07bd003SBill Paul * are met: 8a07bd003SBill Paul * 1. Redistributions of source code must retain the above copyright 9a07bd003SBill Paul * notice, this list of conditions and the following disclaimer. 10a07bd003SBill Paul * 2. Redistributions in binary form must reproduce the above copyright 11a07bd003SBill Paul * notice, this list of conditions and the following disclaimer in the 12a07bd003SBill Paul * documentation and/or other materials provided with the distribution. 13a07bd003SBill Paul * 3. All advertising materials mentioning features or use of this software 14a07bd003SBill Paul * must display the following acknowledgement: 15a07bd003SBill Paul * This product includes software developed by Bill Paul. 16a07bd003SBill Paul * 4. Neither the name of the author nor the names of any co-contributors 17a07bd003SBill Paul * may be used to endorse or promote products derived from this software 18a07bd003SBill Paul * without specific prior written permission. 19a07bd003SBill Paul * 20a07bd003SBill Paul * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND 21a07bd003SBill Paul * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22a07bd003SBill Paul * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 23a07bd003SBill Paul * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD 24a07bd003SBill Paul * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 25a07bd003SBill Paul * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 26a07bd003SBill Paul * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27a07bd003SBill Paul * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28a07bd003SBill Paul * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29a07bd003SBill Paul * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 30a07bd003SBill Paul * THE POSSIBILITY OF SUCH DAMAGE. 31a07bd003SBill Paul */ 32a07bd003SBill Paul 33a07bd003SBill Paul #include <sys/cdefs.h> 34a07bd003SBill Paul __FBSDID("$FreeBSD$"); 35a07bd003SBill Paul 36a07bd003SBill Paul /* 37324eb733SRafal Jaworowski * Driver for the Cicada/Vitesse CS/VSC8xxx 10/100/1000 copper PHY. 38a07bd003SBill Paul */ 39a07bd003SBill Paul 40a07bd003SBill Paul #include <sys/param.h> 41a07bd003SBill Paul #include <sys/systm.h> 42a07bd003SBill Paul #include <sys/kernel.h> 43a07bd003SBill Paul #include <sys/module.h> 44a07bd003SBill Paul #include <sys/socket.h> 45a07bd003SBill Paul #include <sys/bus.h> 46a07bd003SBill Paul 47a07bd003SBill Paul #include <net/if.h> 48a07bd003SBill Paul #include <net/if_arp.h> 49a07bd003SBill Paul #include <net/if_media.h> 50a07bd003SBill Paul 51a07bd003SBill Paul #include <dev/mii/mii.h> 52a07bd003SBill Paul #include <dev/mii/miivar.h> 53a07bd003SBill Paul #include "miidevs.h" 54a07bd003SBill Paul 55a07bd003SBill Paul #include <dev/mii/ciphyreg.h> 56a07bd003SBill Paul 57a07bd003SBill Paul #include "miibus_if.h" 58a07bd003SBill Paul 59a07bd003SBill Paul #include <machine/bus.h> 60a07bd003SBill Paul /* 61a07bd003SBill Paul #include <dev/vge/if_vgereg.h> 62a07bd003SBill Paul */ 63a07bd003SBill Paul static int ciphy_probe(device_t); 64a07bd003SBill Paul static int ciphy_attach(device_t); 65a07bd003SBill Paul 66a07bd003SBill Paul static device_method_t ciphy_methods[] = { 67a07bd003SBill Paul /* device interface */ 68a07bd003SBill Paul DEVMETHOD(device_probe, ciphy_probe), 69a07bd003SBill Paul DEVMETHOD(device_attach, ciphy_attach), 70a07bd003SBill Paul DEVMETHOD(device_detach, mii_phy_detach), 71a07bd003SBill Paul DEVMETHOD(device_shutdown, bus_generic_shutdown), 72a07bd003SBill Paul { 0, 0 } 73a07bd003SBill Paul }; 74a07bd003SBill Paul 75a07bd003SBill Paul static devclass_t ciphy_devclass; 76a07bd003SBill Paul 77a07bd003SBill Paul static driver_t ciphy_driver = { 78a07bd003SBill Paul "ciphy", 79a07bd003SBill Paul ciphy_methods, 80a07bd003SBill Paul sizeof(struct mii_softc) 81a07bd003SBill Paul }; 82a07bd003SBill Paul 83a07bd003SBill Paul DRIVER_MODULE(ciphy, miibus, ciphy_driver, ciphy_devclass, 0, 0); 84a07bd003SBill Paul 85a07bd003SBill Paul static int ciphy_service(struct mii_softc *, struct mii_data *, int); 86a07bd003SBill Paul static void ciphy_status(struct mii_softc *); 87a07bd003SBill Paul static void ciphy_reset(struct mii_softc *); 88a07bd003SBill Paul static void ciphy_fixup(struct mii_softc *); 89a07bd003SBill Paul 90a35b9333SMarius Strobl static const struct mii_phydesc ciphys[] = { 91a35b9333SMarius Strobl MII_PHY_DESC(CICADA, CS8201), 92a35b9333SMarius Strobl MII_PHY_DESC(CICADA, CS8201A), 93a35b9333SMarius Strobl MII_PHY_DESC(CICADA, CS8201B), 94ff857dc5SRafal Jaworowski MII_PHY_DESC(CICADA, CS8204), 95324eb733SRafal Jaworowski MII_PHY_DESC(CICADA, CS8244), 969f6cc3adSPyun YongHyeon MII_PHY_DESC(VITESSE, VSC8601), 97a35b9333SMarius Strobl MII_PHY_END 98a35b9333SMarius Strobl }; 99a35b9333SMarius Strobl 100a07bd003SBill Paul static int 1017d830ac9SWarner Losh ciphy_probe(device_t dev) 102a07bd003SBill Paul { 103a07bd003SBill Paul 104a35b9333SMarius Strobl return (mii_phy_dev_probe(dev, ciphys, BUS_PROBE_DEFAULT)); 105a07bd003SBill Paul } 106a07bd003SBill Paul 107a07bd003SBill Paul static int 1087d830ac9SWarner Losh ciphy_attach(device_t dev) 109a07bd003SBill Paul { 110a07bd003SBill Paul struct mii_softc *sc; 111a07bd003SBill Paul struct mii_attach_args *ma; 112a07bd003SBill Paul struct mii_data *mii; 113a07bd003SBill Paul 114a07bd003SBill Paul sc = device_get_softc(dev); 115a07bd003SBill Paul ma = device_get_ivars(dev); 116a07bd003SBill Paul sc->mii_dev = device_get_parent(dev); 117a07bd003SBill Paul mii = device_get_softc(sc->mii_dev); 118a07bd003SBill Paul LIST_INSERT_HEAD(&mii->mii_phys, sc, mii_list); 119a07bd003SBill Paul 120a07bd003SBill Paul sc->mii_inst = mii->mii_instance; 121a07bd003SBill Paul sc->mii_phy = ma->mii_phyno; 122a07bd003SBill Paul sc->mii_service = ciphy_service; 123a07bd003SBill Paul sc->mii_pdata = mii; 124a07bd003SBill Paul 125a07bd003SBill Paul sc->mii_flags |= MIIF_NOISOLATE; 126a07bd003SBill Paul mii->mii_instance++; 127a07bd003SBill Paul 128a07bd003SBill Paul ciphy_reset(sc); 129a07bd003SBill Paul 130a07bd003SBill Paul sc->mii_capabilities = 131a07bd003SBill Paul PHY_READ(sc, MII_BMSR) & ma->mii_capmask; 132a07bd003SBill Paul if (sc->mii_capabilities & BMSR_EXTSTAT) 133a07bd003SBill Paul sc->mii_extcapabilities = PHY_READ(sc, MII_EXTSR); 134a07bd003SBill Paul device_printf(dev, " "); 135a07bd003SBill Paul mii_phy_add_media(sc); 136a07bd003SBill Paul printf("\n"); 137a07bd003SBill Paul 138a07bd003SBill Paul MIIBUS_MEDIAINIT(sc->mii_dev); 139a07bd003SBill Paul return (0); 140a07bd003SBill Paul } 141a07bd003SBill Paul 142a07bd003SBill Paul static int 1437d830ac9SWarner Losh ciphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) 144a07bd003SBill Paul { 145a07bd003SBill Paul struct ifmedia_entry *ife = mii->mii_media.ifm_cur; 146a07bd003SBill Paul int reg, speed, gig; 147a07bd003SBill Paul 148a07bd003SBill Paul switch (cmd) { 149a07bd003SBill Paul case MII_POLLSTAT: 150a07bd003SBill Paul /* 151a07bd003SBill Paul * If we're not polling our PHY instance, just return. 152a07bd003SBill Paul */ 153a07bd003SBill Paul if (IFM_INST(ife->ifm_media) != sc->mii_inst) 154a07bd003SBill Paul return (0); 155a07bd003SBill Paul break; 156a07bd003SBill Paul 157a07bd003SBill Paul case MII_MEDIACHG: 158a07bd003SBill Paul /* 159a07bd003SBill Paul * If the media indicates a different PHY instance, 160a07bd003SBill Paul * isolate ourselves. 161a07bd003SBill Paul */ 162a07bd003SBill Paul if (IFM_INST(ife->ifm_media) != sc->mii_inst) { 163a07bd003SBill Paul reg = PHY_READ(sc, MII_BMCR); 164a07bd003SBill Paul PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); 165a07bd003SBill Paul return (0); 166a07bd003SBill Paul } 167a07bd003SBill Paul 168a07bd003SBill Paul /* 169a07bd003SBill Paul * If the interface is not up, don't do anything. 170a07bd003SBill Paul */ 171a07bd003SBill Paul if ((mii->mii_ifp->if_flags & IFF_UP) == 0) 172a07bd003SBill Paul break; 173a07bd003SBill Paul 174a07bd003SBill Paul ciphy_fixup(sc); /* XXX hardware bug work-around */ 175a07bd003SBill Paul 176a07bd003SBill Paul switch (IFM_SUBTYPE(ife->ifm_media)) { 177a07bd003SBill Paul case IFM_AUTO: 178a07bd003SBill Paul #ifdef foo 179a07bd003SBill Paul /* 180a07bd003SBill Paul * If we're already in auto mode, just return. 181a07bd003SBill Paul */ 182a07bd003SBill Paul if (PHY_READ(sc, CIPHY_MII_BMCR) & CIPHY_BMCR_AUTOEN) 183a07bd003SBill Paul return (0); 184a07bd003SBill Paul #endif 185a07bd003SBill Paul (void) mii_phy_auto(sc); 186a07bd003SBill Paul break; 187a07bd003SBill Paul case IFM_1000_T: 188a07bd003SBill Paul speed = CIPHY_S1000; 189a07bd003SBill Paul goto setit; 190a07bd003SBill Paul case IFM_100_TX: 191a07bd003SBill Paul speed = CIPHY_S100; 192a07bd003SBill Paul goto setit; 193a07bd003SBill Paul case IFM_10_T: 194a07bd003SBill Paul speed = CIPHY_S10; 195a07bd003SBill Paul setit: 196a07bd003SBill Paul if ((ife->ifm_media & IFM_GMASK) == IFM_FDX) { 197a07bd003SBill Paul speed |= CIPHY_BMCR_FDX; 198a07bd003SBill Paul gig = CIPHY_1000CTL_AFD; 199a07bd003SBill Paul } else { 200a07bd003SBill Paul gig = CIPHY_1000CTL_AHD; 201a07bd003SBill Paul } 202a07bd003SBill Paul 203a07bd003SBill Paul PHY_WRITE(sc, CIPHY_MII_1000CTL, 0); 204a07bd003SBill Paul PHY_WRITE(sc, CIPHY_MII_BMCR, speed); 205a07bd003SBill Paul PHY_WRITE(sc, CIPHY_MII_ANAR, CIPHY_SEL_TYPE); 206a07bd003SBill Paul 207a07bd003SBill Paul if (IFM_SUBTYPE(ife->ifm_media) != IFM_1000_T) 208a07bd003SBill Paul break; 209a07bd003SBill Paul 210a07bd003SBill Paul PHY_WRITE(sc, CIPHY_MII_1000CTL, gig); 211a07bd003SBill Paul PHY_WRITE(sc, CIPHY_MII_BMCR, 212a07bd003SBill Paul speed|CIPHY_BMCR_AUTOEN|CIPHY_BMCR_STARTNEG); 213a07bd003SBill Paul 214a07bd003SBill Paul /* 215a07bd003SBill Paul * When setting the link manually, one side must 216a07bd003SBill Paul * be the master and the other the slave. However 217a07bd003SBill Paul * ifmedia doesn't give us a good way to specify 218a07bd003SBill Paul * this, so we fake it by using one of the LINK 219a07bd003SBill Paul * flags. If LINK0 is set, we program the PHY to 220a07bd003SBill Paul * be a master, otherwise it's a slave. 221a07bd003SBill Paul */ 222a07bd003SBill Paul if ((mii->mii_ifp->if_flags & IFF_LINK0)) { 223a07bd003SBill Paul PHY_WRITE(sc, CIPHY_MII_1000CTL, 224a07bd003SBill Paul gig|CIPHY_1000CTL_MSE|CIPHY_1000CTL_MSC); 225a07bd003SBill Paul } else { 226a07bd003SBill Paul PHY_WRITE(sc, CIPHY_MII_1000CTL, 227a07bd003SBill Paul gig|CIPHY_1000CTL_MSE); 228a07bd003SBill Paul } 229a07bd003SBill Paul break; 230a07bd003SBill Paul case IFM_NONE: 231a07bd003SBill Paul PHY_WRITE(sc, MII_BMCR, BMCR_ISO|BMCR_PDOWN); 232a07bd003SBill Paul break; 233a07bd003SBill Paul case IFM_100_T4: 234a07bd003SBill Paul default: 235a07bd003SBill Paul return (EINVAL); 236a07bd003SBill Paul } 237a07bd003SBill Paul break; 238a07bd003SBill Paul 239a07bd003SBill Paul case MII_TICK: 240a07bd003SBill Paul /* 241a07bd003SBill Paul * If we're not currently selected, just return. 242a07bd003SBill Paul */ 243a07bd003SBill Paul if (IFM_INST(ife->ifm_media) != sc->mii_inst) 244a07bd003SBill Paul return (0); 245a07bd003SBill Paul 246a07bd003SBill Paul /* 247a07bd003SBill Paul * Is the interface even up? 248a07bd003SBill Paul */ 249a07bd003SBill Paul if ((mii->mii_ifp->if_flags & IFF_UP) == 0) 250a07bd003SBill Paul return (0); 251a07bd003SBill Paul 252a07bd003SBill Paul /* 253a07bd003SBill Paul * Only used for autonegotiation. 254a07bd003SBill Paul */ 255a07bd003SBill Paul if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) 256a07bd003SBill Paul break; 257a07bd003SBill Paul 258a07bd003SBill Paul /* 259a07bd003SBill Paul * Check to see if we have link. If we do, we don't 260a07bd003SBill Paul * need to restart the autonegotiation process. Read 261a07bd003SBill Paul * the BMSR twice in case it's latched. 262a07bd003SBill Paul */ 263a07bd003SBill Paul reg = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR); 264a07bd003SBill Paul if (reg & BMSR_LINK) 265a07bd003SBill Paul break; 266a07bd003SBill Paul 267138b38ffSPyun YongHyeon /* Announce link loss right after it happens. */ 268138b38ffSPyun YongHyeon if (++sc->mii_ticks == 0) 269138b38ffSPyun YongHyeon break; 270a07bd003SBill Paul /* 271eb10e723SPyun YongHyeon * Only retry autonegotiation every mii_anegticks seconds. 272a07bd003SBill Paul */ 273eb10e723SPyun YongHyeon if (sc->mii_ticks <= sc->mii_anegticks) 274a07bd003SBill Paul break; 275a07bd003SBill Paul 276a07bd003SBill Paul sc->mii_ticks = 0; 277a07bd003SBill Paul mii_phy_auto(sc); 278a07bd003SBill Paul return (0); 279a07bd003SBill Paul } 280a07bd003SBill Paul 281a07bd003SBill Paul /* Update the media status. */ 282a07bd003SBill Paul ciphy_status(sc); 283a07bd003SBill Paul 284a07bd003SBill Paul /* 285a07bd003SBill Paul * Callback if something changed. Note that we need to poke 286a07bd003SBill Paul * apply fixups for certain PHY revs. 287a07bd003SBill Paul */ 288a07bd003SBill Paul if (sc->mii_media_active != mii->mii_media_active || 289a07bd003SBill Paul sc->mii_media_status != mii->mii_media_status || 290a07bd003SBill Paul cmd == MII_MEDIACHG) { 291a07bd003SBill Paul ciphy_fixup(sc); 292a07bd003SBill Paul } 293a07bd003SBill Paul mii_phy_update(sc, cmd); 294a07bd003SBill Paul return (0); 295a07bd003SBill Paul } 296a07bd003SBill Paul 297a07bd003SBill Paul static void 2987d830ac9SWarner Losh ciphy_status(struct mii_softc *sc) 299a07bd003SBill Paul { 300a07bd003SBill Paul struct mii_data *mii = sc->mii_pdata; 301a07bd003SBill Paul int bmsr, bmcr; 302a07bd003SBill Paul 303a07bd003SBill Paul mii->mii_media_status = IFM_AVALID; 304a07bd003SBill Paul mii->mii_media_active = IFM_ETHER; 305a07bd003SBill Paul 306a07bd003SBill Paul bmsr = PHY_READ(sc, MII_BMSR) | PHY_READ(sc, MII_BMSR); 307a07bd003SBill Paul 308a07bd003SBill Paul if (bmsr & BMSR_LINK) 309a07bd003SBill Paul mii->mii_media_status |= IFM_ACTIVE; 310a07bd003SBill Paul 311a07bd003SBill Paul bmcr = PHY_READ(sc, CIPHY_MII_BMCR); 312a07bd003SBill Paul 313a07bd003SBill Paul if (bmcr & CIPHY_BMCR_LOOP) 314a07bd003SBill Paul mii->mii_media_active |= IFM_LOOP; 315a07bd003SBill Paul 316a07bd003SBill Paul if (bmcr & CIPHY_BMCR_AUTOEN) { 317a07bd003SBill Paul if ((bmsr & CIPHY_BMSR_ACOMP) == 0) { 318a07bd003SBill Paul /* Erg, still trying, I guess... */ 319a07bd003SBill Paul mii->mii_media_active |= IFM_NONE; 320a07bd003SBill Paul return; 321a07bd003SBill Paul } 322a07bd003SBill Paul } 323a07bd003SBill Paul 324a07bd003SBill Paul bmsr = PHY_READ(sc, CIPHY_MII_AUXCSR); 325a07bd003SBill Paul switch (bmsr & CIPHY_AUXCSR_SPEED) { 326a07bd003SBill Paul case CIPHY_SPEED10: 327a07bd003SBill Paul mii->mii_media_active |= IFM_10_T; 328a07bd003SBill Paul break; 329a07bd003SBill Paul case CIPHY_SPEED100: 330a07bd003SBill Paul mii->mii_media_active |= IFM_100_TX; 331a07bd003SBill Paul break; 332a07bd003SBill Paul case CIPHY_SPEED1000: 333a07bd003SBill Paul mii->mii_media_active |= IFM_1000_T; 334a07bd003SBill Paul break; 335a07bd003SBill Paul default: 336a07bd003SBill Paul device_printf(sc->mii_dev, "unknown PHY speed %x\n", 337a07bd003SBill Paul bmsr & CIPHY_AUXCSR_SPEED); 338a07bd003SBill Paul break; 339a07bd003SBill Paul } 340a07bd003SBill Paul 341a07bd003SBill Paul if (bmsr & CIPHY_AUXCSR_FDX) 342a07bd003SBill Paul mii->mii_media_active |= IFM_FDX; 343a07bd003SBill Paul } 344a07bd003SBill Paul 345a07bd003SBill Paul static void 346a07bd003SBill Paul ciphy_reset(struct mii_softc *sc) 347a07bd003SBill Paul { 348028ccec4SMarius Strobl 349a07bd003SBill Paul mii_phy_reset(sc); 350a07bd003SBill Paul DELAY(1000); 351a07bd003SBill Paul } 352a07bd003SBill Paul 353a07bd003SBill Paul #define PHY_SETBIT(x, y, z) \ 354a07bd003SBill Paul PHY_WRITE(x, y, (PHY_READ(x, y) | (z))) 355a07bd003SBill Paul #define PHY_CLRBIT(x, y, z) \ 356a07bd003SBill Paul PHY_WRITE(x, y, (PHY_READ(x, y) & ~(z))) 357a07bd003SBill Paul 358a07bd003SBill Paul static void 359a07bd003SBill Paul ciphy_fixup(struct mii_softc *sc) 360a07bd003SBill Paul { 361a07bd003SBill Paul uint16_t model; 362a07bd003SBill Paul uint16_t status, speed; 3639f6cc3adSPyun YongHyeon uint16_t val; 364a07bd003SBill Paul 365a07bd003SBill Paul model = MII_MODEL(PHY_READ(sc, CIPHY_MII_PHYIDR2)); 366a07bd003SBill Paul status = PHY_READ(sc, CIPHY_MII_AUXCSR); 367a07bd003SBill Paul speed = status & CIPHY_AUXCSR_SPEED; 368a07bd003SBill Paul 3699f6cc3adSPyun YongHyeon if (strcmp(device_get_name(device_get_parent(sc->mii_dev)), 3709f6cc3adSPyun YongHyeon "nfe") == 0) { 3719f6cc3adSPyun YongHyeon /* need to set for 2.5V RGMII for NVIDIA adapters */ 3729f6cc3adSPyun YongHyeon val = PHY_READ(sc, CIPHY_MII_ECTL1); 3739f6cc3adSPyun YongHyeon val &= ~(CIPHY_ECTL1_IOVOL | CIPHY_ECTL1_INTSEL); 3749f6cc3adSPyun YongHyeon val |= (CIPHY_IOVOL_2500MV | CIPHY_INTSEL_RGMII); 3759f6cc3adSPyun YongHyeon PHY_WRITE(sc, CIPHY_MII_ECTL1, val); 3769f6cc3adSPyun YongHyeon /* From Linux. */ 3779f6cc3adSPyun YongHyeon val = PHY_READ(sc, CIPHY_MII_AUXCSR); 3789f6cc3adSPyun YongHyeon val |= CIPHY_AUXCSR_MDPPS; 3799f6cc3adSPyun YongHyeon PHY_WRITE(sc, CIPHY_MII_AUXCSR, val); 3809f6cc3adSPyun YongHyeon val = PHY_READ(sc, CIPHY_MII_10BTCSR); 3819f6cc3adSPyun YongHyeon val |= CIPHY_10BTCSR_ECHO; 3829f6cc3adSPyun YongHyeon PHY_WRITE(sc, CIPHY_MII_10BTCSR, val); 3839f6cc3adSPyun YongHyeon } 3849f6cc3adSPyun YongHyeon 385a07bd003SBill Paul switch (model) { 386ff857dc5SRafal Jaworowski case MII_MODEL_CICADA_CS8204: 387a07bd003SBill Paul case MII_MODEL_CICADA_CS8201: 388a07bd003SBill Paul 389a07bd003SBill Paul /* Turn off "aux mode" (whatever that means) */ 390a07bd003SBill Paul PHY_SETBIT(sc, CIPHY_MII_AUXCSR, CIPHY_AUXCSR_MDPPS); 391a07bd003SBill Paul 392a07bd003SBill Paul /* 393a07bd003SBill Paul * Work around speed polling bug in VT3119/VT3216 394a07bd003SBill Paul * when using MII in full duplex mode. 395a07bd003SBill Paul */ 396a07bd003SBill Paul if ((speed == CIPHY_SPEED10 || speed == CIPHY_SPEED100) && 397a07bd003SBill Paul (status & CIPHY_AUXCSR_FDX)) { 398a07bd003SBill Paul PHY_SETBIT(sc, CIPHY_MII_10BTCSR, CIPHY_10BTCSR_ECHO); 399a07bd003SBill Paul } else { 400a07bd003SBill Paul PHY_CLRBIT(sc, CIPHY_MII_10BTCSR, CIPHY_10BTCSR_ECHO); 401a07bd003SBill Paul } 402a07bd003SBill Paul 403a07bd003SBill Paul /* Enable link/activity LED blink. */ 404a07bd003SBill Paul PHY_SETBIT(sc, CIPHY_MII_LED, CIPHY_LED_LINKACTBLINK); 405a07bd003SBill Paul 406a07bd003SBill Paul break; 407a07bd003SBill Paul 408a07bd003SBill Paul case MII_MODEL_CICADA_CS8201A: 409a07bd003SBill Paul case MII_MODEL_CICADA_CS8201B: 410a07bd003SBill Paul 411a07bd003SBill Paul /* 412a07bd003SBill Paul * Work around speed polling bug in VT3119/VT3216 413a07bd003SBill Paul * when using MII in full duplex mode. 414a07bd003SBill Paul */ 415a07bd003SBill Paul if ((speed == CIPHY_SPEED10 || speed == CIPHY_SPEED100) && 416a07bd003SBill Paul (status & CIPHY_AUXCSR_FDX)) { 417a07bd003SBill Paul PHY_SETBIT(sc, CIPHY_MII_10BTCSR, CIPHY_10BTCSR_ECHO); 418a07bd003SBill Paul } else { 419a07bd003SBill Paul PHY_CLRBIT(sc, CIPHY_MII_10BTCSR, CIPHY_10BTCSR_ECHO); 420a07bd003SBill Paul } 421a07bd003SBill Paul 422a07bd003SBill Paul break; 423324eb733SRafal Jaworowski case MII_MODEL_CICADA_CS8244: 4249f6cc3adSPyun YongHyeon case MII_MODEL_VITESSE_VSC8601: 4259f6cc3adSPyun YongHyeon break; 426a07bd003SBill Paul default: 427a07bd003SBill Paul device_printf(sc->mii_dev, "unknown CICADA PHY model %x\n", 428a07bd003SBill Paul model); 429a07bd003SBill Paul break; 430a07bd003SBill Paul } 431a07bd003SBill Paul } 432