blob: 1b1698f98818219c623038c8781dc2e806a3070d [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
Arnaud Patardbe8c6482010-10-21 03:59:57 -0700320 if ((phydev->interface == PHY_INTERFACE_MODE_RGMII) ||
321 (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) ||
322 (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) ||
323 (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)) {
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000324
Arnaud Patardbe8c6482010-10-21 03:59:57 -0700325 mscr = phy_read(phydev, MII_88E1121_PHY_MSCR_REG) &
326 MII_88E1121_PHY_MSCR_DELAY_MASK;
327
328 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
329 mscr |= (MII_88E1121_PHY_MSCR_RX_DELAY |
330 MII_88E1121_PHY_MSCR_TX_DELAY);
331 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID)
332 mscr |= MII_88E1121_PHY_MSCR_RX_DELAY;
333 else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
334 mscr |= MII_88E1121_PHY_MSCR_TX_DELAY;
335
336 err = phy_write(phydev, MII_88E1121_PHY_MSCR_REG, mscr);
337 if (err < 0)
338 return err;
339 }
Cyril Chemparathyc477d042010-08-02 09:44:53 +0000340
David Daney27d916d2010-11-19 11:58:52 +0000341 phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
Sergei Poselenov140bc922009-04-07 02:01:41 +0000342
343 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
344 if (err < 0)
345 return err;
346
347 err = phy_write(phydev, MII_M1011_PHY_SCR,
348 MII_M1011_PHY_SCR_AUTO_CROSS);
349 if (err < 0)
350 return err;
351
David Daney27d916d2010-11-19 11:58:52 +0000352 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
Sergei Poselenov140bc922009-04-07 02:01:41 +0000353
David Daney27d916d2010-11-19 11:58:52 +0000354 phy_write(phydev, MII_MARVELL_PHY_PAGE, MII_88E1121_PHY_LED_PAGE);
Sergei Poselenov140bc922009-04-07 02:01:41 +0000355 phy_write(phydev, MII_88E1121_PHY_LED_CTRL, MII_88E1121_PHY_LED_DEF);
David Daney27d916d2010-11-19 11:58:52 +0000356 phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
Sergei Poselenov140bc922009-04-07 02:01:41 +0000357
358 err = genphy_config_aneg(phydev);
359
360 return err;
361}
362
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -0700363static int m88e1318_config_aneg(struct phy_device *phydev)
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700364{
365 int err, oldpage, mscr;
366
David Daney27d916d2010-11-19 11:58:52 +0000367 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700368
David Daney27d916d2010-11-19 11:58:52 +0000369 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700370 MII_88E1121_PHY_MSCR_PAGE);
371 if (err < 0)
372 return err;
373
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -0700374 mscr = phy_read(phydev, MII_88E1318S_PHY_MSCR1_REG);
375 mscr |= MII_88E1318S_PHY_MSCR1_PAD_ODD;
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700376
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -0700377 err = phy_write(phydev, MII_88E1318S_PHY_MSCR1_REG, mscr);
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700378 if (err < 0)
379 return err;
380
David Daney27d916d2010-11-19 11:58:52 +0000381 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -0700382 if (err < 0)
383 return err;
384
385 return m88e1121_config_aneg(phydev);
386}
387
Michal Simek10e24caa2013-05-30 20:08:27 +0000388static int m88e1510_config_aneg(struct phy_device *phydev)
389{
390 int err;
391
392 err = m88e1318_config_aneg(phydev);
393 if (err < 0)
394 return err;
395
396 return marvell_of_reg_init(phydev);
397}
398
Michal Simek3da09a52013-05-30 20:08:26 +0000399static int m88e1116r_config_init(struct phy_device *phydev)
400{
401 int temp;
402 int err;
403
404 temp = phy_read(phydev, MII_BMCR);
405 temp |= BMCR_RESET;
406 err = phy_write(phydev, MII_BMCR, temp);
407 if (err < 0)
408 return err;
409
410 mdelay(500);
411
412 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0);
413 if (err < 0)
414 return err;
415
416 temp = phy_read(phydev, MII_M1011_PHY_SCR);
417 temp |= (7 << 12); /* max number of gigabit attempts */
418 temp |= (1 << 11); /* enable downshift */
419 temp |= MII_M1011_PHY_SCR_AUTO_CROSS;
420 err = phy_write(phydev, MII_M1011_PHY_SCR, temp);
421 if (err < 0)
422 return err;
423
424 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 2);
425 if (err < 0)
426 return err;
427 temp = phy_read(phydev, MII_M1116R_CONTROL_REG_MAC);
428 temp |= (1 << 5);
429 temp |= (1 << 4);
430 err = phy_write(phydev, MII_M1116R_CONTROL_REG_MAC, temp);
431 if (err < 0)
432 return err;
433 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0);
434 if (err < 0)
435 return err;
436
437 temp = phy_read(phydev, MII_BMCR);
438 temp |= BMCR_RESET;
439 err = phy_write(phydev, MII_BMCR, temp);
440 if (err < 0)
441 return err;
442
443 mdelay(500);
444
445 return 0;
446}
447
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +0200448static int m88e3016_config_init(struct phy_device *phydev)
449{
450 int reg;
451
452 /* Enable Scrambler and Auto-Crossover */
453 reg = phy_read(phydev, MII_88E3016_PHY_SPEC_CTRL);
454 if (reg < 0)
455 return reg;
456
457 reg &= ~MII_88E3016_DISABLE_SCRAMBLER;
458 reg |= MII_88E3016_AUTO_MDIX_CROSSOVER;
459
460 reg = phy_write(phydev, MII_88E3016_PHY_SPEC_CTRL, reg);
461 if (reg < 0)
462 return reg;
463
464 return 0;
465}
466
Kim Phillips895ee682007-06-05 18:46:47 +0800467static int m88e1111_config_init(struct phy_device *phydev)
468{
469 int err;
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300470 int temp;
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300471
Kim Phillips895ee682007-06-05 18:46:47 +0800472 if ((phydev->interface == PHY_INTERFACE_MODE_RGMII) ||
Kim Phillips9daf5a72007-11-26 16:17:52 -0600473 (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) ||
474 (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) ||
475 (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)) {
Kim Phillips895ee682007-06-05 18:46:47 +0800476
Kim Phillips9daf5a72007-11-26 16:17:52 -0600477 temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
478 if (temp < 0)
479 return temp;
480
Kim Phillips895ee682007-06-05 18:46:47 +0800481 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
Kim Phillips895ee682007-06-05 18:46:47 +0800482 temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
Kim Phillips9daf5a72007-11-26 16:17:52 -0600483 } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) {
484 temp &= ~MII_M1111_TX_DELAY;
485 temp |= MII_M1111_RX_DELAY;
486 } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
487 temp &= ~MII_M1111_RX_DELAY;
488 temp |= MII_M1111_TX_DELAY;
Kim Phillips895ee682007-06-05 18:46:47 +0800489 }
490
Kim Phillips9daf5a72007-11-26 16:17:52 -0600491 err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
492 if (err < 0)
493 return err;
494
Kim Phillips895ee682007-06-05 18:46:47 +0800495 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
496 if (temp < 0)
497 return temp;
498
499 temp &= ~(MII_M1111_HWCFG_MODE_MASK);
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300500
Wang Jian7239016d2008-07-16 21:46:20 +0800501 if (temp & MII_M1111_HWCFG_FIBER_COPPER_RES)
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300502 temp |= MII_M1111_HWCFG_MODE_FIBER_RGMII;
503 else
504 temp |= MII_M1111_HWCFG_MODE_COPPER_RGMII;
Kim Phillips895ee682007-06-05 18:46:47 +0800505
506 err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
507 if (err < 0)
508 return err;
509 }
510
Kapil Juneja4117b5b2007-05-11 18:25:18 -0500511 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
Kapil Juneja4117b5b2007-05-11 18:25:18 -0500512 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
513 if (temp < 0)
514 return temp;
515
516 temp &= ~(MII_M1111_HWCFG_MODE_MASK);
517 temp |= MII_M1111_HWCFG_MODE_SGMII_NO_CLK;
Haiying Wang32d0c1e2009-06-02 04:04:13 +0000518 temp |= MII_M1111_HWCFG_FIBER_COPPER_AUTO;
Kapil Juneja4117b5b2007-05-11 18:25:18 -0500519
520 err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
521 if (err < 0)
522 return err;
523 }
524
Liu Yu-B132015f8cbc12010-01-13 22:13:19 +0000525 if (phydev->interface == PHY_INTERFACE_MODE_RTBI) {
526 temp = phy_read(phydev, MII_M1111_PHY_EXT_CR);
527 if (temp < 0)
528 return temp;
529 temp |= (MII_M1111_RX_DELAY | MII_M1111_TX_DELAY);
530 err = phy_write(phydev, MII_M1111_PHY_EXT_CR, temp);
531 if (err < 0)
532 return err;
533
534 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
535 if (temp < 0)
536 return temp;
537 temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
538 temp |= 0x7 | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
539 err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
540 if (err < 0)
541 return err;
542
543 /* soft reset */
544 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
545 if (err < 0)
546 return err;
547 do
548 temp = phy_read(phydev, MII_BMCR);
549 while (temp & BMCR_RESET);
550
551 temp = phy_read(phydev, MII_M1111_PHY_EXT_SR);
552 if (temp < 0)
553 return temp;
554 temp &= ~(MII_M1111_HWCFG_MODE_MASK | MII_M1111_HWCFG_FIBER_COPPER_RES);
555 temp |= MII_M1111_HWCFG_MODE_COPPER_RTBI | MII_M1111_HWCFG_FIBER_COPPER_AUTO;
556 err = phy_write(phydev, MII_M1111_PHY_EXT_SR, temp);
557 if (err < 0)
558 return err;
559 }
560
David Daneycf41a512010-11-19 12:13:18 +0000561 err = marvell_of_reg_init(phydev);
562 if (err < 0)
563 return err;
Liu Yu-B132015f8cbc12010-01-13 22:13:19 +0000564
Srinivas Kandagatlacc90cb32012-04-02 06:25:24 +0000565 return phy_write(phydev, MII_BMCR, BMCR_RESET);
Kim Phillips895ee682007-06-05 18:46:47 +0800566}
567
Ron Madrid605f1962008-11-06 09:05:26 +0000568static int m88e1118_config_aneg(struct phy_device *phydev)
569{
570 int err;
571
572 err = phy_write(phydev, MII_BMCR, BMCR_RESET);
573 if (err < 0)
574 return err;
575
576 err = phy_write(phydev, MII_M1011_PHY_SCR,
577 MII_M1011_PHY_SCR_AUTO_CROSS);
578 if (err < 0)
579 return err;
580
581 err = genphy_config_aneg(phydev);
582 return 0;
583}
584
585static int m88e1118_config_init(struct phy_device *phydev)
586{
587 int err;
588
589 /* Change address */
David Daney27d916d2010-11-19 11:58:52 +0000590 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0002);
Ron Madrid605f1962008-11-06 09:05:26 +0000591 if (err < 0)
592 return err;
593
594 /* Enable 1000 Mbit */
595 err = phy_write(phydev, 0x15, 0x1070);
596 if (err < 0)
597 return err;
598
599 /* Change address */
David Daney27d916d2010-11-19 11:58:52 +0000600 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0003);
Ron Madrid605f1962008-11-06 09:05:26 +0000601 if (err < 0)
602 return err;
603
604 /* Adjust LED Control */
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +1000605 if (phydev->dev_flags & MARVELL_PHY_M1118_DNS323_LEDS)
606 err = phy_write(phydev, 0x10, 0x1100);
607 else
608 err = phy_write(phydev, 0x10, 0x021e);
Ron Madrid605f1962008-11-06 09:05:26 +0000609 if (err < 0)
610 return err;
611
David Daneycf41a512010-11-19 12:13:18 +0000612 err = marvell_of_reg_init(phydev);
613 if (err < 0)
614 return err;
615
Ron Madrid605f1962008-11-06 09:05:26 +0000616 /* Reset address */
David Daney27d916d2010-11-19 11:58:52 +0000617 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0);
Ron Madrid605f1962008-11-06 09:05:26 +0000618 if (err < 0)
619 return err;
620
Srinivas Kandagatlacc90cb32012-04-02 06:25:24 +0000621 return phy_write(phydev, MII_BMCR, BMCR_RESET);
Ron Madrid605f1962008-11-06 09:05:26 +0000622}
623
David Daney90600732010-11-19 11:58:53 +0000624static int m88e1149_config_init(struct phy_device *phydev)
625{
626 int err;
627
628 /* Change address */
629 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0002);
630 if (err < 0)
631 return err;
632
633 /* Enable 1000 Mbit */
634 err = phy_write(phydev, 0x15, 0x1048);
635 if (err < 0)
636 return err;
637
David Daneycf41a512010-11-19 12:13:18 +0000638 err = marvell_of_reg_init(phydev);
639 if (err < 0)
640 return err;
641
David Daney90600732010-11-19 11:58:53 +0000642 /* Reset address */
643 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x0);
644 if (err < 0)
645 return err;
646
Srinivas Kandagatlacc90cb32012-04-02 06:25:24 +0000647 return phy_write(phydev, MII_BMCR, BMCR_RESET);
David Daney90600732010-11-19 11:58:53 +0000648}
649
Andy Fleming76884672007-02-09 18:13:58 -0600650static int m88e1145_config_init(struct phy_device *phydev)
651{
652 int err;
Viet Nga Daob0224172014-10-23 19:41:53 -0700653 int temp;
Andy Fleming76884672007-02-09 18:13:58 -0600654
655 /* Take care of errata E0 & E1 */
656 err = phy_write(phydev, 0x1d, 0x001b);
657 if (err < 0)
658 return err;
659
660 err = phy_write(phydev, 0x1e, 0x418f);
661 if (err < 0)
662 return err;
663
664 err = phy_write(phydev, 0x1d, 0x0016);
665 if (err < 0)
666 return err;
667
668 err = phy_write(phydev, 0x1e, 0xa2da);
669 if (err < 0)
670 return err;
671
Kim Phillips895ee682007-06-05 18:46:47 +0800672 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) {
Andy Fleming76884672007-02-09 18:13:58 -0600673 int temp = phy_read(phydev, MII_M1145_PHY_EXT_CR);
674 if (temp < 0)
675 return temp;
676
677 temp |= (MII_M1145_RGMII_RX_DELAY | MII_M1145_RGMII_TX_DELAY);
678
679 err = phy_write(phydev, MII_M1145_PHY_EXT_CR, temp);
680 if (err < 0)
681 return err;
682
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +1000683 if (phydev->dev_flags & MARVELL_PHY_M1145_FLAGS_RESISTANCE) {
Andy Fleming76884672007-02-09 18:13:58 -0600684 err = phy_write(phydev, 0x1d, 0x0012);
685 if (err < 0)
686 return err;
687
688 temp = phy_read(phydev, 0x1e);
689 if (temp < 0)
690 return temp;
691
692 temp &= 0xf03f;
693 temp |= 2 << 9; /* 36 ohm */
694 temp |= 2 << 6; /* 39 ohm */
695
696 err = phy_write(phydev, 0x1e, temp);
697 if (err < 0)
698 return err;
699
700 err = phy_write(phydev, 0x1d, 0x3);
701 if (err < 0)
702 return err;
703
704 err = phy_write(phydev, 0x1e, 0x8000);
705 if (err < 0)
706 return err;
707 }
708 }
709
Viet Nga Daob0224172014-10-23 19:41:53 -0700710 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
711 temp = phy_read(phydev, MII_M1145_PHY_EXT_SR);
712 if (temp < 0)
713 return temp;
714
Vince Bridgers99d881f2014-10-26 14:22:24 -0500715 temp &= ~MII_M1145_HWCFG_MODE_MASK;
Viet Nga Daob0224172014-10-23 19:41:53 -0700716 temp |= MII_M1145_HWCFG_MODE_SGMII_NO_CLK;
717 temp |= MII_M1145_HWCFG_FIBER_COPPER_AUTO;
718
719 err = phy_write(phydev, MII_M1145_PHY_EXT_SR, temp);
720 if (err < 0)
721 return err;
722 }
723
David Daneycf41a512010-11-19 12:13:18 +0000724 err = marvell_of_reg_init(phydev);
725 if (err < 0)
726 return err;
727
Andy Fleming76884672007-02-09 18:13:58 -0600728 return 0;
729}
Andy Fleming00db8182005-07-30 19:31:23 -0400730
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300731/* marvell_read_status
732 *
733 * Generic status code does not detect Fiber correctly!
Jeff Garzikf0c88f92008-03-25 23:53:24 -0400734 * Description:
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300735 * Check the link, then figure out the current state
736 * by comparing what we advertise with what the link partner
737 * advertises. Start by checking the gigabit possibilities,
738 * then move on to 10/100.
739 */
740static int marvell_read_status(struct phy_device *phydev)
741{
742 int adv;
743 int err;
744 int lpa;
745 int status = 0;
746
747 /* Update the link, but return if there
748 * was an error */
749 err = genphy_update_link(phydev);
750 if (err)
751 return err;
752
753 if (AUTONEG_ENABLE == phydev->autoneg) {
754 status = phy_read(phydev, MII_M1011_PHY_STATUS);
755 if (status < 0)
756 return status;
757
758 lpa = phy_read(phydev, MII_LPA);
759 if (lpa < 0)
760 return lpa;
761
762 adv = phy_read(phydev, MII_ADVERTISE);
763 if (adv < 0)
764 return adv;
765
766 lpa &= adv;
767
768 if (status & MII_M1011_PHY_STATUS_FULLDUPLEX)
769 phydev->duplex = DUPLEX_FULL;
770 else
771 phydev->duplex = DUPLEX_HALF;
772
773 status = status & MII_M1011_PHY_STATUS_SPD_MASK;
774 phydev->pause = phydev->asym_pause = 0;
775
776 switch (status) {
777 case MII_M1011_PHY_STATUS_1000:
778 phydev->speed = SPEED_1000;
779 break;
780
781 case MII_M1011_PHY_STATUS_100:
782 phydev->speed = SPEED_100;
783 break;
784
785 default:
786 phydev->speed = SPEED_10;
787 break;
788 }
789
790 if (phydev->duplex == DUPLEX_FULL) {
791 phydev->pause = lpa & LPA_PAUSE_CAP ? 1 : 0;
792 phydev->asym_pause = lpa & LPA_PAUSE_ASYM ? 1 : 0;
793 }
794 } else {
795 int bmcr = phy_read(phydev, MII_BMCR);
796
797 if (bmcr < 0)
798 return bmcr;
799
800 if (bmcr & BMCR_FULLDPLX)
801 phydev->duplex = DUPLEX_FULL;
802 else
803 phydev->duplex = DUPLEX_HALF;
804
805 if (bmcr & BMCR_SPEED1000)
806 phydev->speed = SPEED_1000;
807 else if (bmcr & BMCR_SPEED100)
808 phydev->speed = SPEED_100;
809 else
810 phydev->speed = SPEED_10;
811
812 phydev->pause = phydev->asym_pause = 0;
813 }
814
815 return 0;
816}
817
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +0200818static int marvell_aneg_done(struct phy_device *phydev)
819{
820 int retval = phy_read(phydev, MII_M1011_PHY_STATUS);
821 return (retval < 0) ? retval : (retval & MII_M1011_PHY_STATUS_RESOLVED);
822}
823
Anatolij Gustschindcd07be2009-04-07 02:01:43 +0000824static int m88e1121_did_interrupt(struct phy_device *phydev)
825{
826 int imask;
827
828 imask = phy_read(phydev, MII_M1011_IEVENT);
829
830 if (imask & MII_M1011_IMASK_INIT)
831 return 1;
832
833 return 0;
834}
835
Michael Stapelberg3871c382013-03-11 13:56:45 +0000836static void m88e1318_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
837{
838 wol->supported = WAKE_MAGIC;
839 wol->wolopts = 0;
840
841 if (phy_write(phydev, MII_MARVELL_PHY_PAGE,
842 MII_88E1318S_PHY_WOL_PAGE) < 0)
843 return;
844
845 if (phy_read(phydev, MII_88E1318S_PHY_WOL_CTRL) &
846 MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE)
847 wol->wolopts |= WAKE_MAGIC;
848
849 if (phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x00) < 0)
850 return;
851}
852
853static int m88e1318_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
854{
855 int err, oldpage, temp;
856
857 oldpage = phy_read(phydev, MII_MARVELL_PHY_PAGE);
858
859 if (wol->wolopts & WAKE_MAGIC) {
860 /* Explicitly switch to page 0x00, just to be sure */
861 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, 0x00);
862 if (err < 0)
863 return err;
864
865 /* Enable the WOL interrupt */
866 temp = phy_read(phydev, MII_88E1318S_PHY_CSIER);
867 temp |= MII_88E1318S_PHY_CSIER_WOL_EIE;
868 err = phy_write(phydev, MII_88E1318S_PHY_CSIER, temp);
869 if (err < 0)
870 return err;
871
872 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
873 MII_88E1318S_PHY_LED_PAGE);
874 if (err < 0)
875 return err;
876
877 /* Setup LED[2] as interrupt pin (active low) */
878 temp = phy_read(phydev, MII_88E1318S_PHY_LED_TCR);
879 temp &= ~MII_88E1318S_PHY_LED_TCR_FORCE_INT;
880 temp |= MII_88E1318S_PHY_LED_TCR_INTn_ENABLE;
881 temp |= MII_88E1318S_PHY_LED_TCR_INT_ACTIVE_LOW;
882 err = phy_write(phydev, MII_88E1318S_PHY_LED_TCR, temp);
883 if (err < 0)
884 return err;
885
886 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
887 MII_88E1318S_PHY_WOL_PAGE);
888 if (err < 0)
889 return err;
890
891 /* Store the device address for the magic packet */
892 err = phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD2,
893 ((phydev->attached_dev->dev_addr[5] << 8) |
894 phydev->attached_dev->dev_addr[4]));
895 if (err < 0)
896 return err;
897 err = phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD1,
898 ((phydev->attached_dev->dev_addr[3] << 8) |
899 phydev->attached_dev->dev_addr[2]));
900 if (err < 0)
901 return err;
902 err = phy_write(phydev, MII_88E1318S_PHY_MAGIC_PACKET_WORD0,
903 ((phydev->attached_dev->dev_addr[1] << 8) |
904 phydev->attached_dev->dev_addr[0]));
905 if (err < 0)
906 return err;
907
908 /* Clear WOL status and enable magic packet matching */
909 temp = phy_read(phydev, MII_88E1318S_PHY_WOL_CTRL);
910 temp |= MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS;
911 temp |= MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE;
912 err = phy_write(phydev, MII_88E1318S_PHY_WOL_CTRL, temp);
913 if (err < 0)
914 return err;
915 } else {
916 err = phy_write(phydev, MII_MARVELL_PHY_PAGE,
917 MII_88E1318S_PHY_WOL_PAGE);
918 if (err < 0)
919 return err;
920
921 /* Clear WOL status and disable magic packet matching */
922 temp = phy_read(phydev, MII_88E1318S_PHY_WOL_CTRL);
923 temp |= MII_88E1318S_PHY_WOL_CTRL_CLEAR_WOL_STATUS;
924 temp &= ~MII_88E1318S_PHY_WOL_CTRL_MAGIC_PACKET_MATCH_ENABLE;
925 err = phy_write(phydev, MII_88E1318S_PHY_WOL_CTRL, temp);
926 if (err < 0)
927 return err;
928 }
929
930 err = phy_write(phydev, MII_MARVELL_PHY_PAGE, oldpage);
931 if (err < 0)
932 return err;
933
934 return 0;
935}
936
Olof Johanssone5479232007-07-03 16:23:46 -0500937static struct phy_driver marvell_drivers[] = {
938 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +1000939 .phy_id = MARVELL_PHY_ID_88E1101,
940 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johanssone5479232007-07-03 16:23:46 -0500941 .name = "Marvell 88E1101",
942 .features = PHY_GBIT_FEATURES,
943 .flags = PHY_HAS_INTERRUPT,
944 .config_aneg = &marvell_config_aneg,
945 .read_status = &genphy_read_status,
946 .ack_interrupt = &marvell_ack_interrupt,
947 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +0100948 .resume = &genphy_resume,
949 .suspend = &genphy_suspend,
Olof Johanssonac8c6352007-11-04 16:08:51 -0600950 .driver = { .owner = THIS_MODULE },
Olof Johanssone5479232007-07-03 16:23:46 -0500951 },
952 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +1000953 .phy_id = MARVELL_PHY_ID_88E1112,
954 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johansson85cfb532007-07-03 16:24:32 -0500955 .name = "Marvell 88E1112",
956 .features = PHY_GBIT_FEATURES,
957 .flags = PHY_HAS_INTERRUPT,
958 .config_init = &m88e1111_config_init,
959 .config_aneg = &marvell_config_aneg,
960 .read_status = &genphy_read_status,
961 .ack_interrupt = &marvell_ack_interrupt,
962 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +0100963 .resume = &genphy_resume,
964 .suspend = &genphy_suspend,
Olof Johanssonac8c6352007-11-04 16:08:51 -0600965 .driver = { .owner = THIS_MODULE },
Olof Johansson85cfb532007-07-03 16:24:32 -0500966 },
967 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +1000968 .phy_id = MARVELL_PHY_ID_88E1111,
969 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johanssone5479232007-07-03 16:23:46 -0500970 .name = "Marvell 88E1111",
971 .features = PHY_GBIT_FEATURES,
972 .flags = PHY_HAS_INTERRUPT,
973 .config_init = &m88e1111_config_init,
974 .config_aneg = &marvell_config_aneg,
Alexandr Smirnovbe937f12008-03-19 00:37:24 +0300975 .read_status = &marvell_read_status,
Olof Johanssone5479232007-07-03 16:23:46 -0500976 .ack_interrupt = &marvell_ack_interrupt,
977 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +0100978 .resume = &genphy_resume,
979 .suspend = &genphy_suspend,
Olof Johanssonac8c6352007-11-04 16:08:51 -0600980 .driver = { .owner = THIS_MODULE },
Olof Johanssone5479232007-07-03 16:23:46 -0500981 },
982 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +1000983 .phy_id = MARVELL_PHY_ID_88E1118,
984 .phy_id_mask = MARVELL_PHY_ID_MASK,
Ron Madrid605f1962008-11-06 09:05:26 +0000985 .name = "Marvell 88E1118",
986 .features = PHY_GBIT_FEATURES,
987 .flags = PHY_HAS_INTERRUPT,
988 .config_init = &m88e1118_config_init,
989 .config_aneg = &m88e1118_config_aneg,
990 .read_status = &genphy_read_status,
991 .ack_interrupt = &marvell_ack_interrupt,
992 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +0100993 .resume = &genphy_resume,
994 .suspend = &genphy_suspend,
Ron Madrid605f1962008-11-06 09:05:26 +0000995 .driver = {.owner = THIS_MODULE,},
996 },
997 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +1000998 .phy_id = MARVELL_PHY_ID_88E1121R,
999 .phy_id_mask = MARVELL_PHY_ID_MASK,
Sergei Poselenov140bc922009-04-07 02:01:41 +00001000 .name = "Marvell 88E1121R",
1001 .features = PHY_GBIT_FEATURES,
1002 .flags = PHY_HAS_INTERRUPT,
1003 .config_aneg = &m88e1121_config_aneg,
1004 .read_status = &marvell_read_status,
1005 .ack_interrupt = &marvell_ack_interrupt,
1006 .config_intr = &marvell_config_intr,
Anatolij Gustschindcd07be2009-04-07 02:01:43 +00001007 .did_interrupt = &m88e1121_did_interrupt,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001008 .resume = &genphy_resume,
1009 .suspend = &genphy_suspend,
Sergei Poselenov140bc922009-04-07 02:01:41 +00001010 .driver = { .owner = THIS_MODULE },
1011 },
1012 {
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -07001013 .phy_id = MARVELL_PHY_ID_88E1318S,
Linus Torvalds6ba74012010-08-04 11:47:58 -07001014 .phy_id_mask = MARVELL_PHY_ID_MASK,
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -07001015 .name = "Marvell 88E1318S",
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -07001016 .features = PHY_GBIT_FEATURES,
1017 .flags = PHY_HAS_INTERRUPT,
Cyril Chemparathy337ac9d2010-10-29 13:50:25 -07001018 .config_aneg = &m88e1318_config_aneg,
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -07001019 .read_status = &marvell_read_status,
1020 .ack_interrupt = &marvell_ack_interrupt,
1021 .config_intr = &marvell_config_intr,
1022 .did_interrupt = &m88e1121_did_interrupt,
Michael Stapelberg3871c382013-03-11 13:56:45 +00001023 .get_wol = &m88e1318_get_wol,
1024 .set_wol = &m88e1318_set_wol,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001025 .resume = &genphy_resume,
1026 .suspend = &genphy_suspend,
Cyril Chemparathy3ff1c252010-08-03 19:36:06 -07001027 .driver = { .owner = THIS_MODULE },
1028 },
1029 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +10001030 .phy_id = MARVELL_PHY_ID_88E1145,
1031 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johanssone5479232007-07-03 16:23:46 -05001032 .name = "Marvell 88E1145",
1033 .features = PHY_GBIT_FEATURES,
1034 .flags = PHY_HAS_INTERRUPT,
1035 .config_init = &m88e1145_config_init,
1036 .config_aneg = &marvell_config_aneg,
1037 .read_status = &genphy_read_status,
1038 .ack_interrupt = &marvell_ack_interrupt,
1039 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001040 .resume = &genphy_resume,
1041 .suspend = &genphy_suspend,
Olof Johanssonac8c6352007-11-04 16:08:51 -06001042 .driver = { .owner = THIS_MODULE },
1043 },
1044 {
David Daney90600732010-11-19 11:58:53 +00001045 .phy_id = MARVELL_PHY_ID_88E1149R,
1046 .phy_id_mask = MARVELL_PHY_ID_MASK,
1047 .name = "Marvell 88E1149R",
1048 .features = PHY_GBIT_FEATURES,
1049 .flags = PHY_HAS_INTERRUPT,
1050 .config_init = &m88e1149_config_init,
1051 .config_aneg = &m88e1118_config_aneg,
1052 .read_status = &genphy_read_status,
1053 .ack_interrupt = &marvell_ack_interrupt,
1054 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001055 .resume = &genphy_resume,
1056 .suspend = &genphy_suspend,
David Daney90600732010-11-19 11:58:53 +00001057 .driver = { .owner = THIS_MODULE },
1058 },
1059 {
Benjamin Herrenschmidt2f495c32010-06-21 13:20:46 +10001060 .phy_id = MARVELL_PHY_ID_88E1240,
1061 .phy_id_mask = MARVELL_PHY_ID_MASK,
Olof Johanssonac8c6352007-11-04 16:08:51 -06001062 .name = "Marvell 88E1240",
1063 .features = PHY_GBIT_FEATURES,
1064 .flags = PHY_HAS_INTERRUPT,
1065 .config_init = &m88e1111_config_init,
1066 .config_aneg = &marvell_config_aneg,
1067 .read_status = &genphy_read_status,
1068 .ack_interrupt = &marvell_ack_interrupt,
1069 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001070 .resume = &genphy_resume,
1071 .suspend = &genphy_suspend,
Olof Johanssonac8c6352007-11-04 16:08:51 -06001072 .driver = { .owner = THIS_MODULE },
1073 },
Michal Simek3da09a52013-05-30 20:08:26 +00001074 {
1075 .phy_id = MARVELL_PHY_ID_88E1116R,
1076 .phy_id_mask = MARVELL_PHY_ID_MASK,
1077 .name = "Marvell 88E1116R",
1078 .features = PHY_GBIT_FEATURES,
1079 .flags = PHY_HAS_INTERRUPT,
1080 .config_init = &m88e1116r_config_init,
1081 .config_aneg = &genphy_config_aneg,
1082 .read_status = &genphy_read_status,
1083 .ack_interrupt = &marvell_ack_interrupt,
1084 .config_intr = &marvell_config_intr,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001085 .resume = &genphy_resume,
1086 .suspend = &genphy_suspend,
Michal Simek3da09a52013-05-30 20:08:26 +00001087 .driver = { .owner = THIS_MODULE },
1088 },
Michal Simek10e24caa2013-05-30 20:08:27 +00001089 {
1090 .phy_id = MARVELL_PHY_ID_88E1510,
1091 .phy_id_mask = MARVELL_PHY_ID_MASK,
1092 .name = "Marvell 88E1510",
1093 .features = PHY_GBIT_FEATURES,
1094 .flags = PHY_HAS_INTERRUPT,
1095 .config_aneg = &m88e1510_config_aneg,
1096 .read_status = &marvell_read_status,
1097 .ack_interrupt = &marvell_ack_interrupt,
1098 .config_intr = &marvell_config_intr,
1099 .did_interrupt = &m88e1121_did_interrupt,
Sebastian Hesselbarth0898b442013-12-13 10:20:26 +01001100 .resume = &genphy_resume,
1101 .suspend = &genphy_suspend,
Michal Simek10e24caa2013-05-30 20:08:27 +00001102 .driver = { .owner = THIS_MODULE },
1103 },
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +02001104 {
1105 .phy_id = MARVELL_PHY_ID_88E3016,
1106 .phy_id_mask = MARVELL_PHY_ID_MASK,
1107 .name = "Marvell 88E3016",
1108 .features = PHY_BASIC_FEATURES,
1109 .flags = PHY_HAS_INTERRUPT,
1110 .config_aneg = &genphy_config_aneg,
1111 .config_init = &m88e3016_config_init,
1112 .aneg_done = &marvell_aneg_done,
1113 .read_status = &marvell_read_status,
1114 .ack_interrupt = &marvell_ack_interrupt,
1115 .config_intr = &marvell_config_intr,
1116 .did_interrupt = &m88e1121_did_interrupt,
1117 .resume = &genphy_resume,
1118 .suspend = &genphy_suspend,
1119 .driver = { .owner = THIS_MODULE },
1120 },
Andy Fleming00db8182005-07-30 19:31:23 -04001121};
1122
Johan Hovold50fd7152014-11-11 19:45:59 +01001123module_phy_driver(marvell_drivers);
David Woodhouse4e4f10f2010-04-02 01:05:56 +00001124
Uwe Kleine-Königcf93c942010-10-03 23:43:32 +00001125static struct mdio_device_id __maybe_unused marvell_tbl[] = {
Michal Simekf5e1cab2013-05-30 20:08:25 +00001126 { MARVELL_PHY_ID_88E1101, MARVELL_PHY_ID_MASK },
1127 { MARVELL_PHY_ID_88E1112, MARVELL_PHY_ID_MASK },
1128 { MARVELL_PHY_ID_88E1111, MARVELL_PHY_ID_MASK },
1129 { MARVELL_PHY_ID_88E1118, MARVELL_PHY_ID_MASK },
1130 { MARVELL_PHY_ID_88E1121R, MARVELL_PHY_ID_MASK },
1131 { MARVELL_PHY_ID_88E1145, MARVELL_PHY_ID_MASK },
1132 { MARVELL_PHY_ID_88E1149R, MARVELL_PHY_ID_MASK },
1133 { MARVELL_PHY_ID_88E1240, MARVELL_PHY_ID_MASK },
1134 { MARVELL_PHY_ID_88E1318S, MARVELL_PHY_ID_MASK },
Michal Simek3da09a52013-05-30 20:08:26 +00001135 { MARVELL_PHY_ID_88E1116R, MARVELL_PHY_ID_MASK },
Michal Simek10e24caa2013-05-30 20:08:27 +00001136 { MARVELL_PHY_ID_88E1510, MARVELL_PHY_ID_MASK },
Sebastian Hesselbarth6b358ae2014-10-22 20:26:44 +02001137 { MARVELL_PHY_ID_88E3016, MARVELL_PHY_ID_MASK },
David Woodhouse4e4f10f2010-04-02 01:05:56 +00001138 { }
1139};
1140
1141MODULE_DEVICE_TABLE(mdio, marvell_tbl);