blob: f721444c2b0a9413dd0bac8c7e61099cf6d3789b [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
51#define MII_M1011_PHY_SCR_AUTO_CROSS 0x0060
52
Viet Nga Daob0224172014-10-23 19:41:53 -070053#define MII_M1145_PHY_EXT_SR 0x1b
Andy Fleming76884672007-02-09 18:13:58 -060054#define MII_M1145_PHY_EXT_CR 0x14
55#define MII_M1145_RGMII_RX_DELAY 0x0080
56#define MII_M1145_RGMII_TX_DELAY 0x0002
Viet Nga Daob0224172014-10-23 19:41:53 -070057#define MII_M1145_HWCFG_MODE_SGMII_NO_CLK 0x4
58#define MII_M1145_HWCFG_MODE_MASK 0xf
59#define MII_M1145_HWCFG_FIBER_COPPER_AUTO 0x8000
Andy Fleming76884672007-02-09 18:13:58 -060060
Vince Bridgers99d881f2014-10-26 14:22:24 -050061#define MII_M1145_HWCFG_MODE_SGMII_NO_CLK 0x4
62#define MII_M1145_HWCFG_MODE_MASK 0xf
63#define MII_M1145_HWCFG_FIBER_COPPER_AUTO 0x8000
64
Andy Fleming76884672007-02-09 18:13:58 -060065#define MII_M1111_PHY_LED_CONTROL 0x18
66#define MII_M1111_PHY_LED_DIRECT 0x4100
67#define MII_M1111_PHY_LED_COMBINE 0x411c
Kim Phillips895ee682007-06-05 18:46:47 +080068#define MII_M1111_PHY_EXT_CR 0x14
69#define MII_M1111_RX_DELAY 0x80
70#define MII_M1111_TX_DELAY 0x2
71#define MII_M1111_PHY_EXT_SR 0x1b
Alexandr Smirnovbe937f12008-03-19 00:37:24 +030072
73#define MII_M1111_HWCFG_MODE_MASK 0xf
74#define MII_M1111_HWCFG_MODE_COPPER_RGMII 0xb
75#define MII_M1111_HWCFG_MODE_FIBER_RGMII 0x3
Kapil Juneja4117b5b2007-05-11 18:25:18 -050076#define MII_M1111_HWCFG_MODE_SGMII_NO_CLK 0x4
Liu Yu-B132015f8cbc12010-01-13 22:13:19 +000077#define MII_M1111_HWCFG_MODE_COPPER_RTBI 0x9
Alexandr Smirnovbe937f12008-03-19 00:37:24 +030078#define MII_M1111_HWCFG_FIBER_COPPER_AUTO 0x8000
79#define MII_M1111_HWCFG_FIBER_COPPER_RES 0x2000
80
81#define MII_M1111_COPPER 0
82#define MII_M1111_FIBER 1
83
Cyril Chemparathyc477d042010-08-02 09:44:53 +000084#define MII_88E1121_PHY_MSCR_PAGE 2
85#define MII_88E1121_PHY_MSCR_REG 21
86#define MII_88E1121_PHY_MSCR_RX_DELAY BIT(5)
87#define MII_88E1121_PHY_MSCR_TX_DELAY BIT(4)
88#define MII_88E1121_PHY_MSCR_DELAY_MASK (~(0x3 << 4))
89
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -070090#define MII_88E1318S_PHY_MSCR1_REG 16
91#define MII_88E1318S_PHY_MSCR1_PAD_ODD BIT(6)
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -070092
Michael Stapelberg3871c382013-03-11 13:56:45 +000093/* Copper Specific Interrupt Enable Register */
94#define MII_88E1318S_PHY_CSIER 0x12
95/* WOL Event Interrupt Enable */
96#define MII_88E1318S_PHY_CSIER_WOL_EIE BIT(7)
97
98/* LED Timer Control Register */
99#define MII_88E1318S_PHY_LED_PAGE 0x03
100#define MII_88E1318S_PHY_LED_TCR 0x12
101#define MII_88E1318S_PHY_LED_TCR_FORCE_INT BIT(15)
102#define MII_88E1318S_PHY_LED_TCR_INTn_ENABLE BIT(7)
103#define MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW BIT(11)
104
105/* Magic Packet MAC address registers */
106#define MII_88E1318S_PHY_MAGIC_PACKET_WORD2 0x17
107#define MII_88E1318S_PHY_MAGIC_PACKET_WORD1 0x18
108#define MII_88E1318S_PHY_MAGIC_PACKET_WORD0 0x19
109
110#define MII_88E1318S_PHY_WOL_PAGE 0x11
111#define MII_88E1318S_PHY_WOL_CTRL 0x10
112#define MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS BIT(12)
113#define MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE BIT(14)
114
Sergei Poselenov140bc922009-04-07 02:01:41 +0000115#define MII_88E1121_PHY_LED_CTRL 16
116#define MII_88E1121_PHY_LED_PAGE 3
117#define MII_88E1121_PHY_LED_DEF 0x0030
Sergei Poselenov140bc922009-04-07 02:01:41 +0000118
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300119#define MII_M1011_PHY_STATUS 0x11
120#define MII_M1011_PHY_STATUS_1000 0x8000
121#define MII_M1011_PHY_STATUS_100 0x4000
122#define MII_M1011_PHY_STATUS_SPD_MASK 0xc000
123#define MII_M1011_PHY_STATUS_FULLDUPLEX 0x2000
124#define MII_M1011_PHY_STATUS_RESOLVED 0x0800
125#define MII_M1011_PHY_STATUS_LINK 0x0400
126
Michal Simek3da09a52013-05-30 20:08:26 +0000127#define MII_M1116R_CONTROL_REG_MAC 21
128
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +0200129#define MII_88E3016_PHY_SPEC_CTRL 0x10
130#define MII_88E3016_DISABLE_SCRAMBLER 0x0200
131#define MII_88E3016_AUTO_MDIX_CROSSOVER 0x0030
Andy Fleming76884672007-02-09 18:13:58 -0600132
Andy Fleming00db8182005-07-30 19:31:23 -0400133MODULE_DESCRIPTION("Marvell PHY driver");
134MODULE_AUTHOR("Andy Fleming");
135MODULE_LICENSE("GPL");
136
137static int marvell_ack_interrupt(struct phy_device *phydev)
138{
139 int err;
140
141 /* Clear the interrupts by reading the reg */
142 err = phy_read(phydev, MII_M1011_IEVENT);
143
144 if (err < 0)
145 return err;
146
147 return 0;
148}
149
150static int marvell_config_intr(struct phy_device *phydev)
151{
152 int err;
153
Andy Fleming76884672007-02-09 18:13:58 -0600154 if (phydev->interrupts == PHY_INTERRUPT_ENABLED)
Andy Fleming00db8182005-07-30 19:31:23 -0400155 err = phy_write(phydev, MII_M1011_IMASK, MII_M1011_IMASK_INIT);
156 else
157 err = phy_write(phydev, MII_M1011_IMASK, MII_M1011_IMASK_CLEAR);
158
159 return err;
160}
161
162static int marvell_config_aneg(struct phy_device *phydev)
163{
164 int err;
165
166 /* The Marvell PHY has an errata which requires
167 * that certain registers get written in order
168 * to restart autonegotiation */
169 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
170
171 if (err < 0)
172 return err;
173
174 err = phy_write(phydev, 0x1d, 0x1f);
175 if (err < 0)
176 return err;
177
178 err = phy_write(phydev, 0x1e, 0x200c);
179 if (err < 0)
180 return err;
181
182 err = phy_write(phydev, 0x1d, 0x5);
183 if (err < 0)
184 return err;
185
186 err = phy_write(phydev, 0x1e, 0);
187 if (err < 0)
188 return err;
189
190 err = phy_write(phydev, 0x1e, 0x100);
191 if (err < 0)
192 return err;
193
Andy Fleming76884672007-02-09 18:13:58 -0600194 err = phy_write(phydev, MII_M1011_PHY_SCR,
195 MII_M1011_PHY_SCR_AUTO_CROSS);
196 if (err < 0)
197 return err;
198
199 err = phy_write(phydev, MII_M1111_PHY_LED_CONTROL,
200 MII_M1111_PHY_LED_DIRECT);
201 if (err < 0)
202 return err;
Andy Fleming00db8182005-07-30 19:31:23 -0400203
204 err = genphy_config_aneg(phydev);
Anton Vorontsov8ff44982009-09-09 16:01:30 +0000205 if (err < 0)
206 return err;
Andy Fleming00db8182005-07-30 19:31:23 -0400207
Anton Vorontsov8ff44982009-09-09 16:01:30 +0000208 if (phydev->autoneg != AUTONEG_ENABLE) {
209 int bmcr;
210
211 /*
212 * A write to speed/duplex bits (that is performed by
213 * genphy_config_aneg() call above) must be followed by
214 * a software reset. Otherwise, the write has no effect.
215 */
216 bmcr = phy_read(phydev, MII_BMCR);
217 if (bmcr < 0)
218 return bmcr;
219
220 err = phy_write(phydev, MII_BMCR, bmcr | BMCR_RESET);
221 if (err < 0)
222 return err;
223 }
224
225 return 0;
Andy Fleming00db8182005-07-30 19:31:23 -0400226}
227
David Daneycf41a512010-11-19 12:13:18 +0000228#ifdef CONFIG_OF_MDIO
229/*
230 * Set and/or override some configuration registers based on the
231 * marvell,reg-init property stored in the of_node for the phydev.
232 *
233 * marvell,reg-init = <reg-page reg mask value>,...;
234 *
235 * There may be one or more sets of <reg-page reg mask value>:
236 *
237 * reg-page: which register bank to use.
238 * reg: the register.
239 * mask: if non-zero, ANDed with existing register value.
240 * value: ORed with the masked value and written to the regiser.
241 *
242 */
243static int marvell_of_reg_init(struct phy_device *phydev)
244{
245 const __be32 *paddr;
246 int len, i, saved_page, current_page, page_changed, ret;
247
248 if (!phydev->dev.of_node)
249 return 0;
250
251 paddr = of_get_property(phydev->dev.of_node, "marvell,reg-init", &len);
252 if (!paddr || len < (4 * sizeof(*paddr)))
253 return 0;
254
255 saved_page = phy_read(phydev, MII_MARVELL_PHY_PAGE);
256 if (saved_page < 0)
257 return saved_page;
258 page_changed = 0;
259 current_page = saved_page;
260
261 ret = 0;
262 len /= sizeof(*paddr);
263 for (i = 0; i < len - 3; i += 4) {
264 u16 reg_page = be32_to_cpup(paddr + i);
265 u16 reg = be32_to_cpup(paddr + i + 1);
266 u16 mask = be32_to_cpup(paddr + i + 2);
267 u16 val_bits = be32_to_cpup(paddr + i + 3);
268 int val;
269
270 if (reg_page != current_page) {
271 current_page = reg_page;
272 page_changed = 1;
273 ret = phy_write(phydev, MII_MARVELL_PHY_PAGE, reg_page);
274 if (ret < 0)
275 goto err;
276 }
277
278 val = 0;
279 if (mask) {
280 val = phy_read(phydev, reg);
281 if (val < 0) {
282 ret = val;
283 goto err;
284 }
285 val &= mask;
286 }
287 val |= val_bits;
288
289 ret = phy_write(phydev, reg, val);
290 if (ret < 0)
291 goto err;
292
293 }
294err:
295 if (page_changed) {
296 i = phy_write(phydev, MII_MARVELL_PHY_PAGE, saved_page);
297 if (ret == 0)
298 ret = i;
299 }
300 return ret;
301}
302#else
303static int marvell_of_reg_init(struct phy_device *phydev)
304{
305 return 0;
306}
307#endif /* CONFIG_OF_MDIO */
308
Sergei Poselenov140bc922009-04-07 02:01:41 +0000309static int m88e1121_config_aneg(struct phy_device *phydev)
310{
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000311 int err, oldpage, mscr;
312
David Daney27d916d2010-11-19 11:58:52 +0000313 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000314
David Daney27d916d2010-11-19 11:58:52 +0000315 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000316 MII_88E1121_PHY_MSCR_PAGE);
317 if (err < 0)
318 return err;
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000319
Florian Fainelli32a64162015-05-26 12:19:59 -0700320 if (phy_interface_is_rgmii(phydev)) {
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000321
Arnaud Patardbe8c6482010-10-21 03:59:57 -0700322 mscr = phy_read(phydev, MII_88E1121_PHY_MSCR_REG) &
323 MII_88E1121_PHY_MSCR_DELAY_MASK;
324
325 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
326 mscr |= (MII_88E1121_PHY_MSCR_RX_DELAY |
327 MII_88E1121_PHY_MSCR_TX_DELAY);
328 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID)
329 mscr |= MII_88E1121_PHY_MSCR_RX_DELAY;
330 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
331 mscr |= MII_88E1121_PHY_MSCR_TX_DELAY;
332
333 err = phy_write(phydev, MII_88E1121_PHY_MSCR_REG, mscr);
334 if (err < 0)
335 return err;
336 }
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000337
David Daney27d916d2010-11-19 11:58:52 +0000338 phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
Sergei Poselenov140bc922009-04-07 02:01:41 +0000339
340 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
341 if (err < 0)
342 return err;
343
344 err = phy_write(phydev, MII_M1011_PHY_SCR,
345 MII_M1011_PHY_SCR_AUTO_CROSS);
346 if (err < 0)
347 return err;
348
David Daney27d916d2010-11-19 11:58:52 +0000349 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
Sergei Poselenov140bc922009-04-07 02:01:41 +0000350
David Daney27d916d2010-11-19 11:58:52 +0000351 phy_write(phydev, MII_MARVELL_PHY_PAGE, MII_88E1121_PHY_LED_PAGE);
Sergei Poselenov140bc922009-04-07 02:01:41 +0000352 phy_write(phydev, MII_88E1121_PHY_LED_CTRL, MII_88E1121_PHY_LED_DEF);
David Daney27d916d2010-11-19 11:58:52 +0000353 phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
Sergei Poselenov140bc922009-04-07 02:01:41 +0000354
355 err = genphy_config_aneg(phydev);
356
357 return err;
358}
359
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -0700360static int m88e1318_config_aneg(struct phy_device *phydev)
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700361{
362 int err, oldpage, mscr;
363
David Daney27d916d2010-11-19 11:58:52 +0000364 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700365
David Daney27d916d2010-11-19 11:58:52 +0000366 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700367 MII_88E1121_PHY_MSCR_PAGE);
368 if (err < 0)
369 return err;
370
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -0700371 mscr = phy_read(phydev, MII_88E1318S_PHY_MSCR1_REG);
372 mscr |= MII_88E1318S_PHY_MSCR1_PAD_ODD;
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700373
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -0700374 err = phy_write(phydev, MII_88E1318S_PHY_MSCR1_REG, mscr);
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700375 if (err < 0)
376 return err;
377
David Daney27d916d2010-11-19 11:58:52 +0000378 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700379 if (err < 0)
380 return err;
381
382 return m88e1121_config_aneg(phydev);
383}
384
Michal Simek10e24caa2013-05-30 20:08:27 +0000385static int m88e1510_config_aneg(struct phy_device *phydev)
386{
387 int err;
388
389 err = m88e1318_config_aneg(phydev);
390 if (err < 0)
391 return err;
392
393 return marvell_of_reg_init(phydev);
394}
395
Michal Simek3da09a52013-05-30 20:08:26 +0000396static int m88e1116r_config_init(struct phy_device *phydev)
397{
398 int temp;
399 int err;
400
401 temp = phy_read(phydev, MII_BMCR);
402 temp |= BMCR_RESET;
403 err = phy_write(phydev, MII_BMCR, temp);
404 if (err < 0)
405 return err;
406
407 mdelay(500);
408
409 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0);
410 if (err < 0)
411 return err;
412
413 temp = phy_read(phydev, MII_M1011_PHY_SCR);
414 temp |= (7 << 12); /* max number of gigabit attempts */
415 temp |= (1 << 11); /* enable downshift */
416 temp |= MII_M1011_PHY_SCR_AUTO_CROSS;
417 err = phy_write(phydev, MII_M1011_PHY_SCR, temp);
418 if (err < 0)
419 return err;
420
421 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 2);
422 if (err < 0)
423 return err;
424 temp = phy_read(phydev, MII_M1116R_CONTROL_REG_MAC);
425 temp |= (1 << 5);
426 temp |= (1 << 4);
427 err = phy_write(phydev, MII_M1116R_CONTROL_REG_MAC, temp);
428 if (err < 0)
429 return err;
430 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0);
431 if (err < 0)
432 return err;
433
434 temp = phy_read(phydev, MII_BMCR);
435 temp |= BMCR_RESET;
436 err = phy_write(phydev, MII_BMCR, temp);
437 if (err < 0)
438 return err;
439
440 mdelay(500);
441
442 return 0;
443}
444
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +0200445static int m88e3016_config_init(struct phy_device *phydev)
446{
447 int reg;
448
449 /* Enable Scrambler and Auto-Crossover */
450 reg = phy_read(phydev, MII_88E3016_PHY_SPEC_CTRL);
451 if (reg < 0)
452 return reg;
453
454 reg &= ~MII_88E3016_DISABLE_SCRAMBLER;
455 reg |= MII_88E3016_AUTO_MDIX_CROSSOVER;
456
457 reg = phy_write(phydev, MII_88E3016_PHY_SPEC_CTRL, reg);
458 if (reg < 0)
459 return reg;
460
461 return 0;
462}
463
Kim Phillips895ee682007-06-05 18:46:47 +0800464static int m88e1111_config_init(struct phy_device *phydev)
465{
466 int err;
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300467 int temp;
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300468
Florian Fainelli32a64162015-05-26 12:19:59 -0700469 if (phy_interface_is_rgmii(phydev)) {
Kim Phillips895ee682007-06-05 18:46:47 +0800470
Kim Phillips9daf5a72007-11-26 16:17:52 -0600471 temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
472 if (temp < 0)
473 return temp;
474
Kim Phillips895ee682007-06-05 18:46:47 +0800475 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
Kim Phillips895ee682007-06-05 18:46:47 +0800476 temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
Kim Phillips9daf5a72007-11-26 16:17:52 -0600477 } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) {
478 temp &= ~MII_M1111_TX_DELAY;
479 temp |= MII_M1111_RX_DELAY;
480 } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
481 temp &= ~MII_M1111_RX_DELAY;
482 temp |= MII_M1111_TX_DELAY;
Kim Phillips895ee682007-06-05 18:46:47 +0800483 }
484
Kim Phillips9daf5a72007-11-26 16:17:52 -0600485 err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
486 if (err < 0)
487 return err;
488
Kim Phillips895ee682007-06-05 18:46:47 +0800489 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
490 if (temp < 0)
491 return temp;
492
493 temp &= ~(MII_M1111_HWCFG_MODE_MASK);
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300494
Wang Jian7239016d2008-07-16 21:46:20 +0800495 if (temp & MII_M1111_HWCFG_FIBER_COPPER_RES)
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300496 temp |= MII_M1111_HWCFG_MODE_FIBER_RGMII;
497 else
498 temp |= MII_M1111_HWCFG_MODE_COPPER_RGMII;
Kim Phillips895ee682007-06-05 18:46:47 +0800499
500 err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
501 if (err < 0)
502 return err;
503 }
504
Kapil Juneja4117b5b2007-05-11 18:25:18 -0500505 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
Kapil Juneja4117b5b2007-05-11 18:25:18 -0500506 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
507 if (temp < 0)
508 return temp;
509
510 temp &= ~(MII_M1111_HWCFG_MODE_MASK);
511 temp |= MII_M1111_HWCFG_MODE_SGMII_NO_CLK;
Haiying Wang32d0c1e2009-06-02 04:04:13 +0000512 temp |= MII_M1111_HWCFG_FIBER_COPPER_AUTO;
Kapil Juneja4117b5b2007-05-11 18:25:18 -0500513
514 err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
515 if (err < 0)
516 return err;
517 }
518
Liu Yu-B132015f8cbc12010-01-13 22:13:19 +0000519 if (phydev->interface == PHY_INTERFACE_MODE_RTBI) {
520 temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
521 if (temp < 0)
522 return temp;
523 temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
524 err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
525 if (err < 0)
526 return err;
527
528 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
529 if (temp < 0)
530 return temp;
531 temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
532 temp |= 0x7 | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
533 err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
534 if (err < 0)
535 return err;
536
537 /* soft reset */
538 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
539 if (err < 0)
540 return err;
541 do
542 temp = phy_read(phydev, MII_BMCR);
543 while (temp & BMCR_RESET);
544
545 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
546 if (temp < 0)
547 return temp;
548 temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
549 temp |= MII_M1111_HWCFG_MODE_COPPER_RTBI | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
550 err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
551 if (err < 0)
552 return err;
553 }
554
David Daneycf41a512010-11-19 12:13:18 +0000555 err = marvell_of_reg_init(phydev);
556 if (err < 0)
557 return err;
Liu Yu-B132015f8cbc12010-01-13 22:13:19 +0000558
Srinivas Kandagatlacc90cb32012-04-02 06:25:24 +0000559 return phy_write(phydev, MII_BMCR, BMCR_RESET);
Kim Phillips895ee682007-06-05 18:46:47 +0800560}
561
Ron Madrid605f1962008-11-06 09:05:26 +0000562static int m88e1118_config_aneg(struct phy_device *phydev)
563{
564 int err;
565
566 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
567 if (err < 0)
568 return err;
569
570 err = phy_write(phydev, MII_M1011_PHY_SCR,
571 MII_M1011_PHY_SCR_AUTO_CROSS);
572 if (err < 0)
573 return err;
574
575 err = genphy_config_aneg(phydev);
576 return 0;
577}
578
579static int m88e1118_config_init(struct phy_device *phydev)
580{
581 int err;
582
583 /* Change address */
David Daney27d916d2010-11-19 11:58:52 +0000584 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0002);
Ron Madrid605f1962008-11-06 09:05:26 +0000585 if (err < 0)
586 return err;
587
588 /* Enable 1000 Mbit */
589 err = phy_write(phydev, 0x15, 0x1070);
590 if (err < 0)
591 return err;
592
593 /* Change address */
David Daney27d916d2010-11-19 11:58:52 +0000594 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0003);
Ron Madrid605f1962008-11-06 09:05:26 +0000595 if (err < 0)
596 return err;
597
598 /* Adjust LED Control */
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +1000599 if (phydev->dev_flags & MARVELL_PHY_M1118_DNS323_LEDS)
600 err = phy_write(phydev, 0x10, 0x1100);
601 else
602 err = phy_write(phydev, 0x10, 0x021e);
Ron Madrid605f1962008-11-06 09:05:26 +0000603 if (err < 0)
604 return err;
605
David Daneycf41a512010-11-19 12:13:18 +0000606 err = marvell_of_reg_init(phydev);
607 if (err < 0)
608 return err;
609
Ron Madrid605f1962008-11-06 09:05:26 +0000610 /* Reset address */
David Daney27d916d2010-11-19 11:58:52 +0000611 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0);
Ron Madrid605f1962008-11-06 09:05:26 +0000612 if (err < 0)
613 return err;
614
Srinivas Kandagatlacc90cb32012-04-02 06:25:24 +0000615 return phy_write(phydev, MII_BMCR, BMCR_RESET);
Ron Madrid605f1962008-11-06 09:05:26 +0000616}
617
David Daney90600732010-11-19 11:58:53 +0000618static int m88e1149_config_init(struct phy_device *phydev)
619{
620 int err;
621
622 /* Change address */
623 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0002);
624 if (err < 0)
625 return err;
626
627 /* Enable 1000 Mbit */
628 err = phy_write(phydev, 0x15, 0x1048);
629 if (err < 0)
630 return err;
631
David Daneycf41a512010-11-19 12:13:18 +0000632 err = marvell_of_reg_init(phydev);
633 if (err < 0)
634 return err;
635
David Daney90600732010-11-19 11:58:53 +0000636 /* Reset address */
637 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0);
638 if (err < 0)
639 return err;
640
Srinivas Kandagatlacc90cb32012-04-02 06:25:24 +0000641 return phy_write(phydev, MII_BMCR, BMCR_RESET);
David Daney90600732010-11-19 11:58:53 +0000642}
643
Andy Fleming76884672007-02-09 18:13:58 -0600644static int m88e1145_config_init(struct phy_device *phydev)
645{
646 int err;
Viet Nga Daob0224172014-10-23 19:41:53 -0700647 int temp;
Andy Fleming76884672007-02-09 18:13:58 -0600648
649 /* Take care of errata E0 & E1 */
650 err = phy_write(phydev, 0x1d, 0x001b);
651 if (err < 0)
652 return err;
653
654 err = phy_write(phydev, 0x1e, 0x418f);
655 if (err < 0)
656 return err;
657
658 err = phy_write(phydev, 0x1d, 0x0016);
659 if (err < 0)
660 return err;
661
662 err = phy_write(phydev, 0x1e, 0xa2da);
663 if (err < 0)
664 return err;
665
Kim Phillips895ee682007-06-05 18:46:47 +0800666 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
Andy Fleming76884672007-02-09 18:13:58 -0600667 int temp = phy_read(phydev, MII_M1145_PHY_EXT_CR);
668 if (temp < 0)
669 return temp;
670
671 temp |= (MII_M1145_RGMII_RX_DELAY | MII_M1145_RGMII_TX_DELAY);
672
673 err = phy_write(phydev, MII_M1145_PHY_EXT_CR, temp);
674 if (err < 0)
675 return err;
676
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +1000677 if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) {
Andy Fleming76884672007-02-09 18:13:58 -0600678 err = phy_write(phydev, 0x1d, 0x0012);
679 if (err < 0)
680 return err;
681
682 temp = phy_read(phydev, 0x1e);
683 if (temp < 0)
684 return temp;
685
686 temp &= 0xf03f;
687 temp |= 2 << 9; /* 36 ohm */
688 temp |= 2 << 6; /* 39 ohm */
689
690 err = phy_write(phydev, 0x1e, temp);
691 if (err < 0)
692 return err;
693
694 err = phy_write(phydev, 0x1d, 0x3);
695 if (err < 0)
696 return err;
697
698 err = phy_write(phydev, 0x1e, 0x8000);
699 if (err < 0)
700 return err;
701 }
702 }
703
Viet Nga Daob0224172014-10-23 19:41:53 -0700704 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
705 temp = phy_read(phydev, MII_M1145_PHY_EXT_SR);
706 if (temp < 0)
707 return temp;
708
Vince Bridgers99d881f2014-10-26 14:22:24 -0500709 temp &= ~MII_M1145_HWCFG_MODE_MASK;
Viet Nga Daob0224172014-10-23 19:41:53 -0700710 temp |= MII_M1145_HWCFG_MODE_SGMII_NO_CLK;
711 temp |= MII_M1145_HWCFG_FIBER_COPPER_AUTO;
712
713 err = phy_write(phydev, MII_M1145_PHY_EXT_SR, temp);
714 if (err < 0)
715 return err;
716 }
717
David Daneycf41a512010-11-19 12:13:18 +0000718 err = marvell_of_reg_init(phydev);
719 if (err < 0)
720 return err;
721
Andy Fleming76884672007-02-09 18:13:58 -0600722 return 0;
723}
Andy Fleming00db8182005-07-30 19:31:23 -0400724
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300725/* marvell_read_status
726 *
727 * Generic status code does not detect Fiber correctly!
Jeff Garzikf0c88f92008-03-25 23:53:24 -0400728 * Description:
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300729 * Check the link, then figure out the current state
730 * by comparing what we advertise with what the link partner
731 * advertises. Start by checking the gigabit possibilities,
732 * then move on to 10/100.
733 */
734static int marvell_read_status(struct phy_device *phydev)
735{
736 int adv;
737 int err;
738 int lpa;
739 int status = 0;
740
741 /* Update the link, but return if there
742 * was an error */
743 err = genphy_update_link(phydev);
744 if (err)
745 return err;
746
747 if (AUTONEG_ENABLE == phydev->autoneg) {
748 status = phy_read(phydev, MII_M1011_PHY_STATUS);
749 if (status < 0)
750 return status;
751
752 lpa = phy_read(phydev, MII_LPA);
753 if (lpa < 0)
754 return lpa;
755
756 adv = phy_read(phydev, MII_ADVERTISE);
757 if (adv < 0)
758 return adv;
759
760 lpa &= adv;
761
762 if (status & MII_M1011_PHY_STATUS_FULLDUPLEX)
763 phydev->duplex = DUPLEX_FULL;
764 else
765 phydev->duplex = DUPLEX_HALF;
766
767 status = status & MII_M1011_PHY_STATUS_SPD_MASK;
768 phydev->pause = phydev->asym_pause = 0;
769
770 switch (status) {
771 case MII_M1011_PHY_STATUS_1000:
772 phydev->speed = SPEED_1000;
773 break;
774
775 case MII_M1011_PHY_STATUS_100:
776 phydev->speed = SPEED_100;
777 break;
778
779 default:
780 phydev->speed = SPEED_10;
781 break;
782 }
783
784 if (phydev->duplex == DUPLEX_FULL) {
785 phydev->pause = lpa & LPA_PAUSE_CAP ? 1 : 0;
786 phydev->asym_pause = lpa & LPA_PAUSE_ASYM ? 1 : 0;
787 }
788 } else {
789 int bmcr = phy_read(phydev, MII_BMCR);
790
791 if (bmcr < 0)
792 return bmcr;
793
794 if (bmcr & BMCR_FULLDPLX)
795 phydev->duplex = DUPLEX_FULL;
796 else
797 phydev->duplex = DUPLEX_HALF;
798
799 if (bmcr & BMCR_SPEED1000)
800 phydev->speed = SPEED_1000;
801 else if (bmcr & BMCR_SPEED100)
802 phydev->speed = SPEED_100;
803 else
804 phydev->speed = SPEED_10;
805
806 phydev->pause = phydev->asym_pause = 0;
807 }
808
809 return 0;
810}
811
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +0200812static int marvell_aneg_done(struct phy_device *phydev)
813{
814 int retval = phy_read(phydev, MII_M1011_PHY_STATUS);
815 return (retval < 0) ? retval : (retval & MII_M1011_PHY_STATUS_RESOLVED);
816}
817
Anatolij Gustschindcd07be2009-04-07 02:01:43 +0000818static int m88e1121_did_interrupt(struct phy_device *phydev)
819{
820 int imask;
821
822 imask = phy_read(phydev, MII_M1011_IEVENT);
823
824 if (imask & MII_M1011_IMASK_INIT)
825 return 1;
826
827 return 0;
828}
829
Michael Stapelberg3871c382013-03-11 13:56:45 +0000830static void m88e1318_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
831{
832 wol->supported = WAKE_MAGIC;
833 wol->wolopts = 0;
834
835 if (phy_write(phydev, MII_MARVELL_PHY_PAGE,
836 MII_88E1318S_PHY_WOL_PAGE) < 0)
837 return;
838
839 if (phy_read(phydev, MII_88E1318S_PHY_WOL_CTRL) &
840 MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE)
841 wol->wolopts |= WAKE_MAGIC;
842
843 if (phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x00) < 0)
844 return;
845}
846
847static int m88e1318_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
848{
849 int err, oldpage, temp;
850
851 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
852
853 if (wol->wolopts & WAKE_MAGIC) {
854 /* Explicitly switch to page 0x00, just to be sure */
855 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x00);
856 if (err < 0)
857 return err;
858
859 /* Enable the WOL interrupt */
860 temp = phy_read(phydev, MII_88E1318S_PHY_CSIER);
861 temp |= MII_88E1318S_PHY_CSIER_WOL_EIE;
862 err = phy_write(phydev, MII_88E1318S_PHY_CSIER, temp);
863 if (err < 0)
864 return err;
865
866 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
867 MII_88E1318S_PHY_LED_PAGE);
868 if (err < 0)
869 return err;
870
871 /* Setup LED[2] as interrupt pin (active low) */
872 temp = phy_read(phydev, MII_88E1318S_PHY_LED_TCR);
873 temp &= ~MII_88E1318S_PHY_LED_TCR_FORCE_INT;
874 temp |= MII_88E1318S_PHY_LED_TCR_INTn_ENABLE;
875 temp |= MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW;
876 err = phy_write(phydev, MII_88E1318S_PHY_LED_TCR, temp);
877 if (err < 0)
878 return err;
879
880 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
881 MII_88E1318S_PHY_WOL_PAGE);
882 if (err < 0)
883 return err;
884
885 /* Store the device address for the magic packet */
886 err = phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD2,
887 ((phydev->attached_dev->dev_addr[5] << 8) |
888 phydev->attached_dev->dev_addr[4]));
889 if (err < 0)
890 return err;
891 err = phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD1,
892 ((phydev->attached_dev->dev_addr[3] << 8) |
893 phydev->attached_dev->dev_addr[2]));
894 if (err < 0)
895 return err;
896 err = phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD0,
897 ((phydev->attached_dev->dev_addr[1] << 8) |
898 phydev->attached_dev->dev_addr[0]));
899 if (err < 0)
900 return err;
901
902 /* Clear WOL status and enable magic packet matching */
903 temp = phy_read(phydev, MII_88E1318S_PHY_WOL_CTRL);
904 temp |= MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS;
905 temp |= MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE;
906 err = phy_write(phydev, MII_88E1318S_PHY_WOL_CTRL, temp);
907 if (err < 0)
908 return err;
909 } else {
910 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
911 MII_88E1318S_PHY_WOL_PAGE);
912 if (err < 0)
913 return err;
914
915 /* Clear WOL status and disable magic packet matching */
916 temp = phy_read(phydev, MII_88E1318S_PHY_WOL_CTRL);
917 temp |= MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS;
918 temp &= ~MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE;
919 err = phy_write(phydev, MII_88E1318S_PHY_WOL_CTRL, temp);
920 if (err < 0)
921 return err;
922 }
923
924 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
925 if (err < 0)
926 return err;
927
928 return 0;
929}
930
Olof Johanssone5479232007-07-03 16:23:46 -0500931static struct phy_driver marvell_drivers[] = {
932 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +1000933 .phy_id = MARVELL_PHY_ID_88E1101,
934 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johanssone5479232007-07-03 16:23:46 -0500935 .name = "Marvell 88E1101",
936 .features = PHY_GBIT_FEATURES,
937 .flags = PHY_HAS_INTERRUPT,
938 .config_aneg = &marvell_config_aneg,
939 .read_status = &genphy_read_status,
940 .ack_interrupt = &marvell_ack_interrupt,
941 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +0100942 .resume = &genphy_resume,
943 .suspend = &genphy_suspend,
Olof Johanssonac8c6352007-11-04 16:08:51 -0600944 .driver = { .owner = THIS_MODULE },
Olof Johanssone5479232007-07-03 16:23:46 -0500945 },
946 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +1000947 .phy_id = MARVELL_PHY_ID_88E1112,
948 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johansson85cfb532007-07-03 16:24:32 -0500949 .name = "Marvell 88E1112",
950 .features = PHY_GBIT_FEATURES,
951 .flags = PHY_HAS_INTERRUPT,
952 .config_init = &m88e1111_config_init,
953 .config_aneg = &marvell_config_aneg,
954 .read_status = &genphy_read_status,
955 .ack_interrupt = &marvell_ack_interrupt,
956 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +0100957 .resume = &genphy_resume,
958 .suspend = &genphy_suspend,
Olof Johanssonac8c6352007-11-04 16:08:51 -0600959 .driver = { .owner = THIS_MODULE },
Olof Johansson85cfb532007-07-03 16:24:32 -0500960 },
961 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +1000962 .phy_id = MARVELL_PHY_ID_88E1111,
963 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johanssone5479232007-07-03 16:23:46 -0500964 .name = "Marvell 88E1111",
965 .features = PHY_GBIT_FEATURES,
966 .flags = PHY_HAS_INTERRUPT,
967 .config_init = &m88e1111_config_init,
968 .config_aneg = &marvell_config_aneg,
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300969 .read_status = &marvell_read_status,
Olof Johanssone5479232007-07-03 16:23:46 -0500970 .ack_interrupt = &marvell_ack_interrupt,
971 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +0100972 .resume = &genphy_resume,
973 .suspend = &genphy_suspend,
Olof Johanssonac8c6352007-11-04 16:08:51 -0600974 .driver = { .owner = THIS_MODULE },
Olof Johanssone5479232007-07-03 16:23:46 -0500975 },
976 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +1000977 .phy_id = MARVELL_PHY_ID_88E1118,
978 .phy_id_mask = MARVELL_PHY_ID_MASK,
Ron Madrid605f1962008-11-06 09:05:26 +0000979 .name = "Marvell 88E1118",
980 .features = PHY_GBIT_FEATURES,
981 .flags = PHY_HAS_INTERRUPT,
982 .config_init = &m88e1118_config_init,
983 .config_aneg = &m88e1118_config_aneg,
984 .read_status = &genphy_read_status,
985 .ack_interrupt = &marvell_ack_interrupt,
986 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +0100987 .resume = &genphy_resume,
988 .suspend = &genphy_suspend,
Ron Madrid605f1962008-11-06 09:05:26 +0000989 .driver = {.owner = THIS_MODULE,},
990 },
991 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +1000992 .phy_id = MARVELL_PHY_ID_88E1121R,
993 .phy_id_mask = MARVELL_PHY_ID_MASK,
Sergei Poselenov140bc922009-04-07 02:01:41 +0000994 .name = "Marvell 88E1121R",
995 .features = PHY_GBIT_FEATURES,
996 .flags = PHY_HAS_INTERRUPT,
997 .config_aneg = &m88e1121_config_aneg,
998 .read_status = &marvell_read_status,
999 .ack_interrupt = &marvell_ack_interrupt,
1000 .config_intr = &marvell_config_intr,
Anatolij Gustschindcd07be2009-04-07 02:01:43 +00001001 .did_interrupt = &m88e1121_did_interrupt,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001002 .resume = &genphy_resume,
1003 .suspend = &genphy_suspend,
Sergei Poselenov140bc922009-04-07 02:01:41 +00001004 .driver = { .owner = THIS_MODULE },
1005 },
1006 {
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -07001007 .phy_id = MARVELL_PHY_ID_88E1318S,
Linus Torvalds6ba74012010-08-04 11:47:58 -07001008 .phy_id_mask = MARVELL_PHY_ID_MASK,
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -07001009 .name = "Marvell 88E1318S",
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -07001010 .features = PHY_GBIT_FEATURES,
1011 .flags = PHY_HAS_INTERRUPT,
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -07001012 .config_aneg = &m88e1318_config_aneg,
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -07001013 .read_status = &marvell_read_status,
1014 .ack_interrupt = &marvell_ack_interrupt,
1015 .config_intr = &marvell_config_intr,
1016 .did_interrupt = &m88e1121_did_interrupt,
Michael Stapelberg3871c382013-03-11 13:56:45 +00001017 .get_wol = &m88e1318_get_wol,
1018 .set_wol = &m88e1318_set_wol,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001019 .resume = &genphy_resume,
1020 .suspend = &genphy_suspend,
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -07001021 .driver = { .owner = THIS_MODULE },
1022 },
1023 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +10001024 .phy_id = MARVELL_PHY_ID_88E1145,
1025 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johanssone5479232007-07-03 16:23:46 -05001026 .name = "Marvell 88E1145",
1027 .features = PHY_GBIT_FEATURES,
1028 .flags = PHY_HAS_INTERRUPT,
1029 .config_init = &m88e1145_config_init,
1030 .config_aneg = &marvell_config_aneg,
1031 .read_status = &genphy_read_status,
1032 .ack_interrupt = &marvell_ack_interrupt,
1033 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001034 .resume = &genphy_resume,
1035 .suspend = &genphy_suspend,
Olof Johanssonac8c6352007-11-04 16:08:51 -06001036 .driver = { .owner = THIS_MODULE },
1037 },
1038 {
David Daney90600732010-11-19 11:58:53 +00001039 .phy_id = MARVELL_PHY_ID_88E1149R,
1040 .phy_id_mask = MARVELL_PHY_ID_MASK,
1041 .name = "Marvell 88E1149R",
1042 .features = PHY_GBIT_FEATURES,
1043 .flags = PHY_HAS_INTERRUPT,
1044 .config_init = &m88e1149_config_init,
1045 .config_aneg = &m88e1118_config_aneg,
1046 .read_status = &genphy_read_status,
1047 .ack_interrupt = &marvell_ack_interrupt,
1048 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001049 .resume = &genphy_resume,
1050 .suspend = &genphy_suspend,
David Daney90600732010-11-19 11:58:53 +00001051 .driver = { .owner = THIS_MODULE },
1052 },
1053 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +10001054 .phy_id = MARVELL_PHY_ID_88E1240,
1055 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johanssonac8c6352007-11-04 16:08:51 -06001056 .name = "Marvell 88E1240",
1057 .features = PHY_GBIT_FEATURES,
1058 .flags = PHY_HAS_INTERRUPT,
1059 .config_init = &m88e1111_config_init,
1060 .config_aneg = &marvell_config_aneg,
1061 .read_status = &genphy_read_status,
1062 .ack_interrupt = &marvell_ack_interrupt,
1063 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001064 .resume = &genphy_resume,
1065 .suspend = &genphy_suspend,
Olof Johanssonac8c6352007-11-04 16:08:51 -06001066 .driver = { .owner = THIS_MODULE },
1067 },
Michal Simek3da09a52013-05-30 20:08:26 +00001068 {
1069 .phy_id = MARVELL_PHY_ID_88E1116R,
1070 .phy_id_mask = MARVELL_PHY_ID_MASK,
1071 .name = "Marvell 88E1116R",
1072 .features = PHY_GBIT_FEATURES,
1073 .flags = PHY_HAS_INTERRUPT,
1074 .config_init = &m88e1116r_config_init,
1075 .config_aneg = &genphy_config_aneg,
1076 .read_status = &genphy_read_status,
1077 .ack_interrupt = &marvell_ack_interrupt,
1078 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001079 .resume = &genphy_resume,
1080 .suspend = &genphy_suspend,
Michal Simek3da09a52013-05-30 20:08:26 +00001081 .driver = { .owner = THIS_MODULE },
1082 },
Michal Simek10e24caa2013-05-30 20:08:27 +00001083 {
1084 .phy_id = MARVELL_PHY_ID_88E1510,
1085 .phy_id_mask = MARVELL_PHY_ID_MASK,
1086 .name = "Marvell 88E1510",
1087 .features = PHY_GBIT_FEATURES,
1088 .flags = PHY_HAS_INTERRUPT,
1089 .config_aneg = &m88e1510_config_aneg,
1090 .read_status = &marvell_read_status,
1091 .ack_interrupt = &marvell_ack_interrupt,
1092 .config_intr = &marvell_config_intr,
1093 .did_interrupt = &m88e1121_did_interrupt,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001094 .resume = &genphy_resume,
1095 .suspend = &genphy_suspend,
Michal Simek10e24caa2013-05-30 20:08:27 +00001096 .driver = { .owner = THIS_MODULE },
1097 },
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +02001098 {
1099 .phy_id = MARVELL_PHY_ID_88E3016,
1100 .phy_id_mask = MARVELL_PHY_ID_MASK,
1101 .name = "Marvell 88E3016",
1102 .features = PHY_BASIC_FEATURES,
1103 .flags = PHY_HAS_INTERRUPT,
1104 .config_aneg = &genphy_config_aneg,
1105 .config_init = &m88e3016_config_init,
1106 .aneg_done = &marvell_aneg_done,
1107 .read_status = &marvell_read_status,
1108 .ack_interrupt = &marvell_ack_interrupt,
1109 .config_intr = &marvell_config_intr,
1110 .did_interrupt = &m88e1121_did_interrupt,
1111 .resume = &genphy_resume,
1112 .suspend = &genphy_suspend,
1113 .driver = { .owner = THIS_MODULE },
1114 },
Andy Fleming00db8182005-07-30 19:31:23 -04001115};
1116
Johan Hovold50fd7152014-11-11 19:45:59 +01001117module_phy_driver(marvell_drivers);
David Woodhouse4e4f10f2010-04-02 01:05:56 +00001118
Uwe Kleine-Königcf93c942010-10-03 23:43:32 +00001119static struct mdio_device_id __maybe_unused marvell_tbl[] = {
Michal Simekf5e1cab2013-05-30 20:08:25 +00001120 { MARVELL_PHY_ID_88E1101, MARVELL_PHY_ID_MASK },
1121 { MARVELL_PHY_ID_88E1112, MARVELL_PHY_ID_MASK },
1122 { MARVELL_PHY_ID_88E1111, MARVELL_PHY_ID_MASK },
1123 { MARVELL_PHY_ID_88E1118, MARVELL_PHY_ID_MASK },
1124 { MARVELL_PHY_ID_88E1121R, MARVELL_PHY_ID_MASK },
1125 { MARVELL_PHY_ID_88E1145, MARVELL_PHY_ID_MASK },
1126 { MARVELL_PHY_ID_88E1149R, MARVELL_PHY_ID_MASK },
1127 { MARVELL_PHY_ID_88E1240, MARVELL_PHY_ID_MASK },
1128 { MARVELL_PHY_ID_88E1318S, MARVELL_PHY_ID_MASK },
Michal Simek3da09a52013-05-30 20:08:26 +00001129 { MARVELL_PHY_ID_88E1116R, MARVELL_PHY_ID_MASK },
Michal Simek10e24caa2013-05-30 20:08:27 +00001130 { MARVELL_PHY_ID_88E1510, MARVELL_PHY_ID_MASK },
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +02001131 { MARVELL_PHY_ID_88E3016, MARVELL_PHY_ID_MASK },
David Woodhouse4e4f10f2010-04-02 01:05:56 +00001132 { }
1133};
1134
1135MODULE_DEVICE_TABLE(mdio, marvell_tbl);