From nobody Mon Feb 9 19:26:19 2026 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 3BE4CEB64D9 for ; Wed, 12 Jul 2023 15:08:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233385AbjGLPIw (ORCPT ); Wed, 12 Jul 2023 11:08:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56792 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233643AbjGLPIV (ORCPT ); Wed, 12 Jul 2023 11:08:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72B5B1BFB for ; Wed, 12 Jul 2023 08:08:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 54AE66186B for ; Wed, 12 Jul 2023 15:08:07 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2E83C433CD; Wed, 12 Jul 2023 15:08:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689174486; bh=tGVbgShLqia6tBA8cE55D5pDAK2IrF4I9EWmknCRjh0=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=oOzUC8AP2YHXm+L+tlHSymOisnyM1agFYfwujCdepkeQxwmw0HuXbVP5yPmHO4uM6 AmoVAhx/inZg3P/zdkeBy8nL4eOmT9eArENLn2qdX8hXRP6Lko6AY+D0AOo08r3iSl iK6MxIUdU5SbV4LjklkEOCbXO8tLIhemOPP/xpNJTZSjN9oQIP05LxBDBLaCX+5UUk WFzLAPju8LJucJTcnAilU1wykcZHMv8paOWDsGZy0SRvbscPWOIj9FJsweXnvRxvu9 CkLungnJklyoB5aa8bFpogsauNedeJCj1hTO5Vqs6R4lqCocv6Cho5y27JW5Ys/9f/ ZKhxR1xu5o0jA== From: Michael Walle Date: Wed, 12 Jul 2023 17:07:10 +0200 Subject: [PATCH net-next v3 10/11] net: mdio: add C45-over-C22 fallback to fwnode_mdiobus_register_phy() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20230620-feature-c45-over-c22-v3-10-9eb37edf7be0@kernel.org> References: <20230620-feature-c45-over-c22-v3-0-9eb37edf7be0@kernel.org> In-Reply-To: <20230620-feature-c45-over-c22-v3-0-9eb37edf7be0@kernel.org> To: Andrew Lunn , Heiner Kallweit , Russell King , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Yisen Zhuang , Salil Mehta , Florian Fainelli , Broadcom internal kernel review list , =?utf-8?q?Marek_Beh=C3=BAn?= , Xu Liang Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Simon Horman , Michael Walle X-Mailer: b4 0.12.2 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org If trying to register a C45 PHY on an MDIO bus which isn't capable of C45 (either because the MDIO controller doesn't support it or because C45 accesses are prohibited due to faulty C22 PHYs) we can fall back to the new C45-over-C22 access method. Signed-off-by: Michael Walle --- Please note, that both with the old and the new code compatible =3D "ethernet-phy-idNNNN.NNNN" only works for the C22 case. I'm wondering if compatible =3D "ethernet-phy-idNNNN.NNNN", "ethernet-phy-ieee802.3-c45 even makes sense because there might be multiple C45 ids. At least it is an allowed pattern according to the device tree bindings. But with the current code, the ethernet-phy-idNNNN.NNNN is ignored in the c45 case. --- drivers/net/mdio/fwnode_mdio.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c index 972c8932c2fe..fed056d82b4e 100644 --- a/drivers/net/mdio/fwnode_mdio.c +++ b/drivers/net/mdio/fwnode_mdio.c @@ -115,7 +115,6 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus, struct mii_timestamper *mii_ts =3D NULL; struct pse_control *psec =3D NULL; struct phy_device *phy; - bool is_c45; u32 phy_id; int rc; =20 @@ -129,13 +128,19 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus, goto clean_pse; } =20 - is_c45 =3D fwnode_device_is_compatible(child, "ethernet-phy-ieee802.3-c45= "); - if (is_c45 || fwnode_get_phy_id(child, &phy_id)) - phy =3D get_phy_device(bus, addr, - is_c45 ? PHY_ACCESS_C45 : PHY_ACCESS_C22); - else + if (fwnode_device_is_compatible(child, "ethernet-phy-ieee802.3-c45")) { + if (mdiobus_supports_c45(bus)) + phy =3D get_phy_device(bus, addr, PHY_ACCESS_C45); + else + phy =3D get_phy_device(bus, addr, + PHY_ACCESS_C45_OVER_C22); + } else if (fwnode_get_phy_id(child, &phy_id) =3D=3D 0) { phy =3D phy_device_create(bus, addr, phy_id, PHY_ACCESS_C22, NULL); + } else { + phy =3D get_phy_device(bus, addr, PHY_ACCESS_C22); + } + if (IS_ERR(phy)) { rc =3D PTR_ERR(phy); goto clean_mii_ts; --=20 2.39.2