From 961800f3badd72e4efda39f219ac4cbec5791433 Mon Sep 17 00:00:00 2001
From: Christian Marangi <ansuelsmth@gmail.com>
Date: Sat, 26 Jul 2025 22:58:10 +0200
Subject: [PATCH 7/8] net: pcs: airoha: add support for optional xfi reset line

On Airoha AN7583 there is a dedicated reset line for the PON XFI Serdes.
This is needed to permit changing the WAN sel register or the system
will stall on accessing the XFI register.

Add support for this optional dedicated reset to permit correct
configuration of the PON Serdes.

Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
---
 drivers/net/pcs/airoha/pcs-airoha-common.c | 12 ++++++++++++
 drivers/net/pcs/airoha/pcs-airoha.h        |  1 +
 2 files changed, 13 insertions(+)

--- a/drivers/net/pcs/airoha/pcs-airoha-common.c
+++ b/drivers/net/pcs/airoha/pcs-airoha-common.c
@@ -82,6 +82,10 @@ static int airoha_pcs_setup_scu(struct a
 	const struct airoha_pcs_match_data *data = priv->data;
 	int ret;
 
+	ret = reset_control_assert(priv->xfi_rst);
+	if (ret)
+		return ret;
+
 	switch (data->port_type) {
 	case AIROHA_PCS_ETH:
 		airoha_pcs_setup_scu_eth(priv, interface);
@@ -91,6 +95,10 @@ static int airoha_pcs_setup_scu(struct a
 		break;
 	}
 
+	ret = reset_control_deassert(priv->xfi_rst);
+	if (ret)
+		return ret;
+
 	/* TODO better handle reset from MAC */
 	ret = reset_control_bulk_assert(ARRAY_SIZE(priv->rsts),
 					priv->rsts);
@@ -1003,6 +1011,10 @@ static int airoha_pcs_probe(struct platf
 	if (ret)
 		return dev_err_probe(dev, ret, "failed to get bulk reset lines\n");
 
+	priv->xfi_rst = devm_reset_control_get_optional_exclusive(dev, "xfi");
+	if (IS_ERR(priv->xfi_rst))
+		return dev_err_probe(dev, PTR_ERR(priv->xfi_rst), "failed to get xfi reset lines\n");
+
 	/* For Ethernet PCS, read the AN7581 SoC revision to check if
 	 * manual rx calibration is needed. This is only limited to
 	 * any SoC revision before E2.
--- a/drivers/net/pcs/airoha/pcs-airoha.h
+++ b/drivers/net/pcs/airoha/pcs-airoha.h
@@ -1184,6 +1184,7 @@ struct airoha_pcs_priv {
 	struct regmap *xfi_pma;
 	struct regmap *xfi_ana;
 
+	struct reset_control *xfi_rst;
 	struct reset_control_bulk_data rsts[AIROHA_PCS_MAX_NUM_RSTS];
 
 	bool manual_rx_calib;
