From: Marc Zyngier <maz@kernel.org>
To: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-pci@vger.kernel.org
Cc: "Bjorn Helgaas" <bhelgaas@google.com>,
"Rob Herring" <robh+dt@kernel.org>,
"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Alyssa Rosenzweig" <alyssa@rosenzweig.io>,
"Stan Skowronek" <stan@corellium.com>,
"Mark Kettenis" <kettenis@openbsd.org>,
"Sven Peter" <sven@svenpeter.dev>,
"Hector Martin" <marcan@marcan.st>,
"Robin Murphy" <Robin.Murphy@arm.com>,
kernel-team@android.com
Subject: [PATCH v3 05/10] PCI: apple: Set up reference clocks when probing
Date: Mon, 13 Sep 2021 19:25:45 +0100 [thread overview]
Message-ID: <20210913182550.264165-6-maz@kernel.org> (raw)
In-Reply-To: <20210913182550.264165-1-maz@kernel.org>
From: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Apple's PCIe controller requires clocks to be configured in order to
bring up the hardware. Add the register pokes required to do so.
Adapted from Corellium's driver via Mark Kettenis's U-Boot patches.
Co-developed-by: Stan Skowronek <stan@corellium.com>
Signed-off-by: Stan Skowronek <stan@corellium.com>
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20210816031621.240268-4-alyssa@rosenzweig.io
---
drivers/pci/controller/pcie-apple.c | 44 +++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c
index f3c414950a10..dabbfc2e1fb0 100644
--- a/drivers/pci/controller/pcie-apple.c
+++ b/drivers/pci/controller/pcie-apple.c
@@ -132,6 +132,46 @@ static inline void rmwl(u32 clr, u32 set, void __iomem *addr)
writel_relaxed((readl_relaxed(addr) & ~clr) | set, addr);
}
+static int apple_pcie_setup_refclk(struct apple_pcie *pcie,
+ struct apple_pcie_port *port)
+{
+ u32 stat;
+ int res;
+
+ res = readl_relaxed_poll_timeout(pcie->base + CORE_RC_PHYIF_STAT, stat,
+ stat & CORE_RC_PHYIF_STAT_REFCLK,
+ 100, 50000);
+ if (res < 0)
+ return res;
+
+ rmwl(0, CORE_LANE_CTL_CFGACC, pcie->base + CORE_LANE_CTL(port->idx));
+ rmwl(0, CORE_LANE_CFG_REFCLK0REQ, pcie->base + CORE_LANE_CFG(port->idx));
+
+ res = readl_relaxed_poll_timeout(pcie->base + CORE_LANE_CFG(port->idx),
+ stat, stat & CORE_LANE_CFG_REFCLK0ACK,
+ 100, 50000);
+ if (res < 0)
+ return res;
+
+ rmwl(0, CORE_LANE_CFG_REFCLK1, pcie->base + CORE_LANE_CFG(port->idx));
+ res = readl_relaxed_poll_timeout(pcie->base + CORE_LANE_CFG(port->idx),
+ stat, stat & CORE_LANE_CFG_REFCLK1,
+ 100, 50000);
+
+ if (res < 0)
+ return res;
+
+ rmwl(CORE_LANE_CTL_CFGACC, 0, pcie->base + CORE_LANE_CTL(port->idx));
+
+ /* Flush writes before enabling the clocks */
+ dma_wmb();
+
+ rmwl(0, CORE_LANE_CFG_REFCLKEN, pcie->base + CORE_LANE_CFG(port->idx));
+ rmwl(0, PORT_REFCLK_EN, port->base + PORT_REFCLK);
+
+ return 0;
+}
+
static int apple_pcie_setup_port(struct apple_pcie *pcie,
struct device_node *np)
{
@@ -165,6 +205,10 @@ static int apple_pcie_setup_port(struct apple_pcie *pcie,
rmwl(0, PORT_APPCLK_EN, port + PORT_APPCLK);
+ ret = apple_pcie_setup_refclk(pcie, port);
+ if (ret < 0)
+ return ret;
+
rmwl(0, PORT_PERST_OFF, port->base + PORT_PERST);
gpiod_set_value(reset, 1);
--
2.30.2
next prev parent reply other threads:[~2021-09-13 18:26 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-13 18:25 [PATCH v3 00/10] PCI: Add support for Apple M1 Marc Zyngier
2021-09-13 18:25 ` [PATCH v3 01/10] irqdomain: Make of_phandle_args_to_fwspec generally available Marc Zyngier
2021-09-13 18:25 ` [PATCH v3 02/10] of/irq: Allow matching of an interrupt-map local to an interrupt controller Marc Zyngier
2021-09-13 21:13 ` Rob Herring
2021-09-13 18:25 ` [PATCH v3 03/10] PCI: of: Allow matching of an interrupt-map local to a pci device Marc Zyngier
2021-09-13 21:30 ` Rob Herring
2021-09-14 19:09 ` Bjorn Helgaas
2021-09-13 18:25 ` [PATCH v3 04/10] PCI: apple: Add initial hardware bring-up Marc Zyngier
2021-09-13 20:48 ` Sven Peter
2021-09-17 9:20 ` Marc Zyngier
2021-09-17 10:42 ` Hector Martin
2021-09-13 18:25 ` Marc Zyngier [this message]
2021-09-13 18:25 ` [PATCH v3 06/10] PCI: apple: Add INTx and per-port interrupt support Marc Zyngier
2021-09-13 18:25 ` [PATCH v3 07/10] arm64: apple: t8103: Add root port interrupt routing Marc Zyngier
2021-09-13 18:25 ` [PATCH v3 08/10] PCI: apple: Implement MSI support Marc Zyngier
2021-09-13 20:43 ` Alyssa Rosenzweig
2021-09-17 9:08 ` Marc Zyngier
2021-09-13 18:25 ` [PATCH v3 09/10] iommu/dart: Exclude MSI doorbell from PCIe device IOVA range Marc Zyngier
2021-09-13 18:55 ` Alyssa Rosenzweig
2021-09-17 10:05 ` Marc Zyngier
2021-09-14 13:54 ` Sven Peter
2021-09-17 10:01 ` Marc Zyngier
2021-09-13 18:25 ` [PATCH v3 10/10] PCI: apple: Configure RID to SID mapper on device addition Marc Zyngier
2021-09-13 20:45 ` Sven Peter
2021-09-14 9:35 ` Marc Zyngier
2021-09-14 9:56 ` Mark Kettenis
2021-09-17 9:19 ` Marc Zyngier
2021-09-17 9:31 ` Mark Kettenis
2021-09-14 13:56 ` Sven Peter
2021-09-19 11:39 ` [PATCH v3 00/10] PCI: Add support for Apple M1 Alyssa Rosenzweig
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=20210913182550.264165-6-maz@kernel.org \
--to=maz@kernel.org \
--cc=Robin.Murphy@arm.com \
--cc=alyssa@rosenzweig.io \
--cc=bhelgaas@google.com \
--cc=devicetree@vger.kernel.org \
--cc=kernel-team@android.com \
--cc=kettenis@openbsd.org \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lorenzo.pieralisi@arm.com \
--cc=marcan@marcan.st \
--cc=robh+dt@kernel.org \
--cc=stan@corellium.com \
--cc=sven@svenpeter.dev \
/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;
as well as URLs for NNTP newsgroup(s).