Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1564802ybz; Thu, 30 Apr 2020 01:25:42 -0700 (PDT) X-Google-Smtp-Source: APiQypKH552oTtNBM5cBh+3UPdQctadIFQjudIXuaIsjnMcY8DE/crGlWwTetBH6QieCZ8qFVfzf X-Received: by 2002:aa7:c609:: with SMTP id h9mr1554961edq.250.1588235142663; Thu, 30 Apr 2020 01:25:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588235142; cv=none; d=google.com; s=arc-20160816; b=PEBLY9+pT2sx++06e3eMfiu7EsxP3xGWJr6qkNuX3D6YKNMJrE+9ADkGpArfdYxdKm rZ3ATsPbT44HLthuE7/SGlZvRWTfqYVxI1A1KahT5XM/GOgza3Ohh/ApXGeQPhw6FOIl PBPbQ/o7SgiqhjO5lor6CzJXR+zocOCuTdFRCpSge/6thbyb6gaxvAbf2FIzhadm9rE8 eUMBP1zagDBosgLJCYh5xAQosPXvMJMGjlpYNor98N55izkHFchS7EouhhvsYNelgZJw 1qC+yXlifmHP9dBywEgvDz0XQzuUU1WLAnRGuloKyummTX3J/YmPbKwTb2xji5H2Af8w fZ+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=DHsbeO4T4fJ8SNYfC2IIrthe3PQ+hu+fyV5BcnAT3YU=; b=Dorpf+bNUb14EW2KX3nYH3V7fscaUsTCf3L9JkGyBiMnHZD9SnwL5AOiZvE94Jp/K+ 9+EYNF/HvxpQKdY2W+GiRSFc4yZ/nRXWgqb1rCS5qTYD8JbzWUBP94QnaKoRGYE1/ij5 drtDIQbTUOmOBEjhFWZn8LE2rr0FgVuZFnk8KELEismA4NKOHoc30iybDhdg8T88rUN/ U0K4zLg3Zv4waTnNa5pKkbMJgSHH1bO+KZNDch7opv0cQzwojWgpcaZEgBpbXEbYI+j/ ZZTQU9Z2syrON57JnzZaeWPWPzQXmzfLropWyOGw7E9Tp0UbOirvBYDaLhSmWtJ8irLq MkAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=uh2AnTdV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h7si5109776eds.336.2020.04.30.01.25.18; Thu, 30 Apr 2020 01:25:42 -0700 (PDT) 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; dkim=pass header.i=@kernel.org header.s=default header.b=uh2AnTdV; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726814AbgD3IWs (ORCPT + 99 others); Thu, 30 Apr 2020 04:22:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:57346 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726412AbgD3IWs (ORCPT ); Thu, 30 Apr 2020 04:22:48 -0400 Received: from pali.im (pali.im [31.31.79.79]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 814A020838; Thu, 30 Apr 2020 08:22:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588234967; bh=GnPZmnr/Ofem6uvXDZbMnuc5+odjfx382ISo2nPA2og=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uh2AnTdVFUsSdIHfIkORGr321QfK0oEdiFejgkEUQ5lDxRtZwf8MOcw4JsKHMlIGz 8i56R/ssfr+b+as/IcpFK2aMwau3MmjF+Wy9xA80kyYMn3KXAATa+/mRQEv1ZEICdV E0TunFx47hWEaxJco2lF1Czpzn+IgVVwxtzoIhi0= Received: by pali.im (Postfix) id 931537AD; Thu, 30 Apr 2020 10:22:45 +0200 (CEST) Date: Thu, 30 Apr 2020 10:22:45 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Jason Cooper , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Rob Herring , Thomas Petazzoni , Lorenzo Pieralisi , Andrew Murray , Bjorn Helgaas , Remi Pommarel , Marek =?utf-8?B?QmVow7pu?= , Tomasz Maciej Nowak , Xogium Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org Subject: Re: [PATCH v4 05/12] PCI: aardvark: Issue PERST via GPIO Message-ID: <20200430082245.xblvb7xeamm4e336@pali> References: <20200430080625.26070-1-pali@kernel.org> <20200430080625.26070-6-pali@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200430080625.26070-6-pali@kernel.org> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday 30 April 2020 10:06:18 Pali Rohár wrote: > +static void advk_pcie_issue_perst(struct advk_pcie *pcie) > +{ > + u32 reg; > + > + if (!pcie->reset_gpio) > + return; > + > + /* PERST does not work for some cards when link training is enabled */ > + reg = advk_readl(pcie, PCIE_CORE_CTRL0_REG); > + reg &= ~LINK_TRAINING_EN; > + advk_writel(pcie, reg, PCIE_CORE_CTRL0_REG); > + > + /* 10ms delay is needed for some cards */ > + dev_info(&pcie->pdev->dev, "issuing PERST via reset GPIO for 10ms\n"); > + gpiod_set_value_cansleep(pcie->reset_gpio, 1); > + usleep_range(10000, 11000); > + gpiod_set_value_cansleep(pcie->reset_gpio, 0); > +} Just note about delay between changing GPIO reset: In V2 there as only 1ms, but be figured out that it is not enough for WLE900VX cards when they were already initialized in u-boot. I tried to find in PCI specs if there is a defined timeout for this operation. I found following 3 delay definitions which could be related: TPVPERL - PERST# must remain active at least this long after power becomes valid TPERST - When asserted, PERST# must remain asserted at least this long TPERSTCLK - PERST# must remain active at least this long after any supplied reference clock is stable In another spec they have defined also minimal values: TPVPERL - Power stable to PERST# inactive - Min 100 ms TPERST - PERST# active time - Min 100 us TPERSTCLK - REFCLK stable before PERST# inactive - Min 100 us After experimenting with those Compex WLE900VX cards, I know that 100us delay is not enough. And I'm not sure if TPVPERL is really relevant for this case. I understood that TPVPERL is needed when initializing power again. And because delaying boot by another 100ms is does not have to be acceptable if there is not strict reason for it, I rather decided to stay with just 10ms delay. If you know what is the correct timeout between changing GPIO reset, please let me know and in future I can fix/reimplement it.