Skip to content

Commit bd00811

Browse files
committed
net: phy: mtk-2p5ge: support inverted polarity for leds
PHY LED on BPI-R4 Lite / mt7987 seems inverted: green led on when no cable connected and off when link established add a dt-property to allow inverted polarity
1 parent af57965 commit bd00811

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

drivers/net/phy/mediatek/mtk-2p5ge.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -661,16 +661,24 @@ static int mt798x_2p5ge_phy_probe(struct phy_device *phydev)
661661
return -EINVAL;
662662
}
663663

664+
u16 polarity=MTK_PHY_LED_ON_POLARITY;
665+
666+
struct device_node *of_node = phydev->mdio.dev.of_node;
667+
if (of_property_read_bool(of_node, "active-low"))
668+
polarity=0;
669+
664670
switch (phydev->drv->phy_id) {
665671
case MTK_2P5GPHY_ID_MT7987:
666672
ret = mt7987_2p5ge_phy_load_fw(phydev);
667-
phy_clear_bits_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_LED0_ON_CTRL,
668-
MTK_PHY_LED_ON_POLARITY);
673+
phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_LED0_ON_CTRL,
674+
polarity);
675+
dev_err(&phydev->mdio.dev, "DEBUG: mt7987 detected!\n");
669676
break;
670677
case MTK_2P5GPHY_ID_MT7988:
671678
ret = mt7988_2p5ge_phy_load_fw(phydev);
672679
phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_LED0_ON_CTRL,
673-
MTK_PHY_LED_ON_POLARITY);
680+
polarity);
681+
dev_err(&phydev->mdio.dev, "DEBUG: mt7988 detected!\n");
674682
break;
675683
default:
676684
return -EINVAL;
@@ -682,7 +690,7 @@ static int mt798x_2p5ge_phy_probe(struct phy_device *phydev)
682690
* LED1, it blinks as tx/rx transmission takes place.
683691
*/
684692
phy_set_bits_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_LED0_ON_CTRL,
685-
MTK_PHY_LED_ON_POLARITY | MTK_2P5GPHY_LED_ON_SET);
693+
polarity | MTK_2P5GPHY_LED_ON_SET);
686694
phy_clear_bits_mmd(phydev, MDIO_MMD_VEND2, MTK_PHY_LED0_BLINK_CTRL,
687695
MTK_2P5GPHY_LED_TX_BLINK_SET |
688696
MTK_2P5GPHY_LED_RX_BLINK_SET);

0 commit comments

Comments
 (0)