On Wed, May 24, 2017 at 03:57:06PM -0500, Timur Tabi wrote: > On 05/24/2017 02:34 PM, Andrew Lunn wrote: > >>Ok, I'm going to debug this some more. It turns out that the MAC side of > >>the SGMII link can send an interrupt when it thinks that auto-negotiation is > >>done. I might be able to use this. > > > >You can use this for your board. But it still leaves the phy driver > >broken for everybody else. > > Wait, I thought you said the at803x driver was not broken, since it > returns 0 when the SGMII side of the link hasn't finished > auto-negotiating?
It is correct so far. But to work, it needs to interrupt again once the SGMII side has come up. Only then have we link. > My NIC has a feature called autopolling where it takes over the MDIO > bus and regularly polls the link state. When it detects that the > link state has changed, it generates a MAC interrupt. This is when > I call phy_mac_interrupt() normally. Unfortunately, you need to keep this feature turned off. It will not respect the phydev mutex. It has no idea what page has been currently selected. It probably has no way to flip the page and see if the SGMII link is up. etc. > Can you tell my how PHY_HAS_INTERRUPT is supposed to work? How does > the PHY send an interrupt? Generally, the PHY interrupt pin is connected to a GPIO. You then use the GPIO as an interrupt source. So it has an interrupt number. Put that in phydev->irq, eg using the interrupts property in device tree. The core will register an interrupt handler, and enable the interrupt. When it receives an interrupt, it calls the phy driver to service the interrupt. Andrew