mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Lucas Stach <l.stach@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] PCI: imx6: properly shut down core when leaving barebox
Date: Thu,  7 Jan 2016 10:40:23 +0100	[thread overview]
Message-ID: <1452159623-24327-1-git-send-email-l.stach@pengutronix.de> (raw)

As the i.MX6 PCIe core doesn't have a software reachable reset
wired up, it's hard for any driver to get the core into a known
good state.

To make it easier for whatever software follows barebox, bring
back the core into a safe state before leaving barebox.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
This patch is on top of Andrey Smirnovs changes to the
imx6 pcie driver.
---
 drivers/pci/pci-imx6.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/pci/pci-imx6.c b/drivers/pci/pci-imx6.c
index 3a3edd8e218e..d32bd2b4cefa 100644
--- a/drivers/pci/pci-imx6.c
+++ b/drivers/pci/pci-imx6.c
@@ -608,9 +608,35 @@ static int __init imx6_pcie_probe(struct device_d *dev)
 	if (ret < 0)
 		return ret;
 
+	dev->priv = imx6_pcie;
+
 	return 0;
 }
 
+static void imx6_pcie_remove(struct device_d *dev)
+{
+	struct imx6_pcie *imx6_pcie = dev->priv;
+	u32 val;
+
+	val = readl(imx6_pcie->pp.dbi_base + PCIE_PL_PFLR);
+	val &= ~PCIE_PL_PFLR_LINK_STATE_MASK;
+	val |= PCIE_PL_PFLR_FORCE_LINK;
+	data_abort_mask();
+	writel(val, imx6_pcie->pp.dbi_base + PCIE_PL_PFLR);
+	data_abort_unmask();
+
+	val = readl(imx6_pcie->iomuxc_gpr + IOMUXC_GPR12);
+	val &= ~IMX6Q_GPR12_PCIE_CTL_2;
+	writel(val, imx6_pcie->iomuxc_gpr + IOMUXC_GPR12);
+
+	val = readl(imx6_pcie->iomuxc_gpr + IOMUXC_GPR1);
+	val |= IMX6Q_GPR1_PCIE_TEST_PD;
+	writel(val, imx6_pcie->iomuxc_gpr + IOMUXC_GPR1);
+
+	val &= ~IMX6Q_GPR1_PCIE_REF_CLK_EN;
+	writel(val, imx6_pcie->iomuxc_gpr + IOMUXC_GPR1);
+}
+
 static struct of_device_id imx6_pcie_of_match[] = {
 	{ .compatible = "fsl,imx6q-pcie", },
 	{},
@@ -620,6 +646,7 @@ static struct driver_d imx6_pcie_driver = {
 	.name = "imx6-pcie",
 	.of_compatible = DRV_OF_COMPAT(imx6_pcie_of_match),
 	.probe = imx6_pcie_probe,
+	.remove = imx6_pcie_remove,
 };
 device_platform_driver(imx6_pcie_driver);
 
-- 
2.6.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

             reply	other threads:[~2016-01-07  9:40 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-07  9:40 Lucas Stach [this message]
2016-01-08  7:52 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1452159623-24327-1-git-send-email-l.stach@pengutronix.de \
    --to=l.stach@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox