Received: by 10.223.164.221 with SMTP id h29csp136773wrb; Fri, 3 Nov 2017 06:50:06 -0700 (PDT) X-Google-Smtp-Source: ABhQp+R7aIzYBp6ioOq93Dtq3OlurfbJECPE/RczQ9RZCpuu86vpdoeigBH2fV/tbZWVt7iUUm6F X-Received: by 10.84.134.132 with SMTP id 4mr6697094plh.292.1509717006211; Fri, 03 Nov 2017 06:50:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509717006; cv=none; d=google.com; s=arc-20160816; b=fqTW0zFeEu2P5G+nNO0/PLiEyKXnl8oAHhqSGaN3/2b16aul89+x/EGgj1qg6mXXY6 0X6XFdHBsCCJA3TZ7ijKVUv/58zm3zxDuAKNv4/IDFKsFPwNr7Gpzf3fEQqF+tkPc0o9 LLrjAGGWYAWF0OoiNFPAc/7DUW1xMGCk1ZLzjnMzckkhXW1r+Itg4sjgWOkLrXbSizny GX91tIhpeln3u4/qLH/7jMD3myLszpdkmThbjI1KvJ81BuHgBa035qByaRpmu+kXfXZq hwv265sglpkfrE03C/Jwqgf5c/h+IkQ+Bi5IGYYoqD12rsw9rntZq77n+W8Un/aeQNZC oPWw== 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=ESuiwH2WK5d7OMrkcMHxcYGITsmNo8SEeRfZBz2AM3o=; b=YH3568pOyCghWaX7jhl9efXcM+OEpkQJhs0+b/6/vKyuuBkuzHO91VtQwal2QzhGPW JSVN9BVzgY8dFNKpzYCemoxAJZPnsebfqoI6M54iY4FhlxcSxb9ezaKEiFXTUrdx3NT5 zWVjobcPy4F9+xwUX871IoF/TERzaGOWiM8CTRjdjeOGqQraDBinSAyOBNBVvvC+qwIa VB1kXhikAm0l6Vn44qEL0Y62F+WPupAs79MjY08qzk1287vnqOHjMn+MjVI7RGy6ZWCS vQbSdHdEl7n+sscQs+FAdo4cewts5ARtcqc5r3JiReBGdQIy6EpOF16x15uaHJz14ugE kVrg== 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 h1si5902285pgc.417.2017.11.03.06.49.52; Fri, 03 Nov 2017 06:50:06 -0700 (PDT) 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 S933376AbdKCNso (ORCPT + 95 others); Fri, 3 Nov 2017 09:48:44 -0400 Received: from bastet.se.axis.com ([195.60.68.11]:51648 "EHLO bastet.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933274AbdKCNsm (ORCPT ); Fri, 3 Nov 2017 09:48:42 -0400 Received: from localhost (localhost [127.0.0.1]) by bastet.se.axis.com (Postfix) with ESMTP id E662B18919; Fri, 3 Nov 2017 14:48: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 1ZpzlzsUKIob; Fri, 3 Nov 2017 14:48:40 +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 2B33C1839E; Fri, 3 Nov 2017 14:48:40 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F3A931A08D; Fri, 3 Nov 2017 14:48:39 +0100 (CET) Received: from boulder02.se.axis.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E7D611A08A; Fri, 3 Nov 2017 14:48:39 +0100 (CET) Received: from thoth.se.axis.com (unknown [10.0.2.173]) by boulder02.se.axis.com (Postfix) with ESMTP; Fri, 3 Nov 2017 14:48:39 +0100 (CET) Received: from lnxartpec1.se.axis.com (lnxartpec1.se.axis.com [10.88.4.10]) by thoth.se.axis.com (Postfix) with ESMTP id DB61325F2; Fri, 3 Nov 2017 14:48:39 +0100 (CET) Received: by lnxartpec1.se.axis.com (Postfix, from userid 20283) id D5F1840101; Fri, 3 Nov 2017 14:48:39 +0100 (CET) From: Niklas Cassel To: Niklas Cassel , Jesper Nilsson , Bjorn Helgaas Cc: linux-arm-kernel@axis.com, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 12/17] PCI: dwc: artpec6: Split artpec6_pcie_establish_link() into smaller functions Date: Fri, 3 Nov 2017 14:47:16 +0100 Message-Id: <20171103134722.5532-13-niklas.cassel@axis.com> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20171103134722.5532-1-niklas.cassel@axis.com> References: <20171103134722.5532-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 | 53 +++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/drivers/pci/dwc/pcie-artpec6.c b/drivers/pci/dwc/pcie-artpec6.c index 18075e0fab80..3b635e745d25 100644 --- a/drivers/pci/dwc/pcie-artpec6.c +++ b/drivers/pci/dwc/pcie-artpec6.c @@ -80,18 +80,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 +136,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 +171,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 1583053237261465469@xxx Fri Nov 03 13:53:33 +0000 2017 X-GM-THRID: 1583053237261465469 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread