staticint meson_gxl_open_banks(struct phy_device *phydev)
{ int ret;
/* Enable Analog and DSP register Bank access by * toggling TSTCNTL_TEST_MODE bit in the TSTCNTL register
*/
ret = phy_write(phydev, TSTCNTL, 0); if (ret) return ret;
ret = phy_write(phydev, TSTCNTL, TSTCNTL_TEST_MODE); if (ret) return ret;
ret = phy_write(phydev, TSTCNTL, 0); if (ret) return ret; return phy_write(phydev, TSTCNTL, TSTCNTL_TEST_MODE);
}
out: /* Close the bank access on our way out */
meson_gxl_close_banks(phydev); return ret;
}
staticint meson_gxl_config_init(struct phy_device *phydev)
{ int ret;
/* Enable fractional PLL */
ret = meson_gxl_write_reg(phydev, BANK_BIST, FR_PLL_CONTROL, 0x5); if (ret) return ret;
/* Program fraction FR_PLL_DIV1 */
ret = meson_gxl_write_reg(phydev, BANK_BIST, FR_PLL_DIV1, 0x029a); if (ret) return ret;
/* Program fraction FR_PLL_DIV1 */
ret = meson_gxl_write_reg(phydev, BANK_BIST, FR_PLL_DIV0, 0xaaaa); if (ret) return ret;
return 0;
}
/* This function is provided to cope with the possible failures of this phy * during aneg process. When aneg fails, the PHY reports that aneg is done * but the value found in MII_LPA is wrong: * - Early failures: MII_LPA is just 0x0001. if MII_EXPANSION reports that * the link partner (LP) supports aneg but the LP never acked our base * code word, it is likely that we never sent it to begin with. * - Late failures: MII_LPA is filled with a value which seems to make sense * but it actually is not what the LP is advertising. It seems that we * can detect this using a magic bit in the WOL bank (reg 12 - bit 12). * If this particular bit is not set when aneg is reported being done, * it means MII_LPA is likely to be wrong. * * In both case, forcing a restart of the aneg process solve the problem. * When this failure happens, the first retry is usually successful but, * in some cases, it may take up to 6 retries to get a decent result
*/ staticint meson_gxl_read_status(struct phy_device *phydev)
{ int ret, wol, lpa, exp;
if (phydev->autoneg == AUTONEG_ENABLE) {
ret = genphy_aneg_done(phydev); if (ret < 0) return ret; elseif (!ret) goto read_status_continue;
/* Aneg is done, let's check everything is fine */
wol = meson_gxl_read_reg(phydev, BANK_WOL, LPI_STATUS); if (wol < 0) return wol;
lpa = phy_read(phydev, MII_LPA); if (lpa < 0) return lpa;
exp = phy_read(phydev, MII_EXPANSION); if (exp < 0) return exp;
if (!(wol & LPI_STATUS_RSV12) ||
((exp & EXPANSION_NWAY) && !(lpa & LPA_LPACK))) { /* Looks like aneg failed after all */
phydev_dbg(phydev, "LPA corruption - aneg restart\n"); return genphy_restart_aneg(phydev);
}
}
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.