Received: by 10.223.164.202 with SMTP id h10csp3818364wrb; Mon, 20 Nov 2017 05:36:22 -0800 (PST) X-Google-Smtp-Source: AGs4zMbNUaKD2VqcRPgDQcH+55mWEvDnyTMQEBZE2ygESVaFjTJJSJ3uAL35nsuNlX5+1taqh2ls X-Received: by 10.98.59.66 with SMTP id i63mr11428887pfa.117.1511184982627; Mon, 20 Nov 2017 05:36:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511184982; cv=none; d=google.com; s=arc-20160816; b=0RZhG/dxPRwNdj2iSWgk7Y4E/2HozGHZ2hiJkoF4gCcUyIBqmnoeXwcC5U6rFN37QI jz8z3awwxNPRvIPj7+rO7xk+Ns77hAYYEGJ2hR1pziXOy6v5CezfrV34O3W97ih6wqtE MqNC5PWKVyfvTOmQY29iubtgkFgfyJOrBoPtI68wdLnYkHP276oDUMnzn+6xOKz6VjAM N7X9pauekXCzxRQGuMgiK1E9JFMr6l2PtTISO1aZTMm6J5XW+eSGWjqpArwwfYiPDKOX VXBmi63qOBtvMducZF9d/A56JkQQGSN71bThVzwJsr2ZUOG0X2+hDN+9Z7ma6PaY5hxD NFLQ== 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=DvxrU05sqqKr5XzZExgL5xuGXWNK+5qLyTd/0ZzTPBo=; b=FmlN3agTaxbEVEmhgoh9xMgyIKmQ5nIwawfCQ+JFKpa2xLtSR0S3NkwQgWDNPTC4is f/RQ2sSYK4CE4LIK13deJsuu5Hq47DY23zJV2Pb8rcTCz2rCqDPH+ib+QNmu+5rosoCc rO6NxQZkfzyxuuWBhBauKSdtvwlXztE5DQ2afWsusFcPJectUknW2CPE1OMIx2GOEPv1 fys3EUh4ffZ5K87EpJvZBJDSij8u9t5OS1f4VG5iZN+JFZ3V21gVcQN2g83faUmV2YOf 61FbZEKm1X3SqT2ECT/GBA2BdaRUmY0bcQt3Nn001kjYc+2bVQfw8oxvKq37GInom+cQ WwNQ== 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 g1si8324489plb.25.2017.11.20.05.36.12; Mon, 20 Nov 2017 05:36:22 -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 S1751499AbdKTNdo (ORCPT + 66 others); Mon, 20 Nov 2017 08:33:44 -0500 Received: from bastet.se.axis.com ([195.60.68.11]:39633 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751100AbdKTNdl (ORCPT ); Mon, 20 Nov 2017 08:33:41 -0500 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id 58073183B3; Mon, 20 Nov 2017 14:33:40 +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 vZQXLIbzFJYO; Mon, 20 Nov 2017 14:33:39 +0100 (CET) Received: from boulder02.se.axis.com (boulder02.se.axis.com [10.0.8.16]) by bastet.se.axis.com (Postfix) with ESMTPS id 98698180E6; Mon, 20 Nov 2017 14:33:39 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8143C1A08C; Mon, 20 Nov 2017 14:33:39 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 73DD61A070; Mon, 20 Nov 2017 14:33:39 +0100 (CET) Received: from seth.se.axis.com (unknown [10.0.2.172]) by boulder02.se.axis.com (Postfix) with ESMTP; Mon, 20 Nov 2017 14:33:39 +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 67E69198F; Mon, 20 Nov 2017 14:33:39 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id 6152B400FE; Mon, 20 Nov 2017 14:33:39 +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 12/18] PCI: dwc: artpec6: Split artpec6_pcie_establish_link() into smaller functions Date: Mon, 20 Nov 2017 14:32:15 +0100 Message-Id: <20171120133222.27771-13-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 Split artpec6_pcie_establish_link() into smaller functions to better match other drivers such as dra7xx and imx6. This is also done to prepare for endpoint mode support. Signed-off-by: Niklas Cassel --- drivers/pci/dwc/pcie-artpec6.c | 55 ++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 26 deletions(-) diff --git a/drivers/pci/dwc/pcie-artpec6.c b/drivers/pci/dwc/pcie-artpec6.c index 18075e0fab80..b2783b475c2a 100644 --- a/drivers/pci/dwc/pcie-artpec6.c +++ b/drivers/pci/dwc/pcie-artpec6.c @@ -34,8 +34,6 @@ struct artpec6_pcie { /* PCIe Port Logic registers (memory-mapped) */ #define PL_OFFSET 0x700 -#define PCIE_PHY_DEBUG_R0 (PL_OFFSET + 0x28) -#define PCIE_PHY_DEBUG_R1 (PL_OFFSET + 0x2c) /* ARTPEC-6 specific registers */ #define PCIECFG 0x18 @@ -80,18 +78,23 @@ static u64 artpec6_pcie_cpu_addr_fixup(u64 pci_addr) return pci_addr & ARTPEC6_CPU_TO_BUS_ADDR; } -static int artpec6_pcie_establish_link(struct artpec6_pcie *artpec6_pcie) +static int artpec6_pcie_establish_link(struct dw_pcie *pci) { - struct dw_pcie *pci = artpec6_pcie->pci; - struct pcie_port *pp = &pci->pp; + struct artpec6_pcie *artpec6_pcie = to_artpec6_pcie(pci); u32 val; - unsigned int retries; - /* Hold DW core in reset */ val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); - val |= PCIECFG_CORE_RESET_REQ; + val |= PCIECFG_LTSSM_ENABLE; artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); + return 0; +} + +static void artpec6_pcie_init_phy(struct artpec6_pcie *artpec6_pcie) +{ + u32 val; + unsigned int retries; + val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); val |= PCIECFG_RISRCREN | /* Receiver term. 50 Ohm */ PCIECFG_MODE_TX_DRV_EN | @@ -131,30 +134,25 @@ static int artpec6_pcie_establish_link(struct artpec6_pcie *artpec6_pcie) 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) +{ + u32 val; - /* Take DW core out of reset */ val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); - val &= ~PCIECFG_CORE_RESET_REQ; + val |= PCIECFG_CORE_RESET_REQ; artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); - usleep_range(100, 200); +} - /* setup root complex */ - dw_pcie_setup_rc(pp); +static void artpec6_pcie_deassert_core_reset(struct artpec6_pcie *artpec6_pcie) +{ + u32 val; - /* assert LTSSM enable */ val = artpec6_pcie_readl(artpec6_pcie, PCIECFG); - val |= PCIECFG_LTSSM_ENABLE; + val &= ~PCIECFG_CORE_RESET_REQ; artpec6_pcie_writel(artpec6_pcie, PCIECFG, val); - - /* check if the link is up or not */ - if (!dw_pcie_wait_for_link(pci)) - return 0; - - dev_dbg(pci->dev, "DEBUG_R0: 0x%08x, DEBUG_R1: 0x%08x\n", - dw_pcie_readl_dbi(pci, PCIE_PHY_DEBUG_R0), - dw_pcie_readl_dbi(pci, PCIE_PHY_DEBUG_R1)); - - return -ETIMEDOUT; + usleep_range(100, 200); } static void artpec6_pcie_enable_interrupts(struct artpec6_pcie *artpec6_pcie) @@ -171,7 +169,12 @@ static int artpec6_pcie_host_init(struct pcie_port *pp) struct dw_pcie *pci = to_dw_pcie_from_pp(pp); struct artpec6_pcie *artpec6_pcie = to_artpec6_pcie(pci); - artpec6_pcie_establish_link(artpec6_pcie); + artpec6_pcie_assert_core_reset(artpec6_pcie); + artpec6_pcie_init_phy(artpec6_pcie); + artpec6_pcie_deassert_core_reset(artpec6_pcie); + dw_pcie_setup_rc(pp); + artpec6_pcie_establish_link(pci); + dw_pcie_wait_for_link(pci); artpec6_pcie_enable_interrupts(artpec6_pcie); return 0; -- 2.14.2 From 1584625046889052001@xxx Mon Nov 20 22:16:48 +0000 2017 X-GM-THRID: 1584625046889052001 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread