Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp652586pxb; Tue, 2 Feb 2021 14:26:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJzJdUlEU7e6fEc4txv/ekmAftRLWBnVPSLJ7u2/Ftw+3qJetMa3dqkZ/IpZC7k38SUTXkCp X-Received: by 2002:a17:907:968f:: with SMTP id hd15mr175453ejc.440.1612304770035; Tue, 02 Feb 2021 14:26:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612304770; cv=none; d=google.com; s=arc-20160816; b=zKpU84955KuNdtAH27cGr5EUoOXf0hloCJwSyU9A2ZMSWwlXlrijN6c9Ap72SAobtt 6O89bAGmMdZ1CJtHCjY7t2qa68zqkyGoGKQTGcLPwQfk3v2zRvJBN2G0GzbByVXEl3w8 KeGFu8iVXrdHoa4jGnlZE3dC+J3F691G7RzJ5g29/t1ky7IaUHfkVWUbz7AsCbpud2hd HzFYNjkIw77b7tAN3lDhN+92sYzFsPTeyRaVRL2m4S3W98ipN3ei1yMF2JkSrZvuQP8n 6gf6mmF69DA82uKNmA2lG7jFrjoKy/ghl/m+gq06XDcPT3oMgGbapfB2tRVOTqXTxRpy hW7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=AkaAoIIs3AecdX7waJQOLq4wt16xxiL1aV4AB+nVXJU=; b=Utzx+uByc6pRtzM9e5/ldF4uGfwGOrMAS6tI3LhsHhxnCQn/ighy34545cfW+czHVU ZFzBl4KyStR6Or68Q9MJOFp0tXlTp7PcpoUrxpRksXRZd8Ge9UjVmbCQF4mUE34eGRqw DKBD14emoRPsfdpd+D+JV8HXZIAN1naySlLPa7NADqfGIAes7jJNmj21tvEdnO41fhQN P5AdTlqrRv4ewoHyuPUFEqVjCCOmo6+fpgzOLN4Ntb3ktBJLfO4Uc9TqxLxlcHPb3B7H ynXLtqVYtGSM9stZ+kVmrrOfvaxLvgswLykwg02KNsiO0kaxu5OAy6S0nIY5OTPdoYd0 wYXQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h18si61355edw.152.2021.02.02.14.25.43; Tue, 02 Feb 2021 14:26:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232538AbhBBOeZ (ORCPT + 99 others); Tue, 2 Feb 2021 09:34:25 -0500 Received: from jax4mhob17.registeredsite.com ([64.69.218.105]:39900 "EHLO jax4mhob17.registeredsite.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234590AbhBBOdm (ORCPT ); Tue, 2 Feb 2021 09:33:42 -0500 Received: from mailpod.hostingplatform.com ([10.30.71.204]) by jax4mhob17.registeredsite.com (8.14.4/8.14.4) with ESMTP id 112EWkgK119015 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 2 Feb 2021 09:32:46 -0500 Received: (qmail 12776 invoked by uid 0); 2 Feb 2021 14:32:45 -0000 X-TCPREMOTEIP: 83.128.90.119 X-Authenticated-UID: mike@milosoftware.com Received: from unknown (HELO phenom.domain?not?set.invalid) (mike@milosoftware.com@83.128.90.119) by 0 with ESMTPA; 2 Feb 2021 14:32:45 -0000 From: Mike Looijmans To: netdev@vger.kernel.org Cc: Mike Looijmans , Andrew Lunn , "David S. Miller" , Heiner Kallweit , Jakub Kicinski , Russell King , linux-kernel@vger.kernel.org Subject: [PATCH v2] net: mdiobus: Prevent spike on MDIO bus reset signal Date: Tue, 2 Feb 2021 15:32:39 +0100 Message-Id: <20210202143239.10714-1-mike.looijmans@topic.nl> X-Mailer: git-send-email 2.17.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The mdio_bus reset code first de-asserted the reset by allocating with GPIOD_OUT_LOW, then asserted and de-asserted again. In other words, if the reset signal defaulted to asserted, there'd be a short "spike" before the reset. Here is what happens depending on the pre-existing state of the reset signal: Reset (previously asserted): ~~~|_|~~~~|_______ Reset (previously deasserted): _____|~~~~|_______ ^ ^ ^ A B C At point A, the low going transition is because the reset line is requested using GPIOD_OUT_LOW. If the line is successfully requested, the first thing we do is set it high _without_ any delay. This is point B. So, a glitch occurs between A and B. We then fsleep() and finally set the GPIO low at point C. Requesting the line using GPIOD_OUT_HIGH eliminates the A and B transitions. Instead we get: Reset (previously asserted) : ~~~~~~~~~~|______ Reset (previously deasserted): ____|~~~~~|______ ^ ^ A C Where A and C are the points described above in the code. Point B has been eliminated. The issue was found when we pulled down the reset signal for the Marvell 88E1512P PHY (because it requires at least 50ms after POR with an active clock). Looking at the reset signal with a scope revealed a short spike, point B in the artwork above. Signed-off-by: Mike Looijmans Reviewed-by: Andrew Lunn --- Changes in v2: Put more explanation into the commit text, and the artwork from Russell King drivers/net/phy/mdio_bus.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c index 2b42e46066b4..34e98ae75110 100644 --- a/drivers/net/phy/mdio_bus.c +++ b/drivers/net/phy/mdio_bus.c @@ -543,8 +543,8 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner) mutex_init(&bus->mdio_lock); mutex_init(&bus->shared_lock); - /* de-assert bus level PHY GPIO reset */ - gpiod = devm_gpiod_get_optional(&bus->dev, "reset", GPIOD_OUT_LOW); + /* assert bus level PHY GPIO reset */ + gpiod = devm_gpiod_get_optional(&bus->dev, "reset", GPIOD_OUT_HIGH); if (IS_ERR(gpiod)) { err = dev_err_probe(&bus->dev, PTR_ERR(gpiod), "mii_bus %s couldn't get reset GPIO\n", @@ -553,8 +553,6 @@ int __mdiobus_register(struct mii_bus *bus, struct module *owner) return err; } else if (gpiod) { bus->reset_gpiod = gpiod; - - gpiod_set_value_cansleep(gpiod, 1); fsleep(bus->reset_delay_us); gpiod_set_value_cansleep(gpiod, 0); if (bus->reset_post_delay_us > 0) -- 2.17.1