Commit fb44b8d6 authored by Alexandru Ardelean's avatar Alexandru Ardelean Committed by David S. Miller

net: phy: adin: add support for interrupts

This change hooks link-status-change interrupts to phylib.
Reviewed-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
Signed-off-by: default avatarAlexandru Ardelean <alexandru.ardelean@analog.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 49cc4c7d
...@@ -14,11 +14,43 @@ ...@@ -14,11 +14,43 @@
#define PHY_ID_ADIN1200 0x0283bc20 #define PHY_ID_ADIN1200 0x0283bc20
#define PHY_ID_ADIN1300 0x0283bc30 #define PHY_ID_ADIN1300 0x0283bc30
#define ADIN1300_INT_MASK_REG 0x0018
#define ADIN1300_INT_MDIO_SYNC_EN BIT(9)
#define ADIN1300_INT_ANEG_STAT_CHNG_EN BIT(8)
#define ADIN1300_INT_ANEG_PAGE_RX_EN BIT(6)
#define ADIN1300_INT_IDLE_ERR_CNT_EN BIT(5)
#define ADIN1300_INT_MAC_FIFO_OU_EN BIT(4)
#define ADIN1300_INT_RX_STAT_CHNG_EN BIT(3)
#define ADIN1300_INT_LINK_STAT_CHNG_EN BIT(2)
#define ADIN1300_INT_SPEED_CHNG_EN BIT(1)
#define ADIN1300_INT_HW_IRQ_EN BIT(0)
#define ADIN1300_INT_MASK_EN \
(ADIN1300_INT_LINK_STAT_CHNG_EN | ADIN1300_INT_HW_IRQ_EN)
#define ADIN1300_INT_STATUS_REG 0x0019
static int adin_config_init(struct phy_device *phydev) static int adin_config_init(struct phy_device *phydev)
{ {
return genphy_config_init(phydev); return genphy_config_init(phydev);
} }
static int adin_phy_ack_intr(struct phy_device *phydev)
{
/* Clear pending interrupts */
int rc = phy_read(phydev, ADIN1300_INT_STATUS_REG);
return rc < 0 ? rc : 0;
}
static int adin_phy_config_intr(struct phy_device *phydev)
{
if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
return phy_set_bits(phydev, ADIN1300_INT_MASK_REG,
ADIN1300_INT_MASK_EN);
return phy_clear_bits(phydev, ADIN1300_INT_MASK_REG,
ADIN1300_INT_MASK_EN);
}
static struct phy_driver adin_driver[] = { static struct phy_driver adin_driver[] = {
{ {
PHY_ID_MATCH_MODEL(PHY_ID_ADIN1200), PHY_ID_MATCH_MODEL(PHY_ID_ADIN1200),
...@@ -26,6 +58,8 @@ static struct phy_driver adin_driver[] = { ...@@ -26,6 +58,8 @@ static struct phy_driver adin_driver[] = {
.config_init = adin_config_init, .config_init = adin_config_init,
.config_aneg = genphy_config_aneg, .config_aneg = genphy_config_aneg,
.read_status = genphy_read_status, .read_status = genphy_read_status,
.ack_interrupt = adin_phy_ack_intr,
.config_intr = adin_phy_config_intr,
.resume = genphy_resume, .resume = genphy_resume,
.suspend = genphy_suspend, .suspend = genphy_suspend,
}, },
...@@ -35,6 +69,8 @@ static struct phy_driver adin_driver[] = { ...@@ -35,6 +69,8 @@ static struct phy_driver adin_driver[] = {
.config_init = adin_config_init, .config_init = adin_config_init,
.config_aneg = genphy_config_aneg, .config_aneg = genphy_config_aneg,
.read_status = genphy_read_status, .read_status = genphy_read_status,
.ack_interrupt = adin_phy_ack_intr,
.config_intr = adin_phy_config_intr,
.resume = genphy_resume, .resume = genphy_resume,
.suspend = genphy_suspend, .suspend = genphy_suspend,
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment