Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2141022iof; Tue, 7 Jun 2022 21:07:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxHBu5aJxczlUdN4SE9kY3HULUXEj3OXZGlm5P+rUUD6gUmuCUHF4CLVnhRhvCR7itneR35 X-Received: by 2002:a17:902:a418:b0:161:f216:4f49 with SMTP id p24-20020a170902a41800b00161f2164f49mr32207692plq.129.1654661226191; Tue, 07 Jun 2022 21:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654661226; cv=none; d=google.com; s=arc-20160816; b=BqCTMxMYOrbdz+lb5d5BHsHo+XVanScvwGQsVy/jLmqnMUMFT2+d/a+NSHtiAIIsN9 zttHLPa4IjA1gzi32hAoyaVdsSPOxjrO2jkvwMaj5gqe6x6q+0spTaAvxNNm47TTLjsi 3d8fHTulcMOKTtpwv/Q8ftr+ZiUrT5dE+vC1w27k3ViWcK6q0dHOV4k+1ulMp+yKtJAt g9GRniBI+KHbqtO9iiUNiJrxKluRU4TPR1Xm/2OLVT1DtPG/5HiC/YHQCbJRtS5WbPbB kk71rfg6tT9OHwf2nCtHjklaErtVTQeD06qyn+Z5Vo2Re4nQMhXnlgUfUv/97ScqYwWf 9JVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JNzwgR2fiaRkbGqo4mxtqpi2t858ERQI3E2uKnHjPS8=; b=vjeEWcRn1911f5/hOXcoUOD6Ju/db8Zwo+kP/3PsJuZKD1MxgFolAPXnITTKxKSksS TiLQTfHoWfr+qanapW4FLVScHbRht9Yana5gnqAAQEUp3DjtOr8xqwo/N2+N+J7xpxqf wJhOXnd8j67L4gtq7YqlFLRkPkrwkvn+4zbPNWrc+pZ5O3Ua60Qwd8oYO5R2gQaxeB9O b6x+YbN+fR8dn16V046WYHzB+ETlvt+TlQv9QhsbCX6LzwEFLp4dRsZStAvtlSWP/XCv M0EmH8a361InPDkvnQT++TxKGqpdNy1LsA/FbDaFCgDSiacOVPMKjLs6JD7Zcw5xXlTd IWTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Vn8kahqC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id g10-20020a636b0a000000b003fda3857360si11865848pgc.743.2022.06.07.21.07.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 21:07:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Vn8kahqC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CB82D18491A; Tue, 7 Jun 2022 20:33:14 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348736AbiFGRxT (ORCPT + 99 others); Tue, 7 Jun 2022 13:53:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347842AbiFGRfu (ORCPT ); Tue, 7 Jun 2022 13:35:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EAB301109AB; Tue, 7 Jun 2022 10:31:57 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5EAE8614AE; Tue, 7 Jun 2022 17:31:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 649B5C385A5; Tue, 7 Jun 2022 17:31:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654623116; bh=lnVIzLS/8oXyQGTC7yZ6FB72o8AH3PFI3K2kcM4Kszk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vn8kahqCLkbPgRmgbmJq8yT4iAznZxksNVfsE135P/ugovFw6F+7iPXs/8SSwokZ2 yiXzyVyXObNGRwxFt4rM7CNWkK7bKHGouswN01VgLhS/CoQAdYikqPhXyBNr3VsxT2 diDkeiuvTGF0V5Z80YKndcNu3R6A3GY2h8e6Iz+s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Francesco Dolcini , Lorenzo Pieralisi , Lucas Stach , Richard Zhu , Sasha Levin Subject: [PATCH 5.10 302/452] PCI: imx6: Fix PERST# start-up sequence Date: Tue, 7 Jun 2022 19:02:39 +0200 Message-Id: <20220607164917.558475881@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 From: Francesco Dolcini [ Upstream commit a6809941c1f17f455db2cf4ca19c6d8c8746ec25 ] According to the PCIe standard the PERST# signal (reset-gpio in fsl,imx* compatible dts) should be kept asserted for at least 100 usec before the PCIe refclock is stable, should be kept asserted for at least 100 msec after the power rails are stable and the host should wait at least 100 msec after it is de-asserted before accessing the configuration space of any attached device. >From PCIe CEM r2.0, sec 2.6.2 T-PVPERL: Power stable to PERST# inactive - 100 msec T-PERST-CLK: REFCLK stable before PERST# inactive - 100 usec. >From PCIe r5.0, sec 6.6.1 With a Downstream Port that does not support Link speeds greater than 5.0 GT/s, software must wait a minimum of 100 ms before sending a Configuration Request to the device immediately below that Port. Failure to do so could prevent PCIe devices to be working correctly, and this was experienced with real devices. Move reset assert to imx6_pcie_assert_core_reset(), this way we ensure that PERST# is asserted before enabling any clock, move de-assert to the end of imx6_pcie_deassert_core_reset() after the clock is enabled and deemed stable and add a new delay of 100 msec just afterward. Link: https://lore.kernel.org/all/20220211152550.286821-1-francesco.dolcini@toradex.com Link: https://lore.kernel.org/r/20220404081509.94356-1-francesco.dolcini@toradex.com Fixes: bb38919ec56e ("PCI: imx6: Add support for i.MX6 PCIe controller") Signed-off-by: Francesco Dolcini Signed-off-by: Lorenzo Pieralisi Reviewed-by: Lucas Stach Acked-by: Richard Zhu Signed-off-by: Sasha Levin --- drivers/pci/controller/dwc/pci-imx6.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/pci/controller/dwc/pci-imx6.c b/drivers/pci/controller/dwc/pci-imx6.c index 5cf1ef12fb9b..ceb4815379cd 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -401,6 +401,11 @@ static void imx6_pcie_assert_core_reset(struct imx6_pcie *imx6_pcie) dev_err(dev, "failed to disable vpcie regulator: %d\n", ret); } + + /* Some boards don't have PCIe reset GPIO. */ + if (gpio_is_valid(imx6_pcie->reset_gpio)) + gpio_set_value_cansleep(imx6_pcie->reset_gpio, + imx6_pcie->gpio_active_high); } static unsigned int imx6_pcie_grp_offset(const struct imx6_pcie *imx6_pcie) @@ -523,15 +528,6 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) /* allow the clocks to stabilize */ usleep_range(200, 500); - /* Some boards don't have PCIe reset GPIO. */ - if (gpio_is_valid(imx6_pcie->reset_gpio)) { - gpio_set_value_cansleep(imx6_pcie->reset_gpio, - imx6_pcie->gpio_active_high); - msleep(100); - gpio_set_value_cansleep(imx6_pcie->reset_gpio, - !imx6_pcie->gpio_active_high); - } - switch (imx6_pcie->drvdata->variant) { case IMX8MQ: reset_control_deassert(imx6_pcie->pciephy_reset); @@ -574,6 +570,15 @@ static void imx6_pcie_deassert_core_reset(struct imx6_pcie *imx6_pcie) break; } + /* Some boards don't have PCIe reset GPIO. */ + if (gpio_is_valid(imx6_pcie->reset_gpio)) { + msleep(100); + gpio_set_value_cansleep(imx6_pcie->reset_gpio, + !imx6_pcie->gpio_active_high); + /* Wait for 100ms after PERST# deassertion (PCIe r5.0, 6.6.1) */ + msleep(100); + } + return; err_ref_clk: -- 2.35.1