Skip to content

Commit ddb0cd2

Browse files
committed
kernel: rtl8261n: add support for Serdes TX swap
Add support for swapping the Serdes TX line on RTL8261N PHYs. This is used on an Arcadyan Mozart board where the Serdes TX is swapped on the PHY (instead of on the Soc) to permit support of SFP module by using toggling the integrated MUX. Link: openwrt/openwrt#20227 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
1 parent 0147d21 commit ddb0cd2

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

target/linux/generic/files/drivers/net/phy/rtl8261n/rtk_phy.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
#include <linux/module.h>
88
#include <linux/phy.h>
9+
#include <linux/property.h>
910

1011
#include "phy_rtl826xb_patch.h"
1112
#include "rtk_phylib_rtl826xb.h"
@@ -15,6 +16,10 @@
1516
#define REALTEK_PHY_ID_RTL8264B 0x001CC813
1617
#define REALTEK_PHY_ID_RTL8264 0x001CCAF2
1718

19+
#define REALTEK_SERDES_GLOBAL_CFG 0x1c
20+
#define REALTEK_HSO_INV BIT(7)
21+
#define REALTEK_HSI_INV BIT(6)
22+
1823
static int rtl826xb_get_features(struct phy_device *phydev)
1924
{
2025
int ret;
@@ -41,6 +46,7 @@ static int rtl826xb_get_features(struct phy_device *phydev)
4146

4247
static int rtl826xb_probe(struct phy_device *phydev)
4348
{
49+
struct device *dev = &phydev->mdio.dev;
4450
struct rtk_phy_priv *priv = NULL;
4551

4652
priv = devm_kzalloc(&phydev->mdio.dev, sizeof(struct rtk_phy_priv), GFP_KERNEL);
@@ -55,13 +61,15 @@ static int rtl826xb_probe(struct phy_device *phydev)
5561

5662
priv->phytype = (phydev->drv->phy_id == REALTEK_PHY_ID_RTL8261N) ? (RTK_PHYLIB_RTL8261N) : (RTK_PHYLIB_RTL8264B);
5763
priv->isBasePort = (phydev->drv->phy_id == REALTEK_PHY_ID_RTL8261N) ? (1) : (((phydev->mdio.addr % 4) == 0) ? (1) : (0));
64+
priv->pnswap_tx = device_property_read_bool(dev, "realtek,pnswap-tx");
5865
phydev->priv = priv;
5966

6067
return 0;
6168
}
6269

6370
static int rtkphy_config_init(struct phy_device *phydev)
6471
{
72+
struct rtk_phy_priv *priv = phydev->priv;
6573
int ret = 0;
6674
switch (phydev->drv->phy_id)
6775
{
@@ -117,6 +125,11 @@ static int rtkphy_config_init(struct phy_device *phydev)
117125
}
118126
#endif
119127

128+
if (priv->pnswap_tx)
129+
phy_set_bits_mmd(phydev, MDIO_MMD_VEND1,
130+
REALTEK_SERDES_GLOBAL_CFG,
131+
REALTEK_HSO_INV);
132+
120133
break;
121134
default:
122135
phydev_err(phydev, "%s:%u Unknow phy_id: 0x%X\n", __FUNCTION__, __LINE__, phydev->drv->phy_id);

target/linux/generic/files/drivers/net/phy/rtl8261n/rtk_phylib.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
#define __RTK_PHYLIB_H
99

1010
#if defined(RTK_PHYDRV_IN_LINUX)
11+
#include <linux/types.h>
12+
1113
#include "type.h"
1214
#include "rtk_phylib_def.h"
1315
#else
@@ -48,6 +50,8 @@ struct rtk_phy_priv {
4850
rtk_phylib_phy_t phytype;
4951
uint8 isBasePort;
5052
rt_phy_patch_db_t *patch;
53+
54+
bool pnswap_tx;
5155
};
5256

5357
#if defined(RTK_PHYDRV_IN_LINUX)

0 commit comments

Comments
 (0)