Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2203384iof; Tue, 7 Jun 2022 23:06:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+LG16plbuAXo6w5Q1hoJsU5IMA+yiSC6yrktr5qCgMEY57ZYt+QtHzS0fmnH/Udj1SZzM X-Received: by 2002:a17:90b:1bc7:b0:1e8:317d:6b3b with SMTP id oa7-20020a17090b1bc700b001e8317d6b3bmr27829744pjb.136.1654668396127; Tue, 07 Jun 2022 23:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654668396; cv=none; d=google.com; s=arc-20160816; b=D+QV2zes8ZHI5n2d6wV5S1A8d7DofY+8Hb7aGRpLcIsiyT8LNrk12MB1kajtrNQwNt GHUZm0+ajLhyxyTqt4eTpEhgzYXI6uV3L9OezoWCQ84A4GSAe3bqtm7Lq1OZCkSKNMvl F8Z6svpi3KMec+xnlGnddOKUbNHJoDS5qliG2jZsrZfJPAbKcV0K8SBZTlfTAB8pPaqd CBG5AnEcy55n0Sjc7xlh/WPJdMSSuZ6tKhwiqG77+yyUl+oY+VCN5uppGIZj3lsvI9b2 BrL2uI9Q9x1Sr4IwPHP16QnAJm8tLI2QhzJ2v8PLDh3jmWNjA27bhAOiiw7twyRrtXEY XdgA== 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=K6UgwFlB7apD4+zWoWmgRRGIgrWXgowQAks+VTvb6hY=; b=ut9ITfZzV+I0ISqC4XXICVT51OL8a9biVvOHAqHCR/s8meSOaTyjM/CMAXcJtuzVEF ViAX2kYHR30fehU/pWcrFPTwe54rCjXLn7pEp2ZfIMeejZFtSOO1095OQTQR6qXKGpQm OtOVjjPqLIv990DEbDOPCLq/cdT1GHkwZlT+78W89I+uyuboZw7kQSx+M+vTpCyPEcnt Ypb4ZGJmooOPSiMOBPw8+aPdC7uPxzupxcByJM9+bJCvfs10GrgXKE8t/ouXdndAasnz d35RloAGpuEiRJpT8elYXp1kGj3KRB5iyJwcWUn76F41X2JDqMoOxAezh2ZyqS8qH8ev idLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SPM9mvam; 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 35-20020a630f63000000b003fcb3adf3cbsi4994069pgp.809.2022.06.07.23.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 23:06:36 -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=SPM9mvam; 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 A564E129C31; Tue, 7 Jun 2022 22:30:21 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1389051AbiFHB2J (ORCPT + 99 others); Tue, 7 Jun 2022 21:28:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381434AbiFGV5T (ORCPT ); Tue, 7 Jun 2022 17:57:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5795F25E85; Tue, 7 Jun 2022 12:13:55 -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 ams.source.kernel.org (Postfix) with ESMTPS id 978F0B8233E; Tue, 7 Jun 2022 19:13:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF62DC385A2; Tue, 7 Jun 2022 19:13:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654629233; bh=MLDR1WtN5tggexqtrKZsJcRn38uJ/604v4CEPjlL1yU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SPM9mvam7LepTB1aYD+AF6QoKL4Z/TU20nrPWHvoCpen1kYNZNwYYDkpFDMCmzRNK uWa//shto4HI0qcdJsrwW9DIR+mtxOBKYHohFdMEQLdXUsFKBfOscnXTX2CqBYeQUh e98eDJnRHo0GAATGnrbKCMW6/T9YRPgRaQw2GXbM= 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.18 616/879] PCI: imx6: Fix PERST# start-up sequence Date: Tue, 7 Jun 2022 19:02:14 +0200 Message-Id: <20220607165020.729122521@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@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 6619e3caffe2..7a285fb0f619 100644 --- a/drivers/pci/controller/dwc/pci-imx6.c +++ b/drivers/pci/controller/dwc/pci-imx6.c @@ -408,6 +408,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) @@ -540,15 +545,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); @@ -595,6 +591,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