From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F1C04C433E2 for ; Tue, 7 Jul 2020 14:54:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D21A320771 for ; Tue, 7 Jul 2020 14:54:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=cerno.tech header.i=@cerno.tech header.b="eYlXbUd5"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="VbRropzt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728225AbgGGOyr (ORCPT ); Tue, 7 Jul 2020 10:54:47 -0400 Received: from new3-smtp.messagingengine.com ([66.111.4.229]:46913 "EHLO new3-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727987AbgGGOyr (ORCPT ); Tue, 7 Jul 2020 10:54:47 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id B06515803FE; Tue, 7 Jul 2020 10:54:45 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 07 Jul 2020 10:54:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:content-transfer-encoding:in-reply-to; s=fm3; bh=z 2MF8pM2yUhzEcAqtjG/BkSK1B6kF9HAsHHt2JjHLuc=; b=eYlXbUd5rBjRoIDgO Ac1T/2aLAw3Q7djwyIkgIQ/pwVqIVfIr2z3WJZY83Ya0wIMTDJMeKhrCKphOlErR V2MsPmOGqgtYqbSaGYLuK6TBmynzFgX9JdllVSJwGFQSk7rpTIotuH5S8SL8rKL4 pmD+QLJYk+pgiFf6h/4DeCPq+HjqSLpuSLVB24wq2EUcw0w3AtZVdV2mObZm2gJ7 QQgUrDhFXoVDICgURqP+h9AyRL+ITGkxU1KSlVzfbUyhEJ2mKi6VxPjWFNE0piTb Nq1P/0BsYEjwNgMyN6c3kR8fMn3Y91s7lBagBdWjLLntZ1DMW0BwNkqqWC6LobKL 5bmzg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; bh=z2MF8pM2yUhzEcAqtjG/BkSK1B6kF9HAsHHt2JjHL uc=; b=VbRropztsuRUvmMR9Gly4Ig+dMb6KjWmOw2v3I0f1QAeuwbUXldQAq90s kHUlIlURW7q75/piHuxcm+p+gHG1KJpvhnVKJ1QTV7BVfFKBaQXulFEnLRRz1sfo w712f9lYvchiGBW1Oum6uVwAAamdRdfJdQ1sFvTzsGoF+qZxvXK87SbASKRXjXlT kICpquzxdrebQvZCSCZXdh75HOjQgycyHjFCJl+m/b7L0xRlzQsjAx1DGnkAJD2h ilpv/yWO0UQQdMQ5LEp7EIHfJxfilPbf6xT4Z+4jSDj9N55eRg7nIadZxtPZxDpz 8aAtT+i1PT9+RlPSWz7z41eLamY+Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduiedrudehgdejiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvuffkfhggtggugfgjsehtqhertddttddvnecuhfhrohhmpeforgigihhm vgcutfhiphgrrhguuceomhgrgihimhgvsegtvghrnhhordhtvggthheqnecuggftrfgrth htvghrnhepkeeileetveejffegueetjeeigffgfefgkeeuueetfffhheegveefhfekheev kedunecuffhomhgrihhnpehkvghrnhgvlhdrohhrghenucfkphepledtrdekledrieekrd ejieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehm rgigihhmvgestggvrhhnohdrthgvtghh X-ME-Proxy: Received: from localhost (lfbn-tou-1-1502-76.w90-89.abo.wanadoo.fr [90.89.68.76]) by mail.messagingengine.com (Postfix) with ESMTPA id 3D704328006F; Tue, 7 Jul 2020 10:54:42 -0400 (EDT) Date: Tue, 7 Jul 2020 16:54:40 +0200 From: Maxime Ripard To: Andrew Lunn Cc: Florian Fainelli , Heiner Kallweit , Russell King , Rob Herring , Frank Rowand , "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Antoine =?utf-8?Q?T=C3=A9nart?= Subject: Re: PHY reset handling during DT parsing Message-ID: <20200707145440.teimwt6kmsnyi5dz@gilmour.lan> References: <20200706181331.x2tn5cl5jn5kqmhx@gilmour.lan> <20200707141918.GA928075@lunn.ch> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20200707141918.GA928075@lunn.ch> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andrew, On Tue, Jul 07, 2020 at 04:19:18PM +0200, Andrew Lunn wrote: > On Mon, Jul 06, 2020 at 08:13:31PM +0200, Maxime Ripard wrote: > > I came across an issue today on an Allwinner board, but I believe it's a > > core issue. > >=20 > > That board is using the stmac driver together with a phy that happens to > > have a reset GPIO, except that that GPIO will never be claimed, and the > > PHY will thus never work. > >=20 > > You can find an example of such a board here: > > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree= /arch/arm/boot/dts/sun6i-a31-hummingbird.dts#n195 > >=20 > > It looks like when of_mdiobus_register() will parse the DT, it will then > > call of_mdiobus_register_phy() for each PHY it encounters [1]. > > of_mdiobus_register_phy() will then if the phy doesn't have an > > ethernet-phy-id* compatible call get_phy_device() [2], and will later on > > call phy_register_device [3]. > >=20 > > get_phy_device() will then call get_phy_id() [4], that will try to > > access the PHY through the MDIO bus [5]. > >=20 > > The code that deals with the PHY reset line / GPIO is however only done > > in mdiobus_device_register, called through phy_device_register. Since > > this is happening way after the call to get_phy_device, our PHY might > > still very well be in reset if the bootloader hasn't put it out of reset > > and left it there. >=20 > Hi Maxime >=20 > If you look at the history of this code, >=20 > commit bafbdd527d569c8200521f2f7579f65a044271be > Author: Sergei Shtylyov > Date: Mon Dec 4 13:35:05 2017 +0100 >=20 > phylib: Add device reset GPIO support >=20 > you will see there is an assumption the PHY can be detected while in > reset. The reset was originally handled inside the at803x PHY driver > probe function, before it got moved into the core. >=20 > What you are asking for it reasonable, but you have some history to > deal with, changing some assumptions as to what the reset is all > about. Thanks for the pointer. It looks to me from the commit log that the assumption was that a bootloader could leave the PHY into reset though? It starts with: > The PHY devices sometimes do have their reset signal (maybe even power > supply?) tied to some GPIO and sometimes it also does happen that a > boot loader does not leave it deasserted. This is exactly the case I was discussing. The bootloader hasn't used the PHY, and thus the PHY reset signal is still asserted? Maxime