From patchwork Mon Dec 26 07:14:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 13081680 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 50160C3DA79 for ; Mon, 26 Dec 2022 07:14:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231611AbiLZHOh (ORCPT ); Mon, 26 Dec 2022 02:14:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53598 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbiLZHOf (ORCPT ); Mon, 26 Dec 2022 02:14:35 -0500 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id AFE242BF5; Sun, 25 Dec 2022 23:14:33 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.96,274,1665414000"; d="scan'208";a="147425267" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 26 Dec 2022 16:14:33 +0900 Received: from localhost.localdomain (unknown [10.166.15.32]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 0CEC54003FA1; Mon, 26 Dec 2022 16:14:33 +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 1/3] net: phylink: Set host_interfaces for a non-sfp PHY Date: Mon, 26 Dec 2022 16:14:23 +0900 Message-Id: <20221226071425.3895915-2-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221226071425.3895915-1-yoshihiro.shimoda.uh@renesas.com> References: <20221226071425.3895915-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 Set phy_dev->host_interfaces by pl->link_interface in phylink_fwnode_phy_connect() for a non-sfp PHY. Signed-off-by: Yoshihiro Shimoda --- drivers/net/phy/phylink.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index 09cc65c0da93..1958d6cc9ef9 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -1809,6 +1809,7 @@ int phylink_fwnode_phy_connect(struct phylink *pl, pl->link_interface = phy_dev->interface; pl->link_config.interface = pl->link_interface; } + __set_bit(pl->link_interface, phy_dev->host_interfaces); ret = phy_attach_direct(pl->netdev, phy_dev, flags, pl->link_interface); From patchwork Mon Dec 26 07:14:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 13081682 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 14F14C46467 for ; Mon, 26 Dec 2022 07:14:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229643AbiLZHOi (ORCPT ); Mon, 26 Dec 2022 02:14:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53612 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229741AbiLZHOf (ORCPT ); Mon, 26 Dec 2022 02:14:35 -0500 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id C30222BFA; Sun, 25 Dec 2022 23:14:34 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.96,274,1665414000"; d="scan'208";a="144515785" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 26 Dec 2022 16:14:33 +0900 Received: from localhost.localdomain (unknown [10.166.15.32]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 2F09C4003FA1; Mon, 26 Dec 2022 16:14:33 +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 2/3] net: ethernet: renesas: rswitch: Simplify struct phy * handling Date: Mon, 26 Dec 2022 16:14:24 +0900 Message-Id: <20221226071425.3895915-3-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221226071425.3895915-1-yoshihiro.shimoda.uh@renesas.com> References: <20221226071425.3895915-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 | 40 ++++++++++++-------------- drivers/net/ethernet/renesas/rswitch.h | 1 + 2 files changed, 19 insertions(+), 22 deletions(-) diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index 6441892636db..ca79ee168206 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -1235,49 +1235,40 @@ static void rswitch_phylink_deinit(struct rswitch_device *rdev) phylink_destroy(rdev->phylink); } -static int rswitch_serdes_set_params(struct rswitch_device *rdev) +static int rswitch_serdes_phy_get(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); + rdev->serdes = serdes; + + return 0; +} + +static int rswitch_serdes_set_params(struct rswitch_device *rdev) +{ + int err; - 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); + return phy_set_speed(rdev->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); + return phy_init(rdev->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_exit(rdev->serdes); } static int rswitch_ether_port_init_one(struct rswitch_device *rdev) @@ -1299,6 +1290,10 @@ static int rswitch_ether_port_init_one(struct rswitch_device *rdev) if (err < 0) goto err_phylink_init; + err = rswitch_serdes_phy_get(rdev); + if (err < 0) + goto err_serdes_phy_get; + err = rswitch_serdes_set_params(rdev); if (err < 0) goto err_serdes_set_params; @@ -1306,6 +1301,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: diff --git a/drivers/net/ethernet/renesas/rswitch.h b/drivers/net/ethernet/renesas/rswitch.h index edbdd1b98d3d..d9a0be6666f5 100644 --- a/drivers/net/ethernet/renesas/rswitch.h +++ b/drivers/net/ethernet/renesas/rswitch.h @@ -941,6 +941,7 @@ struct rswitch_device { int port; struct rswitch_etha *etha; + struct phy *serdes; }; struct rswitch_mfwd_mac_table_entry { From patchwork Mon Dec 26 07:14:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yoshihiro Shimoda X-Patchwork-Id: 13081683 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 56D47C4708E for ; Mon, 26 Dec 2022 07:14:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231637AbiLZHOk (ORCPT ); Mon, 26 Dec 2022 02:14:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53616 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231585AbiLZHOg (ORCPT ); Mon, 26 Dec 2022 02:14:36 -0500 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 209FE2DC3; Sun, 25 Dec 2022 23:14:35 -0800 (PST) X-IronPort-AV: E=Sophos;i="5.96,274,1665414000"; d="scan'208";a="144515790" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 26 Dec 2022 16:14:33 +0900 Received: from localhost.localdomain (unknown [10.166.15.32]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 4762C4003FDF; Mon, 26 Dec 2022 16:14:33 +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 3/3] net: ethernet: renesas: rswitch: Add phy_power_{on,off}() calling Date: Mon, 26 Dec 2022 16:14:25 +0900 Message-Id: <20221226071425.3895915-4-yoshihiro.shimoda.uh@renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221226071425.3895915-1-yoshihiro.shimoda.uh@renesas.com> References: <20221226071425.3895915-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. Signed-off-by: Yoshihiro Shimoda --- drivers/net/ethernet/renesas/rswitch.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/ethernet/renesas/rswitch.c b/drivers/net/ethernet/renesas/rswitch.c index ca79ee168206..2f335c95f5a8 100644 --- a/drivers/net/ethernet/renesas/rswitch.c +++ b/drivers/net/ethernet/renesas/rswitch.c @@ -1180,6 +1180,10 @@ 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, @@ -1187,7 +1191,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 = {