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);