blob: bb5104ae46104c7a13a7749578839ec9abe2cd5a [file] [log] [blame]
Andrew Lunna2443fd2019-01-21 19:05:50 +01001// SPDX-License-Identifier: GPL-2.0+
Maciej W. Rozyckic4b41c92006-10-03 16:18:13 +01002/*
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. Rozyckic4b41c92006-10-03 16:18:13 +010011 */
12
Arun Parameswarana1cba562015-10-06 12:25:48 -070013#include "bcm-phy-lib.h"
Maciej W. Rozyckic4b41c92006-10-03 16:18:13 +010014#include <linux/module.h>
15#include <linux/phy.h>
Matt Carlson8649f132009-11-02 14:30:00 +000016#include <linux/brcmphy.h>
Jon Masonb14995a2016-11-04 01:10:58 -040017#include <linux/of.h>
Matt Carlsond9221e62009-08-25 10:11:26 +000018
19#define BRCM_PHY_MODEL(phydev) \
20 ((phydev)->drv->phy_id & (phydev)->drv->phy_id_mask)
21
Matt Carlson32e5a8d2009-11-02 14:31:39 +000022#define BRCM_PHY_REV(phydev) \
23 ((phydev)->drv->phy_id & ~((phydev)->drv->phy_id_mask))
24
Maciej W. Rozyckic4b41c92006-10-03 16:18:13 +010025MODULE_DESCRIPTION("Broadcom PHY driver");
26MODULE_AUTHOR("Maciej W. Rozycki");
27MODULE_LICENSE("GPL");
28
Tao Ren042cb562018-11-05 14:35:40 -080029static int bcm54xx_config_clock_delay(struct phy_device *phydev)
Jon Masonb14995a2016-11-04 01:10:58 -040030{
31 int rc, val;
32
Abhishek Shah73333622017-04-30 11:04:21 +053033 /* handling PHY's internal RX clock delay */
Jon Masonb14995a2016-11-04 01:10:58 -040034 val = bcm54xx_auxctl_read(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC);
Jon Masonb14995a2016-11-04 01:10:58 -040035 val |= MII_BCM54XX_AUXCTL_MISC_WREN;
Abhishek Shah73333622017-04-30 11:04:21 +053036 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 Masonb14995a2016-11-04 01:10:58 -040046 rc = bcm54xx_auxctl_write(phydev, MII_BCM54XX_AUXCTL_SHDWSEL_MISC,
47 val);
48 if (rc < 0)
49 return rc;
50
Abhishek Shah73333622017-04-30 11:04:21 +053051 /* handling PHY's internal TX clock delay */
Jon Masonb14995a2016-11-04 01:10:58 -040052 val = bcm_phy_read_shadow(phydev, BCM54810_SHD_CLK_CTL);
Abhishek Shah73333622017-04-30 11:04:21 +053053 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 Masonb14995a2016-11-04 01:10:58 -040063 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 Fainelli133bf7b2021-02-12 19:46:30 -080070static 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
85static 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 Hancock3afd0212021-02-16 16:54:52 -0600106static 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 Carlson47b1b532009-11-02 14:28:04 +0000164/* Needs SMDSP clock enabled via bcm54xx_phydsp_config() */
Matt Carlson772638b2008-11-03 16:56:51 -0800165static int bcm50610_a0_workaround(struct phy_device *phydev)
166{
167 int err;
168
Arun Parameswarana1cba562015-10-06 12:25:48 -0700169 err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_AADJ1CH0,
Matt Carlson47b1b532009-11-02 14:28:04 +0000170 MII_BCM54XX_EXP_AADJ1CH0_SWP_ABCD_OEN |
171 MII_BCM54XX_EXP_AADJ1CH0_SWSEL_THPF);
172 if (err < 0)
173 return err;
174
Arun Parameswarana1cba562015-10-06 12:25:48 -0700175 err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_AADJ1CH3,
176 MII_BCM54XX_EXP_AADJ1CH3_ADCCKADJ);
Matt Carlson47b1b532009-11-02 14:28:04 +0000177 if (err < 0)
178 return err;
179
Arun Parameswarana1cba562015-10-06 12:25:48 -0700180 err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP75,
Matt Carlson47b1b532009-11-02 14:28:04 +0000181 MII_BCM54XX_EXP_EXP75_VDACCTRL);
182 if (err < 0)
183 return err;
184
Arun Parameswarana1cba562015-10-06 12:25:48 -0700185 err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP96,
Matt Carlson47b1b532009-11-02 14:28:04 +0000186 MII_BCM54XX_EXP_EXP96_MYST);
187 if (err < 0)
188 return err;
189
Arun Parameswarana1cba562015-10-06 12:25:48 -0700190 err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP97,
Matt Carlson47b1b532009-11-02 14:28:04 +0000191 MII_BCM54XX_EXP_EXP97_MYST);
192
193 return err;
194}
195
196static int bcm54xx_phydsp_config(struct phy_device *phydev)
197{
198 int err, err2;
199
200 /* Enable the SMDSP clock */
Matt Carlson772638b2008-11-03 16:56:51 -0800201 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 Carlson219c6ef2009-11-02 14:28:33 +0000208 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 Parameswarana1cba562015-10-06 12:25:48 -0700211 err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP08,
Matt Carlson219c6ef2009-11-02 14:28:33 +0000212 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 Carlson772638b2008-11-03 16:56:51 -0800222
Matt Carlson47b1b532009-11-02 14:28:04 +0000223 if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM57780) {
224 int val;
Matt Carlson772638b2008-11-03 16:56:51 -0800225
Arun Parameswarana1cba562015-10-06 12:25:48 -0700226 val = bcm_phy_read_exp(phydev, MII_BCM54XX_EXP_EXP75);
Matt Carlson47b1b532009-11-02 14:28:04 +0000227 if (val < 0)
228 goto error;
Matt Carlson772638b2008-11-03 16:56:51 -0800229
Matt Carlson47b1b532009-11-02 14:28:04 +0000230 val |= MII_BCM54XX_EXP_EXP75_CM_OSC;
Arun Parameswarana1cba562015-10-06 12:25:48 -0700231 err = bcm_phy_write_exp(phydev, MII_BCM54XX_EXP_EXP75, val);
Matt Carlson47b1b532009-11-02 14:28:04 +0000232 }
Matt Carlson772638b2008-11-03 16:56:51 -0800233
234error:
Matt Carlson47b1b532009-11-02 14:28:04 +0000235 /* Disable the SMDSP clock */
236 err2 = bcm54xx_auxctl_write(phydev,
237 MII_BCM54XX_AUXCTL_SHDWSEL_AUXCTL,
238 MII_BCM54XX_AUXCTL_ACTL_TX_6DB);
Matt Carlson772638b2008-11-03 16:56:51 -0800239
Matt Carlson47b1b532009-11-02 14:28:04 +0000240 /* Return the first error reported. */
241 return err ? err : err2;
Matt Carlson772638b2008-11-03 16:56:51 -0800242}
243
Matt Carlson32e5a8d2009-11-02 14:31:39 +0000244static void bcm54xx_adjust_rxrefclk(struct phy_device *phydev)
245{
Roel Kluin5ee6f6a2009-12-18 20:16:10 -0800246 u32 orig;
247 int val;
Matt Carlsonc704dc22009-11-02 14:32:12 +0000248 bool clk125en = true;
Matt Carlson32e5a8d2009-11-02 14:31:39 +0000249
250 /* Abort if we are using an untested phy. */
roel kluin7ec4e7d2009-12-30 06:43:06 +0000251 if (BRCM_PHY_MODEL(phydev) != PHY_ID_BCM57780 &&
252 BRCM_PHY_MODEL(phydev) != PHY_ID_BCM50610 &&
Florian Fainelli0ececcf2020-02-19 12:00:47 -0800253 BRCM_PHY_MODEL(phydev) != PHY_ID_BCM50610M &&
Florian Fainelli5d4358e2021-02-12 19:46:32 -0800254 BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54210E &&
Kevin Lob0ed0bb2020-05-16 01:24:47 +0800255 BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54810 &&
256 BRCM_PHY_MODEL(phydev) != PHY_ID_BCM54811)
Matt Carlson32e5a8d2009-11-02 14:31:39 +0000257 return;
258
Arun Parameswarana1cba562015-10-06 12:25:48 -0700259 val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_SCR3);
Matt Carlson32e5a8d2009-11-02 14:31:39 +0000260 if (val < 0)
261 return;
262
263 orig = val;
264
Matt Carlsonc704dc22009-11-02 14:32:12 +0000265 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 Lob0ed0bb2020-05-16 01:24:47 +0800275 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 Carlsonc704dc22009-11-02 14:32:12 +0000279 clk125en = false;
Matt Carlson32e5a8d2009-11-02 14:31:39 +0000280 }
281 }
282
Joe Perches23677ce2012-02-09 11:17:23 +0000283 if (!clk125en || (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE))
Matt Carlsonc704dc22009-11-02 14:32:12 +0000284 val &= ~BCM54XX_SHD_SCR3_DLLAPD_DIS;
285 else
286 val |= BCM54XX_SHD_SCR3_DLLAPD_DIS;
287
Kevin Lob0ed0bb2020-05-16 01:24:47 +0800288 if (phydev->dev_flags & PHY_BRCM_DIS_TXCRXC_NOENRGY) {
Florian Fainelli5d4358e2021-02-12 19:46:32 -0800289 if (BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54210E ||
290 BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54810 ||
Kevin Load4e1e42021-07-23 21:59:27 +0800291 BRCM_PHY_MODEL(phydev) == PHY_ID_BCM54811)
Florian Fainelli5d4358e2021-02-12 19:46:32 -0800292 val |= BCM54XX_SHD_SCR3_RXCTXC_DIS;
Kevin Lob0ed0bb2020-05-16 01:24:47 +0800293 else
294 val |= BCM54XX_SHD_SCR3_TRDDAPD;
295 }
Matt Carlson52fae082009-11-02 14:32:38 +0000296
Matt Carlson32e5a8d2009-11-02 14:31:39 +0000297 if (orig != val)
Arun Parameswarana1cba562015-10-06 12:25:48 -0700298 bcm_phy_write_shadow(phydev, BCM54XX_SHD_SCR3, val);
Matt Carlsonc704dc22009-11-02 14:32:12 +0000299
Arun Parameswarana1cba562015-10-06 12:25:48 -0700300 val = bcm_phy_read_shadow(phydev, BCM54XX_SHD_APD);
Matt Carlsonc704dc22009-11-02 14:32:12 +0000301 if (val < 0)
302 return;
303
304 orig = val;
305
Joe Perches23677ce2012-02-09 11:17:23 +0000306 if (!clk125en || (phydev->dev_flags & PHY_BRCM_AUTO_PWRDWN_ENABLE))
Matt Carlsonc704dc22009-11-02 14:32:12 +0000307 val |= BCM54XX_SHD_APD_EN;
308 else
309 val &= ~BCM54XX_SHD_APD_EN;
310
311 if (orig != val)
Arun Parameswarana1cba562015-10-06 12:25:48 -0700312 bcm_phy_write_shadow(phydev, BCM54XX_SHD_APD, val);
Matt Carlson32e5a8d2009-11-02 14:31:39 +0000313}
314
Maciej W. Rozyckic4b41c92006-10-03 16:18:13 +0100315static int bcm54xx_config_init(struct phy_device *phydev)
316{
Abhishek Shah73333622017-04-30 11:04:21 +0530317 int reg, err, val;
Maciej W. Rozyckic4b41c92006-10-03 16:18:13 +0100318
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 Carlson772638b2008-11-03 16:56:51 -0800336
Matt Carlson63a14ce2009-11-02 14:30:40 +0000337 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 Parameswarana1cba562015-10-06 12:25:48 -0700340 bcm_phy_write_shadow(phydev, BCM54XX_SHD_RGMII_MODE, 0);
Matt Carlson63a14ce2009-11-02 14:30:40 +0000341
Florian Fainellicb64da32020-02-19 12:00:48 -0800342 bcm54xx_adjust_rxrefclk(phydev);
Matt Carlson32e5a8d2009-11-02 14:31:39 +0000343
Robert Hancock3afd0212021-02-16 16:54:52 -0600344 switch (BRCM_PHY_MODEL(phydev)) {
Florian Fainellib1dd9bf2021-03-11 16:52:50 -0800345 case PHY_ID_BCM50610:
346 case PHY_ID_BCM50610M:
347 err = bcm54xx_config_clock_delay(phydev);
348 break;
Robert Hancock3afd0212021-02-16 16:54:52 -0600349 case PHY_ID_BCM54210E:
Rafał Miłecki0fc9ae12017-01-27 14:07:01 +0100350 err = bcm54210e_config_init(phydev);
Robert Hancock3afd0212021-02-16 16:54:52 -0600351 break;
352 case PHY_ID_BCM54612E:
Rafał Miłecki62e13092017-01-31 22:54:54 +0100353 err = bcm54612e_config_init(phydev);
Robert Hancock3afd0212021-02-16 16:54:52 -0600354 break;
355 case PHY_ID_BCM54616S:
356 err = bcm54616s_config_init(phydev);
357 break;
358 case PHY_ID_BCM54810:
Abhishek Shah73333622017-04-30 11:04:21 +0530359 /* 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 Hancock3afd0212021-02-16 16:54:52 -0600366 break;
Jon Masonb14995a2016-11-04 01:10:58 -0400367 }
Robert Hancock3afd0212021-02-16 16:54:52 -0600368 if (err)
369 return err;
Jon Masonb14995a2016-11-04 01:10:58 -0400370
Matt Carlson47b1b532009-11-02 14:28:04 +0000371 bcm54xx_phydsp_config(phydev);
Matt Carlsond9221e62009-08-25 10:11:26 +0000372
Robert Hancockb5d007e2021-02-16 16:54:54 -0600373 /* For non-SFP setups, encode link speed into LED1 and LED3 pair
374 * (green/amber).
Vladimir Oltean450895d2019-03-24 00:18:46 +0200375 * Also flash these two LEDs on activity. This means configuring
376 * them for MULTICOLOR and encoding link/activity into them.
Robert Hancockb5d007e2021-02-16 16:54:54 -0600377 * 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 Oltean450895d2019-03-24 00:18:46 +0200380 */
Robert Hancockb5d007e2021-02-16 16:54:54 -0600381 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 Oltean450895d2019-03-24 00:18:46 +0200385
Robert Hancockb5d007e2021-02-16 16:54:54 -0600386 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 Oltean450895d2019-03-24 00:18:46 +0200391
Maciej W. Rozyckic4b41c92006-10-03 16:18:13 +0100392 return 0;
393}
394
Florian Fainellid6da08e2021-09-20 14:54:14 -0700395static 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);
412out:
413 return ret;
414}
415
416static 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 Fainellife268212020-02-19 12:00:49 -0800431static int bcm54xx_resume(struct phy_device *phydev)
432{
433 int ret;
434
Florian Fainellid6da08e2021-09-20 14:54:14 -0700435 ret = bcm54xx_iddq_set(phydev, false);
436 if (ret < 0)
437 return ret;
438
Florian Fainellife268212020-02-19 12:00:49 -0800439 /* 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 Fainelli7a1468b2021-03-10 20:53:42 -0800446 /* Upon exiting power down, the PHY remains in an internal reset state
447 * for 40us
448 */
449 fsleep(40);
450
Florian Fainellid6da08e2021-09-20 14:54:14 -0700451 /* 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 Fainellife268212020-02-19 12:00:49 -0800460 return bcm54xx_config_init(phydev);
461}
462
Kevin Lob0ed0bb2020-05-16 01:24:47 +0800463static 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 Lo6f42a292020-05-16 10:09:26 +0800484 }
Kevin Lob0ed0bb2020-05-16 01:24:47 +0800485
486 return err;
487}
488
Anton Vorontsov57bb7e22008-03-04 19:41:32 +0300489static int bcm5481_config_aneg(struct phy_device *phydev)
490{
Jon Masonb14995a2016-11-04 01:10:58 -0400491 struct device_node *np = phydev->mdio.dev.of_node;
Anton Vorontsov57bb7e22008-03-04 19:41:32 +0300492 int ret;
493
Jonathan Neuschäfer29f20dd2020-02-18 16:47:01 +0100494 /* Aneg firstly. */
Anton Vorontsov57bb7e22008-03-04 19:41:32 +0300495 ret = genphy_config_aneg(phydev);
496
497 /* Then we can set up the delay. */
Tao Ren042cb562018-11-05 14:35:40 -0800498 bcm54xx_config_clock_delay(phydev);
Anton Vorontsov57bb7e22008-03-04 19:41:32 +0300499
Jon Masonb14995a2016-11-04 01:10:58 -0400500 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 Vorontsov57bb7e22008-03-04 19:41:32 +0300508 return ret;
509}
510
Florian Fainelli17d3a832021-02-12 19:46:31 -0800511struct bcm54616s_phy_priv {
512 bool mode_1000bx_en;
513};
514
Tao Renb9bcb952019-10-22 11:31:08 -0700515static int bcm54616s_probe(struct phy_device *phydev)
516{
Florian Fainelli17d3a832021-02-12 19:46:31 -0800517 struct bcm54616s_phy_priv *priv;
Robert Hancock3afd0212021-02-16 16:54:52 -0600518 int val;
Tao Renb9bcb952019-10-22 11:31:08 -0700519
Florian Fainelli17d3a832021-02-12 19:46:31 -0800520 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
521 if (!priv)
522 return -ENOMEM;
523
524 phydev->priv = priv;
525
Tao Renb9bcb952019-10-22 11:31:08 -0700526 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 Hancock3afd0212021-02-16 16:54:52 -0600536 if ((val & BCM54XX_SHD_INTF_SEL_MASK) == BCM54XX_SHD_INTF_SEL_RGMII) {
Tao Renb9bcb952019-10-22 11:31:08 -0700537 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 Fainelli17d3a832021-02-12 19:46:31 -0800547 priv->mode_1000bx_en = true;
Michael Walle4217a642021-02-09 17:38:52 +0100548
549 phydev->port = PORT_FIBRE;
Tao Renb9bcb952019-10-22 11:31:08 -0700550 }
551
552 return 0;
553}
554
Tao Ren042cb562018-11-05 14:35:40 -0800555static int bcm54616s_config_aneg(struct phy_device *phydev)
556{
Florian Fainelli17d3a832021-02-12 19:46:31 -0800557 struct bcm54616s_phy_priv *priv = phydev->priv;
Tao Ren042cb562018-11-05 14:35:40 -0800558 int ret;
559
Jonathan Neuschäfer29f20dd2020-02-18 16:47:01 +0100560 /* Aneg firstly. */
Florian Fainelli17d3a832021-02-12 19:46:31 -0800561 if (priv->mode_1000bx_en)
Tao Renb9bcb952019-10-22 11:31:08 -0700562 ret = genphy_c37_config_aneg(phydev);
563 else
564 ret = genphy_config_aneg(phydev);
Tao Ren042cb562018-11-05 14:35:40 -0800565
566 /* Then we can set up the delay. */
567 bcm54xx_config_clock_delay(phydev);
568
569 return ret;
570}
571
Tao Renb9bcb952019-10-22 11:31:08 -0700572static int bcm54616s_read_status(struct phy_device *phydev)
573{
Florian Fainelli17d3a832021-02-12 19:46:31 -0800574 struct bcm54616s_phy_priv *priv = phydev->priv;
Tao Renb9bcb952019-10-22 11:31:08 -0700575 int err;
576
Florian Fainelli17d3a832021-02-12 19:46:31 -0800577 if (priv->mode_1000bx_en)
Tao Renb9bcb952019-10-22 11:31:08 -0700578 err = genphy_c37_read_status(phydev);
579 else
580 err = genphy_read_status(phydev);
581
582 return err;
583}
584
Matt Carlsond7a2ed92009-08-25 10:10:58 +0000585static 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
596static 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 Carlsoncdd4e09d2009-11-02 14:31:11 +0000651 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 Carlsond7a2ed92009-08-25 10:10:58 +0000656
657done:
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
666static 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
678static 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 Ciornei15772e42020-11-01 14:51:07 +0200686 if (phydev->interrupts == PHY_INTERRUPT_ENABLED) {
687 err = brcm_fet_ack_interrupt(phydev);
688 if (err)
689 return err;
Matt Carlsond7a2ed92009-08-25 10:10:58 +0000690
Ioana Ciornei15772e42020-11-01 14:51:07 +0200691 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 Carlsond7a2ed92009-08-25 10:10:58 +0000702 return err;
703}
704
Ioana Ciornei4567d5c2020-11-01 14:51:06 +0200705static 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 Fainelli5a32fcd2021-04-01 09:42:33 -0700723struct bcm54xx_phy_priv {
Florian Fainelli28dc4c82017-12-14 17:48:16 -0800724 u64 *stats;
725};
726
Florian Fainelli5a32fcd2021-04-01 09:42:33 -0700727static int bcm54xx_phy_probe(struct phy_device *phydev)
Florian Fainelli28dc4c82017-12-14 17:48:16 -0800728{
Florian Fainelli5a32fcd2021-04-01 09:42:33 -0700729 struct bcm54xx_phy_priv *priv;
Florian Fainelli28dc4c82017-12-14 17:48:16 -0800730
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 Fainelli5a32fcd2021-04-01 09:42:33 -0700746static void bcm54xx_get_stats(struct phy_device *phydev,
747 struct ethtool_stats *stats, u64 *data)
Florian Fainelli28dc4c82017-12-14 17:48:16 -0800748{
Florian Fainelli5a32fcd2021-04-01 09:42:33 -0700749 struct bcm54xx_phy_priv *priv = phydev->priv;
Florian Fainelli28dc4c82017-12-14 17:48:16 -0800750
751 bcm_phy_get_stats(phydev, priv->stats, stats, data);
752}
753
Florian Fainelli8dc84dc2021-09-16 14:27:41 -0700754static 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 Hohnstaedtd5bf9072012-07-04 05:44:34 +0000784static struct phy_driver broadcom_drivers[] = {
785{
Dmitry Baryshkovfcb26ec2010-06-16 23:02:23 +0000786 .phy_id = PHY_ID_BCM5411,
Maciej W. Rozyckic4b41c92006-10-03 16:18:13 +0100787 .phy_id_mask = 0xfffffff0,
788 .name = "Broadcom BCM5411",
Heiner Kallweitdcdecdc2019-04-12 20:47:03 +0200789 /* PHY_GBIT_FEATURES */
Florian Fainelli5a32fcd2021-04-01 09:42:33 -0700790 .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. Rozyckic4b41c92006-10-03 16:18:13 +0100794 .config_init = bcm54xx_config_init,
Arun Parameswarana1cba562015-10-06 12:25:48 -0700795 .config_intr = bcm_phy_config_intr,
Ioana Ciornei4567d5c2020-11-01 14:51:06 +0200796 .handle_interrupt = bcm_phy_handle_interrupt,
Florian Fainelli8dc84dc2021-09-16 14:27:41 -0700797 .link_change_notify = bcm54xx_link_change_notify,
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000798}, {
Dmitry Baryshkovfcb26ec2010-06-16 23:02:23 +0000799 .phy_id = PHY_ID_BCM5421,
Maciej W. Rozyckic4b41c92006-10-03 16:18:13 +0100800 .phy_id_mask = 0xfffffff0,
801 .name = "Broadcom BCM5421",
Heiner Kallweitdcdecdc2019-04-12 20:47:03 +0200802 /* PHY_GBIT_FEATURES */
Florian Fainelli5a32fcd2021-04-01 09:42:33 -0700803 .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. Rozyckic4b41c92006-10-03 16:18:13 +0100807 .config_init = bcm54xx_config_init,
Arun Parameswarana1cba562015-10-06 12:25:48 -0700808 .config_intr = bcm_phy_config_intr,
Ioana Ciornei4567d5c2020-11-01 14:51:06 +0200809 .handle_interrupt = bcm_phy_handle_interrupt,
Florian Fainelli8dc84dc2021-09-16 14:27:41 -0700810 .link_change_notify = bcm54xx_link_change_notify,
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000811}, {
Rafał Miłecki0fc9ae12017-01-27 14:07:01 +0100812 .phy_id = PHY_ID_BCM54210E,
813 .phy_id_mask = 0xfffffff0,
814 .name = "Broadcom BCM54210E",
Heiner Kallweitdcdecdc2019-04-12 20:47:03 +0200815 /* PHY_GBIT_FEATURES */
Florian Fainelli5a32fcd2021-04-01 09:42:33 -0700816 .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łecki0fc9ae12017-01-27 14:07:01 +0100820 .config_init = bcm54xx_config_init,
Rafał Miłecki0fc9ae12017-01-27 14:07:01 +0100821 .config_intr = bcm_phy_config_intr,
Ioana Ciornei4567d5c2020-11-01 14:51:06 +0200822 .handle_interrupt = bcm_phy_handle_interrupt,
Florian Fainelli8dc84dc2021-09-16 14:27:41 -0700823 .link_change_notify = bcm54xx_link_change_notify,
Florian Fainellid6da08e2021-09-20 14:54:14 -0700824 .suspend = bcm54xx_suspend,
825 .resume = bcm54xx_resume,
Rafał Miłecki0fc9ae12017-01-27 14:07:01 +0100826}, {
Dmitry Baryshkovfcb26ec2010-06-16 23:02:23 +0000827 .phy_id = PHY_ID_BCM5461,
Maciej W. Rozyckic4b41c92006-10-03 16:18:13 +0100828 .phy_id_mask = 0xfffffff0,
829 .name = "Broadcom BCM5461",
Heiner Kallweitdcdecdc2019-04-12 20:47:03 +0200830 /* PHY_GBIT_FEATURES */
Florian Fainelli5a32fcd2021-04-01 09:42:33 -0700831 .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. Rozyckic4b41c92006-10-03 16:18:13 +0100835 .config_init = bcm54xx_config_init,
Arun Parameswarana1cba562015-10-06 12:25:48 -0700836 .config_intr = bcm_phy_config_intr,
Ioana Ciornei4567d5c2020-11-01 14:51:06 +0200837 .handle_interrupt = bcm_phy_handle_interrupt,
Florian Fainelli8dc84dc2021-09-16 14:27:41 -0700838 .link_change_notify = bcm54xx_link_change_notify,
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000839}, {
Xo Wangd92ead12016-10-21 10:20:13 -0700840 .phy_id = PHY_ID_BCM54612E,
841 .phy_id_mask = 0xfffffff0,
842 .name = "Broadcom BCM54612E",
Heiner Kallweitdcdecdc2019-04-12 20:47:03 +0200843 /* PHY_GBIT_FEATURES */
Florian Fainelli5a32fcd2021-04-01 09:42:33 -0700844 .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 Wangd92ead12016-10-21 10:20:13 -0700848 .config_init = bcm54xx_config_init,
Xo Wangd92ead12016-10-21 10:20:13 -0700849 .config_intr = bcm_phy_config_intr,
Ioana Ciornei4567d5c2020-11-01 14:51:06 +0200850 .handle_interrupt = bcm_phy_handle_interrupt,
Florian Fainelli8dc84dc2021-09-16 14:27:41 -0700851 .link_change_notify = bcm54xx_link_change_notify,
Xo Wangd92ead12016-10-21 10:20:13 -0700852}, {
Alessio Igor Bogani3bca4cf62015-04-08 12:15:18 +0200853 .phy_id = PHY_ID_BCM54616S,
854 .phy_id_mask = 0xfffffff0,
855 .name = "Broadcom BCM54616S",
Heiner Kallweitdcdecdc2019-04-12 20:47:03 +0200856 /* PHY_GBIT_FEATURES */
Alessio Igor Bogani3bca4cf62015-04-08 12:15:18 +0200857 .config_init = bcm54xx_config_init,
Tao Ren042cb562018-11-05 14:35:40 -0800858 .config_aneg = bcm54616s_config_aneg,
Arun Parameswarana1cba562015-10-06 12:25:48 -0700859 .config_intr = bcm_phy_config_intr,
Ioana Ciornei4567d5c2020-11-01 14:51:06 +0200860 .handle_interrupt = bcm_phy_handle_interrupt,
Tao Renb9bcb952019-10-22 11:31:08 -0700861 .read_status = bcm54616s_read_status,
862 .probe = bcm54616s_probe,
Florian Fainelli8dc84dc2021-09-16 14:27:41 -0700863 .link_change_notify = bcm54xx_link_change_notify,
Alessio Igor Bogani3bca4cf62015-04-08 12:15:18 +0200864}, {
Dmitry Baryshkovfcb26ec2010-06-16 23:02:23 +0000865 .phy_id = PHY_ID_BCM5464,
Paul Gortmakerb1394f92008-04-14 23:35:41 -0400866 .phy_id_mask = 0xfffffff0,
867 .name = "Broadcom BCM5464",
Heiner Kallweitdcdecdc2019-04-12 20:47:03 +0200868 /* PHY_GBIT_FEATURES */
Florian Fainelli5a32fcd2021-04-01 09:42:33 -0700869 .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 Gortmakerb1394f92008-04-14 23:35:41 -0400873 .config_init = bcm54xx_config_init,
Arun Parameswarana1cba562015-10-06 12:25:48 -0700874 .config_intr = bcm_phy_config_intr,
Ioana Ciornei4567d5c2020-11-01 14:51:06 +0200875 .handle_interrupt = bcm_phy_handle_interrupt,
Vladimir Oltean283da992019-06-08 16:53:56 +0300876 .suspend = genphy_suspend,
877 .resume = genphy_resume,
Florian Fainelli8dc84dc2021-09-16 14:27:41 -0700878 .link_change_notify = bcm54xx_link_change_notify,
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000879}, {
Dmitry Baryshkovfcb26ec2010-06-16 23:02:23 +0000880 .phy_id = PHY_ID_BCM5481,
Anton Vorontsov57bb7e22008-03-04 19:41:32 +0300881 .phy_id_mask = 0xfffffff0,
882 .name = "Broadcom BCM5481",
Heiner Kallweitdcdecdc2019-04-12 20:47:03 +0200883 /* PHY_GBIT_FEATURES */
Florian Fainelli5a32fcd2021-04-01 09:42:33 -0700884 .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 Vorontsov57bb7e22008-03-04 19:41:32 +0300888 .config_init = bcm54xx_config_init,
Heiner Kallweit9753c212017-12-02 10:50:37 +0100889 .config_aneg = bcm5481_config_aneg,
Arun Parameswarana1cba562015-10-06 12:25:48 -0700890 .config_intr = bcm_phy_config_intr,
Ioana Ciornei4567d5c2020-11-01 14:51:06 +0200891 .handle_interrupt = bcm_phy_handle_interrupt,
Florian Fainelli8dc84dc2021-09-16 14:27:41 -0700892 .link_change_notify = bcm54xx_link_change_notify,
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000893}, {
Jon Masonb14995a2016-11-04 01:10:58 -0400894 .phy_id = PHY_ID_BCM54810,
895 .phy_id_mask = 0xfffffff0,
896 .name = "Broadcom BCM54810",
Heiner Kallweitdcdecdc2019-04-12 20:47:03 +0200897 /* PHY_GBIT_FEATURES */
Florian Fainelli5a32fcd2021-04-01 09:42:33 -0700898 .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 Masonb14995a2016-11-04 01:10:58 -0400902 .config_init = bcm54xx_config_init,
Heiner Kallweit9753c212017-12-02 10:50:37 +0100903 .config_aneg = bcm5481_config_aneg,
Jon Masonb14995a2016-11-04 01:10:58 -0400904 .config_intr = bcm_phy_config_intr,
Ioana Ciornei4567d5c2020-11-01 14:51:06 +0200905 .handle_interrupt = bcm_phy_handle_interrupt,
Florian Fainelli72e78d22021-09-20 14:54:16 -0700906 .suspend = bcm54xx_suspend,
Florian Fainellife268212020-02-19 12:00:49 -0800907 .resume = bcm54xx_resume,
Florian Fainelli8dc84dc2021-09-16 14:27:41 -0700908 .link_change_notify = bcm54xx_link_change_notify,
Jon Masonb14995a2016-11-04 01:10:58 -0400909}, {
Kevin Lob0ed0bb2020-05-16 01:24:47 +0800910 .phy_id = PHY_ID_BCM54811,
911 .phy_id_mask = 0xfffffff0,
912 .name = "Broadcom BCM54811",
913 /* PHY_GBIT_FEATURES */
Florian Fainelli5a32fcd2021-04-01 09:42:33 -0700914 .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 Lob0ed0bb2020-05-16 01:24:47 +0800918 .config_init = bcm54811_config_init,
919 .config_aneg = bcm5481_config_aneg,
Kevin Lob0ed0bb2020-05-16 01:24:47 +0800920 .config_intr = bcm_phy_config_intr,
Ioana Ciornei4567d5c2020-11-01 14:51:06 +0200921 .handle_interrupt = bcm_phy_handle_interrupt,
Florian Fainelli72e78d22021-09-20 14:54:16 -0700922 .suspend = bcm54xx_suspend,
Kevin Lob0ed0bb2020-05-16 01:24:47 +0800923 .resume = bcm54xx_resume,
Florian Fainelli8dc84dc2021-09-16 14:27:41 -0700924 .link_change_notify = bcm54xx_link_change_notify,
Kevin Lob0ed0bb2020-05-16 01:24:47 +0800925}, {
Dmitry Baryshkovfcb26ec2010-06-16 23:02:23 +0000926 .phy_id = PHY_ID_BCM5482,
Nate Case03157ac2008-01-29 10:19:00 -0600927 .phy_id_mask = 0xfffffff0,
928 .name = "Broadcom BCM5482",
Heiner Kallweitdcdecdc2019-04-12 20:47:03 +0200929 /* PHY_GBIT_FEATURES */
Florian Fainelli5a32fcd2021-04-01 09:42:33 -0700930 .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 Walle1e2e61af2021-02-09 00:17:06 +0100934 .config_init = bcm54xx_config_init,
Arun Parameswarana1cba562015-10-06 12:25:48 -0700935 .config_intr = bcm_phy_config_intr,
Ioana Ciornei4567d5c2020-11-01 14:51:06 +0200936 .handle_interrupt = bcm_phy_handle_interrupt,
Florian Fainelli8dc84dc2021-09-16 14:27:41 -0700937 .link_change_notify = bcm54xx_link_change_notify,
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000938}, {
Matt Carlson772638b2008-11-03 16:56:51 -0800939 .phy_id = PHY_ID_BCM50610,
940 .phy_id_mask = 0xfffffff0,
941 .name = "Broadcom BCM50610",
Heiner Kallweitdcdecdc2019-04-12 20:47:03 +0200942 /* PHY_GBIT_FEATURES */
Florian Fainelli5a32fcd2021-04-01 09:42:33 -0700943 .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 Carlson772638b2008-11-03 16:56:51 -0800947 .config_init = bcm54xx_config_init,
Arun Parameswarana1cba562015-10-06 12:25:48 -0700948 .config_intr = bcm_phy_config_intr,
Ioana Ciornei4567d5c2020-11-01 14:51:06 +0200949 .handle_interrupt = bcm_phy_handle_interrupt,
Florian Fainelli8dc84dc2021-09-16 14:27:41 -0700950 .link_change_notify = bcm54xx_link_change_notify,
Florian Fainelli38b6a902021-09-20 14:54:15 -0700951 .suspend = bcm54xx_suspend,
952 .resume = bcm54xx_resume,
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000953}, {
Matt Carlson4f4598f2009-08-25 10:10:30 +0000954 .phy_id = PHY_ID_BCM50610M,
955 .phy_id_mask = 0xfffffff0,
956 .name = "Broadcom BCM50610M",
Heiner Kallweitdcdecdc2019-04-12 20:47:03 +0200957 /* PHY_GBIT_FEATURES */
Florian Fainelli5a32fcd2021-04-01 09:42:33 -0700958 .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 Carlson4f4598f2009-08-25 10:10:30 +0000962 .config_init = bcm54xx_config_init,
Arun Parameswarana1cba562015-10-06 12:25:48 -0700963 .config_intr = bcm_phy_config_intr,
Ioana Ciornei4567d5c2020-11-01 14:51:06 +0200964 .handle_interrupt = bcm_phy_handle_interrupt,
Florian Fainelli8dc84dc2021-09-16 14:27:41 -0700965 .link_change_notify = bcm54xx_link_change_notify,
Florian Fainelli38b6a902021-09-20 14:54:15 -0700966 .suspend = bcm54xx_suspend,
967 .resume = bcm54xx_resume,
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000968}, {
Matt Carlsond9221e62009-08-25 10:11:26 +0000969 .phy_id = PHY_ID_BCM57780,
Matt Carlson2fbb69a2008-11-21 17:22:53 -0800970 .phy_id_mask = 0xfffffff0,
971 .name = "Broadcom BCM57780",
Heiner Kallweitdcdecdc2019-04-12 20:47:03 +0200972 /* PHY_GBIT_FEATURES */
Florian Fainelli5a32fcd2021-04-01 09:42:33 -0700973 .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 Carlson2fbb69a2008-11-21 17:22:53 -0800977 .config_init = bcm54xx_config_init,
Arun Parameswarana1cba562015-10-06 12:25:48 -0700978 .config_intr = bcm_phy_config_intr,
Ioana Ciornei4567d5c2020-11-01 14:51:06 +0200979 .handle_interrupt = bcm_phy_handle_interrupt,
Florian Fainelli8dc84dc2021-09-16 14:27:41 -0700980 .link_change_notify = bcm54xx_link_change_notify,
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000981}, {
Matt Carlson6a443a02010-02-17 15:17:04 +0000982 .phy_id = PHY_ID_BCMAC131,
Matt Carlsond7a2ed92009-08-25 10:10:58 +0000983 .phy_id_mask = 0xfffffff0,
984 .name = "Broadcom BCMAC131",
Heiner Kallweitdcdecdc2019-04-12 20:47:03 +0200985 /* PHY_BASIC_FEATURES */
Matt Carlsond7a2ed92009-08-25 10:10:58 +0000986 .config_init = brcm_fet_config_init,
Matt Carlsond7a2ed92009-08-25 10:10:58 +0000987 .config_intr = brcm_fet_config_intr,
Ioana Ciornei4567d5c2020-11-01 14:51:06 +0200988 .handle_interrupt = brcm_fet_handle_interrupt,
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +0000989}, {
Dmitry Baryshkov7a938f82010-06-16 23:02:24 +0000990 .phy_id = PHY_ID_BCM5241,
991 .phy_id_mask = 0xfffffff0,
992 .name = "Broadcom BCM5241",
Heiner Kallweitdcdecdc2019-04-12 20:47:03 +0200993 /* PHY_BASIC_FEATURES */
Dmitry Baryshkov7a938f82010-06-16 23:02:24 +0000994 .config_init = brcm_fet_config_init,
Dmitry Baryshkov7a938f82010-06-16 23:02:24 +0000995 .config_intr = brcm_fet_config_intr,
Ioana Ciornei4567d5c2020-11-01 14:51:06 +0200996 .handle_interrupt = brcm_fet_handle_interrupt,
Florian Fainelli28dc4c82017-12-14 17:48:16 -0800997}, {
998 .phy_id = PHY_ID_BCM5395,
999 .phy_id_mask = 0xfffffff0,
1000 .name = "Broadcom BCM5395",
1001 .flags = PHY_IS_INTERNAL,
Heiner Kallweitdcdecdc2019-04-12 20:47:03 +02001002 /* PHY_GBIT_FEATURES */
Florian Fainelli28dc4c82017-12-14 17:48:16 -08001003 .get_sset_count = bcm_phy_get_sset_count,
1004 .get_strings = bcm_phy_get_strings,
Florian Fainelli5a32fcd2021-04-01 09:42:33 -07001005 .get_stats = bcm54xx_get_stats,
1006 .probe = bcm54xx_phy_probe,
Florian Fainelli8dc84dc2021-09-16 14:27:41 -07001007 .link_change_notify = bcm54xx_link_change_notify,
Bhadram Varka23b83922018-05-02 20:43:58 +05301008}, {
Florian Fainelli123aff22020-04-17 11:38:02 -07001009 .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 Fainelli5a32fcd2021-04-01 09:42:33 -07001016 .get_stats = bcm54xx_get_stats,
1017 .probe = bcm54xx_phy_probe,
Florian Fainelli123aff22020-04-17 11:38:02 -07001018 .config_init = bcm54xx_config_init,
Florian Fainelli123aff22020-04-17 11:38:02 -07001019 .config_intr = bcm_phy_config_intr,
Ioana Ciornei4567d5c2020-11-01 14:51:06 +02001020 .handle_interrupt = bcm_phy_handle_interrupt,
Florian Fainelli8dc84dc2021-09-16 14:27:41 -07001021 .link_change_notify = bcm54xx_link_change_notify,
Florian Fainelli123aff22020-04-17 11:38:02 -07001022}, {
Bhadram Varka23b83922018-05-02 20:43:58 +05301023 .phy_id = PHY_ID_BCM89610,
1024 .phy_id_mask = 0xfffffff0,
1025 .name = "Broadcom BCM89610",
Heiner Kallweitdcdecdc2019-04-12 20:47:03 +02001026 /* PHY_GBIT_FEATURES */
Florian Fainelli5a32fcd2021-04-01 09:42:33 -07001027 .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 Varka23b83922018-05-02 20:43:58 +05301031 .config_init = bcm54xx_config_init,
Bhadram Varka23b83922018-05-02 20:43:58 +05301032 .config_intr = bcm_phy_config_intr,
Ioana Ciornei4567d5c2020-11-01 14:51:06 +02001033 .handle_interrupt = bcm_phy_handle_interrupt,
Florian Fainelli8dc84dc2021-09-16 14:27:41 -07001034 .link_change_notify = bcm54xx_link_change_notify,
Christian Hohnstaedtd5bf9072012-07-04 05:44:34 +00001035} };
Dmitry Baryshkov7a938f82010-06-16 23:02:24 +00001036
Johan Hovold50fd7152014-11-11 19:45:59 +01001037module_phy_driver(broadcom_drivers);
David Woodhouse4e4f10f2010-04-02 01:05:56 +00001038
Uwe Kleine-Königcf93c942010-10-03 23:43:32 +00001039static struct mdio_device_id __maybe_unused broadcom_tbl[] = {
Dmitry Baryshkovfcb26ec2010-06-16 23:02:23 +00001040 { PHY_ID_BCM5411, 0xfffffff0 },
1041 { PHY_ID_BCM5421, 0xfffffff0 },
Rafał Miłecki0fc9ae12017-01-27 14:07:01 +01001042 { PHY_ID_BCM54210E, 0xfffffff0 },
Dmitry Baryshkovfcb26ec2010-06-16 23:02:23 +00001043 { PHY_ID_BCM5461, 0xfffffff0 },
Xo Wangd92ead12016-10-21 10:20:13 -07001044 { PHY_ID_BCM54612E, 0xfffffff0 },
Alessio Igor Bogani3bca4cf62015-04-08 12:15:18 +02001045 { PHY_ID_BCM54616S, 0xfffffff0 },
Dmitry Baryshkovfcb26ec2010-06-16 23:02:23 +00001046 { PHY_ID_BCM5464, 0xfffffff0 },
Aaro Koskinen3c25a862015-11-22 01:08:54 +02001047 { PHY_ID_BCM5481, 0xfffffff0 },
Jon Masonb14995a2016-11-04 01:10:58 -04001048 { PHY_ID_BCM54810, 0xfffffff0 },
Kevin Lob0ed0bb2020-05-16 01:24:47 +08001049 { PHY_ID_BCM54811, 0xfffffff0 },
Dmitry Baryshkovfcb26ec2010-06-16 23:02:23 +00001050 { PHY_ID_BCM5482, 0xfffffff0 },
David Woodhouse4e4f10f2010-04-02 01:05:56 +00001051 { PHY_ID_BCM50610, 0xfffffff0 },
1052 { PHY_ID_BCM50610M, 0xfffffff0 },
1053 { PHY_ID_BCM57780, 0xfffffff0 },
1054 { PHY_ID_BCMAC131, 0xfffffff0 },
Dmitry Baryshkov7a938f82010-06-16 23:02:24 +00001055 { PHY_ID_BCM5241, 0xfffffff0 },
Florian Fainelli28dc4c82017-12-14 17:48:16 -08001056 { PHY_ID_BCM5395, 0xfffffff0 },
Florian Fainelli123aff22020-04-17 11:38:02 -07001057 { PHY_ID_BCM53125, 0xfffffff0 },
Bhadram Varka23b83922018-05-02 20:43:58 +05301058 { PHY_ID_BCM89610, 0xfffffff0 },
David Woodhouse4e4f10f2010-04-02 01:05:56 +00001059 { }
1060};
1061
1062MODULE_DEVICE_TABLE(mdio, broadcom_tbl);