From patchwork Fri Jan 27 14:26:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 13118789 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E953C61DA3 for ; Fri, 27 Jan 2023 14:26:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232415AbjA0O0e (ORCPT ); Fri, 27 Jan 2023 09:26:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232280AbjA0O0c (ORCPT ); Fri, 27 Jan 2023 09:26:32 -0500 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 80F9BA5F7; Fri, 27 Jan 2023 06:26:26 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.97,251,1669042800"; d="scan'208";a="147645291" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 27 Jan 2023 23:26:25 +0900 Received: from localhost.localdomain (unknown [10.166.15.32]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id B8FAF433ACC5; Fri, 27 Jan 2023 23:26:25 +0900 (JST) From: Yoshihiro Shimoda To: linux@armlinux.org.uk, andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH net-next v4 1/4] net: phylink: Set host_interfaces for a non-sfp PHY Date: Fri, 27 Jan 2023 23:26:18 +0900 Message-Id: <20230127142621.1761278-2-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127142621.1761278-1-yoshihiro.shimoda.uh@renesas.com> References: <20230127142621.1761278-1-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org If a new flag (ovr_host_interfaces) in the phylink_config is set, overwrite the host_interfaces in the phy_device by link_interface. Note that an ethernet PHY driver like marvell10g will check PHY_INTERFACE_MODE_SGMII in the host_interfaces whther the host controller supports a rate matching interface mode or not. So, set PHY_INTERFACE_MODE_SGMII to the host_interfaces if it is set in the supported_interfaces. Signed-off-by: Yoshihiro Shimoda --- drivers/net/phy/phylink.c | 11 +++++++++++ include/linux/phylink.h | 3 +++ 2 files changed, 14 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 319790221d7f..dee64b4a1175 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1814,6 +1814,17 @@ int phylink_fwnode_phy_connect(struct phylink *pl, pl->link_config.interface = pl->link_interface; } + if (pl->config->ovr_host_interfaces) { + __set_bit(pl->link_interface, phy_dev->host_interfaces); + + /* An ethernet PHY driver will check PHY_INTERFACE_MODE_SGMII + * in the host_interfaces whether the host controller supports + * a rate matching interface mode or not. + */ + if (test_bit(PHY_INTERFACE_MODE_SGMII, pl->config->supported_interfaces)) + __set_bit(PHY_INTERFACE_MODE_SGMII, phy_dev->host_interfaces); + } + ret = phy_attach_direct(pl->netdev, phy_dev, flags, pl->link_interface); if (ret) { diff --git a/include/linux/phylink.h b/include/linux/phylink.h index c492c26202b5..c8dd53b1e857 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -124,6 +124,8 @@ enum phylink_op_type { * if MAC link is at %MLO_AN_FIXED mode. * @mac_managed_pm: if true, indicate the MAC driver is responsible for PHY PM. * @ovr_an_inband: if true, override PCS to MLO_AN_INBAND + * @ovr_host_interfaces: if true, override host_interfaces of phy_device from + * link_interface. * @get_fixed_state: callback to execute to determine the fixed link state, * if MAC link is at %MLO_AN_FIXED mode. * @supported_interfaces: bitmap describing which PHY_INTERFACE_MODE_xxx @@ -137,6 +139,7 @@ struct phylink_config { bool poll_fixed_state; bool mac_managed_pm; bool ovr_an_inband; + bool ovr_host_interfaces; void (*get_fixed_state)(struct phylink_config *config, struct phylink_link_state *state); DECLARE_PHY_INTERFACE_MASK(supported_interfaces); From patchwork Fri Jan 27 14:26:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 13118791 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8F7FBC636BD for ; Fri, 27 Jan 2023 14:26:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232645AbjA0O0i (ORCPT ); Fri, 27 Jan 2023 09:26:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39178 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232810AbjA0O0f (ORCPT ); Fri, 27 Jan 2023 09:26:35 -0500 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id A723F6E8E; Fri, 27 Jan 2023 06:26:32 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.97,251,1669042800"; d="scan'208";a="150776283" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 27 Jan 2023 23:26:25 +0900 Received: from localhost.localdomain (unknown [10.166.15.32]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id D29E5433ACC5; Fri, 27 Jan 2023 23:26:25 +0900 (JST) From: Yoshihiro Shimoda To: linux@armlinux.org.uk, andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH net-next v4 2/4] net: ethernet: renesas: rswitch: Simplify struct phy * handling Date: Fri, 27 Jan 2023 23:26:19 +0900 Message-Id: <20230127142621.1761278-3-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127142621.1761278-1-yoshihiro.shimoda.uh@renesas.com> References: <20230127142621.1761278-1-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Simplify struct phy *serdes handling by keeping the valiable in the struct rswitch_device. Signed-off-by: Yoshihiro Shimoda --- drivers/net/ethernet/renesas/rswitch.c | 103 ++++++------------------- drivers/net/ethernet/renesas/rswitch.h | 2 + 2 files changed, 27 insertions(+), 78 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index 14fc0af304ce..1c154018d795 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -1071,32 +1071,14 @@ static struct device_node *rswitch_get_port_node(struct rswitch_device *rdev) return port; } -/* Call of_node_put(mdio) after done */ -static struct device_node *rswitch_get_mdio_node(struct rswitch_device *rdev) -{ - struct device_node *port, *mdio; - - port = rswitch_get_port_node(rdev); - if (!port) - return NULL; - - mdio = of_get_child_by_name(port, "mdio"); - of_node_put(port); - - return mdio; -} - static int rswitch_etha_get_params(struct rswitch_device *rdev) { - struct device_node *port; int err; - port = rswitch_get_port_node(rdev); - if (!port) + if (!rdev->np_port) return 0; /* ignored */ - err = of_get_phy_mode(port, &rdev->etha->phy_interface); - of_node_put(port); + err = of_get_phy_mode(rdev->np_port, &rdev->etha->phy_interface); switch (rdev->etha->phy_interface) { case PHY_INTERFACE_MODE_MII: @@ -1133,7 +1115,7 @@ static int rswitch_mii_register(struct rswitch_device *rdev) mii_bus->write_c45 = rswitch_etha_mii_write_c45; mii_bus->parent = &rdev->priv->pdev->dev; - mdio_np = rswitch_get_mdio_node(rdev); + mdio_np = of_get_child_by_name(rdev->np_port, "mdio"); err = of_mdiobus_register(mii_bus, mdio_np); if (err < 0) { mdiobus_free(mii_bus); @@ -1185,12 +1167,9 @@ static const struct phylink_mac_ops rswitch_phylink_ops = { static int rswitch_phylink_init(struct rswitch_device *rdev) { - struct device_node *port; struct phylink *phylink; - int err; - port = rswitch_get_port_node(rdev); - if (!port) + if (!rdev->np_port) return -ENODEV; rdev->phylink_config.dev = &rdev->ndev->dev; @@ -1199,19 +1178,14 @@ static int rswitch_phylink_init(struct rswitch_device *rdev) __set_bit(PHY_INTERFACE_MODE_USXGMII, rdev->phylink_config.supported_interfaces); rdev->phylink_config.mac_capabilities = MAC_100FD | MAC_1000FD | MAC_2500FD; - phylink = phylink_create(&rdev->phylink_config, &port->fwnode, + phylink = phylink_create(&rdev->phylink_config, &rdev->np_port->fwnode, rdev->etha->phy_interface, &rswitch_phylink_ops); - if (IS_ERR(phylink)) { - err = PTR_ERR(phylink); - goto out; - } + if (IS_ERR(phylink)) + return PTR_ERR(phylink); rdev->phylink = phylink; - err = phylink_of_phy_connect(rdev->phylink, port, rdev->etha->phy_interface); -out: - of_node_put(port); - return err; + return phylink_of_phy_connect(rdev->phylink, rdev->np_port, rdev->etha->phy_interface); } static void rswitch_phylink_deinit(struct rswitch_device *rdev) @@ -1224,47 +1198,14 @@ static void rswitch_phylink_deinit(struct rswitch_device *rdev) static int rswitch_serdes_set_params(struct rswitch_device *rdev) { - struct device_node *port = rswitch_get_port_node(rdev); - struct phy *serdes; int err; - serdes = devm_of_phy_get(&rdev->priv->pdev->dev, port, NULL); - of_node_put(port); - if (IS_ERR(serdes)) - return PTR_ERR(serdes); - - err = phy_set_mode_ext(serdes, PHY_MODE_ETHERNET, + err = phy_set_mode_ext(rdev->serdes, PHY_MODE_ETHERNET, rdev->etha->phy_interface); if (err < 0) return err; - return phy_set_speed(serdes, rdev->etha->speed); -} - -static int rswitch_serdes_init(struct rswitch_device *rdev) -{ - struct device_node *port = rswitch_get_port_node(rdev); - struct phy *serdes; - - serdes = devm_of_phy_get(&rdev->priv->pdev->dev, port, NULL); - of_node_put(port); - if (IS_ERR(serdes)) - return PTR_ERR(serdes); - - return phy_init(serdes); -} - -static int rswitch_serdes_deinit(struct rswitch_device *rdev) -{ - struct device_node *port = rswitch_get_port_node(rdev); - struct phy *serdes; - - serdes = devm_of_phy_get(&rdev->priv->pdev->dev, port, NULL); - of_node_put(port); - if (IS_ERR(serdes)) - return PTR_ERR(serdes); - - return phy_exit(serdes); + return phy_set_speed(rdev->serdes, rdev->etha->speed); } static int rswitch_ether_port_init_one(struct rswitch_device *rdev) @@ -1286,6 +1227,12 @@ static int rswitch_ether_port_init_one(struct rswitch_device *rdev) if (err < 0) goto err_phylink_init; + rdev->serdes = devm_of_phy_get(&rdev->priv->pdev->dev, rdev->np_port, NULL); + if (IS_ERR(rdev->serdes)) { + err = PTR_ERR(rdev->serdes); + goto err_serdes_phy_get; + } + err = rswitch_serdes_set_params(rdev); if (err < 0) goto err_serdes_set_params; @@ -1293,6 +1240,7 @@ static int rswitch_ether_port_init_one(struct rswitch_device *rdev) return 0; err_serdes_set_params: +err_serdes_phy_get: rswitch_phylink_deinit(rdev); err_phylink_init: @@ -1318,7 +1266,7 @@ static int rswitch_ether_port_init_all(struct rswitch_private *priv) } rswitch_for_each_enabled_port(priv, i) { - err = rswitch_serdes_init(priv->rdev[i]); + err = phy_init(priv->rdev[i]->serdes); if (err) goto err_serdes; } @@ -1327,7 +1275,7 @@ static int rswitch_ether_port_init_all(struct rswitch_private *priv) err_serdes: rswitch_for_each_enabled_port_continue_reverse(priv, i) - rswitch_serdes_deinit(priv->rdev[i]); + phy_exit(priv->rdev[i]->serdes); i = RSWITCH_NUM_PORTS; err_init_one: @@ -1342,7 +1290,7 @@ static void rswitch_ether_port_deinit_all(struct rswitch_private *priv) int i; for (i = 0; i < RSWITCH_NUM_PORTS; i++) { - rswitch_serdes_deinit(priv->rdev[i]); + phy_exit(priv->rdev[i]->serdes); rswitch_ether_port_deinit_one(priv->rdev[i]); } } @@ -1565,7 +1513,6 @@ static int rswitch_device_alloc(struct rswitch_private *priv, int index) { struct platform_device *pdev = priv->pdev; struct rswitch_device *rdev; - struct device_node *port; struct net_device *ndev; int err; @@ -1594,10 +1541,10 @@ static int rswitch_device_alloc(struct rswitch_private *priv, int index) netif_napi_add(ndev, &rdev->napi, rswitch_poll); - port = rswitch_get_port_node(rdev); - rdev->disabled = !port; - err = of_get_ethdev_address(port, ndev); - of_node_put(port); + rdev->np_port = rswitch_get_port_node(rdev); + rdev->disabled = !rdev->np_port; + err = of_get_ethdev_address(rdev->np_port, ndev); + of_node_put(rdev->np_port); if (err) { if (is_valid_ether_addr(rdev->etha->mac_addr)) eth_hw_addr_set(ndev, rdev->etha->mac_addr); @@ -1798,7 +1745,7 @@ static void rswitch_deinit(struct rswitch_private *priv) for (i = 0; i < RSWITCH_NUM_PORTS; i++) { struct rswitch_device *rdev = priv->rdev[i]; - rswitch_serdes_deinit(rdev); + phy_exit(priv->rdev[i]->serdes); rswitch_ether_port_deinit_one(rdev); unregister_netdev(rdev->ndev); rswitch_device_free(priv, i); diff --git a/drivers/net/ethernet/renesas/rswitch.h b/drivers/net/ethernet/renesas/rswitch.h index 49efb0f31c77..6ae79395006e 100644 --- a/drivers/net/ethernet/renesas/rswitch.h +++ b/drivers/net/ethernet/renesas/rswitch.h @@ -953,6 +953,8 @@ struct rswitch_device { int port; struct rswitch_etha *etha; + struct device_node *np_port; + struct phy *serdes; }; struct rswitch_mfwd_mac_table_entry { From patchwork Fri Jan 27 14:26:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 13118790 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B3C4C54EAA for ; Fri, 27 Jan 2023 14:26:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232398AbjA0O0h (ORCPT ); Fri, 27 Jan 2023 09:26:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232659AbjA0O0f (ORCPT ); Fri, 27 Jan 2023 09:26:35 -0500 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 450C330B34; Fri, 27 Jan 2023 06:26:32 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.97,251,1669042800"; d="scan'208";a="147645294" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie5.idc.renesas.com with ESMTP; 27 Jan 2023 23:26:26 +0900 Received: from localhost.localdomain (unknown [10.166.15.32]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id EBA0F433ACC3; Fri, 27 Jan 2023 23:26:25 +0900 (JST) From: Yoshihiro Shimoda To: linux@armlinux.org.uk, andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH net-next v4 3/4] net: ethernet: renesas: rswitch: Enable ovr_host_interfaces Date: Fri, 27 Jan 2023 23:26:20 +0900 Message-Id: <20230127142621.1761278-4-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127142621.1761278-1-yoshihiro.shimoda.uh@renesas.com> References: <20230127142621.1761278-1-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Enable ovr_host_interfaces to set the host_interfaces of phy_dev for a non-sfp PHY. Signed-off-by: Yoshihiro Shimoda --- drivers/net/ethernet/renesas/rswitch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index 1c154018d795..b9addbc29ef9 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -1174,6 +1174,7 @@ static int rswitch_phylink_init(struct rswitch_device *rdev) rdev->phylink_config.dev = &rdev->ndev->dev; rdev->phylink_config.type = PHYLINK_NETDEV; + rdev->phylink_config.ovr_host_interfaces = true; __set_bit(PHY_INTERFACE_MODE_SGMII, rdev->phylink_config.supported_interfaces); __set_bit(PHY_INTERFACE_MODE_USXGMII, rdev->phylink_config.supported_interfaces); rdev->phylink_config.mac_capabilities = MAC_100FD | MAC_1000FD | MAC_2500FD; From patchwork Fri Jan 27 14:26:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 13118792 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B13F4C38142 for ; Fri, 27 Jan 2023 14:26:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232834AbjA0O0k (ORCPT ); Fri, 27 Jan 2023 09:26:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232785AbjA0O0f (ORCPT ); Fri, 27 Jan 2023 09:26:35 -0500 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F2BFA4709F; Fri, 27 Jan 2023 06:26:32 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.97,251,1669042800"; d="scan'208";a="150776286" Received: from unknown (HELO relmlir6.idc.renesas.com) ([10.200.68.152]) by relmlie6.idc.renesas.com with ESMTP; 27 Jan 2023 23:26:26 +0900 Received: from localhost.localdomain (unknown [10.166.15.32]) by relmlir6.idc.renesas.com (Postfix) with ESMTP id 19FBF433ACC5; Fri, 27 Jan 2023 23:26:26 +0900 (JST) From: Yoshihiro Shimoda To: linux@armlinux.org.uk, andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: netdev@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Yoshihiro Shimoda Subject: [PATCH net-next v4 4/4] net: ethernet: renesas: rswitch: Add phy_power_{on,off}() calling Date: Fri, 27 Jan 2023 23:26:21 +0900 Message-Id: <20230127142621.1761278-5-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230127142621.1761278-1-yoshihiro.shimoda.uh@renesas.com> References: <20230127142621.1761278-1-yoshihiro.shimoda.uh@renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Some Ethernet PHYs (like marvell10g) will decide the host interface mode by the media-side speed. So, the rswitch driver needs to initialize one of the Ethernet SERDES (r8a779f0-eth-serdes) ports after linked the Ethernet PHY up. The r8a779f0-eth-serdes driver has .init() for initializing all ports and .power_on() for initializing each port. So, add phy_power_{on,off} calling for it. Notes that in-band mode will not work because the initialization is not completed. So, output error message if in-band mode. Signed-off-by: Yoshihiro Shimoda --- drivers/net/ethernet/renesas/rswitch.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index b9addbc29ef9..7bdfcb5270c0 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -1143,12 +1143,20 @@ static void rswitch_mac_config(struct phylink_config *config, unsigned int mode, const struct phylink_link_state *state) { + struct net_device *ndev = to_net_dev(config->dev); + + if (mode == MLO_AN_INBAND) + netdev_err(ndev, "Link up/down will not work because in-band mode\n"); } static void rswitch_mac_link_down(struct phylink_config *config, unsigned int mode, phy_interface_t interface) { + struct net_device *ndev = to_net_dev(config->dev); + struct rswitch_device *rdev = netdev_priv(ndev); + + phy_power_off(rdev->serdes); } static void rswitch_mac_link_up(struct phylink_config *config, @@ -1156,7 +1164,11 @@ static void rswitch_mac_link_up(struct phylink_config *config, phy_interface_t interface, int speed, int duplex, bool tx_pause, bool rx_pause) { + struct net_device *ndev = to_net_dev(config->dev); + struct rswitch_device *rdev = netdev_priv(ndev); + /* Current hardware cannot change speed at runtime */ + phy_power_on(rdev->serdes); } static const struct phylink_mac_ops rswitch_phylink_ops = {