On Fri, Jun 02, 2017 at 01:43:39PM +0100, Russell King - ARM Linux wrote: > On Thu, Jun 01, 2017 at 10:16:17AM -0700, Florian Fainelli wrote: > > On 06/01/2017 09:24 AM, Russell King - ARM Linux wrote: > > > Checking 802.3-2015, in "22.2.4 Management functions", the first > > > sentence requires all PHYs that respond to Clause 22 cycles to > > > implement BMCR and BMSR. However, my statement about unimplemented > > > registers returning zero seems to be a C45 thing, not a C22 thing, > > > according to the C22 PICS and "45.2 MDIO Interface Registers" > > > > > > However, digging a bit further, "22.2.4.2.10 Auto-Negotiation complete" > > > states that bit 5 shall be zero if aneg has not completed or if aneg is > > > unimplemented. > > > > > > > So how about we are more defensive than that and if we are presented > > with a C45 PHY driver that does not have an aneg_done() function pointer > > set we return an error/warning during driver registration? > > We don't mark drivers as being C22 or C45, we rely on them matching > the IDs and/or the probe function making that decision, so it's a > tad difficult to make that decision at driver registration time. > > We could reject an attempt to probe a C45 phy with a driver that > does not provide an aneg_done() pointer.
Just an idea. We could make phy_read/phy_write look to see if the is_c45 flag is set. If so, return -EINVAL if the register being accessed does not have MII_ADDR_C45. That should catch all these sort of problems. Andrew