[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251110110536.2596490-2-horatiu.vultur@microchip.com>
Date: Mon, 10 Nov 2025 12:05:35 +0100
From: Horatiu Vultur <horatiu.vultur@...rochip.com>
To: <vkoul@...nel.org>, <kishon@...nel.org>, <robh@...nel.org>,
<krzk+dt@...nel.org>, <conor+dt@...nel.org>
CC: <linux-phy@...ts.infradead.org>, <devicetree@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, Horatiu Vultur <horatiu.vultur@...rochip.com>
Subject: [PATCH 1/2] phy: microchip: lan966x: Add support for inverting the rx/tx lanes
The lan966x has 3 SerDes and they have the capability to invert the P
and N signal for the TX and RX. Add this configuration option, which is
done through device tree ans the board designer will decide if the
serdes signals to be inverted.
Signed-off-by: Horatiu Vultur <horatiu.vultur@...rochip.com>
---
drivers/phy/microchip/lan966x_serdes.c | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
diff --git a/drivers/phy/microchip/lan966x_serdes.c b/drivers/phy/microchip/lan966x_serdes.c
index 835e369cdfc5f..5faf2001a100b 100644
--- a/drivers/phy/microchip/lan966x_serdes.c
+++ b/drivers/phy/microchip/lan966x_serdes.c
@@ -17,6 +17,11 @@
#define PLL_CONF_SERDES_125MHZ 2
#define PLL_CONF_BYPASS 3
+#define LAN966X_SERDES_MAX 3
+#define LAN966X_SERDES_DIR 2
+#define LAN966X_SERDES_TX 0
+#define LAN966X_SERDES_RX 1
+
#define lan_offset_(id, tinst, tcnt, \
gbase, ginst, gcnt, gwidth, \
raddr, rinst, rcnt, rwidth) \
@@ -129,6 +134,7 @@ struct serdes_ctrl {
struct device *dev;
struct phy *phys[SERDES_MAX];
int ref125;
+ bool inverted[LAN966X_SERDES_MAX][LAN966X_SERDES_DIR];
};
struct serdes_macro {
@@ -387,6 +393,11 @@ static int lan966x_sd6g40_setup(struct serdes_macro *macro, u32 idx, int mode)
conf.refclk125M = macro->ctrl->ref125;
+ if (macro->ctrl->inverted[idx][LAN966X_SERDES_TX])
+ conf.txinvert = 1;
+ if (macro->ctrl->inverted[idx][LAN966X_SERDES_RX])
+ conf.rxinvert = 1;
+
if (mode == PHY_INTERFACE_MODE_QSGMII)
conf.mode = LAN966X_SD6G40_MODE_QSGMII;
else
@@ -596,6 +607,18 @@ static int serdes_probe(struct platform_device *pdev)
ctrl->ref125 = (val == PLL_CONF_125MHZ ||
val == PLL_CONF_SERDES_125MHZ);
+ for (i = 0; i < LAN966X_SERDES_MAX; ++i) {
+ u8 prop[25];
+
+ sprintf(prop, "microchip,s%d-tx-inverted", i);
+ if (device_property_read_bool(ctrl->dev, prop))
+ ctrl->inverted[i][LAN966X_SERDES_TX] = true;
+
+ sprintf(prop, "microchip,s%d-rx-inverted", i);
+ if (device_property_read_bool(ctrl->dev, prop))
+ ctrl->inverted[i][LAN966X_SERDES_RX] = true;
+ }
+
dev_set_drvdata(&pdev->dev, ctrl);
provider = devm_of_phy_provider_register(ctrl->dev,
--
2.34.1
Powered by blists - more mailing lists