Andrew Lunn | a2443fd | 2019-01-21 19:05:50 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 2 | /* |
| 3 | * drivers/net/phy/broadcom.c |
| 4 | * |
| 5 | * Broadcom BCM5411, BCM5421 and BCM5461 Gigabit Ethernet |
| 6 | * transceivers. |
| 7 | * |
| 8 | * Copyright (c) 2006 Maciej W. Rozycki |
| 9 | * |
| 10 | * Inspired by code written by Amy Fong. |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 11 | */ |
| 12 | |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 13 | #include "bcm-phy-lib.h" |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 14 | #include <linux/module.h> |
| 15 | #include <linux/phy.h> |
Matt Carlson | 8649f13 | 2009-11-02 14:30:00 +0000 | [diff] [blame] | 16 | #include <linux/brcmphy.h> |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 17 | #include <linux/of.h> |
Matt Carlson | d9221e6 | 2009-08-25 10:11:26 +0000 | [diff] [blame] | 18 | |
| 19 | #define BRCM_PHY_MODEL(phydev) \ |
| 20 | ((phydev)->drv->phy_id & (phydev)->drv->phy_id_mask) |
| 21 | |
Matt Carlson | 32e5a8d | 2009-11-02 14:31:39 +0000 | [diff] [blame] | 22 | #define BRCM_PHY_REV(phydev) \ |
| 23 | ((phydev)->drv->phy_id & ~((phydev)->drv->phy_id_mask)) |
| 24 | |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 25 | MODULE_DESCRIPTION("Broadcom PHY driver"); |
| 26 | MODULE_AUTHOR("Maciej W. Rozycki"); |
| 27 | MODULE_LICENSE("GPL"); |
| 28 | |
Tao Ren | 042cb56 | 2018-11-05 14:35:40 -0800 | [diff] [blame] | 29 | static int bcm54xx_config_clock_delay(struct phy_device *phydev) |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 30 | { |
| 31 | int rc, val; |
| 32 | |
Abhishek Shah | 7333362 | 2017-04-30 11:04:21 +0530 | [diff] [blame] | 33 | /* handling PHY's internal RX clock delay */ |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 34 | val = bcm54xx_auxctl_read(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC); |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 35 | val |= MII_BCM54XX_AUXCTL_MISC_WREN; |
Abhishek Shah | 7333362 | 2017-04-30 11:04:21 +0530 | [diff] [blame] | 36 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII || |
| 37 | phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) { |
| 38 | /* Disable RGMII RXC-RXD skew */ |
| 39 | val &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN; |
| 40 | } |
| 41 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || |
| 42 | phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) { |
| 43 | /* Enable RGMII RXC-RXD skew */ |
| 44 | val |= MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN; |
| 45 | } |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 46 | rc = bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC, |
| 47 | val); |
| 48 | if (rc < 0) |
| 49 | return rc; |
| 50 | |
Abhishek Shah | 7333362 | 2017-04-30 11:04:21 +0530 | [diff] [blame] | 51 | /* handling PHY's internal TX clock delay */ |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 52 | val = bcm_phy_read_shadow(phydev, BCM54810_SHD_CLK_CTL); |
Abhishek Shah | 7333362 | 2017-04-30 11:04:21 +0530 | [diff] [blame] | 53 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII || |
| 54 | phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) { |
| 55 | /* Disable internal TX clock delay */ |
| 56 | val &= ~BCM54810_SHD_CLK_CTL_GTXCLK_EN; |
| 57 | } |
| 58 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || |
| 59 | phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) { |
| 60 | /* Enable internal TX clock delay */ |
| 61 | val |= BCM54810_SHD_CLK_CTL_GTXCLK_EN; |
| 62 | } |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 63 | rc = bcm_phy_write_shadow(phydev, BCM54810_SHD_CLK_CTL, val); |
| 64 | if (rc < 0) |
| 65 | return rc; |
| 66 | |
| 67 | return 0; |
| 68 | } |
| 69 | |
Florian Fainelli | 133bf7b | 2021-02-12 19:46:30 -0800 | [diff] [blame] | 70 | static int bcm54210e_config_init(struct phy_device *phydev) |
| 71 | { |
| 72 | int val; |
| 73 | |
| 74 | bcm54xx_config_clock_delay(phydev); |
| 75 | |
| 76 | if (phydev->dev_flags & PHY_BRCM_EN_MASTER_MODE) { |
| 77 | val = phy_read(phydev, MII_CTRL1000); |
| 78 | val |= CTL1000_AS_MASTER | CTL1000_ENABLE_MASTER; |
| 79 | phy_write(phydev, MII_CTRL1000, val); |
| 80 | } |
| 81 | |
| 82 | return 0; |
| 83 | } |
| 84 | |
| 85 | static int bcm54612e_config_init(struct phy_device *phydev) |
| 86 | { |
| 87 | int reg; |
| 88 | |
| 89 | bcm54xx_config_clock_delay(phydev); |
| 90 | |
| 91 | /* Enable CLK125 MUX on LED4 if ref clock is enabled. */ |
| 92 | if (!(phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED)) { |
| 93 | int err; |
| 94 | |
| 95 | reg = bcm_phy_read_exp(phydev, BCM54612E_EXP_SPARE0); |
| 96 | err = bcm_phy_write_exp(phydev, BCM54612E_EXP_SPARE0, |
| 97 | BCM54612E_LED4_CLK125OUT_EN | reg); |
| 98 | |
| 99 | if (err < 0) |
| 100 | return err; |
| 101 | } |
| 102 | |
| 103 | return 0; |
| 104 | } |
| 105 | |
Robert Hancock | 3afd021 | 2021-02-16 16:54:52 -0600 | [diff] [blame] | 106 | static int bcm54616s_config_init(struct phy_device *phydev) |
| 107 | { |
| 108 | int rc, val; |
| 109 | |
| 110 | if (phydev->interface != PHY_INTERFACE_MODE_SGMII && |
| 111 | phydev->interface != PHY_INTERFACE_MODE_1000BASEX) |
| 112 | return 0; |
| 113 | |
| 114 | /* Ensure proper interface mode is selected. */ |
| 115 | /* Disable RGMII mode */ |
| 116 | val = bcm54xx_auxctl_read(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC); |
| 117 | if (val < 0) |
| 118 | return val; |
| 119 | val &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_EN; |
| 120 | val |= MII_BCM54XX_AUXCTL_MISC_WREN; |
| 121 | rc = bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC, |
| 122 | val); |
| 123 | if (rc < 0) |
| 124 | return rc; |
| 125 | |
| 126 | /* Select 1000BASE-X register set (primary SerDes) */ |
| 127 | val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_MODE); |
| 128 | if (val < 0) |
| 129 | return val; |
| 130 | val |= BCM54XX_SHD_MODE_1000BX; |
| 131 | rc = bcm_phy_write_shadow(phydev, BCM54XX_SHD_MODE, val); |
| 132 | if (rc < 0) |
| 133 | return rc; |
| 134 | |
| 135 | /* Power down SerDes interface */ |
| 136 | rc = phy_set_bits(phydev, MII_BMCR, BMCR_PDOWN); |
| 137 | if (rc < 0) |
| 138 | return rc; |
| 139 | |
| 140 | /* Select proper interface mode */ |
| 141 | val &= ~BCM54XX_SHD_INTF_SEL_MASK; |
| 142 | val |= phydev->interface == PHY_INTERFACE_MODE_SGMII ? |
| 143 | BCM54XX_SHD_INTF_SEL_SGMII : |
| 144 | BCM54XX_SHD_INTF_SEL_GBIC; |
| 145 | rc = bcm_phy_write_shadow(phydev, BCM54XX_SHD_MODE, val); |
| 146 | if (rc < 0) |
| 147 | return rc; |
| 148 | |
| 149 | /* Power up SerDes interface */ |
| 150 | rc = phy_clear_bits(phydev, MII_BMCR, BMCR_PDOWN); |
| 151 | if (rc < 0) |
| 152 | return rc; |
| 153 | |
| 154 | /* Select copper register set */ |
| 155 | val &= ~BCM54XX_SHD_MODE_1000BX; |
| 156 | rc = bcm_phy_write_shadow(phydev, BCM54XX_SHD_MODE, val); |
| 157 | if (rc < 0) |
| 158 | return rc; |
| 159 | |
| 160 | /* Power up copper interface */ |
| 161 | return phy_clear_bits(phydev, MII_BMCR, BMCR_PDOWN); |
| 162 | } |
| 163 | |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 164 | /* Needs SMDSP clock enabled via bcm54xx_phydsp_config() */ |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 165 | static int bcm50610_a0_workaround(struct phy_device *phydev) |
| 166 | { |
| 167 | int err; |
| 168 | |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 169 | err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_AADJ1CH0, |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 170 | MII_BCM54XX_EXP_AADJ1CH0_SWP_ABCD_OEN | |
| 171 | MII_BCM54XX_EXP_AADJ1CH0_SWSEL_THPF); |
| 172 | if (err < 0) |
| 173 | return err; |
| 174 | |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 175 | err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_AADJ1CH3, |
| 176 | MII_BCM54XX_EXP_AADJ1CH3_ADCCKADJ); |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 177 | if (err < 0) |
| 178 | return err; |
| 179 | |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 180 | err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP75, |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 181 | MII_BCM54XX_EXP_EXP75_VDACCTRL); |
| 182 | if (err < 0) |
| 183 | return err; |
| 184 | |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 185 | err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP96, |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 186 | MII_BCM54XX_EXP_EXP96_MYST); |
| 187 | if (err < 0) |
| 188 | return err; |
| 189 | |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 190 | err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP97, |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 191 | MII_BCM54XX_EXP_EXP97_MYST); |
| 192 | |
| 193 | return err; |
| 194 | } |
| 195 | |
| 196 | static int bcm54xx_phydsp_config(struct phy_device *phydev) |
| 197 | { |
| 198 | int err, err2; |
| 199 | |
| 200 | /* Enable the SMDSP clock */ |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 201 | err = bcm54xx_auxctl_write(phydev, |
| 202 | MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL, |
| 203 | MII_BCM54XX_AUXCTL_ACTL_SMDSP_ENA | |
| 204 | MII_BCM54XX_AUXCTL_ACTL_TX_6DB); |
| 205 | if (err < 0) |
| 206 | return err; |
| 207 | |
Matt Carlson | 219c6ef | 2009-11-02 14:28:33 +0000 | [diff] [blame] | 208 | if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 || |
| 209 | BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) { |
| 210 | /* Clear bit 9 to fix a phy interop issue. */ |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 211 | err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP08, |
Matt Carlson | 219c6ef | 2009-11-02 14:28:33 +0000 | [diff] [blame] | 212 | MII_BCM54XX_EXP_EXP08_RJCT_2MHZ); |
| 213 | if (err < 0) |
| 214 | goto error; |
| 215 | |
| 216 | if (phydev->drv->phy_id == PHY_ID_BCM50610) { |
| 217 | err = bcm50610_a0_workaround(phydev); |
| 218 | if (err < 0) |
| 219 | goto error; |
| 220 | } |
| 221 | } |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 222 | |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 223 | if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM57780) { |
| 224 | int val; |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 225 | |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 226 | val = bcm_phy_read_exp(phydev, MII_BCM54XX_EXP_EXP75); |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 227 | if (val < 0) |
| 228 | goto error; |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 229 | |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 230 | val |= MII_BCM54XX_EXP_EXP75_CM_OSC; |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 231 | err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP75, val); |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 232 | } |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 233 | |
| 234 | error: |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 235 | /* Disable the SMDSP clock */ |
| 236 | err2 = bcm54xx_auxctl_write(phydev, |
| 237 | MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL, |
| 238 | MII_BCM54XX_AUXCTL_ACTL_TX_6DB); |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 239 | |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 240 | /* Return the first error reported. */ |
| 241 | return err ? err : err2; |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 242 | } |
| 243 | |
Matt Carlson | 32e5a8d | 2009-11-02 14:31:39 +0000 | [diff] [blame] | 244 | static void bcm54xx_adjust_rxrefclk(struct phy_device *phydev) |
| 245 | { |
Roel Kluin | 5ee6f6a | 2009-12-18 20:16:10 -0800 | [diff] [blame] | 246 | u32 orig; |
| 247 | int val; |
Matt Carlson | c704dc2 | 2009-11-02 14:32:12 +0000 | [diff] [blame] | 248 | bool clk125en = true; |
Matt Carlson | 32e5a8d | 2009-11-02 14:31:39 +0000 | [diff] [blame] | 249 | |
| 250 | /* Abort if we are using an untested phy. */ |
roel kluin | 7ec4e7d | 2009-12-30 06:43:06 +0000 | [diff] [blame] | 251 | if (BRCM_PHY_MODEL(phydev) != PHY_ID_BCM57780 && |
| 252 | BRCM_PHY_MODEL(phydev) != PHY_ID_BCM50610 && |
Florian Fainelli | 0ececcf | 2020-02-19 12:00:47 -0800 | [diff] [blame] | 253 | BRCM_PHY_MODEL(phydev) != PHY_ID_BCM50610M && |
Florian Fainelli | 5d4358e | 2021-02-12 19:46:32 -0800 | [diff] [blame] | 254 | BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54210E && |
Kevin Lo | b0ed0bb | 2020-05-16 01:24:47 +0800 | [diff] [blame] | 255 | BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54810 && |
| 256 | BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54811) |
Matt Carlson | 32e5a8d | 2009-11-02 14:31:39 +0000 | [diff] [blame] | 257 | return; |
| 258 | |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 259 | val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_SCR3); |
Matt Carlson | 32e5a8d | 2009-11-02 14:31:39 +0000 | [diff] [blame] | 260 | if (val < 0) |
| 261 | return; |
| 262 | |
| 263 | orig = val; |
| 264 | |
Matt Carlson | c704dc2 | 2009-11-02 14:32:12 +0000 | [diff] [blame] | 265 | if ((BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 || |
| 266 | BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) && |
| 267 | BRCM_PHY_REV(phydev) >= 0x3) { |
| 268 | /* |
| 269 | * Here, bit 0 _disables_ CLK125 when set. |
| 270 | * This bit is set by default. |
| 271 | */ |
| 272 | clk125en = false; |
| 273 | } else { |
| 274 | if (phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED) { |
Kevin Lo | b0ed0bb | 2020-05-16 01:24:47 +0800 | [diff] [blame] | 275 | if (BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54811) { |
| 276 | /* Here, bit 0 _enables_ CLK125 when set */ |
| 277 | val &= ~BCM54XX_SHD_SCR3_DEF_CLK125; |
| 278 | } |
Matt Carlson | c704dc2 | 2009-11-02 14:32:12 +0000 | [diff] [blame] | 279 | clk125en = false; |
Matt Carlson | 32e5a8d | 2009-11-02 14:31:39 +0000 | [diff] [blame] | 280 | } |
| 281 | } |
| 282 | |
Joe Perches | 23677ce | 2012-02-09 11:17:23 +0000 | [diff] [blame] | 283 | if (!clk125en || (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE)) |
Matt Carlson | c704dc2 | 2009-11-02 14:32:12 +0000 | [diff] [blame] | 284 | val &= ~BCM54XX_SHD_SCR3_DLLAPD_DIS; |
| 285 | else |
| 286 | val |= BCM54XX_SHD_SCR3_DLLAPD_DIS; |
| 287 | |
Kevin Lo | b0ed0bb | 2020-05-16 01:24:47 +0800 | [diff] [blame] | 288 | if (phydev->dev_flags & PHY_BRCM_DIS_TXCRXC_NOENRGY) { |
Florian Fainelli | 5d4358e | 2021-02-12 19:46:32 -0800 | [diff] [blame] | 289 | if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54210E || |
| 290 | BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810 || |
Kevin Lo | ad4e1e4 | 2021-07-23 21:59:27 +0800 | [diff] [blame] | 291 | BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54811) |
Florian Fainelli | 5d4358e | 2021-02-12 19:46:32 -0800 | [diff] [blame] | 292 | val |= BCM54XX_SHD_SCR3_RXCTXC_DIS; |
Kevin Lo | b0ed0bb | 2020-05-16 01:24:47 +0800 | [diff] [blame] | 293 | else |
| 294 | val |= BCM54XX_SHD_SCR3_TRDDAPD; |
| 295 | } |
Matt Carlson | 52fae08 | 2009-11-02 14:32:38 +0000 | [diff] [blame] | 296 | |
Matt Carlson | 32e5a8d | 2009-11-02 14:31:39 +0000 | [diff] [blame] | 297 | if (orig != val) |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 298 | bcm_phy_write_shadow(phydev, BCM54XX_SHD_SCR3, val); |
Matt Carlson | c704dc2 | 2009-11-02 14:32:12 +0000 | [diff] [blame] | 299 | |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 300 | val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_APD); |
Matt Carlson | c704dc2 | 2009-11-02 14:32:12 +0000 | [diff] [blame] | 301 | if (val < 0) |
| 302 | return; |
| 303 | |
| 304 | orig = val; |
| 305 | |
Joe Perches | 23677ce | 2012-02-09 11:17:23 +0000 | [diff] [blame] | 306 | if (!clk125en || (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE)) |
Matt Carlson | c704dc2 | 2009-11-02 14:32:12 +0000 | [diff] [blame] | 307 | val |= BCM54XX_SHD_APD_EN; |
| 308 | else |
| 309 | val &= ~BCM54XX_SHD_APD_EN; |
| 310 | |
| 311 | if (orig != val) |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 312 | bcm_phy_write_shadow(phydev, BCM54XX_SHD_APD, val); |
Matt Carlson | 32e5a8d | 2009-11-02 14:31:39 +0000 | [diff] [blame] | 313 | } |
| 314 | |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 315 | static int bcm54xx_config_init(struct phy_device *phydev) |
| 316 | { |
Abhishek Shah | 7333362 | 2017-04-30 11:04:21 +0530 | [diff] [blame] | 317 | int reg, err, val; |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 318 | |
| 319 | reg = phy_read(phydev, MII_BCM54XX_ECR); |
| 320 | if (reg < 0) |
| 321 | return reg; |
| 322 | |
| 323 | /* Mask interrupts globally. */ |
| 324 | reg |= MII_BCM54XX_ECR_IM; |
| 325 | err = phy_write(phydev, MII_BCM54XX_ECR, reg); |
| 326 | if (err < 0) |
| 327 | return err; |
| 328 | |
| 329 | /* Unmask events we are interested in. */ |
| 330 | reg = ~(MII_BCM54XX_INT_DUPLEX | |
| 331 | MII_BCM54XX_INT_SPEED | |
| 332 | MII_BCM54XX_INT_LINK); |
| 333 | err = phy_write(phydev, MII_BCM54XX_IMR, reg); |
| 334 | if (err < 0) |
| 335 | return err; |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 336 | |
Matt Carlson | 63a14ce | 2009-11-02 14:30:40 +0000 | [diff] [blame] | 337 | if ((BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 || |
| 338 | BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) && |
| 339 | (phydev->dev_flags & PHY_BRCM_CLEAR_RGMII_MODE)) |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 340 | bcm_phy_write_shadow(phydev, BCM54XX_SHD_RGMII_MODE, 0); |
Matt Carlson | 63a14ce | 2009-11-02 14:30:40 +0000 | [diff] [blame] | 341 | |
Florian Fainelli | cb64da3 | 2020-02-19 12:00:48 -0800 | [diff] [blame] | 342 | bcm54xx_adjust_rxrefclk(phydev); |
Matt Carlson | 32e5a8d | 2009-11-02 14:31:39 +0000 | [diff] [blame] | 343 | |
Robert Hancock | 3afd021 | 2021-02-16 16:54:52 -0600 | [diff] [blame] | 344 | switch (BRCM_PHY_MODEL(phydev)) { |
Florian Fainelli | b1dd9bf | 2021-03-11 16:52:50 -0800 | [diff] [blame] | 345 | case PHY_ID_BCM50610: |
| 346 | case PHY_ID_BCM50610M: |
| 347 | err = bcm54xx_config_clock_delay(phydev); |
| 348 | break; |
Robert Hancock | 3afd021 | 2021-02-16 16:54:52 -0600 | [diff] [blame] | 349 | case PHY_ID_BCM54210E: |
Rafał Miłecki | 0fc9ae1 | 2017-01-27 14:07:01 +0100 | [diff] [blame] | 350 | err = bcm54210e_config_init(phydev); |
Robert Hancock | 3afd021 | 2021-02-16 16:54:52 -0600 | [diff] [blame] | 351 | break; |
| 352 | case PHY_ID_BCM54612E: |
Rafał Miłecki | 62e1309 | 2017-01-31 22:54:54 +0100 | [diff] [blame] | 353 | err = bcm54612e_config_init(phydev); |
Robert Hancock | 3afd021 | 2021-02-16 16:54:52 -0600 | [diff] [blame] | 354 | break; |
| 355 | case PHY_ID_BCM54616S: |
| 356 | err = bcm54616s_config_init(phydev); |
| 357 | break; |
| 358 | case PHY_ID_BCM54810: |
Abhishek Shah | 7333362 | 2017-04-30 11:04:21 +0530 | [diff] [blame] | 359 | /* For BCM54810, we need to disable BroadR-Reach function */ |
| 360 | val = bcm_phy_read_exp(phydev, |
| 361 | BCM54810_EXP_BROADREACH_LRE_MISC_CTL); |
| 362 | val &= ~BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN; |
| 363 | err = bcm_phy_write_exp(phydev, |
| 364 | BCM54810_EXP_BROADREACH_LRE_MISC_CTL, |
| 365 | val); |
Robert Hancock | 3afd021 | 2021-02-16 16:54:52 -0600 | [diff] [blame] | 366 | break; |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 367 | } |
Robert Hancock | 3afd021 | 2021-02-16 16:54:52 -0600 | [diff] [blame] | 368 | if (err) |
| 369 | return err; |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 370 | |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 371 | bcm54xx_phydsp_config(phydev); |
Matt Carlson | d9221e6 | 2009-08-25 10:11:26 +0000 | [diff] [blame] | 372 | |
Robert Hancock | b5d007e | 2021-02-16 16:54:54 -0600 | [diff] [blame] | 373 | /* For non-SFP setups, encode link speed into LED1 and LED3 pair |
| 374 | * (green/amber). |
Vladimir Oltean | 450895d | 2019-03-24 00:18:46 +0200 | [diff] [blame] | 375 | * Also flash these two LEDs on activity. This means configuring |
| 376 | * them for MULTICOLOR and encoding link/activity into them. |
Robert Hancock | b5d007e | 2021-02-16 16:54:54 -0600 | [diff] [blame] | 377 | * Don't do this for devices on an SFP module, since some of these |
| 378 | * use the LED outputs to control the SFP LOS signal, and changing |
| 379 | * these settings will cause LOS to malfunction. |
Vladimir Oltean | 450895d | 2019-03-24 00:18:46 +0200 | [diff] [blame] | 380 | */ |
Robert Hancock | b5d007e | 2021-02-16 16:54:54 -0600 | [diff] [blame] | 381 | if (!phy_on_sfp(phydev)) { |
| 382 | val = BCM5482_SHD_LEDS1_LED1(BCM_LED_SRC_MULTICOLOR1) | |
| 383 | BCM5482_SHD_LEDS1_LED3(BCM_LED_SRC_MULTICOLOR1); |
| 384 | bcm_phy_write_shadow(phydev, BCM5482_SHD_LEDS1, val); |
Vladimir Oltean | 450895d | 2019-03-24 00:18:46 +0200 | [diff] [blame] | 385 | |
Robert Hancock | b5d007e | 2021-02-16 16:54:54 -0600 | [diff] [blame] | 386 | val = BCM_LED_MULTICOLOR_IN_PHASE | |
| 387 | BCM5482_SHD_LEDS1_LED1(BCM_LED_MULTICOLOR_LINK_ACT) | |
| 388 | BCM5482_SHD_LEDS1_LED3(BCM_LED_MULTICOLOR_LINK_ACT); |
| 389 | bcm_phy_write_exp(phydev, BCM_EXP_MULTICOLOR, val); |
| 390 | } |
Vladimir Oltean | 450895d | 2019-03-24 00:18:46 +0200 | [diff] [blame] | 391 | |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 392 | return 0; |
| 393 | } |
| 394 | |
Florian Fainelli | d6da08e | 2021-09-20 14:54:14 -0700 | [diff] [blame] | 395 | static int bcm54xx_iddq_set(struct phy_device *phydev, bool enable) |
| 396 | { |
| 397 | int ret = 0; |
| 398 | |
| 399 | if (!(phydev->dev_flags & PHY_BRCM_IDDQ_SUSPEND)) |
| 400 | return ret; |
| 401 | |
| 402 | ret = bcm_phy_read_exp(phydev, BCM54XX_TOP_MISC_IDDQ_CTRL); |
| 403 | if (ret < 0) |
| 404 | goto out; |
| 405 | |
| 406 | if (enable) |
| 407 | ret |= BCM54XX_TOP_MISC_IDDQ_SR | BCM54XX_TOP_MISC_IDDQ_LP; |
| 408 | else |
| 409 | ret &= ~(BCM54XX_TOP_MISC_IDDQ_SR | BCM54XX_TOP_MISC_IDDQ_LP); |
| 410 | |
| 411 | ret = bcm_phy_write_exp(phydev, BCM54XX_TOP_MISC_IDDQ_CTRL, ret); |
| 412 | out: |
| 413 | return ret; |
| 414 | } |
| 415 | |
| 416 | static int bcm54xx_suspend(struct phy_device *phydev) |
| 417 | { |
| 418 | int ret; |
| 419 | |
| 420 | /* We cannot use a read/modify/write here otherwise the PHY gets into |
| 421 | * a bad state where its LEDs keep flashing, thus defeating the purpose |
| 422 | * of low power mode. |
| 423 | */ |
| 424 | ret = phy_write(phydev, MII_BMCR, BMCR_PDOWN); |
| 425 | if (ret < 0) |
| 426 | return ret; |
| 427 | |
| 428 | return bcm54xx_iddq_set(phydev, true); |
| 429 | } |
| 430 | |
Florian Fainelli | fe26821 | 2020-02-19 12:00:49 -0800 | [diff] [blame] | 431 | static int bcm54xx_resume(struct phy_device *phydev) |
| 432 | { |
| 433 | int ret; |
| 434 | |
Florian Fainelli | d6da08e | 2021-09-20 14:54:14 -0700 | [diff] [blame] | 435 | ret = bcm54xx_iddq_set(phydev, false); |
| 436 | if (ret < 0) |
| 437 | return ret; |
| 438 | |
Florian Fainelli | fe26821 | 2020-02-19 12:00:49 -0800 | [diff] [blame] | 439 | /* Writes to register other than BMCR would be ignored |
| 440 | * unless we clear the PDOWN bit first |
| 441 | */ |
| 442 | ret = genphy_resume(phydev); |
| 443 | if (ret < 0) |
| 444 | return ret; |
| 445 | |
Florian Fainelli | 7a1468b | 2021-03-10 20:53:42 -0800 | [diff] [blame] | 446 | /* Upon exiting power down, the PHY remains in an internal reset state |
| 447 | * for 40us |
| 448 | */ |
| 449 | fsleep(40); |
| 450 | |
Florian Fainelli | d6da08e | 2021-09-20 14:54:14 -0700 | [diff] [blame] | 451 | /* Issue a soft reset after clearing the power down bit |
| 452 | * and before doing any other configuration. |
| 453 | */ |
| 454 | if (phydev->dev_flags & PHY_BRCM_IDDQ_SUSPEND) { |
| 455 | ret = genphy_soft_reset(phydev); |
| 456 | if (ret < 0) |
| 457 | return ret; |
| 458 | } |
| 459 | |
Florian Fainelli | fe26821 | 2020-02-19 12:00:49 -0800 | [diff] [blame] | 460 | return bcm54xx_config_init(phydev); |
| 461 | } |
| 462 | |
Kevin Lo | b0ed0bb | 2020-05-16 01:24:47 +0800 | [diff] [blame] | 463 | static int bcm54811_config_init(struct phy_device *phydev) |
| 464 | { |
| 465 | int err, reg; |
| 466 | |
| 467 | /* Disable BroadR-Reach function. */ |
| 468 | reg = bcm_phy_read_exp(phydev, BCM54810_EXP_BROADREACH_LRE_MISC_CTL); |
| 469 | reg &= ~BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN; |
| 470 | err = bcm_phy_write_exp(phydev, BCM54810_EXP_BROADREACH_LRE_MISC_CTL, |
| 471 | reg); |
| 472 | if (err < 0) |
| 473 | return err; |
| 474 | |
| 475 | err = bcm54xx_config_init(phydev); |
| 476 | |
| 477 | /* Enable CLK125 MUX on LED4 if ref clock is enabled. */ |
| 478 | if (!(phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED)) { |
| 479 | reg = bcm_phy_read_exp(phydev, BCM54612E_EXP_SPARE0); |
| 480 | err = bcm_phy_write_exp(phydev, BCM54612E_EXP_SPARE0, |
| 481 | BCM54612E_LED4_CLK125OUT_EN | reg); |
| 482 | if (err < 0) |
| 483 | return err; |
Kevin Lo | 6f42a29 | 2020-05-16 10:09:26 +0800 | [diff] [blame] | 484 | } |
Kevin Lo | b0ed0bb | 2020-05-16 01:24:47 +0800 | [diff] [blame] | 485 | |
| 486 | return err; |
| 487 | } |
| 488 | |
Anton Vorontsov | 57bb7e2 | 2008-03-04 19:41:32 +0300 | [diff] [blame] | 489 | static int bcm5481_config_aneg(struct phy_device *phydev) |
| 490 | { |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 491 | struct device_node *np = phydev->mdio.dev.of_node; |
Anton Vorontsov | 57bb7e2 | 2008-03-04 19:41:32 +0300 | [diff] [blame] | 492 | int ret; |
| 493 | |
Jonathan Neuschäfer | 29f20dd | 2020-02-18 16:47:01 +0100 | [diff] [blame] | 494 | /* Aneg firstly. */ |
Anton Vorontsov | 57bb7e2 | 2008-03-04 19:41:32 +0300 | [diff] [blame] | 495 | ret = genphy_config_aneg(phydev); |
| 496 | |
| 497 | /* Then we can set up the delay. */ |
Tao Ren | 042cb56 | 2018-11-05 14:35:40 -0800 | [diff] [blame] | 498 | bcm54xx_config_clock_delay(phydev); |
Anton Vorontsov | 57bb7e2 | 2008-03-04 19:41:32 +0300 | [diff] [blame] | 499 | |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 500 | if (of_property_read_bool(np, "enet-phy-lane-swap")) { |
| 501 | /* Lane Swap - Undocumented register...magic! */ |
| 502 | ret = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_SEL_ER + 0x9, |
| 503 | 0x11B); |
| 504 | if (ret < 0) |
| 505 | return ret; |
| 506 | } |
| 507 | |
Anton Vorontsov | 57bb7e2 | 2008-03-04 19:41:32 +0300 | [diff] [blame] | 508 | return ret; |
| 509 | } |
| 510 | |
Florian Fainelli | 17d3a83 | 2021-02-12 19:46:31 -0800 | [diff] [blame] | 511 | struct bcm54616s_phy_priv { |
| 512 | bool mode_1000bx_en; |
| 513 | }; |
| 514 | |
Tao Ren | b9bcb95 | 2019-10-22 11:31:08 -0700 | [diff] [blame] | 515 | static int bcm54616s_probe(struct phy_device *phydev) |
| 516 | { |
Florian Fainelli | 17d3a83 | 2021-02-12 19:46:31 -0800 | [diff] [blame] | 517 | struct bcm54616s_phy_priv *priv; |
Robert Hancock | 3afd021 | 2021-02-16 16:54:52 -0600 | [diff] [blame] | 518 | int val; |
Tao Ren | b9bcb95 | 2019-10-22 11:31:08 -0700 | [diff] [blame] | 519 | |
Florian Fainelli | 17d3a83 | 2021-02-12 19:46:31 -0800 | [diff] [blame] | 520 | priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); |
| 521 | if (!priv) |
| 522 | return -ENOMEM; |
| 523 | |
| 524 | phydev->priv = priv; |
| 525 | |
Tao Ren | b9bcb95 | 2019-10-22 11:31:08 -0700 | [diff] [blame] | 526 | val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_MODE); |
| 527 | if (val < 0) |
| 528 | return val; |
| 529 | |
| 530 | /* The PHY is strapped in RGMII-fiber mode when INTERF_SEL[1:0] |
| 531 | * is 01b, and the link between PHY and its link partner can be |
| 532 | * either 1000Base-X or 100Base-FX. |
| 533 | * RGMII-1000Base-X is properly supported, but RGMII-100Base-FX |
| 534 | * support is still missing as of now. |
| 535 | */ |
Robert Hancock | 3afd021 | 2021-02-16 16:54:52 -0600 | [diff] [blame] | 536 | if ((val & BCM54XX_SHD_INTF_SEL_MASK) == BCM54XX_SHD_INTF_SEL_RGMII) { |
Tao Ren | b9bcb95 | 2019-10-22 11:31:08 -0700 | [diff] [blame] | 537 | val = bcm_phy_read_shadow(phydev, BCM54616S_SHD_100FX_CTRL); |
| 538 | if (val < 0) |
| 539 | return val; |
| 540 | |
| 541 | /* Bit 0 of the SerDes 100-FX Control register, when set |
| 542 | * to 1, sets the MII/RGMII -> 100BASE-FX configuration. |
| 543 | * When this bit is set to 0, it sets the GMII/RGMII -> |
| 544 | * 1000BASE-X configuration. |
| 545 | */ |
| 546 | if (!(val & BCM54616S_100FX_MODE)) |
Florian Fainelli | 17d3a83 | 2021-02-12 19:46:31 -0800 | [diff] [blame] | 547 | priv->mode_1000bx_en = true; |
Michael Walle | 4217a64 | 2021-02-09 17:38:52 +0100 | [diff] [blame] | 548 | |
| 549 | phydev->port = PORT_FIBRE; |
Tao Ren | b9bcb95 | 2019-10-22 11:31:08 -0700 | [diff] [blame] | 550 | } |
| 551 | |
| 552 | return 0; |
| 553 | } |
| 554 | |
Tao Ren | 042cb56 | 2018-11-05 14:35:40 -0800 | [diff] [blame] | 555 | static int bcm54616s_config_aneg(struct phy_device *phydev) |
| 556 | { |
Florian Fainelli | 17d3a83 | 2021-02-12 19:46:31 -0800 | [diff] [blame] | 557 | struct bcm54616s_phy_priv *priv = phydev->priv; |
Tao Ren | 042cb56 | 2018-11-05 14:35:40 -0800 | [diff] [blame] | 558 | int ret; |
| 559 | |
Jonathan Neuschäfer | 29f20dd | 2020-02-18 16:47:01 +0100 | [diff] [blame] | 560 | /* Aneg firstly. */ |
Florian Fainelli | 17d3a83 | 2021-02-12 19:46:31 -0800 | [diff] [blame] | 561 | if (priv->mode_1000bx_en) |
Tao Ren | b9bcb95 | 2019-10-22 11:31:08 -0700 | [diff] [blame] | 562 | ret = genphy_c37_config_aneg(phydev); |
| 563 | else |
| 564 | ret = genphy_config_aneg(phydev); |
Tao Ren | 042cb56 | 2018-11-05 14:35:40 -0800 | [diff] [blame] | 565 | |
| 566 | /* Then we can set up the delay. */ |
| 567 | bcm54xx_config_clock_delay(phydev); |
| 568 | |
| 569 | return ret; |
| 570 | } |
| 571 | |
Tao Ren | b9bcb95 | 2019-10-22 11:31:08 -0700 | [diff] [blame] | 572 | static int bcm54616s_read_status(struct phy_device *phydev) |
| 573 | { |
Florian Fainelli | 17d3a83 | 2021-02-12 19:46:31 -0800 | [diff] [blame] | 574 | struct bcm54616s_phy_priv *priv = phydev->priv; |
Tao Ren | b9bcb95 | 2019-10-22 11:31:08 -0700 | [diff] [blame] | 575 | int err; |
| 576 | |
Florian Fainelli | 17d3a83 | 2021-02-12 19:46:31 -0800 | [diff] [blame] | 577 | if (priv->mode_1000bx_en) |
Tao Ren | b9bcb95 | 2019-10-22 11:31:08 -0700 | [diff] [blame] | 578 | err = genphy_c37_read_status(phydev); |
| 579 | else |
| 580 | err = genphy_read_status(phydev); |
| 581 | |
| 582 | return err; |
| 583 | } |
| 584 | |
Matt Carlson | d7a2ed9 | 2009-08-25 10:10:58 +0000 | [diff] [blame] | 585 | static int brcm_phy_setbits(struct phy_device *phydev, int reg, int set) |
| 586 | { |
| 587 | int val; |
| 588 | |
| 589 | val = phy_read(phydev, reg); |
| 590 | if (val < 0) |
| 591 | return val; |
| 592 | |
| 593 | return phy_write(phydev, reg, val | set); |
| 594 | } |
| 595 | |
| 596 | static int brcm_fet_config_init(struct phy_device *phydev) |
| 597 | { |
| 598 | int reg, err, err2, brcmtest; |
| 599 | |
| 600 | /* Reset the PHY to bring it to a known state. */ |
| 601 | err = phy_write(phydev, MII_BMCR, BMCR_RESET); |
| 602 | if (err < 0) |
| 603 | return err; |
| 604 | |
| 605 | reg = phy_read(phydev, MII_BRCM_FET_INTREG); |
| 606 | if (reg < 0) |
| 607 | return reg; |
| 608 | |
| 609 | /* Unmask events we are interested in and mask interrupts globally. */ |
| 610 | reg = MII_BRCM_FET_IR_DUPLEX_EN | |
| 611 | MII_BRCM_FET_IR_SPEED_EN | |
| 612 | MII_BRCM_FET_IR_LINK_EN | |
| 613 | MII_BRCM_FET_IR_ENABLE | |
| 614 | MII_BRCM_FET_IR_MASK; |
| 615 | |
| 616 | err = phy_write(phydev, MII_BRCM_FET_INTREG, reg); |
| 617 | if (err < 0) |
| 618 | return err; |
| 619 | |
| 620 | /* Enable shadow register access */ |
| 621 | brcmtest = phy_read(phydev, MII_BRCM_FET_BRCMTEST); |
| 622 | if (brcmtest < 0) |
| 623 | return brcmtest; |
| 624 | |
| 625 | reg = brcmtest | MII_BRCM_FET_BT_SRE; |
| 626 | |
| 627 | err = phy_write(phydev, MII_BRCM_FET_BRCMTEST, reg); |
| 628 | if (err < 0) |
| 629 | return err; |
| 630 | |
| 631 | /* Set the LED mode */ |
| 632 | reg = phy_read(phydev, MII_BRCM_FET_SHDW_AUXMODE4); |
| 633 | if (reg < 0) { |
| 634 | err = reg; |
| 635 | goto done; |
| 636 | } |
| 637 | |
| 638 | reg &= ~MII_BRCM_FET_SHDW_AM4_LED_MASK; |
| 639 | reg |= MII_BRCM_FET_SHDW_AM4_LED_MODE1; |
| 640 | |
| 641 | err = phy_write(phydev, MII_BRCM_FET_SHDW_AUXMODE4, reg); |
| 642 | if (err < 0) |
| 643 | goto done; |
| 644 | |
| 645 | /* Enable auto MDIX */ |
| 646 | err = brcm_phy_setbits(phydev, MII_BRCM_FET_SHDW_MISCCTRL, |
| 647 | MII_BRCM_FET_SHDW_MC_FAME); |
| 648 | if (err < 0) |
| 649 | goto done; |
| 650 | |
Matt Carlson | cdd4e09d | 2009-11-02 14:31:11 +0000 | [diff] [blame] | 651 | if (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE) { |
| 652 | /* Enable auto power down */ |
| 653 | err = brcm_phy_setbits(phydev, MII_BRCM_FET_SHDW_AUXSTAT2, |
| 654 | MII_BRCM_FET_SHDW_AS2_APDE); |
| 655 | } |
Matt Carlson | d7a2ed9 | 2009-08-25 10:10:58 +0000 | [diff] [blame] | 656 | |
| 657 | done: |
| 658 | /* Disable shadow register access */ |
| 659 | err2 = phy_write(phydev, MII_BRCM_FET_BRCMTEST, brcmtest); |
| 660 | if (!err) |
| 661 | err = err2; |
| 662 | |
| 663 | return err; |
| 664 | } |
| 665 | |
| 666 | static int brcm_fet_ack_interrupt(struct phy_device *phydev) |
| 667 | { |
| 668 | int reg; |
| 669 | |
| 670 | /* Clear pending interrupts. */ |
| 671 | reg = phy_read(phydev, MII_BRCM_FET_INTREG); |
| 672 | if (reg < 0) |
| 673 | return reg; |
| 674 | |
| 675 | return 0; |
| 676 | } |
| 677 | |
| 678 | static int brcm_fet_config_intr(struct phy_device *phydev) |
| 679 | { |
| 680 | int reg, err; |
| 681 | |
| 682 | reg = phy_read(phydev, MII_BRCM_FET_INTREG); |
| 683 | if (reg < 0) |
| 684 | return reg; |
| 685 | |
Ioana Ciornei | 15772e4 | 2020-11-01 14:51:07 +0200 | [diff] [blame] | 686 | if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { |
| 687 | err = brcm_fet_ack_interrupt(phydev); |
| 688 | if (err) |
| 689 | return err; |
Matt Carlson | d7a2ed9 | 2009-08-25 10:10:58 +0000 | [diff] [blame] | 690 | |
Ioana Ciornei | 15772e4 | 2020-11-01 14:51:07 +0200 | [diff] [blame] | 691 | reg &= ~MII_BRCM_FET_IR_MASK; |
| 692 | err = phy_write(phydev, MII_BRCM_FET_INTREG, reg); |
| 693 | } else { |
| 694 | reg |= MII_BRCM_FET_IR_MASK; |
| 695 | err = phy_write(phydev, MII_BRCM_FET_INTREG, reg); |
| 696 | if (err) |
| 697 | return err; |
| 698 | |
| 699 | err = brcm_fet_ack_interrupt(phydev); |
| 700 | } |
| 701 | |
Matt Carlson | d7a2ed9 | 2009-08-25 10:10:58 +0000 | [diff] [blame] | 702 | return err; |
| 703 | } |
| 704 | |
Ioana Ciornei | 4567d5c | 2020-11-01 14:51:06 +0200 | [diff] [blame] | 705 | static irqreturn_t brcm_fet_handle_interrupt(struct phy_device *phydev) |
| 706 | { |
| 707 | int irq_status; |
| 708 | |
| 709 | irq_status = phy_read(phydev, MII_BRCM_FET_INTREG); |
| 710 | if (irq_status < 0) { |
| 711 | phy_error(phydev); |
| 712 | return IRQ_NONE; |
| 713 | } |
| 714 | |
| 715 | if (irq_status == 0) |
| 716 | return IRQ_NONE; |
| 717 | |
| 718 | phy_trigger_machine(phydev); |
| 719 | |
| 720 | return IRQ_HANDLED; |
| 721 | } |
| 722 | |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 723 | struct bcm54xx_phy_priv { |
Florian Fainelli | 28dc4c8 | 2017-12-14 17:48:16 -0800 | [diff] [blame] | 724 | u64 *stats; |
| 725 | }; |
| 726 | |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 727 | static int bcm54xx_phy_probe(struct phy_device *phydev) |
Florian Fainelli | 28dc4c8 | 2017-12-14 17:48:16 -0800 | [diff] [blame] | 728 | { |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 729 | struct bcm54xx_phy_priv *priv; |
Florian Fainelli | 28dc4c8 | 2017-12-14 17:48:16 -0800 | [diff] [blame] | 730 | |
| 731 | priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); |
| 732 | if (!priv) |
| 733 | return -ENOMEM; |
| 734 | |
| 735 | phydev->priv = priv; |
| 736 | |
| 737 | priv->stats = devm_kcalloc(&phydev->mdio.dev, |
| 738 | bcm_phy_get_sset_count(phydev), sizeof(u64), |
| 739 | GFP_KERNEL); |
| 740 | if (!priv->stats) |
| 741 | return -ENOMEM; |
| 742 | |
| 743 | return 0; |
| 744 | } |
| 745 | |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 746 | static void bcm54xx_get_stats(struct phy_device *phydev, |
| 747 | struct ethtool_stats *stats, u64 *data) |
Florian Fainelli | 28dc4c8 | 2017-12-14 17:48:16 -0800 | [diff] [blame] | 748 | { |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 749 | struct bcm54xx_phy_priv *priv = phydev->priv; |
Florian Fainelli | 28dc4c8 | 2017-12-14 17:48:16 -0800 | [diff] [blame] | 750 | |
| 751 | bcm_phy_get_stats(phydev, priv->stats, stats, data); |
| 752 | } |
| 753 | |
Florian Fainelli | 8dc84dc | 2021-09-16 14:27:41 -0700 | [diff] [blame] | 754 | static void bcm54xx_link_change_notify(struct phy_device *phydev) |
| 755 | { |
| 756 | u16 mask = MII_BCM54XX_EXP_EXP08_EARLY_DAC_WAKE | |
| 757 | MII_BCM54XX_EXP_EXP08_FORCE_DAC_WAKE; |
| 758 | int ret; |
| 759 | |
| 760 | if (phydev->state != PHY_RUNNING) |
| 761 | return; |
| 762 | |
| 763 | /* Don't change the DAC wake settings if auto power down |
| 764 | * is not requested. |
| 765 | */ |
| 766 | if (!(phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE)) |
| 767 | return; |
| 768 | |
| 769 | ret = bcm_phy_read_exp(phydev, MII_BCM54XX_EXP_EXP08); |
| 770 | if (ret < 0) |
| 771 | return; |
| 772 | |
| 773 | /* Enable/disable 10BaseT auto and forced early DAC wake depending |
| 774 | * on the negotiated speed, those settings should only be done |
| 775 | * for 10Mbits/sec. |
| 776 | */ |
| 777 | if (phydev->speed == SPEED_10) |
| 778 | ret |= mask; |
| 779 | else |
| 780 | ret &= ~mask; |
| 781 | bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP08, ret); |
| 782 | } |
| 783 | |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 784 | static struct phy_driver broadcom_drivers[] = { |
| 785 | { |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 786 | .phy_id = PHY_ID_BCM5411, |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 787 | .phy_id_mask = 0xfffffff0, |
| 788 | .name = "Broadcom BCM5411", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 789 | /* PHY_GBIT_FEATURES */ |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 790 | .get_sset_count = bcm_phy_get_sset_count, |
| 791 | .get_strings = bcm_phy_get_strings, |
| 792 | .get_stats = bcm54xx_get_stats, |
| 793 | .probe = bcm54xx_phy_probe, |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 794 | .config_init = bcm54xx_config_init, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 795 | .config_intr = bcm_phy_config_intr, |
Ioana Ciornei | 4567d5c | 2020-11-01 14:51:06 +0200 | [diff] [blame] | 796 | .handle_interrupt = bcm_phy_handle_interrupt, |
Florian Fainelli | 8dc84dc | 2021-09-16 14:27:41 -0700 | [diff] [blame] | 797 | .link_change_notify = bcm54xx_link_change_notify, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 798 | }, { |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 799 | .phy_id = PHY_ID_BCM5421, |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 800 | .phy_id_mask = 0xfffffff0, |
| 801 | .name = "Broadcom BCM5421", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 802 | /* PHY_GBIT_FEATURES */ |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 803 | .get_sset_count = bcm_phy_get_sset_count, |
| 804 | .get_strings = bcm_phy_get_strings, |
| 805 | .get_stats = bcm54xx_get_stats, |
| 806 | .probe = bcm54xx_phy_probe, |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 807 | .config_init = bcm54xx_config_init, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 808 | .config_intr = bcm_phy_config_intr, |
Ioana Ciornei | 4567d5c | 2020-11-01 14:51:06 +0200 | [diff] [blame] | 809 | .handle_interrupt = bcm_phy_handle_interrupt, |
Florian Fainelli | 8dc84dc | 2021-09-16 14:27:41 -0700 | [diff] [blame] | 810 | .link_change_notify = bcm54xx_link_change_notify, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 811 | }, { |
Rafał Miłecki | 0fc9ae1 | 2017-01-27 14:07:01 +0100 | [diff] [blame] | 812 | .phy_id = PHY_ID_BCM54210E, |
| 813 | .phy_id_mask = 0xfffffff0, |
| 814 | .name = "Broadcom BCM54210E", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 815 | /* PHY_GBIT_FEATURES */ |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 816 | .get_sset_count = bcm_phy_get_sset_count, |
| 817 | .get_strings = bcm_phy_get_strings, |
| 818 | .get_stats = bcm54xx_get_stats, |
| 819 | .probe = bcm54xx_phy_probe, |
Rafał Miłecki | 0fc9ae1 | 2017-01-27 14:07:01 +0100 | [diff] [blame] | 820 | .config_init = bcm54xx_config_init, |
Rafał Miłecki | 0fc9ae1 | 2017-01-27 14:07:01 +0100 | [diff] [blame] | 821 | .config_intr = bcm_phy_config_intr, |
Ioana Ciornei | 4567d5c | 2020-11-01 14:51:06 +0200 | [diff] [blame] | 822 | .handle_interrupt = bcm_phy_handle_interrupt, |
Florian Fainelli | 8dc84dc | 2021-09-16 14:27:41 -0700 | [diff] [blame] | 823 | .link_change_notify = bcm54xx_link_change_notify, |
Florian Fainelli | d6da08e | 2021-09-20 14:54:14 -0700 | [diff] [blame] | 824 | .suspend = bcm54xx_suspend, |
| 825 | .resume = bcm54xx_resume, |
Rafał Miłecki | 0fc9ae1 | 2017-01-27 14:07:01 +0100 | [diff] [blame] | 826 | }, { |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 827 | .phy_id = PHY_ID_BCM5461, |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 828 | .phy_id_mask = 0xfffffff0, |
| 829 | .name = "Broadcom BCM5461", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 830 | /* PHY_GBIT_FEATURES */ |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 831 | .get_sset_count = bcm_phy_get_sset_count, |
| 832 | .get_strings = bcm_phy_get_strings, |
| 833 | .get_stats = bcm54xx_get_stats, |
| 834 | .probe = bcm54xx_phy_probe, |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 835 | .config_init = bcm54xx_config_init, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 836 | .config_intr = bcm_phy_config_intr, |
Ioana Ciornei | 4567d5c | 2020-11-01 14:51:06 +0200 | [diff] [blame] | 837 | .handle_interrupt = bcm_phy_handle_interrupt, |
Florian Fainelli | 8dc84dc | 2021-09-16 14:27:41 -0700 | [diff] [blame] | 838 | .link_change_notify = bcm54xx_link_change_notify, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 839 | }, { |
Xo Wang | d92ead1 | 2016-10-21 10:20:13 -0700 | [diff] [blame] | 840 | .phy_id = PHY_ID_BCM54612E, |
| 841 | .phy_id_mask = 0xfffffff0, |
| 842 | .name = "Broadcom BCM54612E", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 843 | /* PHY_GBIT_FEATURES */ |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 844 | .get_sset_count = bcm_phy_get_sset_count, |
| 845 | .get_strings = bcm_phy_get_strings, |
| 846 | .get_stats = bcm54xx_get_stats, |
| 847 | .probe = bcm54xx_phy_probe, |
Xo Wang | d92ead1 | 2016-10-21 10:20:13 -0700 | [diff] [blame] | 848 | .config_init = bcm54xx_config_init, |
Xo Wang | d92ead1 | 2016-10-21 10:20:13 -0700 | [diff] [blame] | 849 | .config_intr = bcm_phy_config_intr, |
Ioana Ciornei | 4567d5c | 2020-11-01 14:51:06 +0200 | [diff] [blame] | 850 | .handle_interrupt = bcm_phy_handle_interrupt, |
Florian Fainelli | 8dc84dc | 2021-09-16 14:27:41 -0700 | [diff] [blame] | 851 | .link_change_notify = bcm54xx_link_change_notify, |
Xo Wang | d92ead1 | 2016-10-21 10:20:13 -0700 | [diff] [blame] | 852 | }, { |
Alessio Igor Bogani | 3bca4cf6 | 2015-04-08 12:15:18 +0200 | [diff] [blame] | 853 | .phy_id = PHY_ID_BCM54616S, |
| 854 | .phy_id_mask = 0xfffffff0, |
| 855 | .name = "Broadcom BCM54616S", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 856 | /* PHY_GBIT_FEATURES */ |
Alessio Igor Bogani | 3bca4cf6 | 2015-04-08 12:15:18 +0200 | [diff] [blame] | 857 | .config_init = bcm54xx_config_init, |
Tao Ren | 042cb56 | 2018-11-05 14:35:40 -0800 | [diff] [blame] | 858 | .config_aneg = bcm54616s_config_aneg, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 859 | .config_intr = bcm_phy_config_intr, |
Ioana Ciornei | 4567d5c | 2020-11-01 14:51:06 +0200 | [diff] [blame] | 860 | .handle_interrupt = bcm_phy_handle_interrupt, |
Tao Ren | b9bcb95 | 2019-10-22 11:31:08 -0700 | [diff] [blame] | 861 | .read_status = bcm54616s_read_status, |
| 862 | .probe = bcm54616s_probe, |
Florian Fainelli | 8dc84dc | 2021-09-16 14:27:41 -0700 | [diff] [blame] | 863 | .link_change_notify = bcm54xx_link_change_notify, |
Alessio Igor Bogani | 3bca4cf6 | 2015-04-08 12:15:18 +0200 | [diff] [blame] | 864 | }, { |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 865 | .phy_id = PHY_ID_BCM5464, |
Paul Gortmaker | b1394f9 | 2008-04-14 23:35:41 -0400 | [diff] [blame] | 866 | .phy_id_mask = 0xfffffff0, |
| 867 | .name = "Broadcom BCM5464", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 868 | /* PHY_GBIT_FEATURES */ |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 869 | .get_sset_count = bcm_phy_get_sset_count, |
| 870 | .get_strings = bcm_phy_get_strings, |
| 871 | .get_stats = bcm54xx_get_stats, |
| 872 | .probe = bcm54xx_phy_probe, |
Paul Gortmaker | b1394f9 | 2008-04-14 23:35:41 -0400 | [diff] [blame] | 873 | .config_init = bcm54xx_config_init, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 874 | .config_intr = bcm_phy_config_intr, |
Ioana Ciornei | 4567d5c | 2020-11-01 14:51:06 +0200 | [diff] [blame] | 875 | .handle_interrupt = bcm_phy_handle_interrupt, |
Vladimir Oltean | 283da99 | 2019-06-08 16:53:56 +0300 | [diff] [blame] | 876 | .suspend = genphy_suspend, |
| 877 | .resume = genphy_resume, |
Florian Fainelli | 8dc84dc | 2021-09-16 14:27:41 -0700 | [diff] [blame] | 878 | .link_change_notify = bcm54xx_link_change_notify, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 879 | }, { |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 880 | .phy_id = PHY_ID_BCM5481, |
Anton Vorontsov | 57bb7e2 | 2008-03-04 19:41:32 +0300 | [diff] [blame] | 881 | .phy_id_mask = 0xfffffff0, |
| 882 | .name = "Broadcom BCM5481", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 883 | /* PHY_GBIT_FEATURES */ |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 884 | .get_sset_count = bcm_phy_get_sset_count, |
| 885 | .get_strings = bcm_phy_get_strings, |
| 886 | .get_stats = bcm54xx_get_stats, |
| 887 | .probe = bcm54xx_phy_probe, |
Anton Vorontsov | 57bb7e2 | 2008-03-04 19:41:32 +0300 | [diff] [blame] | 888 | .config_init = bcm54xx_config_init, |
Heiner Kallweit | 9753c21 | 2017-12-02 10:50:37 +0100 | [diff] [blame] | 889 | .config_aneg = bcm5481_config_aneg, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 890 | .config_intr = bcm_phy_config_intr, |
Ioana Ciornei | 4567d5c | 2020-11-01 14:51:06 +0200 | [diff] [blame] | 891 | .handle_interrupt = bcm_phy_handle_interrupt, |
Florian Fainelli | 8dc84dc | 2021-09-16 14:27:41 -0700 | [diff] [blame] | 892 | .link_change_notify = bcm54xx_link_change_notify, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 893 | }, { |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 894 | .phy_id = PHY_ID_BCM54810, |
| 895 | .phy_id_mask = 0xfffffff0, |
| 896 | .name = "Broadcom BCM54810", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 897 | /* PHY_GBIT_FEATURES */ |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 898 | .get_sset_count = bcm_phy_get_sset_count, |
| 899 | .get_strings = bcm_phy_get_strings, |
| 900 | .get_stats = bcm54xx_get_stats, |
| 901 | .probe = bcm54xx_phy_probe, |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 902 | .config_init = bcm54xx_config_init, |
Heiner Kallweit | 9753c21 | 2017-12-02 10:50:37 +0100 | [diff] [blame] | 903 | .config_aneg = bcm5481_config_aneg, |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 904 | .config_intr = bcm_phy_config_intr, |
Ioana Ciornei | 4567d5c | 2020-11-01 14:51:06 +0200 | [diff] [blame] | 905 | .handle_interrupt = bcm_phy_handle_interrupt, |
Florian Fainelli | 72e78d2 | 2021-09-20 14:54:16 -0700 | [diff] [blame] | 906 | .suspend = bcm54xx_suspend, |
Florian Fainelli | fe26821 | 2020-02-19 12:00:49 -0800 | [diff] [blame] | 907 | .resume = bcm54xx_resume, |
Florian Fainelli | 8dc84dc | 2021-09-16 14:27:41 -0700 | [diff] [blame] | 908 | .link_change_notify = bcm54xx_link_change_notify, |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 909 | }, { |
Kevin Lo | b0ed0bb | 2020-05-16 01:24:47 +0800 | [diff] [blame] | 910 | .phy_id = PHY_ID_BCM54811, |
| 911 | .phy_id_mask = 0xfffffff0, |
| 912 | .name = "Broadcom BCM54811", |
| 913 | /* PHY_GBIT_FEATURES */ |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 914 | .get_sset_count = bcm_phy_get_sset_count, |
| 915 | .get_strings = bcm_phy_get_strings, |
| 916 | .get_stats = bcm54xx_get_stats, |
| 917 | .probe = bcm54xx_phy_probe, |
Kevin Lo | b0ed0bb | 2020-05-16 01:24:47 +0800 | [diff] [blame] | 918 | .config_init = bcm54811_config_init, |
| 919 | .config_aneg = bcm5481_config_aneg, |
Kevin Lo | b0ed0bb | 2020-05-16 01:24:47 +0800 | [diff] [blame] | 920 | .config_intr = bcm_phy_config_intr, |
Ioana Ciornei | 4567d5c | 2020-11-01 14:51:06 +0200 | [diff] [blame] | 921 | .handle_interrupt = bcm_phy_handle_interrupt, |
Florian Fainelli | 72e78d2 | 2021-09-20 14:54:16 -0700 | [diff] [blame] | 922 | .suspend = bcm54xx_suspend, |
Kevin Lo | b0ed0bb | 2020-05-16 01:24:47 +0800 | [diff] [blame] | 923 | .resume = bcm54xx_resume, |
Florian Fainelli | 8dc84dc | 2021-09-16 14:27:41 -0700 | [diff] [blame] | 924 | .link_change_notify = bcm54xx_link_change_notify, |
Kevin Lo | b0ed0bb | 2020-05-16 01:24:47 +0800 | [diff] [blame] | 925 | }, { |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 926 | .phy_id = PHY_ID_BCM5482, |
Nate Case | 03157ac | 2008-01-29 10:19:00 -0600 | [diff] [blame] | 927 | .phy_id_mask = 0xfffffff0, |
| 928 | .name = "Broadcom BCM5482", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 929 | /* PHY_GBIT_FEATURES */ |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 930 | .get_sset_count = bcm_phy_get_sset_count, |
| 931 | .get_strings = bcm_phy_get_strings, |
| 932 | .get_stats = bcm54xx_get_stats, |
| 933 | .probe = bcm54xx_phy_probe, |
Michael Walle | 1e2e61af | 2021-02-09 00:17:06 +0100 | [diff] [blame] | 934 | .config_init = bcm54xx_config_init, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 935 | .config_intr = bcm_phy_config_intr, |
Ioana Ciornei | 4567d5c | 2020-11-01 14:51:06 +0200 | [diff] [blame] | 936 | .handle_interrupt = bcm_phy_handle_interrupt, |
Florian Fainelli | 8dc84dc | 2021-09-16 14:27:41 -0700 | [diff] [blame] | 937 | .link_change_notify = bcm54xx_link_change_notify, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 938 | }, { |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 939 | .phy_id = PHY_ID_BCM50610, |
| 940 | .phy_id_mask = 0xfffffff0, |
| 941 | .name = "Broadcom BCM50610", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 942 | /* PHY_GBIT_FEATURES */ |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 943 | .get_sset_count = bcm_phy_get_sset_count, |
| 944 | .get_strings = bcm_phy_get_strings, |
| 945 | .get_stats = bcm54xx_get_stats, |
| 946 | .probe = bcm54xx_phy_probe, |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 947 | .config_init = bcm54xx_config_init, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 948 | .config_intr = bcm_phy_config_intr, |
Ioana Ciornei | 4567d5c | 2020-11-01 14:51:06 +0200 | [diff] [blame] | 949 | .handle_interrupt = bcm_phy_handle_interrupt, |
Florian Fainelli | 8dc84dc | 2021-09-16 14:27:41 -0700 | [diff] [blame] | 950 | .link_change_notify = bcm54xx_link_change_notify, |
Florian Fainelli | 38b6a90 | 2021-09-20 14:54:15 -0700 | [diff] [blame] | 951 | .suspend = bcm54xx_suspend, |
| 952 | .resume = bcm54xx_resume, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 953 | }, { |
Matt Carlson | 4f4598f | 2009-08-25 10:10:30 +0000 | [diff] [blame] | 954 | .phy_id = PHY_ID_BCM50610M, |
| 955 | .phy_id_mask = 0xfffffff0, |
| 956 | .name = "Broadcom BCM50610M", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 957 | /* PHY_GBIT_FEATURES */ |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 958 | .get_sset_count = bcm_phy_get_sset_count, |
| 959 | .get_strings = bcm_phy_get_strings, |
| 960 | .get_stats = bcm54xx_get_stats, |
| 961 | .probe = bcm54xx_phy_probe, |
Matt Carlson | 4f4598f | 2009-08-25 10:10:30 +0000 | [diff] [blame] | 962 | .config_init = bcm54xx_config_init, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 963 | .config_intr = bcm_phy_config_intr, |
Ioana Ciornei | 4567d5c | 2020-11-01 14:51:06 +0200 | [diff] [blame] | 964 | .handle_interrupt = bcm_phy_handle_interrupt, |
Florian Fainelli | 8dc84dc | 2021-09-16 14:27:41 -0700 | [diff] [blame] | 965 | .link_change_notify = bcm54xx_link_change_notify, |
Florian Fainelli | 38b6a90 | 2021-09-20 14:54:15 -0700 | [diff] [blame] | 966 | .suspend = bcm54xx_suspend, |
| 967 | .resume = bcm54xx_resume, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 968 | }, { |
Matt Carlson | d9221e6 | 2009-08-25 10:11:26 +0000 | [diff] [blame] | 969 | .phy_id = PHY_ID_BCM57780, |
Matt Carlson | 2fbb69a | 2008-11-21 17:22:53 -0800 | [diff] [blame] | 970 | .phy_id_mask = 0xfffffff0, |
| 971 | .name = "Broadcom BCM57780", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 972 | /* PHY_GBIT_FEATURES */ |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 973 | .get_sset_count = bcm_phy_get_sset_count, |
| 974 | .get_strings = bcm_phy_get_strings, |
| 975 | .get_stats = bcm54xx_get_stats, |
| 976 | .probe = bcm54xx_phy_probe, |
Matt Carlson | 2fbb69a | 2008-11-21 17:22:53 -0800 | [diff] [blame] | 977 | .config_init = bcm54xx_config_init, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 978 | .config_intr = bcm_phy_config_intr, |
Ioana Ciornei | 4567d5c | 2020-11-01 14:51:06 +0200 | [diff] [blame] | 979 | .handle_interrupt = bcm_phy_handle_interrupt, |
Florian Fainelli | 8dc84dc | 2021-09-16 14:27:41 -0700 | [diff] [blame] | 980 | .link_change_notify = bcm54xx_link_change_notify, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 981 | }, { |
Matt Carlson | 6a443a0 | 2010-02-17 15:17:04 +0000 | [diff] [blame] | 982 | .phy_id = PHY_ID_BCMAC131, |
Matt Carlson | d7a2ed9 | 2009-08-25 10:10:58 +0000 | [diff] [blame] | 983 | .phy_id_mask = 0xfffffff0, |
| 984 | .name = "Broadcom BCMAC131", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 985 | /* PHY_BASIC_FEATURES */ |
Matt Carlson | d7a2ed9 | 2009-08-25 10:10:58 +0000 | [diff] [blame] | 986 | .config_init = brcm_fet_config_init, |
Matt Carlson | d7a2ed9 | 2009-08-25 10:10:58 +0000 | [diff] [blame] | 987 | .config_intr = brcm_fet_config_intr, |
Ioana Ciornei | 4567d5c | 2020-11-01 14:51:06 +0200 | [diff] [blame] | 988 | .handle_interrupt = brcm_fet_handle_interrupt, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 989 | }, { |
Dmitry Baryshkov | 7a938f8 | 2010-06-16 23:02:24 +0000 | [diff] [blame] | 990 | .phy_id = PHY_ID_BCM5241, |
| 991 | .phy_id_mask = 0xfffffff0, |
| 992 | .name = "Broadcom BCM5241", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 993 | /* PHY_BASIC_FEATURES */ |
Dmitry Baryshkov | 7a938f8 | 2010-06-16 23:02:24 +0000 | [diff] [blame] | 994 | .config_init = brcm_fet_config_init, |
Dmitry Baryshkov | 7a938f8 | 2010-06-16 23:02:24 +0000 | [diff] [blame] | 995 | .config_intr = brcm_fet_config_intr, |
Ioana Ciornei | 4567d5c | 2020-11-01 14:51:06 +0200 | [diff] [blame] | 996 | .handle_interrupt = brcm_fet_handle_interrupt, |
Florian Fainelli | 28dc4c8 | 2017-12-14 17:48:16 -0800 | [diff] [blame] | 997 | }, { |
| 998 | .phy_id = PHY_ID_BCM5395, |
| 999 | .phy_id_mask = 0xfffffff0, |
| 1000 | .name = "Broadcom BCM5395", |
| 1001 | .flags = PHY_IS_INTERNAL, |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 1002 | /* PHY_GBIT_FEATURES */ |
Florian Fainelli | 28dc4c8 | 2017-12-14 17:48:16 -0800 | [diff] [blame] | 1003 | .get_sset_count = bcm_phy_get_sset_count, |
| 1004 | .get_strings = bcm_phy_get_strings, |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 1005 | .get_stats = bcm54xx_get_stats, |
| 1006 | .probe = bcm54xx_phy_probe, |
Florian Fainelli | 8dc84dc | 2021-09-16 14:27:41 -0700 | [diff] [blame] | 1007 | .link_change_notify = bcm54xx_link_change_notify, |
Bhadram Varka | 23b8392 | 2018-05-02 20:43:58 +0530 | [diff] [blame] | 1008 | }, { |
Florian Fainelli | 123aff2 | 2020-04-17 11:38:02 -0700 | [diff] [blame] | 1009 | .phy_id = PHY_ID_BCM53125, |
| 1010 | .phy_id_mask = 0xfffffff0, |
| 1011 | .name = "Broadcom BCM53125", |
| 1012 | .flags = PHY_IS_INTERNAL, |
| 1013 | /* PHY_GBIT_FEATURES */ |
| 1014 | .get_sset_count = bcm_phy_get_sset_count, |
| 1015 | .get_strings = bcm_phy_get_strings, |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 1016 | .get_stats = bcm54xx_get_stats, |
| 1017 | .probe = bcm54xx_phy_probe, |
Florian Fainelli | 123aff2 | 2020-04-17 11:38:02 -0700 | [diff] [blame] | 1018 | .config_init = bcm54xx_config_init, |
Florian Fainelli | 123aff2 | 2020-04-17 11:38:02 -0700 | [diff] [blame] | 1019 | .config_intr = bcm_phy_config_intr, |
Ioana Ciornei | 4567d5c | 2020-11-01 14:51:06 +0200 | [diff] [blame] | 1020 | .handle_interrupt = bcm_phy_handle_interrupt, |
Florian Fainelli | 8dc84dc | 2021-09-16 14:27:41 -0700 | [diff] [blame] | 1021 | .link_change_notify = bcm54xx_link_change_notify, |
Florian Fainelli | 123aff2 | 2020-04-17 11:38:02 -0700 | [diff] [blame] | 1022 | }, { |
Bhadram Varka | 23b8392 | 2018-05-02 20:43:58 +0530 | [diff] [blame] | 1023 | .phy_id = PHY_ID_BCM89610, |
| 1024 | .phy_id_mask = 0xfffffff0, |
| 1025 | .name = "Broadcom BCM89610", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame] | 1026 | /* PHY_GBIT_FEATURES */ |
Florian Fainelli | 5a32fcd | 2021-04-01 09:42:33 -0700 | [diff] [blame] | 1027 | .get_sset_count = bcm_phy_get_sset_count, |
| 1028 | .get_strings = bcm_phy_get_strings, |
| 1029 | .get_stats = bcm54xx_get_stats, |
| 1030 | .probe = bcm54xx_phy_probe, |
Bhadram Varka | 23b8392 | 2018-05-02 20:43:58 +0530 | [diff] [blame] | 1031 | .config_init = bcm54xx_config_init, |
Bhadram Varka | 23b8392 | 2018-05-02 20:43:58 +0530 | [diff] [blame] | 1032 | .config_intr = bcm_phy_config_intr, |
Ioana Ciornei | 4567d5c | 2020-11-01 14:51:06 +0200 | [diff] [blame] | 1033 | .handle_interrupt = bcm_phy_handle_interrupt, |
Florian Fainelli | 8dc84dc | 2021-09-16 14:27:41 -0700 | [diff] [blame] | 1034 | .link_change_notify = bcm54xx_link_change_notify, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 1035 | } }; |
Dmitry Baryshkov | 7a938f8 | 2010-06-16 23:02:24 +0000 | [diff] [blame] | 1036 | |
Johan Hovold | 50fd715 | 2014-11-11 19:45:59 +0100 | [diff] [blame] | 1037 | module_phy_driver(broadcom_drivers); |
David Woodhouse | 4e4f10f | 2010-04-02 01:05:56 +0000 | [diff] [blame] | 1038 | |
Uwe Kleine-König | cf93c94 | 2010-10-03 23:43:32 +0000 | [diff] [blame] | 1039 | static struct mdio_device_id __maybe_unused broadcom_tbl[] = { |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 1040 | { PHY_ID_BCM5411, 0xfffffff0 }, |
| 1041 | { PHY_ID_BCM5421, 0xfffffff0 }, |
Rafał Miłecki | 0fc9ae1 | 2017-01-27 14:07:01 +0100 | [diff] [blame] | 1042 | { PHY_ID_BCM54210E, 0xfffffff0 }, |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 1043 | { PHY_ID_BCM5461, 0xfffffff0 }, |
Xo Wang | d92ead1 | 2016-10-21 10:20:13 -0700 | [diff] [blame] | 1044 | { PHY_ID_BCM54612E, 0xfffffff0 }, |
Alessio Igor Bogani | 3bca4cf6 | 2015-04-08 12:15:18 +0200 | [diff] [blame] | 1045 | { PHY_ID_BCM54616S, 0xfffffff0 }, |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 1046 | { PHY_ID_BCM5464, 0xfffffff0 }, |
Aaro Koskinen | 3c25a86 | 2015-11-22 01:08:54 +0200 | [diff] [blame] | 1047 | { PHY_ID_BCM5481, 0xfffffff0 }, |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 1048 | { PHY_ID_BCM54810, 0xfffffff0 }, |
Kevin Lo | b0ed0bb | 2020-05-16 01:24:47 +0800 | [diff] [blame] | 1049 | { PHY_ID_BCM54811, 0xfffffff0 }, |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 1050 | { PHY_ID_BCM5482, 0xfffffff0 }, |
David Woodhouse | 4e4f10f | 2010-04-02 01:05:56 +0000 | [diff] [blame] | 1051 | { PHY_ID_BCM50610, 0xfffffff0 }, |
| 1052 | { PHY_ID_BCM50610M, 0xfffffff0 }, |
| 1053 | { PHY_ID_BCM57780, 0xfffffff0 }, |
| 1054 | { PHY_ID_BCMAC131, 0xfffffff0 }, |
Dmitry Baryshkov | 7a938f8 | 2010-06-16 23:02:24 +0000 | [diff] [blame] | 1055 | { PHY_ID_BCM5241, 0xfffffff0 }, |
Florian Fainelli | 28dc4c8 | 2017-12-14 17:48:16 -0800 | [diff] [blame] | 1056 | { PHY_ID_BCM5395, 0xfffffff0 }, |
Florian Fainelli | 123aff2 | 2020-04-17 11:38:02 -0700 | [diff] [blame] | 1057 | { PHY_ID_BCM53125, 0xfffffff0 }, |
Bhadram Varka | 23b8392 | 2018-05-02 20:43:58 +0530 | [diff] [blame] | 1058 | { PHY_ID_BCM89610, 0xfffffff0 }, |
David Woodhouse | 4e4f10f | 2010-04-02 01:05:56 +0000 | [diff] [blame] | 1059 | { } |
| 1060 | }; |
| 1061 | |
| 1062 | MODULE_DEVICE_TABLE(mdio, broadcom_tbl); |