From patchwork Tue Apr 26 17:31:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bjorn Helgaas X-Patchwork-Id: 8941941 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0BEC5BF29F for ; Tue, 26 Apr 2016 17:33:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1C57E201EC for ; Tue, 26 Apr 2016 17:33: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 29C1C201BB for ; Tue, 26 Apr 2016 17:33: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 1av6qK-0003za-3j; Tue, 26 Apr 2016 17:32:12 +0000 Received: from mail.kernel.org ([198.145.29.136]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1av6qG-0003Mc-RQ for linux-arm-kernel@lists.infradead.org; Tue, 26 Apr 2016 17:32:09 +0000 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BF8E820251; Tue, 26 Apr 2016 17:31:46 +0000 (UTC) Received: from localhost (unknown [69.71.1.1]) (using TLSv1.2 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B0E2720204; Tue, 26 Apr 2016 17:31:45 +0000 (UTC) Date: Tue, 26 Apr 2016 12:31:44 -0500 From: Bjorn Helgaas To: Thomas Petazzoni Subject: Re: [PATCH v3 0/2] pci: host: new driver for Marvell Armada 7K/8K PCIe controller Message-ID: <20160426173144.GB27803@localhost> References: <1461659506-10387-1-git-send-email-thomas.petazzoni@free-electrons.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1461659506-10387-1-git-send-email-thomas.petazzoni@free-electrons.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160426_103208_948528_FC2ACC4C X-CRM114-Status: GOOD ( 24.79 ) X-Spam-Score: -5.2 (-----) 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: Mark Rutland , devicetree@vger.kernel.org, Yehuda Yitschak , Jason Cooper , Pawel Moll , Ian Campbell , linux-pci@vger.kernel.org, Hanna Hawa , Nadav Haklai , Gregory Clement , Lior Amsalem , Rob Herring , Andrew Lunn , Kumar Gala , Bjorn Helgaas , linux-arm-kernel@lists.infradead.org, Sebastian Hesselbarth Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP On Tue, Apr 26, 2016 at 10:31:44AM +0200, Thomas Petazzoni wrote: > Hello, > > Here is the third iteration of the PCIe host controller driver needed > for the ARM64 Marvell Armada 7K/8K platform. > > Changes since v2: > > - Added Rob Herring's Acked-by on the Device Tree binding patch. > > - Reworked the PCIe host driver following the suggestion of Bjorn > Helgaas: creation of armada8k_add_pcie_port() and > armada8k_pcie_establish_link() in order to follow the convention of > other Designware based drivers. > > Thanks! > > Thomas > > Thomas Petazzoni (2): > dt-bindings: pci: add DT binding for Marvell Armada 7K/8K PCIe > controller > pci: host: new driver for Marvell Armada 7K/8K PCIe controller > > .../devicetree/bindings/pci/pci-armada8k.txt | 38 +++ > drivers/pci/host/Kconfig | 11 + > drivers/pci/host/Makefile | 1 + > drivers/pci/host/pcie-armada8k.c | 276 +++++++++++++++++++++ > 4 files changed, 326 insertions(+) > create mode 100644 Documentation/devicetree/bindings/pci/pci-armada8k.txt > create mode 100644 drivers/pci/host/pcie-armada8k.c Thanks, Thomas, I applied these to pci/host-armada for v4.7. I added the tweaks below to use dev_dbg() instead of pr_debug(), use dw_pcie_wait_for_link() instead of another hand-coded timeout loop, and fix a typo and remove unused constants. Bjorn diff --git a/drivers/pci/host/pcie-armada8k.c b/drivers/pci/host/pcie-armada8k.c index 7302de2..811ddf8 100644 --- a/drivers/pci/host/pcie-armada8k.c +++ b/drivers/pci/host/pcie-armada8k.c @@ -10,8 +10,6 @@ * warranty of any kind, whether express or implied. */ -#define pr_fmt(fmt) "armada-8k-pcie: " fmt - #include #include #include @@ -39,8 +37,6 @@ struct armada8k_pcie { #define PCIE_APP_LTSSM_EN BIT(2) #define PCIE_DEVICE_TYPE_SHIFT 4 #define PCIE_DEVICE_TYPE_MASK 0xF -#define PCIE_DEVICE_TYPE_EP 0x0 /* Endpoint */ -#define PCIE_DEVICE_TYPE_LEP 0x1 /* Legacy endpoint */ #define PCIE_DEVICE_TYPE_RC 0x4 /* Root complex */ #define PCIE_GLOBAL_STATUS_REG 0x8 @@ -69,14 +65,12 @@ struct armada8k_pcie { #define AX_USER_DOMAIN_MASK 0x3 #define AX_USER_DOMAIN_SHIFT 4 - - #define to_armada8k_pcie(x) container_of(x, struct armada8k_pcie, pp) static int armada8k_pcie_link_up(struct pcie_port *pp) { - u32 reg; struct armada8k_pcie *pcie = to_armada8k_pcie(pp); + u32 reg; u32 mask = PCIE_GLB_STS_RDLH_LINK_UP | PCIE_GLB_STS_PHY_LINK_UP; reg = readl(pcie->base + PCIE_GLOBAL_STATUS_REG); @@ -84,7 +78,7 @@ static int armada8k_pcie_link_up(struct pcie_port *pp) if ((reg & mask) == mask) return 1; - pr_debug("No link detected (Global-Status: 0x%08x).\n", reg); + dev_dbg(pp->dev, "No link detected (Global-Status: 0x%08x).\n", reg); return 0; } @@ -92,10 +86,9 @@ static void armada8k_pcie_establish_link(struct pcie_port *pp) { struct armada8k_pcie *pcie = to_armada8k_pcie(pp); void __iomem *base = pcie->base; - int timeout = 1000; u32 reg; - if (!armada8k_pcie_link_up(pp)) { + if (!dw_pcie_link_up(pp)) { /* Disable LTSSM state machine to enable configuration */ reg = readl(base + PCIE_GLOBAL_CONTROL_REG); reg &= ~(PCIE_APP_LTSSM_EN); @@ -129,7 +122,7 @@ static void armada8k_pcie_establish_link(struct pcie_port *pp) PCIE_INT_C_ASSERT_MASK | PCIE_INT_D_ASSERT_MASK; writel(reg, base + PCIE_GLOBAL_INT_MASK1_REG); - if (!armada8k_pcie_link_up(pp)) { + if (!dw_pcie_link_up(pp)) { /* Configuration done. Start LTSSM */ reg = readl(base + PCIE_GLOBAL_CONTROL_REG); reg |= PCIE_APP_LTSSM_EN; @@ -137,14 +130,7 @@ static void armada8k_pcie_establish_link(struct pcie_port *pp) } /* Wait until the link becomes active again */ - while (timeout) { - if (armada8k_pcie_link_up(pp)) - break; - msleep(1); - timeout--; - } - - if (timeout == 0) + if (dw_pcie_wait_for_link(pp)) dev_err(pp->dev, "Link not up after reconfiguration\n"); } @@ -163,7 +149,7 @@ static irqreturn_t armada8k_pcie_irq_handler(int irq, void *arg) /* * Interrupts are directly handled by the device driver of the - * PCI device. However, there are also latched into the PCIe + * PCI device. However, they are also latched into the PCIe * controller, so we simply discard them. */ val = readl(base + PCIE_GLOBAL_INT_CAUSE1_REG);