Skip to content

Commit bbc4d71

Browse files
Willy Liudavem330
authored andcommitted
net: phy: realtek: fix rtl8211e rx/tx delay config
There are two chip pins named TXDLY and RXDLY which actually adds the 2ns delays to TXC and RXC for TXD/RXD latching. These two pins can config via 4.7k-ohm resistor to 3.3V hw setting, but also config via software setting (extension page 0xa4 register 0x1c bit13 12 and 11). The configuration register definitions from table 13 official PHY datasheet: PHYAD[2:0] = PHY Address AN[1:0] = Auto-Negotiation Mode = Interface Mode Select RX Delay = RX Delay TX Delay = TX Delay SELRGV = RGMII/GMII Selection This table describes how to config these hw pins via external pull-high or pull- low resistor. It is a misunderstanding that mapping it as register bits below: 8:6 = PHY Address 5:4 = Auto-Negotiation 3 = Interface Mode Select 2 = RX Delay 1 = TX Delay 0 = SELRGV So I removed these descriptions above and add related settings as below: 14 = reserved 13 = force Tx RX Delay controlled by bit12 bit11 12 = Tx Delay 11 = Rx Delay 10:0 = Test && debug settings reserved by realtek Test && debug settings are not recommend to modify by default. Fixes: f81dadb ("net: phy: realtek: Add rtl8211e rx/tx delays config") Signed-off-by: Willy Liu <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1a03b8a commit bbc4d71

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

drivers/net/phy/realtek.c

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// SPDX-License-Identifier: GPL-2.0+
2-
/*
3-
* drivers/net/phy/realtek.c
2+
/* drivers/net/phy/realtek.c
43
*
54
* Driver for Realtek PHYs
65
*
@@ -32,9 +31,9 @@
3231
#define RTL8211F_TX_DELAY BIT(8)
3332
#define RTL8211F_RX_DELAY BIT(3)
3433

35-
#define RTL8211E_TX_DELAY BIT(1)
36-
#define RTL8211E_RX_DELAY BIT(2)
37-
#define RTL8211E_MODE_MII_GMII BIT(3)
34+
#define RTL8211E_CTRL_DELAY BIT(13)
35+
#define RTL8211E_TX_DELAY BIT(12)
36+
#define RTL8211E_RX_DELAY BIT(11)
3837

3938
#define RTL8201F_ISR 0x1e
4039
#define RTL8201F_IER 0x13
@@ -246,28 +245,29 @@ static int rtl8211e_config_init(struct phy_device *phydev)
246245
/* enable TX/RX delay for rgmii-* modes, and disable them for rgmii. */
247246
switch (phydev->interface) {
248247
case PHY_INTERFACE_MODE_RGMII:
249-
val = 0;
248+
val = RTL8211E_CTRL_DELAY | 0;
250249
break;
251250
case PHY_INTERFACE_MODE_RGMII_ID:
252-
val = RTL8211E_TX_DELAY | RTL8211E_RX_DELAY;
251+
val = RTL8211E_CTRL_DELAY | RTL8211E_TX_DELAY | RTL8211E_RX_DELAY;
253252
break;
254253
case PHY_INTERFACE_MODE_RGMII_RXID:
255-
val = RTL8211E_RX_DELAY;
254+
val = RTL8211E_CTRL_DELAY | RTL8211E_RX_DELAY;
256255
break;
257256
case PHY_INTERFACE_MODE_RGMII_TXID:
258-
val = RTL8211E_TX_DELAY;
257+
val = RTL8211E_CTRL_DELAY | RTL8211E_TX_DELAY;
259258
break;
260259
default: /* the rest of the modes imply leaving delays as is. */
261260
return 0;
262261
}
263262

264263
/* According to a sample driver there is a 0x1c config register on the
265264
* 0xa4 extension page (0x7) layout. It can be used to disable/enable
266-
* the RX/TX delays otherwise controlled by RXDLY/TXDLY pins. It can
267-
* also be used to customize the whole configuration register:
268-
* 8:6 = PHY Address, 5:4 = Auto-Negotiation, 3 = Interface Mode Select,
269-
* 2 = RX Delay, 1 = TX Delay, 0 = SELRGV (see original PHY datasheet
270-
* for details).
265+
* the RX/TX delays otherwise controlled by RXDLY/TXDLY pins.
266+
* The configuration register definition:
267+
* 14 = reserved
268+
* 13 = Force Tx RX Delay controlled by bit12 bit11,
269+
* 12 = RX Delay, 11 = TX Delay
270+
* 10:0 = Test && debug settings reserved by realtek
271271
*/
272272
oldpage = phy_select_page(phydev, 0x7);
273273
if (oldpage < 0)
@@ -277,7 +277,8 @@ static int rtl8211e_config_init(struct phy_device *phydev)
277277
if (ret)
278278
goto err_restore_page;
279279

280-
ret = __phy_modify(phydev, 0x1c, RTL8211E_TX_DELAY | RTL8211E_RX_DELAY,
280+
ret = __phy_modify(phydev, 0x1c, RTL8211E_CTRL_DELAY
281+
| RTL8211E_TX_DELAY | RTL8211E_RX_DELAY,
281282
val);
282283

283284
err_restore_page:

0 commit comments

Comments
 (0)