From patchwork Wed Mar 22 11:59:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 666236 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 DC7A5C6FD1C for ; Wed, 22 Mar 2023 12:00:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230304AbjCVMAJ (ORCPT ); Wed, 22 Mar 2023 08:00:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230297AbjCVMAI (ORCPT ); Wed, 22 Mar 2023 08:00:08 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4730957D13; Wed, 22 Mar 2023 05:00:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=XgMHT2HBO+8IToVuu3CA3Bsm2bp98QNQ8P5z5X5y8NU=; b=0NtkeN4qMvD7jDiREWvOyJSCU0 f3Lv1ZtKAZb9ei8pVbIdKxj+P3SZjrBkDw7+h48o84JIklRnwWW1x7B5aQobKV2iUUu3KKPzdgJlK nplWfaw+n33TZMDanvNXgjErMpdTWvYMW+bf3KA39R0JE20QLhhcbv2hoL/TkDUNlBp+WoWcERamu z9WKfuzbv2muUa7lEWqc0Ysu5BlXc25XlLIuEpl12l2mY10qBW4BEQsTaz0H5N4+kxzC03VMVvwxS ye404ej6R97DeeigjNz17nHAQ9/55auGtNK+SVqJOLdQQ8gglSQ5h6ZLQ0PQrXcipWdvV2ZNP6KeP mbDf02aQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:37338 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pex8G-00035B-Ig; Wed, 22 Mar 2023 11:59:56 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1pex8F-00Dvnf-Sm; Wed, 22 Mar 2023 11:59:55 +0000 In-Reply-To: References: From: Russell King (Oracle) To: Andrew Lunn , Heiner Kallweit Cc: Andy Shevchenko , Daniel Scally , "David S. Miller" , Eric Dumazet , Florian Fainelli , Greg Kroah-Hartman , Heikki Krogerus , Jakub Kicinski , linux-acpi@vger.kernel.org, netdev@vger.kernel.org, Paolo Abeni , "Rafael J. Wysocki" , Sakari Ailus , Vladimir Oltean Subject: [PATCH RFC net-next 1/7] software node: allow named software node to be created MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 22 Mar 2023 11:59:55 +0000 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Vladimir Oltean Allow a named software node to be created, which is needed for software nodes for a fixed-link specification for DSA. Signed-off-by: Vladimir Oltean Signed-off-by: Russell King (Oracle) --- drivers/base/swnode.c | 14 ++++++++++++-- include/linux/property.h | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c index 1886995a0b3a..e4d07e1655a9 100644 --- a/drivers/base/swnode.c +++ b/drivers/base/swnode.c @@ -911,8 +911,9 @@ void software_node_unregister(const struct software_node *node) EXPORT_SYMBOL_GPL(software_node_unregister); struct fwnode_handle * -fwnode_create_software_node(const struct property_entry *properties, - const struct fwnode_handle *parent) +fwnode_create_named_software_node(const struct property_entry *properties, + const struct fwnode_handle *parent, + const char *name) { struct fwnode_handle *fwnode; struct software_node *node; @@ -930,6 +931,7 @@ fwnode_create_software_node(const struct property_entry *properties, return ERR_CAST(node); node->parent = p ? p->node : NULL; + node->name = name; fwnode = swnode_register(node, p, 1); if (IS_ERR(fwnode)) @@ -937,6 +939,14 @@ fwnode_create_software_node(const struct property_entry *properties, return fwnode; } +EXPORT_SYMBOL_GPL(fwnode_create_named_software_node); + +struct fwnode_handle * +fwnode_create_software_node(const struct property_entry *properties, + const struct fwnode_handle *parent) +{ + return fwnode_create_named_software_node(properties, parent, NULL); +} EXPORT_SYMBOL_GPL(fwnode_create_software_node); void fwnode_remove_software_node(struct fwnode_handle *fwnode) diff --git a/include/linux/property.h b/include/linux/property.h index 0a29db15ff34..f7100e836eb4 100644 --- a/include/linux/property.h +++ b/include/linux/property.h @@ -495,6 +495,10 @@ void software_node_unregister(const struct software_node *node); struct fwnode_handle * fwnode_create_software_node(const struct property_entry *properties, const struct fwnode_handle *parent); +struct fwnode_handle * +fwnode_create_named_software_node(const struct property_entry *properties, + const struct fwnode_handle *parent, + const char *name); void fwnode_remove_software_node(struct fwnode_handle *fwnode); int device_add_software_node(struct device *dev, const struct software_node *node); From patchwork Wed Mar 22 12:00:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 665934 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 19043C6FD1F for ; Wed, 22 Mar 2023 12:00:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230013AbjCVMAS (ORCPT ); Wed, 22 Mar 2023 08:00:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230316AbjCVMAP (ORCPT ); Wed, 22 Mar 2023 08:00:15 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D497F58B70; Wed, 22 Mar 2023 05:00:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZpAtKl/RV4mqUVq/4aXiz/Cd3G2od94mTwE3ws+jErE=; b=xWAZS+Epu9VEE+Q1zJyJkkG5P0 RCe1jX/Ke7K54z2sAcwM/RRGjbwfjn642BDtIRudf7IyrQUIU2Hv0QZ+CuX/zyOIjva31JJTlKPrX Zrob4y4ZzWktR31ueqz0Kz/XfGOyvLQi9F4aeGZb3UvfcvaI58jT481OAvfNmSuDETMTlWBq1ywvU t0Sl7vDq47VS9F/6G4BaXk5IA5i6Hix2s3Sm3nhgGCmET4T+lr8fLNH+zDx44uW+aUzr1tGm2sZSL RJFF9mnrU4Ydx+dubFMrchiBu3Pq/gj7+LtaIJioFotxGiguJYKCYgXOYhjxhVHfVm5nR7qNBl5A9 bc12tJ2Q==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:37350 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pex8L-00035Q-QF; Wed, 22 Mar 2023 12:00:01 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1pex8L-00Dvnl-1F; Wed, 22 Mar 2023 12:00:01 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Andy Shevchenko , Daniel Scally , "David S. Miller" , Eric Dumazet , Florian Fainelli , Greg Kroah-Hartman , Heikki Krogerus , Jakub Kicinski , linux-acpi@vger.kernel.org, netdev@vger.kernel.org, Paolo Abeni , "Rafael J. Wysocki" , Sakari Ailus , Vladimir Oltean Subject: [PATCH RFC net-next 2/7] net: phylink: provide phylink_find_max_speed() MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 22 Mar 2023 12:00:01 +0000 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Signed-off-by: Russell King (Oracle) Reviewed-by: Andrew Lunn --- drivers/net/phy/phylink.c | 32 ++++++++++++++++++++++++++++++++ include/linux/phylink.h | 1 + 2 files changed, 33 insertions(+) diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c index f7da96f0c75b..5cd29cceaf93 100644 --- a/drivers/net/phy/phylink.c +++ b/drivers/net/phy/phylink.c @@ -426,6 +426,38 @@ static unsigned long phylink_cap_from_speed_duplex(int speed, return 0; } +/** + * phylink_find_max_speed + * @caps: bitmask of MAC capabilities + * @speed: pointer to int for speed + * @duplex: pointer to int for duplex + */ +int phylink_find_max_speed(unsigned long caps, int *speed, int *duplex) +{ + static const int duplex_order[] = { + DUPLEX_FULL, + DUPLEX_HALF, + }; + int i, j; + + *speed = SPEED_UNKNOWN; + *duplex = DUPLEX_UNKNOWN; + + for (j = 0; j < ARRAY_SIZE(duplex_order); j++) { + for (i = 0; i < ARRAY_SIZE(phylink_caps_params); i++) { + if (phylink_caps_params[i].duplex == duplex_order[j] && + caps & phylink_caps_params[i].mask) { + *speed = phylink_caps_params[i].speed; + *duplex = phylink_caps_params[i].duplex; + return 0; + } + } + } + + return -EINVAL; +} +EXPORT_SYMBOL_GPL(phylink_find_max_speed); + /** * phylink_get_capabilities() - get capabilities for a given MAC * @interface: phy interface mode defined by &typedef phy_interface_t diff --git a/include/linux/phylink.h b/include/linux/phylink.h index 9ff56b050584..f8e20ff1e70e 100644 --- a/include/linux/phylink.h +++ b/include/linux/phylink.h @@ -557,6 +557,7 @@ void pcs_link_up(struct phylink_pcs *pcs, unsigned int mode, phy_interface_t interface, int speed, int duplex); #endif +int phylink_find_max_speed(unsigned long caps, int *speed, int *duplex); void phylink_caps_to_linkmodes(unsigned long *linkmodes, unsigned long caps); unsigned long phylink_get_capabilities(phy_interface_t interface, unsigned long mac_capabilities, From patchwork Wed Mar 22 12:00:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 665933 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 BF1E5C761A6 for ; Wed, 22 Mar 2023 12:00:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229767AbjCVMAS (ORCPT ); Wed, 22 Mar 2023 08:00:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46352 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230329AbjCVMAQ (ORCPT ); Wed, 22 Mar 2023 08:00:16 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84DF3570B0; Wed, 22 Mar 2023 05:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=P/qDIKEXByHY2/N3TKS7+nB/0HfKOu7KPqR9nLtkfwE=; b=eDF75J5J8rXizfk3r2+FDs3dOa 35Mmj9z1ZUBXXoKN46KAXYg4dU1BeI/nDOhxYUmxQxRol7BbnVOhTGmY/Z5qH8QI540kjOBwfAwlZ MaGz4YrU8bw3hSn4LRSQdnlA6yTuBflUs8phNy0TV3Afv9nLD8KWXeS86OUmGbEUQkoULypZcnW2+ UZzJ+GoxwBOu4kaER3zm5mRJXlvGQH809xy8nY4xGxh0+2a7Y8vPHkfWQCHmai35eBi9HTSEh8rSJ zALShRUX541MexaRUzESybEvd09uvvVrT9RMrsSzs+kzQcoCJpUSidoSLp7xDUVy/nHPvRirClQD7 OrTXx+qw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:60880 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pex8Q-00035i-SG; Wed, 22 Mar 2023 12:00:06 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1pex8Q-00Dvnr-5y; Wed, 22 Mar 2023 12:00:06 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Andy Shevchenko , Daniel Scally , "David S. Miller" , Eric Dumazet , Florian Fainelli , Greg Kroah-Hartman , Heikki Krogerus , Jakub Kicinski , linux-acpi@vger.kernel.org, netdev@vger.kernel.org, Paolo Abeni , "Rafael J. Wysocki" , Sakari Ailus , Vladimir Oltean Subject: [PATCH RFC net-next 3/7] net: dsa: use fwnode_get_phy_mode() to get phy interface mode MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 22 Mar 2023 12:00:06 +0000 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org In preparation for supporting the use of software nodes to setup phylink, switch DSA to use fwnode_get_phy_mode() to retrieve the phy interface mode, rather than using of_get_phy_mode() which is DT specific. Signed-off-by: Russell King (Oracle) --- net/dsa/port.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/net/dsa/port.c b/net/dsa/port.c index 67ad1adec2a2..07f9cb374a5d 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -1678,13 +1678,9 @@ static const struct phylink_mac_ops dsa_port_phylink_mac_ops = { int dsa_port_phylink_create(struct dsa_port *dp) { struct dsa_switch *ds = dp->ds; - phy_interface_t mode; + struct fwnode_handle *fwnode; struct phylink *pl; - int err; - - err = of_get_phy_mode(dp->dn, &mode); - if (err) - mode = PHY_INTERFACE_MODE_NA; + int mode; /* Presence of phylink_mac_link_state or phylink_mac_an_restart is * an indicator of a legacy phylink driver. @@ -1696,8 +1692,14 @@ int dsa_port_phylink_create(struct dsa_port *dp) if (ds->ops->phylink_get_caps) ds->ops->phylink_get_caps(ds, dp->index, &dp->pl_config); - pl = phylink_create(&dp->pl_config, of_fwnode_handle(dp->dn), - mode, &dsa_port_phylink_mac_ops); + fwnode = of_fwnode_handle(dp->dn); + + mode = fwnode_get_phy_mode(fwnode); + if (mode < 0) + mode = PHY_INTERFACE_MODE_NA; + + pl = phylink_create(&dp->pl_config, fwnode, mode, + &dsa_port_phylink_mac_ops); if (IS_ERR(pl)) { pr_err("error creating PHYLINK: %ld\n", PTR_ERR(pl)); return PTR_ERR(pl); From patchwork Wed Mar 22 12:00:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 666235 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 78CA5C77B60 for ; Wed, 22 Mar 2023 12:00:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229937AbjCVMAT (ORCPT ); Wed, 22 Mar 2023 08:00:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230297AbjCVMAS (ORCPT ); Wed, 22 Mar 2023 08:00:18 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 73850580C0; Wed, 22 Mar 2023 05:00:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=LMKWKeCd1jHrdcZOpqY/W1TGL/nIE2xtHM8njertImI=; b=S3ppIpjbNNM3fsLlzkTbFKVTJ/ mOxEJfbHzu2NlGTffmHYb+9kLkbKFNeExs6k4NDVy3CcEfezUkiXOr8dPHMB+oLYPcGdRPSJkWLKA /CyXN3RpZAXV0mFcdtCU3E61PnP4pEG1ptSXibHBCaGTicZ6Z1J0YIyPGZBNrLmzZtmWZ7bvUpuNN gyrDjbaQ6U9H4ALBJbYxi5ZerhmB1ZPcBLxyKx4Ue/bhloZr7AQtvV7YaLtp7Pbgkarp6SlUC024B FDIab0iUWtxpOoXY7nCLh9W/c+vTMoyY/58J5WJAGh0/5DMYLIv2eRtmgQnJnVsfV7IpqckYrK1qG 4Za7AMdQ==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:60894 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pex8W-00035z-1a; Wed, 22 Mar 2023 12:00:12 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1pex8V-00Dvnx-B2; Wed, 22 Mar 2023 12:00:11 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Andy Shevchenko , Daniel Scally , "David S. Miller" , Eric Dumazet , Florian Fainelli , Greg Kroah-Hartman , Heikki Krogerus , Jakub Kicinski , linux-acpi@vger.kernel.org, netdev@vger.kernel.org, Paolo Abeni , "Rafael J. Wysocki" , Sakari Ailus , Vladimir Oltean Subject: [PATCH RFC net-next 4/7] net: dsa: add ability for switch driver to provide a swnode MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 22 Mar 2023 12:00:11 +0000 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Add a method to dsa_switch_ops to allow a switch driver to override the fwnode used to setup phylink for a port. This will be used for the Marvell 88e6xxx driver to provide its "maximum interface" and "maximum speed" mode to keep compatibility with existing behaviour for CPU and DSA ports via a swnode-backed fwnode. We need to release the swnode after phylink_create() has completed no matter what the outcome was. Signed-off-by: Russell King (Oracle) --- include/net/dsa.h | 3 +++ net/dsa/port.c | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/include/net/dsa.h b/include/net/dsa.h index a15f17a38eca..764f3e74448b 100644 --- a/include/net/dsa.h +++ b/include/net/dsa.h @@ -854,6 +854,9 @@ struct dsa_switch_ops { */ int (*port_setup)(struct dsa_switch *ds, int port); void (*port_teardown)(struct dsa_switch *ds, int port); + struct fwnode_handle *(*port_get_fwnode)(struct dsa_switch *ds, + int port, + struct fwnode_handle *h); u32 (*get_phy_flags)(struct dsa_switch *ds, int port); diff --git a/net/dsa/port.c b/net/dsa/port.c index 07f9cb374a5d..c30e3a7d2145 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -1693,6 +1693,15 @@ int dsa_port_phylink_create(struct dsa_port *dp) ds->ops->phylink_get_caps(ds, dp->index, &dp->pl_config); fwnode = of_fwnode_handle(dp->dn); + if (ds->ops->port_get_fwnode) { + fwnode = ds->ops->port_get_fwnode(ds, dp->index, fwnode); + if (IS_ERR(fwnode)) { + dev_err(ds->dev, + "Failed to get fwnode for port %d: %pe\n", + dp->index, fwnode); + return PTR_ERR(fwnode); + } + } mode = fwnode_get_phy_mode(fwnode); if (mode < 0) @@ -1700,6 +1709,9 @@ int dsa_port_phylink_create(struct dsa_port *dp) pl = phylink_create(&dp->pl_config, fwnode, mode, &dsa_port_phylink_mac_ops); + + fwnode_remove_software_node(fwnode); + if (IS_ERR(pl)) { pr_err("error creating PHYLINK: %ld\n", PTR_ERR(pl)); return PTR_ERR(pl); From patchwork Wed Mar 22 12:00:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 666234 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 E76D1C6FD1F for ; Wed, 22 Mar 2023 12:00:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230297AbjCVMAa (ORCPT ); Wed, 22 Mar 2023 08:00:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230357AbjCVMAV (ORCPT ); Wed, 22 Mar 2023 08:00:21 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2E17A58C08; Wed, 22 Mar 2023 05:00:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8nTXt9jwCRvOhTsm0b98Gb8SczR5k6rwx9F+YdbECbg=; b=It1DEF6JvIsPSYpkNMbiq/hfH3 g/C6n2PDShXjrOiRdjUXqU3nAv1ZLuOMlnl39hRvyD4fW2FVgtxXBuW8pZdULpn1UXyYZbWEFLBWo 3P0WS183DyR1NcrHOozpc+ECG3IyLnXwylzjICxSdKlohqr75LXXKUsFnU/+0AYswl7QnFsGpY5ag Kak9lqzTfS2lWfAr5Cnd1nSSxxrNn8kmvjspshizwSLYl79C095IlnE7Ic1MbKB+cuHvw78XBkOAk Wm2xdt7cmTRg7D4hYAfZxTHVpP7M8pl0LGJXJTfK09KIEMaMW7Rar8ZYJF1dWii+q87h94wN62xFC mpIzYeqw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:45528 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pex8b-00036M-6A; Wed, 22 Mar 2023 12:00:17 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1pex8a-00Dvo3-G7; Wed, 22 Mar 2023 12:00:16 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Andy Shevchenko , Daniel Scally , "David S. Miller" , Eric Dumazet , Florian Fainelli , Greg Kroah-Hartman , Heikki Krogerus , Jakub Kicinski , linux-acpi@vger.kernel.org, netdev@vger.kernel.org, Paolo Abeni , "Rafael J. Wysocki" , Sakari Ailus , Vladimir Oltean Subject: [PATCH RFC net-next 5/7] net: dsa: avoid DT validation for drivers which provide default config MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 22 Mar 2023 12:00:16 +0000 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org When a DSA driver (e.g. mv88e6xxx) provides a default configuration, avoid validating the DT description as missing elements will be provided by the DSA driver. Signed-off-by: Russell King (Oracle) --- net/dsa/port.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/dsa/port.c b/net/dsa/port.c index c30e3a7d2145..23d9970c02d3 100644 --- a/net/dsa/port.c +++ b/net/dsa/port.c @@ -1951,6 +1951,9 @@ static void dsa_shared_port_validate_of(struct dsa_port *dp, *missing_phy_mode = false; *missing_link_description = false; + if (dp->ds->ops->port_get_fwnode) + return; + if (of_get_phy_mode(dn, &mode)) { *missing_phy_mode = true; dev_err(ds->dev, From patchwork Wed Mar 22 12:00:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 665932 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 34CA3C6FD1F for ; Wed, 22 Mar 2023 12:00:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230497AbjCVMAo (ORCPT ); Wed, 22 Mar 2023 08:00:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230370AbjCVMAk (ORCPT ); Wed, 22 Mar 2023 08:00:40 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B98A25D263; Wed, 22 Mar 2023 05:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=KJBQQ1PBt+CBAtmD4WG9aowdjIwjYCP4sx9s51U3L4c=; b=sd1grvSW0dLEvw8ZmoyTQtJEDR B2ZqpDjJLoFiVreCelFX+Rhu/sS3QPIlFEL/AR+aWGV0Vo9LSQT+KTNDH+oHU/elG3uV2Xd6oL2Dz VnZDLkYQAT5gqU6lt6VHb/HQcKMNaqIxbs0Lm9VAGOw22jSp7BYNWT/UWqkN3yojHOmQZhzxVVjcb fgTCcFjANA/siJ0/wnEYuxU9nSY627Dv6Yn0hkf5AIDMIRcYIVTZTsYJVCVOFgkoinGL4yMsEAX6g Zt1nZ+tetY450w9ntKZd3MA5lg23yr/LfRxUsPe7XpfvD6ENbJd9QYrHNH3Iji8RxIwV545TRX6pC SzH/mB0Q==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:45536 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pex8g-00036s-Ac; Wed, 22 Mar 2023 12:00:22 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1pex8f-00Dvo9-KT; Wed, 22 Mar 2023 12:00:21 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Andy Shevchenko , Daniel Scally , "David S. Miller" , Eric Dumazet , Florian Fainelli , Greg Kroah-Hartman , Heikki Krogerus , Jakub Kicinski , linux-acpi@vger.kernel.org, netdev@vger.kernel.org, Paolo Abeni , "Rafael J. Wysocki" , Sakari Ailus , Vladimir Oltean Subject: [PATCH RFC net-next 6/7] net: dsa: mv88e6xxx: provide software node for default settings MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 22 Mar 2023 12:00:21 +0000 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Provide a software node for default settings when no phy, sfp or fixed link is specified. Signed-off-by: Russell King (Oracle) --- drivers/net/dsa/mv88e6xxx/chip.c | 109 +++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index b73d1d6747b7..dde0c306fb3a 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -841,6 +842,113 @@ static void mv88e6xxx_get_caps(struct dsa_switch *ds, int port, } } +static struct fwnode_handle *mv88e6xxx_create_fixed_swnode(struct fwnode_handle *parent, + int speed, + int duplex) +{ + struct property_entry fixed_link_props[3] = { }; + + fixed_link_props[0] = PROPERTY_ENTRY_U32("speed", speed); + if (duplex == DUPLEX_FULL) + fixed_link_props[1] = PROPERTY_ENTRY_BOOL("full-duplex"); + + return fwnode_create_named_software_node(fixed_link_props, parent, + "fixed-link"); +} + +static struct fwnode_handle *mv88e6xxx_create_port_swnode(phy_interface_t mode, + int speed, + int duplex) +{ + struct property_entry port_props[2] = {}; + struct fwnode_handle *fixed_link_fwnode; + struct fwnode_handle *new_port_fwnode; + + port_props[0] = PROPERTY_ENTRY_STRING("phy-mode", phy_modes(mode)); + new_port_fwnode = fwnode_create_software_node(port_props, NULL); + if (IS_ERR(new_port_fwnode)) + return new_port_fwnode; + + fixed_link_fwnode = mv88e6xxx_create_fixed_swnode(new_port_fwnode, + speed, duplex); + if (IS_ERR(fixed_link_fwnode)) { + fwnode_remove_software_node(new_port_fwnode); + return fixed_link_fwnode; + } + + return new_port_fwnode; +} + +static unsigned long mv88e6xxx_get_max_caps(struct phylink_config *config, + phy_interface_t *mode) +{ + unsigned long max_caps, caps, mac_caps; + phy_interface_t interface; + + mac_caps = config->mac_capabilities; + if (*mode != PHY_INTERFACE_MODE_NA) + return phylink_get_capabilities(*mode, mac_caps, + RATE_MATCH_NONE); + + max_caps = 0; + for_each_set_bit(interface, config->supported_interfaces, + PHY_INTERFACE_MODE_MAX) { + caps = phylink_get_capabilities(interface, mac_caps, + RATE_MATCH_NONE); + if (caps > max_caps) { + max_caps = caps; + *mode = interface; + } + } + + return max_caps; +} + +static struct fwnode_handle *mv88e6xxx_port_get_fwnode(struct dsa_switch *ds, + int port, + struct fwnode_handle *h) +{ + struct mv88e6xxx_chip *chip = ds->priv; + struct device_node *np, *phy_node; + int speed, duplex, err; + phy_interface_t mode; + struct dsa_port *dp; + unsigned long caps; + + dp = dsa_to_port(ds, port); + if (dsa_port_is_user(dp)) + return h; + + /* No DT? Eh? */ + np = to_of_node(h); + if (!np) + return h; + + /* If a PHY, fixed-link specification, or in-band mode, then we + * don't need to do any fixup. Simply return the provided fwnode. + */ + phy_node = of_parse_phandle(np, "phy-handle", 0); + of_node_put(phy_node); + if (phy_node || of_phy_is_fixed_link(np)) + return h; + + /* Get the DT specified phy-mode. If missing, try the chip's max speed + * mode method if implemented, otherwise try the supported_interfaces + * mask for the interface mode that gives the fastest speeds. + */ + err = of_get_phy_mode(np, &mode); + if (err && chip->info->ops->port_max_speed_mode) + mode = chip->info->ops->port_max_speed_mode(port); + + caps = mv88e6xxx_get_max_caps(&dp->pl_config, &mode); + + err = phylink_find_max_speed(caps, &speed, &duplex); + if (err) + return ERR_PTR(err); + + return mv88e6xxx_create_port_swnode(mode, speed, duplex); +} + static void mv88e6xxx_mac_config(struct dsa_switch *ds, int port, unsigned int mode, const struct phylink_link_state *state) @@ -6994,6 +7102,7 @@ static const struct dsa_switch_ops mv88e6xxx_switch_ops = { .teardown = mv88e6xxx_teardown, .port_setup = mv88e6xxx_port_setup, .port_teardown = mv88e6xxx_port_teardown, + .port_get_fwnode = mv88e6xxx_port_get_fwnode, .phylink_get_caps = mv88e6xxx_get_caps, .phylink_mac_link_state = mv88e6xxx_serdes_pcs_get_state, .phylink_mac_config = mv88e6xxx_mac_config, From patchwork Wed Mar 22 12:00:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Russell King \(Oracle\)" X-Patchwork-Id: 666233 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 70599C6FD1C for ; Wed, 22 Mar 2023 12:00:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230076AbjCVMAx (ORCPT ); Wed, 22 Mar 2023 08:00:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230454AbjCVMAn (ORCPT ); Wed, 22 Mar 2023 08:00:43 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 710F85D898; Wed, 22 Mar 2023 05:00:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Date:Sender:Message-Id:Content-Type: Content-Transfer-Encoding:MIME-Version:Subject:Cc:To:From:References: In-Reply-To:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=C/XopkrHSruhQua4EDHj5yjjnPImZ/En/wTRBJCzjiY=; b=bcDjKlwK2fma6eRRmDN8WLysZm KhymViMWNAaIPFvvwU5jseL+izR7nP421pn/joDGoStk94T5MK1T8rCdBqsgPkYkHh8FmaQS+0Uq/ FdxlBpHRyk/0oxduiK6AMupkEXEAEUekwlwgHaEYd9QuPEr/EkPtWxhTMEV4uZCBSY900kxk1qc/K WuwJN4OGcCNvhOJJbaZbPEQz2VaVrCKVAb6DGCWIlUD6WfdsMY/sxReC/x4ZgAPGwmjddXvm0zQDs TrjbXoH251GLjdgPqC2EttgMAr4dGKMpcyAnBSLiIY1gizqCJjE2vOSRt54eH8a6YkelAN/DYFkje wQkCzGIw==; Received: from e0022681537dd.dyn.armlinux.org.uk ([fd8f:7570:feb6:1:222:68ff:fe15:37dd]:45962 helo=rmk-PC.armlinux.org.uk) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pex8l-00037L-Ey; Wed, 22 Mar 2023 12:00:27 +0000 Received: from rmk by rmk-PC.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1pex8k-00DvoF-PF; Wed, 22 Mar 2023 12:00:26 +0000 In-Reply-To: References: From: "Russell King (Oracle)" To: Andrew Lunn , Heiner Kallweit Cc: Andy Shevchenko , Daniel Scally , "David S. Miller" , Eric Dumazet , Florian Fainelli , Greg Kroah-Hartman , Heikki Krogerus , Jakub Kicinski , linux-acpi@vger.kernel.org, netdev@vger.kernel.org, Paolo Abeni , "Rafael J. Wysocki" , Sakari Ailus , Vladimir Oltean Subject: [PATCH RFC net-next 7/7] net: dsa: mv88e6xxx: remove handling for DSA and CPU ports MIME-Version: 1.0 Content-Disposition: inline Message-Id: Sender: Russell King Date: Wed, 22 Mar 2023 12:00:26 +0000 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org As we now always use a fixed-link for DSA and CPU ports, we no longer need the hack in the Marvell code to make this work. Remove it. This is especially important with the conversion of DSA drivers to phylink_pcs, as the PCS code only gets called if we are using phylink for the port. Signed-off-by: Russell King (Oracle) --- drivers/net/dsa/mv88e6xxx/chip.c | 48 ++++---------------------------- 1 file changed, 5 insertions(+), 43 deletions(-) diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c index dde0c306fb3a..35dcfe86bdc4 100644 --- a/drivers/net/dsa/mv88e6xxx/chip.c +++ b/drivers/net/dsa/mv88e6xxx/chip.c @@ -3395,56 +3395,17 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) { struct device_node *phy_handle = NULL; struct dsa_switch *ds = chip->ds; - phy_interface_t mode; struct dsa_port *dp; - int tx_amp, speed; + int tx_amp; int err; u16 reg; chip->ports[port].chip = chip; chip->ports[port].port = port; - dp = dsa_to_port(ds, port); - - /* MAC Forcing register: don't force link, speed, duplex or flow control - * state to any particular values on physical ports, but force the CPU - * port and all DSA ports to their maximum bandwidth and full duplex. - */ - if (dsa_is_cpu_port(ds, port) || dsa_is_dsa_port(ds, port)) { - struct phylink_config pl_config = {}; - unsigned long caps; - - chip->info->ops->phylink_get_caps(chip, port, &pl_config); - - caps = pl_config.mac_capabilities; - - if (chip->info->ops->port_max_speed_mode) - mode = chip->info->ops->port_max_speed_mode(port); - else - mode = PHY_INTERFACE_MODE_NA; - - if (caps & MAC_10000FD) - speed = SPEED_10000; - else if (caps & MAC_5000FD) - speed = SPEED_5000; - else if (caps & MAC_2500FD) - speed = SPEED_2500; - else if (caps & MAC_1000) - speed = SPEED_1000; - else if (caps & MAC_100) - speed = SPEED_100; - else - speed = SPEED_10; - - err = mv88e6xxx_port_setup_mac(chip, port, LINK_FORCED_UP, - speed, DUPLEX_FULL, - PAUSE_OFF, mode); - } else { - err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED, - SPEED_UNFORCED, DUPLEX_UNFORCED, - PAUSE_ON, - PHY_INTERFACE_MODE_NA); - } + err = mv88e6xxx_port_setup_mac(chip, port, LINK_UNFORCED, + SPEED_UNFORCED, DUPLEX_UNFORCED, + PAUSE_ON, PHY_INTERFACE_MODE_NA); if (err) return err; @@ -3616,6 +3577,7 @@ static int mv88e6xxx_setup_port(struct mv88e6xxx_chip *chip, int port) } if (chip->info->ops->serdes_set_tx_amplitude) { + dp = dsa_to_port(ds, port); if (dp) phy_handle = of_parse_phandle(dp->dn, "phy-handle", 0);