blob: aa01020ab1b9e0ba82e3776ab7e16d491443a260 [file] [log] [blame]
Florian Fainellib560a582014-02-13 16:08:45 -08001/*
2 * Broadcom BCM7xxx internal transceivers support.
3 *
4 * Copyright (C) 2014, Broadcom Corporation
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11
12#include <linux/module.h>
13#include <linux/phy.h>
14#include <linux/delay.h>
Arun Parameswarana1cba562015-10-06 12:25:48 -070015#include "bcm-phy-lib.h"
Florian Fainellib560a582014-02-13 16:08:45 -080016#include <linux/bitops.h>
17#include <linux/brcmphy.h>
Florian Fainellib8f9a022014-08-22 18:55:45 -070018#include <linux/mdio.h>
Florian Fainellib560a582014-02-13 16:08:45 -080019
20/* Broadcom BCM7xxx internal PHY registers */
Florian Fainellib560a582014-02-13 16:08:45 -080021
22/* 40nm only register definitions */
23#define MII_BCM7XXX_100TX_AUX_CTL 0x10
24#define MII_BCM7XXX_100TX_FALSE_CAR 0x13
25#define MII_BCM7XXX_100TX_DISC 0x14
26#define MII_BCM7XXX_AUX_MODE 0x1d
Florian Fainelli3ccc3052016-02-06 13:09:36 -080027#define MII_BCM7XXX_64CLK_MDIO BIT(12)
Florian Fainellib560a582014-02-13 16:08:45 -080028#define MII_BCM7XXX_TEST 0x1f
29#define MII_BCM7XXX_SHD_MODE_2 BIT(2)
30
Florian Fainellia3622f22014-03-24 16:36:47 -070031/* 28nm only register definitions */
32#define MISC_ADDR(base, channel) base, channel
33
34#define DSP_TAP10 MISC_ADDR(0x0a, 0)
35#define PLL_PLLCTRL_1 MISC_ADDR(0x32, 1)
36#define PLL_PLLCTRL_2 MISC_ADDR(0x32, 2)
37#define PLL_PLLCTRL_4 MISC_ADDR(0x33, 0)
38
39#define AFE_RXCONFIG_0 MISC_ADDR(0x38, 0)
40#define AFE_RXCONFIG_1 MISC_ADDR(0x38, 1)
Florian Fainellia4906312014-11-11 14:55:13 -080041#define AFE_RXCONFIG_2 MISC_ADDR(0x38, 2)
Florian Fainellia3622f22014-03-24 16:36:47 -070042#define AFE_RX_LP_COUNTER MISC_ADDR(0x38, 3)
43#define AFE_TX_CONFIG MISC_ADDR(0x39, 0)
Florian Fainellia4906312014-11-11 14:55:13 -080044#define AFE_VDCA_ICTRL_0 MISC_ADDR(0x39, 1)
45#define AFE_VDAC_OTHERS_0 MISC_ADDR(0x39, 3)
Florian Fainellia3622f22014-03-24 16:36:47 -070046#define AFE_HPF_TRIM_OTHERS MISC_ADDR(0x3a, 0)
47
Florian Fainellib23ce9e2016-11-29 09:57:18 -080048struct bcm7xxx_phy_priv {
49 u64 *stats;
50};
51
Florian Fainelli9c41f2b2014-11-11 14:55:12 -080052static void r_rc_cal_reset(struct phy_device *phydev)
53{
54 /* Reset R_CAL/RC_CAL Engine */
Arun Parameswarana1cba562015-10-06 12:25:48 -070055 bcm_phy_write_exp(phydev, 0x00b0, 0x0010);
Florian Fainelli9c41f2b2014-11-11 14:55:12 -080056
57 /* Disable Reset R_AL/RC_CAL Engine */
Arun Parameswarana1cba562015-10-06 12:25:48 -070058 bcm_phy_write_exp(phydev, 0x00b0, 0x0000);
Florian Fainelli9c41f2b2014-11-11 14:55:12 -080059}
60
Florian Fainelli2a9df742014-11-11 14:55:11 -080061static int bcm7xxx_28nm_b0_afe_config_init(struct phy_device *phydev)
Florian Fainellib560a582014-02-13 16:08:45 -080062{
Florian Fainellib560a582014-02-13 16:08:45 -080063 /* Increase VCO range to prevent unlocking problem of PLL at low
64 * temp
65 */
Arun Parameswarana1cba562015-10-06 12:25:48 -070066 bcm_phy_write_misc(phydev, PLL_PLLCTRL_1, 0x0048);
Florian Fainellib560a582014-02-13 16:08:45 -080067
68 /* Change Ki to 011 */
Arun Parameswarana1cba562015-10-06 12:25:48 -070069 bcm_phy_write_misc(phydev, PLL_PLLCTRL_2, 0x021b);
Florian Fainellib560a582014-02-13 16:08:45 -080070
71 /* Disable loading of TVCO buffer to bandgap, set bandgap trim
72 * to 111
73 */
Arun Parameswarana1cba562015-10-06 12:25:48 -070074 bcm_phy_write_misc(phydev, PLL_PLLCTRL_4, 0x0e20);
Florian Fainellib560a582014-02-13 16:08:45 -080075
76 /* Adjust bias current trim by -3 */
Arun Parameswarana1cba562015-10-06 12:25:48 -070077 bcm_phy_write_misc(phydev, DSP_TAP10, 0x690b);
Florian Fainellib560a582014-02-13 16:08:45 -080078
79 /* Switch to CORE_BASE1E */
Arun Parameswaran9200c272015-10-06 12:25:50 -070080 phy_write(phydev, MII_BRCM_CORE_BASE1E, 0xd);
Florian Fainellib560a582014-02-13 16:08:45 -080081
Florian Fainelli9c41f2b2014-11-11 14:55:12 -080082 r_rc_cal_reset(phydev);
Florian Fainellib560a582014-02-13 16:08:45 -080083
Florian Fainelli99185422014-03-24 16:36:48 -070084 /* write AFE_RXCONFIG_0 */
Arun Parameswarana1cba562015-10-06 12:25:48 -070085 bcm_phy_write_misc(phydev, AFE_RXCONFIG_0, 0xeb19);
Florian Fainelli99185422014-03-24 16:36:48 -070086
87 /* write AFE_RXCONFIG_1 */
Arun Parameswarana1cba562015-10-06 12:25:48 -070088 bcm_phy_write_misc(phydev, AFE_RXCONFIG_1, 0x9a3f);
Florian Fainelli99185422014-03-24 16:36:48 -070089
90 /* write AFE_RX_LP_COUNTER */
Arun Parameswarana1cba562015-10-06 12:25:48 -070091 bcm_phy_write_misc(phydev, AFE_RX_LP_COUNTER, 0x7fc0);
Florian Fainelli99185422014-03-24 16:36:48 -070092
93 /* write AFE_HPF_TRIM_OTHERS */
Arun Parameswarana1cba562015-10-06 12:25:48 -070094 bcm_phy_write_misc(phydev, AFE_HPF_TRIM_OTHERS, 0x000b);
Florian Fainelli99185422014-03-24 16:36:48 -070095
96 /* write AFTE_TX_CONFIG */
Arun Parameswarana1cba562015-10-06 12:25:48 -070097 bcm_phy_write_misc(phydev, AFE_TX_CONFIG, 0x0800);
Florian Fainelli99185422014-03-24 16:36:48 -070098
Florian Fainellib560a582014-02-13 16:08:45 -080099 return 0;
100}
101
Florian Fainellia4906312014-11-11 14:55:13 -0800102static int bcm7xxx_28nm_d0_afe_config_init(struct phy_device *phydev)
103{
104 /* AFE_RXCONFIG_0 */
Arun Parameswarana1cba562015-10-06 12:25:48 -0700105 bcm_phy_write_misc(phydev, AFE_RXCONFIG_0, 0xeb15);
Florian Fainellia4906312014-11-11 14:55:13 -0800106
107 /* AFE_RXCONFIG_1 */
Arun Parameswarana1cba562015-10-06 12:25:48 -0700108 bcm_phy_write_misc(phydev, AFE_RXCONFIG_1, 0x9b2f);
Florian Fainellia4906312014-11-11 14:55:13 -0800109
110 /* AFE_RXCONFIG_2, set rCal offset for HT=0 code and LT=-2 code */
Arun Parameswarana1cba562015-10-06 12:25:48 -0700111 bcm_phy_write_misc(phydev, AFE_RXCONFIG_2, 0x2003);
Florian Fainellia4906312014-11-11 14:55:13 -0800112
113 /* AFE_RX_LP_COUNTER, set RX bandwidth to maximum */
Arun Parameswarana1cba562015-10-06 12:25:48 -0700114 bcm_phy_write_misc(phydev, AFE_RX_LP_COUNTER, 0x7fc0);
Florian Fainellia4906312014-11-11 14:55:13 -0800115
Florian Fainelli6da82532015-06-08 11:05:20 -0700116 /* AFE_TX_CONFIG, set 100BT Cfeed=011 to improve rise/fall time */
Arun Parameswarana1cba562015-10-06 12:25:48 -0700117 bcm_phy_write_misc(phydev, AFE_TX_CONFIG, 0x431);
Florian Fainellia4906312014-11-11 14:55:13 -0800118
119 /* AFE_VDCA_ICTRL_0, set Iq=1101 instead of 0111 for AB symmetry */
Arun Parameswarana1cba562015-10-06 12:25:48 -0700120 bcm_phy_write_misc(phydev, AFE_VDCA_ICTRL_0, 0xa7da);
Florian Fainellia4906312014-11-11 14:55:13 -0800121
122 /* AFE_VDAC_OTHERS_0, set 1000BT Cidac=010 for all ports */
Arun Parameswarana1cba562015-10-06 12:25:48 -0700123 bcm_phy_write_misc(phydev, AFE_VDAC_OTHERS_0, 0xa020);
Florian Fainellia4906312014-11-11 14:55:13 -0800124
125 /* AFE_HPF_TRIM_OTHERS, set 100Tx/10BT to -4.5% swing and set rCal
126 * offset for HT=0 code
127 */
Arun Parameswarana1cba562015-10-06 12:25:48 -0700128 bcm_phy_write_misc(phydev, AFE_HPF_TRIM_OTHERS, 0x00e3);
Florian Fainellia4906312014-11-11 14:55:13 -0800129
130 /* CORE_BASE1E, force trim to overwrite and set I_ext trim to 0000 */
Arun Parameswaran9200c272015-10-06 12:25:50 -0700131 phy_write(phydev, MII_BRCM_CORE_BASE1E, 0x0010);
Florian Fainellia4906312014-11-11 14:55:13 -0800132
133 /* DSP_TAP10, adjust bias current trim (+0% swing, +0 tick) */
Arun Parameswarana1cba562015-10-06 12:25:48 -0700134 bcm_phy_write_misc(phydev, DSP_TAP10, 0x011b);
Florian Fainellia4906312014-11-11 14:55:13 -0800135
136 /* Reset R_CAL/RC_CAL engine */
137 r_rc_cal_reset(phydev);
138
139 return 0;
140}
141
Florian Fainelli0c2fdc22014-11-11 14:55:14 -0800142static int bcm7xxx_28nm_e0_plus_afe_config_init(struct phy_device *phydev)
143{
144 /* AFE_RXCONFIG_1, provide more margin for INL/DNL measurement */
Arun Parameswarana1cba562015-10-06 12:25:48 -0700145 bcm_phy_write_misc(phydev, AFE_RXCONFIG_1, 0x9b2f);
Florian Fainelli0c2fdc22014-11-11 14:55:14 -0800146
Florian Fainelli6da82532015-06-08 11:05:20 -0700147 /* AFE_TX_CONFIG, set 100BT Cfeed=011 to improve rise/fall time */
Arun Parameswarana1cba562015-10-06 12:25:48 -0700148 bcm_phy_write_misc(phydev, AFE_TX_CONFIG, 0x431);
Florian Fainelli6da82532015-06-08 11:05:20 -0700149
Florian Fainelli0c2fdc22014-11-11 14:55:14 -0800150 /* AFE_VDCA_ICTRL_0, set Iq=1101 instead of 0111 for AB symmetry */
Arun Parameswarana1cba562015-10-06 12:25:48 -0700151 bcm_phy_write_misc(phydev, AFE_VDCA_ICTRL_0, 0xa7da);
Florian Fainelli0c2fdc22014-11-11 14:55:14 -0800152
153 /* AFE_HPF_TRIM_OTHERS, set 100Tx/10BT to -4.5% swing and set rCal
154 * offset for HT=0 code
155 */
Arun Parameswarana1cba562015-10-06 12:25:48 -0700156 bcm_phy_write_misc(phydev, AFE_HPF_TRIM_OTHERS, 0x00e3);
Florian Fainelli0c2fdc22014-11-11 14:55:14 -0800157
158 /* CORE_BASE1E, force trim to overwrite and set I_ext trim to 0000 */
Arun Parameswaran9200c272015-10-06 12:25:50 -0700159 phy_write(phydev, MII_BRCM_CORE_BASE1E, 0x0010);
Florian Fainelli0c2fdc22014-11-11 14:55:14 -0800160
161 /* DSP_TAP10, adjust bias current trim (+0% swing, +0 tick) */
Arun Parameswarana1cba562015-10-06 12:25:48 -0700162 bcm_phy_write_misc(phydev, DSP_TAP10, 0x011b);
Florian Fainelli0c2fdc22014-11-11 14:55:14 -0800163
164 /* Reset R_CAL/RC_CAL engine */
165 r_rc_cal_reset(phydev);
166
167 return 0;
168}
169
Florian Fainelli039a7b82017-01-20 12:36:34 -0800170static int bcm7xxx_28nm_a0_patch_afe_config_init(struct phy_device *phydev)
171{
172 /* +1 RC_CAL codes for RL centering for both LT and HT conditions */
173 bcm_phy_write_misc(phydev, AFE_RXCONFIG_2, 0xd003);
174
175 /* Cut master bias current by 2% to compensate for RC_CAL offset */
176 bcm_phy_write_misc(phydev, DSP_TAP10, 0x791b);
177
178 /* Improve hybrid leakage */
179 bcm_phy_write_misc(phydev, AFE_HPF_TRIM_OTHERS, 0x10e3);
180
181 /* Change rx_on_tune 8 to 0xf */
182 bcm_phy_write_misc(phydev, 0x21, 0x2, 0x87f6);
183
184 /* Change 100Tx EEE bandwidth */
185 bcm_phy_write_misc(phydev, 0x22, 0x2, 0x017d);
186
187 /* Enable ffe zero detection for Vitesse interoperability */
188 bcm_phy_write_misc(phydev, 0x26, 0x2, 0x0015);
189
190 r_rc_cal_reset(phydev);
191
192 return 0;
193}
194
Florian Fainellib560a582014-02-13 16:08:45 -0800195static int bcm7xxx_28nm_config_init(struct phy_device *phydev)
196{
Florian Fainellid8ebfed2014-09-19 13:07:56 -0700197 u8 rev = PHY_BRCM_7XXX_REV(phydev->dev_flags);
198 u8 patch = PHY_BRCM_7XXX_PATCH(phydev->dev_flags);
Florian Fainellidb888162016-11-22 11:40:57 -0800199 u8 count;
Florian Fainellid8ebfed2014-09-19 13:07:56 -0700200 int ret = 0;
Florian Fainellib560a582014-02-13 16:08:45 -0800201
Florian Fainelli039a7b82017-01-20 12:36:34 -0800202 /* Newer devices have moved the revision information back into a
203 * standard location in MII_PHYS_ID[23]
204 */
205 if (rev == 0)
206 rev = phydev->phy_id & ~phydev->drv->phy_id_mask;
207
Florian Fainelli6ec259c2014-11-11 14:55:10 -0800208 pr_info_once("%s: %s PHY revision: 0x%02x, patch: %d\n",
Andrew Lunn84eff6d2016-01-06 20:11:10 +0100209 phydev_name(phydev), phydev->drv->name, rev, patch);
Florian Fainellib560a582014-02-13 16:08:45 -0800210
Florian Fainelli8e346e12015-06-26 10:39:04 -0700211 /* Dummy read to a register to workaround an issue upon reset where the
212 * internal inverter may not allow the first MDIO transaction to pass
213 * the MDIO management controller and make us return 0xffff for such
214 * reads.
215 */
216 phy_read(phydev, MII_BMSR);
217
Florian Fainellid8ebfed2014-09-19 13:07:56 -0700218 switch (rev) {
Florian Fainellid8ebfed2014-09-19 13:07:56 -0700219 case 0xb0:
Florian Fainelli2a9df742014-11-11 14:55:11 -0800220 ret = bcm7xxx_28nm_b0_afe_config_init(phydev);
Florian Fainellid8ebfed2014-09-19 13:07:56 -0700221 break;
Florian Fainellia4906312014-11-11 14:55:13 -0800222 case 0xd0:
223 ret = bcm7xxx_28nm_d0_afe_config_init(phydev);
224 break;
Florian Fainelli0c2fdc22014-11-11 14:55:14 -0800225 case 0xe0:
226 case 0xf0:
Florian Fainelli60efff02014-12-03 09:57:00 -0800227 /* Rev G0 introduces a roll over */
228 case 0x10:
Florian Fainelli0c2fdc22014-11-11 14:55:14 -0800229 ret = bcm7xxx_28nm_e0_plus_afe_config_init(phydev);
230 break;
Florian Fainelli039a7b82017-01-20 12:36:34 -0800231 case 0x01:
232 ret = bcm7xxx_28nm_a0_patch_afe_config_init(phydev);
233 break;
Florian Fainellid8ebfed2014-09-19 13:07:56 -0700234 default:
Florian Fainellid8ebfed2014-09-19 13:07:56 -0700235 break;
236 }
237
Florian Fainelli9df54dd2014-08-22 18:55:41 -0700238 if (ret)
239 return ret;
240
Florian Fainellidb888162016-11-22 11:40:57 -0800241 ret = bcm_phy_downshift_get(phydev, &count);
242 if (ret)
243 return ret;
244
245 /* Only enable EEE if Wirespeed/downshift is disabled */
246 ret = bcm_phy_set_eee(phydev, count == DOWNSHIFT_DEV_DISABLE);
Florian Fainellib8f9a022014-08-22 18:55:45 -0700247 if (ret)
248 return ret;
249
Arun Parameswarana1cba562015-10-06 12:25:48 -0700250 return bcm_phy_enable_apd(phydev, true);
Florian Fainellib560a582014-02-13 16:08:45 -0800251}
252
Florian Fainelli4fd14e02014-08-14 16:52:52 -0700253static int bcm7xxx_28nm_resume(struct phy_device *phydev)
254{
255 int ret;
256
257 /* Re-apply workarounds coming out suspend/resume */
258 ret = bcm7xxx_28nm_config_init(phydev);
259 if (ret)
260 return ret;
261
262 /* 28nm Gigabit PHYs come out of reset without any half-duplex
263 * or "hub" compliant advertised mode, fix that. This does not
264 * cause any problems with the PHY library since genphy_config_aneg()
265 * gracefully handles auto-negotiated and forced modes.
266 */
267 return genphy_config_aneg(phydev);
268}
269
Florian Fainellib560a582014-02-13 16:08:45 -0800270static int phy_set_clr_bits(struct phy_device *dev, int location,
271 int set_mask, int clr_mask)
272{
273 int v, ret;
274
275 v = phy_read(dev, location);
276 if (v < 0)
277 return v;
278
279 v &= ~clr_mask;
280 v |= set_mask;
281
282 ret = phy_write(dev, location, v);
283 if (ret < 0)
284 return ret;
285
286 return v;
287}
288
289static int bcm7xxx_config_init(struct phy_device *phydev)
290{
291 int ret;
292
293 /* Enable 64 clock MDIO */
Florian Fainelli3ccc3052016-02-06 13:09:36 -0800294 phy_write(phydev, MII_BCM7XXX_AUX_MODE, MII_BCM7XXX_64CLK_MDIO);
Florian Fainellib560a582014-02-13 16:08:45 -0800295 phy_read(phydev, MII_BCM7XXX_AUX_MODE);
296
Florian Fainellib560a582014-02-13 16:08:45 -0800297 /* set shadow mode 2 */
298 ret = phy_set_clr_bits(phydev, MII_BCM7XXX_TEST,
299 MII_BCM7XXX_SHD_MODE_2, MII_BCM7XXX_SHD_MODE_2);
300 if (ret < 0)
301 return ret;
302
303 /* set iddq_clkbias */
304 phy_write(phydev, MII_BCM7XXX_100TX_DISC, 0x0F00);
305 udelay(10);
306
307 /* reset iddq_clkbias */
308 phy_write(phydev, MII_BCM7XXX_100TX_DISC, 0x0C00);
309
310 phy_write(phydev, MII_BCM7XXX_100TX_FALSE_CAR, 0x7555);
311
312 /* reset shadow mode 2 */
Florian Fainelli50d89982016-02-06 12:58:48 -0800313 ret = phy_set_clr_bits(phydev, MII_BCM7XXX_TEST, 0, MII_BCM7XXX_SHD_MODE_2);
Florian Fainellib560a582014-02-13 16:08:45 -0800314 if (ret < 0)
315 return ret;
316
317 return 0;
318}
319
320/* Workaround for putting the PHY in IDDQ mode, required
Florian Fainelli82c084f2014-08-14 16:52:53 -0700321 * for all BCM7XXX 40nm and 65nm PHYs
Florian Fainellib560a582014-02-13 16:08:45 -0800322 */
323static int bcm7xxx_suspend(struct phy_device *phydev)
324{
325 int ret;
326 const struct bcm7xxx_regs {
327 int reg;
328 u16 value;
329 } bcm7xxx_suspend_cfg[] = {
330 { MII_BCM7XXX_TEST, 0x008b },
331 { MII_BCM7XXX_100TX_AUX_CTL, 0x01c0 },
332 { MII_BCM7XXX_100TX_DISC, 0x7000 },
333 { MII_BCM7XXX_TEST, 0x000f },
334 { MII_BCM7XXX_100TX_AUX_CTL, 0x20d0 },
335 { MII_BCM7XXX_TEST, 0x000b },
336 };
337 unsigned int i;
338
339 for (i = 0; i < ARRAY_SIZE(bcm7xxx_suspend_cfg); i++) {
340 ret = phy_write(phydev,
341 bcm7xxx_suspend_cfg[i].reg,
342 bcm7xxx_suspend_cfg[i].value);
343 if (ret)
344 return ret;
345 }
346
347 return 0;
348}
349
Florian Fainellidb888162016-11-22 11:40:57 -0800350static int bcm7xxx_28nm_get_tunable(struct phy_device *phydev,
351 struct ethtool_tunable *tuna,
352 void *data)
353{
354 switch (tuna->id) {
355 case ETHTOOL_PHY_DOWNSHIFT:
356 return bcm_phy_downshift_get(phydev, (u8 *)data);
357 default:
358 return -EOPNOTSUPP;
359 }
360}
361
362static int bcm7xxx_28nm_set_tunable(struct phy_device *phydev,
363 struct ethtool_tunable *tuna,
364 const void *data)
365{
366 u8 count = *(u8 *)data;
367 int ret;
368
369 switch (tuna->id) {
370 case ETHTOOL_PHY_DOWNSHIFT:
371 ret = bcm_phy_downshift_set(phydev, count);
372 break;
373 default:
374 return -EOPNOTSUPP;
375 }
376
377 if (ret)
378 return ret;
379
380 /* Disable EEE advertisment since this prevents the PHY
381 * from successfully linking up, trigger auto-negotiation restart
382 * to let the MAC decide what to do.
383 */
384 ret = bcm_phy_set_eee(phydev, count == DOWNSHIFT_DEV_DISABLE);
385 if (ret)
386 return ret;
387
388 return genphy_restart_aneg(phydev);
389}
390
Florian Fainellib23ce9e2016-11-29 09:57:18 -0800391static void bcm7xxx_28nm_get_phy_stats(struct phy_device *phydev,
392 struct ethtool_stats *stats, u64 *data)
393{
394 struct bcm7xxx_phy_priv *priv = phydev->priv;
395
396 bcm_phy_get_stats(phydev, priv->stats, stats, data);
397}
398
399static int bcm7xxx_28nm_probe(struct phy_device *phydev)
400{
401 struct bcm7xxx_phy_priv *priv;
402
403 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
404 if (!priv)
405 return -ENOMEM;
406
407 phydev->priv = priv;
408
409 priv->stats = devm_kcalloc(&phydev->mdio.dev,
410 bcm_phy_get_sset_count(phydev), sizeof(u64),
411 GFP_KERNEL);
412 if (!priv->stats)
413 return -ENOMEM;
414
415 return 0;
416}
417
Florian Fainelli153df3c2014-08-26 13:15:24 -0700418#define BCM7XXX_28NM_GPHY(_oui, _name) \
419{ \
420 .phy_id = (_oui), \
421 .phy_id_mask = 0xfffffff0, \
422 .name = _name, \
Timur Tabi529ed122016-12-07 13:20:51 -0600423 .features = PHY_GBIT_FEATURES, \
Florian Fainelli153df3c2014-08-26 13:15:24 -0700424 .flags = PHY_IS_INTERNAL, \
Florian Fainelli2a9df742014-11-11 14:55:11 -0800425 .config_init = bcm7xxx_28nm_config_init, \
Florian Fainelli153df3c2014-08-26 13:15:24 -0700426 .config_aneg = genphy_config_aneg, \
427 .read_status = genphy_read_status, \
428 .resume = bcm7xxx_28nm_resume, \
Florian Fainellidb888162016-11-22 11:40:57 -0800429 .get_tunable = bcm7xxx_28nm_get_tunable, \
430 .set_tunable = bcm7xxx_28nm_set_tunable, \
Florian Fainellib23ce9e2016-11-29 09:57:18 -0800431 .get_sset_count = bcm_phy_get_sset_count, \
432 .get_strings = bcm_phy_get_strings, \
433 .get_stats = bcm7xxx_28nm_get_phy_stats, \
434 .probe = bcm7xxx_28nm_probe, \
Florian Fainelli153df3c2014-08-26 13:15:24 -0700435}
436
Florian Fainelli3125c082016-02-06 13:09:37 -0800437#define BCM7XXX_40NM_EPHY(_oui, _name) \
438{ \
439 .phy_id = (_oui), \
440 .phy_id_mask = 0xfffffff0, \
441 .name = _name, \
Timur Tabi529ed122016-12-07 13:20:51 -0600442 .features = PHY_BASIC_FEATURES, \
Florian Fainelli3125c082016-02-06 13:09:37 -0800443 .flags = PHY_IS_INTERNAL, \
444 .config_init = bcm7xxx_config_init, \
445 .config_aneg = genphy_config_aneg, \
446 .read_status = genphy_read_status, \
447 .suspend = bcm7xxx_suspend, \
448 .resume = bcm7xxx_config_init, \
449}
450
Florian Fainellib560a582014-02-13 16:08:45 -0800451static struct phy_driver bcm7xxx_driver[] = {
Florian Fainelli430ad682014-08-26 13:15:27 -0700452 BCM7XXX_28NM_GPHY(PHY_ID_BCM7250, "Broadcom BCM7250"),
Florian Fainelli582d0ac2017-01-20 12:36:33 -0800453 BCM7XXX_28NM_GPHY(PHY_ID_BCM7278, "Broadcom BCM7278"),
Florian Fainelli430ad682014-08-26 13:15:27 -0700454 BCM7XXX_28NM_GPHY(PHY_ID_BCM7364, "Broadcom BCM7364"),
Florian Fainelli153df3c2014-08-26 13:15:24 -0700455 BCM7XXX_28NM_GPHY(PHY_ID_BCM7366, "Broadcom BCM7366"),
456 BCM7XXX_28NM_GPHY(PHY_ID_BCM7439, "Broadcom BCM7439"),
Florian Fainelli59e33c22015-03-09 15:44:13 -0700457 BCM7XXX_28NM_GPHY(PHY_ID_BCM7439_2, "Broadcom BCM7439 (2)"),
Florian Fainelli153df3c2014-08-26 13:15:24 -0700458 BCM7XXX_28NM_GPHY(PHY_ID_BCM7445, "Broadcom BCM7445"),
Jaedon Shin4cef1912016-03-25 12:46:54 +0900459 BCM7XXX_40NM_EPHY(PHY_ID_BCM7346, "Broadcom BCM7346"),
460 BCM7XXX_40NM_EPHY(PHY_ID_BCM7362, "Broadcom BCM7362"),
Florian Fainelli3125c082016-02-06 13:09:37 -0800461 BCM7XXX_40NM_EPHY(PHY_ID_BCM7425, "Broadcom BCM7425"),
462 BCM7XXX_40NM_EPHY(PHY_ID_BCM7429, "Broadcom BCM7429"),
463 BCM7XXX_40NM_EPHY(PHY_ID_BCM7435, "Broadcom BCM7435"),
David S. Millerb6333532016-02-23 00:09:14 -0500464};
Florian Fainellib560a582014-02-13 16:08:45 -0800465
466static struct mdio_device_id __maybe_unused bcm7xxx_tbl[] = {
Florian Fainelli430ad682014-08-26 13:15:27 -0700467 { PHY_ID_BCM7250, 0xfffffff0, },
Florian Fainelli582d0ac2017-01-20 12:36:33 -0800468 { PHY_ID_BCM7278, 0xfffffff0, },
Florian Fainelli430ad682014-08-26 13:15:27 -0700469 { PHY_ID_BCM7364, 0xfffffff0, },
Florian Fainellib560a582014-02-13 16:08:45 -0800470 { PHY_ID_BCM7366, 0xfffffff0, },
Jaedon Shin4cef1912016-03-25 12:46:54 +0900471 { PHY_ID_BCM7346, 0xfffffff0, },
472 { PHY_ID_BCM7362, 0xfffffff0, },
Petri Gyntherd068b022014-10-01 11:58:02 -0700473 { PHY_ID_BCM7425, 0xfffffff0, },
474 { PHY_ID_BCM7429, 0xfffffff0, },
Florian Fainellib560a582014-02-13 16:08:45 -0800475 { PHY_ID_BCM7439, 0xfffffff0, },
Florian Fainelli9458cea2015-11-24 15:30:21 -0800476 { PHY_ID_BCM7435, 0xfffffff0, },
Florian Fainellib560a582014-02-13 16:08:45 -0800477 { PHY_ID_BCM7445, 0xfffffff0, },
Florian Fainellib560a582014-02-13 16:08:45 -0800478 { }
479};
480
Johan Hovold50fd7152014-11-11 19:45:59 +0100481module_phy_driver(bcm7xxx_driver);
Florian Fainellib560a582014-02-13 16:08:45 -0800482
483MODULE_DEVICE_TABLE(mdio, bcm7xxx_tbl);
484
485MODULE_DESCRIPTION("Broadcom BCM7xxx internal PHY driver");
486MODULE_LICENSE("GPL");
487MODULE_AUTHOR("Broadcom Corporation");