Received: by 10.223.164.202 with SMTP id h10csp3818910wrb; Mon, 20 Nov 2017 05:36:54 -0800 (PST) X-Google-Smtp-Source: AGs4zMZARgq3PfChIROEld1TTREDKusuSAm1WMZ5w+lwULzXCHlGK23m0iqY/QLI0BSkkus8tsIs X-Received: by 10.159.216.131 with SMTP id s3mr13712245plp.252.1511185014311; Mon, 20 Nov 2017 05:36:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511185014; cv=none; d=google.com; s=arc-20160816; b=p8Vf5pR2wsEF4i4h8Wzkdx+Cxc8PtHmPDtLEsRMMZEcwFg3jB5yC0siYfyqW7d0Bch Tn1agWq7fPBGR0jJ7TT0PnerHkf2z4sdyZek+tNUY+qqXLB54g5e7M5mMti+j967drgb 1xi2t6HCLakGtmdYIWgJUcSfoFmRp5pO0mUpyhC+XyyUbMramTUZ7nf+yxqSBbxarGFy YrWmyTEWm3ywJwVAaooJo1nAJJllmC+oH4bkdoG/5b+ZP4p/UjBGSxcyzk1IlG0xrELg kxpg2FjaoRo2Axhb2T3FFTJQZmI6bWjWkjeT6UL0UrWF5oNFLWOTsUAfF5ywhrof/vLm J4Bw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=YH66mCLyPpX7n4BssM2PSdGHi55zP0Q/dBWN3M50loI=; b=GHnCiazVmUl8BwqKmOsS7++myUVit50t7yh1uKrTP1qKUh7+pU3tNn+9u32tHYK6ud wkn/VfDiY2XGcorUwSse042a4VfCA9GW8F0IMZOnnO+SjZkpD20KCTlxdbhscqGJ/Xv3 18oA9qK959AGY2faaIvZT6npPZR4O4XjQePxAHAUgIzHBLH0EnWRuZ6k95hf7Eeo6ZoJ Xo0LikM4L4p6H8i3lXPEY4Mp30Ib89Flnuu8oS0vnhuuSTa8GzgJGcXC4xWigNeev1OM 0ZUJsz8Kz18Gbd4CRWaOv6KgsKbi8P0hKGM2B7O3X/VgPcOYy5bW3sqxufHPWWN2FagZ 0G2Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8si8106592pls.804.2017.11.20.05.36.44; Mon, 20 Nov 2017 05:36:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751665AbdKTNec (ORCPT + 66 others); Mon, 20 Nov 2017 08:34:32 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:39685 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751537AbdKTNd6 (ORCPT ); Mon, 20 Nov 2017 08:33:58 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 5BC66180E6; Mon, 20 Nov 2017 14:33:57 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at bastet.se.axis.com Received: from bastet.se.axis.com ([IPv6:::ffff:127.0.0.1]) by localhost (bastet.se.axis.com [::ffff:127.0.0.1]) (amavisd-new, port 10024) with LMTP id 5-ufFFCd352t; Mon, 20 Nov 2017 14:33:54 +0100 (CET) Received: from boulder03.se.axis.com (boulder03.se.axis.com [10.0.8.17]) by bastet.se.axis.com (Postfix) with ESMTPS id CCE47183B1; Mon, 20 Nov 2017 14:33:54 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B909B1E07D; Mon, 20 Nov 2017 14:33:54 +0100 (CET) Received: from boulder03.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AD7321E07C; Mon, 20 Nov 2017 14:33:54 +0100 (CET) Received: from seth.se.axis.com (unknown [10.0.2.172]) by boulder03.se.axis.com (Postfix) with ESMTP; Mon, 20 Nov 2017 14:33:54 +0100 (CET) Received: from lnxartpec1.se.axis.com (lnxartpec1.se.axis.com [10.88.4.10]) by seth.se.axis.com (Postfix) with ESMTP id A0BBE198F; Mon, 20 Nov 2017 14:33:54 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id 9C820400FE; Mon, 20 Nov 2017 14:33:54 +0100 (CET) From: Niklas Cassel To: Niklas Cassel , Jesper Nilsson , Lorenzo Pieralisi , Bjorn Helgaas Cc: linux-arm-kernel@axis.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 16/18] PCI: dwc: artpec6: Deassert the core before waiting for PHY Date: Mon, 20 Nov 2017 14:32:19 +0100 Message-Id: <20171120133222.27771-17-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171120133222.27771-1-niklas.cassel@axis.com> References: <20171120133222.27771-1-niklas.cassel@axis.com> X-TM-AS-GCONF: 00 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Waiting for the PHY while the core was held in reset worked for artpec6, but for artpec7, in order to read the required registers, the core has to be out of reset. Refactor the code so we always wait for the PHY after the core has been deasserted, since this works for both artpec6 and artpec7. Signed-off-by: Niklas Cassel --- drivers/pci/dwc/pcie-artpec6.c | 45 +++++++++++++++++++++++++++--------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/drivers/pci/dwc/pcie-artpec6.c b/drivers/pci/dwc/pcie-artpec6.c index 318a2bd0d97e..064c5a93ea80 100644 --- a/drivers/pci/dwc/pcie-artpec6.c +++ b/drivers/pci/dwc/pcie-artpec6.c @@ -125,11 +125,37 @@ static const struct dw_pcie_ops dw_pcie_ops = { .stop_link = artpec6_pcie_stop_link, }; -static void artpec6_pcie_init_phy(struct artpec6_pcie *artpec6_pcie) +static void artpec6_pcie_wait_for_phy(struct artpec6_pcie *artpec6_pcie) { + struct dw_pcie *pci = artpec6_pcie->pci; + struct device *dev = pci->dev; u32 val; unsigned int retries; + retries = 50; + do { + usleep_range(1000, 2000); + val = artpec6_pcie_readl(artpec6_pcie, NOCCFG); + retries--; + } while (retries && + (val & (NOCCFG_POWER_PCIE_IDLEACK | NOCCFG_POWER_PCIE_IDLE))); + if (!retries) + dev_err(dev, "PCIe clock manager did not leave idle state\n"); + + retries = 50; + do { + usleep_range(1000, 2000); + val = readl(artpec6_pcie->phy_base + PHY_STATUS); + retries--; + } while (retries && !(val & PHY_COSPLLLOCK)); + if (!retries) + dev_err(dev, "PHY PLL did not lock\n"); +} + +static void artpec6_pcie_init_phy(struct artpec6_pcie *artpec6_pcie) +{ + u32 val; + val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); val |= PCIECFG_RISRCREN | /* Receiver term. 50 Ohm */ PCIECFG_MODE_TX_DRV_EN | @@ -154,21 +180,6 @@ static void artpec6_pcie_init_phy(struct artpec6_pcie *artpec6_pcie) val = artpec6_pcie_readl(artpec6_pcie, NOCCFG); val &= ~NOCCFG_POWER_PCIE_IDLEREQ; artpec6_pcie_writel(artpec6_pcie, NOCCFG, val); - - retries = 50; - do { - usleep_range(1000, 2000); - val = artpec6_pcie_readl(artpec6_pcie, NOCCFG); - retries--; - } while (retries && - (val & (NOCCFG_POWER_PCIE_IDLEACK | NOCCFG_POWER_PCIE_IDLE))); - - retries = 50; - do { - usleep_range(1000, 2000); - val = readl(artpec6_pcie->phy_base + PHY_STATUS); - retries--; - } while (retries && !(val & PHY_COSPLLLOCK)); } static void artpec6_pcie_assert_core_reset(struct artpec6_pcie *artpec6_pcie) @@ -207,6 +218,7 @@ static int artpec6_pcie_host_init(struct pcie_port *pp) artpec6_pcie_assert_core_reset(artpec6_pcie); artpec6_pcie_init_phy(artpec6_pcie); artpec6_pcie_deassert_core_reset(artpec6_pcie); + artpec6_pcie_wait_for_phy(artpec6_pcie); dw_pcie_setup_rc(pp); artpec6_pcie_establish_link(pci); dw_pcie_wait_for_link(pci); @@ -274,6 +286,7 @@ static void artpec6_pcie_ep_init(struct dw_pcie_ep *ep) artpec6_pcie_assert_core_reset(artpec6_pcie); artpec6_pcie_init_phy(artpec6_pcie); artpec6_pcie_deassert_core_reset(artpec6_pcie); + artpec6_pcie_wait_for_phy(artpec6_pcie); for (bar = BAR_0; bar <= BAR_5; bar++) dw_pcie_ep_reset_bar(pci, bar); -- 2.14.2 From 1584527258062180213@xxx Sun Nov 19 20:22:29 +0000 2017 X-GM-THRID: 1584527258062180213 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread