Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1524865pxb; Sun, 22 Aug 2021 20:33:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyc8/ibi4quKuuw2b7cbMcEymKrZk2o8z2K0vZ5wW4UHjsypkGteuzoNnW2E1l8/0OOmY9N X-Received: by 2002:a05:6402:1359:: with SMTP id y25mr13675777edw.50.1629689633539; Sun, 22 Aug 2021 20:33:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629689633; cv=none; d=google.com; s=arc-20160816; b=yPY2TwLG8D93ECagudfRdBHhoxP3potswVCjwG0U5DvkTbSJA/LHvdsd46GUpBvYbj va0C0a58DciS2449vKMRQ2TTtDgJf10UbagUlvTCE+pfYhsRyZJBDD7WL4NAUipmw+H3 wwgxuFr+NWSw+TY6IU+f1CgB57hIyP19vEGynENEMihK1Y9W0ChSOoY4CjKn8YpmCM2v JsrlFRZrsomsAHt7SE/ZZo6or7jlyNOKzoDQyz422BlUC00XYoaetFvgtcTJmURGtS3B H93OMbiG6d/cqx4DrYX6fkpCu+QX3CHILwoNVVbaJE81uC3TcQFko0nVGBMKmgmCYUMz DUxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=BVeA7GD2NvsKShRI+rjXojVaeDyb2L7nQX9YiE3NYhs=; b=m3OyC0ZCs5r2VW3F7+0QFgCIwjOur7xDXKbs2kLJPl5i5A61EbfI1VHHZevSKONUV1 /4uX5xnjrddZq8Vzoq++WibP+2Pe9Jb4ElXXgdrnIxdsG6N52YxxgYyDNha/gAQZmQES qzMqj/714x9hnG0uUTlvsgVj+0mio/gn9iQuWKh4W840+fLKcN9Myr1gXq10Ec3pWGm7 Qrl5GLtsXknIxsW7ygPG7+Oh7gXVGQ4TY94fyML6G2/ZJk8wQdYYZUnAw5yG3C5WRzP5 qNphsSBbrnA0ZH8wWqsa5bE8wzbG2Rlz4+3tmXhRcAQBhMgobim6qteGlYxwNr2YTZXs 2Afw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hp19si14581965ejc.372.2021.08.22.20.33.30; Sun, 22 Aug 2021 20:33:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234907AbhHWDaM (ORCPT + 99 others); Sun, 22 Aug 2021 23:30:12 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:35320 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S232830AbhHWD3W (ORCPT ); Sun, 22 Aug 2021 23:29:22 -0400 X-UUID: 0e5a1a810d5a42a0a7c19e7f14a370d5-20210823 X-UUID: 0e5a1a810d5a42a0a7c19e7f14a370d5-20210823 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1903176124; Mon, 23 Aug 2021 11:28:36 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs05n2.mediatek.inc (172.21.101.140) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 23 Aug 2021 11:28:33 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkcas07.mediatek.inc (172.21.101.84) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 23 Aug 2021 11:28:32 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas10.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Mon, 23 Aug 2021 11:28:31 +0800 From: Chuanjia Liu To: , , , CC: , , , , , , , , Subject: [PATCH v12 2/6] PCI: mediatek: Add new method to get shared pcie-cfg base address Date: Mon, 23 Aug 2021 11:27:56 +0800 Message-ID: <20210823032800.1660-3-chuanjia.liu@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210823032800.1660-1-chuanjia.liu@mediatek.com> References: <20210823032800.1660-1-chuanjia.liu@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For the new dts format, add a new method to get shared pcie-cfg base address and use it to configure the PCIECFG controller Signed-off-by: Chuanjia Liu Acked-by: Ryder Lee --- drivers/pci/controller/pcie-mediatek.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c index 25bee693834f..4296d9e04240 100644 --- a/drivers/pci/controller/pcie-mediatek.c +++ b/drivers/pci/controller/pcie-mediatek.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -23,6 +24,7 @@ #include #include #include +#include #include #include "../pci.h" @@ -207,6 +209,7 @@ struct mtk_pcie_port { * struct mtk_pcie - PCIe host information * @dev: pointer to PCIe device * @base: IO mapped register base + * @cfg: IO mapped register map for PCIe config * @free_ck: free-run reference clock * @mem: non-prefetchable memory resource * @ports: pointer to PCIe port information @@ -215,6 +218,7 @@ struct mtk_pcie_port { struct mtk_pcie { struct device *dev; void __iomem *base; + struct regmap *cfg; struct clk *free_ck; struct list_head ports; @@ -682,6 +686,10 @@ static int mtk_pcie_startup_port_v2(struct mtk_pcie_port *port) val |= PCIE_CSR_LTSSM_EN(port->slot) | PCIE_CSR_ASPM_L1_EN(port->slot); writel(val, pcie->base + PCIE_SYS_CFG_V2); + } else if (pcie->cfg) { + val = PCIE_CSR_LTSSM_EN(port->slot) | + PCIE_CSR_ASPM_L1_EN(port->slot); + regmap_update_bits(pcie->cfg, PCIE_SYS_CFG_V2, val, val); } /* Assert all reset signals */ @@ -985,6 +993,7 @@ static int mtk_pcie_subsys_powerup(struct mtk_pcie *pcie) struct device *dev = pcie->dev; struct platform_device *pdev = to_platform_device(dev); struct resource *regs; + struct device_node *cfg_node; int err; /* get shared registers, which are optional */ @@ -995,6 +1004,14 @@ static int mtk_pcie_subsys_powerup(struct mtk_pcie *pcie) return PTR_ERR(pcie->base); } + cfg_node = of_find_compatible_node(NULL, NULL, + "mediatek,generic-pciecfg"); + if (cfg_node) { + pcie->cfg = syscon_node_to_regmap(cfg_node); + if (IS_ERR(pcie->cfg)) + return PTR_ERR(pcie->cfg); + } + pcie->free_ck = devm_clk_get(dev, "free_ck"); if (IS_ERR(pcie->free_ck)) { if (PTR_ERR(pcie->free_ck) == -EPROBE_DEFER) -- 2.18.0