blob: 64713fbaebf4ff22397aece3da7058998c1414f5 [file] [log] [blame]
Andy Fleming9082eea2011-04-07 21:56:05 -05001/*
2 * Marvell PHY drivers
3 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02004 * SPDX-License-Identifier: GPL-2.0+
Andy Fleming9082eea2011-04-07 21:56:05 -05005 *
6 * Copyright 2010-2011 Freescale Semiconductor, Inc.
7 * author Andy Fleming
Andy Fleming9082eea2011-04-07 21:56:05 -05008 */
9#include <config.h>
10#include <common.h>
11#include <phy.h>
12
13#define PHY_AUTONEGOTIATE_TIMEOUT 5000
14
15/* 88E1011 PHY Status Register */
16#define MIIM_88E1xxx_PHY_STATUS 0x11
17#define MIIM_88E1xxx_PHYSTAT_SPEED 0xc000
18#define MIIM_88E1xxx_PHYSTAT_GBIT 0x8000
19#define MIIM_88E1xxx_PHYSTAT_100 0x4000
20#define MIIM_88E1xxx_PHYSTAT_DUPLEX 0x2000
21#define MIIM_88E1xxx_PHYSTAT_SPDDONE 0x0800
22#define MIIM_88E1xxx_PHYSTAT_LINK 0x0400
23
24#define MIIM_88E1xxx_PHY_SCR 0x10
25#define MIIM_88E1xxx_PHY_MDI_X_AUTO 0x0060
26
27/* 88E1111 PHY LED Control Register */
28#define MIIM_88E1111_PHY_LED_CONTROL 24
29#define MIIM_88E1111_PHY_LED_DIRECT 0x4100
30#define MIIM_88E1111_PHY_LED_COMBINE 0x411C
31
Zang Roy-R61911fa12a082011-10-27 18:52:09 +000032/* 88E1111 Extended PHY Specific Control Register */
33#define MIIM_88E1111_PHY_EXT_CR 0x14
34#define MIIM_88E1111_RX_DELAY 0x80
35#define MIIM_88E1111_TX_DELAY 0x2
36
37/* 88E1111 Extended PHY Specific Status Register */
38#define MIIM_88E1111_PHY_EXT_SR 0x1b
39#define MIIM_88E1111_HWCFG_MODE_MASK 0xf
40#define MIIM_88E1111_HWCFG_MODE_COPPER_RGMII 0xb
41#define MIIM_88E1111_HWCFG_MODE_FIBER_RGMII 0x3
42#define MIIM_88E1111_HWCFG_MODE_SGMII_NO_CLK 0x4
43#define MIIM_88E1111_HWCFG_MODE_COPPER_RTBI 0x9
44#define MIIM_88E1111_HWCFG_FIBER_COPPER_AUTO 0x8000
45#define MIIM_88E1111_HWCFG_FIBER_COPPER_RES 0x2000
46
47#define MIIM_88E1111_COPPER 0
48#define MIIM_88E1111_FIBER 1
49
Andy Fleming9082eea2011-04-07 21:56:05 -050050/* 88E1118 PHY defines */
51#define MIIM_88E1118_PHY_PAGE 22
52#define MIIM_88E1118_PHY_LED_PAGE 3
53
54/* 88E1121 PHY LED Control Register */
55#define MIIM_88E1121_PHY_LED_CTRL 16
56#define MIIM_88E1121_PHY_LED_PAGE 3
57#define MIIM_88E1121_PHY_LED_DEF 0x0030
58
59/* 88E1121 PHY IRQ Enable/Status Register */
60#define MIIM_88E1121_PHY_IRQ_EN 18
61#define MIIM_88E1121_PHY_IRQ_STATUS 19
62
63#define MIIM_88E1121_PHY_PAGE 22
64
65/* 88E1145 Extended PHY Specific Control Register */
66#define MIIM_88E1145_PHY_EXT_CR 20
67#define MIIM_M88E1145_RGMII_RX_DELAY 0x0080
68#define MIIM_M88E1145_RGMII_TX_DELAY 0x0002
69
70#define MIIM_88E1145_PHY_LED_CONTROL 24
71#define MIIM_88E1145_PHY_LED_DIRECT 0x4100
72
73#define MIIM_88E1145_PHY_PAGE 29
74#define MIIM_88E1145_PHY_CAL_OV 30
75
76#define MIIM_88E1149_PHY_PAGE 29
77
Sebastian Hesselbarthaeceec02012-12-04 09:31:59 +010078/* 88E1310 PHY defines */
79#define MIIM_88E1310_PHY_LED_CTRL 16
80#define MIIM_88E1310_PHY_IRQ_EN 18
81#define MIIM_88E1310_PHY_RGMII_CTRL 21
82#define MIIM_88E1310_PHY_PAGE 22
83
Andy Fleming9082eea2011-04-07 21:56:05 -050084/* Marvell 88E1011S */
85static int m88e1011s_config(struct phy_device *phydev)
86{
87 /* Reset and configure the PHY */
88 phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, BMCR_RESET);
89
90 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x1f);
91 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x200c);
92 phy_write(phydev, MDIO_DEVAD_NONE, 0x1d, 0x5);
93 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0);
94 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100);
95
96 phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, BMCR_RESET);
97
98 genphy_config_aneg(phydev);
99
100 return 0;
101}
102
103/* Parse the 88E1011's status register for speed and duplex
104 * information
105 */
Michal Simekef5e8212016-05-18 12:48:57 +0200106static int m88e1xxx_parse_status(struct phy_device *phydev)
Andy Fleming9082eea2011-04-07 21:56:05 -0500107{
108 unsigned int speed;
109 unsigned int mii_reg;
110
111 mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_88E1xxx_PHY_STATUS);
112
113 if ((mii_reg & MIIM_88E1xxx_PHYSTAT_LINK) &&
114 !(mii_reg & MIIM_88E1xxx_PHYSTAT_SPDDONE)) {
115 int i = 0;
116
117 puts("Waiting for PHY realtime link");
118 while (!(mii_reg & MIIM_88E1xxx_PHYSTAT_SPDDONE)) {
119 /* Timeout reached ? */
120 if (i > PHY_AUTONEGOTIATE_TIMEOUT) {
121 puts(" TIMEOUT !\n");
122 phydev->link = 0;
Michal Simekef5e8212016-05-18 12:48:57 +0200123 return -ETIMEDOUT;
Andy Fleming9082eea2011-04-07 21:56:05 -0500124 }
125
126 if ((i++ % 1000) == 0)
127 putc('.');
128 udelay(1000);
129 mii_reg = phy_read(phydev, MDIO_DEVAD_NONE,
130 MIIM_88E1xxx_PHY_STATUS);
131 }
132 puts(" done\n");
133 udelay(500000); /* another 500 ms (results in faster booting) */
134 } else {
135 if (mii_reg & MIIM_88E1xxx_PHYSTAT_LINK)
136 phydev->link = 1;
137 else
138 phydev->link = 0;
139 }
140
141 if (mii_reg & MIIM_88E1xxx_PHYSTAT_DUPLEX)
142 phydev->duplex = DUPLEX_FULL;
143 else
144 phydev->duplex = DUPLEX_HALF;
145
146 speed = mii_reg & MIIM_88E1xxx_PHYSTAT_SPEED;
147
148 switch (speed) {
149 case MIIM_88E1xxx_PHYSTAT_GBIT:
150 phydev->speed = SPEED_1000;
151 break;
152 case MIIM_88E1xxx_PHYSTAT_100:
153 phydev->speed = SPEED_100;
154 break;
155 default:
156 phydev->speed = SPEED_10;
157 break;
158 }
159
160 return 0;
161}
162
163static int m88e1011s_startup(struct phy_device *phydev)
164{
Michal Simekb733c272016-05-18 12:46:12 +0200165 int ret;
Andy Fleming9082eea2011-04-07 21:56:05 -0500166
Michal Simekb733c272016-05-18 12:46:12 +0200167 ret = genphy_update_link(phydev);
168 if (ret)
169 return ret;
170
171 return m88e1xxx_parse_status(phydev);
Andy Fleming9082eea2011-04-07 21:56:05 -0500172}
173
174/* Marvell 88E1111S */
175static int m88e1111s_config(struct phy_device *phydev)
176{
177 int reg;
178
179 if ((phydev->interface == PHY_INTERFACE_MODE_RGMII) ||
180 (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) ||
181 (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) ||
182 (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)) {
Zang Roy-R61911fa12a082011-10-27 18:52:09 +0000183 reg = phy_read(phydev,
184 MDIO_DEVAD_NONE, MIIM_88E1111_PHY_EXT_CR);
185 if ((phydev->interface == PHY_INTERFACE_MODE_RGMII) ||
186 (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)) {
187 reg |= (MIIM_88E1111_RX_DELAY | MIIM_88E1111_TX_DELAY);
188 } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID) {
189 reg &= ~MIIM_88E1111_TX_DELAY;
190 reg |= MIIM_88E1111_RX_DELAY;
191 } else if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
192 reg &= ~MIIM_88E1111_RX_DELAY;
193 reg |= MIIM_88E1111_TX_DELAY;
194 }
195
196 phy_write(phydev,
197 MDIO_DEVAD_NONE, MIIM_88E1111_PHY_EXT_CR, reg);
198
199 reg = phy_read(phydev,
200 MDIO_DEVAD_NONE, MIIM_88E1111_PHY_EXT_SR);
201
202 reg &= ~(MIIM_88E1111_HWCFG_MODE_MASK);
203
204 if (reg & MIIM_88E1111_HWCFG_FIBER_COPPER_RES)
205 reg |= MIIM_88E1111_HWCFG_MODE_FIBER_RGMII;
206 else
207 reg |= MIIM_88E1111_HWCFG_MODE_COPPER_RGMII;
208
209 phy_write(phydev,
210 MDIO_DEVAD_NONE, MIIM_88E1111_PHY_EXT_SR, reg);
Andy Fleming9082eea2011-04-07 21:56:05 -0500211 }
212
Zang Roy-R61911fa12a082011-10-27 18:52:09 +0000213 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
214 reg = phy_read(phydev,
215 MDIO_DEVAD_NONE, MIIM_88E1111_PHY_EXT_SR);
216
217 reg &= ~(MIIM_88E1111_HWCFG_MODE_MASK);
218 reg |= MIIM_88E1111_HWCFG_MODE_SGMII_NO_CLK;
219 reg |= MIIM_88E1111_HWCFG_FIBER_COPPER_AUTO;
220
221 phy_write(phydev, MDIO_DEVAD_NONE,
222 MIIM_88E1111_PHY_EXT_SR, reg);
223 }
224
225 if (phydev->interface == PHY_INTERFACE_MODE_RTBI) {
226 reg = phy_read(phydev,
227 MDIO_DEVAD_NONE, MIIM_88E1111_PHY_EXT_CR);
228 reg |= (MIIM_88E1111_RX_DELAY | MIIM_88E1111_TX_DELAY);
229 phy_write(phydev,
230 MDIO_DEVAD_NONE, MIIM_88E1111_PHY_EXT_CR, reg);
231
232 reg = phy_read(phydev, MDIO_DEVAD_NONE,
233 MIIM_88E1111_PHY_EXT_SR);
234 reg &= ~(MIIM_88E1111_HWCFG_MODE_MASK |
235 MIIM_88E1111_HWCFG_FIBER_COPPER_RES);
236 reg |= 0x7 | MIIM_88E1111_HWCFG_FIBER_COPPER_AUTO;
237 phy_write(phydev, MDIO_DEVAD_NONE,
238 MIIM_88E1111_PHY_EXT_SR, reg);
239
240 /* soft reset */
Stefan Roese3089c472016-02-10 07:06:05 +0100241 phy_reset(phydev);
Zang Roy-R61911fa12a082011-10-27 18:52:09 +0000242
243 reg = phy_read(phydev, MDIO_DEVAD_NONE,
244 MIIM_88E1111_PHY_EXT_SR);
245 reg &= ~(MIIM_88E1111_HWCFG_MODE_MASK |
246 MIIM_88E1111_HWCFG_FIBER_COPPER_RES);
247 reg |= MIIM_88E1111_HWCFG_MODE_COPPER_RTBI |
248 MIIM_88E1111_HWCFG_FIBER_COPPER_AUTO;
249 phy_write(phydev, MDIO_DEVAD_NONE,
250 MIIM_88E1111_PHY_EXT_SR, reg);
251 }
252
253 /* soft reset */
Stefan Roese3089c472016-02-10 07:06:05 +0100254 phy_reset(phydev);
Andy Fleming9082eea2011-04-07 21:56:05 -0500255
256 genphy_config_aneg(phydev);
Stefan Roesea8c3eca2016-02-10 07:06:06 +0100257 genphy_restart_aneg(phydev);
Andy Fleming9082eea2011-04-07 21:56:05 -0500258
259 return 0;
260}
261
Hao Zhang35fa0dd2014-10-30 18:59:43 +0200262/**
263 * m88e1518_phy_writebits - write bits to a register
264 */
265void m88e1518_phy_writebits(struct phy_device *phydev,
266 u8 reg_num, u16 offset, u16 len, u16 data)
267{
268 u16 reg, mask;
269
270 if ((len + offset) >= 16)
271 mask = 0 - (1 << offset);
272 else
273 mask = (1 << (len + offset)) - (1 << offset);
274
275 reg = phy_read(phydev, MDIO_DEVAD_NONE, reg_num);
276
277 reg &= ~mask;
278 reg |= data << offset;
279
280 phy_write(phydev, MDIO_DEVAD_NONE, reg_num, reg);
281}
282
283static int m88e1518_config(struct phy_device *phydev)
284{
285 /*
286 * As per Marvell Release Notes - Alaska 88E1510/88E1518/88E1512
287 * /88E1514 Rev A0, Errata Section 3.1
288 */
Clemens Gruber90a94ef2015-06-06 14:44:57 +0200289
290 /* EEE initialization */
291 phy_write(phydev, MDIO_DEVAD_NONE, 22, 0x00ff);
292 phy_write(phydev, MDIO_DEVAD_NONE, 17, 0x214B);
293 phy_write(phydev, MDIO_DEVAD_NONE, 16, 0x2144);
294 phy_write(phydev, MDIO_DEVAD_NONE, 17, 0x0C28);
295 phy_write(phydev, MDIO_DEVAD_NONE, 16, 0x2146);
296 phy_write(phydev, MDIO_DEVAD_NONE, 17, 0xB233);
297 phy_write(phydev, MDIO_DEVAD_NONE, 16, 0x214D);
298 phy_write(phydev, MDIO_DEVAD_NONE, 17, 0xCC0C);
299 phy_write(phydev, MDIO_DEVAD_NONE, 16, 0x2159);
300 phy_write(phydev, MDIO_DEVAD_NONE, 22, 0x0000);
301
302 /* SGMII-to-Copper mode initialization */
Hao Zhang35fa0dd2014-10-30 18:59:43 +0200303 if (phydev->interface == PHY_INTERFACE_MODE_SGMII) {
Clemens Gruber90a94ef2015-06-06 14:44:57 +0200304 /* Select page 18 */
305 phy_write(phydev, MDIO_DEVAD_NONE, 22, 18);
306
307 /* In reg 20, write MODE[2:0] = 0x1 (SGMII to Copper) */
Hao Zhang35fa0dd2014-10-30 18:59:43 +0200308 m88e1518_phy_writebits(phydev, 20, 0, 3, 1);
309
Clemens Gruber90a94ef2015-06-06 14:44:57 +0200310 /* PHY reset is necessary after changing MODE[2:0] */
Hao Zhang35fa0dd2014-10-30 18:59:43 +0200311 m88e1518_phy_writebits(phydev, 20, 15, 1, 1);
Clemens Gruber90a94ef2015-06-06 14:44:57 +0200312
313 /* Reset page selection */
314 phy_write(phydev, MDIO_DEVAD_NONE, 22, 0);
315
Hao Zhang35fa0dd2014-10-30 18:59:43 +0200316 udelay(100);
317 }
318
319 return m88e1111s_config(phydev);
320}
321
Clemens Gruber8396d0a2015-06-06 14:44:58 +0200322/* Marvell 88E1510 */
323static int m88e1510_config(struct phy_device *phydev)
324{
325 /* Select page 3 */
326 phy_write(phydev, MDIO_DEVAD_NONE, 22, 3);
327
328 /* Enable INTn output on LED[2] */
329 m88e1518_phy_writebits(phydev, 18, 7, 1, 1);
330
331 /* Configure LEDs */
332 m88e1518_phy_writebits(phydev, 16, 0, 4, 3); /* LED[0]:0011 (ACT) */
333 m88e1518_phy_writebits(phydev, 16, 4, 4, 6); /* LED[1]:0110 (LINK) */
334
335 /* Reset page selection */
336 phy_write(phydev, MDIO_DEVAD_NONE, 22, 0);
337
338 return m88e1518_config(phydev);
339}
340
Andy Fleming9082eea2011-04-07 21:56:05 -0500341/* Marvell 88E1118 */
342static int m88e1118_config(struct phy_device *phydev)
343{
344 /* Change Page Number */
345 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1118_PHY_PAGE, 0x0002);
346 /* Delay RGMII TX and RX */
347 phy_write(phydev, MDIO_DEVAD_NONE, 0x15, 0x1070);
348 /* Change Page Number */
349 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1118_PHY_PAGE, 0x0003);
350 /* Adjust LED control */
351 phy_write(phydev, MDIO_DEVAD_NONE, 0x10, 0x021e);
352 /* Change Page Number */
353 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1118_PHY_PAGE, 0x0000);
354
355 genphy_config_aneg(phydev);
356
357 phy_reset(phydev);
358
359 return 0;
360}
361
362static int m88e1118_startup(struct phy_device *phydev)
363{
Michal Simekb733c272016-05-18 12:46:12 +0200364 int ret;
365
Andy Fleming9082eea2011-04-07 21:56:05 -0500366 /* Change Page Number */
367 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1118_PHY_PAGE, 0x0000);
368
Michal Simekb733c272016-05-18 12:46:12 +0200369 ret = genphy_update_link(phydev);
370 if (ret)
371 return ret;
Andy Fleming9082eea2011-04-07 21:56:05 -0500372
Michal Simekb733c272016-05-18 12:46:12 +0200373 return m88e1xxx_parse_status(phydev);
Andy Fleming9082eea2011-04-07 21:56:05 -0500374}
375
376/* Marvell 88E1121R */
377static int m88e1121_config(struct phy_device *phydev)
378{
379 int pg;
380
381 /* Configure the PHY */
382 genphy_config_aneg(phydev);
383
384 /* Switch the page to access the led register */
385 pg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_88E1121_PHY_PAGE);
386 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1121_PHY_PAGE,
387 MIIM_88E1121_PHY_LED_PAGE);
388 /* Configure leds */
389 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1121_PHY_LED_CTRL,
390 MIIM_88E1121_PHY_LED_DEF);
391 /* Restore the page pointer */
392 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1121_PHY_PAGE, pg);
393
394 /* Disable IRQs and de-assert interrupt */
395 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1121_PHY_IRQ_EN, 0);
396 phy_read(phydev, MDIO_DEVAD_NONE, MIIM_88E1121_PHY_IRQ_STATUS);
397
398 return 0;
399}
400
401/* Marvell 88E1145 */
402static int m88e1145_config(struct phy_device *phydev)
403{
404 int reg;
405
406 /* Errata E0, E1 */
407 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1145_PHY_PAGE, 0x001b);
408 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1145_PHY_CAL_OV, 0x418f);
409 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1145_PHY_PAGE, 0x0016);
410 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1145_PHY_CAL_OV, 0xa2da);
411
412 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1xxx_PHY_SCR,
413 MIIM_88E1xxx_PHY_MDI_X_AUTO);
414
415 reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_88E1145_PHY_EXT_CR);
416 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID)
417 reg |= MIIM_M88E1145_RGMII_RX_DELAY |
418 MIIM_M88E1145_RGMII_TX_DELAY;
419 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1145_PHY_EXT_CR, reg);
420
421 genphy_config_aneg(phydev);
422
423 phy_reset(phydev);
424
425 return 0;
426}
427
428static int m88e1145_startup(struct phy_device *phydev)
429{
Michal Simekb733c272016-05-18 12:46:12 +0200430 int ret;
431
432 ret = genphy_update_link(phydev);
433 if (ret)
434 return ret;
435
Andy Fleming9082eea2011-04-07 21:56:05 -0500436 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1145_PHY_LED_CONTROL,
437 MIIM_88E1145_PHY_LED_DIRECT);
Michal Simekb733c272016-05-18 12:46:12 +0200438 return m88e1xxx_parse_status(phydev);
Andy Fleming9082eea2011-04-07 21:56:05 -0500439}
440
441/* Marvell 88E1149S */
442static int m88e1149_config(struct phy_device *phydev)
443{
444 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1149_PHY_PAGE, 0x1f);
445 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x200c);
446 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1149_PHY_PAGE, 0x5);
447 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x0);
448 phy_write(phydev, MDIO_DEVAD_NONE, 0x1e, 0x100);
449
450 genphy_config_aneg(phydev);
451
452 phy_reset(phydev);
453
454 return 0;
455}
456
Sebastian Hesselbarthaeceec02012-12-04 09:31:59 +0100457/* Marvell 88E1310 */
458static int m88e1310_config(struct phy_device *phydev)
459{
460 u16 reg;
461
462 /* LED link and activity */
463 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_PAGE, 0x0003);
464 reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_LED_CTRL);
465 reg = (reg & ~0xf) | 0x1;
466 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_LED_CTRL, reg);
467
468 /* Set LED2/INT to INT mode, low active */
469 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_PAGE, 0x0003);
470 reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_IRQ_EN);
471 reg = (reg & 0x77ff) | 0x0880;
472 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_IRQ_EN, reg);
473
474 /* Set RGMII delay */
475 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_PAGE, 0x0002);
476 reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_RGMII_CTRL);
477 reg |= 0x0030;
478 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_RGMII_CTRL, reg);
479
480 /* Ensure to return to page 0 */
481 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_88E1310_PHY_PAGE, 0x0000);
482
483 genphy_config_aneg(phydev);
484 phy_reset(phydev);
485
486 return 0;
487}
Andy Fleming9082eea2011-04-07 21:56:05 -0500488
489static struct phy_driver M88E1011S_driver = {
490 .name = "Marvell 88E1011S",
491 .uid = 0x1410c60,
492 .mask = 0xffffff0,
493 .features = PHY_GBIT_FEATURES,
494 .config = &m88e1011s_config,
495 .startup = &m88e1011s_startup,
496 .shutdown = &genphy_shutdown,
497};
498
499static struct phy_driver M88E1111S_driver = {
500 .name = "Marvell 88E1111S",
501 .uid = 0x1410cc0,
502 .mask = 0xffffff0,
503 .features = PHY_GBIT_FEATURES,
504 .config = &m88e1111s_config,
505 .startup = &m88e1011s_startup,
506 .shutdown = &genphy_shutdown,
507};
508
509static struct phy_driver M88E1118_driver = {
510 .name = "Marvell 88E1118",
511 .uid = 0x1410e10,
512 .mask = 0xffffff0,
513 .features = PHY_GBIT_FEATURES,
514 .config = &m88e1118_config,
515 .startup = &m88e1118_startup,
516 .shutdown = &genphy_shutdown,
517};
518
Michal Simekb4b81e82012-08-07 02:23:07 +0000519static struct phy_driver M88E1118R_driver = {
520 .name = "Marvell 88E1118R",
521 .uid = 0x1410e40,
522 .mask = 0xffffff0,
523 .features = PHY_GBIT_FEATURES,
524 .config = &m88e1118_config,
525 .startup = &m88e1118_startup,
526 .shutdown = &genphy_shutdown,
527};
528
Andy Fleming9082eea2011-04-07 21:56:05 -0500529static struct phy_driver M88E1121R_driver = {
530 .name = "Marvell 88E1121R",
531 .uid = 0x1410cb0,
532 .mask = 0xffffff0,
533 .features = PHY_GBIT_FEATURES,
534 .config = &m88e1121_config,
535 .startup = &genphy_startup,
536 .shutdown = &genphy_shutdown,
537};
538
539static struct phy_driver M88E1145_driver = {
540 .name = "Marvell 88E1145",
541 .uid = 0x1410cd0,
542 .mask = 0xffffff0,
543 .features = PHY_GBIT_FEATURES,
544 .config = &m88e1145_config,
545 .startup = &m88e1145_startup,
546 .shutdown = &genphy_shutdown,
547};
548
549static struct phy_driver M88E1149S_driver = {
550 .name = "Marvell 88E1149S",
551 .uid = 0x1410ca0,
552 .mask = 0xffffff0,
553 .features = PHY_GBIT_FEATURES,
554 .config = &m88e1149_config,
555 .startup = &m88e1011s_startup,
556 .shutdown = &genphy_shutdown,
557};
558
Clemens Gruber8396d0a2015-06-06 14:44:58 +0200559static struct phy_driver M88E1510_driver = {
560 .name = "Marvell 88E1510",
561 .uid = 0x1410dd0,
562 .mask = 0xffffff0,
563 .features = PHY_GBIT_FEATURES,
564 .config = &m88e1510_config,
565 .startup = &m88e1011s_startup,
566 .shutdown = &genphy_shutdown,
567};
568
Michal Simek14151072012-10-15 14:03:00 +0200569static struct phy_driver M88E1518_driver = {
570 .name = "Marvell 88E1518",
571 .uid = 0x1410dd1,
572 .mask = 0xffffff0,
573 .features = PHY_GBIT_FEATURES,
Hao Zhang35fa0dd2014-10-30 18:59:43 +0200574 .config = &m88e1518_config,
Michal Simek14151072012-10-15 14:03:00 +0200575 .startup = &m88e1011s_startup,
576 .shutdown = &genphy_shutdown,
577};
578
Sebastian Hesselbarthaeceec02012-12-04 09:31:59 +0100579static struct phy_driver M88E1310_driver = {
580 .name = "Marvell 88E1310",
581 .uid = 0x01410e90,
582 .mask = 0xffffff0,
583 .features = PHY_GBIT_FEATURES,
584 .config = &m88e1310_config,
585 .startup = &m88e1011s_startup,
586 .shutdown = &genphy_shutdown,
587};
588
Andy Fleming9082eea2011-04-07 21:56:05 -0500589int phy_marvell_init(void)
590{
Sebastian Hesselbarthaeceec02012-12-04 09:31:59 +0100591 phy_register(&M88E1310_driver);
Andy Fleming9082eea2011-04-07 21:56:05 -0500592 phy_register(&M88E1149S_driver);
593 phy_register(&M88E1145_driver);
594 phy_register(&M88E1121R_driver);
595 phy_register(&M88E1118_driver);
Michal Simekb4b81e82012-08-07 02:23:07 +0000596 phy_register(&M88E1118R_driver);
Andy Fleming9082eea2011-04-07 21:56:05 -0500597 phy_register(&M88E1111S_driver);
598 phy_register(&M88E1011S_driver);
Clemens Gruber8396d0a2015-06-06 14:44:58 +0200599 phy_register(&M88E1510_driver);
Michal Simek14151072012-10-15 14:03:00 +0200600 phy_register(&M88E1518_driver);
Andy Fleming9082eea2011-04-07 21:56:05 -0500601
602 return 0;
603}