blob: 24c3ea59bbb0ee9086e2401ac07dadfd1182fe53 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Andy Fleming9082eea2011-04-07 21:56:05 -05002/*
3 * RealTek PHY drivers
4 *
Codrin Ciubotariu3cee1382015-02-13 14:47:58 +02005 * Copyright 2010-2011, 2015 Freescale Semiconductor, Inc.
Andy Fleming9082eea2011-04-07 21:56:05 -05006 * author Andy Fleming
Karsten Merker563d8d92016-03-21 20:29:07 +01007 * Copyright 2016 Karsten Merker <merker@debian.org>
Andy Fleming9082eea2011-04-07 21:56:05 -05008 */
Andy Fleming9082eea2011-04-07 21:56:05 -05009#include <common.h>
oliver@schinagl.nl020f6762016-11-08 17:38:57 +010010#include <linux/bitops.h>
Andy Fleming9082eea2011-04-07 21:56:05 -050011#include <phy.h>
Simon Glassc05ed002020-05-10 11:40:11 -060012#include <linux/delay.h>
Andy Fleming9082eea2011-04-07 21:56:05 -050013
oliver@schinagl.nlcebf3f52016-11-08 17:38:59 +010014#define PHY_RTL8211x_FORCE_MASTER BIT(1)
Carlo Caioned47cfdb2019-01-24 08:54:37 +000015#define PHY_RTL8211F_FORCE_EEE_RXC_ON BIT(3)
Amit Singh Tomarfa6539a2020-05-09 19:55:11 +053016#define PHY_RTL8201F_S700_RMII_TIMINGS BIT(4)
oliver@schinagl.nlcebf3f52016-11-08 17:38:59 +010017
Andy Fleming9082eea2011-04-07 21:56:05 -050018#define PHY_AUTONEGOTIATE_TIMEOUT 5000
19
Michael Haas525d1872016-03-25 18:22:50 +010020/* RTL8211x 1000BASE-T Control Register */
oliver@schinagl.nl020f6762016-11-08 17:38:57 +010021#define MIIM_RTL8211x_CTRL1000T_MSCE BIT(12);
oliver@schinagl.nlcbe40e12016-11-08 17:38:58 +010022#define MIIM_RTL8211x_CTRL1000T_MASTER BIT(11);
Michael Haas525d1872016-03-25 18:22:50 +010023
Bhupesh Sharmac624d162013-07-18 13:58:20 +053024/* RTL8211x PHY Status Register */
25#define MIIM_RTL8211x_PHY_STATUS 0x11
26#define MIIM_RTL8211x_PHYSTAT_SPEED 0xc000
27#define MIIM_RTL8211x_PHYSTAT_GBIT 0x8000
28#define MIIM_RTL8211x_PHYSTAT_100 0x4000
29#define MIIM_RTL8211x_PHYSTAT_DUPLEX 0x2000
30#define MIIM_RTL8211x_PHYSTAT_SPDDONE 0x0800
31#define MIIM_RTL8211x_PHYSTAT_LINK 0x0400
Andy Fleming9082eea2011-04-07 21:56:05 -050032
Codrin Ciubotariu3cee1382015-02-13 14:47:58 +020033/* RTL8211x PHY Interrupt Enable Register */
34#define MIIM_RTL8211x_PHY_INER 0x12
35#define MIIM_RTL8211x_PHY_INTR_ENA 0x9f01
36#define MIIM_RTL8211x_PHY_INTR_DIS 0x0000
37
38/* RTL8211x PHY Interrupt Status Register */
39#define MIIM_RTL8211x_PHY_INSR 0x13
Andy Fleming9082eea2011-04-07 21:56:05 -050040
Shengzhou Liu3d6af742015-03-12 18:54:59 +080041/* RTL8211F PHY Status Register */
42#define MIIM_RTL8211F_PHY_STATUS 0x1a
43#define MIIM_RTL8211F_AUTONEG_ENABLE 0x1000
44#define MIIM_RTL8211F_PHYSTAT_SPEED 0x0030
45#define MIIM_RTL8211F_PHYSTAT_GBIT 0x0020
46#define MIIM_RTL8211F_PHYSTAT_100 0x0010
47#define MIIM_RTL8211F_PHYSTAT_DUPLEX 0x0008
48#define MIIM_RTL8211F_PHYSTAT_SPDDONE 0x0800
49#define MIIM_RTL8211F_PHYSTAT_LINK 0x0004
50
Samuel Hollandf11513d2021-10-12 21:07:32 -050051#define MIIM_RTL8211E_CONFREG 0x1c
52#define MIIM_RTL8211E_CTRL_DELAY BIT(13)
53#define MIIM_RTL8211E_TX_DELAY BIT(12)
54#define MIIM_RTL8211E_RX_DELAY BIT(11)
kevans@FreeBSD.org66526e72018-02-14 17:02:15 -060055
56#define MIIM_RTL8211E_EXT_PAGE_SELECT 0x1e
57
Shengzhou Liu3d6af742015-03-12 18:54:59 +080058#define MIIM_RTL8211F_PAGE_SELECT 0x1f
Shengzhou Liu793ea942015-04-24 16:57:17 +080059#define MIIM_RTL8211F_TX_DELAY 0x100
Fugang Duane32e4d02020-05-03 22:41:16 +080060#define MIIM_RTL8211F_RX_DELAY 0x8
Shengzhou Liu90712742015-05-21 18:07:35 +080061#define MIIM_RTL8211F_LCR 0x10
Shengzhou Liu3d6af742015-03-12 18:54:59 +080062
Amit Singh Tomarfa6539a2020-05-09 19:55:11 +053063#define RTL8201F_RMSR 0x10
64
65#define RMSR_RX_TIMING_SHIFT BIT(2)
66#define RMSR_RX_TIMING_MASK GENMASK(7, 4)
67#define RMSR_RX_TIMING_VAL 0x4
68#define RMSR_TX_TIMING_SHIFT BIT(3)
69#define RMSR_TX_TIMING_MASK GENMASK(11, 8)
70#define RMSR_TX_TIMING_VAL 0x5
71
Carlo Caionee57c9fd2019-01-16 11:34:50 +000072static int rtl8211f_phy_extread(struct phy_device *phydev, int addr,
73 int devaddr, int regnum)
74{
75 int oldpage = phy_read(phydev, MDIO_DEVAD_NONE,
76 MIIM_RTL8211F_PAGE_SELECT);
77 int val;
78
79 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT, devaddr);
80 val = phy_read(phydev, MDIO_DEVAD_NONE, regnum);
81 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT, oldpage);
82
83 return val;
84}
85
86static int rtl8211f_phy_extwrite(struct phy_device *phydev, int addr,
87 int devaddr, int regnum, u16 val)
88{
89 int oldpage = phy_read(phydev, MDIO_DEVAD_NONE,
90 MIIM_RTL8211F_PAGE_SELECT);
91
92 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT, devaddr);
93 phy_write(phydev, MDIO_DEVAD_NONE, regnum, val);
94 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT, oldpage);
95
96 return 0;
97}
98
oliver@schinagl.nlcebf3f52016-11-08 17:38:59 +010099static int rtl8211b_probe(struct phy_device *phydev)
100{
101#ifdef CONFIG_RTL8211X_PHY_FORCE_MASTER
102 phydev->flags |= PHY_RTL8211x_FORCE_MASTER;
103#endif
104
105 return 0;
106}
107
kevans@FreeBSD.org66526e72018-02-14 17:02:15 -0600108static int rtl8211e_probe(struct phy_device *phydev)
109{
kevans@FreeBSD.org66526e72018-02-14 17:02:15 -0600110 return 0;
111}
112
Carlo Caioned47cfdb2019-01-24 08:54:37 +0000113static int rtl8211f_probe(struct phy_device *phydev)
114{
115#ifdef CONFIG_RTL8211F_PHY_FORCE_EEE_RXC_ON
116 phydev->flags |= PHY_RTL8211F_FORCE_EEE_RXC_ON;
117#endif
118
119 return 0;
120}
121
Amit Singh Tomarfa6539a2020-05-09 19:55:11 +0530122static int rtl8210f_probe(struct phy_device *phydev)
123{
124#ifdef CONFIG_RTL8201F_PHY_S700_RMII_TIMINGS
125 phydev->flags |= PHY_RTL8201F_S700_RMII_TIMINGS;
126#endif
127
128 return 0;
129}
130
Bhupesh Sharmac624d162013-07-18 13:58:20 +0530131/* RealTek RTL8211x */
132static int rtl8211x_config(struct phy_device *phydev)
Andy Fleming9082eea2011-04-07 21:56:05 -0500133{
134 phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, BMCR_RESET);
135
Codrin Ciubotariu3cee1382015-02-13 14:47:58 +0200136 /* mask interrupt at init; if the interrupt is
137 * needed indeed, it should be explicitly enabled
138 */
139 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER,
140 MIIM_RTL8211x_PHY_INTR_DIS);
oliver@schinagl.nlcebf3f52016-11-08 17:38:59 +0100141
142 if (phydev->flags & PHY_RTL8211x_FORCE_MASTER) {
143 unsigned int reg;
144
145 reg = phy_read(phydev, MDIO_DEVAD_NONE, MII_CTRL1000);
146 /* force manual master/slave configuration */
147 reg |= MIIM_RTL8211x_CTRL1000T_MSCE;
148 /* force master mode */
149 reg |= MIIM_RTL8211x_CTRL1000T_MASTER;
150 phy_write(phydev, MDIO_DEVAD_NONE, MII_CTRL1000, reg);
151 }
Codrin Ciubotariu3cee1382015-02-13 14:47:58 +0200152 /* read interrupt status just to clear it */
153 phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_INER);
154
Andy Fleming9082eea2011-04-07 21:56:05 -0500155 genphy_config_aneg(phydev);
156
157 return 0;
158}
159
Amit Singh Tomarb0778d92020-05-09 19:55:10 +0530160/* RealTek RTL8201F */
161static int rtl8201f_config(struct phy_device *phydev)
162{
Amit Singh Tomarfa6539a2020-05-09 19:55:11 +0530163 unsigned int reg;
164
165 if (phydev->flags & PHY_RTL8201F_S700_RMII_TIMINGS) {
166 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT,
167 7);
168 reg = phy_read(phydev, MDIO_DEVAD_NONE, RTL8201F_RMSR);
169 reg &= ~(RMSR_RX_TIMING_MASK | RMSR_TX_TIMING_MASK);
170 /* Set the needed Rx/Tx Timings for proper PHY operation */
171 reg |= (RMSR_RX_TIMING_VAL << RMSR_RX_TIMING_SHIFT)
172 | (RMSR_TX_TIMING_VAL << RMSR_TX_TIMING_SHIFT);
173 phy_write(phydev, MDIO_DEVAD_NONE, RTL8201F_RMSR, reg);
174 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT,
175 0);
176 }
177
Amit Singh Tomarb0778d92020-05-09 19:55:10 +0530178 genphy_config_aneg(phydev);
179
180 return 0;
181}
182
Samuel Hollandf11513d2021-10-12 21:07:32 -0500183static int rtl8211e_config(struct phy_device *phydev)
184{
185 int reg, val;
186
187 /* enable TX/RX delay for rgmii-* modes, and disable them for rgmii. */
188 switch (phydev->interface) {
189 case PHY_INTERFACE_MODE_RGMII:
190 val = MIIM_RTL8211E_CTRL_DELAY;
191 break;
192 case PHY_INTERFACE_MODE_RGMII_ID:
193 val = MIIM_RTL8211E_CTRL_DELAY | MIIM_RTL8211E_TX_DELAY |
194 MIIM_RTL8211E_RX_DELAY;
195 break;
196 case PHY_INTERFACE_MODE_RGMII_RXID:
197 val = MIIM_RTL8211E_CTRL_DELAY | MIIM_RTL8211E_RX_DELAY;
198 break;
199 case PHY_INTERFACE_MODE_RGMII_TXID:
200 val = MIIM_RTL8211E_CTRL_DELAY | MIIM_RTL8211E_TX_DELAY;
201 break;
202 default: /* the rest of the modes imply leaving delays as is. */
203 goto default_delay;
204 }
205
206 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT, 7);
207 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211E_EXT_PAGE_SELECT, 0xa4);
208
209 reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211E_CONFREG);
210 reg &= ~(MIIM_RTL8211E_TX_DELAY | MIIM_RTL8211E_RX_DELAY);
211 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211E_CONFREG, reg | val);
212
213 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT, 0);
214
215default_delay:
216 genphy_config_aneg(phydev);
217
218 return 0;
219}
220
Shengzhou Liu793ea942015-04-24 16:57:17 +0800221static int rtl8211f_config(struct phy_device *phydev)
222{
223 u16 reg;
224
Carlo Caioned47cfdb2019-01-24 08:54:37 +0000225 if (phydev->flags & PHY_RTL8211F_FORCE_EEE_RXC_ON) {
226 unsigned int reg;
227
228 reg = phy_read_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1);
229 reg &= ~MDIO_PCS_CTRL1_CLKSTOP_EN;
230 phy_write_mmd(phydev, MDIO_MMD_PCS, MDIO_CTRL1, reg);
231 }
232
Shengzhou Liu793ea942015-04-24 16:57:17 +0800233 phy_write(phydev, MDIO_DEVAD_NONE, MII_BMCR, BMCR_RESET);
234
Madalin Bucur05b29aa2017-08-18 11:35:24 +0300235 phy_write(phydev, MDIO_DEVAD_NONE,
236 MIIM_RTL8211F_PAGE_SELECT, 0xd08);
237 reg = phy_read(phydev, MDIO_DEVAD_NONE, 0x11);
238
239 /* enable TX-delay for rgmii-id and rgmii-txid, otherwise disable it */
240 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
241 phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID)
Shengzhou Liu793ea942015-04-24 16:57:17 +0800242 reg |= MIIM_RTL8211F_TX_DELAY;
Madalin Bucur05b29aa2017-08-18 11:35:24 +0300243 else
244 reg &= ~MIIM_RTL8211F_TX_DELAY;
245
246 phy_write(phydev, MDIO_DEVAD_NONE, 0x11, reg);
Fugang Duane32e4d02020-05-03 22:41:16 +0800247
248 /* enable RX-delay for rgmii-id and rgmii-rxid, otherwise disable it */
249 reg = phy_read(phydev, MDIO_DEVAD_NONE, 0x15);
250 if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID ||
251 phydev->interface == PHY_INTERFACE_MODE_RGMII_RXID)
252 reg |= MIIM_RTL8211F_RX_DELAY;
253 else
254 reg &= ~MIIM_RTL8211F_RX_DELAY;
255 phy_write(phydev, MDIO_DEVAD_NONE, 0x15, reg);
256
Madalin Bucur05b29aa2017-08-18 11:35:24 +0300257 /* restore to default page 0 */
258 phy_write(phydev, MDIO_DEVAD_NONE,
259 MIIM_RTL8211F_PAGE_SELECT, 0x0);
Shengzhou Liu793ea942015-04-24 16:57:17 +0800260
Shengzhou Liu90712742015-05-21 18:07:35 +0800261 /* Set green LED for Link, yellow LED for Active */
262 phy_write(phydev, MDIO_DEVAD_NONE,
263 MIIM_RTL8211F_PAGE_SELECT, 0xd04);
264 phy_write(phydev, MDIO_DEVAD_NONE, 0x10, 0x617f);
265 phy_write(phydev, MDIO_DEVAD_NONE,
266 MIIM_RTL8211F_PAGE_SELECT, 0x0);
267
Shengzhou Liu793ea942015-04-24 16:57:17 +0800268 genphy_config_aneg(phydev);
269
270 return 0;
271}
272
Bhupesh Sharmac624d162013-07-18 13:58:20 +0530273static int rtl8211x_parse_status(struct phy_device *phydev)
Andy Fleming9082eea2011-04-07 21:56:05 -0500274{
275 unsigned int speed;
276 unsigned int mii_reg;
277
Bhupesh Sharmac624d162013-07-18 13:58:20 +0530278 mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211x_PHY_STATUS);
Andy Fleming9082eea2011-04-07 21:56:05 -0500279
Bhupesh Sharmac624d162013-07-18 13:58:20 +0530280 if (!(mii_reg & MIIM_RTL8211x_PHYSTAT_SPDDONE)) {
Andy Fleming9082eea2011-04-07 21:56:05 -0500281 int i = 0;
282
283 /* in case of timeout ->link is cleared */
284 phydev->link = 1;
285 puts("Waiting for PHY realtime link");
Bhupesh Sharmac624d162013-07-18 13:58:20 +0530286 while (!(mii_reg & MIIM_RTL8211x_PHYSTAT_SPDDONE)) {
Andy Fleming9082eea2011-04-07 21:56:05 -0500287 /* Timeout reached ? */
288 if (i > PHY_AUTONEGOTIATE_TIMEOUT) {
289 puts(" TIMEOUT !\n");
290 phydev->link = 0;
291 break;
292 }
293
294 if ((i++ % 1000) == 0)
295 putc('.');
296 udelay(1000); /* 1 ms */
297 mii_reg = phy_read(phydev, MDIO_DEVAD_NONE,
Bhupesh Sharmac624d162013-07-18 13:58:20 +0530298 MIIM_RTL8211x_PHY_STATUS);
Andy Fleming9082eea2011-04-07 21:56:05 -0500299 }
300 puts(" done\n");
301 udelay(500000); /* another 500 ms (results in faster booting) */
302 } else {
Bhupesh Sharmac624d162013-07-18 13:58:20 +0530303 if (mii_reg & MIIM_RTL8211x_PHYSTAT_LINK)
Andy Fleming9082eea2011-04-07 21:56:05 -0500304 phydev->link = 1;
305 else
306 phydev->link = 0;
307 }
308
Bhupesh Sharmac624d162013-07-18 13:58:20 +0530309 if (mii_reg & MIIM_RTL8211x_PHYSTAT_DUPLEX)
Andy Fleming9082eea2011-04-07 21:56:05 -0500310 phydev->duplex = DUPLEX_FULL;
311 else
312 phydev->duplex = DUPLEX_HALF;
313
Bhupesh Sharmac624d162013-07-18 13:58:20 +0530314 speed = (mii_reg & MIIM_RTL8211x_PHYSTAT_SPEED);
Andy Fleming9082eea2011-04-07 21:56:05 -0500315
316 switch (speed) {
Bhupesh Sharmac624d162013-07-18 13:58:20 +0530317 case MIIM_RTL8211x_PHYSTAT_GBIT:
Andy Fleming9082eea2011-04-07 21:56:05 -0500318 phydev->speed = SPEED_1000;
319 break;
Bhupesh Sharmac624d162013-07-18 13:58:20 +0530320 case MIIM_RTL8211x_PHYSTAT_100:
Andy Fleming9082eea2011-04-07 21:56:05 -0500321 phydev->speed = SPEED_100;
322 break;
323 default:
324 phydev->speed = SPEED_10;
325 }
326
327 return 0;
328}
329
Shengzhou Liu3d6af742015-03-12 18:54:59 +0800330static int rtl8211f_parse_status(struct phy_device *phydev)
331{
332 unsigned int speed;
333 unsigned int mii_reg;
334 int i = 0;
335
336 phy_write(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PAGE_SELECT, 0xa43);
337 mii_reg = phy_read(phydev, MDIO_DEVAD_NONE, MIIM_RTL8211F_PHY_STATUS);
338
339 phydev->link = 1;
340 while (!(mii_reg & MIIM_RTL8211F_PHYSTAT_LINK)) {
341 if (i > PHY_AUTONEGOTIATE_TIMEOUT) {
342 puts(" TIMEOUT !\n");
343 phydev->link = 0;
344 break;
345 }
346
347 if ((i++ % 1000) == 0)
348 putc('.');
349 udelay(1000);
350 mii_reg = phy_read(phydev, MDIO_DEVAD_NONE,
351 MIIM_RTL8211F_PHY_STATUS);
352 }
353
354 if (mii_reg & MIIM_RTL8211F_PHYSTAT_DUPLEX)
355 phydev->duplex = DUPLEX_FULL;
356 else
357 phydev->duplex = DUPLEX_HALF;
358
359 speed = (mii_reg & MIIM_RTL8211F_PHYSTAT_SPEED);
360
361 switch (speed) {
362 case MIIM_RTL8211F_PHYSTAT_GBIT:
363 phydev->speed = SPEED_1000;
364 break;
365 case MIIM_RTL8211F_PHYSTAT_100:
366 phydev->speed = SPEED_100;
367 break;
368 default:
369 phydev->speed = SPEED_10;
370 }
371
Shengzhou Liu3d6af742015-03-12 18:54:59 +0800372 return 0;
373}
374
Bhupesh Sharmac624d162013-07-18 13:58:20 +0530375static int rtl8211x_startup(struct phy_device *phydev)
Andy Fleming9082eea2011-04-07 21:56:05 -0500376{
Michal Simekb733c272016-05-18 12:46:12 +0200377 int ret;
Andy Fleming9082eea2011-04-07 21:56:05 -0500378
Michal Simekb733c272016-05-18 12:46:12 +0200379 /* Read the Status (2x to make sure link is right) */
380 ret = genphy_update_link(phydev);
381 if (ret)
382 return ret;
383
384 return rtl8211x_parse_status(phydev);
Andy Fleming9082eea2011-04-07 21:56:05 -0500385}
386
Michal Simek6a10bc52016-02-13 10:31:32 +0100387static int rtl8211e_startup(struct phy_device *phydev)
388{
Michal Simekb733c272016-05-18 12:46:12 +0200389 int ret;
Michal Simek6a10bc52016-02-13 10:31:32 +0100390
Michal Simekb733c272016-05-18 12:46:12 +0200391 ret = genphy_update_link(phydev);
392 if (ret)
393 return ret;
394
395 return genphy_parse_link(phydev);
Michal Simek6a10bc52016-02-13 10:31:32 +0100396}
397
Shengzhou Liu3d6af742015-03-12 18:54:59 +0800398static int rtl8211f_startup(struct phy_device *phydev)
399{
Michal Simekb733c272016-05-18 12:46:12 +0200400 int ret;
Shengzhou Liu3d6af742015-03-12 18:54:59 +0800401
Michal Simekb733c272016-05-18 12:46:12 +0200402 /* Read the Status (2x to make sure link is right) */
403 ret = genphy_update_link(phydev);
404 if (ret)
405 return ret;
406 /* Read the Status (2x to make sure link is right) */
407
408 return rtl8211f_parse_status(phydev);
Shengzhou Liu3d6af742015-03-12 18:54:59 +0800409}
410
Bhupesh Sharmac624d162013-07-18 13:58:20 +0530411/* Support for RTL8211B PHY */
Andy Fleming9082eea2011-04-07 21:56:05 -0500412static struct phy_driver RTL8211B_driver = {
413 .name = "RealTek RTL8211B",
Karsten Merker563d8d92016-03-21 20:29:07 +0100414 .uid = 0x1cc912,
Bhupesh Sharma42205042013-09-01 04:40:52 +0530415 .mask = 0xffffff,
Andy Fleming9082eea2011-04-07 21:56:05 -0500416 .features = PHY_GBIT_FEATURES,
oliver@schinagl.nlcebf3f52016-11-08 17:38:59 +0100417 .probe = &rtl8211b_probe,
Bhupesh Sharmac624d162013-07-18 13:58:20 +0530418 .config = &rtl8211x_config,
419 .startup = &rtl8211x_startup,
420 .shutdown = &genphy_shutdown,
421};
422
423/* Support for RTL8211E-VB-CG, RTL8211E-VL-CG and RTL8211EG-VB-CG PHYs */
424static struct phy_driver RTL8211E_driver = {
425 .name = "RealTek RTL8211E",
426 .uid = 0x1cc915,
Bhupesh Sharma42205042013-09-01 04:40:52 +0530427 .mask = 0xffffff,
Bhupesh Sharmac624d162013-07-18 13:58:20 +0530428 .features = PHY_GBIT_FEATURES,
kevans@FreeBSD.org66526e72018-02-14 17:02:15 -0600429 .probe = &rtl8211e_probe,
Samuel Hollandf11513d2021-10-12 21:07:32 -0500430 .config = &rtl8211e_config,
Michal Simek6a10bc52016-02-13 10:31:32 +0100431 .startup = &rtl8211e_startup,
Bhupesh Sharmac624d162013-07-18 13:58:20 +0530432 .shutdown = &genphy_shutdown,
433};
434
435/* Support for RTL8211DN PHY */
436static struct phy_driver RTL8211DN_driver = {
437 .name = "RealTek RTL8211DN",
438 .uid = 0x1cc914,
Bhupesh Sharma42205042013-09-01 04:40:52 +0530439 .mask = 0xffffff,
Bhupesh Sharmac624d162013-07-18 13:58:20 +0530440 .features = PHY_GBIT_FEATURES,
441 .config = &rtl8211x_config,
442 .startup = &rtl8211x_startup,
Andy Fleming9082eea2011-04-07 21:56:05 -0500443 .shutdown = &genphy_shutdown,
444};
445
Shengzhou Liu3d6af742015-03-12 18:54:59 +0800446/* Support for RTL8211F PHY */
447static struct phy_driver RTL8211F_driver = {
448 .name = "RealTek RTL8211F",
449 .uid = 0x1cc916,
450 .mask = 0xffffff,
451 .features = PHY_GBIT_FEATURES,
Carlo Caioned47cfdb2019-01-24 08:54:37 +0000452 .probe = &rtl8211f_probe,
Shengzhou Liu793ea942015-04-24 16:57:17 +0800453 .config = &rtl8211f_config,
Shengzhou Liu3d6af742015-03-12 18:54:59 +0800454 .startup = &rtl8211f_startup,
455 .shutdown = &genphy_shutdown,
Carlo Caionee57c9fd2019-01-16 11:34:50 +0000456 .readext = &rtl8211f_phy_extread,
457 .writeext = &rtl8211f_phy_extwrite,
Shengzhou Liu3d6af742015-03-12 18:54:59 +0800458};
459
Amit Singh Tomarb0778d92020-05-09 19:55:10 +0530460/* Support for RTL8201F PHY */
461static struct phy_driver RTL8201F_driver = {
462 .name = "RealTek RTL8201F 10/100Mbps Ethernet",
463 .uid = 0x1cc816,
464 .mask = 0xffffff,
465 .features = PHY_BASIC_FEATURES,
Amit Singh Tomarfa6539a2020-05-09 19:55:11 +0530466 .probe = &rtl8210f_probe,
Amit Singh Tomarb0778d92020-05-09 19:55:10 +0530467 .config = &rtl8201f_config,
468 .startup = &rtl8211e_startup,
469 .shutdown = &genphy_shutdown,
470};
471
Andy Fleming9082eea2011-04-07 21:56:05 -0500472int phy_realtek_init(void)
473{
474 phy_register(&RTL8211B_driver);
Bhupesh Sharmac624d162013-07-18 13:58:20 +0530475 phy_register(&RTL8211E_driver);
Shengzhou Liu3d6af742015-03-12 18:54:59 +0800476 phy_register(&RTL8211F_driver);
Bhupesh Sharmac624d162013-07-18 13:58:20 +0530477 phy_register(&RTL8211DN_driver);
Amit Singh Tomarb0778d92020-05-09 19:55:10 +0530478 phy_register(&RTL8201F_driver);
Andy Fleming9082eea2011-04-07 21:56:05 -0500479
480 return 0;
481}