From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0DFE4CCD184 for ; Sun, 12 Oct 2025 20:59:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:To:From:Reply-To: Cc:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=HfCCKZmM8pHKKYsT+xDhYQD00mwQ4CthcxXjlQ/ajbw=; b=jKQDLwVXwgLdwHepPs0fVlhQ1c 5FKhVw4izz8xXzLogOipDyNpxNtBx+x8biiZVqiw9KNnfUcr2BpnPNams4UDGe8PsWAVmdyz7/EbV dwmDteuSGo3hqmT1xl170ADB2LQXprvYCmFcA1MQiITlI/ZTKXHFTpqhkDyg0SvCsqetVvWzJYypi bni4RAm4HthCLHah0tkk9Lrmf6m/WzdjYb/B/G0iK9Poh/jsxNbZ3vRabO1iGUIUl2amS9TROCTfl Oaj/5D1zQXmPZkdLPFKnbqPPwo/6zcZQc/9OlXuYXYxVqnfZb2VCtCNl6YR2yoygNfCktCQbXpEfX rVm4y8iQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1v83A2-0000000BldE-3KLZ; Sun, 12 Oct 2025 20:59:22 +0000 Received: from mail-wr1-x433.google.com ([2a00:1450:4864:20::433]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1v839w-0000000BlVa-4BvS for linux-mediatek@lists.infradead.org; Sun, 12 Oct 2025 20:59:18 +0000 Received: by mail-wr1-x433.google.com with SMTP id ffacd0b85a97d-3fc36b99e92so3212234f8f.0 for ; Sun, 12 Oct 2025 13:59:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1760302755; x=1760907555; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=HfCCKZmM8pHKKYsT+xDhYQD00mwQ4CthcxXjlQ/ajbw=; b=E+pbB39dKsLW0cXjGOeFZdbTfpO60blMkeFlV0czjch7mbJyDRu3gE2jLYpS4EkFQ9 B2mkRwTTLRI1TYSNAbPW1ThD3rzzvhpRobiXHAvuTjIynPoc31FQ3jtOCtr28N++tX/m A0mgtDld0zHoU6o2BBborDXP20EI7lDwKB1irZ1t0oT+Q4GUETfvIIajaEIbe2+cx4SQ SBb/B0YCJrs+z45/sFZU8tdBD+X3sjkNJtBxixJ+RivRaHRCv+XfNXUYd2eOth55MDWp 7Z+sIKntvMPBbvmiBnc3+wMaKVyDrPeEgebgfGpfUr1QKNW1ql0MPzMT3t0kNz9Yye3Q B6nQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1760302755; x=1760907555; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HfCCKZmM8pHKKYsT+xDhYQD00mwQ4CthcxXjlQ/ajbw=; b=NaZwG/AA549K/EB2FHBjj3iH1LIqFlFn5LxBL6hVg3wZP2vJzvsGMFCRa6lxDGAfaH sIzy1y8ZSORvufYH+kKVuqGz+Vz+EcCbhzibTGVifxSMDThPIDqzXnp1mPrNA/6g74WG ADzXofRhcVcNAB77w3YcqX1LXiVysgt/qS1sH6ueAbvjdofIiCkyir/rjNpl+b+rddrr l85wW+OWafQYYlT7SYhgN7N5QwikmnJKKOfGYB3fNnFaq+cYmslVOJaQLn7QLF/PmqWw za70REEwWjrUwxdGkDJHD01eELqpoKkPQdG5TQzMFjyE4+P6le/9LvZZS4MAl4Y/f/E3 CbYw== X-Forwarded-Encrypted: i=1; AJvYcCWMK1XQSazgMj6T+P1tsO/0l/rxX3LxhIMnSi5ktFM/zPMscciYfXb28TJ7DXCxRoer9FhyBaGSd7j4TB19dw==@lists.infradead.org X-Gm-Message-State: AOJu0YyA8RT7c7krD9KROSNPossCfkMrVOs5h3xtT24kFt0FxTz8P/1k czLPB8qx15cVoqvXSWv7yZnc6dfdOehDzRibgl3kfndrxNRj3/x6CfUU X-Gm-Gg: ASbGncskAhfd2ElX46C69Vx0aiEi1Y9RiGyCc0TCV5JQgP+ugq/2y2EFzzAzVu0x6sg 50NdjgrFidwBMa4Ki1ixJvQESHE7sa755xpQb1xYV2J29GUBn6VpA5vLmSla7lNVLTTZCJH4Iz0 gOqwolCYk4bti3lSLF5jaihjauNA9rmv6+v8PzU1pNPvlTpO2if2Wl4Y46L6YC33sTb+No2lNgy Ve6rBXol2GSnRdgZcuzBj+VejwK6NU8CAedbrSqOMXgs4v7qwcuH22dnbtQZJn45d24vICuVZc2 jUO/Z5otHE6JRNrtw2K9IxbtzXr2T5EDVtiD5J7Bf0vNla13LDN/KfRrxD4iMxWzAS74p3yLEpc 2/vJBnuL/7qs5inaJlogxpl8TFsIvrIA8Z/5g8+5F4NisskJYvC0Z84HMN0Er+tDwW7FhguyeLD +35iZmVquf X-Google-Smtp-Source: AGHT+IH7sgN1Uipv2qIehYyfPkgfd4Xy/W9AcNWaxkV0fmExJBTYScLNQstD+s0qCJYHU+iZtjXiGQ== X-Received: by 2002:a05:6000:4027:b0:401:2cbf:ccad with SMTP id ffacd0b85a97d-425829e78e9mr16695402f8f.17.1760302754926; Sun, 12 Oct 2025 13:59:14 -0700 (PDT) Received: from Ansuel-XPS24 (93-34-92-177.ip49.fastwebnet.it. [93.34.92.177]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-46fb489197dsm156506505e9.10.2025.10.12.13.59.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Oct 2025 13:59:14 -0700 (PDT) From: Christian Marangi To: Ryder Lee , Jianjun Wang , Bjorn Helgaas , Lorenzo Pieralisi , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , Manivannan Sadhasivam , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno , Christian Marangi , linux-pci@vger.kernel.org, linux-mediatek@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, upstream@airoha.com Subject: [PATCH v5 5/5] PCI: mediatek: add support for Airoha AN7583 SoC Date: Sun, 12 Oct 2025 22:56:59 +0200 Message-ID: <20251012205900.5948-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251012205900.5948-1-ansuelsmth@gmail.com> References: <20251012205900.5948-1-ansuelsmth@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251012_135917_113621_6C79BBD0 X-CRM114-Status: GOOD ( 19.55 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Add support for the second PCIe Root Complex present on Airoha AN7583 SoC. This is based on the Mediatek Gen1/2 PCIe driver and similar to Gen3 also require workaround for the reset signals. Introduce a new flag to skip having to reset signals and also introduce some additional logic to configure the PBUS registers required for Airoha SoC. While at it, also add additional info on the PERST# Signal delay comments and use dedicated macro. Signed-off-by: Christian Marangi --- drivers/pci/controller/pcie-mediatek.c | 92 ++++++++++++++++++++------ 1 file changed, 70 insertions(+), 22 deletions(-) diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c index 1678461e56d3..3340c005da4b 100644 --- a/drivers/pci/controller/pcie-mediatek.c +++ b/drivers/pci/controller/pcie-mediatek.c @@ -148,6 +148,7 @@ enum mtk_pcie_flags { NO_MSI = BIT(2), /* Bridge has no MSI support, and relies on an * external block */ + SKIP_PCIE_RSTB = BIT(3), /* Skip calling RSTB bits on PCIe probe */ }; /** @@ -684,28 +685,32 @@ static int mtk_pcie_startup_port_v2(struct mtk_pcie_port *port) regmap_update_bits(pcie->cfg, PCIE_SYS_CFG_V2, val, val); } - /* Assert all reset signals */ - writel(0, port->base + PCIE_RST_CTRL); - - /* - * Enable PCIe link down reset, if link status changed from link up to - * link down, this will reset MAC control registers and configuration - * space. - */ - writel(PCIE_LINKDOWN_RST_EN, port->base + PCIE_RST_CTRL); - - /* - * Described in PCIe CEM specification sections 2.2 (PERST# Signal) and - * 2.2.1 (Initial Power-Up (G3 to S0)). The deassertion of PERST# should - * be delayed 100ms (TPVPERL) for the power and clock to become stable. - */ - msleep(100); - - /* De-assert PHY, PE, PIPE, MAC and configuration reset */ - val = readl(port->base + PCIE_RST_CTRL); - val |= PCIE_PHY_RSTB | PCIE_PERSTB | PCIE_PIPE_SRSTB | - PCIE_MAC_SRSTB | PCIE_CRSTB; - writel(val, port->base + PCIE_RST_CTRL); + if (!(soc->flags & SKIP_PCIE_RSTB)) { + /* Assert all reset signals */ + writel(0, port->base + PCIE_RST_CTRL); + + /* + * Enable PCIe link down reset, if link status changed from + * link up to link down, this will reset MAC control registers + * and configuration space. + */ + writel(PCIE_LINKDOWN_RST_EN, port->base + PCIE_RST_CTRL); + + /* + * Described in PCIe CEM specification revision 3.0 sections + * 2.2 (PERST# Signal) and 2.2.1 (Initial Power-Up (G3 to S0)). + * + * The deassertion of PERST# should be delayed 100ms (TPVPERL) + * for the power and clock to become stable. + */ + msleep(PCIE_T_PVPERL_MS); + + /* De-assert PHY, PE, PIPE, MAC and configuration reset */ + val = readl(port->base + PCIE_RST_CTRL); + val |= PCIE_PHY_RSTB | PCIE_PERSTB | PCIE_PIPE_SRSTB | + PCIE_MAC_SRSTB | PCIE_CRSTB; + writel(val, port->base + PCIE_RST_CTRL); + } /* Set up vendor ID and class code */ if (soc->flags & NEED_FIX_CLASS_ID) { @@ -826,6 +831,41 @@ static int mtk_pcie_startup_port(struct mtk_pcie_port *port) return 0; } +static int mtk_pcie_startup_port_an7583(struct mtk_pcie_port *port) +{ + struct mtk_pcie *pcie = port->pcie; + struct device *dev = pcie->dev; + struct pci_host_bridge *host; + struct resource_entry *entry; + struct regmap *pbus_regmap; + resource_size_t addr; + u32 args[2], size; + + /* + * Configure PBus base address and base address mask to allow + * the hw to detect if a given address is accessible on PCIe + * controller. + */ + pbus_regmap = syscon_regmap_lookup_by_phandle_args(dev->of_node, + "mediatek,pbus-csr", + ARRAY_SIZE(args), + args); + if (IS_ERR(pbus_regmap)) + return PTR_ERR(pbus_regmap); + + host = pci_host_bridge_from_priv(pcie); + entry = resource_list_first_type(&host->windows, IORESOURCE_MEM); + if (!entry) + return -ENODEV; + + addr = entry->res->start - entry->offset; + regmap_write(pbus_regmap, args[0], lower_32_bits(addr)); + size = lower_32_bits(resource_size(entry->res)); + regmap_write(pbus_regmap, args[1], GENMASK(31, __fls(size))); + + return mtk_pcie_startup_port_v2(port); +} + static void mtk_pcie_enable_port(struct mtk_pcie_port *port) { struct mtk_pcie *pcie = port->pcie; @@ -1210,6 +1250,13 @@ static const struct mtk_pcie_soc mtk_pcie_soc_mt7622 = { .flags = NEED_FIX_CLASS_ID, }; +static const struct mtk_pcie_soc mtk_pcie_soc_an7583 = { + .ops = &mtk_pcie_ops_v2, + .startup = mtk_pcie_startup_port_an7583, + .setup_irq = mtk_pcie_setup_irq, + .flags = NEED_FIX_CLASS_ID | SKIP_PCIE_RSTB, +}; + static const struct mtk_pcie_soc mtk_pcie_soc_mt7629 = { .device_id = PCI_DEVICE_ID_MEDIATEK_7629, .ops = &mtk_pcie_ops_v2, @@ -1219,6 +1266,7 @@ static const struct mtk_pcie_soc mtk_pcie_soc_mt7629 = { }; static const struct of_device_id mtk_pcie_ids[] = { + { .compatible = "airoha,an7583-pcie", .data = &mtk_pcie_soc_an7583 }, { .compatible = "mediatek,mt2701-pcie", .data = &mtk_pcie_soc_v1 }, { .compatible = "mediatek,mt7623-pcie", .data = &mtk_pcie_soc_v1 }, { .compatible = "mediatek,mt2712-pcie", .data = &mtk_pcie_soc_mt2712 }, -- 2.51.0