From nobody Fri Dec 19 15:17:54 2025 Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com [209.85.221.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DDBBA24634F for ; Sun, 12 Oct 2025 20:59:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760302759; cv=none; b=uoDZTbXgtcQablqFcbsNcEGetstWUNm+AK1X5CF9W+KQnqlKlavjLxQ1pQPl96N7rmzjnsQ+ReCDfOluYGyEGtZwACBod5Ld3m7eAl5WnqxZ4Y+Z+GvvxLYYBboFl0x9pB4VbeSipCMcfM27VNLbcV5JCxuMqNP4FV6tgMFe2D0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760302759; c=relaxed/simple; bh=Y9B4pzLzBUoQ9UIuQ9tIIiCjBmPz1CktqXuCtCWM/sI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Xv9+vsEyfYURp0pdW57TQ/cfe3iRCt7K5Tb95Ce+6J4k5k5R12VPe/AUjAYqIMInJemiON3Mjc28M4X9A6MisCbCB/fvfWLU3eSFY9+pZff2iCGs76nS0SRblgBgviicU8DIK9YES+7Tjs4IKDQ9KvGJLIXegUj3CilBlX0yePY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nsc6IO06; arc=none smtp.client-ip=209.85.221.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nsc6IO06" Received: by mail-wr1-f41.google.com with SMTP id ffacd0b85a97d-3fa528f127fso2568219f8f.1 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=vger.kernel.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=nsc6IO06Tlyq7aYcLRg/jr0M5+naBwyxEy3UUtJgdS2QAN7AeRMzf966b4s3JQMt+u jikZHsnMSBBTUO1c0LPzA8f5RwKmwOqmLgGrYeZM/7uCJGxaal7l/JGi9wqzk0K1vsNh 7qL6dJ3PvoajOHpb4MoTHGOH7TvWfes4ndwnpU8a0fgEv1Pr5htOAvsi2Qpvj41JobjL JMrCydbyzBvNlOvh5G1zQVfRuKVAO9/gdo78K0b3XDqFV/2STAfeMurhyvZtRc7SwG42 X7NeznZn6ivEjz8TKQScgYgmCImPpV7AI4CGFAiql6XhwuwOT4Xcsd759VXRVFqtdI6M dTww== 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=BiigQGJQx2wqNEMOlSCz5RF70wOj6eNo15ZYGqZbXMpTlrTmaDVs8ukbJ6iMl6nWkd VjKxx5rqVKqmEzG2HuGLn7s5WLF60gL88VnvVBdoqRuYPPO3bLFwS7QxynX/iN4lqVVL oO2TbTiz5T9XHE63CqA4q0p5fmDbCKn+QpLoDXMuXEdQYFSn0aRBAHp6eZg5hn16mGNI TdRkTJRj8KY7w2P/yCq9DPOLLrItacfY+q+NZcwK/niUlwUCjkNc5gzwyaJ0e41JlklZ G0I0KTPz3Lwdafpraq9MXNlA2lngF7kLmKg+qD0kOiAFtodgiCvjr/DOe7gLz5iBElWC 0DUA== X-Forwarded-Encrypted: i=1; AJvYcCX9CFS3eaJ062KMhGTLTPC99Fb9cS+YxVomOz2tZsHvTicmZHc8GnaEX8Z1OzTp5nGB2bhWOT5T/XO+kY4=@vger.kernel.org X-Gm-Message-State: AOJu0YwAKs9H6mg+pYeybHOre7IOmpvSEplqA3e1swUYvqRqg5vUwfsK UTS1StWigpQswq2iSd0iA3dXMgfnHC/u46SlzZaBDfYPEd6PmtxsSRVy X-Gm-Gg: ASbGncuSK717u8HQyalYD7IAy+J+GshLKU/wuvDMCHENxbZCVLtraW/Rq3jqGEVcr3g c6LyNuvNo44fX4yX+sN2oZYjDGZ6tEIqPwh95QrhjNxdZL0jWR/cGsGqVcw8bLiXKfoNS8jKR6b xocdTADNXwkH/+9aIHVcfMEv/oHVTNAFhwVTkzeGiNybcLtiAfvT79t4KbszX4PnxKxwp/n90T4 gZZXyjWllhFiLGZ1kC58Y6ca2t200axxzKMlr6c2u5jbRL+YQnFJ1kggCCCy4aRmNbVTcwb39X6 9WtYQ2odO4d60NBX+4+GPu82BcHqHo216/6mr2uVoBARidAFnhOvbZuEPRDELvjUGtsnnOr1GVR FCPx+jdH+YNNTrQyC5PtMhw+G2Loa7b9YrCfTHysqWNU3YU5SuthXXdoMIKA6phYiP72mW/0ntv FvxHRCTogG 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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/controlle= r/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 =3D BIT(2), /* Bridge has no MSI support, and relies on an * external block */ + SKIP_PCIE_RSTB =3D BIT(3), /* Skip calling RSTB bits on PCIe probe */ }; =20 /** @@ -684,28 +685,32 @@ static int mtk_pcie_startup_port_v2(struct mtk_pcie_p= ort *port) regmap_update_bits(pcie->cfg, PCIE_SYS_CFG_V2, val, val); } =20 - /* 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 =3D readl(port->base + PCIE_RST_CTRL); - val |=3D 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 =3D readl(port->base + PCIE_RST_CTRL); + val |=3D PCIE_PHY_RSTB | PCIE_PERSTB | PCIE_PIPE_SRSTB | + PCIE_MAC_SRSTB | PCIE_CRSTB; + writel(val, port->base + PCIE_RST_CTRL); + } =20 /* 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; } =20 +static int mtk_pcie_startup_port_an7583(struct mtk_pcie_port *port) +{ + struct mtk_pcie *pcie =3D port->pcie; + struct device *dev =3D 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 =3D 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 =3D pci_host_bridge_from_priv(pcie); + entry =3D resource_list_first_type(&host->windows, IORESOURCE_MEM); + if (!entry) + return -ENODEV; + + addr =3D entry->res->start - entry->offset; + regmap_write(pbus_regmap, args[0], lower_32_bits(addr)); + size =3D 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 =3D port->pcie; @@ -1210,6 +1250,13 @@ static const struct mtk_pcie_soc mtk_pcie_soc_mt7622= =3D { .flags =3D NEED_FIX_CLASS_ID, }; =20 +static const struct mtk_pcie_soc mtk_pcie_soc_an7583 =3D { + .ops =3D &mtk_pcie_ops_v2, + .startup =3D mtk_pcie_startup_port_an7583, + .setup_irq =3D mtk_pcie_setup_irq, + .flags =3D NEED_FIX_CLASS_ID | SKIP_PCIE_RSTB, +}; + static const struct mtk_pcie_soc mtk_pcie_soc_mt7629 =3D { .device_id =3D PCI_DEVICE_ID_MEDIATEK_7629, .ops =3D &mtk_pcie_ops_v2, @@ -1219,6 +1266,7 @@ static const struct mtk_pcie_soc mtk_pcie_soc_mt7629 = =3D { }; =20 static const struct of_device_id mtk_pcie_ids[] =3D { + { .compatible =3D "airoha,an7583-pcie", .data =3D &mtk_pcie_soc_an7583 }, { .compatible =3D "mediatek,mt2701-pcie", .data =3D &mtk_pcie_soc_v1 }, { .compatible =3D "mediatek,mt7623-pcie", .data =3D &mtk_pcie_soc_v1 }, { .compatible =3D "mediatek,mt2712-pcie", .data =3D &mtk_pcie_soc_mt2712 = }, --=20 2.51.0