lkml.org 
[lkml]   [2022]   [Dec]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH net-next 3/4] drivers/net/phy: Add driver for the onsemi NCN26000 10BASE-T1S PHY
> On Sun, Dec 04, 2022 at 03:31:33AM +0100, Piergiorgio Beruto wrote:
> > +static irqreturn_t ncn26000_handle_interrupt(struct phy_device *phydev)
> > +{
> > + const struct ncn26000_priv *const priv = phydev->priv;
> > + u16 events;
> > + int ret;
> > +
> > + // read and aknowledge the IRQ status register
> > + ret = phy_read(phydev, NCN26000_REG_IRQ_STATUS);
> > +
> > + if (unlikely(ret < 0))
> > + return IRQ_NONE;
> > +
> > + events = (u16)ret & priv->enabled_irqs;
> > + if (events == 0)
> > + return IRQ_NONE;
> > +
> > + if (events & NCN26000_IRQ_LINKST_BIT) {
> > + ret = phy_read(phydev, MII_BMSR);
> > +
> > + if (unlikely(ret < 0)) {
> > + phydev_err(phydev,
> > + "error reading the status register (%d)\n",
> > + ret);
> > +
> > + return IRQ_NONE;
> > + }
> > +
> > + phydev->link = ((u16)ret & BMSR_ANEGCOMPLETE) ? 1 : 0;

Hi Piergiorgio

Interrupt handling in PHY don't follow the usual model. Historically,
PHYs were always polled once per second. The read_status() function
gets called to report the current status of the PHY. Interrupt are
just used to indicate that poll should happen now. All the handler
needs to do is clear the interrupt line so it can be safely reenabled
and not cause an interrupt storm, and call phy_trigger_machine() to
trigger the poll.

Andrew

\
 
 \ /
  Last update: 2022-12-04 19:02    [W:0.090 / U:0.332 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site