Making mii_read/mii_write accessible via HAL

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Post Reply
ulikoehler
Posts: 71
Joined: Tue Mar 17, 2015 2:32 am
Been thanked: 3 times

Making mii_read/mii_write accessible via HAL

Post 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
User avatar
Giovanni
Site Admin
Posts: 14893
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 997 times

Re: Making mii_read/mii_write accessible via HAL

Post by Giovanni »

Hi,

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

Giovanni
Post Reply