1
0
Fork 0
This commit is contained in:
Sebastien Bourdeauducq 2021-07-05 13:45:22 +08:00
parent a42e5a95ff
commit 2c161720fa
1 changed files with 97 additions and 138 deletions

View File

@ -1,4 +1,5 @@
pub mod id; pub mod id;
use id::{identify_phy, PhyIdentifier};
mod status; mod status;
pub use status::Status; pub use status::Status;
mod control; mod control;
@ -34,21 +35,17 @@ pub trait PhyRegister {
fn addr() -> u8; fn addr() -> u8;
} }
#[cfg(not(feature = "target_kasli_soc"))]
mod phy_impl {
use super::*;
use id::{identify_phy, PhyIdentifier};
#[derive(Clone)] #[derive(Clone)]
pub struct Phy { pub struct Phy {
pub addr: u8, pub addr: u8,
} }
const OUI_MARVELL: u32 = 0x005043; const OUI_MARVELL: u32 = 0x005043;
const OUI_REALTEK: u32 = 0x000732; const OUI_REALTEK: u32 = 0x000732;
const OUI_LANTIQ : u32 = 0x355969; const OUI_LANTIQ : u32 = 0x355969;
impl Phy { impl Phy {
/// Probe all addresses on MDIO for a known PHY /// Probe all addresses on MDIO for a known PHY
pub fn find<PA: PhyAccess>(pa: &mut PA) -> Option<Phy> { pub fn find<PA: PhyAccess>(pa: &mut PA) -> Option<Phy> {
(0..32).find(|addr| { (0..32).find(|addr| {
@ -142,42 +139,4 @@ mod phy_impl {
.set_restart_autoneg(true) .set_restart_autoneg(true)
); );
} }
}
} }
#[cfg(feature = "target_kasli_soc")]
mod phy_impl {
use super::*;
#[derive(Clone)]
pub struct Phy {
}
impl Phy {
pub fn find<PA: PhyAccess>(_pa: &mut PA) -> Option<Phy> {
Some(Phy {})
}
pub fn get_link<PA: PhyAccess>(&self, _pa: &mut PA) -> Option<Link> {
Some(Link {
speed: LinkSpeed::S1000,
duplex: LinkDuplex::Full,
})
}
pub fn modify_control<PA, F>(&self, _pa: &mut PA, _f: F)
where
PA: PhyAccess,
F: FnMut(Control) -> Control,
{
}
pub fn reset<PA: PhyAccess>(&self, _pa: &mut PA) {
}
pub fn restart_autoneg<PA: PhyAccess>(&self, _pa: &mut PA) {
}
}
}
pub use phy_impl::*;