blob: 5de8d5827536b1c196b4dabe95f3815964dd0296 [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
Andy Fleming00db8182005-07-30 19:31:23 -0400136MODULE_DESCRIPTION("Marvell PHY driver");
137MODULE_AUTHOR("Andy Fleming");
138MODULE_LICENSE("GPL");
139
140static int marvell_ack_interrupt(struct phy_device *phydev)
141{
142 int err;
143
144 /* Clear the interrupts by reading the reg */
145 err = phy_read(phydev, MII_M1011_IEVENT);
146
147 if (err < 0)
148 return err;
149
150 return 0;
151}
152
153static int marvell_config_intr(struct phy_device *phydev)
154{
155 int err;
156
Andy Fleming76884672007-02-09 18:13:58 -0600157 if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
Andy Fleming00db8182005-07-30 19:31:23 -0400158 err = phy_write(phydev, MII_M1011_IMASK, MII_M1011_IMASK_INIT);
159 else
160 err = phy_write(phydev, MII_M1011_IMASK, MII_M1011_IMASK_CLEAR);
161
162 return err;
163}
164
David Thomson239aa552015-07-10 16:28:25 +1200165static int marvell_set_polarity(struct phy_device *phydev, int polarity)
166{
167 int reg;
168 int err;
169 int val;
170
171 /* get the current settings */
172 reg = phy_read(phydev, MII_M1011_PHY_SCR);
173 if (reg < 0)
174 return reg;
175
176 val = reg;
177 val &= ~MII_M1011_PHY_SCR_AUTO_CROSS;
178 switch (polarity) {
179 case ETH_TP_MDI:
180 val |= MII_M1011_PHY_SCR_MDI;
181 break;
182 case ETH_TP_MDI_X:
183 val |= MII_M1011_PHY_SCR_MDI_X;
184 break;
185 case ETH_TP_MDI_AUTO:
186 case ETH_TP_MDI_INVALID:
187 default:
188 val |= MII_M1011_PHY_SCR_AUTO_CROSS;
189 break;
190 }
191
192 if (val != reg) {
193 /* Set the new polarity value in the register */
194 err = phy_write(phydev, MII_M1011_PHY_SCR, val);
195 if (err)
196 return err;
197 }
198
199 return 0;
200}
201
Andy Fleming00db8182005-07-30 19:31:23 -0400202static int marvell_config_aneg(struct phy_device *phydev)
203{
204 int err;
205
206 /* The Marvell PHY has an errata which requires
207 * that certain registers get written in order
208 * to restart autonegotiation */
209 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
210
211 if (err < 0)
212 return err;
213
214 err = phy_write(phydev, 0x1d, 0x1f);
215 if (err < 0)
216 return err;
217
218 err = phy_write(phydev, 0x1e, 0x200c);
219 if (err < 0)
220 return err;
221
222 err = phy_write(phydev, 0x1d, 0x5);
223 if (err < 0)
224 return err;
225
226 err = phy_write(phydev, 0x1e, 0);
227 if (err < 0)
228 return err;
229
230 err = phy_write(phydev, 0x1e, 0x100);
231 if (err < 0)
232 return err;
233
David Thomson239aa552015-07-10 16:28:25 +1200234 err = marvell_set_polarity(phydev, phydev->mdix);
Andy Fleming76884672007-02-09 18:13:58 -0600235 if (err < 0)
236 return err;
237
238 err = phy_write(phydev, MII_M1111_PHY_LED_CONTROL,
239 MII_M1111_PHY_LED_DIRECT);
240 if (err < 0)
241 return err;
Andy Fleming00db8182005-07-30 19:31:23 -0400242
243 err = genphy_config_aneg(phydev);
Anton Vorontsov8ff44982009-09-09 16:01:30 +0000244 if (err < 0)
245 return err;
Andy Fleming00db8182005-07-30 19:31:23 -0400246
Anton Vorontsov8ff44982009-09-09 16:01:30 +0000247 if (phydev->autoneg != AUTONEG_ENABLE) {
248 int bmcr;
249
250 /*
251 * A write to speed/duplex bits (that is performed by
252 * genphy_config_aneg() call above) must be followed by
253 * a software reset. Otherwise, the write has no effect.
254 */
255 bmcr = phy_read(phydev, MII_BMCR);
256 if (bmcr < 0)
257 return bmcr;
258
259 err = phy_write(phydev, MII_BMCR, bmcr | BMCR_RESET);
260 if (err < 0)
261 return err;
262 }
263
264 return 0;
Andy Fleming00db8182005-07-30 19:31:23 -0400265}
266
David Daneycf41a512010-11-19 12:13:18 +0000267#ifdef CONFIG_OF_MDIO
268/*
269 * Set and/or override some configuration registers based on the
270 * marvell,reg-init property stored in the of_node for the phydev.
271 *
272 * marvell,reg-init = <reg-page reg mask value>,...;
273 *
274 * There may be one or more sets of <reg-page reg mask value>:
275 *
276 * reg-page: which register bank to use.
277 * reg: the register.
278 * mask: if non-zero, ANDed with existing register value.
279 * value: ORed with the masked value and written to the regiser.
280 *
281 */
282static int marvell_of_reg_init(struct phy_device *phydev)
283{
284 const __be32 *paddr;
285 int len, i, saved_page, current_page, page_changed, ret;
286
287 if (!phydev->dev.of_node)
288 return 0;
289
290 paddr = of_get_property(phydev->dev.of_node, "marvell,reg-init", &len);
291 if (!paddr || len < (4 * sizeof(*paddr)))
292 return 0;
293
294 saved_page = phy_read(phydev, MII_MARVELL_PHY_PAGE);
295 if (saved_page < 0)
296 return saved_page;
297 page_changed = 0;
298 current_page = saved_page;
299
300 ret = 0;
301 len /= sizeof(*paddr);
302 for (i = 0; i < len - 3; i += 4) {
303 u16 reg_page = be32_to_cpup(paddr + i);
304 u16 reg = be32_to_cpup(paddr + i + 1);
305 u16 mask = be32_to_cpup(paddr + i + 2);
306 u16 val_bits = be32_to_cpup(paddr + i + 3);
307 int val;
308
309 if (reg_page != current_page) {
310 current_page = reg_page;
311 page_changed = 1;
312 ret = phy_write(phydev, MII_MARVELL_PHY_PAGE, reg_page);
313 if (ret < 0)
314 goto err;
315 }
316
317 val = 0;
318 if (mask) {
319 val = phy_read(phydev, reg);
320 if (val < 0) {
321 ret = val;
322 goto err;
323 }
324 val &= mask;
325 }
326 val |= val_bits;
327
328 ret = phy_write(phydev, reg, val);
329 if (ret < 0)
330 goto err;
331
332 }
333err:
334 if (page_changed) {
335 i = phy_write(phydev, MII_MARVELL_PHY_PAGE, saved_page);
336 if (ret == 0)
337 ret = i;
338 }
339 return ret;
340}
341#else
342static int marvell_of_reg_init(struct phy_device *phydev)
343{
344 return 0;
345}
346#endif /* CONFIG_OF_MDIO */
347
Sergei Poselenov140bc922009-04-07 02:01:41 +0000348static int m88e1121_config_aneg(struct phy_device *phydev)
349{
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000350 int err, oldpage, mscr;
351
David Daney27d916d2010-11-19 11:58:52 +0000352 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000353
David Daney27d916d2010-11-19 11:58:52 +0000354 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000355 MII_88E1121_PHY_MSCR_PAGE);
356 if (err < 0)
357 return err;
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000358
Florian Fainelli32a64162015-05-26 12:19:59 -0700359 if (phy_interface_is_rgmii(phydev)) {
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000360
Arnaud Patardbe8c6482010-10-21 03:59:57 -0700361 mscr = phy_read(phydev, MII_88E1121_PHY_MSCR_REG) &
362 MII_88E1121_PHY_MSCR_DELAY_MASK;
363
364 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
365 mscr |= (MII_88E1121_PHY_MSCR_RX_DELAY |
366 MII_88E1121_PHY_MSCR_TX_DELAY);
367 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID)
368 mscr |= MII_88E1121_PHY_MSCR_RX_DELAY;
369 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
370 mscr |= MII_88E1121_PHY_MSCR_TX_DELAY;
371
372 err = phy_write(phydev, MII_88E1121_PHY_MSCR_REG, mscr);
373 if (err < 0)
374 return err;
375 }
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000376
David Daney27d916d2010-11-19 11:58:52 +0000377 phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
Sergei Poselenov140bc922009-04-07 02:01:41 +0000378
379 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
380 if (err < 0)
381 return err;
382
383 err = phy_write(phydev, MII_M1011_PHY_SCR,
384 MII_M1011_PHY_SCR_AUTO_CROSS);
385 if (err < 0)
386 return err;
387
David Daney27d916d2010-11-19 11:58:52 +0000388 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
Sergei Poselenov140bc922009-04-07 02:01:41 +0000389
David Daney27d916d2010-11-19 11:58:52 +0000390 phy_write(phydev, MII_MARVELL_PHY_PAGE, MII_88E1121_PHY_LED_PAGE);
Sergei Poselenov140bc922009-04-07 02:01:41 +0000391 phy_write(phydev, MII_88E1121_PHY_LED_CTRL, MII_88E1121_PHY_LED_DEF);
David Daney27d916d2010-11-19 11:58:52 +0000392 phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
Sergei Poselenov140bc922009-04-07 02:01:41 +0000393
394 err = genphy_config_aneg(phydev);
395
396 return err;
397}
398
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -0700399static int m88e1318_config_aneg(struct phy_device *phydev)
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700400{
401 int err, oldpage, mscr;
402
David Daney27d916d2010-11-19 11:58:52 +0000403 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700404
David Daney27d916d2010-11-19 11:58:52 +0000405 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700406 MII_88E1121_PHY_MSCR_PAGE);
407 if (err < 0)
408 return err;
409
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -0700410 mscr = phy_read(phydev, MII_88E1318S_PHY_MSCR1_REG);
411 mscr |= MII_88E1318S_PHY_MSCR1_PAD_ODD;
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700412
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -0700413 err = phy_write(phydev, MII_88E1318S_PHY_MSCR1_REG, mscr);
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700414 if (err < 0)
415 return err;
416
David Daney27d916d2010-11-19 11:58:52 +0000417 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700418 if (err < 0)
419 return err;
420
421 return m88e1121_config_aneg(phydev);
422}
423
Michal Simek10e24caa2013-05-30 20:08:27 +0000424static int m88e1510_config_aneg(struct phy_device *phydev)
425{
426 int err;
427
428 err = m88e1318_config_aneg(phydev);
429 if (err < 0)
430 return err;
431
432 return marvell_of_reg_init(phydev);
433}
434
Michal Simek3da09a52013-05-30 20:08:26 +0000435static int m88e1116r_config_init(struct phy_device *phydev)
436{
437 int temp;
438 int err;
439
440 temp = phy_read(phydev, MII_BMCR);
441 temp |= BMCR_RESET;
442 err = phy_write(phydev, MII_BMCR, temp);
443 if (err < 0)
444 return err;
445
446 mdelay(500);
447
448 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0);
449 if (err < 0)
450 return err;
451
452 temp = phy_read(phydev, MII_M1011_PHY_SCR);
453 temp |= (7 << 12); /* max number of gigabit attempts */
454 temp |= (1 << 11); /* enable downshift */
455 temp |= MII_M1011_PHY_SCR_AUTO_CROSS;
456 err = phy_write(phydev, MII_M1011_PHY_SCR, temp);
457 if (err < 0)
458 return err;
459
460 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 2);
461 if (err < 0)
462 return err;
463 temp = phy_read(phydev, MII_M1116R_CONTROL_REG_MAC);
464 temp |= (1 << 5);
465 temp |= (1 << 4);
466 err = phy_write(phydev, MII_M1116R_CONTROL_REG_MAC, temp);
467 if (err < 0)
468 return err;
469 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0);
470 if (err < 0)
471 return err;
472
473 temp = phy_read(phydev, MII_BMCR);
474 temp |= BMCR_RESET;
475 err = phy_write(phydev, MII_BMCR, temp);
476 if (err < 0)
477 return err;
478
479 mdelay(500);
480
481 return 0;
482}
483
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +0200484static int m88e3016_config_init(struct phy_device *phydev)
485{
486 int reg;
487
488 /* Enable Scrambler and Auto-Crossover */
489 reg = phy_read(phydev, MII_88E3016_PHY_SPEC_CTRL);
490 if (reg < 0)
491 return reg;
492
493 reg &= ~MII_88E3016_DISABLE_SCRAMBLER;
494 reg |= MII_88E3016_AUTO_MDIX_CROSSOVER;
495
496 reg = phy_write(phydev, MII_88E3016_PHY_SPEC_CTRL, reg);
497 if (reg < 0)
498 return reg;
499
500 return 0;
501}
502
Kim Phillips895ee682007-06-05 18:46:47 +0800503static int m88e1111_config_init(struct phy_device *phydev)
504{
505 int err;
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300506 int temp;
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300507
Florian Fainelli32a64162015-05-26 12:19:59 -0700508 if (phy_interface_is_rgmii(phydev)) {
Kim Phillips895ee682007-06-05 18:46:47 +0800509
Kim Phillips9daf5a72007-11-26 16:17:52 -0600510 temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
511 if (temp < 0)
512 return temp;
513
Kim Phillips895ee682007-06-05 18:46:47 +0800514 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
Kim Phillips895ee682007-06-05 18:46:47 +0800515 temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
Kim Phillips9daf5a72007-11-26 16:17:52 -0600516 } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) {
517 temp &= ~MII_M1111_TX_DELAY;
518 temp |= MII_M1111_RX_DELAY;
519 } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
520 temp &= ~MII_M1111_RX_DELAY;
521 temp |= MII_M1111_TX_DELAY;
Kim Phillips895ee682007-06-05 18:46:47 +0800522 }
523
Kim Phillips9daf5a72007-11-26 16:17:52 -0600524 err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
525 if (err < 0)
526 return err;
527
Kim Phillips895ee682007-06-05 18:46:47 +0800528 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
529 if (temp < 0)
530 return temp;
531
532 temp &= ~(MII_M1111_HWCFG_MODE_MASK);
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300533
Wang Jian7239016d2008-07-16 21:46:20 +0800534 if (temp & MII_M1111_HWCFG_FIBER_COPPER_RES)
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300535 temp |= MII_M1111_HWCFG_MODE_FIBER_RGMII;
536 else
537 temp |= MII_M1111_HWCFG_MODE_COPPER_RGMII;
Kim Phillips895ee682007-06-05 18:46:47 +0800538
539 err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
540 if (err < 0)
541 return err;
542 }
543
Kapil Juneja4117b5b2007-05-11 18:25:18 -0500544 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
Kapil Juneja4117b5b2007-05-11 18:25:18 -0500545 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
546 if (temp < 0)
547 return temp;
548
549 temp &= ~(MII_M1111_HWCFG_MODE_MASK);
550 temp |= MII_M1111_HWCFG_MODE_SGMII_NO_CLK;
Haiying Wang32d0c1e2009-06-02 04:04:13 +0000551 temp |= MII_M1111_HWCFG_FIBER_COPPER_AUTO;
Kapil Juneja4117b5b2007-05-11 18:25:18 -0500552
553 err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
554 if (err < 0)
555 return err;
Madalin Bucur07151bc2015-08-07 17:07:50 +0800556
557 /* make sure copper is selected */
558 err = phy_read(phydev, MII_M1145_PHY_EXT_ADDR_PAGE);
559 if (err < 0)
560 return err;
561
562 err = phy_write(phydev, MII_M1145_PHY_EXT_ADDR_PAGE,
563 err & (~0xff));
564 if (err < 0)
565 return err;
Kapil Juneja4117b5b2007-05-11 18:25:18 -0500566 }
567
Liu Yu-B132015f8cbc12010-01-13 22:13:19 +0000568 if (phydev->interface == PHY_INTERFACE_MODE_RTBI) {
569 temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
570 if (temp < 0)
571 return temp;
572 temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
573 err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
574 if (err < 0)
575 return err;
576
577 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
578 if (temp < 0)
579 return temp;
580 temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
581 temp |= 0x7 | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
582 err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
583 if (err < 0)
584 return err;
585
586 /* soft reset */
587 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
588 if (err < 0)
589 return err;
590 do
591 temp = phy_read(phydev, MII_BMCR);
592 while (temp & BMCR_RESET);
593
594 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
595 if (temp < 0)
596 return temp;
597 temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
598 temp |= MII_M1111_HWCFG_MODE_COPPER_RTBI | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
599 err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
600 if (err < 0)
601 return err;
602 }
603
David Daneycf41a512010-11-19 12:13:18 +0000604 err = marvell_of_reg_init(phydev);
605 if (err < 0)
606 return err;
Liu Yu-B132015f8cbc12010-01-13 22:13:19 +0000607
Srinivas Kandagatlacc90cb32012-04-02 06:25:24 +0000608 return phy_write(phydev, MII_BMCR, BMCR_RESET);
Kim Phillips895ee682007-06-05 18:46:47 +0800609}
610
Ron Madrid605f1962008-11-06 09:05:26 +0000611static int m88e1118_config_aneg(struct phy_device *phydev)
612{
613 int err;
614
615 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
616 if (err < 0)
617 return err;
618
619 err = phy_write(phydev, MII_M1011_PHY_SCR,
620 MII_M1011_PHY_SCR_AUTO_CROSS);
621 if (err < 0)
622 return err;
623
624 err = genphy_config_aneg(phydev);
625 return 0;
626}
627
628static int m88e1118_config_init(struct phy_device *phydev)
629{
630 int err;
631
632 /* Change address */
David Daney27d916d2010-11-19 11:58:52 +0000633 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0002);
Ron Madrid605f1962008-11-06 09:05:26 +0000634 if (err < 0)
635 return err;
636
637 /* Enable 1000 Mbit */
638 err = phy_write(phydev, 0x15, 0x1070);
639 if (err < 0)
640 return err;
641
642 /* Change address */
David Daney27d916d2010-11-19 11:58:52 +0000643 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0003);
Ron Madrid605f1962008-11-06 09:05:26 +0000644 if (err < 0)
645 return err;
646
647 /* Adjust LED Control */
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +1000648 if (phydev->dev_flags & MARVELL_PHY_M1118_DNS323_LEDS)
649 err = phy_write(phydev, 0x10, 0x1100);
650 else
651 err = phy_write(phydev, 0x10, 0x021e);
Ron Madrid605f1962008-11-06 09:05:26 +0000652 if (err < 0)
653 return err;
654
David Daneycf41a512010-11-19 12:13:18 +0000655 err = marvell_of_reg_init(phydev);
656 if (err < 0)
657 return err;
658
Ron Madrid605f1962008-11-06 09:05:26 +0000659 /* Reset address */
David Daney27d916d2010-11-19 11:58:52 +0000660 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0);
Ron Madrid605f1962008-11-06 09:05:26 +0000661 if (err < 0)
662 return err;
663
Srinivas Kandagatlacc90cb32012-04-02 06:25:24 +0000664 return phy_write(phydev, MII_BMCR, BMCR_RESET);
Ron Madrid605f1962008-11-06 09:05:26 +0000665}
666
David Daney90600732010-11-19 11:58:53 +0000667static int m88e1149_config_init(struct phy_device *phydev)
668{
669 int err;
670
671 /* Change address */
672 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0002);
673 if (err < 0)
674 return err;
675
676 /* Enable 1000 Mbit */
677 err = phy_write(phydev, 0x15, 0x1048);
678 if (err < 0)
679 return err;
680
David Daneycf41a512010-11-19 12:13:18 +0000681 err = marvell_of_reg_init(phydev);
682 if (err < 0)
683 return err;
684
David Daney90600732010-11-19 11:58:53 +0000685 /* Reset address */
686 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0);
687 if (err < 0)
688 return err;
689
Srinivas Kandagatlacc90cb32012-04-02 06:25:24 +0000690 return phy_write(phydev, MII_BMCR, BMCR_RESET);
David Daney90600732010-11-19 11:58:53 +0000691}
692
Andy Fleming76884672007-02-09 18:13:58 -0600693static int m88e1145_config_init(struct phy_device *phydev)
694{
695 int err;
Viet Nga Daob0224172014-10-23 19:41:53 -0700696 int temp;
Andy Fleming76884672007-02-09 18:13:58 -0600697
698 /* Take care of errata E0 & E1 */
699 err = phy_write(phydev, 0x1d, 0x001b);
700 if (err < 0)
701 return err;
702
703 err = phy_write(phydev, 0x1e, 0x418f);
704 if (err < 0)
705 return err;
706
707 err = phy_write(phydev, 0x1d, 0x0016);
708 if (err < 0)
709 return err;
710
711 err = phy_write(phydev, 0x1e, 0xa2da);
712 if (err < 0)
713 return err;
714
Kim Phillips895ee682007-06-05 18:46:47 +0800715 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
Andy Fleming76884672007-02-09 18:13:58 -0600716 int temp = phy_read(phydev, MII_M1145_PHY_EXT_CR);
717 if (temp < 0)
718 return temp;
719
720 temp |= (MII_M1145_RGMII_RX_DELAY | MII_M1145_RGMII_TX_DELAY);
721
722 err = phy_write(phydev, MII_M1145_PHY_EXT_CR, temp);
723 if (err < 0)
724 return err;
725
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +1000726 if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) {
Andy Fleming76884672007-02-09 18:13:58 -0600727 err = phy_write(phydev, 0x1d, 0x0012);
728 if (err < 0)
729 return err;
730
731 temp = phy_read(phydev, 0x1e);
732 if (temp < 0)
733 return temp;
734
735 temp &= 0xf03f;
736 temp |= 2 << 9; /* 36 ohm */
737 temp |= 2 << 6; /* 39 ohm */
738
739 err = phy_write(phydev, 0x1e, temp);
740 if (err < 0)
741 return err;
742
743 err = phy_write(phydev, 0x1d, 0x3);
744 if (err < 0)
745 return err;
746
747 err = phy_write(phydev, 0x1e, 0x8000);
748 if (err < 0)
749 return err;
750 }
751 }
752
Viet Nga Daob0224172014-10-23 19:41:53 -0700753 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
754 temp = phy_read(phydev, MII_M1145_PHY_EXT_SR);
755 if (temp < 0)
756 return temp;
757
Vince Bridgers99d881f2014-10-26 14:22:24 -0500758 temp &= ~MII_M1145_HWCFG_MODE_MASK;
Viet Nga Daob0224172014-10-23 19:41:53 -0700759 temp |= MII_M1145_HWCFG_MODE_SGMII_NO_CLK;
760 temp |= MII_M1145_HWCFG_FIBER_COPPER_AUTO;
761
762 err = phy_write(phydev, MII_M1145_PHY_EXT_SR, temp);
763 if (err < 0)
764 return err;
765 }
766
David Daneycf41a512010-11-19 12:13:18 +0000767 err = marvell_of_reg_init(phydev);
768 if (err < 0)
769 return err;
770
Andy Fleming76884672007-02-09 18:13:58 -0600771 return 0;
772}
Andy Fleming00db8182005-07-30 19:31:23 -0400773
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300774/* marvell_read_status
775 *
776 * Generic status code does not detect Fiber correctly!
Jeff Garzikf0c88f92008-03-25 23:53:24 -0400777 * Description:
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300778 * Check the link, then figure out the current state
779 * by comparing what we advertise with what the link partner
780 * advertises. Start by checking the gigabit possibilities,
781 * then move on to 10/100.
782 */
783static int marvell_read_status(struct phy_device *phydev)
784{
785 int adv;
786 int err;
787 int lpa;
Russell King357cd642015-09-24 00:07:17 +0100788 int lpagb;
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300789 int status = 0;
790
791 /* Update the link, but return if there
792 * was an error */
793 err = genphy_update_link(phydev);
794 if (err)
795 return err;
796
797 if (AUTONEG_ENABLE == phydev->autoneg) {
798 status = phy_read(phydev, MII_M1011_PHY_STATUS);
799 if (status < 0)
800 return status;
801
802 lpa = phy_read(phydev, MII_LPA);
803 if (lpa < 0)
804 return lpa;
805
Russell King357cd642015-09-24 00:07:17 +0100806 lpagb = phy_read(phydev, MII_STAT1000);
807 if (lpagb < 0)
808 return lpagb;
809
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300810 adv = phy_read(phydev, MII_ADVERTISE);
811 if (adv < 0)
812 return adv;
813
Russell King357cd642015-09-24 00:07:17 +0100814 phydev->lp_advertising = mii_stat1000_to_ethtool_lpa_t(lpagb) |
815 mii_lpa_to_ethtool_lpa_t(lpa);
816
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300817 lpa &= adv;
818
819 if (status & MII_M1011_PHY_STATUS_FULLDUPLEX)
820 phydev->duplex = DUPLEX_FULL;
821 else
822 phydev->duplex = DUPLEX_HALF;
823
824 status = status & MII_M1011_PHY_STATUS_SPD_MASK;
825 phydev->pause = phydev->asym_pause = 0;
826
827 switch (status) {
828 case MII_M1011_PHY_STATUS_1000:
829 phydev->speed = SPEED_1000;
830 break;
831
832 case MII_M1011_PHY_STATUS_100:
833 phydev->speed = SPEED_100;
834 break;
835
836 default:
837 phydev->speed = SPEED_10;
838 break;
839 }
840
841 if (phydev->duplex == DUPLEX_FULL) {
842 phydev->pause = lpa & LPA_PAUSE_CAP ? 1 : 0;
843 phydev->asym_pause = lpa & LPA_PAUSE_ASYM ? 1 : 0;
844 }
845 } else {
846 int bmcr = phy_read(phydev, MII_BMCR);
847
848 if (bmcr < 0)
849 return bmcr;
850
851 if (bmcr & BMCR_FULLDPLX)
852 phydev->duplex = DUPLEX_FULL;
853 else
854 phydev->duplex = DUPLEX_HALF;
855
856 if (bmcr & BMCR_SPEED1000)
857 phydev->speed = SPEED_1000;
858 else if (bmcr & BMCR_SPEED100)
859 phydev->speed = SPEED_100;
860 else
861 phydev->speed = SPEED_10;
862
863 phydev->pause = phydev->asym_pause = 0;
Russell King357cd642015-09-24 00:07:17 +0100864 phydev->lp_advertising = 0;
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300865 }
866
867 return 0;
868}
869
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +0200870static int marvell_aneg_done(struct phy_device *phydev)
871{
872 int retval = phy_read(phydev, MII_M1011_PHY_STATUS);
873 return (retval < 0) ? retval : (retval & MII_M1011_PHY_STATUS_RESOLVED);
874}
875
Anatolij Gustschindcd07be2009-04-07 02:01:43 +0000876static int m88e1121_did_interrupt(struct phy_device *phydev)
877{
878 int imask;
879
880 imask = phy_read(phydev, MII_M1011_IEVENT);
881
882 if (imask & MII_M1011_IMASK_INIT)
883 return 1;
884
885 return 0;
886}
887
Michael Stapelberg3871c382013-03-11 13:56:45 +0000888static void m88e1318_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
889{
890 wol->supported = WAKE_MAGIC;
891 wol->wolopts = 0;
892
893 if (phy_write(phydev, MII_MARVELL_PHY_PAGE,
894 MII_88E1318S_PHY_WOL_PAGE) < 0)
895 return;
896
897 if (phy_read(phydev, MII_88E1318S_PHY_WOL_CTRL) &
898 MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE)
899 wol->wolopts |= WAKE_MAGIC;
900
901 if (phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x00) < 0)
902 return;
903}
904
905static int m88e1318_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
906{
907 int err, oldpage, temp;
908
909 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
910
911 if (wol->wolopts & WAKE_MAGIC) {
912 /* Explicitly switch to page 0x00, just to be sure */
913 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x00);
914 if (err < 0)
915 return err;
916
917 /* Enable the WOL interrupt */
918 temp = phy_read(phydev, MII_88E1318S_PHY_CSIER);
919 temp |= MII_88E1318S_PHY_CSIER_WOL_EIE;
920 err = phy_write(phydev, MII_88E1318S_PHY_CSIER, temp);
921 if (err < 0)
922 return err;
923
924 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
925 MII_88E1318S_PHY_LED_PAGE);
926 if (err < 0)
927 return err;
928
929 /* Setup LED[2] as interrupt pin (active low) */
930 temp = phy_read(phydev, MII_88E1318S_PHY_LED_TCR);
931 temp &= ~MII_88E1318S_PHY_LED_TCR_FORCE_INT;
932 temp |= MII_88E1318S_PHY_LED_TCR_INTn_ENABLE;
933 temp |= MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW;
934 err = phy_write(phydev, MII_88E1318S_PHY_LED_TCR, temp);
935 if (err < 0)
936 return err;
937
938 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
939 MII_88E1318S_PHY_WOL_PAGE);
940 if (err < 0)
941 return err;
942
943 /* Store the device address for the magic packet */
944 err = phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD2,
945 ((phydev->attached_dev->dev_addr[5] << 8) |
946 phydev->attached_dev->dev_addr[4]));
947 if (err < 0)
948 return err;
949 err = phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD1,
950 ((phydev->attached_dev->dev_addr[3] << 8) |
951 phydev->attached_dev->dev_addr[2]));
952 if (err < 0)
953 return err;
954 err = phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD0,
955 ((phydev->attached_dev->dev_addr[1] << 8) |
956 phydev->attached_dev->dev_addr[0]));
957 if (err < 0)
958 return err;
959
960 /* Clear WOL status and enable magic packet matching */
961 temp = phy_read(phydev, MII_88E1318S_PHY_WOL_CTRL);
962 temp |= MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS;
963 temp |= MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE;
964 err = phy_write(phydev, MII_88E1318S_PHY_WOL_CTRL, temp);
965 if (err < 0)
966 return err;
967 } else {
968 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
969 MII_88E1318S_PHY_WOL_PAGE);
970 if (err < 0)
971 return err;
972
973 /* Clear WOL status and disable magic packet matching */
974 temp = phy_read(phydev, MII_88E1318S_PHY_WOL_CTRL);
975 temp |= MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS;
976 temp &= ~MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE;
977 err = phy_write(phydev, MII_88E1318S_PHY_WOL_CTRL, temp);
978 if (err < 0)
979 return err;
980 }
981
982 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
983 if (err < 0)
984 return err;
985
986 return 0;
987}
988
Olof Johanssone5479232007-07-03 16:23:46 -0500989static struct phy_driver marvell_drivers[] = {
990 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +1000991 .phy_id = MARVELL_PHY_ID_88E1101,
992 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johanssone5479232007-07-03 16:23:46 -0500993 .name = "Marvell 88E1101",
994 .features = PHY_GBIT_FEATURES,
995 .flags = PHY_HAS_INTERRUPT,
996 .config_aneg = &marvell_config_aneg,
997 .read_status = &genphy_read_status,
998 .ack_interrupt = &marvell_ack_interrupt,
999 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001000 .resume = &genphy_resume,
1001 .suspend = &genphy_suspend,
Olof Johanssonac8c6352007-11-04 16:08:51 -06001002 .driver = { .owner = THIS_MODULE },
Olof Johanssone5479232007-07-03 16:23:46 -05001003 },
1004 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +10001005 .phy_id = MARVELL_PHY_ID_88E1112,
1006 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johansson85cfb532007-07-03 16:24:32 -05001007 .name = "Marvell 88E1112",
1008 .features = PHY_GBIT_FEATURES,
1009 .flags = PHY_HAS_INTERRUPT,
1010 .config_init = &m88e1111_config_init,
1011 .config_aneg = &marvell_config_aneg,
1012 .read_status = &genphy_read_status,
1013 .ack_interrupt = &marvell_ack_interrupt,
1014 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001015 .resume = &genphy_resume,
1016 .suspend = &genphy_suspend,
Olof Johanssonac8c6352007-11-04 16:08:51 -06001017 .driver = { .owner = THIS_MODULE },
Olof Johansson85cfb532007-07-03 16:24:32 -05001018 },
1019 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +10001020 .phy_id = MARVELL_PHY_ID_88E1111,
1021 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johanssone5479232007-07-03 16:23:46 -05001022 .name = "Marvell 88E1111",
1023 .features = PHY_GBIT_FEATURES,
1024 .flags = PHY_HAS_INTERRUPT,
1025 .config_init = &m88e1111_config_init,
1026 .config_aneg = &marvell_config_aneg,
Alexandr Smirnovbe937f12008-03-19 00:37:24 +03001027 .read_status = &marvell_read_status,
Olof Johanssone5479232007-07-03 16:23:46 -05001028 .ack_interrupt = &marvell_ack_interrupt,
1029 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001030 .resume = &genphy_resume,
1031 .suspend = &genphy_suspend,
Olof Johanssonac8c6352007-11-04 16:08:51 -06001032 .driver = { .owner = THIS_MODULE },
Olof Johanssone5479232007-07-03 16:23:46 -05001033 },
1034 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +10001035 .phy_id = MARVELL_PHY_ID_88E1118,
1036 .phy_id_mask = MARVELL_PHY_ID_MASK,
Ron Madrid605f1962008-11-06 09:05:26 +00001037 .name = "Marvell 88E1118",
1038 .features = PHY_GBIT_FEATURES,
1039 .flags = PHY_HAS_INTERRUPT,
1040 .config_init = &m88e1118_config_init,
1041 .config_aneg = &m88e1118_config_aneg,
1042 .read_status = &genphy_read_status,
1043 .ack_interrupt = &marvell_ack_interrupt,
1044 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001045 .resume = &genphy_resume,
1046 .suspend = &genphy_suspend,
Ron Madrid605f1962008-11-06 09:05:26 +00001047 .driver = {.owner = THIS_MODULE,},
1048 },
1049 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +10001050 .phy_id = MARVELL_PHY_ID_88E1121R,
1051 .phy_id_mask = MARVELL_PHY_ID_MASK,
Sergei Poselenov140bc922009-04-07 02:01:41 +00001052 .name = "Marvell 88E1121R",
1053 .features = PHY_GBIT_FEATURES,
1054 .flags = PHY_HAS_INTERRUPT,
1055 .config_aneg = &m88e1121_config_aneg,
1056 .read_status = &marvell_read_status,
1057 .ack_interrupt = &marvell_ack_interrupt,
1058 .config_intr = &marvell_config_intr,
Anatolij Gustschindcd07be2009-04-07 02:01:43 +00001059 .did_interrupt = &m88e1121_did_interrupt,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001060 .resume = &genphy_resume,
1061 .suspend = &genphy_suspend,
Sergei Poselenov140bc922009-04-07 02:01:41 +00001062 .driver = { .owner = THIS_MODULE },
1063 },
1064 {
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -07001065 .phy_id = MARVELL_PHY_ID_88E1318S,
Linus Torvalds6ba74012010-08-04 11:47:58 -07001066 .phy_id_mask = MARVELL_PHY_ID_MASK,
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -07001067 .name = "Marvell 88E1318S",
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -07001068 .features = PHY_GBIT_FEATURES,
1069 .flags = PHY_HAS_INTERRUPT,
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -07001070 .config_aneg = &m88e1318_config_aneg,
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -07001071 .read_status = &marvell_read_status,
1072 .ack_interrupt = &marvell_ack_interrupt,
1073 .config_intr = &marvell_config_intr,
1074 .did_interrupt = &m88e1121_did_interrupt,
Michael Stapelberg3871c382013-03-11 13:56:45 +00001075 .get_wol = &m88e1318_get_wol,
1076 .set_wol = &m88e1318_set_wol,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001077 .resume = &genphy_resume,
1078 .suspend = &genphy_suspend,
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -07001079 .driver = { .owner = THIS_MODULE },
1080 },
1081 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +10001082 .phy_id = MARVELL_PHY_ID_88E1145,
1083 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johanssone5479232007-07-03 16:23:46 -05001084 .name = "Marvell 88E1145",
1085 .features = PHY_GBIT_FEATURES,
1086 .flags = PHY_HAS_INTERRUPT,
1087 .config_init = &m88e1145_config_init,
1088 .config_aneg = &marvell_config_aneg,
1089 .read_status = &genphy_read_status,
1090 .ack_interrupt = &marvell_ack_interrupt,
1091 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001092 .resume = &genphy_resume,
1093 .suspend = &genphy_suspend,
Olof Johanssonac8c6352007-11-04 16:08:51 -06001094 .driver = { .owner = THIS_MODULE },
1095 },
1096 {
David Daney90600732010-11-19 11:58:53 +00001097 .phy_id = MARVELL_PHY_ID_88E1149R,
1098 .phy_id_mask = MARVELL_PHY_ID_MASK,
1099 .name = "Marvell 88E1149R",
1100 .features = PHY_GBIT_FEATURES,
1101 .flags = PHY_HAS_INTERRUPT,
1102 .config_init = &m88e1149_config_init,
1103 .config_aneg = &m88e1118_config_aneg,
1104 .read_status = &genphy_read_status,
1105 .ack_interrupt = &marvell_ack_interrupt,
1106 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001107 .resume = &genphy_resume,
1108 .suspend = &genphy_suspend,
David Daney90600732010-11-19 11:58:53 +00001109 .driver = { .owner = THIS_MODULE },
1110 },
1111 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +10001112 .phy_id = MARVELL_PHY_ID_88E1240,
1113 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johanssonac8c6352007-11-04 16:08:51 -06001114 .name = "Marvell 88E1240",
1115 .features = PHY_GBIT_FEATURES,
1116 .flags = PHY_HAS_INTERRUPT,
1117 .config_init = &m88e1111_config_init,
1118 .config_aneg = &marvell_config_aneg,
1119 .read_status = &genphy_read_status,
1120 .ack_interrupt = &marvell_ack_interrupt,
1121 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001122 .resume = &genphy_resume,
1123 .suspend = &genphy_suspend,
Olof Johanssonac8c6352007-11-04 16:08:51 -06001124 .driver = { .owner = THIS_MODULE },
1125 },
Michal Simek3da09a52013-05-30 20:08:26 +00001126 {
1127 .phy_id = MARVELL_PHY_ID_88E1116R,
1128 .phy_id_mask = MARVELL_PHY_ID_MASK,
1129 .name = "Marvell 88E1116R",
1130 .features = PHY_GBIT_FEATURES,
1131 .flags = PHY_HAS_INTERRUPT,
1132 .config_init = &m88e1116r_config_init,
1133 .config_aneg = &genphy_config_aneg,
1134 .read_status = &genphy_read_status,
1135 .ack_interrupt = &marvell_ack_interrupt,
1136 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001137 .resume = &genphy_resume,
1138 .suspend = &genphy_suspend,
Michal Simek3da09a52013-05-30 20:08:26 +00001139 .driver = { .owner = THIS_MODULE },
1140 },
Michal Simek10e24caa2013-05-30 20:08:27 +00001141 {
1142 .phy_id = MARVELL_PHY_ID_88E1510,
1143 .phy_id_mask = MARVELL_PHY_ID_MASK,
1144 .name = "Marvell 88E1510",
1145 .features = PHY_GBIT_FEATURES,
1146 .flags = PHY_HAS_INTERRUPT,
1147 .config_aneg = &m88e1510_config_aneg,
1148 .read_status = &marvell_read_status,
1149 .ack_interrupt = &marvell_ack_interrupt,
1150 .config_intr = &marvell_config_intr,
1151 .did_interrupt = &m88e1121_did_interrupt,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001152 .resume = &genphy_resume,
1153 .suspend = &genphy_suspend,
Michal Simek10e24caa2013-05-30 20:08:27 +00001154 .driver = { .owner = THIS_MODULE },
1155 },
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +02001156 {
1157 .phy_id = MARVELL_PHY_ID_88E3016,
1158 .phy_id_mask = MARVELL_PHY_ID_MASK,
1159 .name = "Marvell 88E3016",
1160 .features = PHY_BASIC_FEATURES,
1161 .flags = PHY_HAS_INTERRUPT,
1162 .config_aneg = &genphy_config_aneg,
1163 .config_init = &m88e3016_config_init,
1164 .aneg_done = &marvell_aneg_done,
1165 .read_status = &marvell_read_status,
1166 .ack_interrupt = &marvell_ack_interrupt,
1167 .config_intr = &marvell_config_intr,
1168 .did_interrupt = &m88e1121_did_interrupt,
1169 .resume = &genphy_resume,
1170 .suspend = &genphy_suspend,
1171 .driver = { .owner = THIS_MODULE },
1172 },
Andy Fleming00db8182005-07-30 19:31:23 -04001173};
1174
Johan Hovold50fd7152014-11-11 19:45:59 +01001175module_phy_driver(marvell_drivers);
David Woodhouse4e4f10f2010-04-02 01:05:56 +00001176
Uwe Kleine-Königcf93c942010-10-03 23:43:32 +00001177static struct mdio_device_id __maybe_unused marvell_tbl[] = {
Michal Simekf5e1cab2013-05-30 20:08:25 +00001178 { MARVELL_PHY_ID_88E1101, MARVELL_PHY_ID_MASK },
1179 { MARVELL_PHY_ID_88E1112, MARVELL_PHY_ID_MASK },
1180 { MARVELL_PHY_ID_88E1111, MARVELL_PHY_ID_MASK },
1181 { MARVELL_PHY_ID_88E1118, MARVELL_PHY_ID_MASK },
1182 { MARVELL_PHY_ID_88E1121R, MARVELL_PHY_ID_MASK },
1183 { MARVELL_PHY_ID_88E1145, MARVELL_PHY_ID_MASK },
1184 { MARVELL_PHY_ID_88E1149R, MARVELL_PHY_ID_MASK },
1185 { MARVELL_PHY_ID_88E1240, MARVELL_PHY_ID_MASK },
1186 { MARVELL_PHY_ID_88E1318S, MARVELL_PHY_ID_MASK },
Michal Simek3da09a52013-05-30 20:08:26 +00001187 { MARVELL_PHY_ID_88E1116R, MARVELL_PHY_ID_MASK },
Michal Simek10e24caa2013-05-30 20:08:27 +00001188 { MARVELL_PHY_ID_88E1510, MARVELL_PHY_ID_MASK },
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +02001189 { MARVELL_PHY_ID_88E3016, MARVELL_PHY_ID_MASK },
David Woodhouse4e4f10f2010-04-02 01:05:56 +00001190 { }
1191};
1192
1193MODULE_DEVICE_TABLE(mdio, marvell_tbl);