blob: ec2c1eee64051919a7623abf160eacf4233b57de [file] [log] [blame]
Andy Fleming00db8182005-07-30 19:31:23 -04001/*
2 * drivers/net/phy/marvell.c
3 *
4 * Driver for Marvell PHYs
5 *
6 * Author: Andy Fleming
7 *
8 * Copyright (c) 2004 Freescale Semiconductor, Inc.
9 *
Michael Stapelberg3871c382013-03-11 13:56:45 +000010 * Copyright (c) 2013 Michael Stapelberg <michael@stapelberg.de>
11 *
Andy Fleming00db8182005-07-30 19:31:23 -040012 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
16 *
17 */
Andy Fleming00db8182005-07-30 19:31:23 -040018#include <linux/kernel.h>
Andy Fleming00db8182005-07-30 19:31:23 -040019#include <linux/string.h>
20#include <linux/errno.h>
21#include <linux/unistd.h>
Andy Fleming00db8182005-07-30 19:31:23 -040022#include <linux/interrupt.h>
23#include <linux/init.h>
24#include <linux/delay.h>
25#include <linux/netdevice.h>
26#include <linux/etherdevice.h>
27#include <linux/skbuff.h>
28#include <linux/spinlock.h>
29#include <linux/mm.h>
30#include <linux/module.h>
Andy Fleming00db8182005-07-30 19:31:23 -040031#include <linux/mii.h>
32#include <linux/ethtool.h>
33#include <linux/phy.h>
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +100034#include <linux/marvell_phy.h>
David Daneycf41a512010-11-19 12:13:18 +000035#include <linux/of.h>
Andy Fleming00db8182005-07-30 19:31:23 -040036
Avinash Kumareea3b202013-09-30 09:36:44 +053037#include <linux/io.h>
Andy Fleming00db8182005-07-30 19:31:23 -040038#include <asm/irq.h>
Avinash Kumareea3b202013-09-30 09:36:44 +053039#include <linux/uaccess.h>
Andy Fleming00db8182005-07-30 19:31:23 -040040
David Daney27d916d2010-11-19 11:58:52 +000041#define MII_MARVELL_PHY_PAGE 22
42
Andy Fleming00db8182005-07-30 19:31:23 -040043#define MII_M1011_IEVENT 0x13
44#define MII_M1011_IEVENT_CLEAR 0x0000
45
46#define MII_M1011_IMASK 0x12
47#define MII_M1011_IMASK_INIT 0x6400
48#define MII_M1011_IMASK_CLEAR 0x0000
49
Andy Fleming76884672007-02-09 18:13:58 -060050#define MII_M1011_PHY_SCR 0x10
David Thomson239aa552015-07-10 16:28:25 +120051#define MII_M1011_PHY_SCR_MDI 0x0000
52#define MII_M1011_PHY_SCR_MDI_X 0x0020
Andy Fleming76884672007-02-09 18:13:58 -060053#define MII_M1011_PHY_SCR_AUTO_CROSS 0x0060
54
Madalin Bucur07151bc2015-08-07 17:07:50 +080055#define MII_M1145_PHY_EXT_ADDR_PAGE 0x16
Viet Nga Daob0224172014-10-23 19:41:53 -070056#define MII_M1145_PHY_EXT_SR 0x1b
Andy Fleming76884672007-02-09 18:13:58 -060057#define MII_M1145_PHY_EXT_CR 0x14
58#define MII_M1145_RGMII_RX_DELAY 0x0080
59#define MII_M1145_RGMII_TX_DELAY 0x0002
Viet Nga Daob0224172014-10-23 19:41:53 -070060#define MII_M1145_HWCFG_MODE_SGMII_NO_CLK 0x4
61#define MII_M1145_HWCFG_MODE_MASK 0xf
62#define MII_M1145_HWCFG_FIBER_COPPER_AUTO 0x8000
Andy Fleming76884672007-02-09 18:13:58 -060063
Vince Bridgers99d881f2014-10-26 14:22:24 -050064#define MII_M1145_HWCFG_MODE_SGMII_NO_CLK 0x4
65#define MII_M1145_HWCFG_MODE_MASK 0xf
66#define MII_M1145_HWCFG_FIBER_COPPER_AUTO 0x8000
67
Andy Fleming76884672007-02-09 18:13:58 -060068#define MII_M1111_PHY_LED_CONTROL 0x18
69#define MII_M1111_PHY_LED_DIRECT 0x4100
70#define MII_M1111_PHY_LED_COMBINE 0x411c
Kim Phillips895ee682007-06-05 18:46:47 +080071#define MII_M1111_PHY_EXT_CR 0x14
72#define MII_M1111_RX_DELAY 0x80
73#define MII_M1111_TX_DELAY 0x2
74#define MII_M1111_PHY_EXT_SR 0x1b
Alexandr Smirnovbe937f12008-03-19 00:37:24 +030075
76#define MII_M1111_HWCFG_MODE_MASK 0xf
77#define MII_M1111_HWCFG_MODE_COPPER_RGMII 0xb
78#define MII_M1111_HWCFG_MODE_FIBER_RGMII 0x3
Kapil Juneja4117b5b2007-05-11 18:25:18 -050079#define MII_M1111_HWCFG_MODE_SGMII_NO_CLK 0x4
Liu Yu-B132015f8cbc12010-01-13 22:13:19 +000080#define MII_M1111_HWCFG_MODE_COPPER_RTBI 0x9
Alexandr Smirnovbe937f12008-03-19 00:37:24 +030081#define MII_M1111_HWCFG_FIBER_COPPER_AUTO 0x8000
82#define MII_M1111_HWCFG_FIBER_COPPER_RES 0x2000
83
84#define MII_M1111_COPPER 0
85#define MII_M1111_FIBER 1
86
Cyril Chemparathyc477d042010-08-02 09:44:53 +000087#define MII_88E1121_PHY_MSCR_PAGE 2
88#define MII_88E1121_PHY_MSCR_REG 21
89#define MII_88E1121_PHY_MSCR_RX_DELAY BIT(5)
90#define MII_88E1121_PHY_MSCR_TX_DELAY BIT(4)
91#define MII_88E1121_PHY_MSCR_DELAY_MASK (~(0x3 << 4))
92
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -070093#define MII_88E1318S_PHY_MSCR1_REG 16
94#define MII_88E1318S_PHY_MSCR1_PAD_ODD BIT(6)
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -070095
Michael Stapelberg3871c382013-03-11 13:56:45 +000096/* Copper Specific Interrupt Enable Register */
97#define MII_88E1318S_PHY_CSIER 0x12
98/* WOL Event Interrupt Enable */
99#define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7)
100
101/* LED Timer Control Register */
102#define MII_88E1318S_PHY_LED_PAGE 0x03
103#define MII_88E1318S_PHY_LED_TCR 0x12
104#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15)
105#define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7)
106#define MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW BIT(11)
107
108/* Magic Packet MAC address registers */
109#define MII_88E1318S_PHY_MAGIC_PACKET_WORD2 0x17
110#define MII_88E1318S_PHY_MAGIC_PACKET_WORD1 0x18
111#define MII_88E1318S_PHY_MAGIC_PACKET_WORD0 0x19
112
113#define MII_88E1318S_PHY_WOL_PAGE 0x11
114#define MII_88E1318S_PHY_WOL_CTRL 0x10
115#define MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS BIT(12)
116#define MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE BIT(14)
117
Sergei Poselenov140bc922009-04-07 02:01:41 +0000118#define MII_88E1121_PHY_LED_CTRL 16
119#define MII_88E1121_PHY_LED_PAGE 3
120#define MII_88E1121_PHY_LED_DEF 0x0030
Sergei Poselenov140bc922009-04-07 02:01:41 +0000121
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300122#define MII_M1011_PHY_STATUS 0x11
123#define MII_M1011_PHY_STATUS_1000 0x8000
124#define MII_M1011_PHY_STATUS_100 0x4000
125#define MII_M1011_PHY_STATUS_SPD_MASK 0xc000
126#define MII_M1011_PHY_STATUS_FULLDUPLEX 0x2000
127#define MII_M1011_PHY_STATUS_RESOLVED 0x0800
128#define MII_M1011_PHY_STATUS_LINK 0x0400
129
Michal Simek3da09a52013-05-30 20:08:26 +0000130#define MII_M1116R_CONTROL_REG_MAC 21
131
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +0200132#define MII_88E3016_PHY_SPEC_CTRL 0x10
133#define MII_88E3016_DISABLE_SCRAMBLER 0x0200
134#define MII_88E3016_AUTO_MDIX_CROSSOVER 0x0030
Andy Fleming76884672007-02-09 18:13:58 -0600135
Stefan Roese930b37e2016-02-18 10:59:07 +0100136#define MII_88E1510_GEN_CTRL_REG_1 0x14
137#define MII_88E1510_GEN_CTRL_REG_1_MODE_MASK 0x7
138#define MII_88E1510_GEN_CTRL_REG_1_MODE_SGMII 0x1 /* SGMII to copper */
139#define MII_88E1510_GEN_CTRL_REG_1_RESET 0x8000 /* Soft reset */
140
Andy Fleming00db8182005-07-30 19:31:23 -0400141MODULE_DESCRIPTION("Marvell PHY driver");
142MODULE_AUTHOR("Andy Fleming");
143MODULE_LICENSE("GPL");
144
Andrew Lunnd2fa47d2015-12-30 16:28:26 +0100145struct marvell_hw_stat {
146 const char *string;
147 u8 page;
148 u8 reg;
149 u8 bits;
150};
151
152static struct marvell_hw_stat marvell_hw_stats[] = {
153 { "phy_receive_errors", 0, 21, 16},
154 { "phy_idle_errors", 0, 10, 8 },
155};
156
157struct marvell_priv {
158 u64 stats[ARRAY_SIZE(marvell_hw_stats)];
159};
160
Andy Fleming00db8182005-07-30 19:31:23 -0400161static int marvell_ack_interrupt(struct phy_device *phydev)
162{
163 int err;
164
165 /* Clear the interrupts by reading the reg */
166 err = phy_read(phydev, MII_M1011_IEVENT);
167
168 if (err < 0)
169 return err;
170
171 return 0;
172}
173
174static int marvell_config_intr(struct phy_device *phydev)
175{
176 int err;
177
Andy Fleming76884672007-02-09 18:13:58 -0600178 if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
Andy Fleming00db8182005-07-30 19:31:23 -0400179 err = phy_write(phydev, MII_M1011_IMASK, MII_M1011_IMASK_INIT);
180 else
181 err = phy_write(phydev, MII_M1011_IMASK, MII_M1011_IMASK_CLEAR);
182
183 return err;
184}
185
David Thomson239aa552015-07-10 16:28:25 +1200186static int marvell_set_polarity(struct phy_device *phydev, int polarity)
187{
188 int reg;
189 int err;
190 int val;
191
192 /* get the current settings */
193 reg = phy_read(phydev, MII_M1011_PHY_SCR);
194 if (reg < 0)
195 return reg;
196
197 val = reg;
198 val &= ~MII_M1011_PHY_SCR_AUTO_CROSS;
199 switch (polarity) {
200 case ETH_TP_MDI:
201 val |= MII_M1011_PHY_SCR_MDI;
202 break;
203 case ETH_TP_MDI_X:
204 val |= MII_M1011_PHY_SCR_MDI_X;
205 break;
206 case ETH_TP_MDI_AUTO:
207 case ETH_TP_MDI_INVALID:
208 default:
209 val |= MII_M1011_PHY_SCR_AUTO_CROSS;
210 break;
211 }
212
213 if (val != reg) {
214 /* Set the new polarity value in the register */
215 err = phy_write(phydev, MII_M1011_PHY_SCR, val);
216 if (err)
217 return err;
218 }
219
220 return 0;
221}
222
Andy Fleming00db8182005-07-30 19:31:23 -0400223static int marvell_config_aneg(struct phy_device *phydev)
224{
225 int err;
226
227 /* The Marvell PHY has an errata which requires
228 * that certain registers get written in order
229 * to restart autonegotiation */
230 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
231
232 if (err < 0)
233 return err;
234
235 err = phy_write(phydev, 0x1d, 0x1f);
236 if (err < 0)
237 return err;
238
239 err = phy_write(phydev, 0x1e, 0x200c);
240 if (err < 0)
241 return err;
242
243 err = phy_write(phydev, 0x1d, 0x5);
244 if (err < 0)
245 return err;
246
247 err = phy_write(phydev, 0x1e, 0);
248 if (err < 0)
249 return err;
250
251 err = phy_write(phydev, 0x1e, 0x100);
252 if (err < 0)
253 return err;
254
David Thomson239aa552015-07-10 16:28:25 +1200255 err = marvell_set_polarity(phydev, phydev->mdix);
Andy Fleming76884672007-02-09 18:13:58 -0600256 if (err < 0)
257 return err;
258
259 err = phy_write(phydev, MII_M1111_PHY_LED_CONTROL,
260 MII_M1111_PHY_LED_DIRECT);
261 if (err < 0)
262 return err;
Andy Fleming00db8182005-07-30 19:31:23 -0400263
264 err = genphy_config_aneg(phydev);
Anton Vorontsov8ff44982009-09-09 16:01:30 +0000265 if (err < 0)
266 return err;
Andy Fleming00db8182005-07-30 19:31:23 -0400267
Anton Vorontsov8ff44982009-09-09 16:01:30 +0000268 if (phydev->autoneg != AUTONEG_ENABLE) {
269 int bmcr;
270
271 /*
272 * A write to speed/duplex bits (that is performed by
273 * genphy_config_aneg() call above) must be followed by
274 * a software reset. Otherwise, the write has no effect.
275 */
276 bmcr = phy_read(phydev, MII_BMCR);
277 if (bmcr < 0)
278 return bmcr;
279
280 err = phy_write(phydev, MII_BMCR, bmcr | BMCR_RESET);
281 if (err < 0)
282 return err;
283 }
284
285 return 0;
Andy Fleming00db8182005-07-30 19:31:23 -0400286}
287
Harini Katakam3ec0a0f2016-06-27 13:09:59 +0530288static int m88e1111_config_aneg(struct phy_device *phydev)
289{
290 int err;
291
292 /* The Marvell PHY has an errata which requires
293 * that certain registers get written in order
294 * to restart autonegotiation
295 */
296 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
297
298 err = marvell_set_polarity(phydev, phydev->mdix);
299 if (err < 0)
300 return err;
301
302 err = phy_write(phydev, MII_M1111_PHY_LED_CONTROL,
303 MII_M1111_PHY_LED_DIRECT);
304 if (err < 0)
305 return err;
306
307 err = genphy_config_aneg(phydev);
308 if (err < 0)
309 return err;
310
311 if (phydev->autoneg != AUTONEG_ENABLE) {
312 int bmcr;
313
314 /* A write to speed/duplex bits (that is performed by
315 * genphy_config_aneg() call above) must be followed by
316 * a software reset. Otherwise, the write has no effect.
317 */
318 bmcr = phy_read(phydev, MII_BMCR);
319 if (bmcr < 0)
320 return bmcr;
321
322 err = phy_write(phydev, MII_BMCR, bmcr | BMCR_RESET);
323 if (err < 0)
324 return err;
325 }
326
327 return 0;
328}
329
David Daneycf41a512010-11-19 12:13:18 +0000330#ifdef CONFIG_OF_MDIO
331/*
332 * Set and/or override some configuration registers based on the
333 * marvell,reg-init property stored in the of_node for the phydev.
334 *
335 * marvell,reg-init = <reg-page reg mask value>,...;
336 *
337 * There may be one or more sets of <reg-page reg mask value>:
338 *
339 * reg-page: which register bank to use.
340 * reg: the register.
341 * mask: if non-zero, ANDed with existing register value.
342 * value: ORed with the masked value and written to the regiser.
343 *
344 */
345static int marvell_of_reg_init(struct phy_device *phydev)
346{
347 const __be32 *paddr;
348 int len, i, saved_page, current_page, page_changed, ret;
349
Andrew Lunne5a03bf2016-01-06 20:11:16 +0100350 if (!phydev->mdio.dev.of_node)
David Daneycf41a512010-11-19 12:13:18 +0000351 return 0;
352
Andrew Lunne5a03bf2016-01-06 20:11:16 +0100353 paddr = of_get_property(phydev->mdio.dev.of_node,
354 "marvell,reg-init", &len);
David Daneycf41a512010-11-19 12:13:18 +0000355 if (!paddr || len < (4 * sizeof(*paddr)))
356 return 0;
357
358 saved_page = phy_read(phydev, MII_MARVELL_PHY_PAGE);
359 if (saved_page < 0)
360 return saved_page;
361 page_changed = 0;
362 current_page = saved_page;
363
364 ret = 0;
365 len /= sizeof(*paddr);
366 for (i = 0; i < len - 3; i += 4) {
367 u16 reg_page = be32_to_cpup(paddr + i);
368 u16 reg = be32_to_cpup(paddr + i + 1);
369 u16 mask = be32_to_cpup(paddr + i + 2);
370 u16 val_bits = be32_to_cpup(paddr + i + 3);
371 int val;
372
373 if (reg_page != current_page) {
374 current_page = reg_page;
375 page_changed = 1;
376 ret = phy_write(phydev, MII_MARVELL_PHY_PAGE, reg_page);
377 if (ret < 0)
378 goto err;
379 }
380
381 val = 0;
382 if (mask) {
383 val = phy_read(phydev, reg);
384 if (val < 0) {
385 ret = val;
386 goto err;
387 }
388 val &= mask;
389 }
390 val |= val_bits;
391
392 ret = phy_write(phydev, reg, val);
393 if (ret < 0)
394 goto err;
395
396 }
397err:
398 if (page_changed) {
399 i = phy_write(phydev, MII_MARVELL_PHY_PAGE, saved_page);
400 if (ret == 0)
401 ret = i;
402 }
403 return ret;
404}
405#else
406static int marvell_of_reg_init(struct phy_device *phydev)
407{
408 return 0;
409}
410#endif /* CONFIG_OF_MDIO */
411
Sergei Poselenov140bc922009-04-07 02:01:41 +0000412static int m88e1121_config_aneg(struct phy_device *phydev)
413{
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000414 int err, oldpage, mscr;
415
David Daney27d916d2010-11-19 11:58:52 +0000416 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000417
David Daney27d916d2010-11-19 11:58:52 +0000418 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000419 MII_88E1121_PHY_MSCR_PAGE);
420 if (err < 0)
421 return err;
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000422
Florian Fainelli32a64162015-05-26 12:19:59 -0700423 if (phy_interface_is_rgmii(phydev)) {
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000424
Arnaud Patardbe8c6482010-10-21 03:59:57 -0700425 mscr = phy_read(phydev, MII_88E1121_PHY_MSCR_REG) &
426 MII_88E1121_PHY_MSCR_DELAY_MASK;
427
428 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
429 mscr |= (MII_88E1121_PHY_MSCR_RX_DELAY |
430 MII_88E1121_PHY_MSCR_TX_DELAY);
431 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID)
432 mscr |= MII_88E1121_PHY_MSCR_RX_DELAY;
433 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
434 mscr |= MII_88E1121_PHY_MSCR_TX_DELAY;
435
436 err = phy_write(phydev, MII_88E1121_PHY_MSCR_REG, mscr);
437 if (err < 0)
438 return err;
439 }
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000440
David Daney27d916d2010-11-19 11:58:52 +0000441 phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
Sergei Poselenov140bc922009-04-07 02:01:41 +0000442
443 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
444 if (err < 0)
445 return err;
446
447 err = phy_write(phydev, MII_M1011_PHY_SCR,
448 MII_M1011_PHY_SCR_AUTO_CROSS);
449 if (err < 0)
450 return err;
451
Clemens Gruberfdecf362016-06-11 17:21:26 +0200452 return genphy_config_aneg(phydev);
Sergei Poselenov140bc922009-04-07 02:01:41 +0000453}
454
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -0700455static int m88e1318_config_aneg(struct phy_device *phydev)
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700456{
457 int err, oldpage, mscr;
458
David Daney27d916d2010-11-19 11:58:52 +0000459 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700460
David Daney27d916d2010-11-19 11:58:52 +0000461 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700462 MII_88E1121_PHY_MSCR_PAGE);
463 if (err < 0)
464 return err;
465
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -0700466 mscr = phy_read(phydev, MII_88E1318S_PHY_MSCR1_REG);
467 mscr |= MII_88E1318S_PHY_MSCR1_PAD_ODD;
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700468
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -0700469 err = phy_write(phydev, MII_88E1318S_PHY_MSCR1_REG, mscr);
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700470 if (err < 0)
471 return err;
472
David Daney27d916d2010-11-19 11:58:52 +0000473 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700474 if (err < 0)
475 return err;
476
477 return m88e1121_config_aneg(phydev);
478}
479
Michal Simek10e24caa2013-05-30 20:08:27 +0000480static int m88e1510_config_aneg(struct phy_device *phydev)
481{
482 int err;
483
484 err = m88e1318_config_aneg(phydev);
485 if (err < 0)
486 return err;
487
Clemens Gruber79be1a12016-02-15 23:46:45 +0100488 return 0;
489}
490
491static int marvell_config_init(struct phy_device *phydev)
492{
493 /* Set registers from marvell,reg-init DT property */
Michal Simek10e24caa2013-05-30 20:08:27 +0000494 return marvell_of_reg_init(phydev);
495}
496
Michal Simek3da09a52013-05-30 20:08:26 +0000497static int m88e1116r_config_init(struct phy_device *phydev)
498{
499 int temp;
500 int err;
501
502 temp = phy_read(phydev, MII_BMCR);
503 temp |= BMCR_RESET;
504 err = phy_write(phydev, MII_BMCR, temp);
505 if (err < 0)
506 return err;
507
508 mdelay(500);
509
510 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0);
511 if (err < 0)
512 return err;
513
514 temp = phy_read(phydev, MII_M1011_PHY_SCR);
515 temp |= (7 << 12); /* max number of gigabit attempts */
516 temp |= (1 << 11); /* enable downshift */
517 temp |= MII_M1011_PHY_SCR_AUTO_CROSS;
518 err = phy_write(phydev, MII_M1011_PHY_SCR, temp);
519 if (err < 0)
520 return err;
521
522 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 2);
523 if (err < 0)
524 return err;
525 temp = phy_read(phydev, MII_M1116R_CONTROL_REG_MAC);
526 temp |= (1 << 5);
527 temp |= (1 << 4);
528 err = phy_write(phydev, MII_M1116R_CONTROL_REG_MAC, temp);
529 if (err < 0)
530 return err;
531 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0);
532 if (err < 0)
533 return err;
534
535 temp = phy_read(phydev, MII_BMCR);
536 temp |= BMCR_RESET;
537 err = phy_write(phydev, MII_BMCR, temp);
538 if (err < 0)
539 return err;
540
541 mdelay(500);
542
Clemens Gruber79be1a12016-02-15 23:46:45 +0100543 return marvell_config_init(phydev);
Michal Simek3da09a52013-05-30 20:08:26 +0000544}
545
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +0200546static int m88e3016_config_init(struct phy_device *phydev)
547{
548 int reg;
549
550 /* Enable Scrambler and Auto-Crossover */
551 reg = phy_read(phydev, MII_88E3016_PHY_SPEC_CTRL);
552 if (reg < 0)
553 return reg;
554
555 reg &= ~MII_88E3016_DISABLE_SCRAMBLER;
556 reg |= MII_88E3016_AUTO_MDIX_CROSSOVER;
557
558 reg = phy_write(phydev, MII_88E3016_PHY_SPEC_CTRL, reg);
559 if (reg < 0)
560 return reg;
561
Clemens Gruber79be1a12016-02-15 23:46:45 +0100562 return marvell_config_init(phydev);
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +0200563}
564
Kim Phillips895ee682007-06-05 18:46:47 +0800565static int m88e1111_config_init(struct phy_device *phydev)
566{
567 int err;
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300568 int temp;
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300569
Florian Fainelli32a64162015-05-26 12:19:59 -0700570 if (phy_interface_is_rgmii(phydev)) {
Kim Phillips895ee682007-06-05 18:46:47 +0800571
Kim Phillips9daf5a72007-11-26 16:17:52 -0600572 temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
573 if (temp < 0)
574 return temp;
575
Kim Phillips895ee682007-06-05 18:46:47 +0800576 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
Kim Phillips895ee682007-06-05 18:46:47 +0800577 temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
Kim Phillips9daf5a72007-11-26 16:17:52 -0600578 } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) {
579 temp &= ~MII_M1111_TX_DELAY;
580 temp |= MII_M1111_RX_DELAY;
581 } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
582 temp &= ~MII_M1111_RX_DELAY;
583 temp |= MII_M1111_TX_DELAY;
Kim Phillips895ee682007-06-05 18:46:47 +0800584 }
585
Kim Phillips9daf5a72007-11-26 16:17:52 -0600586 err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
587 if (err < 0)
588 return err;
589
Kim Phillips895ee682007-06-05 18:46:47 +0800590 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
591 if (temp < 0)
592 return temp;
593
594 temp &= ~(MII_M1111_HWCFG_MODE_MASK);
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300595
Wang Jian7239016d2008-07-16 21:46:20 +0800596 if (temp & MII_M1111_HWCFG_FIBER_COPPER_RES)
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300597 temp |= MII_M1111_HWCFG_MODE_FIBER_RGMII;
598 else
599 temp |= MII_M1111_HWCFG_MODE_COPPER_RGMII;
Kim Phillips895ee682007-06-05 18:46:47 +0800600
601 err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
602 if (err < 0)
603 return err;
604 }
605
Kapil Juneja4117b5b2007-05-11 18:25:18 -0500606 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
Kapil Juneja4117b5b2007-05-11 18:25:18 -0500607 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
608 if (temp < 0)
609 return temp;
610
611 temp &= ~(MII_M1111_HWCFG_MODE_MASK);
612 temp |= MII_M1111_HWCFG_MODE_SGMII_NO_CLK;
Haiying Wang32d0c1e2009-06-02 04:04:13 +0000613 temp |= MII_M1111_HWCFG_FIBER_COPPER_AUTO;
Kapil Juneja4117b5b2007-05-11 18:25:18 -0500614
615 err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
616 if (err < 0)
617 return err;
Madalin Bucur07151bc2015-08-07 17:07:50 +0800618
619 /* make sure copper is selected */
620 err = phy_read(phydev, MII_M1145_PHY_EXT_ADDR_PAGE);
621 if (err < 0)
622 return err;
623
624 err = phy_write(phydev, MII_M1145_PHY_EXT_ADDR_PAGE,
625 err & (~0xff));
626 if (err < 0)
627 return err;
Kapil Juneja4117b5b2007-05-11 18:25:18 -0500628 }
629
Liu Yu-B132015f8cbc12010-01-13 22:13:19 +0000630 if (phydev->interface == PHY_INTERFACE_MODE_RTBI) {
631 temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
632 if (temp < 0)
633 return temp;
634 temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
635 err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
636 if (err < 0)
637 return err;
638
639 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
640 if (temp < 0)
641 return temp;
642 temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
643 temp |= 0x7 | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
644 err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
645 if (err < 0)
646 return err;
647
648 /* soft reset */
649 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
650 if (err < 0)
651 return err;
652 do
653 temp = phy_read(phydev, MII_BMCR);
654 while (temp & BMCR_RESET);
655
656 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
657 if (temp < 0)
658 return temp;
659 temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
660 temp |= MII_M1111_HWCFG_MODE_COPPER_RTBI | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
661 err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
662 if (err < 0)
663 return err;
664 }
665
David Daneycf41a512010-11-19 12:13:18 +0000666 err = marvell_of_reg_init(phydev);
667 if (err < 0)
668 return err;
Liu Yu-B132015f8cbc12010-01-13 22:13:19 +0000669
Srinivas Kandagatlacc90cb32012-04-02 06:25:24 +0000670 return phy_write(phydev, MII_BMCR, BMCR_RESET);
Kim Phillips895ee682007-06-05 18:46:47 +0800671}
672
Clemens Gruberfdecf362016-06-11 17:21:26 +0200673static int m88e1121_config_init(struct phy_device *phydev)
674{
675 int err, oldpage;
676
677 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
678
679 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, MII_88E1121_PHY_LED_PAGE);
680 if (err < 0)
681 return err;
682
683 /* Default PHY LED config: LED[0] .. Link, LED[1] .. Activity */
684 err = phy_write(phydev, MII_88E1121_PHY_LED_CTRL,
685 MII_88E1121_PHY_LED_DEF);
686 if (err < 0)
687 return err;
688
689 phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
690
691 /* Set marvell,reg-init configuration from device tree */
692 return marvell_config_init(phydev);
693}
694
Clemens Gruber407353e2016-02-23 20:16:58 +0100695static int m88e1510_config_init(struct phy_device *phydev)
696{
697 int err;
698 int temp;
699
700 /* SGMII-to-Copper mode initialization */
701 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
702 /* Select page 18 */
703 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 18);
704 if (err < 0)
705 return err;
706
707 /* In reg 20, write MODE[2:0] = 0x1 (SGMII to Copper) */
708 temp = phy_read(phydev, MII_88E1510_GEN_CTRL_REG_1);
709 temp &= ~MII_88E1510_GEN_CTRL_REG_1_MODE_MASK;
710 temp |= MII_88E1510_GEN_CTRL_REG_1_MODE_SGMII;
711 err = phy_write(phydev, MII_88E1510_GEN_CTRL_REG_1, temp);
712 if (err < 0)
713 return err;
714
715 /* PHY reset is necessary after changing MODE[2:0] */
716 temp |= MII_88E1510_GEN_CTRL_REG_1_RESET;
717 err = phy_write(phydev, MII_88E1510_GEN_CTRL_REG_1, temp);
718 if (err < 0)
719 return err;
720
721 /* Reset page selection */
722 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0);
723 if (err < 0)
724 return err;
725 }
726
Clemens Gruberfdecf362016-06-11 17:21:26 +0200727 return m88e1121_config_init(phydev);
Clemens Gruber407353e2016-02-23 20:16:58 +0100728}
729
Ron Madrid605f1962008-11-06 09:05:26 +0000730static int m88e1118_config_aneg(struct phy_device *phydev)
731{
732 int err;
733
734 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
735 if (err < 0)
736 return err;
737
738 err = phy_write(phydev, MII_M1011_PHY_SCR,
739 MII_M1011_PHY_SCR_AUTO_CROSS);
740 if (err < 0)
741 return err;
742
743 err = genphy_config_aneg(phydev);
744 return 0;
745}
746
747static int m88e1118_config_init(struct phy_device *phydev)
748{
749 int err;
750
751 /* Change address */
David Daney27d916d2010-11-19 11:58:52 +0000752 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0002);
Ron Madrid605f1962008-11-06 09:05:26 +0000753 if (err < 0)
754 return err;
755
756 /* Enable 1000 Mbit */
757 err = phy_write(phydev, 0x15, 0x1070);
758 if (err < 0)
759 return err;
760
761 /* Change address */
David Daney27d916d2010-11-19 11:58:52 +0000762 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0003);
Ron Madrid605f1962008-11-06 09:05:26 +0000763 if (err < 0)
764 return err;
765
766 /* Adjust LED Control */
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +1000767 if (phydev->dev_flags & MARVELL_PHY_M1118_DNS323_LEDS)
768 err = phy_write(phydev, 0x10, 0x1100);
769 else
770 err = phy_write(phydev, 0x10, 0x021e);
Ron Madrid605f1962008-11-06 09:05:26 +0000771 if (err < 0)
772 return err;
773
David Daneycf41a512010-11-19 12:13:18 +0000774 err = marvell_of_reg_init(phydev);
775 if (err < 0)
776 return err;
777
Ron Madrid605f1962008-11-06 09:05:26 +0000778 /* Reset address */
David Daney27d916d2010-11-19 11:58:52 +0000779 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0);
Ron Madrid605f1962008-11-06 09:05:26 +0000780 if (err < 0)
781 return err;
782
Srinivas Kandagatlacc90cb32012-04-02 06:25:24 +0000783 return phy_write(phydev, MII_BMCR, BMCR_RESET);
Ron Madrid605f1962008-11-06 09:05:26 +0000784}
785
David Daney90600732010-11-19 11:58:53 +0000786static int m88e1149_config_init(struct phy_device *phydev)
787{
788 int err;
789
790 /* Change address */
791 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0002);
792 if (err < 0)
793 return err;
794
795 /* Enable 1000 Mbit */
796 err = phy_write(phydev, 0x15, 0x1048);
797 if (err < 0)
798 return err;
799
David Daneycf41a512010-11-19 12:13:18 +0000800 err = marvell_of_reg_init(phydev);
801 if (err < 0)
802 return err;
803
David Daney90600732010-11-19 11:58:53 +0000804 /* Reset address */
805 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0);
806 if (err < 0)
807 return err;
808
Srinivas Kandagatlacc90cb32012-04-02 06:25:24 +0000809 return phy_write(phydev, MII_BMCR, BMCR_RESET);
David Daney90600732010-11-19 11:58:53 +0000810}
811
Andy Fleming76884672007-02-09 18:13:58 -0600812static int m88e1145_config_init(struct phy_device *phydev)
813{
814 int err;
Viet Nga Daob0224172014-10-23 19:41:53 -0700815 int temp;
Andy Fleming76884672007-02-09 18:13:58 -0600816
817 /* Take care of errata E0 & E1 */
818 err = phy_write(phydev, 0x1d, 0x001b);
819 if (err < 0)
820 return err;
821
822 err = phy_write(phydev, 0x1e, 0x418f);
823 if (err < 0)
824 return err;
825
826 err = phy_write(phydev, 0x1d, 0x0016);
827 if (err < 0)
828 return err;
829
830 err = phy_write(phydev, 0x1e, 0xa2da);
831 if (err < 0)
832 return err;
833
Kim Phillips895ee682007-06-05 18:46:47 +0800834 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
Andy Fleming76884672007-02-09 18:13:58 -0600835 int temp = phy_read(phydev, MII_M1145_PHY_EXT_CR);
836 if (temp < 0)
837 return temp;
838
839 temp |= (MII_M1145_RGMII_RX_DELAY | MII_M1145_RGMII_TX_DELAY);
840
841 err = phy_write(phydev, MII_M1145_PHY_EXT_CR, temp);
842 if (err < 0)
843 return err;
844
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +1000845 if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) {
Andy Fleming76884672007-02-09 18:13:58 -0600846 err = phy_write(phydev, 0x1d, 0x0012);
847 if (err < 0)
848 return err;
849
850 temp = phy_read(phydev, 0x1e);
851 if (temp < 0)
852 return temp;
853
854 temp &= 0xf03f;
855 temp |= 2 << 9; /* 36 ohm */
856 temp |= 2 << 6; /* 39 ohm */
857
858 err = phy_write(phydev, 0x1e, temp);
859 if (err < 0)
860 return err;
861
862 err = phy_write(phydev, 0x1d, 0x3);
863 if (err < 0)
864 return err;
865
866 err = phy_write(phydev, 0x1e, 0x8000);
867 if (err < 0)
868 return err;
869 }
870 }
871
Viet Nga Daob0224172014-10-23 19:41:53 -0700872 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
873 temp = phy_read(phydev, MII_M1145_PHY_EXT_SR);
874 if (temp < 0)
875 return temp;
876
Vince Bridgers99d881f2014-10-26 14:22:24 -0500877 temp &= ~MII_M1145_HWCFG_MODE_MASK;
Viet Nga Daob0224172014-10-23 19:41:53 -0700878 temp |= MII_M1145_HWCFG_MODE_SGMII_NO_CLK;
879 temp |= MII_M1145_HWCFG_FIBER_COPPER_AUTO;
880
881 err = phy_write(phydev, MII_M1145_PHY_EXT_SR, temp);
882 if (err < 0)
883 return err;
884 }
885
David Daneycf41a512010-11-19 12:13:18 +0000886 err = marvell_of_reg_init(phydev);
887 if (err < 0)
888 return err;
889
Andy Fleming76884672007-02-09 18:13:58 -0600890 return 0;
891}
Andy Fleming00db8182005-07-30 19:31:23 -0400892
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300893/* marvell_read_status
894 *
895 * Generic status code does not detect Fiber correctly!
Jeff Garzikf0c88f92008-03-25 23:53:24 -0400896 * Description:
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300897 * Check the link, then figure out the current state
898 * by comparing what we advertise with what the link partner
899 * advertises. Start by checking the gigabit possibilities,
900 * then move on to 10/100.
901 */
902static int marvell_read_status(struct phy_device *phydev)
903{
904 int adv;
905 int err;
906 int lpa;
Russell King357cd642015-09-24 00:07:17 +0100907 int lpagb;
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300908 int status = 0;
909
910 /* Update the link, but return if there
911 * was an error */
912 err = genphy_update_link(phydev);
913 if (err)
914 return err;
915
916 if (AUTONEG_ENABLE == phydev->autoneg) {
917 status = phy_read(phydev, MII_M1011_PHY_STATUS);
918 if (status < 0)
919 return status;
920
921 lpa = phy_read(phydev, MII_LPA);
922 if (lpa < 0)
923 return lpa;
924
Russell King357cd642015-09-24 00:07:17 +0100925 lpagb = phy_read(phydev, MII_STAT1000);
926 if (lpagb < 0)
927 return lpagb;
928
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300929 adv = phy_read(phydev, MII_ADVERTISE);
930 if (adv < 0)
931 return adv;
932
Russell King357cd642015-09-24 00:07:17 +0100933 phydev->lp_advertising = mii_stat1000_to_ethtool_lpa_t(lpagb) |
934 mii_lpa_to_ethtool_lpa_t(lpa);
935
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300936 lpa &= adv;
937
938 if (status & MII_M1011_PHY_STATUS_FULLDUPLEX)
939 phydev->duplex = DUPLEX_FULL;
940 else
941 phydev->duplex = DUPLEX_HALF;
942
943 status = status & MII_M1011_PHY_STATUS_SPD_MASK;
944 phydev->pause = phydev->asym_pause = 0;
945
946 switch (status) {
947 case MII_M1011_PHY_STATUS_1000:
948 phydev->speed = SPEED_1000;
949 break;
950
951 case MII_M1011_PHY_STATUS_100:
952 phydev->speed = SPEED_100;
953 break;
954
955 default:
956 phydev->speed = SPEED_10;
957 break;
958 }
959
960 if (phydev->duplex == DUPLEX_FULL) {
961 phydev->pause = lpa & LPA_PAUSE_CAP ? 1 : 0;
962 phydev->asym_pause = lpa & LPA_PAUSE_ASYM ? 1 : 0;
963 }
964 } else {
965 int bmcr = phy_read(phydev, MII_BMCR);
966
967 if (bmcr < 0)
968 return bmcr;
969
970 if (bmcr & BMCR_FULLDPLX)
971 phydev->duplex = DUPLEX_FULL;
972 else
973 phydev->duplex = DUPLEX_HALF;
974
975 if (bmcr & BMCR_SPEED1000)
976 phydev->speed = SPEED_1000;
977 else if (bmcr & BMCR_SPEED100)
978 phydev->speed = SPEED_100;
979 else
980 phydev->speed = SPEED_10;
981
982 phydev->pause = phydev->asym_pause = 0;
Russell King357cd642015-09-24 00:07:17 +0100983 phydev->lp_advertising = 0;
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300984 }
985
986 return 0;
987}
988
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +0200989static int marvell_aneg_done(struct phy_device *phydev)
990{
991 int retval = phy_read(phydev, MII_M1011_PHY_STATUS);
992 return (retval < 0) ? retval : (retval & MII_M1011_PHY_STATUS_RESOLVED);
993}
994
Anatolij Gustschindcd07be2009-04-07 02:01:43 +0000995static int m88e1121_did_interrupt(struct phy_device *phydev)
996{
997 int imask;
998
999 imask = phy_read(phydev, MII_M1011_IEVENT);
1000
1001 if (imask & MII_M1011_IMASK_INIT)
1002 return 1;
1003
1004 return 0;
1005}
1006
Michael Stapelberg3871c382013-03-11 13:56:45 +00001007static void m88e1318_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
1008{
1009 wol->supported = WAKE_MAGIC;
1010 wol->wolopts = 0;
1011
1012 if (phy_write(phydev, MII_MARVELL_PHY_PAGE,
1013 MII_88E1318S_PHY_WOL_PAGE) < 0)
1014 return;
1015
1016 if (phy_read(phydev, MII_88E1318S_PHY_WOL_CTRL) &
1017 MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE)
1018 wol->wolopts |= WAKE_MAGIC;
1019
1020 if (phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x00) < 0)
1021 return;
1022}
1023
1024static int m88e1318_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
1025{
1026 int err, oldpage, temp;
1027
1028 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
1029
1030 if (wol->wolopts & WAKE_MAGIC) {
1031 /* Explicitly switch to page 0x00, just to be sure */
1032 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x00);
1033 if (err < 0)
1034 return err;
1035
1036 /* Enable the WOL interrupt */
1037 temp = phy_read(phydev, MII_88E1318S_PHY_CSIER);
1038 temp |= MII_88E1318S_PHY_CSIER_WOL_EIE;
1039 err = phy_write(phydev, MII_88E1318S_PHY_CSIER, temp);
1040 if (err < 0)
1041 return err;
1042
1043 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
1044 MII_88E1318S_PHY_LED_PAGE);
1045 if (err < 0)
1046 return err;
1047
1048 /* Setup LED[2] as interrupt pin (active low) */
1049 temp = phy_read(phydev, MII_88E1318S_PHY_LED_TCR);
1050 temp &= ~MII_88E1318S_PHY_LED_TCR_FORCE_INT;
1051 temp |= MII_88E1318S_PHY_LED_TCR_INTn_ENABLE;
1052 temp |= MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW;
1053 err = phy_write(phydev, MII_88E1318S_PHY_LED_TCR, temp);
1054 if (err < 0)
1055 return err;
1056
1057 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
1058 MII_88E1318S_PHY_WOL_PAGE);
1059 if (err < 0)
1060 return err;
1061
1062 /* Store the device address for the magic packet */
1063 err = phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD2,
1064 ((phydev->attached_dev->dev_addr[5] << 8) |
1065 phydev->attached_dev->dev_addr[4]));
1066 if (err < 0)
1067 return err;
1068 err = phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD1,
1069 ((phydev->attached_dev->dev_addr[3] << 8) |
1070 phydev->attached_dev->dev_addr[2]));
1071 if (err < 0)
1072 return err;
1073 err = phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD0,
1074 ((phydev->attached_dev->dev_addr[1] << 8) |
1075 phydev->attached_dev->dev_addr[0]));
1076 if (err < 0)
1077 return err;
1078
1079 /* Clear WOL status and enable magic packet matching */
1080 temp = phy_read(phydev, MII_88E1318S_PHY_WOL_CTRL);
1081 temp |= MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS;
1082 temp |= MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE;
1083 err = phy_write(phydev, MII_88E1318S_PHY_WOL_CTRL, temp);
1084 if (err < 0)
1085 return err;
1086 } else {
1087 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
1088 MII_88E1318S_PHY_WOL_PAGE);
1089 if (err < 0)
1090 return err;
1091
1092 /* Clear WOL status and disable magic packet matching */
1093 temp = phy_read(phydev, MII_88E1318S_PHY_WOL_CTRL);
1094 temp |= MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS;
1095 temp &= ~MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE;
1096 err = phy_write(phydev, MII_88E1318S_PHY_WOL_CTRL, temp);
1097 if (err < 0)
1098 return err;
1099 }
1100
1101 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
1102 if (err < 0)
1103 return err;
1104
1105 return 0;
1106}
1107
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001108static int marvell_get_sset_count(struct phy_device *phydev)
1109{
1110 return ARRAY_SIZE(marvell_hw_stats);
1111}
1112
1113static void marvell_get_strings(struct phy_device *phydev, u8 *data)
1114{
1115 int i;
1116
1117 for (i = 0; i < ARRAY_SIZE(marvell_hw_stats); i++) {
1118 memcpy(data + i * ETH_GSTRING_LEN,
1119 marvell_hw_stats[i].string, ETH_GSTRING_LEN);
1120 }
1121}
1122
1123#ifndef UINT64_MAX
1124#define UINT64_MAX (u64)(~((u64)0))
1125#endif
1126static u64 marvell_get_stat(struct phy_device *phydev, int i)
1127{
1128 struct marvell_hw_stat stat = marvell_hw_stats[i];
1129 struct marvell_priv *priv = phydev->priv;
Andrew Lunn321b4d42016-02-20 00:35:29 +01001130 int err, oldpage, val;
1131 u64 ret;
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001132
1133 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
1134 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
1135 stat.page);
1136 if (err < 0)
1137 return UINT64_MAX;
1138
1139 val = phy_read(phydev, stat.reg);
1140 if (val < 0) {
Andrew Lunn321b4d42016-02-20 00:35:29 +01001141 ret = UINT64_MAX;
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001142 } else {
1143 val = val & ((1 << stat.bits) - 1);
1144 priv->stats[i] += val;
Andrew Lunn321b4d42016-02-20 00:35:29 +01001145 ret = priv->stats[i];
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001146 }
1147
1148 phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
1149
Andrew Lunn321b4d42016-02-20 00:35:29 +01001150 return ret;
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001151}
1152
1153static void marvell_get_stats(struct phy_device *phydev,
1154 struct ethtool_stats *stats, u64 *data)
1155{
1156 int i;
1157
1158 for (i = 0; i < ARRAY_SIZE(marvell_hw_stats); i++)
1159 data[i] = marvell_get_stat(phydev, i);
1160}
1161
1162static int marvell_probe(struct phy_device *phydev)
1163{
1164 struct marvell_priv *priv;
1165
Andrew Lunne5a03bf2016-01-06 20:11:16 +01001166 priv = devm_kzalloc(&phydev->mdio.dev, sizeof(*priv), GFP_KERNEL);
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001167 if (!priv)
1168 return -ENOMEM;
1169
1170 phydev->priv = priv;
1171
1172 return 0;
1173}
1174
Olof Johanssone5479232007-07-03 16:23:46 -05001175static struct phy_driver marvell_drivers[] = {
1176 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +10001177 .phy_id = MARVELL_PHY_ID_88E1101,
1178 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johanssone5479232007-07-03 16:23:46 -05001179 .name = "Marvell 88E1101",
1180 .features = PHY_GBIT_FEATURES,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001181 .probe = marvell_probe,
Olof Johanssone5479232007-07-03 16:23:46 -05001182 .flags = PHY_HAS_INTERRUPT,
Clemens Gruber79be1a12016-02-15 23:46:45 +01001183 .config_init = &marvell_config_init,
Olof Johanssone5479232007-07-03 16:23:46 -05001184 .config_aneg = &marvell_config_aneg,
1185 .read_status = &genphy_read_status,
1186 .ack_interrupt = &marvell_ack_interrupt,
1187 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001188 .resume = &genphy_resume,
1189 .suspend = &genphy_suspend,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001190 .get_sset_count = marvell_get_sset_count,
1191 .get_strings = marvell_get_strings,
1192 .get_stats = marvell_get_stats,
Olof Johanssone5479232007-07-03 16:23:46 -05001193 },
1194 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +10001195 .phy_id = MARVELL_PHY_ID_88E1112,
1196 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johansson85cfb532007-07-03 16:24:32 -05001197 .name = "Marvell 88E1112",
1198 .features = PHY_GBIT_FEATURES,
1199 .flags = PHY_HAS_INTERRUPT,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001200 .probe = marvell_probe,
Olof Johansson85cfb532007-07-03 16:24:32 -05001201 .config_init = &m88e1111_config_init,
1202 .config_aneg = &marvell_config_aneg,
1203 .read_status = &genphy_read_status,
1204 .ack_interrupt = &marvell_ack_interrupt,
1205 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001206 .resume = &genphy_resume,
1207 .suspend = &genphy_suspend,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001208 .get_sset_count = marvell_get_sset_count,
1209 .get_strings = marvell_get_strings,
1210 .get_stats = marvell_get_stats,
Olof Johansson85cfb532007-07-03 16:24:32 -05001211 },
1212 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +10001213 .phy_id = MARVELL_PHY_ID_88E1111,
1214 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johanssone5479232007-07-03 16:23:46 -05001215 .name = "Marvell 88E1111",
1216 .features = PHY_GBIT_FEATURES,
1217 .flags = PHY_HAS_INTERRUPT,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001218 .probe = marvell_probe,
Olof Johanssone5479232007-07-03 16:23:46 -05001219 .config_init = &m88e1111_config_init,
Harini Katakam3ec0a0f2016-06-27 13:09:59 +05301220 .config_aneg = &m88e1111_config_aneg,
Alexandr Smirnovbe937f12008-03-19 00:37:24 +03001221 .read_status = &marvell_read_status,
Olof Johanssone5479232007-07-03 16:23:46 -05001222 .ack_interrupt = &marvell_ack_interrupt,
1223 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001224 .resume = &genphy_resume,
1225 .suspend = &genphy_suspend,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001226 .get_sset_count = marvell_get_sset_count,
1227 .get_strings = marvell_get_strings,
1228 .get_stats = marvell_get_stats,
Olof Johanssone5479232007-07-03 16:23:46 -05001229 },
1230 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +10001231 .phy_id = MARVELL_PHY_ID_88E1118,
1232 .phy_id_mask = MARVELL_PHY_ID_MASK,
Ron Madrid605f1962008-11-06 09:05:26 +00001233 .name = "Marvell 88E1118",
1234 .features = PHY_GBIT_FEATURES,
1235 .flags = PHY_HAS_INTERRUPT,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001236 .probe = marvell_probe,
Ron Madrid605f1962008-11-06 09:05:26 +00001237 .config_init = &m88e1118_config_init,
1238 .config_aneg = &m88e1118_config_aneg,
1239 .read_status = &genphy_read_status,
1240 .ack_interrupt = &marvell_ack_interrupt,
1241 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001242 .resume = &genphy_resume,
1243 .suspend = &genphy_suspend,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001244 .get_sset_count = marvell_get_sset_count,
1245 .get_strings = marvell_get_strings,
1246 .get_stats = marvell_get_stats,
Ron Madrid605f1962008-11-06 09:05:26 +00001247 },
1248 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +10001249 .phy_id = MARVELL_PHY_ID_88E1121R,
1250 .phy_id_mask = MARVELL_PHY_ID_MASK,
Sergei Poselenov140bc922009-04-07 02:01:41 +00001251 .name = "Marvell 88E1121R",
1252 .features = PHY_GBIT_FEATURES,
1253 .flags = PHY_HAS_INTERRUPT,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001254 .probe = marvell_probe,
Clemens Gruberfdecf362016-06-11 17:21:26 +02001255 .config_init = &m88e1121_config_init,
Sergei Poselenov140bc922009-04-07 02:01:41 +00001256 .config_aneg = &m88e1121_config_aneg,
1257 .read_status = &marvell_read_status,
1258 .ack_interrupt = &marvell_ack_interrupt,
1259 .config_intr = &marvell_config_intr,
Anatolij Gustschindcd07be2009-04-07 02:01:43 +00001260 .did_interrupt = &m88e1121_did_interrupt,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001261 .resume = &genphy_resume,
1262 .suspend = &genphy_suspend,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001263 .get_sset_count = marvell_get_sset_count,
1264 .get_strings = marvell_get_strings,
1265 .get_stats = marvell_get_stats,
Sergei Poselenov140bc922009-04-07 02:01:41 +00001266 },
1267 {
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -07001268 .phy_id = MARVELL_PHY_ID_88E1318S,
Linus Torvalds6ba74012010-08-04 11:47:58 -07001269 .phy_id_mask = MARVELL_PHY_ID_MASK,
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -07001270 .name = "Marvell 88E1318S",
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -07001271 .features = PHY_GBIT_FEATURES,
1272 .flags = PHY_HAS_INTERRUPT,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001273 .probe = marvell_probe,
Clemens Gruberfdecf362016-06-11 17:21:26 +02001274 .config_init = &m88e1121_config_init,
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -07001275 .config_aneg = &m88e1318_config_aneg,
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -07001276 .read_status = &marvell_read_status,
1277 .ack_interrupt = &marvell_ack_interrupt,
1278 .config_intr = &marvell_config_intr,
1279 .did_interrupt = &m88e1121_did_interrupt,
Michael Stapelberg3871c382013-03-11 13:56:45 +00001280 .get_wol = &m88e1318_get_wol,
1281 .set_wol = &m88e1318_set_wol,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001282 .resume = &genphy_resume,
1283 .suspend = &genphy_suspend,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001284 .get_sset_count = marvell_get_sset_count,
1285 .get_strings = marvell_get_strings,
1286 .get_stats = marvell_get_stats,
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -07001287 },
1288 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +10001289 .phy_id = MARVELL_PHY_ID_88E1145,
1290 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johanssone5479232007-07-03 16:23:46 -05001291 .name = "Marvell 88E1145",
1292 .features = PHY_GBIT_FEATURES,
1293 .flags = PHY_HAS_INTERRUPT,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001294 .probe = marvell_probe,
Olof Johanssone5479232007-07-03 16:23:46 -05001295 .config_init = &m88e1145_config_init,
1296 .config_aneg = &marvell_config_aneg,
1297 .read_status = &genphy_read_status,
1298 .ack_interrupt = &marvell_ack_interrupt,
1299 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001300 .resume = &genphy_resume,
1301 .suspend = &genphy_suspend,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001302 .get_sset_count = marvell_get_sset_count,
1303 .get_strings = marvell_get_strings,
1304 .get_stats = marvell_get_stats,
Olof Johanssonac8c6352007-11-04 16:08:51 -06001305 },
1306 {
David Daney90600732010-11-19 11:58:53 +00001307 .phy_id = MARVELL_PHY_ID_88E1149R,
1308 .phy_id_mask = MARVELL_PHY_ID_MASK,
1309 .name = "Marvell 88E1149R",
1310 .features = PHY_GBIT_FEATURES,
1311 .flags = PHY_HAS_INTERRUPT,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001312 .probe = marvell_probe,
David Daney90600732010-11-19 11:58:53 +00001313 .config_init = &m88e1149_config_init,
1314 .config_aneg = &m88e1118_config_aneg,
1315 .read_status = &genphy_read_status,
1316 .ack_interrupt = &marvell_ack_interrupt,
1317 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001318 .resume = &genphy_resume,
1319 .suspend = &genphy_suspend,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001320 .get_sset_count = marvell_get_sset_count,
1321 .get_strings = marvell_get_strings,
1322 .get_stats = marvell_get_stats,
David Daney90600732010-11-19 11:58:53 +00001323 },
1324 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +10001325 .phy_id = MARVELL_PHY_ID_88E1240,
1326 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johanssonac8c6352007-11-04 16:08:51 -06001327 .name = "Marvell 88E1240",
1328 .features = PHY_GBIT_FEATURES,
1329 .flags = PHY_HAS_INTERRUPT,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001330 .probe = marvell_probe,
Olof Johanssonac8c6352007-11-04 16:08:51 -06001331 .config_init = &m88e1111_config_init,
1332 .config_aneg = &marvell_config_aneg,
1333 .read_status = &genphy_read_status,
1334 .ack_interrupt = &marvell_ack_interrupt,
1335 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001336 .resume = &genphy_resume,
1337 .suspend = &genphy_suspend,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001338 .get_sset_count = marvell_get_sset_count,
1339 .get_strings = marvell_get_strings,
1340 .get_stats = marvell_get_stats,
Olof Johanssonac8c6352007-11-04 16:08:51 -06001341 },
Michal Simek3da09a52013-05-30 20:08:26 +00001342 {
1343 .phy_id = MARVELL_PHY_ID_88E1116R,
1344 .phy_id_mask = MARVELL_PHY_ID_MASK,
1345 .name = "Marvell 88E1116R",
1346 .features = PHY_GBIT_FEATURES,
1347 .flags = PHY_HAS_INTERRUPT,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001348 .probe = marvell_probe,
Michal Simek3da09a52013-05-30 20:08:26 +00001349 .config_init = &m88e1116r_config_init,
1350 .config_aneg = &genphy_config_aneg,
1351 .read_status = &genphy_read_status,
1352 .ack_interrupt = &marvell_ack_interrupt,
1353 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001354 .resume = &genphy_resume,
1355 .suspend = &genphy_suspend,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001356 .get_sset_count = marvell_get_sset_count,
1357 .get_strings = marvell_get_strings,
1358 .get_stats = marvell_get_stats,
Michal Simek3da09a52013-05-30 20:08:26 +00001359 },
Michal Simek10e24caa2013-05-30 20:08:27 +00001360 {
1361 .phy_id = MARVELL_PHY_ID_88E1510,
1362 .phy_id_mask = MARVELL_PHY_ID_MASK,
1363 .name = "Marvell 88E1510",
1364 .features = PHY_GBIT_FEATURES,
1365 .flags = PHY_HAS_INTERRUPT,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001366 .probe = marvell_probe,
Stefan Roese930b37e2016-02-18 10:59:07 +01001367 .config_init = &m88e1510_config_init,
Michal Simek10e24caa2013-05-30 20:08:27 +00001368 .config_aneg = &m88e1510_config_aneg,
1369 .read_status = &marvell_read_status,
1370 .ack_interrupt = &marvell_ack_interrupt,
1371 .config_intr = &marvell_config_intr,
1372 .did_interrupt = &m88e1121_did_interrupt,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001373 .resume = &genphy_resume,
1374 .suspend = &genphy_suspend,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001375 .get_sset_count = marvell_get_sset_count,
1376 .get_strings = marvell_get_strings,
1377 .get_stats = marvell_get_stats,
Michal Simek10e24caa2013-05-30 20:08:27 +00001378 },
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +02001379 {
Andrew Lunn819ec8e2015-11-16 23:34:41 +01001380 .phy_id = MARVELL_PHY_ID_88E1540,
1381 .phy_id_mask = MARVELL_PHY_ID_MASK,
1382 .name = "Marvell 88E1540",
1383 .features = PHY_GBIT_FEATURES,
1384 .flags = PHY_HAS_INTERRUPT,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001385 .probe = marvell_probe,
Clemens Gruber79be1a12016-02-15 23:46:45 +01001386 .config_init = &marvell_config_init,
Andrew Lunn819ec8e2015-11-16 23:34:41 +01001387 .config_aneg = &m88e1510_config_aneg,
1388 .read_status = &marvell_read_status,
1389 .ack_interrupt = &marvell_ack_interrupt,
1390 .config_intr = &marvell_config_intr,
1391 .did_interrupt = &m88e1121_did_interrupt,
1392 .resume = &genphy_resume,
1393 .suspend = &genphy_suspend,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001394 .get_sset_count = marvell_get_sset_count,
1395 .get_strings = marvell_get_strings,
1396 .get_stats = marvell_get_stats,
Andrew Lunn819ec8e2015-11-16 23:34:41 +01001397 },
1398 {
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +02001399 .phy_id = MARVELL_PHY_ID_88E3016,
1400 .phy_id_mask = MARVELL_PHY_ID_MASK,
1401 .name = "Marvell 88E3016",
1402 .features = PHY_BASIC_FEATURES,
1403 .flags = PHY_HAS_INTERRUPT,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001404 .probe = marvell_probe,
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +02001405 .config_aneg = &genphy_config_aneg,
1406 .config_init = &m88e3016_config_init,
1407 .aneg_done = &marvell_aneg_done,
1408 .read_status = &marvell_read_status,
1409 .ack_interrupt = &marvell_ack_interrupt,
1410 .config_intr = &marvell_config_intr,
1411 .did_interrupt = &m88e1121_did_interrupt,
1412 .resume = &genphy_resume,
1413 .suspend = &genphy_suspend,
Andrew Lunnd2fa47d2015-12-30 16:28:26 +01001414 .get_sset_count = marvell_get_sset_count,
1415 .get_strings = marvell_get_strings,
1416 .get_stats = marvell_get_stats,
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +02001417 },
Andy Fleming00db8182005-07-30 19:31:23 -04001418};
1419
Johan Hovold50fd7152014-11-11 19:45:59 +01001420module_phy_driver(marvell_drivers);
David Woodhouse4e4f10f2010-04-02 01:05:56 +00001421
Uwe Kleine-Königcf93c942010-10-03 23:43:32 +00001422static struct mdio_device_id __maybe_unused marvell_tbl[] = {
Michal Simekf5e1cab2013-05-30 20:08:25 +00001423 { MARVELL_PHY_ID_88E1101, MARVELL_PHY_ID_MASK },
1424 { MARVELL_PHY_ID_88E1112, MARVELL_PHY_ID_MASK },
1425 { MARVELL_PHY_ID_88E1111, MARVELL_PHY_ID_MASK },
1426 { MARVELL_PHY_ID_88E1118, MARVELL_PHY_ID_MASK },
1427 { MARVELL_PHY_ID_88E1121R, MARVELL_PHY_ID_MASK },
1428 { MARVELL_PHY_ID_88E1145, MARVELL_PHY_ID_MASK },
1429 { MARVELL_PHY_ID_88E1149R, MARVELL_PHY_ID_MASK },
1430 { MARVELL_PHY_ID_88E1240, MARVELL_PHY_ID_MASK },
1431 { MARVELL_PHY_ID_88E1318S, MARVELL_PHY_ID_MASK },
Michal Simek3da09a52013-05-30 20:08:26 +00001432 { MARVELL_PHY_ID_88E1116R, MARVELL_PHY_ID_MASK },
Michal Simek10e24caa2013-05-30 20:08:27 +00001433 { MARVELL_PHY_ID_88E1510, MARVELL_PHY_ID_MASK },
Andrew Lunn819ec8e2015-11-16 23:34:41 +01001434 { MARVELL_PHY_ID_88E1540, MARVELL_PHY_ID_MASK },
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +02001435 { MARVELL_PHY_ID_88E3016, MARVELL_PHY_ID_MASK },
David Woodhouse4e4f10f2010-04-02 01:05:56 +00001436 { }
1437};
1438
1439MODULE_DEVICE_TABLE(mdio, marvell_tbl);