[RFC net-next PATCH 12/16] net: macb: Support external PCSs

From: Sean Anderson
Date: Mon Oct 04 2021 - 15:16:39 EST


This adds support for using an external PCS. If someone else has set the
PCS beforehand, then we will use it instead of the internal PCS.

Signed-off-by: Sean Anderson <sean.anderson@xxxxxxxx>
---

drivers/net/ethernet/cadence/macb_main.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index b938cdf4bb59..7e9fd12c09c8 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -862,7 +862,7 @@ static int macb_mac_prepare(struct phylink_config *config, unsigned int mode,
}

if (set_pcs)
- phylink_set_pcs(bp->phylink, &bp->phylink_pcs);
+ set_pcs = phylink_set_pcs_weak(bp->phylink, &bp->phylink_pcs);

spin_lock_irqsave(&bp->lock, flags);

@@ -877,8 +877,11 @@ static int macb_mac_prepare(struct phylink_config *config, unsigned int mode,
ncr |= MACB_BIT(MIIONRGMII);
}

- if (macb_is_gem(bp) && set_pcs)
- ctrl |= GEM_BIT(PCSSEL);
+ if (macb_is_gem(bp)) {
+ ctrl &= ~GEM_BIT(PCSSEL);
+ if (set_pcs)
+ ctrl |= GEM_BIT(PCSSEL);
+ }

/* Apply the new configuration, if any */
if (old_ctrl ^ ctrl)
--
2.25.1