Subject: Re: PROBLEM: smsc95xx loses config on link down/up

From: Andrew Lunn <[email-masked]>
Date: Tue, 3 Dec 2019 14:27:30 +0100

> Basically it looks as though doing a BMCR_RESET does, in fact, reset
> every PHY R/W register bit except for those marked as "Not Affected by
> Software Reset" (NASR). This means it will reset, to the default
> value:
> 
> - Autonegotiation
> - Speed
> - Duplex
> - Auto MDIX
> - Energy Detect Power-Down
> - Auto Negotiation Advertisement
> - PHY Identification (although I don't know why you'd change this?)
> - Power down
> - Loopback
> 
> I tested this by checking the value of the BMCR register before and
> after doing a BMCR_RESET and it did reset the BMCR register to its
> default values.

O.K, not what we want.

So there are two different paths here you can follow:

1) Moving the reset out of open and into bind.
2) Re-write the driver to make use of the core phylib support.

1) is probably the quick and simple solution, but watch out for
suspend/resume.

2) is more work, but brings the driver into line with other MAC
drivers. phylib would then program the PHY, maybe via PHY driver. It
would do this during open, using state information. So it should
correctly handle state change while the interface is down, or
suspended etc.

The USB-ethernet drivers lan78xx and ax88172a both use phylib.  They
can give you ideas how this should work.

drivers/net/phy/smsc.c might be a good basis for a PHY driver, but it
looks like you will need to extend it for MDIX, etc.

      Andrew