Page 1 of 1

Powering Down Ethernet LAN8742 on Discovery 769

Posted: Thu Dec 06, 2018 3:51 am
by gligorov
Looking at the hal_mii.h, on line 67, i see there is a definition for power down control:

67: #define BMCR_PDOWN 0x0800 /**< Powerdown.

Is there support then, to put this interface in a powered down mode?

I am playing with Discovery 769 Board, and would like to test this, so any pointers are appreciated.

Thanks.

Re: Powering Down Ethernet LAN8742 on Discovery 769

Posted: Thu Dec 06, 2018 8:36 am
by Giovanni
Hi,

That is a generic header, you need to refer to the datasheet and see if/how the function is implemented. The driver itself does not support this mode, it is up to you to write into the register.

Giovanni

Re: Powering Down Ethernet LAN8742 on Discovery 769

Posted: Thu Dec 06, 2018 3:20 pm
by gligorov
The function to shut down is compatible with the declaration is why I asked the question. It basically says setting bit 11 (0x0800) to 1, will shut the ethernet interface down, and setting it to 0, enables it.

Any suggestions on where would be a good place to try to add this function in the driver?

Thanks.

Re: Powering Down Ethernet LAN8742 on Discovery 769

Posted: Thu Dec 06, 2018 6:49 pm
by Giovanni
Hi,

The proper place would be doing this kind of things in start/stop, it is pointless to keep the PHY active is the driver is stopped.

Giovanni

Re: Powering Down Ethernet LAN8742 on Discovery 769

Posted: Sat Dec 08, 2018 10:06 pm
by gligorov
So I think I have an implementation, but am not able to test it. Got the latest ChibiOS studio, working with Disco 769I board, and can build the solution but debug is not working, and I am not able to deploy, but anyway, here is what I did:

1. Added a #define BOARD_PHY_POWER to the board.h file

In the chibios182\os\hal\ports\STM32\LLD\MACv1\hal_mac_lld.c file, the 2 methods mac_lld_start and mac_lld_stop got 1 line each:

void mac_lld_stop(MACDriver *macp) {
...
#if defined(BOARD_PHY_POWER) /* Power Down Ethernet IC */
mii_write(macp, MII_BMCR, BMCR_PDOWN);
#endif


void mac_lld_start(MACDriver *macp) {
...
#if defined(BOARD_PHY_POWER) /* Power Up Ethernet IC */
mii_write(macp, MII_BMCR, ~BMCR_PDOWN);
#endif

So, is this on the right track at least?

Thanks.

Re: Powering Down Ethernet LAN8742 on Discovery 769

Posted: Sun Dec 09, 2018 3:24 am
by gligorov
On a detailed review, these methods are already implemented in the trunk, so seems is already in place.

void mac_lld_stop(MACDriver macp) {

#if STM32_MAC_ETH1_CHANGE_PHY_STATE
/ PHY in power down mode until the driver will be restarted.*/
mii_write(macp, MII_BMCR, mii_read(macp, MII_BMCR) | BMCR_PDOWN);
#endif

Also the opposite on start:
void mac_lld_start(MACDriver macp) {
...
#if STM32_MAC_ETH1_CHANGE_PHY_STATE
/ PHY in power up mode.*/
mii_write(macp, MII_BMCR, mii_read(macp, MII_BMCR) & ~BMCR_PDOWN);
#endif

Zan