Skip to content

Commit b2f0ca0

Browse files
Radu Pirea (NXP OSS)davem330
authored andcommitted
phy: nxp-c45-tja11xx: add interrupt support
Added .config_intr and .handle_interrupt callbacks. Link event interrupt will trigger an interrupt every time when the link goes up or down. Signed-off-by: Radu Pirea (NXP OSS) <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent cbbd21a commit b2f0ca0

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

drivers/net/phy/nxp-c45-tja11xx.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@
2828
#define DEVICE_CONTROL_CONFIG_GLOBAL_EN BIT(14)
2929
#define DEVICE_CONTROL_CONFIG_ALL_EN BIT(13)
3030

31+
#define VEND1_PHY_IRQ_ACK 0x80A0
32+
#define VEND1_PHY_IRQ_EN 0x80A1
33+
#define VEND1_PHY_IRQ_STATUS 0x80A2
34+
#define PHY_IRQ_LINK_EVENT BIT(1)
35+
3136
#define VEND1_PHY_CONTROL 0x8100
3237
#define PHY_CONFIG_EN BIT(14)
3338
#define PHY_START_OP BIT(0)
@@ -188,6 +193,32 @@ static int nxp_c45_start_op(struct phy_device *phydev)
188193
PHY_START_OP);
189194
}
190195

196+
static int nxp_c45_config_intr(struct phy_device *phydev)
197+
{
198+
if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
199+
return phy_set_bits_mmd(phydev, MDIO_MMD_VEND1,
200+
VEND1_PHY_IRQ_EN, PHY_IRQ_LINK_EVENT);
201+
else
202+
return phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1,
203+
VEND1_PHY_IRQ_EN, PHY_IRQ_LINK_EVENT);
204+
}
205+
206+
static irqreturn_t nxp_c45_handle_interrupt(struct phy_device *phydev)
207+
{
208+
irqreturn_t ret = IRQ_NONE;
209+
int irq;
210+
211+
irq = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_PHY_IRQ_STATUS);
212+
if (irq & PHY_IRQ_LINK_EVENT) {
213+
phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_PHY_IRQ_ACK,
214+
PHY_IRQ_LINK_EVENT);
215+
phy_trigger_machine(phydev);
216+
ret = IRQ_HANDLED;
217+
}
218+
219+
return ret;
220+
}
221+
191222
static int nxp_c45_soft_reset(struct phy_device *phydev)
192223
{
193224
int ret;
@@ -560,6 +591,8 @@ static struct phy_driver nxp_c45_driver[] = {
560591
.soft_reset = nxp_c45_soft_reset,
561592
.config_aneg = nxp_c45_config_aneg,
562593
.config_init = nxp_c45_config_init,
594+
.config_intr = nxp_c45_config_intr,
595+
.handle_interrupt = nxp_c45_handle_interrupt,
563596
.read_status = nxp_c45_read_status,
564597
.suspend = genphy_c45_pma_suspend,
565598
.resume = genphy_c45_pma_resume,

0 commit comments

Comments
 (0)