Management Data Input/Output (MDIO)

Overview

MDIO is a bus that is commonly used to communicate with ethernet PHY devices. Many ethernet MAC controllers also provide hardware to communicate over MDIO bus with a peripheral device.

This API is intended to be used primarily by PHY drivers but can also be used by user firmware.

API Reference

group mdio_interface

MDIO Interface.

Functions

void mdio_bus_enable(const struct device *dev)

Enable MDIO bus.

Parameters:
  • dev[in] Pointer to the device structure for the controller

void mdio_bus_disable(const struct device *dev)

Disable MDIO bus and tri-state drivers.

Parameters:
  • dev[in] Pointer to the device structure for the controller

int mdio_read(const struct device *dev, uint8_t prtad, uint8_t regad, uint16_t *data)

Read from MDIO Bus.

This routine provides a generic interface to perform a read on the MDIO bus.

Parameters:
  • dev[in] Pointer to the device structure for the controller

  • prtad[in] Port address

  • regad[in] Register address

  • data – Pointer to receive read data

Return values:
  • 0 – If successful.

  • -EIO – General input / output error.

  • -ETIMEDOUT – If transaction timedout on the bus

  • -ENOSYS – if read is not supported

int mdio_write(const struct device *dev, uint8_t prtad, uint8_t regad, uint16_t data)

Write to MDIO bus.

This routine provides a generic interface to perform a write on the MDIO bus.

Parameters:
  • dev[in] Pointer to the device structure for the controller

  • prtad[in] Port address

  • regad[in] Register address

  • data[in] Data to write

Return values:
  • 0 – If successful.

  • -EIO – General input / output error.

  • -ETIMEDOUT – If transaction timedout on the bus

  • -ENOSYS – if write is not supported

int mdio_read_c45(const struct device *dev, uint8_t prtad, uint8_t devad, uint16_t regad, uint16_t *data)

Read from MDIO Bus using Clause 45 access.

This routine provides an interface to perform a read on the MDIO bus using IEEE 802.3 Clause 45 access.

Parameters:
  • dev[in] Pointer to the device structure for the controller

  • prtad[in] Port address

  • devad[in] Device address

  • regad[in] Register address

  • data – Pointer to receive read data

Return values:
  • 0 – If successful.

  • -EIO – General input / output error.

  • -ETIMEDOUT – If transaction timedout on the bus

  • -ENOSYS – if write using Clause 45 access is not supported

int mdio_write_c45(const struct device *dev, uint8_t prtad, uint8_t devad, uint16_t regad, uint16_t data)

Write to MDIO bus using Clause 45 access.

This routine provides an interface to perform a write on the MDIO bus using IEEE 802.3 Clause 45 access.

Parameters:
  • dev[in] Pointer to the device structure for the controller

  • prtad[in] Port address

  • devad[in] Device address

  • regad[in] Register address

  • data[in] Data to write

Return values:
  • 0 – If successful.

  • -EIO – General input / output error.

  • -ETIMEDOUT – If transaction timedout on the bus

  • -ENOSYS – if write using Clause 45 access is not supported