/* * Copyright (c) 2005-2008 Chelsio, Inc. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE.
*/ #include"common.h"
/* * Reset the PHY. This PHY completes reset immediately so we never wait.
*/ staticint vsc8211_reset(struct cphy *cphy, int wait)
{ return t3_phy_reset(cphy, MDIO_DEVAD_NONE, 0);
}
staticint vsc8211_get_link_status(struct cphy *cphy, int *link_ok, int *speed, int *duplex, int *fc)
{ unsignedint bmcr, status, lpa, adv; int err, sp = -1, dplx = -1, pause = 0;
err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_BMCR, &bmcr); if (!err)
err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_BMSR, &status); if (err) return err;
if (link_ok) { /* * BMSR_LSTATUS is latch-low, so if it is 0 we need to read it * once more to get the current link state.
*/ if (!(status & BMSR_LSTATUS))
err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_BMSR,
&status); if (err) return err;
*link_ok = (status & BMSR_LSTATUS) != 0;
} if (!(bmcr & BMCR_ANENABLE)) {
dplx = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF; if (bmcr & BMCR_SPEED1000)
sp = SPEED_1000; elseif (bmcr & BMCR_SPEED100)
sp = SPEED_100; else
sp = SPEED_10;
} elseif (status & BMSR_ANEGCOMPLETE) {
err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, VSC8211_AUX_CTRL_STAT,
&status); if (err) return err;
staticint vsc8211_get_link_status_fiber(struct cphy *cphy, int *link_ok, int *speed, int *duplex, int *fc)
{ unsignedint bmcr, status, lpa, adv; int err, sp = -1, dplx = -1, pause = 0;
err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_BMCR, &bmcr); if (!err)
err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_BMSR, &status); if (err) return err;
if (link_ok) { /* * BMSR_LSTATUS is latch-low, so if it is 0 we need to read it * once more to get the current link state.
*/ if (!(status & BMSR_LSTATUS))
err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_BMSR,
&status); if (err) return err;
*link_ok = (status & BMSR_LSTATUS) != 0;
} if (!(bmcr & BMCR_ANENABLE)) {
dplx = (bmcr & BMCR_FULLDPLX) ? DUPLEX_FULL : DUPLEX_HALF; if (bmcr & BMCR_SPEED1000)
sp = SPEED_1000; elseif (bmcr & BMCR_SPEED100)
sp = SPEED_100; else
sp = SPEED_10;
} elseif (status & BMSR_ANEGCOMPLETE) {
err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_LPA, &lpa); if (!err)
err = t3_mdio_read(cphy, MDIO_DEVAD_NONE, MII_ADVERTISE,
&adv); if (err) return err;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.