From patchwork Mon Oct 15 13:07:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 148836 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp3777788lji; Mon, 15 Oct 2018 06:10:10 -0700 (PDT) X-Google-Smtp-Source: ACcGV609ukGYdBFQO8g0i0xBFlNaK372UvvmjBmFsHRnKMZUGmgNzUzfHx8I2fpwc9XA56P5lVzc X-Received: by 2002:a62:5343:: with SMTP id h64-v6mr17443718pfb.226.1539609010327; Mon, 15 Oct 2018 06:10:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539609010; cv=none; d=google.com; s=arc-20160816; b=zRuT5cEAVFUjNPinYH/WeYKy4J/Qhm/7XZrnVdun1FWhC+3BtXPFaBaOuDhkmNQ5Jx lm8BVpD6jyyX0fGwTP37ytdvY10pg/3hB2rJIiCbtAKoh4rnw7fQTas4/YHb4MF3dRmb yzAg/WeCldBk//iD+0H9GbgO+YmBLI3iazsUFNLQqq4rH/f9OZrmNYSr8Rv207mPjgzl zpnLeCuK5yxAlUe25H/qG3guVm6liiAjY/TCqDJ5MIcqmhVOr9OAFvouX7OsfwCbwfTU W6pvbxvmuxMF44Xvdpn+gCMCCuK6DyEjxMeUB4Pw1cRTFnPiIJD+QTP7UFBXtnCs88/y D+/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=I+8oB3slUMP8h64wG5S3UqrQQp1pEImCeexOuq//BTs=; b=mlpuzScWvchzHIUaQ1f0nPBXoLTZ6pHDiqACY9E1MQzkBtxXAJ69ELLPj5MuTlEo3+ 4GtSedpALctJgrXOuGkgmHrVnrejVt73NGcTEfWHsKspPsZRF5mXdhTryQtqAPG/6Ix/ anJY7T+oHbuZHpKAbSA2G9cCVAxpDf7r0AcGuxv2Ukprhh6ZwcsyElCYkDOllVVglnrQ yz2gXOlmTZjb3RMo5QX8VCDCW19v/rO2aS9skN8ceQa3/mN/HHhmu3d+lP80JM+FPG3H AIg/LhhFVl3BtKmUBvLJCQBoGwLIXdbgdTyQHXV8Jh4jJeSTqHiKwKcSbnC/dB5k0ONx MTuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=fgizKdNv; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r3-v6si8169164plb.197.2018.10.15.06.10.02; Mon, 15 Oct 2018 06:10:10 -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; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=fgizKdNv; 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; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726888AbeJOUyU (ORCPT + 32 others); Mon, 15 Oct 2018 16:54:20 -0400 Received: from fllv0015.ext.ti.com ([198.47.19.141]:47964 "EHLO fllv0015.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726400AbeJOUyU (ORCPT ); Mon, 15 Oct 2018 16:54:20 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id w9FD8Xid123815; Mon, 15 Oct 2018 08:08:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1539608913; bh=I+8oB3slUMP8h64wG5S3UqrQQp1pEImCeexOuq//BTs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=fgizKdNvy5mPKPo/4QrZKVnn5YTB7KYLVHhSJ0YpezWODF3V4aPFCDGePshJanU2d DxQ9sdf8wVfs5kQPjJtN51W2211/ASAMJCE+jNsgGo2oDdrbe6j7bYoWC/p6/8UEcW cU2dYfxFtpojYJPWhp4/AHcDCthXXgBXI0U3D8AY= Received: from DFLE109.ent.ti.com (dfle109.ent.ti.com [10.64.6.30]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w9FD8Xvn011585; Mon, 15 Oct 2018 08:08:33 -0500 Received: from DFLE102.ent.ti.com (10.64.6.23) by DFLE109.ent.ti.com (10.64.6.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Mon, 15 Oct 2018 08:08:32 -0500 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE102.ent.ti.com (10.64.6.23) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Mon, 15 Oct 2018 08:08:32 -0500 Received: from a0393678ub.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id w9FD7tLD009433; Mon, 15 Oct 2018 08:08:29 -0500 From: Kishon Vijay Abraham I To: Bjorn Helgaas , Lorenzo Pieralisi , Murali Karicheri , Jingoo Han , Gustavo Pimentel CC: Rob Herring , , , , , Kishon Vijay Abraham I Subject: [PATCH 10/19] PCI: keystone: Use syscon APIs to get device id from control module Date: Mon, 15 Oct 2018 18:37:12 +0530 Message-ID: <20181015130721.5535-11-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181015130721.5535-1-kishon@ti.com> References: <20181015130721.5535-1-kishon@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Control module registers should be read using syscon APIs. pci-keystone.c uses platform_get_resource to get control module registers. Fix it here by using syscon APIs to get device id from control module. Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/controller/dwc/pci-keystone.c | 45 ++++++++++++++++------- 1 file changed, 32 insertions(+), 13 deletions(-) -- 2.17.1 diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c index e2045b5d2af2..e22328f89c84 100644 --- a/drivers/pci/controller/dwc/pci-keystone.c +++ b/drivers/pci/controller/dwc/pci-keystone.c @@ -15,12 +15,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include #include @@ -28,6 +30,9 @@ #define DRIVER_NAME "keystone-pcie" +#define PCIE_VENDORID_MASK 0xffff +#define PCIE_DEVICEID_SHIFT 16 + /* DEV_STAT_CTRL */ #define PCIE_CAP_BASE 0x70 @@ -744,10 +749,34 @@ static int ks_pcie_fault(unsigned long addr, unsigned int fsr, return 0; } +static int __init ks_pcie_init_id(struct keystone_pcie *ks_pcie) +{ + int ret; + unsigned int id; + struct regmap *devctrl_regs; + struct dw_pcie *pci = ks_pcie->pci; + struct device *dev = pci->dev; + struct device_node *np = dev->of_node; + + devctrl_regs = syscon_regmap_lookup_by_phandle(np, "ti,syscon-pcie-id"); + if (IS_ERR(devctrl_regs)) + return PTR_ERR(devctrl_regs); + + ret = regmap_read(devctrl_regs, 0, &id); + if (ret) + return ret; + + dw_pcie_writew_dbi(pci, PCI_VENDOR_ID, id & PCIE_VENDORID_MASK); + dw_pcie_writew_dbi(pci, PCI_DEVICE_ID, id >> PCIE_DEVICEID_SHIFT); + + return 0; +} + static int __init ks_pcie_host_init(struct pcie_port *pp) { struct dw_pcie *pci = to_dw_pcie_from_pp(pp); struct keystone_pcie *ks_pcie = to_keystone_pcie(pci); + int ret; dw_pcie_setup_rc(pp); @@ -757,8 +786,9 @@ static int __init ks_pcie_host_init(struct pcie_port *pp) writew(PCI_IO_RANGE_TYPE_32 | (PCI_IO_RANGE_TYPE_32 << 8), pci->dbi_base + PCI_IO_BASE); - /* update the Vendor ID */ - writew(ks_pcie->device_id, pci->dbi_base + PCI_DEVICE_ID); + ret = ks_pcie_init_id(ks_pcie); + if (ret < 0) + return ret; /* * PCIe access errors that result into OCP errors are caught by ARM as @@ -864,8 +894,6 @@ static int __init ks_pcie_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct dw_pcie *pci; struct keystone_pcie *ks_pcie; - struct resource *res; - void __iomem *reg_p; struct phy *phy; int ret; @@ -893,15 +921,6 @@ static int __init ks_pcie_probe(struct platform_device *pdev) return ret; } - /* index 2 is to read PCI DEVICE_ID */ - res = platform_get_resource(pdev, IORESOURCE_MEM, 2); - reg_p = devm_ioremap_resource(dev, res); - if (IS_ERR(reg_p)) - return PTR_ERR(reg_p); - ks_pcie->device_id = readl(reg_p) >> 16; - devm_iounmap(dev, reg_p); - devm_release_mem_region(dev, res->start, resource_size(res)); - ks_pcie->np = dev->of_node; platform_set_drvdata(pdev, ks_pcie); ks_pcie->clk = devm_clk_get(dev, "pcie");