txphy.c (5f832cef) | txphy.c (5d6e3d42) |
---|---|
1/* $OpenBSD: txphy.c,v 1.1 1999/12/10 21:48:20 jason Exp $ */ | 1/* $OpenBSD: txphy.c,v 1.2 2000/08/26 20:04:18 nate Exp $ */ |
2 3/* 4 * Copyright (c) 1999 Jason L. Wright (jason@thought.net) 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: --- 39 unchanged lines hidden (view full) --- 49#include <dev/mii/mii.h> 50#include <dev/mii/miivar.h> 51#include <dev/mii/miidevs.h> 52 53int txphymatch __P((struct device *, void *, void *)); 54void txphyattach __P((struct device *, struct device *, void *)); 55 56struct cfattach txphy_ca = { | 2 3/* 4 * Copyright (c) 1999 Jason L. Wright (jason@thought.net) 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: --- 39 unchanged lines hidden (view full) --- 49#include <dev/mii/mii.h> 50#include <dev/mii/miivar.h> 51#include <dev/mii/miidevs.h> 52 53int txphymatch __P((struct device *, void *, void *)); 54void txphyattach __P((struct device *, struct device *, void *)); 55 56struct cfattach txphy_ca = { |
57 sizeof(struct mii_softc), txphymatch, txphyattach | 57 sizeof(struct mii_softc), txphymatch, txphyattach, mii_phy_detach, 58 mii_phy_activate |
58}; 59 60struct cfdriver txphy_cd = { 61 NULL, "txphy", DV_DULL 62}; 63 64int txphy_service __P((struct mii_softc *, struct mii_data *, int)); 65 --- 21 unchanged lines hidden (view full) --- 87 struct mii_data *mii = ma->mii_data; 88 89 printf(": %s, rev. %d\n", MII_STR_xxTI_TNETE2101, 90 MII_REV(ma->mii_id2)); 91 92 sc->mii_inst = mii->mii_instance; 93 sc->mii_phy = ma->mii_phyno; 94 sc->mii_service = txphy_service; | 59}; 60 61struct cfdriver txphy_cd = { 62 NULL, "txphy", DV_DULL 63}; 64 65int txphy_service __P((struct mii_softc *, struct mii_data *, int)); 66 --- 21 unchanged lines hidden (view full) --- 88 struct mii_data *mii = ma->mii_data; 89 90 printf(": %s, rev. %d\n", MII_STR_xxTI_TNETE2101, 91 MII_REV(ma->mii_id2)); 92 93 sc->mii_inst = mii->mii_instance; 94 sc->mii_phy = ma->mii_phyno; 95 sc->mii_service = txphy_service; |
96 sc->mii_status = ukphy_status; |
|
95 sc->mii_pdata = mii; | 97 sc->mii_pdata = mii; |
98 sc->mii_flags = mii->mii_flags; |
|
96 97 mii_phy_reset(sc); 98 99 sc->mii_capabilities = 100 PHY_READ(sc, MII_BMSR) & ma->mii_capmask; 101 if (sc->mii_capabilities & BMSR_MEDIAMASK) | 99 100 mii_phy_reset(sc); 101 102 sc->mii_capabilities = 103 PHY_READ(sc, MII_BMSR) & ma->mii_capmask; 104 if (sc->mii_capabilities & BMSR_MEDIAMASK) |
102 mii_add_media(sc); | 105 mii_phy_add_media(sc); |
103} 104 105int 106txphy_service(sc, mii, cmd) 107 struct mii_softc *sc; 108 struct mii_data *mii; 109 int cmd; 110{ 111 struct ifmedia_entry *ife = mii->mii_media.ifm_cur; 112 | 106} 107 108int 109txphy_service(sc, mii, cmd) 110 struct mii_softc *sc; 111 struct mii_data *mii; 112 int cmd; 113{ 114 struct ifmedia_entry *ife = mii->mii_media.ifm_cur; 115 |
116 if ((sc->mii_dev.dv_flags & DVF_ACTIVE) == 0) 117 return (ENXIO); 118 |
|
113 /* 114 * Can't isolate the RTL8139 phy, so it has to be the only one. 115 */ 116 if (IFM_INST(ife->ifm_media) != sc->mii_inst) 117 panic("txphy_service: attempt to isolate phy"); 118 119 switch (cmd) { 120 case MII_POLLSTAT: 121 break; 122 123 case MII_MEDIACHG: 124 /* 125 * If the interface is not up, don't do anything. 126 */ 127 if ((mii->mii_ifp->if_flags & IFF_UP) == 0) 128 break; 129 130 switch (IFM_SUBTYPE(ife->ifm_media)) { | 119 /* 120 * Can't isolate the RTL8139 phy, so it has to be the only one. 121 */ 122 if (IFM_INST(ife->ifm_media) != sc->mii_inst) 123 panic("txphy_service: attempt to isolate phy"); 124 125 switch (cmd) { 126 case MII_POLLSTAT: 127 break; 128 129 case MII_MEDIACHG: 130 /* 131 * If the interface is not up, don't do anything. 132 */ 133 if ((mii->mii_ifp->if_flags & IFF_UP) == 0) 134 break; 135 136 switch (IFM_SUBTYPE(ife->ifm_media)) { |
131 case IFM_AUTO: 132 /* 133 * If we're already in auto mode, just return. 134 */ 135 if (PHY_READ(sc, MII_BMCR) & BMCR_AUTOEN) 136 return (0); 137 (void) mii_phy_auto(sc, 1); 138 break; 139 default: 140 mii_phy_setmedia(sc); 141 } | 137 mii_phy_setmedia(sc); |
142 break; 143 144 case MII_TICK: | 138 break; 139 140 case MII_TICK: |
145 /* 146 * Only used for autonegotiation. 147 */ 148 if (IFM_SUBTYPE(ife->ifm_media) != IFM_AUTO) | 141 if (mii_phy_tick(sc) == EJUSTRETURN) |
149 return (0); | 142 return (0); |
150 151 /* 152 * Is the interface even up? 153 */ 154 if ((mii->mii_ifp->if_flags & IFF_UP) == 0) 155 return (0); 156 157 /* 158 * The TNETE2101 autonegotiation doesn't need to be 159 * kicked; it continues in the background. 160 */ | |
161 break; 162 163 case MII_DOWN: 164 mii_phy_down(sc); 165 return (0); 166 } 167 168 /* Update the media status. */ | 143 break; 144 145 case MII_DOWN: 146 mii_phy_down(sc); 147 return (0); 148 } 149 150 /* Update the media status. */ |
169 ukphy_status(sc); | 151 mii_phy_status(sc); |
170 171 /* Callback if something changed. */ | 152 153 /* Callback if something changed. */ |
172 if (sc->mii_active != mii->mii_media_active || cmd == MII_MEDIACHG) { 173 (*mii->mii_statchg)(sc->mii_dev.dv_parent); 174 sc->mii_active = mii->mii_media_active; 175 } | 154 mii_phy_update(sc, cmd); |
176 return (0); 177} | 155 return (0); 156} |