From nobody Wed Oct 1 23:32:13 2025 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (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 D61183019D1 for ; Mon, 29 Sep 2025 11:38:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759145906; cv=none; b=GDK+KwsEOlA3OjC4t+58J0iMAFYli/gxF5RS+RAhDGWaUB4DXCp6DYq1UuDML6w5iKooqKHwTX0fx30wb2H7ahOJH91af2bAo3wqW2dEUVtbSx/EdPK0QKSJo8nfIpcU0zdsAi15xKkX68q7FOySRZlFDBfjT1X5uriZipm9lAU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1759145906; c=relaxed/simple; bh=Y9B4pzLzBUoQ9UIuQ9tIIiCjBmPz1CktqXuCtCWM/sI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jXfZUDbS7VsSnV2MLCbxnLuAmaBvm3rMx/bKSeXJEZp9KpmF9XlUSHCjAkrjCBIXPC6GeULF2Rc22oXAtiBzZrz/EpwWv3tPakON+V6MdvnRX4Xsm2f0Y1QklXsONb+gjyqF8JgbytjBgAbUgKAptB0ehMm0F7UXm7Pftjw9/6o= 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=PgLlWE2V; arc=none smtp.client-ip=209.85.128.46 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="PgLlWE2V" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-46e52279279so6864485e9.3 for ; Mon, 29 Sep 2025 04:38:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759145903; x=1759750703; 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=PgLlWE2VVDs5gVdfQme1SED6pFSZ8LG0i6DrTeojYnEV2/WzX9F9nb7eWeQGPPRA7d B+hFkECQ0al2qeu4K87WXDcus1xHYXkDZ5RNVcLXb2cqSRtWs+6oIR1k4fpNfYRJhLP6 q10p3PGwqD/tW6fYr3EjNpFikq+tegwarDwDKaYR0aDiHFD9e25AljUj4C3l4uHzwCku XB655er/hfGG6E37RqLafMqbJY+dkydMEqzR4E6RXHE+u+VcpUEfTkB6C0gKOZdvqgto ovY7cN6nlwRu/+fTPicbaDwe0X6DPrWb6/uekD2dj736US8mNEhFAg9FqlldV2sf9ZiF 8wfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759145903; x=1759750703; 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=NQZFKPU3ERDbZTOr2Ur4ubURhFjZxKXF6+bqFCApvpK9IUpoP3OwFuZgfp2uPxLmbF ietZUoxBFwwuTgKH0bFos/NXgw6w5cqM1vsph/eg/3tQPZHOi4cMpxzfNyiOWq5FUDnW ytZlPcSCL3xaWgfwE8Xau3Gkm/m5tUY9zA7eLwaPsSe+EsiygaizDw5uT0kpTNLZE6Xq WwA1eiPTwRwyFsxcebNQPItfGK60AcIN6GISNJArcjdtSD8O+mKrpt/l8mCGsZseWCOb x7yQSMhBfrf7iBoaSupHjerZs5+aK5LwNVIf07s0nc/ffKBLd68eOFsXcSu5N9yAIoB9 KBkA== X-Forwarded-Encrypted: i=1; AJvYcCXMFtBtqJu8h5jhS2h+tGPPQdMHjphBPf1u1j7+EawSXkTUBtP5lPRkPZVgq+Z7nmRXTPxp0pK9yMWKbTk=@vger.kernel.org X-Gm-Message-State: AOJu0YwqEZ+cmN7TcIfoDHonowkentBxRe1rJ5oswAgEi1r0yQfwa3BX XlBGkwKDrIPcpPxewZ5i1basOgxO6a04RIQeA8wUx0nwsToVw3eakqxP X-Gm-Gg: ASbGncuRlS/1Df7yjN44ktx1NxwCvTWnQMksqHT7y6Z3idLEPu1GtfOKurlGUA1oHDA CwyTYqKLWtAaU3WH8iX/TvIMwHIucItJYEfCZZqTQqWbxSYEZlTlKxHSCp3BGjlDjbum6eCGiLy 6zq/ESzEO4pAAzC5pMxGiCKl0nRiIScZg4deTdyL+5kI1MM0R4U2bsiq2YBJkXUURIWSsquQe/G GePuxa803KYGRLd/Gk2cJHOSCTj11ZdEJqGoV4Adnz5hMmQKKgk3WaPv+7QI3cBJXPRnT3cvAal FomY2a2DyMuWi+74rAR9GOnamXKCSA8sJlN+CmU1TXkXKW0/7/tr1/yVFjDyVD/QDawZ1ukCVDG bW0FnvKo4qCBjf95UEs8VervWhnK0PwQfzQ5PluLL3H1USoRYEiyTZWjX/ZLVzW3oO2kqWKw8uW o8227CgQ== X-Google-Smtp-Source: AGHT+IHyG6lnL8qQ0LD131D8WPiKwUrMMhMJ4PKeOnuBD/ytBbwWaTjIucbfk9dUwJTA+msn8KI/1A== X-Received: by 2002:a05:600c:608d:b0:46e:4f25:aace with SMTP id 5b1f17b1804b1-46e510d28edmr38669385e9.6.1759145902845; Mon, 29 Sep 2025 04:38:22 -0700 (PDT) Received: from Ansuel-XPS24 (host-95-249-236-54.retail.telecomitalia.it. [95.249.236.54]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-46e56f53596sm9502465e9.7.2025.09.29.04.38.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Sep 2025 04:38:22 -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 Subject: [PATCH v4 5/5] PCI: mediatek: add support for Airoha AN7583 SoC Date: Mon, 29 Sep 2025 13:38:04 +0200 Message-ID: <20250929113806.2484-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20250929113806.2484-1-ansuelsmth@gmail.com> References: <20250929113806.2484-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