cxgb_vsc8211.c (256281) | cxgb_vsc8211.c (277343) |
---|---|
1/************************************************************************** 2 3Copyright (c) 2007, Chelsio Inc. 4All rights reserved. 5 6Redistribution and use in source and binary forms, with or without 7modification, are permitted provided that the following conditions are met: 8 --- 14 unchanged lines hidden (view full) --- 23INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26POSSIBILITY OF SUCH DAMAGE. 27 28***************************************************************************/ 29 30#include <sys/cdefs.h> | 1/************************************************************************** 2 3Copyright (c) 2007, Chelsio Inc. 4All rights reserved. 5 6Redistribution and use in source and binary forms, with or without 7modification, are permitted provided that the following conditions are met: 8 --- 14 unchanged lines hidden (view full) --- 23INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26POSSIBILITY OF SUCH DAMAGE. 27 28***************************************************************************/ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: stable/10/sys/dev/cxgb/common/cxgb_vsc8211.c 197791 2009-10-05 20:21:41Z np $"); | 31__FBSDID("$FreeBSD: stable/10/sys/dev/cxgb/common/cxgb_vsc8211.c 277343 2015-01-18 20:38:38Z np $"); |
32 33#include <cxgb_include.h> 34 35#undef msleep 36#define msleep t3_os_sleep 37 38/* VSC8211 PHY specific registers. */ 39enum { --- 84 unchanged lines hidden (view full) --- 124} 125 126static int vsc8211_autoneg_restart(struct cphy *cphy) 127{ 128 return t3_mdio_change_bits(cphy, 0, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, 129 BMCR_ANRESTART); 130} 131 | 32 33#include <cxgb_include.h> 34 35#undef msleep 36#define msleep t3_os_sleep 37 38/* VSC8211 PHY specific registers. */ 39enum { --- 84 unchanged lines hidden (view full) --- 124} 125 126static int vsc8211_autoneg_restart(struct cphy *cphy) 127{ 128 return t3_mdio_change_bits(cphy, 0, MII_BMCR, BMCR_PDOWN | BMCR_ISOLATE, 129 BMCR_ANRESTART); 130} 131 |
132static int vsc8211_get_link_status(struct cphy *cphy, int *link_ok, | 132static int vsc8211_get_link_status(struct cphy *cphy, int *link_state, |
133 int *speed, int *duplex, int *fc) 134{ 135 unsigned int bmcr, status, lpa, adv; 136 int err, sp = -1, dplx = -1, pause = 0; 137 138 err = mdio_read(cphy, 0, MII_BMCR, &bmcr); 139 if (!err) 140 err = mdio_read(cphy, 0, MII_BMSR, &status); 141 if (err) 142 return err; 143 | 133 int *speed, int *duplex, int *fc) 134{ 135 unsigned int bmcr, status, lpa, adv; 136 int err, sp = -1, dplx = -1, pause = 0; 137 138 err = mdio_read(cphy, 0, MII_BMCR, &bmcr); 139 if (!err) 140 err = mdio_read(cphy, 0, MII_BMSR, &status); 141 if (err) 142 return err; 143 |
144 if (link_ok) { | 144 if (link_state) { |
145 /* 146 * BMSR_LSTATUS is latch-low, so if it is 0 we need to read it 147 * once more to get the current link state. 148 */ 149 if (!(status & BMSR_LSTATUS)) 150 err = mdio_read(cphy, 0, MII_BMSR, &status); 151 if (err) 152 return err; | 145 /* 146 * BMSR_LSTATUS is latch-low, so if it is 0 we need to read it 147 * once more to get the current link state. 148 */ 149 if (!(status & BMSR_LSTATUS)) 150 err = mdio_read(cphy, 0, MII_BMSR, &status); 151 if (err) 152 return err; |
153 *link_ok = (status & BMSR_LSTATUS) != 0; | 153 *link_state = status & BMSR_LSTATUS ? PHY_LINK_UP : 154 PHY_LINK_DOWN; |
154 } 155 if (!(bmcr & BMCR_ANENABLE)) { 156 dplx = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF; 157 if (bmcr & BMCR_SPEED1000) 158 sp = SPEED_1000; 159 else if (bmcr & BMCR_SPEED100) 160 sp = SPEED_100; 161 else --- 34 unchanged lines hidden (view full) --- 196 *speed = sp; 197 if (duplex) 198 *duplex = dplx; 199 if (fc) 200 *fc = pause; 201 return 0; 202} 203 | 155 } 156 if (!(bmcr & BMCR_ANENABLE)) { 157 dplx = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF; 158 if (bmcr & BMCR_SPEED1000) 159 sp = SPEED_1000; 160 else if (bmcr & BMCR_SPEED100) 161 sp = SPEED_100; 162 else --- 34 unchanged lines hidden (view full) --- 197 *speed = sp; 198 if (duplex) 199 *duplex = dplx; 200 if (fc) 201 *fc = pause; 202 return 0; 203} 204 |
204static int vsc8211_get_link_status_fiber(struct cphy *cphy, int *link_ok, | 205static int vsc8211_get_link_status_fiber(struct cphy *cphy, int *link_state, |
205 int *speed, int *duplex, int *fc) 206{ 207 unsigned int bmcr, status, lpa, adv; 208 int err, sp = -1, dplx = -1, pause = 0; 209 210 err = mdio_read(cphy, 0, MII_BMCR, &bmcr); 211 if (!err) 212 err = mdio_read(cphy, 0, MII_BMSR, &status); 213 if (err) 214 return err; 215 | 206 int *speed, int *duplex, int *fc) 207{ 208 unsigned int bmcr, status, lpa, adv; 209 int err, sp = -1, dplx = -1, pause = 0; 210 211 err = mdio_read(cphy, 0, MII_BMCR, &bmcr); 212 if (!err) 213 err = mdio_read(cphy, 0, MII_BMSR, &status); 214 if (err) 215 return err; 216 |
216 if (link_ok) { | 217 if (link_state) { |
217 /* 218 * BMSR_LSTATUS is latch-low, so if it is 0 we need to read it 219 * once more to get the current link state. 220 */ 221 if (!(status & BMSR_LSTATUS)) 222 err = mdio_read(cphy, 0, MII_BMSR, &status); 223 if (err) 224 return err; | 218 /* 219 * BMSR_LSTATUS is latch-low, so if it is 0 we need to read it 220 * once more to get the current link state. 221 */ 222 if (!(status & BMSR_LSTATUS)) 223 err = mdio_read(cphy, 0, MII_BMSR, &status); 224 if (err) 225 return err; |
225 *link_ok = (status & BMSR_LSTATUS) != 0; | 226 *link_state = status & BMSR_LSTATUS ? PHY_LINK_UP : 227 PHY_LINK_DOWN; |
226 } 227 if (!(bmcr & BMCR_ANENABLE)) { 228 dplx = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF; 229 if (bmcr & BMCR_SPEED1000) 230 sp = SPEED_1000; 231 else if (bmcr & BMCR_SPEED100) 232 sp = SPEED_100; 233 else --- 230 unchanged lines hidden --- | 228 } 229 if (!(bmcr & BMCR_ANENABLE)) { 230 dplx = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF; 231 if (bmcr & BMCR_SPEED1000) 232 sp = SPEED_1000; 233 else if (bmcr & BMCR_SPEED100) 234 sp = SPEED_100; 235 else --- 230 unchanged lines hidden --- |