[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20220914095053.189851-6-s-vadapalli@ti.com>
Date: Wed, 14 Sep 2022 15:20:50 +0530
From: Siddharth Vadapalli <s-vadapalli@...com>
To: <davem@...emloft.net>, <edumazet@...gle.com>, <kuba@...nel.org>,
<pabeni@...hat.com>, <robh+dt@...nel.org>,
<krzysztof.kozlowski@...aro.org>,
<krzysztof.kozlowski+dt@...aro.org>, <linux@...linux.org.uk>,
<vladimir.oltean@....com>, <grygorii.strashko@...com>,
<vigneshr@...com>, <nsekhar@...com>
CC: <netdev@...r.kernel.org>, <devicetree@...r.kernel.org>,
<linux-kernel@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>, <kishon@...com>,
<s-vadapalli@...com>
Subject: [PATCH 5/8] net: ethernet: ti: am65-cpsw: Add support for fixed-link configuration
Check for fixed-link in am65_cpsw_nuss_mac_config() using struct
am65_cpsw_slave_data's phy_node property to obtain fwnode. Since
am65_cpsw_nuss_mac_link_up() is not invoked in fixed-link mode, perform
the relevant operations in am65_cpsw_nuss_mac_config() itself.
Signed-off-by: Siddharth Vadapalli <s-vadapalli@...com>
---
drivers/net/ethernet/ti/am65-cpsw-nuss.c | 40 ++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/drivers/net/ethernet/ti/am65-cpsw-nuss.c b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
index 72b1df12f320..1739c389af20 100644
--- a/drivers/net/ethernet/ti/am65-cpsw-nuss.c
+++ b/drivers/net/ethernet/ti/am65-cpsw-nuss.c
@@ -1494,10 +1494,50 @@ static void am65_cpsw_nuss_mac_config(struct phylink_config *config, unsigned in
phylink_config);
struct am65_cpsw_port *port = container_of(slave, struct am65_cpsw_port, slave);
struct am65_cpsw_common *common = port->common;
+ struct fwnode_handle *fwnode;
+ bool fixed_link = false;
if (common->pdata.extra_modes & BIT(state->interface))
writel(AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE,
port->sgmii_base + AM65_CPSW_SGMII_CONTROL_REG);
+
+ /* Detecting fixed-link */
+ fwnode = of_node_to_fwnode(port->slave.phy_node);
+ if (fwnode)
+ fixed_link = !!fwnode_get_named_child_node(fwnode, "fixed-link");
+
+ if (fixed_link) {
+ /* In fixed-link mode, mac_link_up is not invoked.
+ * Therefore, the relevant mac_link_up operations
+ * have to be moved to mac_config.
+ */
+ am65_cpsw_nuss_mac_control(port, state->interface, state->speed,
+ state->duplex, state->pause & MLO_PAUSE_TX,
+ state->pause & MLO_PAUSE_RX);
+
+ if (state->speed == SPEED_1000)
+ mr_adv_ability |= MAC2MAC_MR_ADV_ABILITY_1G;
+ if (state->speed == SPEED_100)
+ mr_adv_ability |= MAC2MAC_MR_ADV_ABILITY_100M;
+ if (state->duplex)
+ mr_adv_ability |= MAC2MAC_MR_ADV_ABILITY_FULLDUPLEX;
+
+ if (state->interface == PHY_INTERFACE_MODE_SGMII &&
+ (common->pdata.extra_modes & BIT(state->interface))) {
+ writel(mr_adv_ability,
+ port->sgmii_base + AM65_CPSW_SGMII_MR_ADV_ABILITY_REG);
+ writel((AM65_CPSW_SGMII_CONTROL_MASTER_MODE |
+ AM65_CPSW_SGMII_CONTROL_MR_AN_ENABLE),
+ port->sgmii_base + AM65_CPSW_SGMII_CONTROL_REG);
+ }
+
+ am65_cpsw_nuss_mac_enable_link(port, state->speed, state->duplex);
+ } else {
+ if (state->interface == PHY_INTERFACE_MODE_SGMII &&
+ (common->pdata.extra_modes & BIT(state->interface)))
+ writel(MAC2PHY_MR_ADV_ABILITY,
+ port->sgmii_base + AM65_CPSW_SGMII_MR_ADV_ABILITY_REG);
+ }
}
static void am65_cpsw_nuss_mac_link_down(struct phylink_config *config, unsigned int mode,
--
2.25.1
Powered by blists - more mailing lists