Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2476213rwb; Sun, 15 Jan 2023 16:25:09 -0800 (PST) X-Google-Smtp-Source: AMrXdXsCDciUC+zG6NBAnxFtKbPNXiJhDK8eA0yPpXi8vO3hAZ9fyrGWDlj8xj8vBFGCBUsfaAG5 X-Received: by 2002:aa7:d355:0:b0:49d:5c6:3e5f with SMTP id m21-20020aa7d355000000b0049d05c63e5fmr9636381edr.41.1673828709457; Sun, 15 Jan 2023 16:25:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673828709; cv=none; d=google.com; s=arc-20160816; b=VVFoi7yEhD6iG9ILOQxucBQi57dd7peHTWFCjSWNAxZ1rsynFkHUCNgKa3JGtdfjU4 8YUiRzDrDeBlX3yWtpeJtyZWDx+SnUrihfMJiwMZ/PABKm4R9w1ZsAi+sKsuUkHLgX2n kXZB7nR3+yl9CnlKQJYLMSB9j5uc1NR9zRRghjMjbQ+0QEPYtnvsBNrPLBJVVKESRjYF Cr9t5Z9zkFq8Aa8J0rV6F5mHgkhmpsPW5vSlW+Jdkxprsp68uzQzX/E9cViiWUt3xwGC QG+P0UfPctk9/ra8ALxmaGGc8U7Sx+GOCNjfL2UTdRAVupd/nQvAqaeMULKBQWqE7Bl6 XlDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=C9kBaSGomzBeY39dSxemuW01FKp1Lm9mgpLGAgSDUjc=; b=HW1wkEnpVBePxYh8XPVb2rqp8oRYA4vb5zEgOKWlEtxf7n8t145lH6YqNiV/Gpzp7l VFA+uSISimE0drXh2ss2X/D2uV0iAR+p698gTZZ0CR3iEa4IwxEc8SojtKC7r6sYQjWq GVAsnkja+MNZnRTKjDJK5U2WyCFLm6VcvKvFwd81uVGQRFzlWN1W5OwlhqzZXpCOBP55 cipkiRQrTbb+jb1hpvF0Qgur4Gw5DgWbh8ZhbJYAJvQGjWEJQfeDeCMBERDBt0wP1GEf 6KxEURJ8r9DMfQPu6orMvHs/aqF0aW09q5w2/6ptrSlfcQXYQ/Fzg/LQacAbJeM+3a4h lvnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=afjDdP89; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o15-20020a509b0f000000b0046c53c2be4asi20660851edi.365.2023.01.15.16.24.56; Sun, 15 Jan 2023 16:25:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@lunn.ch header.s=20171124 header.b=afjDdP89; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=lunn.ch Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231633AbjAOXzr (ORCPT + 52 others); Sun, 15 Jan 2023 18:55:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231624AbjAOXzo (ORCPT ); Sun, 15 Jan 2023 18:55:44 -0500 Received: from vps0.lunn.ch (vps0.lunn.ch [156.67.10.101]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E8EC16321; Sun, 15 Jan 2023 15:55:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lunn.ch; s=20171124; h=In-Reply-To:Content-Disposition:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:From:Sender:Reply-To:Subject: Date:Message-ID:To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Content-Disposition:In-Reply-To:References; bh=C9kBaSGomzBeY39dSxemuW01FKp1Lm9mgpLGAgSDUjc=; b=afjDdP892qLrNfjmmt/PHGmLDR HhNB1yaxhrJPKkqVkNohnn5LYDbsNPViPuZvkqXw2voZxehopsUQNRAYmEqE31IHvwITkZpa/t5X/ 2BdPrE49BrkaWyHnJZgo3mBfjNT0LL3nrEDW1WZKMKVwXVcZCGMTbSTZ6STf5PCg1W80=; Received: from andrew by vps0.lunn.ch with local (Exim 4.94.2) (envelope-from ) id 1pHCqV-002A4x-6c; Mon, 16 Jan 2023 00:55:27 +0100 Date: Mon, 16 Jan 2023 00:55:27 +0100 From: Andrew Lunn To: Lars-Peter Clausen Cc: Pierluigi Passaro , hkallweit1@gmail.com, linux@armlinux.org.uk, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, eran.m@variscite.com, nate.d@variscite.com, francesco.f@variscite.com, pierluigi.p@variscite.com Subject: Re: [PATCH] net: mdio: force deassert MDIO reset signal Message-ID: References: <20230115161006.16431-1-pierluigi.p@variscite.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > Specifying the ID as part of the compatible string works for clause 22 PHYs, > but for clause 45 PHYs it does not work. The code always wants to read the > ID from the PHY itself. But I do not understand things well enough to tell > whether that's a fundamental restriction of C45 or just our implementation > and the implementation can be changed to fix it. > > Do you have some thoughts on this? Do you have more details about what goes wrong? Which PHY driver is it? What compatibles do you put into DT for the PHY? To some extent, the ID is only used to find the driver. A C45 device has a lot of ID register, and all of them are used by phy_bus_match() to see if a driver matches. So you need to be careful which ID you pick, it needs to match the driver. It is the driver which decides to use C22 or C45 to talk to the PHY. However, we do have: static int phy_probe(struct device *dev) { ... else if (phydev->is_c45) err = genphy_c45_pma_read_abilities(phydev); else err = genphy_read_abilities(phydev); so it could be a C45 PHY probed using an ID does not have phydev->is_c45 set, and so it looks in the wrong place for the capabilities. Make sure you also have the compatible "ethernet-phy-ieee802.3-c45" which i think should cause is_c45 to be set. There is no fundamental restriction that i know of here, it probably just needs somebody to debug it and find where it goes wrong. Ah! int fwnode_mdiobus_register_phy(struct mii_bus *bus, struct fwnode_handle *child, u32 addr) { ... rc = fwnode_property_match_string(child, "compatible", "ethernet-phy-ieee802.3-c45"); if (rc >= 0) is_c45 = true; if (is_c45 || fwnode_get_phy_id(child, &phy_id)) phy = get_phy_device(bus, addr, is_c45); else phy = phy_device_create(bus, addr, phy_id, 0, NULL); So compatible "ethernet-phy-ieee802.3-c45" results in is_c45 being set true. The if (is_c45 || is then true, so it does not need to call fwnode_get_phy_id(child, &phy_id) so ignores whatever ID is in DT and asks the PHY. Try this, totally untested: diff --git a/drivers/net/mdio/fwnode_mdio.c b/drivers/net/mdio/fwnode_mdio.c index b782c35c4ac1..13be23f8ac97 100644 --- a/drivers/net/mdio/fwnode_mdio.c +++ b/drivers/net/mdio/fwnode_mdio.c @@ -134,10 +134,10 @@ int fwnode_mdiobus_register_phy(struct mii_bus *bus, if (rc >= 0) is_c45 = true; - if (is_c45 || fwnode_get_phy_id(child, &phy_id)) + if (fwnode_get_phy_id (child, &phy_id)) phy = get_phy_device(bus, addr, is_c45); else - phy = phy_device_create(bus, addr, phy_id, 0, NULL); + phy = phy_device_create(bus, addr, phy_id, is_c45, NULL); if (IS_ERR(phy)) { rc = PTR_ERR(phy); goto clean_mii_ts; Andrew