//! Rust Asix PHYs driver //! //! C version of this driver: [`drivers/net/phy/ax88796b.c`](./ax88796b.c) use kernel::{
c_str,
net::phy::{self, reg::C22, DeviceId, Driver},
prelude::*,
uapi,
};
const BMCR_SPEED100: u16 = uapi::BMCR_SPEED100 as u16; const BMCR_FULLDPLX: u16 = uapi::BMCR_FULLDPLX as u16;
// Performs a software PHY reset using the standard // BMCR_RESET bit and poll for the reset bit to be cleared. // Toggle BMCR_RESET bit off to accommodate broken AX8796B PHY implementation // such as used on the Individual Computers' X-Surf 100 Zorro card. fn asix_soft_reset(dev: &mut phy::Device) -> Result {
dev.write(C22::BMCR, 0)?;
dev.genphy_soft_reset()
}
// AX88772A is not working properly with some old switches (NETGEAR EN 108TP): // after autoneg is done and the link status is reported as active, the MII_LPA // register is 0. This issue is not reproducible on AX88772C. fn read_status(dev: &mut phy::Device) -> Result<u16> {
dev.genphy_update_link()?; if !dev.is_link_up() { return Ok(0);
} // If MII_LPA is 0, phy_resolve_aneg_linkmode() will fail to resolve // linkmode so use MII_BMCR as default values. let ret = dev.read(C22::BMCR)?;
if ret & BMCR_SPEED100 != 0 {
dev.set_speed(uapi::SPEED_100);
} else {
dev.set_speed(uapi::SPEED_10);
}
let duplex = if ret & BMCR_FULLDPLX != 0 {
phy::DuplexMode::Full
} else {
phy::DuplexMode::Half
};
dev.set_duplex(duplex);
dev.genphy_read_lpa()?;
if dev.is_autoneg_enabled() && dev.is_autoneg_completed() {
dev.resolve_aneg_linkmode();
}
Ok(0)
}
fn suspend(dev: &mut phy::Device) -> Result {
dev.genphy_suspend()
}
fn resume(dev: &mut phy::Device) -> Result {
dev.genphy_resume()
}
fn soft_reset(dev: &mut phy::Device) -> Result {
asix_soft_reset(dev)
}
fn link_change_notify(dev: &mut phy::Device) { // Reset PHY, otherwise MII_LPA will provide outdated information. // This issue is reproducible only with some link partner PHYs. if dev.state() == phy::DeviceState::NoLink { let _ = dev.init_hw(); let _ = dev.start_aneg();
}
}
}
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.