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