blob: 2222bbf8d0a448e7dec9d46dd91b9c2ed0311e08 [file] [log] [blame]
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001/*
2 * AMD 10Gb Ethernet driver
3 *
4 * This file is available to you under your choice of the following two
5 * licenses:
6 *
7 * License 1: GPLv2
8 *
Lendacky, Thomasced3fca2016-02-17 11:49:28 -06009 * Copyright (c) 2014-2016 Advanced Micro Devices, Inc.
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -050010 *
11 * This file is free software; you may copy, redistribute and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation, either version 2 of the License, or (at
14 * your option) any later version.
15 *
16 * This file is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program. If not, see <http://www.gnu.org/licenses/>.
23 *
24 * This file incorporates work covered by the following copyright and
25 * permission notice:
26 * The Synopsys DWC ETHER XGMAC Software Driver and documentation
27 * (hereinafter "Software") is an unsupported proprietary work of Synopsys,
28 * Inc. unless otherwise expressly agreed to in writing between Synopsys
29 * and you.
30 *
31 * The Software IS NOT an item of Licensed Software or Licensed Product
32 * under any End User Software License Agreement or Agreement for Licensed
33 * Product with Synopsys or any supplement thereto. Permission is hereby
34 * granted, free of charge, to any person obtaining a copy of this software
35 * annotated with this license and the Software, to deal in the Software
36 * without restriction, including without limitation the rights to use,
37 * copy, modify, merge, publish, distribute, sublicense, and/or sell copies
38 * of the Software, and to permit persons to whom the Software is furnished
39 * to do so, subject to the following conditions:
40 *
41 * The above copyright notice and this permission notice shall be included
42 * in all copies or substantial portions of the Software.
43 *
44 * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
45 * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
46 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
47 * PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
48 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
49 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
50 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
51 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
52 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
53 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
54 * THE POSSIBILITY OF SUCH DAMAGE.
55 *
56 *
57 * License 2: Modified BSD
58 *
Lendacky, Thomasced3fca2016-02-17 11:49:28 -060059 * Copyright (c) 2014-2016 Advanced Micro Devices, Inc.
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -050060 * All rights reserved.
61 *
62 * Redistribution and use in source and binary forms, with or without
63 * modification, are permitted provided that the following conditions are met:
64 * * Redistributions of source code must retain the above copyright
65 * notice, this list of conditions and the following disclaimer.
66 * * Redistributions in binary form must reproduce the above copyright
67 * notice, this list of conditions and the following disclaimer in the
68 * documentation and/or other materials provided with the distribution.
69 * * Neither the name of Advanced Micro Devices, Inc. nor the
70 * names of its contributors may be used to endorse or promote products
71 * derived from this software without specific prior written permission.
72 *
73 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
74 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
75 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
76 * ARE DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
77 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
78 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
79 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
80 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
81 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
82 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
83 *
84 * This file incorporates work covered by the following copyright and
85 * permission notice:
86 * The Synopsys DWC ETHER XGMAC Software Driver and documentation
87 * (hereinafter "Software") is an unsupported proprietary work of Synopsys,
88 * Inc. unless otherwise expressly agreed to in writing between Synopsys
89 * and you.
90 *
91 * The Software IS NOT an item of Licensed Software or Licensed Product
92 * under any End User Software License Agreement or Agreement for Licensed
93 * Product with Synopsys or any supplement thereto. Permission is hereby
94 * granted, free of charge, to any person obtaining a copy of this software
95 * annotated with this license and the Software, to deal in the Software
96 * without restriction, including without limitation the rights to use,
97 * copy, modify, merge, publish, distribute, sublicense, and/or sell copies
98 * of the Software, and to permit persons to whom the Software is furnished
99 * to do so, subject to the following conditions:
100 *
101 * The above copyright notice and this permission notice shall be included
102 * in all copies or substantial portions of the Software.
103 *
104 * THIS SOFTWARE IS BEING DISTRIBUTED BY SYNOPSYS SOLELY ON AN "AS IS"
105 * BASIS AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
106 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
107 * PARTICULAR PURPOSE ARE HEREBY DISCLAIMED. IN NO EVENT SHALL SYNOPSYS
108 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
109 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
110 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
111 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
112 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
113 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
114 * THE POSSIBILITY OF SUCH DAMAGE.
115 */
116
Florian Westphal282ccf62017-03-29 17:17:31 +0200117#include <linux/interrupt.h>
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500118#include <linux/module.h>
119#include <linux/kmod.h>
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500120#include <linux/mdio.h>
121#include <linux/phy.h>
122#include <linux/of.h>
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500123#include <linux/bitops.h>
124#include <linux/jiffies.h>
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500125
126#include "xgbe.h"
127#include "xgbe-common.h"
128
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500129static void xgbe_an37_clear_interrupts(struct xgbe_prv_data *pdata)
130{
131 int reg;
132
133 reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_VEND2_AN_STAT);
134 reg &= ~XGBE_AN_CL37_INT_MASK;
135 XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_VEND2_AN_STAT, reg);
136}
137
138static void xgbe_an37_disable_interrupts(struct xgbe_prv_data *pdata)
139{
140 int reg;
141
142 reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_VEND2_AN_CTRL);
143 reg &= ~XGBE_AN_CL37_INT_MASK;
144 XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_VEND2_AN_CTRL, reg);
145
146 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_PCS_DIG_CTRL);
147 reg &= ~XGBE_PCS_CL37_BP;
148 XMDIO_WRITE(pdata, MDIO_MMD_PCS, MDIO_PCS_DIG_CTRL, reg);
149}
150
151static void xgbe_an37_enable_interrupts(struct xgbe_prv_data *pdata)
152{
153 int reg;
154
155 reg = XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_PCS_DIG_CTRL);
156 reg |= XGBE_PCS_CL37_BP;
157 XMDIO_WRITE(pdata, MDIO_MMD_PCS, MDIO_PCS_DIG_CTRL, reg);
158
159 reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_VEND2_AN_CTRL);
160 reg |= XGBE_AN_CL37_INT_MASK;
161 XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_VEND2_AN_CTRL, reg);
162}
163
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500164static void xgbe_an73_clear_interrupts(struct xgbe_prv_data *pdata)
165{
166 XMDIO_WRITE(pdata, MDIO_MMD_AN, MDIO_AN_INT, 0);
167}
168
169static void xgbe_an73_disable_interrupts(struct xgbe_prv_data *pdata)
170{
171 XMDIO_WRITE(pdata, MDIO_MMD_AN, MDIO_AN_INTMASK, 0);
172}
173
174static void xgbe_an73_enable_interrupts(struct xgbe_prv_data *pdata)
175{
176 XMDIO_WRITE(pdata, MDIO_MMD_AN, MDIO_AN_INTMASK, XGBE_AN_CL73_INT_MASK);
177}
178
179static void xgbe_an_enable_interrupts(struct xgbe_prv_data *pdata)
180{
181 switch (pdata->an_mode) {
182 case XGBE_AN_MODE_CL73:
Lendacky, Thomasd7445d12016-11-10 17:11:41 -0600183 case XGBE_AN_MODE_CL73_REDRV:
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500184 xgbe_an73_enable_interrupts(pdata);
185 break;
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500186 case XGBE_AN_MODE_CL37:
187 case XGBE_AN_MODE_CL37_SGMII:
188 xgbe_an37_enable_interrupts(pdata);
189 break;
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500190 default:
191 break;
192 }
193}
194
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500195static void xgbe_an_clear_interrupts_all(struct xgbe_prv_data *pdata)
196{
197 xgbe_an73_clear_interrupts(pdata);
198 xgbe_an37_clear_interrupts(pdata);
199}
200
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500201static void xgbe_an73_enable_kr_training(struct xgbe_prv_data *pdata)
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500202{
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500203 unsigned int reg;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500204
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500205 reg = XMDIO_READ(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_PMD_CTRL);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500206
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500207 reg |= XGBE_KR_TRAINING_ENABLE;
208 XMDIO_WRITE(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_PMD_CTRL, reg);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500209}
210
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500211static void xgbe_an73_disable_kr_training(struct xgbe_prv_data *pdata)
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500212{
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500213 unsigned int reg;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500214
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500215 reg = XMDIO_READ(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_PMD_CTRL);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500216
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500217 reg &= ~XGBE_KR_TRAINING_ENABLE;
218 XMDIO_WRITE(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_PMD_CTRL, reg);
219}
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -0500220
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500221static void xgbe_kr_mode(struct xgbe_prv_data *pdata)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500222{
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500223 /* Enable KR training */
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500224 xgbe_an73_enable_kr_training(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500225
226 /* Set MAC to 10G speed */
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500227 pdata->hw_if.set_speed(pdata, SPEED_10000);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500228
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500229 /* Call PHY implementation support to complete rate change */
230 pdata->phy_if.phy_impl.set_mode(pdata, XGBE_MODE_KR);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500231}
232
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500233static void xgbe_kx_2500_mode(struct xgbe_prv_data *pdata)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500234{
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500235 /* Disable KR training */
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500236 xgbe_an73_disable_kr_training(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500237
238 /* Set MAC to 2.5G speed */
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500239 pdata->hw_if.set_speed(pdata, SPEED_2500);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500240
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500241 /* Call PHY implementation support to complete rate change */
242 pdata->phy_if.phy_impl.set_mode(pdata, XGBE_MODE_KX_2500);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500243}
244
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500245static void xgbe_kx_1000_mode(struct xgbe_prv_data *pdata)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500246{
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500247 /* Disable KR training */
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500248 xgbe_an73_disable_kr_training(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500249
250 /* Set MAC to 1G speed */
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500251 pdata->hw_if.set_speed(pdata, SPEED_1000);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500252
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500253 /* Call PHY implementation support to complete rate change */
254 pdata->phy_if.phy_impl.set_mode(pdata, XGBE_MODE_KX_1000);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500255}
256
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -0600257static void xgbe_sfi_mode(struct xgbe_prv_data *pdata)
258{
Lendacky, Thomasd7445d12016-11-10 17:11:41 -0600259 /* If a KR re-driver is present, change to KR mode instead */
260 if (pdata->kr_redrv)
261 return xgbe_kr_mode(pdata);
262
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -0600263 /* Disable KR training */
264 xgbe_an73_disable_kr_training(pdata);
265
266 /* Set MAC to 10G speed */
267 pdata->hw_if.set_speed(pdata, SPEED_10000);
268
269 /* Call PHY implementation support to complete rate change */
270 pdata->phy_if.phy_impl.set_mode(pdata, XGBE_MODE_SFI);
271}
272
273static void xgbe_x_mode(struct xgbe_prv_data *pdata)
274{
275 /* Disable KR training */
276 xgbe_an73_disable_kr_training(pdata);
277
278 /* Set MAC to 1G speed */
279 pdata->hw_if.set_speed(pdata, SPEED_1000);
280
281 /* Call PHY implementation support to complete rate change */
282 pdata->phy_if.phy_impl.set_mode(pdata, XGBE_MODE_X);
283}
284
285static void xgbe_sgmii_1000_mode(struct xgbe_prv_data *pdata)
286{
287 /* Disable KR training */
288 xgbe_an73_disable_kr_training(pdata);
289
290 /* Set MAC to 1G speed */
291 pdata->hw_if.set_speed(pdata, SPEED_1000);
292
293 /* Call PHY implementation support to complete rate change */
294 pdata->phy_if.phy_impl.set_mode(pdata, XGBE_MODE_SGMII_1000);
295}
296
297static void xgbe_sgmii_100_mode(struct xgbe_prv_data *pdata)
298{
299 /* Disable KR training */
300 xgbe_an73_disable_kr_training(pdata);
301
302 /* Set MAC to 1G speed */
303 pdata->hw_if.set_speed(pdata, SPEED_1000);
304
305 /* Call PHY implementation support to complete rate change */
306 pdata->phy_if.phy_impl.set_mode(pdata, XGBE_MODE_SGMII_100);
307}
308
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500309static enum xgbe_mode xgbe_cur_mode(struct xgbe_prv_data *pdata)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500310{
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500311 return pdata->phy_if.phy_impl.cur_mode(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500312}
313
314static bool xgbe_in_kr_mode(struct xgbe_prv_data *pdata)
315{
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500316 return (xgbe_cur_mode(pdata) == XGBE_MODE_KR);
317}
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500318
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500319static void xgbe_change_mode(struct xgbe_prv_data *pdata,
320 enum xgbe_mode mode)
321{
322 switch (mode) {
323 case XGBE_MODE_KX_1000:
324 xgbe_kx_1000_mode(pdata);
325 break;
326 case XGBE_MODE_KX_2500:
327 xgbe_kx_2500_mode(pdata);
328 break;
329 case XGBE_MODE_KR:
330 xgbe_kr_mode(pdata);
331 break;
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -0600332 case XGBE_MODE_SGMII_100:
333 xgbe_sgmii_100_mode(pdata);
334 break;
335 case XGBE_MODE_SGMII_1000:
336 xgbe_sgmii_1000_mode(pdata);
337 break;
338 case XGBE_MODE_X:
339 xgbe_x_mode(pdata);
340 break;
341 case XGBE_MODE_SFI:
342 xgbe_sfi_mode(pdata);
343 break;
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500344 case XGBE_MODE_UNKNOWN:
345 break;
346 default:
347 netif_dbg(pdata, link, pdata->netdev,
348 "invalid operation mode requested (%u)\n", mode);
349 }
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500350}
351
352static void xgbe_switch_mode(struct xgbe_prv_data *pdata)
353{
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500354 xgbe_change_mode(pdata, pdata->phy_if.phy_impl.switch_mode(pdata));
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500355}
356
357static void xgbe_set_mode(struct xgbe_prv_data *pdata,
358 enum xgbe_mode mode)
359{
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500360 if (mode == xgbe_cur_mode(pdata))
361 return;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500362
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500363 xgbe_change_mode(pdata, mode);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500364}
365
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500366static bool xgbe_use_mode(struct xgbe_prv_data *pdata,
367 enum xgbe_mode mode)
Lendacky, Thomas471e14b2015-05-22 16:32:14 -0500368{
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500369 return pdata->phy_if.phy_impl.use_mode(pdata, mode);
Lendacky, Thomas471e14b2015-05-22 16:32:14 -0500370}
371
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500372static void xgbe_an37_set(struct xgbe_prv_data *pdata, bool enable,
373 bool restart)
374{
375 unsigned int reg;
376
377 reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_CTRL1);
378 reg &= ~MDIO_VEND2_CTRL1_AN_ENABLE;
379
380 if (enable)
381 reg |= MDIO_VEND2_CTRL1_AN_ENABLE;
382
383 if (restart)
384 reg |= MDIO_VEND2_CTRL1_AN_RESTART;
385
386 XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_CTRL1, reg);
387}
388
389static void xgbe_an37_restart(struct xgbe_prv_data *pdata)
390{
391 xgbe_an37_enable_interrupts(pdata);
392 xgbe_an37_set(pdata, true, true);
393
394 netif_dbg(pdata, link, pdata->netdev, "CL37 AN enabled/restarted\n");
395}
396
397static void xgbe_an37_disable(struct xgbe_prv_data *pdata)
398{
399 xgbe_an37_set(pdata, false, false);
400 xgbe_an37_disable_interrupts(pdata);
401
402 netif_dbg(pdata, link, pdata->netdev, "CL37 AN disabled\n");
403}
404
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500405static void xgbe_an73_set(struct xgbe_prv_data *pdata, bool enable,
406 bool restart)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500407{
408 unsigned int reg;
409
410 reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_CTRL1);
411 reg &= ~MDIO_AN_CTRL1_ENABLE;
412
413 if (enable)
414 reg |= MDIO_AN_CTRL1_ENABLE;
415
416 if (restart)
417 reg |= MDIO_AN_CTRL1_RESTART;
418
419 XMDIO_WRITE(pdata, MDIO_MMD_AN, MDIO_CTRL1, reg);
420}
421
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500422static void xgbe_an73_restart(struct xgbe_prv_data *pdata)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500423{
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500424 xgbe_an73_enable_interrupts(pdata);
425 xgbe_an73_set(pdata, true, true);
Lendacky, Thomasd5c78392015-05-22 16:32:21 -0500426
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500427 netif_dbg(pdata, link, pdata->netdev, "CL73 AN enabled/restarted\n");
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500428}
429
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500430static void xgbe_an73_disable(struct xgbe_prv_data *pdata)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500431{
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500432 xgbe_an73_set(pdata, false, false);
433 xgbe_an73_disable_interrupts(pdata);
Lendacky, Thomasd5c78392015-05-22 16:32:21 -0500434
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500435 netif_dbg(pdata, link, pdata->netdev, "CL73 AN disabled\n");
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500436}
437
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500438static void xgbe_an_restart(struct xgbe_prv_data *pdata)
439{
440 switch (pdata->an_mode) {
441 case XGBE_AN_MODE_CL73:
Lendacky, Thomasd7445d12016-11-10 17:11:41 -0600442 case XGBE_AN_MODE_CL73_REDRV:
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500443 xgbe_an73_restart(pdata);
444 break;
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500445 case XGBE_AN_MODE_CL37:
446 case XGBE_AN_MODE_CL37_SGMII:
447 xgbe_an37_restart(pdata);
448 break;
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500449 default:
450 break;
451 }
452}
453
454static void xgbe_an_disable(struct xgbe_prv_data *pdata)
455{
456 switch (pdata->an_mode) {
457 case XGBE_AN_MODE_CL73:
Lendacky, Thomasd7445d12016-11-10 17:11:41 -0600458 case XGBE_AN_MODE_CL73_REDRV:
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500459 xgbe_an73_disable(pdata);
460 break;
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500461 case XGBE_AN_MODE_CL37:
462 case XGBE_AN_MODE_CL37_SGMII:
463 xgbe_an37_disable(pdata);
464 break;
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500465 default:
466 break;
467 }
468}
469
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500470static void xgbe_an_disable_all(struct xgbe_prv_data *pdata)
471{
472 xgbe_an73_disable(pdata);
473 xgbe_an37_disable(pdata);
474}
475
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500476static enum xgbe_an xgbe_an73_tx_training(struct xgbe_prv_data *pdata,
477 enum xgbe_rx *state)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500478{
479 unsigned int ad_reg, lp_reg, reg;
480
481 *state = XGBE_RX_COMPLETE;
482
483 /* If we're not in KR mode then we're done */
484 if (!xgbe_in_kr_mode(pdata))
485 return XGBE_AN_PAGE_RECEIVED;
486
487 /* Enable/Disable FEC */
488 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 2);
489 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA + 2);
490
491 reg = XMDIO_READ(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_FECCTRL);
492 reg &= ~(MDIO_PMA_10GBR_FECABLE_ABLE | MDIO_PMA_10GBR_FECABLE_ERRABLE);
493 if ((ad_reg & 0xc000) && (lp_reg & 0xc000))
494 reg |= pdata->fec_ability;
495
496 XMDIO_WRITE(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_FECCTRL, reg);
497
498 /* Start KR training */
499 reg = XMDIO_READ(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_PMD_CTRL);
500 if (reg & XGBE_KR_TRAINING_ENABLE) {
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500501 if (pdata->phy_if.phy_impl.kr_training_pre)
502 pdata->phy_if.phy_impl.kr_training_pre(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500503
504 reg |= XGBE_KR_TRAINING_START;
505 XMDIO_WRITE(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_10GBR_PMD_CTRL,
506 reg);
507
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500508 if (pdata->phy_if.phy_impl.kr_training_post)
509 pdata->phy_if.phy_impl.kr_training_post(pdata);
Lendacky, Thomasd5c78392015-05-22 16:32:21 -0500510
511 netif_dbg(pdata, link, pdata->netdev,
512 "KR training initiated\n");
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500513 }
514
515 return XGBE_AN_PAGE_RECEIVED;
516}
517
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500518static enum xgbe_an xgbe_an73_tx_xnp(struct xgbe_prv_data *pdata,
519 enum xgbe_rx *state)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500520{
521 u16 msg;
522
523 *state = XGBE_RX_XNP;
524
525 msg = XGBE_XNP_MCF_NULL_MESSAGE;
526 msg |= XGBE_XNP_MP_FORMATTED;
527
528 XMDIO_WRITE(pdata, MDIO_MMD_AN, MDIO_AN_XNP + 2, 0);
529 XMDIO_WRITE(pdata, MDIO_MMD_AN, MDIO_AN_XNP + 1, 0);
530 XMDIO_WRITE(pdata, MDIO_MMD_AN, MDIO_AN_XNP, msg);
531
532 return XGBE_AN_PAGE_RECEIVED;
533}
534
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500535static enum xgbe_an xgbe_an73_rx_bpa(struct xgbe_prv_data *pdata,
536 enum xgbe_rx *state)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500537{
538 unsigned int link_support;
539 unsigned int reg, ad_reg, lp_reg;
540
541 /* Read Base Ability register 2 first */
542 reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA + 1);
543
544 /* Check for a supported mode, otherwise restart in a different one */
545 link_support = xgbe_in_kr_mode(pdata) ? 0x80 : 0x20;
546 if (!(reg & link_support))
547 return XGBE_AN_INCOMPAT_LINK;
548
549 /* Check Extended Next Page support */
550 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE);
551 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPA);
552
553 return ((ad_reg & XGBE_XNP_NP_EXCHANGE) ||
554 (lp_reg & XGBE_XNP_NP_EXCHANGE))
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500555 ? xgbe_an73_tx_xnp(pdata, state)
556 : xgbe_an73_tx_training(pdata, state);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500557}
558
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500559static enum xgbe_an xgbe_an73_rx_xnp(struct xgbe_prv_data *pdata,
560 enum xgbe_rx *state)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500561{
562 unsigned int ad_reg, lp_reg;
563
564 /* Check Extended Next Page support */
565 ad_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_XNP);
566 lp_reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_LPX);
567
568 return ((ad_reg & XGBE_XNP_NP_EXCHANGE) ||
569 (lp_reg & XGBE_XNP_NP_EXCHANGE))
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500570 ? xgbe_an73_tx_xnp(pdata, state)
571 : xgbe_an73_tx_training(pdata, state);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500572}
573
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500574static enum xgbe_an xgbe_an73_page_received(struct xgbe_prv_data *pdata)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500575{
576 enum xgbe_rx *state;
577 unsigned long an_timeout;
578 enum xgbe_an ret;
579
580 if (!pdata->an_start) {
581 pdata->an_start = jiffies;
582 } else {
583 an_timeout = pdata->an_start +
584 msecs_to_jiffies(XGBE_AN_MS_TIMEOUT);
585 if (time_after(jiffies, an_timeout)) {
586 /* Auto-negotiation timed out, reset state */
587 pdata->kr_state = XGBE_RX_BPA;
588 pdata->kx_state = XGBE_RX_BPA;
589
590 pdata->an_start = jiffies;
Lendacky, Thomasd5c78392015-05-22 16:32:21 -0500591
592 netif_dbg(pdata, link, pdata->netdev,
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500593 "CL73 AN timed out, resetting state\n");
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500594 }
595 }
596
597 state = xgbe_in_kr_mode(pdata) ? &pdata->kr_state
Lendacky, Thomase57f7a32016-11-03 13:18:27 -0500598 : &pdata->kx_state;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500599
600 switch (*state) {
601 case XGBE_RX_BPA:
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500602 ret = xgbe_an73_rx_bpa(pdata, state);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500603 break;
604
605 case XGBE_RX_XNP:
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500606 ret = xgbe_an73_rx_xnp(pdata, state);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500607 break;
608
609 default:
610 ret = XGBE_AN_ERROR;
611 }
612
613 return ret;
614}
615
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500616static enum xgbe_an xgbe_an73_incompat_link(struct xgbe_prv_data *pdata)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500617{
618 /* Be sure we aren't looping trying to negotiate */
619 if (xgbe_in_kr_mode(pdata)) {
620 pdata->kr_state = XGBE_RX_ERROR;
621
622 if (!(pdata->phy.advertising & ADVERTISED_1000baseKX_Full) &&
623 !(pdata->phy.advertising & ADVERTISED_2500baseX_Full))
624 return XGBE_AN_NO_LINK;
625
626 if (pdata->kx_state != XGBE_RX_BPA)
627 return XGBE_AN_NO_LINK;
628 } else {
629 pdata->kx_state = XGBE_RX_ERROR;
630
631 if (!(pdata->phy.advertising & ADVERTISED_10000baseKR_Full))
632 return XGBE_AN_NO_LINK;
633
634 if (pdata->kr_state != XGBE_RX_BPA)
635 return XGBE_AN_NO_LINK;
636 }
637
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500638 xgbe_an73_disable(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500639
640 xgbe_switch_mode(pdata);
641
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500642 xgbe_an73_restart(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500643
644 return XGBE_AN_INCOMPAT_LINK;
645}
646
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500647static void xgbe_an37_isr(struct xgbe_prv_data *pdata)
648{
649 unsigned int reg;
650
651 /* Disable AN interrupts */
652 xgbe_an37_disable_interrupts(pdata);
653
654 /* Save the interrupt(s) that fired */
655 reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_VEND2_AN_STAT);
656 pdata->an_int = reg & XGBE_AN_CL37_INT_MASK;
657 pdata->an_status = reg & ~XGBE_AN_CL37_INT_MASK;
658
659 if (pdata->an_int) {
660 /* Clear the interrupt(s) that fired and process them */
661 reg &= ~XGBE_AN_CL37_INT_MASK;
662 XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_VEND2_AN_STAT, reg);
663
664 queue_work(pdata->an_workqueue, &pdata->an_irq_work);
665 } else {
666 /* Enable AN interrupts */
667 xgbe_an37_enable_interrupts(pdata);
Lendacky, Thomas85b85c82017-06-28 13:42:42 -0500668
669 /* Reissue interrupt if status is not clear */
670 if (pdata->vdata->irq_reissue_support)
671 XP_IOWRITE(pdata, XP_INT_REISSUE_EN, 1 << 3);
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500672 }
673}
674
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500675static void xgbe_an73_isr(struct xgbe_prv_data *pdata)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500676{
Lendacky, Thomasced3fca2016-02-17 11:49:28 -0600677 /* Disable AN interrupts */
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500678 xgbe_an73_disable_interrupts(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500679
Lendacky, Thomasced3fca2016-02-17 11:49:28 -0600680 /* Save the interrupt(s) that fired */
681 pdata->an_int = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_INT);
682
683 if (pdata->an_int) {
684 /* Clear the interrupt(s) that fired and process them */
685 XMDIO_WRITE(pdata, MDIO_MMD_AN, MDIO_AN_INT, ~pdata->an_int);
686
687 queue_work(pdata->an_workqueue, &pdata->an_irq_work);
688 } else {
689 /* Enable AN interrupts */
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500690 xgbe_an73_enable_interrupts(pdata);
Lendacky, Thomas85b85c82017-06-28 13:42:42 -0500691
692 /* Reissue interrupt if status is not clear */
693 if (pdata->vdata->irq_reissue_support)
694 XP_IOWRITE(pdata, XP_INT_REISSUE_EN, 1 << 3);
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500695 }
696}
697
Lendacky, Thomas85b85c82017-06-28 13:42:42 -0500698static void xgbe_an_isr_task(unsigned long data)
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500699{
700 struct xgbe_prv_data *pdata = (struct xgbe_prv_data *)data;
701
702 netif_dbg(pdata, intr, pdata->netdev, "AN interrupt received\n");
703
704 switch (pdata->an_mode) {
705 case XGBE_AN_MODE_CL73:
Lendacky, Thomasd7445d12016-11-10 17:11:41 -0600706 case XGBE_AN_MODE_CL73_REDRV:
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500707 xgbe_an73_isr(pdata);
708 break;
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500709 case XGBE_AN_MODE_CL37:
710 case XGBE_AN_MODE_CL37_SGMII:
711 xgbe_an37_isr(pdata);
712 break;
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500713 default:
714 break;
Lendacky, Thomasced3fca2016-02-17 11:49:28 -0600715 }
Lendacky, Thomas85b85c82017-06-28 13:42:42 -0500716}
717
718static irqreturn_t xgbe_an_isr(int irq, void *data)
719{
720 struct xgbe_prv_data *pdata = (struct xgbe_prv_data *)data;
721
722 if (pdata->isr_as_tasklet)
723 tasklet_schedule(&pdata->tasklet_an);
724 else
725 xgbe_an_isr_task((unsigned long)pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500726
727 return IRQ_HANDLED;
728}
729
Lendacky, Thomas85b85c82017-06-28 13:42:42 -0500730static irqreturn_t xgbe_an_combined_isr(struct xgbe_prv_data *pdata)
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600731{
Lendacky, Thomas85b85c82017-06-28 13:42:42 -0500732 xgbe_an_isr_task((unsigned long)pdata);
733
734 return IRQ_HANDLED;
Lendacky, Thomas47f164d2016-11-10 17:09:55 -0600735}
736
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500737static void xgbe_an_irq_work(struct work_struct *work)
738{
739 struct xgbe_prv_data *pdata = container_of(work,
740 struct xgbe_prv_data,
741 an_irq_work);
742
743 /* Avoid a race between enabling the IRQ and exiting the work by
744 * waiting for the work to finish and then queueing it
745 */
746 flush_work(&pdata->an_work);
747 queue_work(pdata->an_workqueue, &pdata->an_work);
748}
749
Lendacky, Thomasd5c78392015-05-22 16:32:21 -0500750static const char *xgbe_state_as_string(enum xgbe_an state)
751{
752 switch (state) {
753 case XGBE_AN_READY:
754 return "Ready";
755 case XGBE_AN_PAGE_RECEIVED:
756 return "Page-Received";
757 case XGBE_AN_INCOMPAT_LINK:
758 return "Incompatible-Link";
759 case XGBE_AN_COMPLETE:
760 return "Complete";
761 case XGBE_AN_NO_LINK:
762 return "No-Link";
763 case XGBE_AN_ERROR:
764 return "Error";
765 default:
766 return "Undefined";
767 }
768}
769
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500770static void xgbe_an37_state_machine(struct xgbe_prv_data *pdata)
771{
772 enum xgbe_an cur_state = pdata->an_state;
773
774 if (!pdata->an_int)
775 return;
776
777 if (pdata->an_int & XGBE_AN_CL37_INT_CMPLT) {
778 pdata->an_state = XGBE_AN_COMPLETE;
779 pdata->an_int &= ~XGBE_AN_CL37_INT_CMPLT;
780
781 /* If SGMII is enabled, check the link status */
782 if ((pdata->an_mode == XGBE_AN_MODE_CL37_SGMII) &&
783 !(pdata->an_status & XGBE_SGMII_AN_LINK_STATUS))
784 pdata->an_state = XGBE_AN_NO_LINK;
785 }
786
787 netif_dbg(pdata, link, pdata->netdev, "CL37 AN %s\n",
788 xgbe_state_as_string(pdata->an_state));
789
790 cur_state = pdata->an_state;
791
792 switch (pdata->an_state) {
793 case XGBE_AN_READY:
794 break;
795
796 case XGBE_AN_COMPLETE:
797 netif_dbg(pdata, link, pdata->netdev,
798 "Auto negotiation successful\n");
799 break;
800
801 case XGBE_AN_NO_LINK:
802 break;
803
804 default:
805 pdata->an_state = XGBE_AN_ERROR;
806 }
807
808 if (pdata->an_state == XGBE_AN_ERROR) {
809 netdev_err(pdata->netdev,
810 "error during auto-negotiation, state=%u\n",
811 cur_state);
812
813 pdata->an_int = 0;
814 xgbe_an37_clear_interrupts(pdata);
815 }
816
817 if (pdata->an_state >= XGBE_AN_COMPLETE) {
818 pdata->an_result = pdata->an_state;
819 pdata->an_state = XGBE_AN_READY;
820
821 netif_dbg(pdata, link, pdata->netdev, "CL37 AN result: %s\n",
822 xgbe_state_as_string(pdata->an_result));
823 }
824
825 xgbe_an37_enable_interrupts(pdata);
826}
827
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500828static void xgbe_an73_state_machine(struct xgbe_prv_data *pdata)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500829{
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500830 enum xgbe_an cur_state = pdata->an_state;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500831
Lendacky, Thomasced3fca2016-02-17 11:49:28 -0600832 if (!pdata->an_int)
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500833 return;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500834
835next_int:
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500836 if (pdata->an_int & XGBE_AN_CL73_PG_RCV) {
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500837 pdata->an_state = XGBE_AN_PAGE_RECEIVED;
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500838 pdata->an_int &= ~XGBE_AN_CL73_PG_RCV;
839 } else if (pdata->an_int & XGBE_AN_CL73_INC_LINK) {
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500840 pdata->an_state = XGBE_AN_INCOMPAT_LINK;
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500841 pdata->an_int &= ~XGBE_AN_CL73_INC_LINK;
842 } else if (pdata->an_int & XGBE_AN_CL73_INT_CMPLT) {
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500843 pdata->an_state = XGBE_AN_COMPLETE;
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500844 pdata->an_int &= ~XGBE_AN_CL73_INT_CMPLT;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500845 } else {
846 pdata->an_state = XGBE_AN_ERROR;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500847 }
848
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500849again:
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500850 netif_dbg(pdata, link, pdata->netdev, "CL73 AN %s\n",
Lendacky, Thomasd5c78392015-05-22 16:32:21 -0500851 xgbe_state_as_string(pdata->an_state));
852
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500853 cur_state = pdata->an_state;
854
855 switch (pdata->an_state) {
856 case XGBE_AN_READY:
857 pdata->an_supported = 0;
858 break;
859
860 case XGBE_AN_PAGE_RECEIVED:
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500861 pdata->an_state = xgbe_an73_page_received(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500862 pdata->an_supported++;
863 break;
864
865 case XGBE_AN_INCOMPAT_LINK:
866 pdata->an_supported = 0;
867 pdata->parallel_detect = 0;
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500868 pdata->an_state = xgbe_an73_incompat_link(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500869 break;
870
871 case XGBE_AN_COMPLETE:
872 pdata->parallel_detect = pdata->an_supported ? 0 : 1;
Lendacky, Thomasd5c78392015-05-22 16:32:21 -0500873 netif_dbg(pdata, link, pdata->netdev, "%s successful\n",
874 pdata->an_supported ? "Auto negotiation"
875 : "Parallel detection");
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500876 break;
877
878 case XGBE_AN_NO_LINK:
879 break;
880
881 default:
882 pdata->an_state = XGBE_AN_ERROR;
883 }
884
885 if (pdata->an_state == XGBE_AN_NO_LINK) {
Lendacky, Thomasced3fca2016-02-17 11:49:28 -0600886 pdata->an_int = 0;
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500887 xgbe_an73_clear_interrupts(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500888 } else if (pdata->an_state == XGBE_AN_ERROR) {
889 netdev_err(pdata->netdev,
890 "error during auto-negotiation, state=%u\n",
891 cur_state);
892
Lendacky, Thomasced3fca2016-02-17 11:49:28 -0600893 pdata->an_int = 0;
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500894 xgbe_an73_clear_interrupts(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500895 }
896
897 if (pdata->an_state >= XGBE_AN_COMPLETE) {
898 pdata->an_result = pdata->an_state;
899 pdata->an_state = XGBE_AN_READY;
900 pdata->kr_state = XGBE_RX_BPA;
901 pdata->kx_state = XGBE_RX_BPA;
902 pdata->an_start = 0;
Lendacky, Thomasd5c78392015-05-22 16:32:21 -0500903
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500904 netif_dbg(pdata, link, pdata->netdev, "CL73 AN result: %s\n",
Lendacky, Thomasd5c78392015-05-22 16:32:21 -0500905 xgbe_state_as_string(pdata->an_result));
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500906 }
907
908 if (cur_state != pdata->an_state)
909 goto again;
910
Lendacky, Thomasced3fca2016-02-17 11:49:28 -0600911 if (pdata->an_int)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500912 goto next_int;
913
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500914 xgbe_an73_enable_interrupts(pdata);
915}
916
917static void xgbe_an_state_machine(struct work_struct *work)
918{
919 struct xgbe_prv_data *pdata = container_of(work,
920 struct xgbe_prv_data,
921 an_work);
922
923 mutex_lock(&pdata->an_mutex);
924
925 switch (pdata->an_mode) {
926 case XGBE_AN_MODE_CL73:
Lendacky, Thomasd7445d12016-11-10 17:11:41 -0600927 case XGBE_AN_MODE_CL73_REDRV:
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500928 xgbe_an73_state_machine(pdata);
929 break;
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500930 case XGBE_AN_MODE_CL37:
931 case XGBE_AN_MODE_CL37_SGMII:
932 xgbe_an37_state_machine(pdata);
933 break;
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500934 default:
935 break;
936 }
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500937
Lendacky, Thomas85b85c82017-06-28 13:42:42 -0500938 /* Reissue interrupt if status is not clear */
939 if (pdata->vdata->irq_reissue_support)
940 XP_IOWRITE(pdata, XP_INT_REISSUE_EN, 1 << 3);
941
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500942 mutex_unlock(&pdata->an_mutex);
943}
944
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500945static void xgbe_an37_init(struct xgbe_prv_data *pdata)
946{
Lendacky, Thomasd7445d12016-11-10 17:11:41 -0600947 unsigned int advertising, reg;
948
949 advertising = pdata->phy_if.phy_impl.an_advertising(pdata);
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500950
951 /* Set up Advertisement register */
952 reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_VEND2_AN_ADVERTISE);
Lendacky, Thomasd7445d12016-11-10 17:11:41 -0600953 if (advertising & ADVERTISED_Pause)
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500954 reg |= 0x100;
955 else
956 reg &= ~0x100;
957
Lendacky, Thomasd7445d12016-11-10 17:11:41 -0600958 if (advertising & ADVERTISED_Asym_Pause)
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500959 reg |= 0x80;
960 else
961 reg &= ~0x80;
962
963 /* Full duplex, but not half */
964 reg |= XGBE_AN_CL37_FD_MASK;
965 reg &= ~XGBE_AN_CL37_HD_MASK;
966
967 XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_VEND2_AN_ADVERTISE, reg);
968
969 /* Set up the Control register */
970 reg = XMDIO_READ(pdata, MDIO_MMD_VEND2, MDIO_VEND2_AN_CTRL);
Lendacky, Thomase6fbd472016-11-14 16:39:07 -0600971 reg &= ~XGBE_AN_CL37_TX_CONFIG_MASK;
972 reg &= ~XGBE_AN_CL37_PCS_MODE_MASK;
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500973
974 switch (pdata->an_mode) {
975 case XGBE_AN_MODE_CL37:
976 reg |= XGBE_AN_CL37_PCS_MODE_BASEX;
977 break;
978 case XGBE_AN_MODE_CL37_SGMII:
979 reg |= XGBE_AN_CL37_PCS_MODE_SGMII;
980 break;
981 default:
982 break;
983 }
984
Lendacky, Thomasf087b502017-08-18 09:02:27 -0500985 reg |= XGBE_AN_CL37_MII_CTRL_8BIT;
986
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -0500987 XMDIO_WRITE(pdata, MDIO_MMD_VEND2, MDIO_VEND2_AN_CTRL, reg);
988
989 netif_dbg(pdata, link, pdata->netdev, "CL37 AN (%s) initialized\n",
990 (pdata->an_mode == XGBE_AN_MODE_CL37) ? "BaseX" : "SGMII");
991}
992
Lendacky, Thomasa64def42016-11-03 13:18:38 -0500993static void xgbe_an73_init(struct xgbe_prv_data *pdata)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500994{
Lendacky, Thomasd7445d12016-11-10 17:11:41 -0600995 unsigned int advertising, reg;
996
997 advertising = pdata->phy_if.phy_impl.an_advertising(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -0500998
999 /* Set up Advertisement register 3 first */
1000 reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 2);
Lendacky, Thomasd7445d12016-11-10 17:11:41 -06001001 if (advertising & ADVERTISED_10000baseR_FEC)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001002 reg |= 0xc000;
1003 else
1004 reg &= ~0xc000;
1005
1006 XMDIO_WRITE(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 2, reg);
1007
1008 /* Set up Advertisement register 2 next */
1009 reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 1);
Lendacky, Thomasd7445d12016-11-10 17:11:41 -06001010 if (advertising & ADVERTISED_10000baseKR_Full)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001011 reg |= 0x80;
1012 else
1013 reg &= ~0x80;
1014
Lendacky, Thomasd7445d12016-11-10 17:11:41 -06001015 if ((advertising & ADVERTISED_1000baseKX_Full) ||
1016 (advertising & ADVERTISED_2500baseX_Full))
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001017 reg |= 0x20;
1018 else
1019 reg &= ~0x20;
1020
1021 XMDIO_WRITE(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 1, reg);
1022
1023 /* Set up Advertisement register 1 last */
1024 reg = XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE);
Lendacky, Thomasd7445d12016-11-10 17:11:41 -06001025 if (advertising & ADVERTISED_Pause)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001026 reg |= 0x400;
1027 else
1028 reg &= ~0x400;
1029
Lendacky, Thomasd7445d12016-11-10 17:11:41 -06001030 if (advertising & ADVERTISED_Asym_Pause)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001031 reg |= 0x800;
1032 else
1033 reg &= ~0x800;
1034
1035 /* We don't intend to perform XNP */
1036 reg &= ~XGBE_XNP_NP_EXCHANGE;
1037
1038 XMDIO_WRITE(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE, reg);
Lendacky, Thomasd5c78392015-05-22 16:32:21 -05001039
Lendacky, Thomasa64def42016-11-03 13:18:38 -05001040 netif_dbg(pdata, link, pdata->netdev, "CL73 AN initialized\n");
1041}
1042
1043static void xgbe_an_init(struct xgbe_prv_data *pdata)
1044{
1045 /* Set up advertisement registers based on current settings */
1046 pdata->an_mode = pdata->phy_if.phy_impl.an_mode(pdata);
1047 switch (pdata->an_mode) {
1048 case XGBE_AN_MODE_CL73:
Lendacky, Thomasd7445d12016-11-10 17:11:41 -06001049 case XGBE_AN_MODE_CL73_REDRV:
Lendacky, Thomasa64def42016-11-03 13:18:38 -05001050 xgbe_an73_init(pdata);
1051 break;
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -05001052 case XGBE_AN_MODE_CL37:
1053 case XGBE_AN_MODE_CL37_SGMII:
1054 xgbe_an37_init(pdata);
1055 break;
Lendacky, Thomasa64def42016-11-03 13:18:38 -05001056 default:
1057 break;
1058 }
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001059}
1060
Lendacky, Thomasc1ce2f72015-05-14 11:44:27 -05001061static const char *xgbe_phy_fc_string(struct xgbe_prv_data *pdata)
1062{
1063 if (pdata->tx_pause && pdata->rx_pause)
1064 return "rx/tx";
1065 else if (pdata->rx_pause)
1066 return "rx";
1067 else if (pdata->tx_pause)
1068 return "tx";
1069 else
1070 return "off";
1071}
1072
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001073static const char *xgbe_phy_speed_string(int speed)
1074{
1075 switch (speed) {
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -06001076 case SPEED_100:
1077 return "100Mbps";
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001078 case SPEED_1000:
1079 return "1Gbps";
1080 case SPEED_2500:
1081 return "2.5Gbps";
1082 case SPEED_10000:
1083 return "10Gbps";
1084 case SPEED_UNKNOWN:
1085 return "Unknown";
1086 default:
1087 return "Unsupported";
1088 }
1089}
1090
1091static void xgbe_phy_print_status(struct xgbe_prv_data *pdata)
1092{
1093 if (pdata->phy.link)
1094 netdev_info(pdata->netdev,
1095 "Link is Up - %s/%s - flow control %s\n",
1096 xgbe_phy_speed_string(pdata->phy.speed),
1097 pdata->phy.duplex == DUPLEX_FULL ? "Full" : "Half",
Lendacky, Thomasc1ce2f72015-05-14 11:44:27 -05001098 xgbe_phy_fc_string(pdata));
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001099 else
1100 netdev_info(pdata->netdev, "Link is Down\n");
1101}
1102
1103static void xgbe_phy_adjust_link(struct xgbe_prv_data *pdata)
1104{
1105 int new_state = 0;
1106
1107 if (pdata->phy.link) {
1108 /* Flow control support */
Lendacky, Thomasc1ce2f72015-05-14 11:44:27 -05001109 pdata->pause_autoneg = pdata->phy.pause_autoneg;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001110
Lendacky, Thomasc1ce2f72015-05-14 11:44:27 -05001111 if (pdata->tx_pause != pdata->phy.tx_pause) {
1112 new_state = 1;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001113 pdata->hw_if.config_tx_flow_control(pdata);
Lendacky, Thomasc1ce2f72015-05-14 11:44:27 -05001114 pdata->tx_pause = pdata->phy.tx_pause;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001115 }
1116
Lendacky, Thomasc1ce2f72015-05-14 11:44:27 -05001117 if (pdata->rx_pause != pdata->phy.rx_pause) {
1118 new_state = 1;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001119 pdata->hw_if.config_rx_flow_control(pdata);
Lendacky, Thomasc1ce2f72015-05-14 11:44:27 -05001120 pdata->rx_pause = pdata->phy.rx_pause;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001121 }
1122
1123 /* Speed support */
1124 if (pdata->phy_speed != pdata->phy.speed) {
1125 new_state = 1;
1126 pdata->phy_speed = pdata->phy.speed;
1127 }
1128
1129 if (pdata->phy_link != pdata->phy.link) {
1130 new_state = 1;
1131 pdata->phy_link = pdata->phy.link;
1132 }
1133 } else if (pdata->phy_link) {
1134 new_state = 1;
1135 pdata->phy_link = 0;
1136 pdata->phy_speed = SPEED_UNKNOWN;
1137 }
1138
1139 if (new_state && netif_msg_link(pdata))
1140 xgbe_phy_print_status(pdata);
1141}
1142
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001143static bool xgbe_phy_valid_speed(struct xgbe_prv_data *pdata, int speed)
1144{
1145 return pdata->phy_if.phy_impl.valid_speed(pdata, speed);
1146}
1147
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001148static int xgbe_phy_config_fixed(struct xgbe_prv_data *pdata)
1149{
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001150 enum xgbe_mode mode;
1151
Lendacky, Thomasd5c78392015-05-22 16:32:21 -05001152 netif_dbg(pdata, link, pdata->netdev, "fixed PHY configuration\n");
1153
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001154 /* Disable auto-negotiation */
Lendacky, Thomasa64def42016-11-03 13:18:38 -05001155 xgbe_an_disable(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001156
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001157 /* Set specified mode for specified speed */
1158 mode = pdata->phy_if.phy_impl.get_mode(pdata, pdata->phy.speed);
1159 switch (mode) {
1160 case XGBE_MODE_KX_1000:
1161 case XGBE_MODE_KX_2500:
1162 case XGBE_MODE_KR:
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -06001163 case XGBE_MODE_SGMII_100:
1164 case XGBE_MODE_SGMII_1000:
1165 case XGBE_MODE_X:
1166 case XGBE_MODE_SFI:
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001167 break;
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001168 case XGBE_MODE_UNKNOWN:
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001169 default:
1170 return -EINVAL;
1171 }
1172
1173 /* Validate duplex mode */
1174 if (pdata->phy.duplex != DUPLEX_FULL)
1175 return -EINVAL;
1176
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001177 xgbe_set_mode(pdata, mode);
1178
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001179 return 0;
1180}
1181
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001182static int __xgbe_phy_config_aneg(struct xgbe_prv_data *pdata)
1183{
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -06001184 int ret;
1185
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001186 set_bit(XGBE_LINK_INIT, &pdata->dev_state);
1187 pdata->link_check = jiffies;
1188
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -06001189 ret = pdata->phy_if.phy_impl.an_config(pdata);
1190 if (ret)
1191 return ret;
1192
Lendacky, Thomasd7445d12016-11-10 17:11:41 -06001193 if (pdata->phy.autoneg != AUTONEG_ENABLE) {
1194 ret = xgbe_phy_config_fixed(pdata);
1195 if (ret || !pdata->kr_redrv)
1196 return ret;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001197
Lendacky, Thomasd7445d12016-11-10 17:11:41 -06001198 netif_dbg(pdata, link, pdata->netdev, "AN redriver support\n");
1199 } else {
1200 netif_dbg(pdata, link, pdata->netdev, "AN PHY configuration\n");
1201 }
Lendacky, Thomasd5c78392015-05-22 16:32:21 -05001202
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001203 /* Disable auto-negotiation interrupt */
1204 disable_irq(pdata->an_irq);
1205
1206 /* Start auto-negotiation in a supported mode */
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001207 if (xgbe_use_mode(pdata, XGBE_MODE_KR)) {
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001208 xgbe_set_mode(pdata, XGBE_MODE_KR);
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001209 } else if (xgbe_use_mode(pdata, XGBE_MODE_KX_2500)) {
1210 xgbe_set_mode(pdata, XGBE_MODE_KX_2500);
1211 } else if (xgbe_use_mode(pdata, XGBE_MODE_KX_1000)) {
1212 xgbe_set_mode(pdata, XGBE_MODE_KX_1000);
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -06001213 } else if (xgbe_use_mode(pdata, XGBE_MODE_SFI)) {
1214 xgbe_set_mode(pdata, XGBE_MODE_SFI);
1215 } else if (xgbe_use_mode(pdata, XGBE_MODE_X)) {
1216 xgbe_set_mode(pdata, XGBE_MODE_X);
1217 } else if (xgbe_use_mode(pdata, XGBE_MODE_SGMII_1000)) {
1218 xgbe_set_mode(pdata, XGBE_MODE_SGMII_1000);
1219 } else if (xgbe_use_mode(pdata, XGBE_MODE_SGMII_100)) {
1220 xgbe_set_mode(pdata, XGBE_MODE_SGMII_100);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001221 } else {
1222 enable_irq(pdata->an_irq);
1223 return -EINVAL;
1224 }
1225
1226 /* Disable and stop any in progress auto-negotiation */
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -05001227 xgbe_an_disable_all(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001228
1229 /* Clear any auto-negotitation interrupts */
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -05001230 xgbe_an_clear_interrupts_all(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001231
1232 pdata->an_result = XGBE_AN_READY;
1233 pdata->an_state = XGBE_AN_READY;
1234 pdata->kr_state = XGBE_RX_BPA;
1235 pdata->kx_state = XGBE_RX_BPA;
1236
1237 /* Re-enable auto-negotiation interrupt */
1238 enable_irq(pdata->an_irq);
1239
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001240 xgbe_an_init(pdata);
Lendacky, Thomasa64def42016-11-03 13:18:38 -05001241 xgbe_an_restart(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001242
1243 return 0;
1244}
1245
1246static int xgbe_phy_config_aneg(struct xgbe_prv_data *pdata)
1247{
1248 int ret;
1249
1250 mutex_lock(&pdata->an_mutex);
1251
1252 ret = __xgbe_phy_config_aneg(pdata);
1253 if (ret)
1254 set_bit(XGBE_LINK_ERR, &pdata->dev_state);
1255 else
1256 clear_bit(XGBE_LINK_ERR, &pdata->dev_state);
1257
1258 mutex_unlock(&pdata->an_mutex);
1259
1260 return ret;
1261}
1262
1263static bool xgbe_phy_aneg_done(struct xgbe_prv_data *pdata)
1264{
1265 return (pdata->an_result == XGBE_AN_COMPLETE);
1266}
1267
1268static void xgbe_check_link_timeout(struct xgbe_prv_data *pdata)
1269{
1270 unsigned long link_timeout;
1271
1272 link_timeout = pdata->link_check + (XGBE_LINK_TIMEOUT * HZ);
Lendacky, Thomasd5c78392015-05-22 16:32:21 -05001273 if (time_after(jiffies, link_timeout)) {
1274 netif_dbg(pdata, link, pdata->netdev, "AN link timeout\n");
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001275 xgbe_phy_config_aneg(pdata);
Lendacky, Thomasd5c78392015-05-22 16:32:21 -05001276 }
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001277}
1278
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001279static enum xgbe_mode xgbe_phy_status_aneg(struct xgbe_prv_data *pdata)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001280{
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001281 return pdata->phy_if.phy_impl.an_outcome(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001282}
1283
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001284static void xgbe_phy_status_result(struct xgbe_prv_data *pdata)
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001285{
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001286 enum xgbe_mode mode;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001287
1288 pdata->phy.lp_advertising = 0;
1289
1290 if ((pdata->phy.autoneg != AUTONEG_ENABLE) || pdata->parallel_detect)
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001291 mode = xgbe_cur_mode(pdata);
1292 else
1293 mode = xgbe_phy_status_aneg(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001294
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001295 switch (mode) {
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -06001296 case XGBE_MODE_SGMII_100:
1297 pdata->phy.speed = SPEED_100;
1298 break;
1299 case XGBE_MODE_X:
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001300 case XGBE_MODE_KX_1000:
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -06001301 case XGBE_MODE_SGMII_1000:
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001302 pdata->phy.speed = SPEED_1000;
1303 break;
1304 case XGBE_MODE_KX_2500:
1305 pdata->phy.speed = SPEED_2500;
1306 break;
1307 case XGBE_MODE_KR:
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -06001308 case XGBE_MODE_SFI:
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001309 pdata->phy.speed = SPEED_10000;
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001310 break;
1311 case XGBE_MODE_UNKNOWN:
1312 default:
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001313 pdata->phy.speed = SPEED_UNKNOWN;
1314 }
1315
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001316 pdata->phy.duplex = DUPLEX_FULL;
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001317
1318 xgbe_set_mode(pdata, mode);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001319}
1320
1321static void xgbe_phy_status(struct xgbe_prv_data *pdata)
1322{
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001323 unsigned int link_aneg;
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -06001324 int an_restart;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001325
1326 if (test_bit(XGBE_LINK_ERR, &pdata->dev_state)) {
Lendacky, Thomas50789845c2015-09-30 08:53:22 -05001327 netif_carrier_off(pdata->netdev);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001328
1329 pdata->phy.link = 0;
1330 goto adjust_link;
1331 }
1332
1333 link_aneg = (pdata->phy.autoneg == AUTONEG_ENABLE);
1334
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -06001335 pdata->phy.link = pdata->phy_if.phy_impl.link_status(pdata,
1336 &an_restart);
1337 if (an_restart) {
1338 xgbe_phy_config_aneg(pdata);
1339 return;
1340 }
1341
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001342 if (pdata->phy.link) {
1343 if (link_aneg && !xgbe_phy_aneg_done(pdata)) {
1344 xgbe_check_link_timeout(pdata);
1345 return;
1346 }
1347
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001348 xgbe_phy_status_result(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001349
1350 if (test_bit(XGBE_LINK_INIT, &pdata->dev_state))
1351 clear_bit(XGBE_LINK_INIT, &pdata->dev_state);
1352
Lendacky, Thomas50789845c2015-09-30 08:53:22 -05001353 netif_carrier_on(pdata->netdev);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001354 } else {
1355 if (test_bit(XGBE_LINK_INIT, &pdata->dev_state)) {
1356 xgbe_check_link_timeout(pdata);
1357
1358 if (link_aneg)
1359 return;
1360 }
1361
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001362 xgbe_phy_status_result(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001363
Lendacky, Thomas50789845c2015-09-30 08:53:22 -05001364 netif_carrier_off(pdata->netdev);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001365 }
1366
1367adjust_link:
1368 xgbe_phy_adjust_link(pdata);
1369}
1370
1371static void xgbe_phy_stop(struct xgbe_prv_data *pdata)
1372{
Lendacky, Thomasd5c78392015-05-22 16:32:21 -05001373 netif_dbg(pdata, link, pdata->netdev, "stopping PHY\n");
1374
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001375 if (!pdata->phy_started)
1376 return;
1377
1378 /* Indicate the PHY is down */
1379 pdata->phy_started = 0;
1380
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001381 /* Disable auto-negotiation */
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -05001382 xgbe_an_disable_all(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001383
Lendacky, Thomas47f164d2016-11-10 17:09:55 -06001384 if (pdata->dev_irq != pdata->an_irq)
1385 devm_free_irq(pdata->dev, pdata->an_irq, pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001386
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001387 pdata->phy_if.phy_impl.stop(pdata);
1388
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001389 pdata->phy.link = 0;
Lendacky, Thomas50789845c2015-09-30 08:53:22 -05001390 netif_carrier_off(pdata->netdev);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001391
1392 xgbe_phy_adjust_link(pdata);
1393}
1394
1395static int xgbe_phy_start(struct xgbe_prv_data *pdata)
1396{
1397 struct net_device *netdev = pdata->netdev;
1398 int ret;
1399
Lendacky, Thomasd5c78392015-05-22 16:32:21 -05001400 netif_dbg(pdata, link, pdata->netdev, "starting PHY\n");
1401
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001402 ret = pdata->phy_if.phy_impl.start(pdata);
1403 if (ret)
1404 return ret;
1405
Lendacky, Thomas47f164d2016-11-10 17:09:55 -06001406 /* If we have a separate AN irq, enable it */
1407 if (pdata->dev_irq != pdata->an_irq) {
Lendacky, Thomas85b85c82017-06-28 13:42:42 -05001408 tasklet_init(&pdata->tasklet_an, xgbe_an_isr_task,
1409 (unsigned long)pdata);
1410
Lendacky, Thomas47f164d2016-11-10 17:09:55 -06001411 ret = devm_request_irq(pdata->dev, pdata->an_irq,
1412 xgbe_an_isr, 0, pdata->an_name,
1413 pdata);
1414 if (ret) {
1415 netdev_err(netdev, "phy irq request failed\n");
1416 goto err_stop;
1417 }
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001418 }
1419
1420 /* Set initial mode - call the mode setting routines
1421 * directly to insure we are properly configured
1422 */
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001423 if (xgbe_use_mode(pdata, XGBE_MODE_KR)) {
1424 xgbe_kr_mode(pdata);
1425 } else if (xgbe_use_mode(pdata, XGBE_MODE_KX_2500)) {
1426 xgbe_kx_2500_mode(pdata);
1427 } else if (xgbe_use_mode(pdata, XGBE_MODE_KX_1000)) {
1428 xgbe_kx_1000_mode(pdata);
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -06001429 } else if (xgbe_use_mode(pdata, XGBE_MODE_SFI)) {
1430 xgbe_sfi_mode(pdata);
1431 } else if (xgbe_use_mode(pdata, XGBE_MODE_X)) {
1432 xgbe_x_mode(pdata);
1433 } else if (xgbe_use_mode(pdata, XGBE_MODE_SGMII_1000)) {
1434 xgbe_sgmii_1000_mode(pdata);
1435 } else if (xgbe_use_mode(pdata, XGBE_MODE_SGMII_100)) {
1436 xgbe_sgmii_100_mode(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001437 } else {
1438 ret = -EINVAL;
1439 goto err_irq;
1440 }
1441
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001442 /* Indicate the PHY is up and running */
1443 pdata->phy_started = 1;
1444
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001445 xgbe_an_init(pdata);
Lendacky, Thomasa64def42016-11-03 13:18:38 -05001446 xgbe_an_enable_interrupts(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001447
1448 return xgbe_phy_config_aneg(pdata);
1449
1450err_irq:
Lendacky, Thomas47f164d2016-11-10 17:09:55 -06001451 if (pdata->dev_irq != pdata->an_irq)
1452 devm_free_irq(pdata->dev, pdata->an_irq, pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001453
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001454err_stop:
1455 pdata->phy_if.phy_impl.stop(pdata);
1456
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001457 return ret;
1458}
1459
1460static int xgbe_phy_reset(struct xgbe_prv_data *pdata)
1461{
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001462 int ret;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001463
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001464 ret = pdata->phy_if.phy_impl.reset(pdata);
1465 if (ret)
1466 return ret;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001467
1468 /* Disable auto-negotiation for now */
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -05001469 xgbe_an_disable_all(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001470
1471 /* Clear auto-negotiation interrupts */
Lendacky, Thomas1bf40ad2016-11-03 13:18:47 -05001472 xgbe_an_clear_interrupts_all(pdata);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001473
1474 return 0;
1475}
1476
1477static void xgbe_dump_phy_registers(struct xgbe_prv_data *pdata)
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001478{
1479 struct device *dev = pdata->dev;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001480
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001481 dev_dbg(dev, "\n************* PHY Reg dump **********************\n");
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001482
Lendacky, Thomasd9682c92016-11-03 13:17:38 -05001483 dev_dbg(dev, "PCS Control Reg (%#06x) = %#06x\n", MDIO_CTRL1,
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001484 XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_CTRL1));
Lendacky, Thomasd9682c92016-11-03 13:17:38 -05001485 dev_dbg(dev, "PCS Status Reg (%#06x) = %#06x\n", MDIO_STAT1,
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001486 XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_STAT1));
Lendacky, Thomasd9682c92016-11-03 13:17:38 -05001487 dev_dbg(dev, "Phy Id (PHYS ID 1 %#06x)= %#06x\n", MDIO_DEVID1,
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001488 XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_DEVID1));
Lendacky, Thomasd9682c92016-11-03 13:17:38 -05001489 dev_dbg(dev, "Phy Id (PHYS ID 2 %#06x)= %#06x\n", MDIO_DEVID2,
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001490 XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_DEVID2));
Lendacky, Thomasd9682c92016-11-03 13:17:38 -05001491 dev_dbg(dev, "Devices in Package (%#06x)= %#06x\n", MDIO_DEVS1,
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001492 XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_DEVS1));
Lendacky, Thomasd9682c92016-11-03 13:17:38 -05001493 dev_dbg(dev, "Devices in Package (%#06x)= %#06x\n", MDIO_DEVS2,
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001494 XMDIO_READ(pdata, MDIO_MMD_PCS, MDIO_DEVS2));
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001495
Lendacky, Thomasd9682c92016-11-03 13:17:38 -05001496 dev_dbg(dev, "Auto-Neg Control Reg (%#06x) = %#06x\n", MDIO_CTRL1,
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001497 XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_CTRL1));
Lendacky, Thomasd9682c92016-11-03 13:17:38 -05001498 dev_dbg(dev, "Auto-Neg Status Reg (%#06x) = %#06x\n", MDIO_STAT1,
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001499 XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_STAT1));
Lendacky, Thomasd9682c92016-11-03 13:17:38 -05001500 dev_dbg(dev, "Auto-Neg Ad Reg 1 (%#06x) = %#06x\n",
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001501 MDIO_AN_ADVERTISE,
1502 XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE));
Lendacky, Thomasd9682c92016-11-03 13:17:38 -05001503 dev_dbg(dev, "Auto-Neg Ad Reg 2 (%#06x) = %#06x\n",
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001504 MDIO_AN_ADVERTISE + 1,
1505 XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 1));
Lendacky, Thomasd9682c92016-11-03 13:17:38 -05001506 dev_dbg(dev, "Auto-Neg Ad Reg 3 (%#06x) = %#06x\n",
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001507 MDIO_AN_ADVERTISE + 2,
1508 XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_ADVERTISE + 2));
Lendacky, Thomasd9682c92016-11-03 13:17:38 -05001509 dev_dbg(dev, "Auto-Neg Completion Reg (%#06x) = %#06x\n",
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001510 MDIO_AN_COMP_STAT,
1511 XMDIO_READ(pdata, MDIO_MMD_AN, MDIO_AN_COMP_STAT));
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001512
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001513 dev_dbg(dev, "\n*************************************************\n");
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001514}
1515
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001516static int xgbe_phy_best_advertised_speed(struct xgbe_prv_data *pdata)
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001517{
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001518 if (pdata->phy.advertising & ADVERTISED_10000baseKR_Full)
1519 return SPEED_10000;
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -06001520 else if (pdata->phy.advertising & ADVERTISED_10000baseT_Full)
1521 return SPEED_10000;
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001522 else if (pdata->phy.advertising & ADVERTISED_2500baseX_Full)
1523 return SPEED_2500;
1524 else if (pdata->phy.advertising & ADVERTISED_1000baseKX_Full)
1525 return SPEED_1000;
Lendacky, Thomasabf0a1c2016-11-10 17:10:58 -06001526 else if (pdata->phy.advertising & ADVERTISED_1000baseT_Full)
1527 return SPEED_1000;
1528 else if (pdata->phy.advertising & ADVERTISED_100baseT_Full)
1529 return SPEED_100;
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001530
1531 return SPEED_UNKNOWN;
1532}
1533
1534static void xgbe_phy_exit(struct xgbe_prv_data *pdata)
1535{
1536 xgbe_phy_stop(pdata);
1537
1538 pdata->phy_if.phy_impl.exit(pdata);
1539}
1540
1541static int xgbe_phy_init(struct xgbe_prv_data *pdata)
1542{
1543 int ret;
1544
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001545 mutex_init(&pdata->an_mutex);
1546 INIT_WORK(&pdata->an_irq_work, xgbe_an_irq_work);
1547 INIT_WORK(&pdata->an_work, xgbe_an_state_machine);
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001548 pdata->mdio_mmd = MDIO_MMD_PCS;
1549
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001550 /* Check for FEC support */
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001551 pdata->fec_ability = XMDIO_READ(pdata, MDIO_MMD_PMAPMD,
1552 MDIO_PMA_10GBR_FECABLE);
1553 pdata->fec_ability &= (MDIO_PMA_10GBR_FECABLE_ABLE |
1554 MDIO_PMA_10GBR_FECABLE_ERRABLE);
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001555
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001556 /* Setup the phy (including supported features) */
1557 ret = pdata->phy_if.phy_impl.init(pdata);
1558 if (ret)
1559 return ret;
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001560 pdata->phy.advertising = pdata->phy.supported;
1561
1562 pdata->phy.address = 0;
1563
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001564 if (pdata->phy.advertising & ADVERTISED_Autoneg) {
1565 pdata->phy.autoneg = AUTONEG_ENABLE;
1566 pdata->phy.speed = SPEED_UNKNOWN;
1567 pdata->phy.duplex = DUPLEX_UNKNOWN;
1568 } else {
1569 pdata->phy.autoneg = AUTONEG_DISABLE;
1570 pdata->phy.speed = xgbe_phy_best_advertised_speed(pdata);
1571 pdata->phy.duplex = DUPLEX_FULL;
1572 }
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001573
1574 pdata->phy.link = 0;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001575
Lendacky, Thomasc1ce2f72015-05-14 11:44:27 -05001576 pdata->phy.pause_autoneg = pdata->pause_autoneg;
1577 pdata->phy.tx_pause = pdata->tx_pause;
1578 pdata->phy.rx_pause = pdata->rx_pause;
1579
1580 /* Fix up Flow Control advertising */
1581 pdata->phy.advertising &= ~ADVERTISED_Pause;
1582 pdata->phy.advertising &= ~ADVERTISED_Asym_Pause;
1583
1584 if (pdata->rx_pause) {
1585 pdata->phy.advertising |= ADVERTISED_Pause;
1586 pdata->phy.advertising |= ADVERTISED_Asym_Pause;
1587 }
1588
1589 if (pdata->tx_pause)
1590 pdata->phy.advertising ^= ADVERTISED_Asym_Pause;
1591
Lendacky, Thomas34bf65d2015-05-14 11:44:03 -05001592 if (netif_msg_drv(pdata))
1593 xgbe_dump_phy_registers(pdata);
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001594
1595 return 0;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001596}
1597
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001598void xgbe_init_function_ptrs_phy(struct xgbe_phy_if *phy_if)
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001599{
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001600 phy_if->phy_init = xgbe_phy_init;
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001601 phy_if->phy_exit = xgbe_phy_exit;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001602
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001603 phy_if->phy_reset = xgbe_phy_reset;
1604 phy_if->phy_start = xgbe_phy_start;
1605 phy_if->phy_stop = xgbe_phy_stop;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001606
Lendacky, Thomas7c12aa02015-05-14 11:44:15 -05001607 phy_if->phy_status = xgbe_phy_status;
1608 phy_if->phy_config_aneg = xgbe_phy_config_aneg;
Lendacky, Thomase57f7a32016-11-03 13:18:27 -05001609
1610 phy_if->phy_valid_speed = xgbe_phy_valid_speed;
Lendacky, Thomas47f164d2016-11-10 17:09:55 -06001611
1612 phy_if->an_isr = xgbe_an_combined_isr;
Lendacky, Thomasc5aa9e32014-06-05 09:15:06 -05001613}