Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp2399640rwb; Sun, 15 Jan 2023 14:53:45 -0800 (PST) X-Google-Smtp-Source: AMrXdXtEU8NnlVMDmsBogjlnHRxb3G+ZQYjJNDaNsmlxV2Wj+AZnpMo++rg57xhiBxtU1x9KqcL0 X-Received: by 2002:a17:902:d5cd:b0:194:97d3:d724 with SMTP id g13-20020a170902d5cd00b0019497d3d724mr743378plh.23.1673823225548; Sun, 15 Jan 2023 14:53:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673823225; cv=none; d=google.com; s=arc-20160816; b=zr7sUHYsvmNGM0rYlE27sKs1jkyn7KMyVA+eN3h3qciOJRO0SoYRG0yTAmyTEcZ+Jz RkAKLr/uTHxvZ5mvamop+nH+NDpq+oB6RSR0ZJ8Y1CeYk/SRmmEP8vMBOUsWI8TnESKw ADz+SI95/XKRN+kQ1TREaryJ/XhRrBDTTgKqqGfs3bU0DvBcqlxW0xx9S2xtyqE/mLOF ezDIIYPden5gH69lAaSOchAjgSdYwcncTZct6BG8EWqj7H8fQG39vS0juBsG83MZIFfj QDSQX9D2Alpul4+8ALnO/RKhjV/RwcwaoDV9tKJrcygmKPQgh6EIrejoz7BZB1p8YPJQ KA/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=PFKSzjkxvB/mlkvHAJr5Uw0FSkGRIzDY5XBNi8/DRKg=; b=owiNSqetCHN5Fvc0S8FLt71cmCiwZ8vMIStRjIn9eDReYiVJaOjU8jHaTdW9Pmb/3A purHn8R7PSpkM1BvY1Z2967flzX8Th+TqUaJ4JPN80x5jAXutBL96OVZH3LRZIHcNz8q 0m8p2NvDiYdmdix/SMy+fa08jwd8EV/1qD5kXMZVGK1ESPWxpQn2IxIY02nq+0Ajic0g VpoM+4L5tSdY6+xhbsNjUkl0VZ5e7W6zkRC/FACsOppALkttY+tXf+R0+y70HrswNdcn VBRQvA4PsyZBAX4Z6w/nePMCsNFqcKFoPREkvU7gbNVANBYknWMpPUx7RzvOPj+zWfN5 oGNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oWhqG3k4; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h16-20020a170902f71000b0019442e6b916si16842525plo.182.2023.01.15.14.53.39; Sun, 15 Jan 2023 14:53:45 -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=@gmail.com header.s=20210112 header.b=oWhqG3k4; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231269AbjAOWdr (ORCPT + 54 others); Sun, 15 Jan 2023 17:33:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231346AbjAOWdo (ORCPT ); Sun, 15 Jan 2023 17:33:44 -0500 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [IPv6:2607:f8b0:4864:20::f32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7A111E9C1; Sun, 15 Jan 2023 14:33:43 -0800 (PST) Received: by mail-qv1-xf32.google.com with SMTP id y8so18566441qvn.11; Sun, 15 Jan 2023 14:33:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=PFKSzjkxvB/mlkvHAJr5Uw0FSkGRIzDY5XBNi8/DRKg=; b=oWhqG3k4CpBHY9jWeLVs6Menj7FPZdZ3rMwdyN01tclsoaZhf4XSXaatc7wXFnEQeU +Sz3BVStBFAobDBF84N/bt8RgWqfAPPHLnc/D9sc/4hVgKidgyIisZstLaq0pi6i00fp +GPhUU/csQSe/2TTsobZw96JmvhSIUcfNGtSqh8xsxvuBBdYI5vbCb+ySqyo9s2+gK5j 8PxIdM5sfa59Ct895ChSuECIdDSSddKZJY8umLRpegIGRypaHCfwFUC666x9rz2lj4rM XLUamtIX6ECS9tBD6jWwSo6gTjw9vIcoHcZLw+3cInLtnbAYfwL0B9L3ra8FosKjXHep T5tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PFKSzjkxvB/mlkvHAJr5Uw0FSkGRIzDY5XBNi8/DRKg=; b=DASo/f4GBqlKcd9fdSCxv60qadZ1QxPArR6ZyjtKh8cjzNGWthjqNrKo+z17DB1kEo 7rzmFime7ey3xM99zLg0vn4ty758/5QRDLvagnFg+O+gEtzx+lelk0cNzZOReR+FgjxL XcyS9SUo1TTvZ8CgWAPJpY/KcRk1fPhekzjtwY/AY94lu38XRS9VlmEu4Zep9pT6MVEx uWJcNE5E5IMQratze/b4A26CXnBjTObcEAtQ5ej1KT05jz7ssHj2xDnY8JCneKoGPmQ0 kMex5fYQeCDJ7xSNKcUZHakiTSLwverjiWlD+XD48nuIxY3pjygDhz6HsvpPrupuIsu5 gnHg== X-Gm-Message-State: AFqh2kqViHcgzBm7Ho9zn4Xt8GhPozeyXyXHCcgLnKiiAWEYVoL/U9Uy 6OHPygzqe0FKJnaHKT9OHFirH1VjLWYgkLsufoo= X-Received: by 2002:a05:6214:2dc7:b0:532:8c6:4552 with SMTP id nc7-20020a0562142dc700b0053208c64552mr3103594qvb.107.1673822022618; Sun, 15 Jan 2023 14:33:42 -0800 (PST) MIME-Version: 1.0 References: <20230115161006.16431-1-pierluigi.p@variscite.com> In-Reply-To: From: Pierluigi Passaro Date: Sun, 15 Jan 2023 23:33:31 +0100 Message-ID: Subject: Re: [PATCH] net: mdio: force deassert MDIO reset signal To: Lars-Peter Clausen Cc: Andrew Lunn , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,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 On Sun, Jan 15, 2023 at 10:59 PM Lars-Peter Clausen wrote: > On 1/15/23 09:08, Andrew Lunn wrote: > > On Sun, Jan 15, 2023 at 05:10:06PM +0100, Pierluigi Passaro wrote: > >> When the reset gpio is defined within the node of the device tree > >> describing the PHY, the reset is initialized and managed only after > >> calling the fwnode_mdiobus_phy_device_register function. > >> However, before calling it, the MDIO communication is checked by the > >> get_phy_device function. > >> When this happen and the reset GPIO was somehow previously set down, > >> the get_phy_device function fails, preventing the PHY detection. > >> These changes force the deassert of the MDIO reset signal before > >> checking the MDIO channel. > >> The PHY may require a minimum deassert time before being responsive: > >> use a reasonable sleep time after forcing the deassert of the MDIO > >> reset signal. > >> Once done, free the gpio descriptor to allow managing it later. > > This has been discussed before. The problem is, it is not just a reset > > GPIO. There could also be a clock which needs turning on, a regulator, > > and/or a linux reset controller. And what order do you turn these on? > > > > The conclusions of the discussion is you assume the device cannot be > > found by enumeration, and you put the ID in the compatible. That is > > enough to get the driver to load, and the driver can then turn > > everything on in the correct order, with the correct delays, etc. > > I've been running into this same problem again and again over the past > years. > > 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? > IMHO, since the framework allows defining the reset GPIO, it does not sound reasonable to manage it only after checking if the PHY can communicate: if the reset is asserted, the PHY cannot communicate at all. This patch just ensures that, if the reset GPIO is defined, it's not asserted while checking the communication.