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 | |
Rafał Miłecki | 0fc9ae1 | 2017-01-27 14:07:01 +0100 | [diff] [blame] | 29 | static int bcm54210e_config_init(struct phy_device *phydev) |
| 30 | { |
| 31 | int val; |
| 32 | |
| 33 | val = bcm54xx_auxctl_read(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC); |
| 34 | val &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN; |
| 35 | val |= MII_BCM54XX_AUXCTL_MISC_WREN; |
| 36 | bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC, val); |
| 37 | |
| 38 | val = bcm_phy_read_shadow(phydev, BCM54810_SHD_CLK_CTL); |
| 39 | val &= ~BCM54810_SHD_CLK_CTL_GTXCLK_EN; |
| 40 | bcm_phy_write_shadow(phydev, BCM54810_SHD_CLK_CTL, val); |
| 41 | |
Rafał Miłecki | 2355a65 | 2017-10-12 10:21:25 +0200 | [diff] [blame] | 42 | if (phydev->dev_flags & PHY_BRCM_EN_MASTER_MODE) { |
| 43 | val = phy_read(phydev, MII_CTRL1000); |
| 44 | val |= CTL1000_AS_MASTER | CTL1000_ENABLE_MASTER; |
| 45 | phy_write(phydev, MII_CTRL1000, val); |
| 46 | } |
| 47 | |
Rafał Miłecki | 0fc9ae1 | 2017-01-27 14:07:01 +0100 | [diff] [blame] | 48 | return 0; |
| 49 | } |
| 50 | |
Rafał Miłecki | 62e1309 | 2017-01-31 22:54:54 +0100 | [diff] [blame] | 51 | static int bcm54612e_config_init(struct phy_device *phydev) |
| 52 | { |
Kun Yi | 69e2ecc | 2018-06-04 13:17:04 -0700 | [diff] [blame] | 53 | int reg; |
| 54 | |
Rafał Miłecki | 62e1309 | 2017-01-31 22:54:54 +0100 | [diff] [blame] | 55 | /* Clear TX internal delay unless requested. */ |
| 56 | if ((phydev->interface != PHY_INTERFACE_MODE_RGMII_ID) && |
| 57 | (phydev->interface != PHY_INTERFACE_MODE_RGMII_TXID)) { |
| 58 | /* Disable TXD to GTXCLK clock delay (default set) */ |
| 59 | /* Bit 9 is the only field in shadow register 00011 */ |
| 60 | bcm_phy_write_shadow(phydev, 0x03, 0); |
| 61 | } |
| 62 | |
| 63 | /* Clear RX internal delay unless requested. */ |
| 64 | if ((phydev->interface != PHY_INTERFACE_MODE_RGMII_ID) && |
| 65 | (phydev->interface != PHY_INTERFACE_MODE_RGMII_RXID)) { |
Rafał Miłecki | 62e1309 | 2017-01-31 22:54:54 +0100 | [diff] [blame] | 66 | reg = bcm54xx_auxctl_read(phydev, |
| 67 | MII_BCM54XX_AUXCTL_SHDWSEL_MISC); |
| 68 | /* Disable RXD to RXC delay (default set) */ |
| 69 | reg &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN; |
| 70 | /* Clear shadow selector field */ |
| 71 | reg &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MASK; |
| 72 | bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC, |
| 73 | MII_BCM54XX_AUXCTL_MISC_WREN | reg); |
| 74 | } |
| 75 | |
Kun Yi | 69e2ecc | 2018-06-04 13:17:04 -0700 | [diff] [blame] | 76 | /* Enable CLK125 MUX on LED4 if ref clock is enabled. */ |
| 77 | if (!(phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED)) { |
| 78 | int err; |
| 79 | |
| 80 | reg = bcm_phy_read_exp(phydev, BCM54612E_EXP_SPARE0); |
| 81 | err = bcm_phy_write_exp(phydev, BCM54612E_EXP_SPARE0, |
| 82 | BCM54612E_LED4_CLK125OUT_EN | reg); |
| 83 | |
| 84 | if (err < 0) |
| 85 | return err; |
| 86 | } |
| 87 | |
Rafał Miłecki | 62e1309 | 2017-01-31 22:54:54 +0100 | [diff] [blame] | 88 | return 0; |
| 89 | } |
| 90 | |
Tao Ren | 042cb56 | 2018-11-05 14:35:40 -0800 | [diff] [blame] | 91 | static int bcm54xx_config_clock_delay(struct phy_device *phydev) |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 92 | { |
| 93 | int rc, val; |
| 94 | |
Abhishek Shah | 7333362 | 2017-04-30 11:04:21 +0530 | [diff] [blame] | 95 | /* handling PHY's internal RX clock delay */ |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 96 | val = bcm54xx_auxctl_read(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC); |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 97 | val |= MII_BCM54XX_AUXCTL_MISC_WREN; |
Abhishek Shah | 7333362 | 2017-04-30 11:04:21 +0530 | [diff] [blame] | 98 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII || |
| 99 | phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) { |
| 100 | /* Disable RGMII RXC-RXD skew */ |
| 101 | val &= ~MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN; |
| 102 | } |
| 103 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || |
| 104 | phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) { |
| 105 | /* Enable RGMII RXC-RXD skew */ |
| 106 | val |= MII_BCM54XX_AUXCTL_SHDWSEL_MISC_RGMII_SKEW_EN; |
| 107 | } |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 108 | rc = bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC, |
| 109 | val); |
| 110 | if (rc < 0) |
| 111 | return rc; |
| 112 | |
Abhishek Shah | 7333362 | 2017-04-30 11:04:21 +0530 | [diff] [blame] | 113 | /* handling PHY's internal TX clock delay */ |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 114 | val = bcm_phy_read_shadow(phydev, BCM54810_SHD_CLK_CTL); |
Abhishek Shah | 7333362 | 2017-04-30 11:04:21 +0530 | [diff] [blame] | 115 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII || |
| 116 | phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) { |
| 117 | /* Disable internal TX clock delay */ |
| 118 | val &= ~BCM54810_SHD_CLK_CTL_GTXCLK_EN; |
| 119 | } |
| 120 | if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID || |
| 121 | phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) { |
| 122 | /* Enable internal TX clock delay */ |
| 123 | val |= BCM54810_SHD_CLK_CTL_GTXCLK_EN; |
| 124 | } |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 125 | rc = bcm_phy_write_shadow(phydev, BCM54810_SHD_CLK_CTL, val); |
| 126 | if (rc < 0) |
| 127 | return rc; |
| 128 | |
| 129 | return 0; |
| 130 | } |
| 131 | |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 132 | /* Needs SMDSP clock enabled via bcm54xx_phydsp_config() */ |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 133 | static int bcm50610_a0_workaround(struct phy_device *phydev) |
| 134 | { |
| 135 | int err; |
| 136 | |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 137 | err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_AADJ1CH0, |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 138 | MII_BCM54XX_EXP_AADJ1CH0_SWP_ABCD_OEN | |
| 139 | MII_BCM54XX_EXP_AADJ1CH0_SWSEL_THPF); |
| 140 | if (err < 0) |
| 141 | return err; |
| 142 | |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 143 | err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_AADJ1CH3, |
| 144 | MII_BCM54XX_EXP_AADJ1CH3_ADCCKADJ); |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 145 | if (err < 0) |
| 146 | return err; |
| 147 | |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 148 | err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP75, |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 149 | MII_BCM54XX_EXP_EXP75_VDACCTRL); |
| 150 | if (err < 0) |
| 151 | return err; |
| 152 | |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 153 | err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP96, |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 154 | MII_BCM54XX_EXP_EXP96_MYST); |
| 155 | if (err < 0) |
| 156 | return err; |
| 157 | |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 158 | err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP97, |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 159 | MII_BCM54XX_EXP_EXP97_MYST); |
| 160 | |
| 161 | return err; |
| 162 | } |
| 163 | |
| 164 | static int bcm54xx_phydsp_config(struct phy_device *phydev) |
| 165 | { |
| 166 | int err, err2; |
| 167 | |
| 168 | /* Enable the SMDSP clock */ |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 169 | err = bcm54xx_auxctl_write(phydev, |
| 170 | MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL, |
| 171 | MII_BCM54XX_AUXCTL_ACTL_SMDSP_ENA | |
| 172 | MII_BCM54XX_AUXCTL_ACTL_TX_6DB); |
| 173 | if (err < 0) |
| 174 | return err; |
| 175 | |
Matt Carlson | 219c6ef | 2009-11-02 14:28:33 +0000 | [diff] [blame] | 176 | if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 || |
| 177 | BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) { |
| 178 | /* Clear bit 9 to fix a phy interop issue. */ |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 179 | err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP08, |
Matt Carlson | 219c6ef | 2009-11-02 14:28:33 +0000 | [diff] [blame] | 180 | MII_BCM54XX_EXP_EXP08_RJCT_2MHZ); |
| 181 | if (err < 0) |
| 182 | goto error; |
| 183 | |
| 184 | if (phydev->drv->phy_id == PHY_ID_BCM50610) { |
| 185 | err = bcm50610_a0_workaround(phydev); |
| 186 | if (err < 0) |
| 187 | goto error; |
| 188 | } |
| 189 | } |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 190 | |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 191 | if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM57780) { |
| 192 | int val; |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 193 | |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 194 | val = bcm_phy_read_exp(phydev, MII_BCM54XX_EXP_EXP75); |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 195 | if (val < 0) |
| 196 | goto error; |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 197 | |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 198 | val |= MII_BCM54XX_EXP_EXP75_CM_OSC; |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 199 | err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP75, val); |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 200 | } |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 201 | |
| 202 | error: |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 203 | /* Disable the SMDSP clock */ |
| 204 | err2 = bcm54xx_auxctl_write(phydev, |
| 205 | MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL, |
| 206 | MII_BCM54XX_AUXCTL_ACTL_TX_6DB); |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 207 | |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 208 | /* Return the first error reported. */ |
| 209 | return err ? err : err2; |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 210 | } |
| 211 | |
Matt Carlson | 32e5a8d | 2009-11-02 14:31:39 +0000 | [diff] [blame] | 212 | static void bcm54xx_adjust_rxrefclk(struct phy_device *phydev) |
| 213 | { |
Roel Kluin | 5ee6f6a | 2009-12-18 20:16:10 -0800 | [diff] [blame] | 214 | u32 orig; |
| 215 | int val; |
Matt Carlson | c704dc2 | 2009-11-02 14:32:12 +0000 | [diff] [blame] | 216 | bool clk125en = true; |
Matt Carlson | 32e5a8d | 2009-11-02 14:31:39 +0000 | [diff] [blame] | 217 | |
| 218 | /* Abort if we are using an untested phy. */ |
roel kluin | 7ec4e7d | 2009-12-30 06:43:06 +0000 | [diff] [blame] | 219 | if (BRCM_PHY_MODEL(phydev) != PHY_ID_BCM57780 && |
| 220 | BRCM_PHY_MODEL(phydev) != PHY_ID_BCM50610 && |
Matt Carlson | 32e5a8d | 2009-11-02 14:31:39 +0000 | [diff] [blame] | 221 | BRCM_PHY_MODEL(phydev) != PHY_ID_BCM50610M) |
| 222 | return; |
| 223 | |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 224 | val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_SCR3); |
Matt Carlson | 32e5a8d | 2009-11-02 14:31:39 +0000 | [diff] [blame] | 225 | if (val < 0) |
| 226 | return; |
| 227 | |
| 228 | orig = val; |
| 229 | |
Matt Carlson | c704dc2 | 2009-11-02 14:32:12 +0000 | [diff] [blame] | 230 | if ((BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 || |
| 231 | BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) && |
| 232 | BRCM_PHY_REV(phydev) >= 0x3) { |
| 233 | /* |
| 234 | * Here, bit 0 _disables_ CLK125 when set. |
| 235 | * This bit is set by default. |
| 236 | */ |
| 237 | clk125en = false; |
| 238 | } else { |
| 239 | if (phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED) { |
Matt Carlson | 32e5a8d | 2009-11-02 14:31:39 +0000 | [diff] [blame] | 240 | /* Here, bit 0 _enables_ CLK125 when set */ |
| 241 | val &= ~BCM54XX_SHD_SCR3_DEF_CLK125; |
Matt Carlson | c704dc2 | 2009-11-02 14:32:12 +0000 | [diff] [blame] | 242 | clk125en = false; |
Matt Carlson | 32e5a8d | 2009-11-02 14:31:39 +0000 | [diff] [blame] | 243 | } |
| 244 | } |
| 245 | |
Joe Perches | 23677ce | 2012-02-09 11:17:23 +0000 | [diff] [blame] | 246 | if (!clk125en || (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE)) |
Matt Carlson | c704dc2 | 2009-11-02 14:32:12 +0000 | [diff] [blame] | 247 | val &= ~BCM54XX_SHD_SCR3_DLLAPD_DIS; |
| 248 | else |
| 249 | val |= BCM54XX_SHD_SCR3_DLLAPD_DIS; |
| 250 | |
Matt Carlson | 52fae08 | 2009-11-02 14:32:38 +0000 | [diff] [blame] | 251 | if (phydev->dev_flags & PHY_BRCM_DIS_TXCRXC_NOENRGY) |
| 252 | val |= BCM54XX_SHD_SCR3_TRDDAPD; |
| 253 | |
Matt Carlson | 32e5a8d | 2009-11-02 14:31:39 +0000 | [diff] [blame] | 254 | if (orig != val) |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 255 | bcm_phy_write_shadow(phydev, BCM54XX_SHD_SCR3, val); |
Matt Carlson | c704dc2 | 2009-11-02 14:32:12 +0000 | [diff] [blame] | 256 | |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 257 | val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_APD); |
Matt Carlson | c704dc2 | 2009-11-02 14:32:12 +0000 | [diff] [blame] | 258 | if (val < 0) |
| 259 | return; |
| 260 | |
| 261 | orig = val; |
| 262 | |
Joe Perches | 23677ce | 2012-02-09 11:17:23 +0000 | [diff] [blame] | 263 | if (!clk125en || (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE)) |
Matt Carlson | c704dc2 | 2009-11-02 14:32:12 +0000 | [diff] [blame] | 264 | val |= BCM54XX_SHD_APD_EN; |
| 265 | else |
| 266 | val &= ~BCM54XX_SHD_APD_EN; |
| 267 | |
| 268 | if (orig != val) |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 269 | bcm_phy_write_shadow(phydev, BCM54XX_SHD_APD, val); |
Matt Carlson | 32e5a8d | 2009-11-02 14:31:39 +0000 | [diff] [blame] | 270 | } |
| 271 | |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 272 | static int bcm54xx_config_init(struct phy_device *phydev) |
| 273 | { |
Abhishek Shah | 7333362 | 2017-04-30 11:04:21 +0530 | [diff] [blame] | 274 | int reg, err, val; |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 275 | |
| 276 | reg = phy_read(phydev, MII_BCM54XX_ECR); |
| 277 | if (reg < 0) |
| 278 | return reg; |
| 279 | |
| 280 | /* Mask interrupts globally. */ |
| 281 | reg |= MII_BCM54XX_ECR_IM; |
| 282 | err = phy_write(phydev, MII_BCM54XX_ECR, reg); |
| 283 | if (err < 0) |
| 284 | return err; |
| 285 | |
| 286 | /* Unmask events we are interested in. */ |
| 287 | reg = ~(MII_BCM54XX_INT_DUPLEX | |
| 288 | MII_BCM54XX_INT_SPEED | |
| 289 | MII_BCM54XX_INT_LINK); |
| 290 | err = phy_write(phydev, MII_BCM54XX_IMR, reg); |
| 291 | if (err < 0) |
| 292 | return err; |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 293 | |
Matt Carlson | 63a14ce | 2009-11-02 14:30:40 +0000 | [diff] [blame] | 294 | if ((BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610 || |
| 295 | BRCM_PHY_MODEL(phydev) == PHY_ID_BCM50610M) && |
| 296 | (phydev->dev_flags & PHY_BRCM_CLEAR_RGMII_MODE)) |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 297 | bcm_phy_write_shadow(phydev, BCM54XX_SHD_RGMII_MODE, 0); |
Matt Carlson | 63a14ce | 2009-11-02 14:30:40 +0000 | [diff] [blame] | 298 | |
Matt Carlson | c704dc2 | 2009-11-02 14:32:12 +0000 | [diff] [blame] | 299 | if ((phydev->dev_flags & PHY_BRCM_RX_REFCLK_UNUSED) || |
Matt Carlson | 52fae08 | 2009-11-02 14:32:38 +0000 | [diff] [blame] | 300 | (phydev->dev_flags & PHY_BRCM_DIS_TXCRXC_NOENRGY) || |
Matt Carlson | c704dc2 | 2009-11-02 14:32:12 +0000 | [diff] [blame] | 301 | (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE)) |
Matt Carlson | 32e5a8d | 2009-11-02 14:31:39 +0000 | [diff] [blame] | 302 | bcm54xx_adjust_rxrefclk(phydev); |
| 303 | |
Rafał Miłecki | 0fc9ae1 | 2017-01-27 14:07:01 +0100 | [diff] [blame] | 304 | if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54210E) { |
| 305 | err = bcm54210e_config_init(phydev); |
| 306 | if (err) |
| 307 | return err; |
Rafał Miłecki | 62e1309 | 2017-01-31 22:54:54 +0100 | [diff] [blame] | 308 | } else if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54612E) { |
| 309 | err = bcm54612e_config_init(phydev); |
| 310 | if (err) |
| 311 | return err; |
Rafał Miłecki | 0fc9ae1 | 2017-01-27 14:07:01 +0100 | [diff] [blame] | 312 | } else if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810) { |
Abhishek Shah | 7333362 | 2017-04-30 11:04:21 +0530 | [diff] [blame] | 313 | /* For BCM54810, we need to disable BroadR-Reach function */ |
| 314 | val = bcm_phy_read_exp(phydev, |
| 315 | BCM54810_EXP_BROADREACH_LRE_MISC_CTL); |
| 316 | val &= ~BCM54810_EXP_BROADREACH_LRE_MISC_CTL_EN; |
| 317 | err = bcm_phy_write_exp(phydev, |
| 318 | BCM54810_EXP_BROADREACH_LRE_MISC_CTL, |
| 319 | val); |
| 320 | if (err < 0) |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 321 | return err; |
| 322 | } |
| 323 | |
Matt Carlson | 47b1b53 | 2009-11-02 14:28:04 +0000 | [diff] [blame] | 324 | bcm54xx_phydsp_config(phydev); |
Matt Carlson | d9221e6 | 2009-08-25 10:11:26 +0000 | [diff] [blame] | 325 | |
Vladimir Oltean | 450895d | 2019-03-24 00:18:46 +0200 | [diff] [blame] | 326 | /* Encode link speed into LED1 and LED3 pair (green/amber). |
| 327 | * Also flash these two LEDs on activity. This means configuring |
| 328 | * them for MULTICOLOR and encoding link/activity into them. |
| 329 | */ |
| 330 | val = BCM5482_SHD_LEDS1_LED1(BCM_LED_SRC_MULTICOLOR1) | |
| 331 | BCM5482_SHD_LEDS1_LED3(BCM_LED_SRC_MULTICOLOR1); |
| 332 | bcm_phy_write_shadow(phydev, BCM5482_SHD_LEDS1, val); |
| 333 | |
| 334 | val = BCM_LED_MULTICOLOR_IN_PHASE | |
| 335 | BCM5482_SHD_LEDS1_LED1(BCM_LED_MULTICOLOR_LINK_ACT) | |
| 336 | BCM5482_SHD_LEDS1_LED3(BCM_LED_MULTICOLOR_LINK_ACT); |
| 337 | bcm_phy_write_exp(phydev, BCM_EXP_MULTICOLOR, val); |
| 338 | |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 339 | return 0; |
| 340 | } |
| 341 | |
Nate Case | cd9af3d | 2008-05-17 06:40:39 +0100 | [diff] [blame] | 342 | static int bcm5482_config_init(struct phy_device *phydev) |
| 343 | { |
| 344 | int err, reg; |
| 345 | |
| 346 | err = bcm54xx_config_init(phydev); |
| 347 | |
| 348 | if (phydev->dev_flags & PHY_BCM_FLAGS_MODE_1000BX) { |
| 349 | /* |
| 350 | * Enable secondary SerDes and its use as an LED source |
| 351 | */ |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 352 | reg = bcm_phy_read_shadow(phydev, BCM5482_SHD_SSD); |
| 353 | bcm_phy_write_shadow(phydev, BCM5482_SHD_SSD, |
Nate Case | cd9af3d | 2008-05-17 06:40:39 +0100 | [diff] [blame] | 354 | reg | |
| 355 | BCM5482_SHD_SSD_LEDM | |
| 356 | BCM5482_SHD_SSD_EN); |
| 357 | |
| 358 | /* |
| 359 | * Enable SGMII slave mode and auto-detection |
| 360 | */ |
Matt Carlson | 042a75b | 2008-11-03 16:56:29 -0800 | [diff] [blame] | 361 | reg = BCM5482_SSD_SGMII_SLAVE | MII_BCM54XX_EXP_SEL_SSD; |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 362 | err = bcm_phy_read_exp(phydev, reg); |
Matt Carlson | 042a75b | 2008-11-03 16:56:29 -0800 | [diff] [blame] | 363 | if (err < 0) |
| 364 | return err; |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 365 | err = bcm_phy_write_exp(phydev, reg, err | |
Matt Carlson | 042a75b | 2008-11-03 16:56:29 -0800 | [diff] [blame] | 366 | BCM5482_SSD_SGMII_SLAVE_EN | |
| 367 | BCM5482_SSD_SGMII_SLAVE_AD); |
| 368 | if (err < 0) |
| 369 | return err; |
Nate Case | cd9af3d | 2008-05-17 06:40:39 +0100 | [diff] [blame] | 370 | |
| 371 | /* |
| 372 | * Disable secondary SerDes powerdown |
| 373 | */ |
Matt Carlson | 042a75b | 2008-11-03 16:56:29 -0800 | [diff] [blame] | 374 | reg = BCM5482_SSD_1000BX_CTL | MII_BCM54XX_EXP_SEL_SSD; |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 375 | err = bcm_phy_read_exp(phydev, reg); |
Matt Carlson | 042a75b | 2008-11-03 16:56:29 -0800 | [diff] [blame] | 376 | if (err < 0) |
| 377 | return err; |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 378 | err = bcm_phy_write_exp(phydev, reg, |
Matt Carlson | 042a75b | 2008-11-03 16:56:29 -0800 | [diff] [blame] | 379 | err & ~BCM5482_SSD_1000BX_CTL_PWRDOWN); |
| 380 | if (err < 0) |
| 381 | return err; |
Nate Case | cd9af3d | 2008-05-17 06:40:39 +0100 | [diff] [blame] | 382 | |
| 383 | /* |
| 384 | * Select 1000BASE-X register set (primary SerDes) |
| 385 | */ |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 386 | reg = bcm_phy_read_shadow(phydev, BCM5482_SHD_MODE); |
| 387 | bcm_phy_write_shadow(phydev, BCM5482_SHD_MODE, |
Nate Case | cd9af3d | 2008-05-17 06:40:39 +0100 | [diff] [blame] | 388 | reg | BCM5482_SHD_MODE_1000BX); |
| 389 | |
| 390 | /* |
| 391 | * LED1=ACTIVITYLED, LED3=LINKSPD[2] |
| 392 | * (Use LED1 as secondary SerDes ACTIVITY LED) |
| 393 | */ |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 394 | bcm_phy_write_shadow(phydev, BCM5482_SHD_LEDS1, |
Nate Case | cd9af3d | 2008-05-17 06:40:39 +0100 | [diff] [blame] | 395 | BCM5482_SHD_LEDS1_LED1(BCM_LED_SRC_ACTIVITYLED) | |
| 396 | BCM5482_SHD_LEDS1_LED3(BCM_LED_SRC_LINKSPD2)); |
| 397 | |
| 398 | /* |
| 399 | * Auto-negotiation doesn't seem to work quite right |
| 400 | * in this mode, so we disable it and force it to the |
| 401 | * right speed/duplex setting. Only 'link status' |
| 402 | * is important. |
| 403 | */ |
| 404 | phydev->autoneg = AUTONEG_DISABLE; |
| 405 | phydev->speed = SPEED_1000; |
| 406 | phydev->duplex = DUPLEX_FULL; |
| 407 | } |
| 408 | |
| 409 | return err; |
| 410 | } |
| 411 | |
| 412 | static int bcm5482_read_status(struct phy_device *phydev) |
| 413 | { |
| 414 | int err; |
| 415 | |
| 416 | err = genphy_read_status(phydev); |
| 417 | |
| 418 | if (phydev->dev_flags & PHY_BCM_FLAGS_MODE_1000BX) { |
| 419 | /* |
| 420 | * Only link status matters for 1000Base-X mode, so force |
| 421 | * 1000 Mbit/s full-duplex status |
| 422 | */ |
| 423 | if (phydev->link) { |
| 424 | phydev->speed = SPEED_1000; |
| 425 | phydev->duplex = DUPLEX_FULL; |
| 426 | } |
| 427 | } |
| 428 | |
| 429 | return err; |
| 430 | } |
| 431 | |
Anton Vorontsov | 57bb7e2 | 2008-03-04 19:41:32 +0300 | [diff] [blame] | 432 | static int bcm5481_config_aneg(struct phy_device *phydev) |
| 433 | { |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 434 | struct device_node *np = phydev->mdio.dev.of_node; |
Anton Vorontsov | 57bb7e2 | 2008-03-04 19:41:32 +0300 | [diff] [blame] | 435 | int ret; |
| 436 | |
| 437 | /* Aneg firsly. */ |
| 438 | ret = genphy_config_aneg(phydev); |
| 439 | |
| 440 | /* Then we can set up the delay. */ |
Tao Ren | 042cb56 | 2018-11-05 14:35:40 -0800 | [diff] [blame] | 441 | bcm54xx_config_clock_delay(phydev); |
Anton Vorontsov | 57bb7e2 | 2008-03-04 19:41:32 +0300 | [diff] [blame] | 442 | |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 443 | if (of_property_read_bool(np, "enet-phy-lane-swap")) { |
| 444 | /* Lane Swap - Undocumented register...magic! */ |
| 445 | ret = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_SEL_ER + 0x9, |
| 446 | 0x11B); |
| 447 | if (ret < 0) |
| 448 | return ret; |
| 449 | } |
| 450 | |
Anton Vorontsov | 57bb7e2 | 2008-03-04 19:41:32 +0300 | [diff] [blame] | 451 | return ret; |
| 452 | } |
| 453 | |
Tao Ren | 042cb56 | 2018-11-05 14:35:40 -0800 | [diff] [blame] | 454 | static int bcm54616s_config_aneg(struct phy_device *phydev) |
| 455 | { |
| 456 | int ret; |
| 457 | |
| 458 | /* Aneg firsly. */ |
| 459 | ret = genphy_config_aneg(phydev); |
| 460 | |
| 461 | /* Then we can set up the delay. */ |
| 462 | bcm54xx_config_clock_delay(phydev); |
| 463 | |
| 464 | return ret; |
| 465 | } |
| 466 | |
Matt Carlson | d7a2ed9 | 2009-08-25 10:10:58 +0000 | [diff] [blame] | 467 | static int brcm_phy_setbits(struct phy_device *phydev, int reg, int set) |
| 468 | { |
| 469 | int val; |
| 470 | |
| 471 | val = phy_read(phydev, reg); |
| 472 | if (val < 0) |
| 473 | return val; |
| 474 | |
| 475 | return phy_write(phydev, reg, val | set); |
| 476 | } |
| 477 | |
| 478 | static int brcm_fet_config_init(struct phy_device *phydev) |
| 479 | { |
| 480 | int reg, err, err2, brcmtest; |
| 481 | |
| 482 | /* Reset the PHY to bring it to a known state. */ |
| 483 | err = phy_write(phydev, MII_BMCR, BMCR_RESET); |
| 484 | if (err < 0) |
| 485 | return err; |
| 486 | |
| 487 | reg = phy_read(phydev, MII_BRCM_FET_INTREG); |
| 488 | if (reg < 0) |
| 489 | return reg; |
| 490 | |
| 491 | /* Unmask events we are interested in and mask interrupts globally. */ |
| 492 | reg = MII_BRCM_FET_IR_DUPLEX_EN | |
| 493 | MII_BRCM_FET_IR_SPEED_EN | |
| 494 | MII_BRCM_FET_IR_LINK_EN | |
| 495 | MII_BRCM_FET_IR_ENABLE | |
| 496 | MII_BRCM_FET_IR_MASK; |
| 497 | |
| 498 | err = phy_write(phydev, MII_BRCM_FET_INTREG, reg); |
| 499 | if (err < 0) |
| 500 | return err; |
| 501 | |
| 502 | /* Enable shadow register access */ |
| 503 | brcmtest = phy_read(phydev, MII_BRCM_FET_BRCMTEST); |
| 504 | if (brcmtest < 0) |
| 505 | return brcmtest; |
| 506 | |
| 507 | reg = brcmtest | MII_BRCM_FET_BT_SRE; |
| 508 | |
| 509 | err = phy_write(phydev, MII_BRCM_FET_BRCMTEST, reg); |
| 510 | if (err < 0) |
| 511 | return err; |
| 512 | |
| 513 | /* Set the LED mode */ |
| 514 | reg = phy_read(phydev, MII_BRCM_FET_SHDW_AUXMODE4); |
| 515 | if (reg < 0) { |
| 516 | err = reg; |
| 517 | goto done; |
| 518 | } |
| 519 | |
| 520 | reg &= ~MII_BRCM_FET_SHDW_AM4_LED_MASK; |
| 521 | reg |= MII_BRCM_FET_SHDW_AM4_LED_MODE1; |
| 522 | |
| 523 | err = phy_write(phydev, MII_BRCM_FET_SHDW_AUXMODE4, reg); |
| 524 | if (err < 0) |
| 525 | goto done; |
| 526 | |
| 527 | /* Enable auto MDIX */ |
| 528 | err = brcm_phy_setbits(phydev, MII_BRCM_FET_SHDW_MISCCTRL, |
| 529 | MII_BRCM_FET_SHDW_MC_FAME); |
| 530 | if (err < 0) |
| 531 | goto done; |
| 532 | |
Matt Carlson | cdd4e09d | 2009-11-02 14:31:11 +0000 | [diff] [blame] | 533 | if (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE) { |
| 534 | /* Enable auto power down */ |
| 535 | err = brcm_phy_setbits(phydev, MII_BRCM_FET_SHDW_AUXSTAT2, |
| 536 | MII_BRCM_FET_SHDW_AS2_APDE); |
| 537 | } |
Matt Carlson | d7a2ed9 | 2009-08-25 10:10:58 +0000 | [diff] [blame] | 538 | |
| 539 | done: |
| 540 | /* Disable shadow register access */ |
| 541 | err2 = phy_write(phydev, MII_BRCM_FET_BRCMTEST, brcmtest); |
| 542 | if (!err) |
| 543 | err = err2; |
| 544 | |
| 545 | return err; |
| 546 | } |
| 547 | |
| 548 | static int brcm_fet_ack_interrupt(struct phy_device *phydev) |
| 549 | { |
| 550 | int reg; |
| 551 | |
| 552 | /* Clear pending interrupts. */ |
| 553 | reg = phy_read(phydev, MII_BRCM_FET_INTREG); |
| 554 | if (reg < 0) |
| 555 | return reg; |
| 556 | |
| 557 | return 0; |
| 558 | } |
| 559 | |
| 560 | static int brcm_fet_config_intr(struct phy_device *phydev) |
| 561 | { |
| 562 | int reg, err; |
| 563 | |
| 564 | reg = phy_read(phydev, MII_BRCM_FET_INTREG); |
| 565 | if (reg < 0) |
| 566 | return reg; |
| 567 | |
| 568 | if (phydev->interrupts == PHY_INTERRUPT_ENABLED) |
| 569 | reg &= ~MII_BRCM_FET_IR_MASK; |
| 570 | else |
| 571 | reg |= MII_BRCM_FET_IR_MASK; |
| 572 | |
| 573 | err = phy_write(phydev, MII_BRCM_FET_INTREG, reg); |
| 574 | return err; |
| 575 | } |
| 576 | |
Florian Fainelli | 28dc4c8 | 2017-12-14 17:48:16 -0800 | [diff] [blame] | 577 | struct bcm53xx_phy_priv { |
| 578 | u64 *stats; |
| 579 | }; |
| 580 | |
| 581 | static int bcm53xx_phy_probe(struct phy_device *phydev) |
| 582 | { |
| 583 | struct bcm53xx_phy_priv *priv; |
| 584 | |
| 585 | priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL); |
| 586 | if (!priv) |
| 587 | return -ENOMEM; |
| 588 | |
| 589 | phydev->priv = priv; |
| 590 | |
| 591 | priv->stats = devm_kcalloc(&phydev->mdio.dev, |
| 592 | bcm_phy_get_sset_count(phydev), sizeof(u64), |
| 593 | GFP_KERNEL); |
| 594 | if (!priv->stats) |
| 595 | return -ENOMEM; |
| 596 | |
| 597 | return 0; |
| 598 | } |
| 599 | |
| 600 | static void bcm53xx_phy_get_stats(struct phy_device *phydev, |
| 601 | struct ethtool_stats *stats, u64 *data) |
| 602 | { |
| 603 | struct bcm53xx_phy_priv *priv = phydev->priv; |
| 604 | |
| 605 | bcm_phy_get_stats(phydev, priv->stats, stats, data); |
| 606 | } |
| 607 | |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 608 | static struct phy_driver broadcom_drivers[] = { |
| 609 | { |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 610 | .phy_id = PHY_ID_BCM5411, |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 611 | .phy_id_mask = 0xfffffff0, |
| 612 | .name = "Broadcom BCM5411", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame^] | 613 | /* PHY_GBIT_FEATURES */ |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 614 | .config_init = bcm54xx_config_init, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 615 | .ack_interrupt = bcm_phy_ack_intr, |
| 616 | .config_intr = bcm_phy_config_intr, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 617 | }, { |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 618 | .phy_id = PHY_ID_BCM5421, |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 619 | .phy_id_mask = 0xfffffff0, |
| 620 | .name = "Broadcom BCM5421", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame^] | 621 | /* PHY_GBIT_FEATURES */ |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 622 | .config_init = bcm54xx_config_init, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 623 | .ack_interrupt = bcm_phy_ack_intr, |
| 624 | .config_intr = bcm_phy_config_intr, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 625 | }, { |
Rafał Miłecki | 0fc9ae1 | 2017-01-27 14:07:01 +0100 | [diff] [blame] | 626 | .phy_id = PHY_ID_BCM54210E, |
| 627 | .phy_id_mask = 0xfffffff0, |
| 628 | .name = "Broadcom BCM54210E", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame^] | 629 | /* PHY_GBIT_FEATURES */ |
Rafał Miłecki | 0fc9ae1 | 2017-01-27 14:07:01 +0100 | [diff] [blame] | 630 | .config_init = bcm54xx_config_init, |
Rafał Miłecki | 0fc9ae1 | 2017-01-27 14:07:01 +0100 | [diff] [blame] | 631 | .ack_interrupt = bcm_phy_ack_intr, |
| 632 | .config_intr = bcm_phy_config_intr, |
| 633 | }, { |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 634 | .phy_id = PHY_ID_BCM5461, |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 635 | .phy_id_mask = 0xfffffff0, |
| 636 | .name = "Broadcom BCM5461", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame^] | 637 | /* PHY_GBIT_FEATURES */ |
Maciej W. Rozycki | c4b41c9 | 2006-10-03 16:18:13 +0100 | [diff] [blame] | 638 | .config_init = bcm54xx_config_init, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 639 | .ack_interrupt = bcm_phy_ack_intr, |
| 640 | .config_intr = bcm_phy_config_intr, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 641 | }, { |
Xo Wang | d92ead1 | 2016-10-21 10:20:13 -0700 | [diff] [blame] | 642 | .phy_id = PHY_ID_BCM54612E, |
| 643 | .phy_id_mask = 0xfffffff0, |
| 644 | .name = "Broadcom BCM54612E", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame^] | 645 | /* PHY_GBIT_FEATURES */ |
Xo Wang | d92ead1 | 2016-10-21 10:20:13 -0700 | [diff] [blame] | 646 | .config_init = bcm54xx_config_init, |
Xo Wang | d92ead1 | 2016-10-21 10:20:13 -0700 | [diff] [blame] | 647 | .ack_interrupt = bcm_phy_ack_intr, |
| 648 | .config_intr = bcm_phy_config_intr, |
| 649 | }, { |
Alessio Igor Bogani | 3bca4cf6 | 2015-04-08 12:15:18 +0200 | [diff] [blame] | 650 | .phy_id = PHY_ID_BCM54616S, |
| 651 | .phy_id_mask = 0xfffffff0, |
| 652 | .name = "Broadcom BCM54616S", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame^] | 653 | /* PHY_GBIT_FEATURES */ |
Alessio Igor Bogani | 3bca4cf6 | 2015-04-08 12:15:18 +0200 | [diff] [blame] | 654 | .config_init = bcm54xx_config_init, |
Tao Ren | 042cb56 | 2018-11-05 14:35:40 -0800 | [diff] [blame] | 655 | .config_aneg = bcm54616s_config_aneg, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 656 | .ack_interrupt = bcm_phy_ack_intr, |
| 657 | .config_intr = bcm_phy_config_intr, |
Alessio Igor Bogani | 3bca4cf6 | 2015-04-08 12:15:18 +0200 | [diff] [blame] | 658 | }, { |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 659 | .phy_id = PHY_ID_BCM5464, |
Paul Gortmaker | b1394f9 | 2008-04-14 23:35:41 -0400 | [diff] [blame] | 660 | .phy_id_mask = 0xfffffff0, |
| 661 | .name = "Broadcom BCM5464", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame^] | 662 | /* PHY_GBIT_FEATURES */ |
Paul Gortmaker | b1394f9 | 2008-04-14 23:35:41 -0400 | [diff] [blame] | 663 | .config_init = bcm54xx_config_init, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 664 | .ack_interrupt = bcm_phy_ack_intr, |
| 665 | .config_intr = bcm_phy_config_intr, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 666 | }, { |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 667 | .phy_id = PHY_ID_BCM5481, |
Anton Vorontsov | 57bb7e2 | 2008-03-04 19:41:32 +0300 | [diff] [blame] | 668 | .phy_id_mask = 0xfffffff0, |
| 669 | .name = "Broadcom BCM5481", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame^] | 670 | /* PHY_GBIT_FEATURES */ |
Anton Vorontsov | 57bb7e2 | 2008-03-04 19:41:32 +0300 | [diff] [blame] | 671 | .config_init = bcm54xx_config_init, |
Heiner Kallweit | 9753c21 | 2017-12-02 10:50:37 +0100 | [diff] [blame] | 672 | .config_aneg = bcm5481_config_aneg, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 673 | .ack_interrupt = bcm_phy_ack_intr, |
| 674 | .config_intr = bcm_phy_config_intr, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 675 | }, { |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 676 | .phy_id = PHY_ID_BCM54810, |
| 677 | .phy_id_mask = 0xfffffff0, |
| 678 | .name = "Broadcom BCM54810", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame^] | 679 | /* PHY_GBIT_FEATURES */ |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 680 | .config_init = bcm54xx_config_init, |
Heiner Kallweit | 9753c21 | 2017-12-02 10:50:37 +0100 | [diff] [blame] | 681 | .config_aneg = bcm5481_config_aneg, |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 682 | .ack_interrupt = bcm_phy_ack_intr, |
| 683 | .config_intr = bcm_phy_config_intr, |
| 684 | }, { |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 685 | .phy_id = PHY_ID_BCM5482, |
Nate Case | 03157ac | 2008-01-29 10:19:00 -0600 | [diff] [blame] | 686 | .phy_id_mask = 0xfffffff0, |
| 687 | .name = "Broadcom BCM5482", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame^] | 688 | /* PHY_GBIT_FEATURES */ |
Nate Case | cd9af3d | 2008-05-17 06:40:39 +0100 | [diff] [blame] | 689 | .config_init = bcm5482_config_init, |
Heiner Kallweit | 9753c21 | 2017-12-02 10:50:37 +0100 | [diff] [blame] | 690 | .read_status = bcm5482_read_status, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 691 | .ack_interrupt = bcm_phy_ack_intr, |
| 692 | .config_intr = bcm_phy_config_intr, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 693 | }, { |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 694 | .phy_id = PHY_ID_BCM50610, |
| 695 | .phy_id_mask = 0xfffffff0, |
| 696 | .name = "Broadcom BCM50610", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame^] | 697 | /* PHY_GBIT_FEATURES */ |
Matt Carlson | 772638b | 2008-11-03 16:56:51 -0800 | [diff] [blame] | 698 | .config_init = bcm54xx_config_init, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 699 | .ack_interrupt = bcm_phy_ack_intr, |
| 700 | .config_intr = bcm_phy_config_intr, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 701 | }, { |
Matt Carlson | 4f4598f | 2009-08-25 10:10:30 +0000 | [diff] [blame] | 702 | .phy_id = PHY_ID_BCM50610M, |
| 703 | .phy_id_mask = 0xfffffff0, |
| 704 | .name = "Broadcom BCM50610M", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame^] | 705 | /* PHY_GBIT_FEATURES */ |
Matt Carlson | 4f4598f | 2009-08-25 10:10:30 +0000 | [diff] [blame] | 706 | .config_init = bcm54xx_config_init, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 707 | .ack_interrupt = bcm_phy_ack_intr, |
| 708 | .config_intr = bcm_phy_config_intr, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 709 | }, { |
Matt Carlson | d9221e6 | 2009-08-25 10:11:26 +0000 | [diff] [blame] | 710 | .phy_id = PHY_ID_BCM57780, |
Matt Carlson | 2fbb69a | 2008-11-21 17:22:53 -0800 | [diff] [blame] | 711 | .phy_id_mask = 0xfffffff0, |
| 712 | .name = "Broadcom BCM57780", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame^] | 713 | /* PHY_GBIT_FEATURES */ |
Matt Carlson | 2fbb69a | 2008-11-21 17:22:53 -0800 | [diff] [blame] | 714 | .config_init = bcm54xx_config_init, |
Arun Parameswaran | a1cba56 | 2015-10-06 12:25:48 -0700 | [diff] [blame] | 715 | .ack_interrupt = bcm_phy_ack_intr, |
| 716 | .config_intr = bcm_phy_config_intr, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 717 | }, { |
Matt Carlson | 6a443a0 | 2010-02-17 15:17:04 +0000 | [diff] [blame] | 718 | .phy_id = PHY_ID_BCMAC131, |
Matt Carlson | d7a2ed9 | 2009-08-25 10:10:58 +0000 | [diff] [blame] | 719 | .phy_id_mask = 0xfffffff0, |
| 720 | .name = "Broadcom BCMAC131", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame^] | 721 | /* PHY_BASIC_FEATURES */ |
Matt Carlson | d7a2ed9 | 2009-08-25 10:10:58 +0000 | [diff] [blame] | 722 | .config_init = brcm_fet_config_init, |
Matt Carlson | d7a2ed9 | 2009-08-25 10:10:58 +0000 | [diff] [blame] | 723 | .ack_interrupt = brcm_fet_ack_interrupt, |
| 724 | .config_intr = brcm_fet_config_intr, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 725 | }, { |
Dmitry Baryshkov | 7a938f8 | 2010-06-16 23:02:24 +0000 | [diff] [blame] | 726 | .phy_id = PHY_ID_BCM5241, |
| 727 | .phy_id_mask = 0xfffffff0, |
| 728 | .name = "Broadcom BCM5241", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame^] | 729 | /* PHY_BASIC_FEATURES */ |
Dmitry Baryshkov | 7a938f8 | 2010-06-16 23:02:24 +0000 | [diff] [blame] | 730 | .config_init = brcm_fet_config_init, |
Dmitry Baryshkov | 7a938f8 | 2010-06-16 23:02:24 +0000 | [diff] [blame] | 731 | .ack_interrupt = brcm_fet_ack_interrupt, |
| 732 | .config_intr = brcm_fet_config_intr, |
Florian Fainelli | 28dc4c8 | 2017-12-14 17:48:16 -0800 | [diff] [blame] | 733 | }, { |
| 734 | .phy_id = PHY_ID_BCM5395, |
| 735 | .phy_id_mask = 0xfffffff0, |
| 736 | .name = "Broadcom BCM5395", |
| 737 | .flags = PHY_IS_INTERNAL, |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame^] | 738 | /* PHY_GBIT_FEATURES */ |
Florian Fainelli | 28dc4c8 | 2017-12-14 17:48:16 -0800 | [diff] [blame] | 739 | .get_sset_count = bcm_phy_get_sset_count, |
| 740 | .get_strings = bcm_phy_get_strings, |
| 741 | .get_stats = bcm53xx_phy_get_stats, |
| 742 | .probe = bcm53xx_phy_probe, |
Bhadram Varka | 23b8392 | 2018-05-02 20:43:58 +0530 | [diff] [blame] | 743 | }, { |
| 744 | .phy_id = PHY_ID_BCM89610, |
| 745 | .phy_id_mask = 0xfffffff0, |
| 746 | .name = "Broadcom BCM89610", |
Heiner Kallweit | dcdecdc | 2019-04-12 20:47:03 +0200 | [diff] [blame^] | 747 | /* PHY_GBIT_FEATURES */ |
Bhadram Varka | 23b8392 | 2018-05-02 20:43:58 +0530 | [diff] [blame] | 748 | .config_init = bcm54xx_config_init, |
| 749 | .ack_interrupt = bcm_phy_ack_intr, |
| 750 | .config_intr = bcm_phy_config_intr, |
Christian Hohnstaedt | d5bf907 | 2012-07-04 05:44:34 +0000 | [diff] [blame] | 751 | } }; |
Dmitry Baryshkov | 7a938f8 | 2010-06-16 23:02:24 +0000 | [diff] [blame] | 752 | |
Johan Hovold | 50fd715 | 2014-11-11 19:45:59 +0100 | [diff] [blame] | 753 | module_phy_driver(broadcom_drivers); |
David Woodhouse | 4e4f10f | 2010-04-02 01:05:56 +0000 | [diff] [blame] | 754 | |
Uwe Kleine-König | cf93c94 | 2010-10-03 23:43:32 +0000 | [diff] [blame] | 755 | static struct mdio_device_id __maybe_unused broadcom_tbl[] = { |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 756 | { PHY_ID_BCM5411, 0xfffffff0 }, |
| 757 | { PHY_ID_BCM5421, 0xfffffff0 }, |
Rafał Miłecki | 0fc9ae1 | 2017-01-27 14:07:01 +0100 | [diff] [blame] | 758 | { PHY_ID_BCM54210E, 0xfffffff0 }, |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 759 | { PHY_ID_BCM5461, 0xfffffff0 }, |
Xo Wang | d92ead1 | 2016-10-21 10:20:13 -0700 | [diff] [blame] | 760 | { PHY_ID_BCM54612E, 0xfffffff0 }, |
Alessio Igor Bogani | 3bca4cf6 | 2015-04-08 12:15:18 +0200 | [diff] [blame] | 761 | { PHY_ID_BCM54616S, 0xfffffff0 }, |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 762 | { PHY_ID_BCM5464, 0xfffffff0 }, |
Aaro Koskinen | 3c25a86 | 2015-11-22 01:08:54 +0200 | [diff] [blame] | 763 | { PHY_ID_BCM5481, 0xfffffff0 }, |
Jon Mason | b14995a | 2016-11-04 01:10:58 -0400 | [diff] [blame] | 764 | { PHY_ID_BCM54810, 0xfffffff0 }, |
Dmitry Baryshkov | fcb26ec | 2010-06-16 23:02:23 +0000 | [diff] [blame] | 765 | { PHY_ID_BCM5482, 0xfffffff0 }, |
David Woodhouse | 4e4f10f | 2010-04-02 01:05:56 +0000 | [diff] [blame] | 766 | { PHY_ID_BCM50610, 0xfffffff0 }, |
| 767 | { PHY_ID_BCM50610M, 0xfffffff0 }, |
| 768 | { PHY_ID_BCM57780, 0xfffffff0 }, |
| 769 | { PHY_ID_BCMAC131, 0xfffffff0 }, |
Dmitry Baryshkov | 7a938f8 | 2010-06-16 23:02:24 +0000 | [diff] [blame] | 770 | { PHY_ID_BCM5241, 0xfffffff0 }, |
Florian Fainelli | 28dc4c8 | 2017-12-14 17:48:16 -0800 | [diff] [blame] | 771 | { PHY_ID_BCM5395, 0xfffffff0 }, |
Bhadram Varka | 23b8392 | 2018-05-02 20:43:58 +0530 | [diff] [blame] | 772 | { PHY_ID_BCM89610, 0xfffffff0 }, |
David Woodhouse | 4e4f10f | 2010-04-02 01:05:56 +0000 | [diff] [blame] | 773 | { } |
| 774 | }; |
| 775 | |
| 776 | MODULE_DEVICE_TABLE(mdio, broadcom_tbl); |