Struct Device

Source
pub struct Device(/* private fields */);
Expand description

An instance of a PHY device.

Wraps the kernel’s struct phy_device.

A Device instance is created when a callback in Driver is executed. A PHY driver executes Driver’s methods during the callback.

§Invariants

  • Referencing a phy_device using this struct asserts that you are in a context where all methods defined on this struct are safe to call.
  • This struct always has a valid self.0.mdio.dev.

Implementations§

Source§

impl Device

Source

pub fn phy_id(&self) -> u32

Gets the id of the PHY.

Source

pub fn state(&self) -> DeviceState

Gets the state of PHY state machine states.

Gets the current link state.

It returns true if the link is up.

Source

pub fn is_autoneg_enabled(&self) -> bool

Gets the current auto-negotiation configuration.

It returns true if auto-negotiation is enabled.

Source

pub fn is_autoneg_completed(&self) -> bool

Gets the current auto-negotiation state.

It returns true if auto-negotiation is completed.

Source

pub fn set_speed(&mut self, speed: u32)

Sets the speed of the PHY.

Source

pub fn set_duplex(&mut self, mode: DuplexMode)

Sets duplex mode.

Source

pub fn read<R: Register>(&mut self, reg: R) -> Result<u16>

Reads a PHY register.

Source

pub fn write<R: Register>(&mut self, reg: R, val: u16) -> Result

Writes a PHY register.

Source

pub fn read_paged(&mut self, page: u16, regnum: u16) -> Result<u16>

Reads a paged register.

Source

pub fn resolve_aneg_linkmode(&mut self)

Resolves the advertisements into PHY settings.

Source

pub fn genphy_soft_reset(&mut self) -> Result

Executes software reset the PHY via BMCR_RESET bit.

Source

pub fn init_hw(&mut self) -> Result

Initializes the PHY.

Source

pub fn start_aneg(&mut self) -> Result

Starts auto-negotiation.

Source

pub fn genphy_resume(&mut self) -> Result

Resumes the PHY via BMCR_PDOWN bit.

Source

pub fn genphy_suspend(&mut self) -> Result

Suspends the PHY via BMCR_PDOWN bit.

Source

pub fn genphy_read_status<R: Register>(&mut self) -> Result<u16>

Checks the link status and updates current link state.

Updates the link status.

Source

pub fn genphy_read_lpa(&mut self) -> Result

Reads link partner ability.

Source

pub fn genphy_read_abilities(&mut self) -> Result

Reads PHY abilities.

Trait Implementations§

Source§

impl AsRef<Device> for Device

Source§

fn as_ref(&self) -> &Device

Converts this type into a shared reference of the (usually inferred) input type.

Auto Trait Implementations§

§

impl !Freeze for Device

§

impl !RefUnwindSafe for Device

§

impl !Send for Device

§

impl !Sync for Device

§

impl !Unpin for Device

§

impl UnwindSafe for Device

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, E> Init<T, E> for T

Source§

unsafe fn __init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
Source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, E> PinInit<T, E> for T

Source§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
Source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.