From patchwork Wed Oct 17 07:41:03 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: 149034 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp327773lji; Wed, 17 Oct 2018 00:42:41 -0700 (PDT) X-Google-Smtp-Source: ACcGV604DpvfCt7eMwdE0JJ15QSIFzN8K3G3FnIojLvHiuIsNW1JSoqrLiDszyMNlEMz38g3JdCb X-Received: by 2002:a63:fd58:: with SMTP id m24-v6mr23892753pgj.132.1539762161320; Wed, 17 Oct 2018 00:42:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539762161; cv=none; d=google.com; s=arc-20160816; b=lk8L0ZR1KfZQ27sZCCMr38OlX8q9ou/q8wx5jjwZhbYTWhDce1LBarJJ3opQOmfQnb o9UmQmtky1sGAm2cqp4hws8E7ArANA20yKDacuzql+cV4ZqcDcSosHcW1Z0ymqx932d2 cpTbltc2il+SGws/qAG5zKAdNC+hp/ciwnpbdijdimIAS+7gchJuEEkOwP2svNcB76Gr iXtohIyEOy/2oeMhlsw6jL62nJ3P5qcfOklB0Wa6GgeNESORiCXuY1LHvLN+Enpoidp5 IhvTo8iT7mcIw79svWuE/eAHEZq7BdYaLxDf/VC//5veAwVoGpy/Q5DFlkQBf2rzOp9s WX+g== 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=jgdwuJgG1OccyOdMJAcKPxNS1ELPyDHEnSV0mkvVgny/u1xmLush/2nyOy85y20FYs dZT+jUFs+Lo1u+0MCxO8szBCbgoXIM5czyTs5A7nXTbRnwXUtFVYTjMejtl1AMDWcRD8 sX5E9lYJro12GGZmW7iPIwU8em5u8MPH3RfCLbSh7bI0JF/AfaQXvOoM8U/yI71wnuOr TVrNLXo6q6cCngEs8bmgKwEoA1KjmL1TzGAtROAb6qAJK0gHsmHNrv2yPfC00U+cV7Xc 7Ip7W+3POYDbBmFR6QrCxwv6sizJO2BAEYvE5zT9TbBUJHDBspofpCWoOGdyJHQM4B5w ax6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=OBHCxJvx; 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 c14-v6si16796943pgm.556.2018.10.17.00.42.41; Wed, 17 Oct 2018 00:42:41 -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=OBHCxJvx; 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 S1727493AbeJQPhB (ORCPT + 32 others); Wed, 17 Oct 2018 11:37:01 -0400 Received: from fllv0016.ext.ti.com ([198.47.19.142]:56520 "EHLO fllv0016.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727435AbeJQPhB (ORCPT ); Wed, 17 Oct 2018 11:37:01 -0400 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllv0016.ext.ti.com (8.15.2/8.15.2) with ESMTP id w9H7gKHF022931; Wed, 17 Oct 2018 02:42:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1539762140; bh=I+8oB3slUMP8h64wG5S3UqrQQp1pEImCeexOuq//BTs=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=OBHCxJvxGbPQsUzweKOMWKfjjHbvfiG7NTSGJUsyt3K0mgOOysc/65gBM5Q/M/BWi Hn8u07wS6+ZyltSl15FDZb1/D50/8fQcBZcAxaeHllEA/WYMAVK3epWrUb0iRVqHee KtMl6sJAX9oJVOOf37cg8lFnv7T6ovKQ0lLo1D/8= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id w9H7gKMG009200; Wed, 17 Oct 2018 02:42:20 -0500 Received: from DLEE111.ent.ti.com (157.170.170.22) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1466.3; Wed, 17 Oct 2018 02:42:20 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE111.ent.ti.com (157.170.170.22) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1466.3 via Frontend Transport; Wed, 17 Oct 2018 02:42:19 -0500 Received: from a0393678ub.dal.design.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id w9H7fgSV009413; Wed, 17 Oct 2018 02:42:16 -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 v2 10/21] PCI: keystone: Use SYSCON APIs to get device ID from control module Date: Wed, 17 Oct 2018 13:11:03 +0530 Message-ID: <20181017074114.28239-11-kishon@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181017074114.28239-1-kishon@ti.com> References: <20181017074114.28239-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");