From patchwork Mon Apr 18 05:51:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 8868011 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 932589F36E for ; Mon, 18 Apr 2016 05:53:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A3552201DD for ; Mon, 18 Apr 2016 05:53:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A8B872021A for ; Mon, 18 Apr 2016 05:53:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1as26Q-0007dI-VC; Mon, 18 Apr 2016 05:52:06 +0000 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1as26N-0007bQ-RD for linux-arm-kernel@lists.infradead.org; Mon, 18 Apr 2016 05:52:04 +0000 Received: by mail-pf0-x234.google.com with SMTP id c20so77151209pfc.1 for ; Sun, 17 Apr 2016 22:51:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=6Tz86CGRbzPC9wjKa5G6JxFDldNG+RCIxW88PEm1wn4=; b=KNfuvMwR9atlKyd8JS5nWK4ErhIrGopvep05BXuQUaHV9B00ktKEpEx08bliL9yL1T E7vvN/rUHhlR5AyMz86l4RSM6kp5+Z/ExaV017yoIuYQa2yuhFNB+XDdABwUcOJhRIiN 6qygG16ancsZYE/F1xkh3ak8IQB1RPshTSA6b/nlE/T6WyfBx6eKhmrKFHxKr13p08bH EX6G6PEdww430cJf0E1XANGTSuF2LtJRo1o0iHPwpZ4vEX6+9/+KO1MU3M3tKjHgEUmu FAh9S0URENqaAD23Ha+DmjrzMSnvGFoKfV1nkuaVhkY6XJ4F86xvLKwFXiF6Ppp5ihau 6i/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=6Tz86CGRbzPC9wjKa5G6JxFDldNG+RCIxW88PEm1wn4=; b=T2NePS1BqppxWkKOiwRE+KveOOQ6laaCq6JeZc/sh9MLiair6LIU9+vh5+BxM5LKcV +HFALkuEMZnQWN2r3NvLTBlH4R0SGl4qZD/3LJSBQlZ1K+4uZRBLUeYF1gG1w+2rJ2w7 pgMRbMSa1Pqw+CiVKEkdA1W3tx8qI2AnJUvjwD9DbgVrx9eotPB84O75UHoIpX56Cmzo T2nX+l6cQBe/JpNbyz3bf5gBvphlAH/WzLGxNOI46Eby+IhR6oEIGQmJSGm3xbASRf1i NMhE5Xr9ufrULCHYW/K04fHUNx87svefCUgkffJeAX5zzf0b9yt2PfadY3f/EyrezHe6 LP9w== X-Gm-Message-State: AOPr4FX87mchbUSIxJNYf3vPScQsCvmCUyxWNpAwNK6lTAW56NRjOesNz9cHLpoFyMGLVg== X-Received: by 10.98.1.69 with SMTP id 66mr48207206pfb.10.1460958702839; Sun, 17 Apr 2016 22:51:42 -0700 (PDT) Received: from squirtle.localdomain.localdomain (c-73-225-163-254.hsd1.wa.comcast.net. [73.225.163.254]) by smtp.gmail.com with ESMTPSA id fv10sm26409045pad.40.2016.04.17.22.51.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 17 Apr 2016 22:51:42 -0700 (PDT) From: Andrey Smirnov To: linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 2/3] PCI: imx6: Implement reset sequence for i.MX6+ Date: Sun, 17 Apr 2016 22:51:16 -0700 Message-Id: <1460958677-10604-2-git-send-email-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1460958677-10604-1-git-send-email-andrew.smirnov@gmail.com> References: <1460958677-10604-1-git-send-email-andrew.smirnov@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160417_225203_912631_07111798 X-CRM114-Status: GOOD ( 16.87 ) X-Spam-Score: -2.7 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrey Smirnov , Richard Zhu , linux-kernel@vger.kernel.org, gary.bisson@boundarydevices.com, Bjorn Helgaas , Lucas Stach MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP I.MX6+ has a dedicated bit for reseting PCIe core, which should be used instead of a regular reset sequence since using the latter will hang the SoC. This commit is based on c34068d48273e24d392d9a49a38be807954420ed from http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git Signed-off-by: Andrey Smirnov --- Changes since v1: - Patchset is rebased against https://git.kernel.org/cgit/linux/kernel/git/helgaas/pci.git/log/?h=pci/host-imx6 - DTS files changes moved into a separate patch drivers/pci/host/pci-imx6.c | 28 ++++++++++++++++++++++++++-- include/linux/mfd/syscon/imx6q-iomuxc-gpr.h | 1 + 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/pci/host/pci-imx6.c b/drivers/pci/host/pci-imx6.c index c570bbb..834c5b8 100644 --- a/drivers/pci/host/pci-imx6.c +++ b/drivers/pci/host/pci-imx6.c @@ -33,7 +33,8 @@ enum imx6_pcie_variants { IMX6Q, - IMX6SX + IMX6SX, + IMX6QP, }; struct imx6_pcie { @@ -253,6 +254,11 @@ static int imx6_pcie_assert_core_reset(struct pcie_port *pp) IMX6SX_GPR5_PCIE_BTNRST_RESET, IMX6SX_GPR5_PCIE_BTNRST_RESET); break; + case IMX6QP: + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, + IMX6Q_GPR1_PCIE_SW_RST, + IMX6Q_GPR1_PCIE_SW_RST); + break; case IMX6Q: /* * If the bootloader already enabled the link we need some special @@ -307,6 +313,7 @@ static int imx6_pcie_enable_ref_clk(struct imx6_pcie *imx6_pcie) regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR12, IMX6SX_GPR12_PCIE_TEST_POWERDOWN, 0); break; + case IMX6QP: /* FALLTHROUGH */ case IMX6Q: /* power up core phy and enable ref clock */ regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, @@ -367,9 +374,22 @@ static int imx6_pcie_deassert_core_reset(struct pcie_port *pp) gpiod_set_value_cansleep(imx6_pcie->reset_gpio, 1); } - if (imx6_pcie->variant == IMX6SX) + switch (imx6_pcie->variant) { + case IMX6SX: regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR5, IMX6SX_GPR5_PCIE_BTNRST_RESET, 0); + break; + case IMX6QP: + regmap_update_bits(imx6_pcie->iomuxc_gpr, IOMUXC_GPR1, + IMX6Q_GPR1_PCIE_SW_RST, 0); + + usleep_range(200, 500); + break; + case IMX6Q: /* Nothing to do */ + break; + default: + BUG(); + } return 0; @@ -601,6 +621,9 @@ static int __init imx6_pcie_probe(struct platform_device *pdev) if (of_device_is_compatible(pp->dev->of_node, "fsl,imx6sx-pcie")) imx6_pcie->variant = IMX6SX; + else if (of_device_is_compatible(pp->dev->of_node, + "fsl,imx6qp-pcie")) + imx6_pcie->variant = IMX6QP; else imx6_pcie->variant = IMX6Q; @@ -697,6 +720,7 @@ static void imx6_pcie_shutdown(struct platform_device *pdev) static const struct of_device_id imx6_pcie_of_match[] = { { .compatible = "fsl,imx6q-pcie", }, { .compatible = "fsl,imx6sx-pcie", }, + { .compatible = "fsl,imx6qp-pcie", }, {}, }; MODULE_DEVICE_TABLE(of, imx6_pcie_of_match); diff --git a/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h b/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h index 238c8db..5b08e3c 100644 --- a/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h +++ b/include/linux/mfd/syscon/imx6q-iomuxc-gpr.h @@ -95,6 +95,7 @@ #define IMX6Q_GPR0_DMAREQ_MUX_SEL0_IOMUX BIT(0) #define IMX6Q_GPR1_PCIE_REQ_MASK (0x3 << 30) +#define IMX6Q_GPR1_PCIE_SW_RST BIT(29) #define IMX6Q_GPR1_PCIE_EXIT_L1 BIT(28) #define IMX6Q_GPR1_PCIE_RDY_L23 BIT(27) #define IMX6Q_GPR1_PCIE_ENTER_L1 BIT(26)