Page 1 of 1

Making mii_read/mii_write accessible via HAL

Posted: Tue Sep 08, 2015 1:20 am
by ulikoehler
Hi,
currently AFAIK it is not possible to write PHY registers using the HAL MAC interface. The functions mii_read() and mii_write() that do that in the STM32 LLD are not exported to the generic HAL driver.

This is a useful feature to have. Examples include using IEEE powerdown (in BMCR) or the energy detect stuff in the LAN8710. Other diagnostic information is also available using this feature.

AFAIK it is not possible to implement a working HAL without implementing MDC. It can therefore be assumed that every HAL LLD has a PHY register read/write capability.

I therefore propose to add two functions to mac.h:

Code: Select all

  void macWritePHYRegister(MACDriver *macp, uint32_t reg, uint32_t value);
  uint32_t macReadPHYRegister(MACDriver *macp, uint32_t reg);

and, accordingly, rename mii_read() and mii_write() to mac_lld_read_phy_reg() and mac_lld_write_phy_reg(), while defining a preprocessor alias in mac_lld.h to keep 100% compatibility with existing code.

I'm willing to contribute that as a patch if you think this approach is acceptable.

Best regards,
Uli

Re: Making mii_read/mii_write accessible via HAL

Posted: Tue Sep 08, 2015 8:28 am
by Giovanni
Hi,

Those are not API because not all Ethernet interfaces have a MII PHY. Better keep them as unofficial interfaces.

Giovanni