Powering Down Ethernet LAN8742 on Discovery 769

Discussions and support about ChibiOS/HAL, the MCU Hardware Abstraction Layer.
Post Reply
gligorov
Posts: 6
Joined: Mon Nov 19, 2018 4:44 pm
Has thanked: 3 times

Powering Down Ethernet LAN8742 on Discovery 769

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

Re: Powering Down Ethernet LAN8742 on Discovery 769

Post 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
gligorov
Posts: 6
Joined: Mon Nov 19, 2018 4:44 pm
Has thanked: 3 times

Re: Powering Down Ethernet LAN8742 on Discovery 769

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

Re: Powering Down Ethernet LAN8742 on Discovery 769

Post 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
gligorov
Posts: 6
Joined: Mon Nov 19, 2018 4:44 pm
Has thanked: 3 times

Re: Powering Down Ethernet LAN8742 on Discovery 769

Post 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.
gligorov
Posts: 6
Joined: Mon Nov 19, 2018 4:44 pm
Has thanked: 3 times

Re: Powering Down Ethernet LAN8742 on Discovery 769

Post 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
Post Reply