18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0+
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *	drivers/net/phy/broadcom.c
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci *	Broadcom BCM5411, BCM5421 and BCM5461 Gigabit Ethernet
68c2ecf20Sopenharmony_ci *	transceivers.
78c2ecf20Sopenharmony_ci *
88c2ecf20Sopenharmony_ci *	Copyright (c) 2006  Maciej W. Rozycki
98c2ecf20Sopenharmony_ci *
108c2ecf20Sopenharmony_ci *	Inspired by code written by Amy Fong.
118c2ecf20Sopenharmony_ci */
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include "bcm-phy-lib.h"
148c2ecf20Sopenharmony_ci#include <linux/delay.h>
158c2ecf20Sopenharmony_ci#include <linux/module.h>
168c2ecf20Sopenharmony_ci#include <linux/phy.h>
178c2ecf20Sopenharmony_ci#include <linux/brcmphy.h>
188c2ecf20Sopenharmony_ci#include <linux/of.h>
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define BRCM_PHY_MODEL(phydev) \
218c2ecf20Sopenharmony_ci	((phydev)->drv->phy_id & (phydev)->drv->phy_id_mask)
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci#define BRCM_PHY_REV(phydev) \
248c2ecf20Sopenharmony_ci	((phydev)->drv->phy_id & ~((phydev)->drv->phy_id_mask))
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciMODULE_DESCRIPTION("Broadcom PHY driver");
278c2ecf20Sopenharmony_ciMODULE_AUTHOR("Maciej W. Rozycki");
288c2ecf20Sopenharmony_ciMODULE_LICENSE("GPL");
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_cistatic int bcm54xx_config_clock_delay(struct phy_device *phydev)
318c2ecf20Sopenharmony_ci{
328c2ecf20Sopenharmony_ci	int rc, val;
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ci	/* handling PHY's internal RX clock delay */
358c2ecf20Sopenharmony_ci	val = bcm54xx_auxctl_read(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
368c2ecf20Sopenharmony_ci	val |= MII_BCM54XX_AUXCTL_MISC_WREN;
378c2ecf20Sopenharmony_ci	if (phydev->interface == PHY_INTERFACE_MODE_RGMII ||
388c2ecf20Sopenharmony_ci	    phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
398c2ecf20Sopenharmony_ci		/* Disable RGMII RXC-RXD skew */
408c2ecf20Sopenharmony_ci		val &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN;
418c2ecf20Sopenharmony_ci	}
428c2ecf20Sopenharmony_ci	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
438c2ecf20Sopenharmony_ci	    phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) {
448c2ecf20Sopenharmony_ci		/* Enable RGMII RXC-RXD skew */
458c2ecf20Sopenharmony_ci		val |= MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN;
468c2ecf20Sopenharmony_ci	}
478c2ecf20Sopenharmony_ci	rc = bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
488c2ecf20Sopenharmony_ci				  val);
498c2ecf20Sopenharmony_ci	if (rc < 0)
508c2ecf20Sopenharmony_ci		return rc;
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ci	/* handling PHY's internal TX clock delay */
538c2ecf20Sopenharmony_ci	val = bcm_phy_read_shadow(phydev, BCM54810_SHD_CLK_CTL);
548c2ecf20Sopenharmony_ci	if (phydev->interface == PHY_INTERFACE_MODE_RGMII ||
558c2ecf20Sopenharmony_ci	    phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) {
568c2ecf20Sopenharmony_ci		/* Disable internal TX clock delay */
578c2ecf20Sopenharmony_ci		val &= ~BCM54810_SHD_CLK_CTL_GTXCLK_EN;
588c2ecf20Sopenharmony_ci	}
598c2ecf20Sopenharmony_ci	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
608c2ecf20Sopenharmony_ci	    phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
618c2ecf20Sopenharmony_ci		/* Enable internal TX clock delay */
628c2ecf20Sopenharmony_ci		val |= BCM54810_SHD_CLK_CTL_GTXCLK_EN;
638c2ecf20Sopenharmony_ci	}
648c2ecf20Sopenharmony_ci	rc = bcm_phy_write_shadow(phydev, BCM54810_SHD_CLK_CTL, val);
658c2ecf20Sopenharmony_ci	if (rc < 0)
668c2ecf20Sopenharmony_ci		return rc;
678c2ecf20Sopenharmony_ci
688c2ecf20Sopenharmony_ci	return 0;
698c2ecf20Sopenharmony_ci}
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_cistatic int bcm54210e_config_init(struct phy_device *phydev)
728c2ecf20Sopenharmony_ci{
738c2ecf20Sopenharmony_ci	int val;
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci	bcm54xx_config_clock_delay(phydev);
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci	if (phydev->dev_flags & PHY_BRCM_EN_MASTER_MODE) {
788c2ecf20Sopenharmony_ci		val = phy_read(phydev, MII_CTRL1000);
798c2ecf20Sopenharmony_ci		val |= CTL1000_AS_MASTER | CTL1000_ENABLE_MASTER;
808c2ecf20Sopenharmony_ci		phy_write(phydev, MII_CTRL1000, val);
818c2ecf20Sopenharmony_ci	}
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci	return 0;
848c2ecf20Sopenharmony_ci}
858c2ecf20Sopenharmony_ci
868c2ecf20Sopenharmony_cistatic int bcm54612e_config_init(struct phy_device *phydev)
878c2ecf20Sopenharmony_ci{
888c2ecf20Sopenharmony_ci	int reg;
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci	bcm54xx_config_clock_delay(phydev);
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci	/* Enable CLK125 MUX on LED4 if ref clock is enabled. */
938c2ecf20Sopenharmony_ci	if (!(phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED)) {
948c2ecf20Sopenharmony_ci		int err;
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ci		reg = bcm_phy_read_exp(phydev, BCM54612E_EXP_SPARE0);
978c2ecf20Sopenharmony_ci		err = bcm_phy_write_exp(phydev, BCM54612E_EXP_SPARE0,
988c2ecf20Sopenharmony_ci					BCM54612E_LED4_CLK125OUT_EN | reg);
998c2ecf20Sopenharmony_ci
1008c2ecf20Sopenharmony_ci		if (err < 0)
1018c2ecf20Sopenharmony_ci			return err;
1028c2ecf20Sopenharmony_ci	}
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci	return 0;
1058c2ecf20Sopenharmony_ci}
1068c2ecf20Sopenharmony_ci
1078c2ecf20Sopenharmony_cistatic int bcm54616s_config_init(struct phy_device *phydev)
1088c2ecf20Sopenharmony_ci{
1098c2ecf20Sopenharmony_ci	int rc, val;
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci	if (phydev->interface != PHY_INTERFACE_MODE_SGMII &&
1128c2ecf20Sopenharmony_ci	    phydev->interface != PHY_INTERFACE_MODE_1000BASEX)
1138c2ecf20Sopenharmony_ci		return 0;
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci	/* Ensure proper interface mode is selected. */
1168c2ecf20Sopenharmony_ci	/* Disable RGMII mode */
1178c2ecf20Sopenharmony_ci	val = bcm54xx_auxctl_read(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
1188c2ecf20Sopenharmony_ci	if (val < 0)
1198c2ecf20Sopenharmony_ci		return val;
1208c2ecf20Sopenharmony_ci	val &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_EN;
1218c2ecf20Sopenharmony_ci	val |= MII_BCM54XX_AUXCTL_MISC_WREN;
1228c2ecf20Sopenharmony_ci	rc = bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
1238c2ecf20Sopenharmony_ci				  val);
1248c2ecf20Sopenharmony_ci	if (rc < 0)
1258c2ecf20Sopenharmony_ci		return rc;
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci	/* Select 1000BASE-X register set (primary SerDes) */
1288c2ecf20Sopenharmony_ci	val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_MODE);
1298c2ecf20Sopenharmony_ci	if (val < 0)
1308c2ecf20Sopenharmony_ci		return val;
1318c2ecf20Sopenharmony_ci	val |= BCM54XX_SHD_MODE_1000BX;
1328c2ecf20Sopenharmony_ci	rc = bcm_phy_write_shadow(phydev, BCM54XX_SHD_MODE, val);
1338c2ecf20Sopenharmony_ci	if (rc < 0)
1348c2ecf20Sopenharmony_ci		return rc;
1358c2ecf20Sopenharmony_ci
1368c2ecf20Sopenharmony_ci	/* Power down SerDes interface */
1378c2ecf20Sopenharmony_ci	rc = phy_set_bits(phydev, MII_BMCR, BMCR_PDOWN);
1388c2ecf20Sopenharmony_ci	if (rc < 0)
1398c2ecf20Sopenharmony_ci		return rc;
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci	/* Select proper interface mode */
1428c2ecf20Sopenharmony_ci	val &= ~BCM54XX_SHD_INTF_SEL_MASK;
1438c2ecf20Sopenharmony_ci	val |= phydev->interface == PHY_INTERFACE_MODE_SGMII ?
1448c2ecf20Sopenharmony_ci		BCM54XX_SHD_INTF_SEL_SGMII :
1458c2ecf20Sopenharmony_ci		BCM54XX_SHD_INTF_SEL_GBIC;
1468c2ecf20Sopenharmony_ci	rc = bcm_phy_write_shadow(phydev, BCM54XX_SHD_MODE, val);
1478c2ecf20Sopenharmony_ci	if (rc < 0)
1488c2ecf20Sopenharmony_ci		return rc;
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci	/* Power up SerDes interface */
1518c2ecf20Sopenharmony_ci	rc = phy_clear_bits(phydev, MII_BMCR, BMCR_PDOWN);
1528c2ecf20Sopenharmony_ci	if (rc < 0)
1538c2ecf20Sopenharmony_ci		return rc;
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ci	/* Select copper register set */
1568c2ecf20Sopenharmony_ci	val &= ~BCM54XX_SHD_MODE_1000BX;
1578c2ecf20Sopenharmony_ci	rc = bcm_phy_write_shadow(phydev, BCM54XX_SHD_MODE, val);
1588c2ecf20Sopenharmony_ci	if (rc < 0)
1598c2ecf20Sopenharmony_ci		return rc;
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci	/* Power up copper interface */
1628c2ecf20Sopenharmony_ci	return phy_clear_bits(phydev, MII_BMCR, BMCR_PDOWN);
1638c2ecf20Sopenharmony_ci}
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci/* Needs SMDSP clock enabled via bcm54xx_phydsp_config() */
1668c2ecf20Sopenharmony_cistatic int bcm50610_a0_workaround(struct phy_device *phydev)
1678c2ecf20Sopenharmony_ci{
1688c2ecf20Sopenharmony_ci	int err;
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci	err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_AADJ1CH0,
1718c2ecf20Sopenharmony_ci				MII_BCM54XX_EXP_AADJ1CH0_SWP_ABCD_OEN |
1728c2ecf20Sopenharmony_ci				MII_BCM54XX_EXP_AADJ1CH0_SWSEL_THPF);
1738c2ecf20Sopenharmony_ci	if (err < 0)
1748c2ecf20Sopenharmony_ci		return err;
1758c2ecf20Sopenharmony_ci
1768c2ecf20Sopenharmony_ci	err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_AADJ1CH3,
1778c2ecf20Sopenharmony_ci				MII_BCM54XX_EXP_AADJ1CH3_ADCCKADJ);
1788c2ecf20Sopenharmony_ci	if (err < 0)
1798c2ecf20Sopenharmony_ci		return err;
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_ci	err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP75,
1828c2ecf20Sopenharmony_ci				MII_BCM54XX_EXP_EXP75_VDACCTRL);
1838c2ecf20Sopenharmony_ci	if (err < 0)
1848c2ecf20Sopenharmony_ci		return err;
1858c2ecf20Sopenharmony_ci
1868c2ecf20Sopenharmony_ci	err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP96,
1878c2ecf20Sopenharmony_ci				MII_BCM54XX_EXP_EXP96_MYST);
1888c2ecf20Sopenharmony_ci	if (err < 0)
1898c2ecf20Sopenharmony_ci		return err;
1908c2ecf20Sopenharmony_ci
1918c2ecf20Sopenharmony_ci	err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP97,
1928c2ecf20Sopenharmony_ci				MII_BCM54XX_EXP_EXP97_MYST);
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci	return err;
1958c2ecf20Sopenharmony_ci}
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_cistatic int bcm54xx_phydsp_config(struct phy_device *phydev)
1988c2ecf20Sopenharmony_ci{
1998c2ecf20Sopenharmony_ci	int err, err2;
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci	/* Enable the SMDSP clock */
2028c2ecf20Sopenharmony_ci	err = bcm54xx_auxctl_write(phydev,
2038c2ecf20Sopenharmony_ci				   MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL,
2048c2ecf20Sopenharmony_ci				   MII_BCM54XX_AUXCTL_ACTL_SMDSP_ENA |
2058c2ecf20Sopenharmony_ci				   MII_BCM54XX_AUXCTL_ACTL_TX_6DB);
2068c2ecf20Sopenharmony_ci	if (err < 0)
2078c2ecf20Sopenharmony_ci		return err;
2088c2ecf20Sopenharmony_ci
2098c2ecf20Sopenharmony_ci	if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 ||
2108c2ecf20Sopenharmony_ci	    BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) {
2118c2ecf20Sopenharmony_ci		/* Clear bit 9 to fix a phy interop issue. */
2128c2ecf20Sopenharmony_ci		err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP08,
2138c2ecf20Sopenharmony_ci					MII_BCM54XX_EXP_EXP08_RJCT_2MHZ);
2148c2ecf20Sopenharmony_ci		if (err < 0)
2158c2ecf20Sopenharmony_ci			goto error;
2168c2ecf20Sopenharmony_ci
2178c2ecf20Sopenharmony_ci		if (phydev->drv->phy_id == PHY_ID_BCM50610) {
2188c2ecf20Sopenharmony_ci			err = bcm50610_a0_workaround(phydev);
2198c2ecf20Sopenharmony_ci			if (err < 0)
2208c2ecf20Sopenharmony_ci				goto error;
2218c2ecf20Sopenharmony_ci		}
2228c2ecf20Sopenharmony_ci	}
2238c2ecf20Sopenharmony_ci
2248c2ecf20Sopenharmony_ci	if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM57780) {
2258c2ecf20Sopenharmony_ci		int val;
2268c2ecf20Sopenharmony_ci
2278c2ecf20Sopenharmony_ci		val = bcm_phy_read_exp(phydev, MII_BCM54XX_EXP_EXP75);
2288c2ecf20Sopenharmony_ci		if (val < 0)
2298c2ecf20Sopenharmony_ci			goto error;
2308c2ecf20Sopenharmony_ci
2318c2ecf20Sopenharmony_ci		val |= MII_BCM54XX_EXP_EXP75_CM_OSC;
2328c2ecf20Sopenharmony_ci		err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP75, val);
2338c2ecf20Sopenharmony_ci	}
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_cierror:
2368c2ecf20Sopenharmony_ci	/* Disable the SMDSP clock */
2378c2ecf20Sopenharmony_ci	err2 = bcm54xx_auxctl_write(phydev,
2388c2ecf20Sopenharmony_ci				    MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL,
2398c2ecf20Sopenharmony_ci				    MII_BCM54XX_AUXCTL_ACTL_TX_6DB);
2408c2ecf20Sopenharmony_ci
2418c2ecf20Sopenharmony_ci	/* Return the first error reported. */
2428c2ecf20Sopenharmony_ci	return err ? err : err2;
2438c2ecf20Sopenharmony_ci}
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_cistatic void bcm54xx_adjust_rxrefclk(struct phy_device *phydev)
2468c2ecf20Sopenharmony_ci{
2478c2ecf20Sopenharmony_ci	u32 orig;
2488c2ecf20Sopenharmony_ci	int val;
2498c2ecf20Sopenharmony_ci	bool clk125en = true;
2508c2ecf20Sopenharmony_ci
2518c2ecf20Sopenharmony_ci	/* Abort if we are using an untested phy. */
2528c2ecf20Sopenharmony_ci	if (BRCM_PHY_MODEL(phydev) != PHY_ID_BCM57780 &&
2538c2ecf20Sopenharmony_ci	    BRCM_PHY_MODEL(phydev) != PHY_ID_BCM50610 &&
2548c2ecf20Sopenharmony_ci	    BRCM_PHY_MODEL(phydev) != PHY_ID_BCM50610M &&
2558c2ecf20Sopenharmony_ci	    BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54810 &&
2568c2ecf20Sopenharmony_ci	    BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54811)
2578c2ecf20Sopenharmony_ci		return;
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ci	val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_SCR3);
2608c2ecf20Sopenharmony_ci	if (val < 0)
2618c2ecf20Sopenharmony_ci		return;
2628c2ecf20Sopenharmony_ci
2638c2ecf20Sopenharmony_ci	orig = val;
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ci	if ((BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 ||
2668c2ecf20Sopenharmony_ci	     BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) &&
2678c2ecf20Sopenharmony_ci	    BRCM_PHY_REV(phydev) >= 0x3) {
2688c2ecf20Sopenharmony_ci		/*
2698c2ecf20Sopenharmony_ci		 * Here, bit 0 _disables_ CLK125 when set.
2708c2ecf20Sopenharmony_ci		 * This bit is set by default.
2718c2ecf20Sopenharmony_ci		 */
2728c2ecf20Sopenharmony_ci		clk125en = false;
2738c2ecf20Sopenharmony_ci	} else {
2748c2ecf20Sopenharmony_ci		if (phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED) {
2758c2ecf20Sopenharmony_ci			if (BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54811) {
2768c2ecf20Sopenharmony_ci				/* Here, bit 0 _enables_ CLK125 when set */
2778c2ecf20Sopenharmony_ci				val &= ~BCM54XX_SHD_SCR3_DEF_CLK125;
2788c2ecf20Sopenharmony_ci			}
2798c2ecf20Sopenharmony_ci			clk125en = false;
2808c2ecf20Sopenharmony_ci		}
2818c2ecf20Sopenharmony_ci	}
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ci	if (!clk125en || (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE))
2848c2ecf20Sopenharmony_ci		val &= ~BCM54XX_SHD_SCR3_DLLAPD_DIS;
2858c2ecf20Sopenharmony_ci	else
2868c2ecf20Sopenharmony_ci		val |= BCM54XX_SHD_SCR3_DLLAPD_DIS;
2878c2ecf20Sopenharmony_ci
2888c2ecf20Sopenharmony_ci	if (phydev->dev_flags & PHY_BRCM_DIS_TXCRXC_NOENRGY) {
2898c2ecf20Sopenharmony_ci		if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810 ||
2908c2ecf20Sopenharmony_ci		    BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54811)
2918c2ecf20Sopenharmony_ci			val |= BCM54810_SHD_SCR3_TRDDAPD;
2928c2ecf20Sopenharmony_ci		else
2938c2ecf20Sopenharmony_ci			val |= BCM54XX_SHD_SCR3_TRDDAPD;
2948c2ecf20Sopenharmony_ci	}
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_ci	if (orig != val)
2978c2ecf20Sopenharmony_ci		bcm_phy_write_shadow(phydev, BCM54XX_SHD_SCR3, val);
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_ci	val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_APD);
3008c2ecf20Sopenharmony_ci	if (val < 0)
3018c2ecf20Sopenharmony_ci		return;
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci	orig = val;
3048c2ecf20Sopenharmony_ci
3058c2ecf20Sopenharmony_ci	if (!clk125en || (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE))
3068c2ecf20Sopenharmony_ci		val |= BCM54XX_SHD_APD_EN;
3078c2ecf20Sopenharmony_ci	else
3088c2ecf20Sopenharmony_ci		val &= ~BCM54XX_SHD_APD_EN;
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_ci	if (orig != val)
3118c2ecf20Sopenharmony_ci		bcm_phy_write_shadow(phydev, BCM54XX_SHD_APD, val);
3128c2ecf20Sopenharmony_ci}
3138c2ecf20Sopenharmony_ci
3148c2ecf20Sopenharmony_cistatic int bcm54xx_config_init(struct phy_device *phydev)
3158c2ecf20Sopenharmony_ci{
3168c2ecf20Sopenharmony_ci	int reg, err, val;
3178c2ecf20Sopenharmony_ci
3188c2ecf20Sopenharmony_ci	reg = phy_read(phydev, MII_BCM54XX_ECR);
3198c2ecf20Sopenharmony_ci	if (reg < 0)
3208c2ecf20Sopenharmony_ci		return reg;
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_ci	/* Mask interrupts globally.  */
3238c2ecf20Sopenharmony_ci	reg |= MII_BCM54XX_ECR_IM;
3248c2ecf20Sopenharmony_ci	err = phy_write(phydev, MII_BCM54XX_ECR, reg);
3258c2ecf20Sopenharmony_ci	if (err < 0)
3268c2ecf20Sopenharmony_ci		return err;
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci	/* Unmask events we are interested in.  */
3298c2ecf20Sopenharmony_ci	reg = ~(MII_BCM54XX_INT_DUPLEX |
3308c2ecf20Sopenharmony_ci		MII_BCM54XX_INT_SPEED |
3318c2ecf20Sopenharmony_ci		MII_BCM54XX_INT_LINK);
3328c2ecf20Sopenharmony_ci	err = phy_write(phydev, MII_BCM54XX_IMR, reg);
3338c2ecf20Sopenharmony_ci	if (err < 0)
3348c2ecf20Sopenharmony_ci		return err;
3358c2ecf20Sopenharmony_ci
3368c2ecf20Sopenharmony_ci	if ((BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 ||
3378c2ecf20Sopenharmony_ci	     BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) &&
3388c2ecf20Sopenharmony_ci	    (phydev->dev_flags & PHY_BRCM_CLEAR_RGMII_MODE))
3398c2ecf20Sopenharmony_ci		bcm_phy_write_shadow(phydev, BCM54XX_SHD_RGMII_MODE, 0);
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_ci	bcm54xx_adjust_rxrefclk(phydev);
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ci	switch (BRCM_PHY_MODEL(phydev)) {
3448c2ecf20Sopenharmony_ci	case PHY_ID_BCM50610:
3458c2ecf20Sopenharmony_ci	case PHY_ID_BCM50610M:
3468c2ecf20Sopenharmony_ci		err = bcm54xx_config_clock_delay(phydev);
3478c2ecf20Sopenharmony_ci		break;
3488c2ecf20Sopenharmony_ci	case PHY_ID_BCM54210E:
3498c2ecf20Sopenharmony_ci		err = bcm54210e_config_init(phydev);
3508c2ecf20Sopenharmony_ci		break;
3518c2ecf20Sopenharmony_ci	case PHY_ID_BCM54612E:
3528c2ecf20Sopenharmony_ci		err = bcm54612e_config_init(phydev);
3538c2ecf20Sopenharmony_ci		break;
3548c2ecf20Sopenharmony_ci	case PHY_ID_BCM54616S:
3558c2ecf20Sopenharmony_ci		err = bcm54616s_config_init(phydev);
3568c2ecf20Sopenharmony_ci		break;
3578c2ecf20Sopenharmony_ci	case PHY_ID_BCM54810:
3588c2ecf20Sopenharmony_ci		/* For BCM54810, we need to disable BroadR-Reach function */
3598c2ecf20Sopenharmony_ci		val = bcm_phy_read_exp(phydev,
3608c2ecf20Sopenharmony_ci				       BCM54810_EXP_BROADREACH_LRE_MISC_CTL);
3618c2ecf20Sopenharmony_ci		val &= ~BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN;
3628c2ecf20Sopenharmony_ci		err = bcm_phy_write_exp(phydev,
3638c2ecf20Sopenharmony_ci					BCM54810_EXP_BROADREACH_LRE_MISC_CTL,
3648c2ecf20Sopenharmony_ci					val);
3658c2ecf20Sopenharmony_ci		break;
3668c2ecf20Sopenharmony_ci	}
3678c2ecf20Sopenharmony_ci	if (err)
3688c2ecf20Sopenharmony_ci		return err;
3698c2ecf20Sopenharmony_ci
3708c2ecf20Sopenharmony_ci	bcm54xx_phydsp_config(phydev);
3718c2ecf20Sopenharmony_ci
3728c2ecf20Sopenharmony_ci	/* Encode link speed into LED1 and LED3 pair (green/amber).
3738c2ecf20Sopenharmony_ci	 * Also flash these two LEDs on activity. This means configuring
3748c2ecf20Sopenharmony_ci	 * them for MULTICOLOR and encoding link/activity into them.
3758c2ecf20Sopenharmony_ci	 */
3768c2ecf20Sopenharmony_ci	val = BCM5482_SHD_LEDS1_LED1(BCM_LED_SRC_MULTICOLOR1) |
3778c2ecf20Sopenharmony_ci		BCM5482_SHD_LEDS1_LED3(BCM_LED_SRC_MULTICOLOR1);
3788c2ecf20Sopenharmony_ci	bcm_phy_write_shadow(phydev, BCM5482_SHD_LEDS1, val);
3798c2ecf20Sopenharmony_ci
3808c2ecf20Sopenharmony_ci	val = BCM_LED_MULTICOLOR_IN_PHASE |
3818c2ecf20Sopenharmony_ci		BCM5482_SHD_LEDS1_LED1(BCM_LED_MULTICOLOR_LINK_ACT) |
3828c2ecf20Sopenharmony_ci		BCM5482_SHD_LEDS1_LED3(BCM_LED_MULTICOLOR_LINK_ACT);
3838c2ecf20Sopenharmony_ci	bcm_phy_write_exp(phydev, BCM_EXP_MULTICOLOR, val);
3848c2ecf20Sopenharmony_ci
3858c2ecf20Sopenharmony_ci	return 0;
3868c2ecf20Sopenharmony_ci}
3878c2ecf20Sopenharmony_ci
3888c2ecf20Sopenharmony_cistatic int bcm54xx_resume(struct phy_device *phydev)
3898c2ecf20Sopenharmony_ci{
3908c2ecf20Sopenharmony_ci	int ret;
3918c2ecf20Sopenharmony_ci
3928c2ecf20Sopenharmony_ci	/* Writes to register other than BMCR would be ignored
3938c2ecf20Sopenharmony_ci	 * unless we clear the PDOWN bit first
3948c2ecf20Sopenharmony_ci	 */
3958c2ecf20Sopenharmony_ci	ret = genphy_resume(phydev);
3968c2ecf20Sopenharmony_ci	if (ret < 0)
3978c2ecf20Sopenharmony_ci		return ret;
3988c2ecf20Sopenharmony_ci
3998c2ecf20Sopenharmony_ci	/* Upon exiting power down, the PHY remains in an internal reset state
4008c2ecf20Sopenharmony_ci	 * for 40us
4018c2ecf20Sopenharmony_ci	 */
4028c2ecf20Sopenharmony_ci	fsleep(40);
4038c2ecf20Sopenharmony_ci
4048c2ecf20Sopenharmony_ci	return bcm54xx_config_init(phydev);
4058c2ecf20Sopenharmony_ci}
4068c2ecf20Sopenharmony_ci
4078c2ecf20Sopenharmony_cistatic int bcm54810_read_mmd(struct phy_device *phydev, int devnum, u16 regnum)
4088c2ecf20Sopenharmony_ci{
4098c2ecf20Sopenharmony_ci	return -EOPNOTSUPP;
4108c2ecf20Sopenharmony_ci}
4118c2ecf20Sopenharmony_ci
4128c2ecf20Sopenharmony_cistatic int bcm54810_write_mmd(struct phy_device *phydev, int devnum, u16 regnum,
4138c2ecf20Sopenharmony_ci			      u16 val)
4148c2ecf20Sopenharmony_ci{
4158c2ecf20Sopenharmony_ci	return -EOPNOTSUPP;
4168c2ecf20Sopenharmony_ci}
4178c2ecf20Sopenharmony_ci
4188c2ecf20Sopenharmony_cistatic int bcm54811_config_init(struct phy_device *phydev)
4198c2ecf20Sopenharmony_ci{
4208c2ecf20Sopenharmony_ci	int err, reg;
4218c2ecf20Sopenharmony_ci
4228c2ecf20Sopenharmony_ci	/* Disable BroadR-Reach function. */
4238c2ecf20Sopenharmony_ci	reg = bcm_phy_read_exp(phydev, BCM54810_EXP_BROADREACH_LRE_MISC_CTL);
4248c2ecf20Sopenharmony_ci	reg &= ~BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN;
4258c2ecf20Sopenharmony_ci	err = bcm_phy_write_exp(phydev, BCM54810_EXP_BROADREACH_LRE_MISC_CTL,
4268c2ecf20Sopenharmony_ci				reg);
4278c2ecf20Sopenharmony_ci	if (err < 0)
4288c2ecf20Sopenharmony_ci		return err;
4298c2ecf20Sopenharmony_ci
4308c2ecf20Sopenharmony_ci	err = bcm54xx_config_init(phydev);
4318c2ecf20Sopenharmony_ci
4328c2ecf20Sopenharmony_ci	/* Enable CLK125 MUX on LED4 if ref clock is enabled. */
4338c2ecf20Sopenharmony_ci	if (!(phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED)) {
4348c2ecf20Sopenharmony_ci		reg = bcm_phy_read_exp(phydev, BCM54612E_EXP_SPARE0);
4358c2ecf20Sopenharmony_ci		err = bcm_phy_write_exp(phydev, BCM54612E_EXP_SPARE0,
4368c2ecf20Sopenharmony_ci					BCM54612E_LED4_CLK125OUT_EN | reg);
4378c2ecf20Sopenharmony_ci		if (err < 0)
4388c2ecf20Sopenharmony_ci			return err;
4398c2ecf20Sopenharmony_ci	}
4408c2ecf20Sopenharmony_ci
4418c2ecf20Sopenharmony_ci	return err;
4428c2ecf20Sopenharmony_ci}
4438c2ecf20Sopenharmony_ci
4448c2ecf20Sopenharmony_cistatic int bcm5482_config_init(struct phy_device *phydev)
4458c2ecf20Sopenharmony_ci{
4468c2ecf20Sopenharmony_ci	int err, reg;
4478c2ecf20Sopenharmony_ci
4488c2ecf20Sopenharmony_ci	err = bcm54xx_config_init(phydev);
4498c2ecf20Sopenharmony_ci
4508c2ecf20Sopenharmony_ci	if (phydev->dev_flags & PHY_BCM_FLAGS_MODE_1000BX) {
4518c2ecf20Sopenharmony_ci		/*
4528c2ecf20Sopenharmony_ci		 * Enable secondary SerDes and its use as an LED source
4538c2ecf20Sopenharmony_ci		 */
4548c2ecf20Sopenharmony_ci		reg = bcm_phy_read_shadow(phydev, BCM5482_SHD_SSD);
4558c2ecf20Sopenharmony_ci		bcm_phy_write_shadow(phydev, BCM5482_SHD_SSD,
4568c2ecf20Sopenharmony_ci				     reg |
4578c2ecf20Sopenharmony_ci				     BCM5482_SHD_SSD_LEDM |
4588c2ecf20Sopenharmony_ci				     BCM5482_SHD_SSD_EN);
4598c2ecf20Sopenharmony_ci
4608c2ecf20Sopenharmony_ci		/*
4618c2ecf20Sopenharmony_ci		 * Enable SGMII slave mode and auto-detection
4628c2ecf20Sopenharmony_ci		 */
4638c2ecf20Sopenharmony_ci		reg = BCM5482_SSD_SGMII_SLAVE | MII_BCM54XX_EXP_SEL_SSD;
4648c2ecf20Sopenharmony_ci		err = bcm_phy_read_exp(phydev, reg);
4658c2ecf20Sopenharmony_ci		if (err < 0)
4668c2ecf20Sopenharmony_ci			return err;
4678c2ecf20Sopenharmony_ci		err = bcm_phy_write_exp(phydev, reg, err |
4688c2ecf20Sopenharmony_ci					BCM5482_SSD_SGMII_SLAVE_EN |
4698c2ecf20Sopenharmony_ci					BCM5482_SSD_SGMII_SLAVE_AD);
4708c2ecf20Sopenharmony_ci		if (err < 0)
4718c2ecf20Sopenharmony_ci			return err;
4728c2ecf20Sopenharmony_ci
4738c2ecf20Sopenharmony_ci		/*
4748c2ecf20Sopenharmony_ci		 * Disable secondary SerDes powerdown
4758c2ecf20Sopenharmony_ci		 */
4768c2ecf20Sopenharmony_ci		reg = BCM5482_SSD_1000BX_CTL | MII_BCM54XX_EXP_SEL_SSD;
4778c2ecf20Sopenharmony_ci		err = bcm_phy_read_exp(phydev, reg);
4788c2ecf20Sopenharmony_ci		if (err < 0)
4798c2ecf20Sopenharmony_ci			return err;
4808c2ecf20Sopenharmony_ci		err = bcm_phy_write_exp(phydev, reg,
4818c2ecf20Sopenharmony_ci					err & ~BCM5482_SSD_1000BX_CTL_PWRDOWN);
4828c2ecf20Sopenharmony_ci		if (err < 0)
4838c2ecf20Sopenharmony_ci			return err;
4848c2ecf20Sopenharmony_ci
4858c2ecf20Sopenharmony_ci		/*
4868c2ecf20Sopenharmony_ci		 * Select 1000BASE-X register set (primary SerDes)
4878c2ecf20Sopenharmony_ci		 */
4888c2ecf20Sopenharmony_ci		reg = bcm_phy_read_shadow(phydev, BCM54XX_SHD_MODE);
4898c2ecf20Sopenharmony_ci		bcm_phy_write_shadow(phydev, BCM54XX_SHD_MODE,
4908c2ecf20Sopenharmony_ci				     reg | BCM54XX_SHD_MODE_1000BX);
4918c2ecf20Sopenharmony_ci
4928c2ecf20Sopenharmony_ci		/*
4938c2ecf20Sopenharmony_ci		 * LED1=ACTIVITYLED, LED3=LINKSPD[2]
4948c2ecf20Sopenharmony_ci		 * (Use LED1 as secondary SerDes ACTIVITY LED)
4958c2ecf20Sopenharmony_ci		 */
4968c2ecf20Sopenharmony_ci		bcm_phy_write_shadow(phydev, BCM5482_SHD_LEDS1,
4978c2ecf20Sopenharmony_ci			BCM5482_SHD_LEDS1_LED1(BCM_LED_SRC_ACTIVITYLED) |
4988c2ecf20Sopenharmony_ci			BCM5482_SHD_LEDS1_LED3(BCM_LED_SRC_LINKSPD2));
4998c2ecf20Sopenharmony_ci
5008c2ecf20Sopenharmony_ci		/*
5018c2ecf20Sopenharmony_ci		 * Auto-negotiation doesn't seem to work quite right
5028c2ecf20Sopenharmony_ci		 * in this mode, so we disable it and force it to the
5038c2ecf20Sopenharmony_ci		 * right speed/duplex setting.  Only 'link status'
5048c2ecf20Sopenharmony_ci		 * is important.
5058c2ecf20Sopenharmony_ci		 */
5068c2ecf20Sopenharmony_ci		phydev->autoneg = AUTONEG_DISABLE;
5078c2ecf20Sopenharmony_ci		phydev->speed = SPEED_1000;
5088c2ecf20Sopenharmony_ci		phydev->duplex = DUPLEX_FULL;
5098c2ecf20Sopenharmony_ci	}
5108c2ecf20Sopenharmony_ci
5118c2ecf20Sopenharmony_ci	return err;
5128c2ecf20Sopenharmony_ci}
5138c2ecf20Sopenharmony_ci
5148c2ecf20Sopenharmony_cistatic int bcm5482_read_status(struct phy_device *phydev)
5158c2ecf20Sopenharmony_ci{
5168c2ecf20Sopenharmony_ci	int err;
5178c2ecf20Sopenharmony_ci
5188c2ecf20Sopenharmony_ci	err = genphy_read_status(phydev);
5198c2ecf20Sopenharmony_ci
5208c2ecf20Sopenharmony_ci	if (phydev->dev_flags & PHY_BCM_FLAGS_MODE_1000BX) {
5218c2ecf20Sopenharmony_ci		/*
5228c2ecf20Sopenharmony_ci		 * Only link status matters for 1000Base-X mode, so force
5238c2ecf20Sopenharmony_ci		 * 1000 Mbit/s full-duplex status
5248c2ecf20Sopenharmony_ci		 */
5258c2ecf20Sopenharmony_ci		if (phydev->link) {
5268c2ecf20Sopenharmony_ci			phydev->speed = SPEED_1000;
5278c2ecf20Sopenharmony_ci			phydev->duplex = DUPLEX_FULL;
5288c2ecf20Sopenharmony_ci		}
5298c2ecf20Sopenharmony_ci	}
5308c2ecf20Sopenharmony_ci
5318c2ecf20Sopenharmony_ci	return err;
5328c2ecf20Sopenharmony_ci}
5338c2ecf20Sopenharmony_ci
5348c2ecf20Sopenharmony_cistatic int bcm5481_config_aneg(struct phy_device *phydev)
5358c2ecf20Sopenharmony_ci{
5368c2ecf20Sopenharmony_ci	struct device_node *np = phydev->mdio.dev.of_node;
5378c2ecf20Sopenharmony_ci	int ret;
5388c2ecf20Sopenharmony_ci
5398c2ecf20Sopenharmony_ci	/* Aneg firstly. */
5408c2ecf20Sopenharmony_ci	ret = genphy_config_aneg(phydev);
5418c2ecf20Sopenharmony_ci
5428c2ecf20Sopenharmony_ci	/* Then we can set up the delay. */
5438c2ecf20Sopenharmony_ci	bcm54xx_config_clock_delay(phydev);
5448c2ecf20Sopenharmony_ci
5458c2ecf20Sopenharmony_ci	if (of_property_read_bool(np, "enet-phy-lane-swap")) {
5468c2ecf20Sopenharmony_ci		/* Lane Swap - Undocumented register...magic! */
5478c2ecf20Sopenharmony_ci		ret = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_SEL_ER + 0x9,
5488c2ecf20Sopenharmony_ci					0x11B);
5498c2ecf20Sopenharmony_ci		if (ret < 0)
5508c2ecf20Sopenharmony_ci			return ret;
5518c2ecf20Sopenharmony_ci	}
5528c2ecf20Sopenharmony_ci
5538c2ecf20Sopenharmony_ci	return ret;
5548c2ecf20Sopenharmony_ci}
5558c2ecf20Sopenharmony_ci
5568c2ecf20Sopenharmony_cistatic int bcm54616s_probe(struct phy_device *phydev)
5578c2ecf20Sopenharmony_ci{
5588c2ecf20Sopenharmony_ci	int val;
5598c2ecf20Sopenharmony_ci
5608c2ecf20Sopenharmony_ci	val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_MODE);
5618c2ecf20Sopenharmony_ci	if (val < 0)
5628c2ecf20Sopenharmony_ci		return val;
5638c2ecf20Sopenharmony_ci
5648c2ecf20Sopenharmony_ci	/* The PHY is strapped in RGMII-fiber mode when INTERF_SEL[1:0]
5658c2ecf20Sopenharmony_ci	 * is 01b, and the link between PHY and its link partner can be
5668c2ecf20Sopenharmony_ci	 * either 1000Base-X or 100Base-FX.
5678c2ecf20Sopenharmony_ci	 * RGMII-1000Base-X is properly supported, but RGMII-100Base-FX
5688c2ecf20Sopenharmony_ci	 * support is still missing as of now.
5698c2ecf20Sopenharmony_ci	 */
5708c2ecf20Sopenharmony_ci	if ((val & BCM54XX_SHD_INTF_SEL_MASK) == BCM54XX_SHD_INTF_SEL_RGMII) {
5718c2ecf20Sopenharmony_ci		val = bcm_phy_read_shadow(phydev, BCM54616S_SHD_100FX_CTRL);
5728c2ecf20Sopenharmony_ci		if (val < 0)
5738c2ecf20Sopenharmony_ci			return val;
5748c2ecf20Sopenharmony_ci
5758c2ecf20Sopenharmony_ci		/* Bit 0 of the SerDes 100-FX Control register, when set
5768c2ecf20Sopenharmony_ci		 * to 1, sets the MII/RGMII -> 100BASE-FX configuration.
5778c2ecf20Sopenharmony_ci		 * When this bit is set to 0, it sets the GMII/RGMII ->
5788c2ecf20Sopenharmony_ci		 * 1000BASE-X configuration.
5798c2ecf20Sopenharmony_ci		 */
5808c2ecf20Sopenharmony_ci		if (!(val & BCM54616S_100FX_MODE))
5818c2ecf20Sopenharmony_ci			phydev->dev_flags |= PHY_BCM_FLAGS_MODE_1000BX;
5828c2ecf20Sopenharmony_ci
5838c2ecf20Sopenharmony_ci		phydev->port = PORT_FIBRE;
5848c2ecf20Sopenharmony_ci	}
5858c2ecf20Sopenharmony_ci
5868c2ecf20Sopenharmony_ci	return 0;
5878c2ecf20Sopenharmony_ci}
5888c2ecf20Sopenharmony_ci
5898c2ecf20Sopenharmony_cistatic int bcm54616s_config_aneg(struct phy_device *phydev)
5908c2ecf20Sopenharmony_ci{
5918c2ecf20Sopenharmony_ci	int ret;
5928c2ecf20Sopenharmony_ci
5938c2ecf20Sopenharmony_ci	/* Aneg firstly. */
5948c2ecf20Sopenharmony_ci	if (phydev->dev_flags & PHY_BCM_FLAGS_MODE_1000BX)
5958c2ecf20Sopenharmony_ci		ret = genphy_c37_config_aneg(phydev);
5968c2ecf20Sopenharmony_ci	else
5978c2ecf20Sopenharmony_ci		ret = genphy_config_aneg(phydev);
5988c2ecf20Sopenharmony_ci
5998c2ecf20Sopenharmony_ci	/* Then we can set up the delay. */
6008c2ecf20Sopenharmony_ci	bcm54xx_config_clock_delay(phydev);
6018c2ecf20Sopenharmony_ci
6028c2ecf20Sopenharmony_ci	return ret;
6038c2ecf20Sopenharmony_ci}
6048c2ecf20Sopenharmony_ci
6058c2ecf20Sopenharmony_cistatic int bcm54616s_read_status(struct phy_device *phydev)
6068c2ecf20Sopenharmony_ci{
6078c2ecf20Sopenharmony_ci	int err;
6088c2ecf20Sopenharmony_ci
6098c2ecf20Sopenharmony_ci	if (phydev->dev_flags & PHY_BCM_FLAGS_MODE_1000BX)
6108c2ecf20Sopenharmony_ci		err = genphy_c37_read_status(phydev);
6118c2ecf20Sopenharmony_ci	else
6128c2ecf20Sopenharmony_ci		err = genphy_read_status(phydev);
6138c2ecf20Sopenharmony_ci
6148c2ecf20Sopenharmony_ci	return err;
6158c2ecf20Sopenharmony_ci}
6168c2ecf20Sopenharmony_ci
6178c2ecf20Sopenharmony_cistatic int brcm_phy_setbits(struct phy_device *phydev, int reg, int set)
6188c2ecf20Sopenharmony_ci{
6198c2ecf20Sopenharmony_ci	int val;
6208c2ecf20Sopenharmony_ci
6218c2ecf20Sopenharmony_ci	val = phy_read(phydev, reg);
6228c2ecf20Sopenharmony_ci	if (val < 0)
6238c2ecf20Sopenharmony_ci		return val;
6248c2ecf20Sopenharmony_ci
6258c2ecf20Sopenharmony_ci	return phy_write(phydev, reg, val | set);
6268c2ecf20Sopenharmony_ci}
6278c2ecf20Sopenharmony_ci
6288c2ecf20Sopenharmony_cistatic int brcm_fet_config_init(struct phy_device *phydev)
6298c2ecf20Sopenharmony_ci{
6308c2ecf20Sopenharmony_ci	int reg, err, err2, brcmtest;
6318c2ecf20Sopenharmony_ci
6328c2ecf20Sopenharmony_ci	/* Reset the PHY to bring it to a known state. */
6338c2ecf20Sopenharmony_ci	err = phy_write(phydev, MII_BMCR, BMCR_RESET);
6348c2ecf20Sopenharmony_ci	if (err < 0)
6358c2ecf20Sopenharmony_ci		return err;
6368c2ecf20Sopenharmony_ci
6378c2ecf20Sopenharmony_ci	/* The datasheet indicates the PHY needs up to 1us to complete a reset,
6388c2ecf20Sopenharmony_ci	 * build some slack here.
6398c2ecf20Sopenharmony_ci	 */
6408c2ecf20Sopenharmony_ci	usleep_range(1000, 2000);
6418c2ecf20Sopenharmony_ci
6428c2ecf20Sopenharmony_ci	/* The PHY requires 65 MDC clock cycles to complete a write operation
6438c2ecf20Sopenharmony_ci	 * and turnaround the line properly.
6448c2ecf20Sopenharmony_ci	 *
6458c2ecf20Sopenharmony_ci	 * We ignore -EIO here as the MDIO controller (e.g.: mdio-bcm-unimac)
6468c2ecf20Sopenharmony_ci	 * may flag the lack of turn-around as a read failure. This is
6478c2ecf20Sopenharmony_ci	 * particularly true with this combination since the MDIO controller
6488c2ecf20Sopenharmony_ci	 * only used 64 MDC cycles. This is not a critical failure in this
6498c2ecf20Sopenharmony_ci	 * specific case and it has no functional impact otherwise, so we let
6508c2ecf20Sopenharmony_ci	 * that one go through. If there is a genuine bus error, the next read
6518c2ecf20Sopenharmony_ci	 * of MII_BRCM_FET_INTREG will error out.
6528c2ecf20Sopenharmony_ci	 */
6538c2ecf20Sopenharmony_ci	err = phy_read(phydev, MII_BMCR);
6548c2ecf20Sopenharmony_ci	if (err < 0 && err != -EIO)
6558c2ecf20Sopenharmony_ci		return err;
6568c2ecf20Sopenharmony_ci
6578c2ecf20Sopenharmony_ci	reg = phy_read(phydev, MII_BRCM_FET_INTREG);
6588c2ecf20Sopenharmony_ci	if (reg < 0)
6598c2ecf20Sopenharmony_ci		return reg;
6608c2ecf20Sopenharmony_ci
6618c2ecf20Sopenharmony_ci	/* Unmask events we are interested in and mask interrupts globally. */
6628c2ecf20Sopenharmony_ci	reg = MII_BRCM_FET_IR_DUPLEX_EN |
6638c2ecf20Sopenharmony_ci	      MII_BRCM_FET_IR_SPEED_EN |
6648c2ecf20Sopenharmony_ci	      MII_BRCM_FET_IR_LINK_EN |
6658c2ecf20Sopenharmony_ci	      MII_BRCM_FET_IR_ENABLE |
6668c2ecf20Sopenharmony_ci	      MII_BRCM_FET_IR_MASK;
6678c2ecf20Sopenharmony_ci
6688c2ecf20Sopenharmony_ci	err = phy_write(phydev, MII_BRCM_FET_INTREG, reg);
6698c2ecf20Sopenharmony_ci	if (err < 0)
6708c2ecf20Sopenharmony_ci		return err;
6718c2ecf20Sopenharmony_ci
6728c2ecf20Sopenharmony_ci	/* Enable shadow register access */
6738c2ecf20Sopenharmony_ci	brcmtest = phy_read(phydev, MII_BRCM_FET_BRCMTEST);
6748c2ecf20Sopenharmony_ci	if (brcmtest < 0)
6758c2ecf20Sopenharmony_ci		return brcmtest;
6768c2ecf20Sopenharmony_ci
6778c2ecf20Sopenharmony_ci	reg = brcmtest | MII_BRCM_FET_BT_SRE;
6788c2ecf20Sopenharmony_ci
6798c2ecf20Sopenharmony_ci	err = phy_write(phydev, MII_BRCM_FET_BRCMTEST, reg);
6808c2ecf20Sopenharmony_ci	if (err < 0)
6818c2ecf20Sopenharmony_ci		return err;
6828c2ecf20Sopenharmony_ci
6838c2ecf20Sopenharmony_ci	/* Set the LED mode */
6848c2ecf20Sopenharmony_ci	reg = phy_read(phydev, MII_BRCM_FET_SHDW_AUXMODE4);
6858c2ecf20Sopenharmony_ci	if (reg < 0) {
6868c2ecf20Sopenharmony_ci		err = reg;
6878c2ecf20Sopenharmony_ci		goto done;
6888c2ecf20Sopenharmony_ci	}
6898c2ecf20Sopenharmony_ci
6908c2ecf20Sopenharmony_ci	reg &= ~MII_BRCM_FET_SHDW_AM4_LED_MASK;
6918c2ecf20Sopenharmony_ci	reg |= MII_BRCM_FET_SHDW_AM4_LED_MODE1;
6928c2ecf20Sopenharmony_ci
6938c2ecf20Sopenharmony_ci	err = phy_write(phydev, MII_BRCM_FET_SHDW_AUXMODE4, reg);
6948c2ecf20Sopenharmony_ci	if (err < 0)
6958c2ecf20Sopenharmony_ci		goto done;
6968c2ecf20Sopenharmony_ci
6978c2ecf20Sopenharmony_ci	/* Enable auto MDIX */
6988c2ecf20Sopenharmony_ci	err = brcm_phy_setbits(phydev, MII_BRCM_FET_SHDW_MISCCTRL,
6998c2ecf20Sopenharmony_ci				       MII_BRCM_FET_SHDW_MC_FAME);
7008c2ecf20Sopenharmony_ci	if (err < 0)
7018c2ecf20Sopenharmony_ci		goto done;
7028c2ecf20Sopenharmony_ci
7038c2ecf20Sopenharmony_ci	if (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE) {
7048c2ecf20Sopenharmony_ci		/* Enable auto power down */
7058c2ecf20Sopenharmony_ci		err = brcm_phy_setbits(phydev, MII_BRCM_FET_SHDW_AUXSTAT2,
7068c2ecf20Sopenharmony_ci					       MII_BRCM_FET_SHDW_AS2_APDE);
7078c2ecf20Sopenharmony_ci	}
7088c2ecf20Sopenharmony_ci
7098c2ecf20Sopenharmony_cidone:
7108c2ecf20Sopenharmony_ci	/* Disable shadow register access */
7118c2ecf20Sopenharmony_ci	err2 = phy_write(phydev, MII_BRCM_FET_BRCMTEST, brcmtest);
7128c2ecf20Sopenharmony_ci	if (!err)
7138c2ecf20Sopenharmony_ci		err = err2;
7148c2ecf20Sopenharmony_ci
7158c2ecf20Sopenharmony_ci	return err;
7168c2ecf20Sopenharmony_ci}
7178c2ecf20Sopenharmony_ci
7188c2ecf20Sopenharmony_cistatic int brcm_fet_ack_interrupt(struct phy_device *phydev)
7198c2ecf20Sopenharmony_ci{
7208c2ecf20Sopenharmony_ci	int reg;
7218c2ecf20Sopenharmony_ci
7228c2ecf20Sopenharmony_ci	/* Clear pending interrupts.  */
7238c2ecf20Sopenharmony_ci	reg = phy_read(phydev, MII_BRCM_FET_INTREG);
7248c2ecf20Sopenharmony_ci	if (reg < 0)
7258c2ecf20Sopenharmony_ci		return reg;
7268c2ecf20Sopenharmony_ci
7278c2ecf20Sopenharmony_ci	return 0;
7288c2ecf20Sopenharmony_ci}
7298c2ecf20Sopenharmony_ci
7308c2ecf20Sopenharmony_cistatic int brcm_fet_config_intr(struct phy_device *phydev)
7318c2ecf20Sopenharmony_ci{
7328c2ecf20Sopenharmony_ci	int reg, err;
7338c2ecf20Sopenharmony_ci
7348c2ecf20Sopenharmony_ci	reg = phy_read(phydev, MII_BRCM_FET_INTREG);
7358c2ecf20Sopenharmony_ci	if (reg < 0)
7368c2ecf20Sopenharmony_ci		return reg;
7378c2ecf20Sopenharmony_ci
7388c2ecf20Sopenharmony_ci	if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
7398c2ecf20Sopenharmony_ci		reg &= ~MII_BRCM_FET_IR_MASK;
7408c2ecf20Sopenharmony_ci	else
7418c2ecf20Sopenharmony_ci		reg |= MII_BRCM_FET_IR_MASK;
7428c2ecf20Sopenharmony_ci
7438c2ecf20Sopenharmony_ci	err = phy_write(phydev, MII_BRCM_FET_INTREG, reg);
7448c2ecf20Sopenharmony_ci	return err;
7458c2ecf20Sopenharmony_ci}
7468c2ecf20Sopenharmony_ci
7478c2ecf20Sopenharmony_cistruct bcm53xx_phy_priv {
7488c2ecf20Sopenharmony_ci	u64	*stats;
7498c2ecf20Sopenharmony_ci};
7508c2ecf20Sopenharmony_ci
7518c2ecf20Sopenharmony_cistatic int bcm53xx_phy_probe(struct phy_device *phydev)
7528c2ecf20Sopenharmony_ci{
7538c2ecf20Sopenharmony_ci	struct bcm53xx_phy_priv *priv;
7548c2ecf20Sopenharmony_ci
7558c2ecf20Sopenharmony_ci	priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
7568c2ecf20Sopenharmony_ci	if (!priv)
7578c2ecf20Sopenharmony_ci		return -ENOMEM;
7588c2ecf20Sopenharmony_ci
7598c2ecf20Sopenharmony_ci	phydev->priv = priv;
7608c2ecf20Sopenharmony_ci
7618c2ecf20Sopenharmony_ci	priv->stats = devm_kcalloc(&phydev->mdio.dev,
7628c2ecf20Sopenharmony_ci				   bcm_phy_get_sset_count(phydev), sizeof(u64),
7638c2ecf20Sopenharmony_ci				   GFP_KERNEL);
7648c2ecf20Sopenharmony_ci	if (!priv->stats)
7658c2ecf20Sopenharmony_ci		return -ENOMEM;
7668c2ecf20Sopenharmony_ci
7678c2ecf20Sopenharmony_ci	return 0;
7688c2ecf20Sopenharmony_ci}
7698c2ecf20Sopenharmony_ci
7708c2ecf20Sopenharmony_cistatic void bcm53xx_phy_get_stats(struct phy_device *phydev,
7718c2ecf20Sopenharmony_ci				  struct ethtool_stats *stats, u64 *data)
7728c2ecf20Sopenharmony_ci{
7738c2ecf20Sopenharmony_ci	struct bcm53xx_phy_priv *priv = phydev->priv;
7748c2ecf20Sopenharmony_ci
7758c2ecf20Sopenharmony_ci	bcm_phy_get_stats(phydev, priv->stats, stats, data);
7768c2ecf20Sopenharmony_ci}
7778c2ecf20Sopenharmony_ci
7788c2ecf20Sopenharmony_cistatic struct phy_driver broadcom_drivers[] = {
7798c2ecf20Sopenharmony_ci{
7808c2ecf20Sopenharmony_ci	.phy_id		= PHY_ID_BCM5411,
7818c2ecf20Sopenharmony_ci	.phy_id_mask	= 0xfffffff0,
7828c2ecf20Sopenharmony_ci	.name		= "Broadcom BCM5411",
7838c2ecf20Sopenharmony_ci	/* PHY_GBIT_FEATURES */
7848c2ecf20Sopenharmony_ci	.config_init	= bcm54xx_config_init,
7858c2ecf20Sopenharmony_ci	.ack_interrupt	= bcm_phy_ack_intr,
7868c2ecf20Sopenharmony_ci	.config_intr	= bcm_phy_config_intr,
7878c2ecf20Sopenharmony_ci}, {
7888c2ecf20Sopenharmony_ci	.phy_id		= PHY_ID_BCM5421,
7898c2ecf20Sopenharmony_ci	.phy_id_mask	= 0xfffffff0,
7908c2ecf20Sopenharmony_ci	.name		= "Broadcom BCM5421",
7918c2ecf20Sopenharmony_ci	/* PHY_GBIT_FEATURES */
7928c2ecf20Sopenharmony_ci	.config_init	= bcm54xx_config_init,
7938c2ecf20Sopenharmony_ci	.ack_interrupt	= bcm_phy_ack_intr,
7948c2ecf20Sopenharmony_ci	.config_intr	= bcm_phy_config_intr,
7958c2ecf20Sopenharmony_ci}, {
7968c2ecf20Sopenharmony_ci	.phy_id		= PHY_ID_BCM54210E,
7978c2ecf20Sopenharmony_ci	.phy_id_mask	= 0xfffffff0,
7988c2ecf20Sopenharmony_ci	.name		= "Broadcom BCM54210E",
7998c2ecf20Sopenharmony_ci	/* PHY_GBIT_FEATURES */
8008c2ecf20Sopenharmony_ci	.config_init	= bcm54xx_config_init,
8018c2ecf20Sopenharmony_ci	.ack_interrupt	= bcm_phy_ack_intr,
8028c2ecf20Sopenharmony_ci	.config_intr	= bcm_phy_config_intr,
8038c2ecf20Sopenharmony_ci}, {
8048c2ecf20Sopenharmony_ci	.phy_id		= PHY_ID_BCM5461,
8058c2ecf20Sopenharmony_ci	.phy_id_mask	= 0xfffffff0,
8068c2ecf20Sopenharmony_ci	.name		= "Broadcom BCM5461",
8078c2ecf20Sopenharmony_ci	/* PHY_GBIT_FEATURES */
8088c2ecf20Sopenharmony_ci	.config_init	= bcm54xx_config_init,
8098c2ecf20Sopenharmony_ci	.ack_interrupt	= bcm_phy_ack_intr,
8108c2ecf20Sopenharmony_ci	.config_intr	= bcm_phy_config_intr,
8118c2ecf20Sopenharmony_ci}, {
8128c2ecf20Sopenharmony_ci	.phy_id		= PHY_ID_BCM54612E,
8138c2ecf20Sopenharmony_ci	.phy_id_mask	= 0xfffffff0,
8148c2ecf20Sopenharmony_ci	.name		= "Broadcom BCM54612E",
8158c2ecf20Sopenharmony_ci	/* PHY_GBIT_FEATURES */
8168c2ecf20Sopenharmony_ci	.config_init	= bcm54xx_config_init,
8178c2ecf20Sopenharmony_ci	.ack_interrupt	= bcm_phy_ack_intr,
8188c2ecf20Sopenharmony_ci	.config_intr	= bcm_phy_config_intr,
8198c2ecf20Sopenharmony_ci}, {
8208c2ecf20Sopenharmony_ci	.phy_id		= PHY_ID_BCM54616S,
8218c2ecf20Sopenharmony_ci	.phy_id_mask	= 0xfffffff0,
8228c2ecf20Sopenharmony_ci	.name		= "Broadcom BCM54616S",
8238c2ecf20Sopenharmony_ci	/* PHY_GBIT_FEATURES */
8248c2ecf20Sopenharmony_ci	.soft_reset     = genphy_soft_reset,
8258c2ecf20Sopenharmony_ci	.config_init	= bcm54xx_config_init,
8268c2ecf20Sopenharmony_ci	.config_aneg	= bcm54616s_config_aneg,
8278c2ecf20Sopenharmony_ci	.ack_interrupt	= bcm_phy_ack_intr,
8288c2ecf20Sopenharmony_ci	.config_intr	= bcm_phy_config_intr,
8298c2ecf20Sopenharmony_ci	.read_status	= bcm54616s_read_status,
8308c2ecf20Sopenharmony_ci	.probe		= bcm54616s_probe,
8318c2ecf20Sopenharmony_ci}, {
8328c2ecf20Sopenharmony_ci	.phy_id		= PHY_ID_BCM5464,
8338c2ecf20Sopenharmony_ci	.phy_id_mask	= 0xfffffff0,
8348c2ecf20Sopenharmony_ci	.name		= "Broadcom BCM5464",
8358c2ecf20Sopenharmony_ci	/* PHY_GBIT_FEATURES */
8368c2ecf20Sopenharmony_ci	.config_init	= bcm54xx_config_init,
8378c2ecf20Sopenharmony_ci	.ack_interrupt	= bcm_phy_ack_intr,
8388c2ecf20Sopenharmony_ci	.config_intr	= bcm_phy_config_intr,
8398c2ecf20Sopenharmony_ci	.suspend	= genphy_suspend,
8408c2ecf20Sopenharmony_ci	.resume		= genphy_resume,
8418c2ecf20Sopenharmony_ci}, {
8428c2ecf20Sopenharmony_ci	.phy_id		= PHY_ID_BCM5481,
8438c2ecf20Sopenharmony_ci	.phy_id_mask	= 0xfffffff0,
8448c2ecf20Sopenharmony_ci	.name		= "Broadcom BCM5481",
8458c2ecf20Sopenharmony_ci	/* PHY_GBIT_FEATURES */
8468c2ecf20Sopenharmony_ci	.config_init	= bcm54xx_config_init,
8478c2ecf20Sopenharmony_ci	.config_aneg	= bcm5481_config_aneg,
8488c2ecf20Sopenharmony_ci	.ack_interrupt	= bcm_phy_ack_intr,
8498c2ecf20Sopenharmony_ci	.config_intr	= bcm_phy_config_intr,
8508c2ecf20Sopenharmony_ci}, {
8518c2ecf20Sopenharmony_ci	.phy_id         = PHY_ID_BCM54810,
8528c2ecf20Sopenharmony_ci	.phy_id_mask    = 0xfffffff0,
8538c2ecf20Sopenharmony_ci	.name           = "Broadcom BCM54810",
8548c2ecf20Sopenharmony_ci	/* PHY_GBIT_FEATURES */
8558c2ecf20Sopenharmony_ci	.read_mmd	= bcm54810_read_mmd,
8568c2ecf20Sopenharmony_ci	.write_mmd	= bcm54810_write_mmd,
8578c2ecf20Sopenharmony_ci	.config_init    = bcm54xx_config_init,
8588c2ecf20Sopenharmony_ci	.config_aneg    = bcm5481_config_aneg,
8598c2ecf20Sopenharmony_ci	.ack_interrupt  = bcm_phy_ack_intr,
8608c2ecf20Sopenharmony_ci	.config_intr    = bcm_phy_config_intr,
8618c2ecf20Sopenharmony_ci	.suspend	= genphy_suspend,
8628c2ecf20Sopenharmony_ci	.resume		= bcm54xx_resume,
8638c2ecf20Sopenharmony_ci}, {
8648c2ecf20Sopenharmony_ci	.phy_id         = PHY_ID_BCM54811,
8658c2ecf20Sopenharmony_ci	.phy_id_mask    = 0xfffffff0,
8668c2ecf20Sopenharmony_ci	.name           = "Broadcom BCM54811",
8678c2ecf20Sopenharmony_ci	/* PHY_GBIT_FEATURES */
8688c2ecf20Sopenharmony_ci	.config_init    = bcm54811_config_init,
8698c2ecf20Sopenharmony_ci	.config_aneg    = bcm5481_config_aneg,
8708c2ecf20Sopenharmony_ci	.ack_interrupt  = bcm_phy_ack_intr,
8718c2ecf20Sopenharmony_ci	.config_intr    = bcm_phy_config_intr,
8728c2ecf20Sopenharmony_ci	.suspend	= genphy_suspend,
8738c2ecf20Sopenharmony_ci	.resume		= bcm54xx_resume,
8748c2ecf20Sopenharmony_ci}, {
8758c2ecf20Sopenharmony_ci	.phy_id		= PHY_ID_BCM5482,
8768c2ecf20Sopenharmony_ci	.phy_id_mask	= 0xfffffff0,
8778c2ecf20Sopenharmony_ci	.name		= "Broadcom BCM5482",
8788c2ecf20Sopenharmony_ci	/* PHY_GBIT_FEATURES */
8798c2ecf20Sopenharmony_ci	.config_init	= bcm5482_config_init,
8808c2ecf20Sopenharmony_ci	.read_status	= bcm5482_read_status,
8818c2ecf20Sopenharmony_ci	.ack_interrupt	= bcm_phy_ack_intr,
8828c2ecf20Sopenharmony_ci	.config_intr	= bcm_phy_config_intr,
8838c2ecf20Sopenharmony_ci}, {
8848c2ecf20Sopenharmony_ci	.phy_id		= PHY_ID_BCM50610,
8858c2ecf20Sopenharmony_ci	.phy_id_mask	= 0xfffffff0,
8868c2ecf20Sopenharmony_ci	.name		= "Broadcom BCM50610",
8878c2ecf20Sopenharmony_ci	/* PHY_GBIT_FEATURES */
8888c2ecf20Sopenharmony_ci	.config_init	= bcm54xx_config_init,
8898c2ecf20Sopenharmony_ci	.ack_interrupt	= bcm_phy_ack_intr,
8908c2ecf20Sopenharmony_ci	.config_intr	= bcm_phy_config_intr,
8918c2ecf20Sopenharmony_ci}, {
8928c2ecf20Sopenharmony_ci	.phy_id		= PHY_ID_BCM50610M,
8938c2ecf20Sopenharmony_ci	.phy_id_mask	= 0xfffffff0,
8948c2ecf20Sopenharmony_ci	.name		= "Broadcom BCM50610M",
8958c2ecf20Sopenharmony_ci	/* PHY_GBIT_FEATURES */
8968c2ecf20Sopenharmony_ci	.config_init	= bcm54xx_config_init,
8978c2ecf20Sopenharmony_ci	.ack_interrupt	= bcm_phy_ack_intr,
8988c2ecf20Sopenharmony_ci	.config_intr	= bcm_phy_config_intr,
8998c2ecf20Sopenharmony_ci}, {
9008c2ecf20Sopenharmony_ci	.phy_id		= PHY_ID_BCM57780,
9018c2ecf20Sopenharmony_ci	.phy_id_mask	= 0xfffffff0,
9028c2ecf20Sopenharmony_ci	.name		= "Broadcom BCM57780",
9038c2ecf20Sopenharmony_ci	/* PHY_GBIT_FEATURES */
9048c2ecf20Sopenharmony_ci	.config_init	= bcm54xx_config_init,
9058c2ecf20Sopenharmony_ci	.ack_interrupt	= bcm_phy_ack_intr,
9068c2ecf20Sopenharmony_ci	.config_intr	= bcm_phy_config_intr,
9078c2ecf20Sopenharmony_ci}, {
9088c2ecf20Sopenharmony_ci	.phy_id		= PHY_ID_BCMAC131,
9098c2ecf20Sopenharmony_ci	.phy_id_mask	= 0xfffffff0,
9108c2ecf20Sopenharmony_ci	.name		= "Broadcom BCMAC131",
9118c2ecf20Sopenharmony_ci	/* PHY_BASIC_FEATURES */
9128c2ecf20Sopenharmony_ci	.config_init	= brcm_fet_config_init,
9138c2ecf20Sopenharmony_ci	.ack_interrupt	= brcm_fet_ack_interrupt,
9148c2ecf20Sopenharmony_ci	.config_intr	= brcm_fet_config_intr,
9158c2ecf20Sopenharmony_ci}, {
9168c2ecf20Sopenharmony_ci	.phy_id		= PHY_ID_BCM5241,
9178c2ecf20Sopenharmony_ci	.phy_id_mask	= 0xfffffff0,
9188c2ecf20Sopenharmony_ci	.name		= "Broadcom BCM5241",
9198c2ecf20Sopenharmony_ci	/* PHY_BASIC_FEATURES */
9208c2ecf20Sopenharmony_ci	.config_init	= brcm_fet_config_init,
9218c2ecf20Sopenharmony_ci	.ack_interrupt	= brcm_fet_ack_interrupt,
9228c2ecf20Sopenharmony_ci	.config_intr	= brcm_fet_config_intr,
9238c2ecf20Sopenharmony_ci}, {
9248c2ecf20Sopenharmony_ci	.phy_id		= PHY_ID_BCM5395,
9258c2ecf20Sopenharmony_ci	.phy_id_mask	= 0xfffffff0,
9268c2ecf20Sopenharmony_ci	.name		= "Broadcom BCM5395",
9278c2ecf20Sopenharmony_ci	.flags		= PHY_IS_INTERNAL,
9288c2ecf20Sopenharmony_ci	/* PHY_GBIT_FEATURES */
9298c2ecf20Sopenharmony_ci	.get_sset_count	= bcm_phy_get_sset_count,
9308c2ecf20Sopenharmony_ci	.get_strings	= bcm_phy_get_strings,
9318c2ecf20Sopenharmony_ci	.get_stats	= bcm53xx_phy_get_stats,
9328c2ecf20Sopenharmony_ci	.probe		= bcm53xx_phy_probe,
9338c2ecf20Sopenharmony_ci}, {
9348c2ecf20Sopenharmony_ci	.phy_id		= PHY_ID_BCM53125,
9358c2ecf20Sopenharmony_ci	.phy_id_mask	= 0xfffffff0,
9368c2ecf20Sopenharmony_ci	.name		= "Broadcom BCM53125",
9378c2ecf20Sopenharmony_ci	.flags		= PHY_IS_INTERNAL,
9388c2ecf20Sopenharmony_ci	/* PHY_GBIT_FEATURES */
9398c2ecf20Sopenharmony_ci	.get_sset_count	= bcm_phy_get_sset_count,
9408c2ecf20Sopenharmony_ci	.get_strings	= bcm_phy_get_strings,
9418c2ecf20Sopenharmony_ci	.get_stats	= bcm53xx_phy_get_stats,
9428c2ecf20Sopenharmony_ci	.probe		= bcm53xx_phy_probe,
9438c2ecf20Sopenharmony_ci	.config_init	= bcm54xx_config_init,
9448c2ecf20Sopenharmony_ci	.ack_interrupt	= bcm_phy_ack_intr,
9458c2ecf20Sopenharmony_ci	.config_intr	= bcm_phy_config_intr,
9468c2ecf20Sopenharmony_ci}, {
9478c2ecf20Sopenharmony_ci	.phy_id         = PHY_ID_BCM89610,
9488c2ecf20Sopenharmony_ci	.phy_id_mask    = 0xfffffff0,
9498c2ecf20Sopenharmony_ci	.name           = "Broadcom BCM89610",
9508c2ecf20Sopenharmony_ci	/* PHY_GBIT_FEATURES */
9518c2ecf20Sopenharmony_ci	.config_init    = bcm54xx_config_init,
9528c2ecf20Sopenharmony_ci	.ack_interrupt  = bcm_phy_ack_intr,
9538c2ecf20Sopenharmony_ci	.config_intr    = bcm_phy_config_intr,
9548c2ecf20Sopenharmony_ci} };
9558c2ecf20Sopenharmony_ci
9568c2ecf20Sopenharmony_cimodule_phy_driver(broadcom_drivers);
9578c2ecf20Sopenharmony_ci
9588c2ecf20Sopenharmony_cistatic struct mdio_device_id __maybe_unused broadcom_tbl[] = {
9598c2ecf20Sopenharmony_ci	{ PHY_ID_BCM5411, 0xfffffff0 },
9608c2ecf20Sopenharmony_ci	{ PHY_ID_BCM5421, 0xfffffff0 },
9618c2ecf20Sopenharmony_ci	{ PHY_ID_BCM54210E, 0xfffffff0 },
9628c2ecf20Sopenharmony_ci	{ PHY_ID_BCM5461, 0xfffffff0 },
9638c2ecf20Sopenharmony_ci	{ PHY_ID_BCM54612E, 0xfffffff0 },
9648c2ecf20Sopenharmony_ci	{ PHY_ID_BCM54616S, 0xfffffff0 },
9658c2ecf20Sopenharmony_ci	{ PHY_ID_BCM5464, 0xfffffff0 },
9668c2ecf20Sopenharmony_ci	{ PHY_ID_BCM5481, 0xfffffff0 },
9678c2ecf20Sopenharmony_ci	{ PHY_ID_BCM54810, 0xfffffff0 },
9688c2ecf20Sopenharmony_ci	{ PHY_ID_BCM54811, 0xfffffff0 },
9698c2ecf20Sopenharmony_ci	{ PHY_ID_BCM5482, 0xfffffff0 },
9708c2ecf20Sopenharmony_ci	{ PHY_ID_BCM50610, 0xfffffff0 },
9718c2ecf20Sopenharmony_ci	{ PHY_ID_BCM50610M, 0xfffffff0 },
9728c2ecf20Sopenharmony_ci	{ PHY_ID_BCM57780, 0xfffffff0 },
9738c2ecf20Sopenharmony_ci	{ PHY_ID_BCMAC131, 0xfffffff0 },
9748c2ecf20Sopenharmony_ci	{ PHY_ID_BCM5241, 0xfffffff0 },
9758c2ecf20Sopenharmony_ci	{ PHY_ID_BCM5395, 0xfffffff0 },
9768c2ecf20Sopenharmony_ci	{ PHY_ID_BCM53125, 0xfffffff0 },
9778c2ecf20Sopenharmony_ci	{ PHY_ID_BCM89610, 0xfffffff0 },
9788c2ecf20Sopenharmony_ci	{ }
9798c2ecf20Sopenharmony_ci};
9808c2ecf20Sopenharmony_ci
9818c2ecf20Sopenharmony_ciMODULE_DEVICE_TABLE(mdio, broadcom_tbl);
982