Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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) <radu-nicolae.pirea@oss.nxp.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Radu Pirea (NXP OSS) and committed by
David S. Miller
b2f0ca00 cbbd21a4

+33
+33
drivers/net/phy/nxp-c45-tja11xx.c
··· 28 28 #define DEVICE_CONTROL_CONFIG_GLOBAL_EN BIT(14) 29 29 #define DEVICE_CONTROL_CONFIG_ALL_EN BIT(13) 30 30 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 + 31 36 #define VEND1_PHY_CONTROL 0x8100 32 37 #define PHY_CONFIG_EN BIT(14) 33 38 #define PHY_START_OP BIT(0) ··· 191 186 { 192 187 return phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, VEND1_PHY_CONTROL, 193 188 PHY_START_OP); 189 + } 190 + 191 + static int nxp_c45_config_intr(struct phy_device *phydev) 192 + { 193 + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) 194 + return phy_set_bits_mmd(phydev, MDIO_MMD_VEND1, 195 + VEND1_PHY_IRQ_EN, PHY_IRQ_LINK_EVENT); 196 + else 197 + return phy_clear_bits_mmd(phydev, MDIO_MMD_VEND1, 198 + VEND1_PHY_IRQ_EN, PHY_IRQ_LINK_EVENT); 199 + } 200 + 201 + static irqreturn_t nxp_c45_handle_interrupt(struct phy_device *phydev) 202 + { 203 + irqreturn_t ret = IRQ_NONE; 204 + int irq; 205 + 206 + irq = phy_read_mmd(phydev, MDIO_MMD_VEND1, VEND1_PHY_IRQ_STATUS); 207 + if (irq & PHY_IRQ_LINK_EVENT) { 208 + phy_write_mmd(phydev, MDIO_MMD_VEND1, VEND1_PHY_IRQ_ACK, 209 + PHY_IRQ_LINK_EVENT); 210 + phy_trigger_machine(phydev); 211 + ret = IRQ_HANDLED; 212 + } 213 + 214 + return ret; 194 215 } 195 216 196 217 static int nxp_c45_soft_reset(struct phy_device *phydev) ··· 591 560 .soft_reset = nxp_c45_soft_reset, 592 561 .config_aneg = nxp_c45_config_aneg, 593 562 .config_init = nxp_c45_config_init, 563 + .config_intr = nxp_c45_config_intr, 564 + .handle_interrupt = nxp_c45_handle_interrupt, 594 565 .read_status = nxp_c45_read_status, 595 566 .suspend = genphy_c45_pma_suspend, 596 567 .resume = genphy_c45_pma_resume,