From patchwork Fri Jan 3 06:00:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Smlhbmp1biBXYW5nICjnjovlu7rlhpsp?= X-Patchwork-Id: 13925168 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 74CD2E7718F for ; Fri, 3 Jan 2025 06:03:25 +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-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7fSI14JXINs/0jFNxsxkI+ZTe1Oh5xsksvQrQ5PGxns=; b=VtHJEkrGpJI7lB37gSeYK9z1I9 89m1iEZQBz5OpSgPrro+h7O98SXUjveHluc0mDKzwY4Bu1LIwoF21eKuMIeLD17Z8t9YE6v6Gkn3g J3gP83tD2k1f9mf8aBKduOZqV96iw+p3EBO9onmuVUFBqvg0KbBPao3QubtFQGDHD/kydWGWcK/gY JPgcoIvjf6N0usK3Ug19H0zQJYVcVWEV1eqEJEFJeBm/hsHUUoWo8lNHuuuDaZgwOEy8TiizeTEZd 8disMHKl+YmRR/HGGiWa7Si/ER1m8TK7p+vVpMGsjPX7ds/Cmtl/kKdi9TRwP4WaLc4Ku+D+pi8jR YVIogWHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tTamK-0000000CAb3-2kyg; Fri, 03 Jan 2025 06:03:24 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tTajv-0000000CA0d-2KPA; Fri, 03 Jan 2025 06:00:56 +0000 X-UUID: 140db102c99811ef82ff63e91e7eb18c-20250102 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=7fSI14JXINs/0jFNxsxkI+ZTe1Oh5xsksvQrQ5PGxns=; b=iQ0neLuW5KlMOjCVH4HYY9qWkjaRhsQHNPGgVc15Tbn/yi9sJjYwkBsQPHhcDwKQj9qOZ0MMf3Bz/VDFACFN0aA64P2rrUCq6KUuudUMKdXCXSH+aZa7AFjxIsq1k+7QxFwEBl6xJ5yOcC4PS6sdmUHlmzqKett+GE6nHH57q+A=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.46,REQID:63ae151e-912a-4fb3-9293-adb2f8a69112,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:60aa074,CLOUDID:39db4b37-e11c-4c1a-89f7-e7a032832c40,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:nil,Content:0|50,EDM:-3 ,IP:nil,URL:11|1,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0 ,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULN X-UUID: 140db102c99811ef82ff63e91e7eb18c-20250102 Received: from mtkmbs11n1.mediatek.inc [(172.21.101.185)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 2076254845; Thu, 02 Jan 2025 23:00:48 -0700 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by MTKMBS14N1.mediatek.inc (172.21.101.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 3 Jan 2025 14:00:45 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 3 Jan 2025 14:00:44 +0800 From: Jianjun Wang To: Bjorn Helgaas , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Manivannan Sadhasivam , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno CC: Ryder Lee , Jianjun Wang , , , , , , Xavier Chang Subject: [PATCH 1/5] dt-bindings: PCI: mediatek-gen3: Add MT8196 support Date: Fri, 3 Jan 2025 14:00:11 +0800 Message-ID: <20250103060035.30688-2-jianjun.wang@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20250103060035.30688-1-jianjun.wang@mediatek.com> References: <20250103060035.30688-1-jianjun.wang@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250102_220055_599769_B4410A69 X-CRM114-Status: UNSURE ( 9.33 ) X-CRM114-Notice: Please train this message. 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 compatible string and clock definition for MT8196. It has 6 clocks like the MT8195, but 2 of them are different. Signed-off-by: Jianjun Wang --- .../bindings/pci/mediatek-pcie-gen3.yaml | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml b/Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml index f05aab2b1add..b4158a666fb6 100644 --- a/Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml +++ b/Documentation/devicetree/bindings/pci/mediatek-pcie-gen3.yaml @@ -51,6 +51,7 @@ properties: - mediatek,mt7986-pcie - mediatek,mt8188-pcie - mediatek,mt8195-pcie + - mediatek,mt8196-pcie - const: mediatek,mt8192-pcie - const: mediatek,mt8192-pcie - const: airoha,en7581-pcie @@ -197,6 +198,34 @@ allOf: minItems: 1 maxItems: 2 + - if: + properties: + compatible: + contains: + enum: + - mediatek,mt8196-pcie + then: + properties: + clocks: + minItems: 6 + + clock-names: + items: + - const: pl_250m + - const: tl_26m + - const: peri_26m + - const: peri_mem + - const: ahb_apb + - const: low_power + + resets: + minItems: 1 + maxItems: 2 + + reset-names: + minItems: 1 + maxItems: 2 + - if: properties: compatible: From patchwork Fri Jan 3 06:00:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Smlhbmp1biBXYW5nICjnjovlu7rlhpsp?= X-Patchwork-Id: 13925177 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 58B1DE77198 for ; Fri, 3 Jan 2025 06:05:54 +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-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TsN1T6L83srZgilF5kt3qouXhBxTQ7s/Q1aBq4w0S/I=; b=tg8bR4X0/AMb6Lu/m44Zr5aFNC Dse783cv206CV0IFH1XC6zga6xb4+QqKkiQ1ms9gKxIS7q3a+FyHDtoZ/Q5LhmiB9e5kZuWcYTnfG 7DU7AyfyHousumVe7pDYV6IxftL9BLVFrEbTmpDozISYuZteT/h2HsA0vjrKioUCN9sGdn/ArWOok cqVTiJchKE57vxS32CpWjFlV2VEON4UVZ2an71RfhrWVHwWqsjCrLxNrfBhIv7KTPaD0AKEv3C2B+ VSINjkmOkSWrc318WAK6rGtqQaRvgw2nTKAT+JEVQBqULTzNGcx0mixxcpOPNI5piSWAmGgFLZytI uVbyUnSw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tTaoj-0000000CAyP-2IFd; Fri, 03 Jan 2025 06:05:53 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tTajv-0000000CA0e-2YlE; Fri, 03 Jan 2025 06:00:57 +0000 X-UUID: 149cec3cc99811ef9048ed6ed365623b-20250102 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=TsN1T6L83srZgilF5kt3qouXhBxTQ7s/Q1aBq4w0S/I=; b=aNaXvgf/AvIsHxoZQ4CoUHne+8bvsWYH48481XdPlwjtFZeFWZQAqNPk7dT+I5sxmL9Nd6CB2A9H+xGEOkWjloYN4yHOV4eQQ0rDrSUMrJ6FvmsC8X7shZvOEJDgUCOea4+kVI/DVA7ZGbCIgu8whN63zTA0vWFrXzZRmAt6xHQ=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.46,REQID:c2471643-0288-4d98-806c-9a5db5a96549,IP:0,U RL:0,TC:0,Content:-25,EDM:25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:0 X-CID-META: VersionHash:60aa074,CLOUDID:61db4b37-e11c-4c1a-89f7-e7a032832c40,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:nil,Content:0|50,EDM:5, IP:nil,URL:11|1,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0, AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULN X-UUID: 149cec3cc99811ef9048ed6ed365623b-20250102 Received: from mtkmbs09n1.mediatek.inc [(172.21.101.35)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 284206438; Thu, 02 Jan 2025 23:00:48 -0700 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs11n2.mediatek.inc (172.21.101.187) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 3 Jan 2025 14:00:46 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 3 Jan 2025 14:00:45 +0800 From: Jianjun Wang To: Bjorn Helgaas , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Manivannan Sadhasivam , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno CC: Ryder Lee , Jianjun Wang , , , , , , Xavier Chang Subject: [PATCH 2/5] PCI: mediatek-gen3: Add MT8196 support Date: Fri, 3 Jan 2025 14:00:12 +0800 Message-ID: <20250103060035.30688-3-jianjun.wang@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20250103060035.30688-1-jianjun.wang@mediatek.com> References: <20250103060035.30688-1-jianjun.wang@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250102_220055_658128_F0AAE67B X-CRM114-Status: GOOD ( 22.11 ) 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 The MT8196 is an ARM platform SoC that has the same PCIe IP as the MT8195. However, it requires additional settings in the pextpcfg registers. Introduce pextpcfg in PCIe driver for these settings. Signed-off-by: Jianjun Wang --- drivers/pci/controller/pcie-mediatek-gen3.c | 88 +++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c index be52e3a123ab..ed3c0614486c 100644 --- a/drivers/pci/controller/pcie-mediatek-gen3.c +++ b/drivers/pci/controller/pcie-mediatek-gen3.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -123,6 +124,17 @@ #define PCIE_ATR_TLP_TYPE_MEM PCIE_ATR_TLP_TYPE(0) #define PCIE_ATR_TLP_TYPE_IO PCIE_ATR_TLP_TYPE(2) +#define PCIE_RESOURCE_CTRL_REG 0xd2c +#define PCIE_SYS_CLK_RDY_TIME_MASK GENMASK(7, 0) +#define PCIE_SYS_CLK_RDY_TIME_TO_10US 0xa + +/* PEXTPCFG Registers */ +#define PEXTP_CLOCK_CON_REG 0x20 +#define PEXTP_P0P1_LOWPOWER_CK_SEL BIT(0) +#define PEXTP_REQ_CTRL_0_REG 0x7c +#define PEXTP_26M_REQ_FORCE_ON BIT(0) +#define PEXTP_PCIE26M_BYPASS BIT(4) + #define MAX_NUM_PHY_RESETS 3 /* Time in ms needed to complete PCIe reset on EN7581 SoC */ @@ -136,10 +148,14 @@ struct mtk_gen3_pcie; /** * struct mtk_gen3_pcie_pdata - differentiate between host generations * @power_up: pcie power_up callback + * @pre_init: initialize settings before link up + * @cleanup: cleanup when PCIe power down * @phy_resets: phy reset lines SoC data. */ struct mtk_gen3_pcie_pdata { int (*power_up)(struct mtk_gen3_pcie *pcie); + int (*pre_init)(struct mtk_gen3_pcie *pcie); + void (*cleanup)(struct mtk_gen3_pcie *pcie); struct { const char *id[MAX_NUM_PHY_RESETS]; int num_resets; @@ -162,6 +178,7 @@ struct mtk_msi_set { * struct mtk_gen3_pcie - PCIe port information * @dev: pointer to PCIe device * @base: IO mapped register base + * @pextpcfg: pextpcfg_ao IO mapped register base * @reg_base: physical register base * @mac_reset: MAC reset control * @phy_resets: PHY reset controllers @@ -184,6 +201,7 @@ struct mtk_msi_set { struct mtk_gen3_pcie { struct device *dev; void __iomem *base; + void __iomem *pextpcfg; phys_addr_t reg_base; struct reset_control *mac_reset; struct reset_control_bulk_data phy_resets[MAX_NUM_PHY_RESETS]; @@ -422,6 +440,13 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie) writel_relaxed(val, pcie->base + PCIE_CONF_LINK2_CTL_STS); } + /* + * The values of some registers are different in RC and EP mode. Therefore, + * call soc->pre_init after the mode change in case it depends on these registers. + */ + if (pcie->soc && pcie->soc->pre_init) + pcie->soc->pre_init(pcie); + /* Set class code */ val = readl_relaxed(pcie->base + PCIE_PCI_IDS_1); val &= ~GENMASK(31, 8); @@ -848,6 +873,7 @@ static int mtk_pcie_parse_port(struct mtk_gen3_pcie *pcie) int i, ret, num_resets = pcie->soc->phy_resets.num_resets; struct device *dev = pcie->dev; struct platform_device *pdev = to_platform_device(dev); + struct device_node *node; struct resource *regs; u32 num_lanes; @@ -903,6 +929,18 @@ static int mtk_pcie_parse_port(struct mtk_gen3_pcie *pcie) pcie->num_lanes = num_lanes; } + node = of_parse_phandle(dev->of_node, "pextpcfg", 0); + if (node) { + pcie->pextpcfg = of_iomap(node, 0); + of_node_put(node); + if (IS_ERR(pcie->pextpcfg)) { + dev_err(dev, "failed to get pextpcfg\n"); + ret = PTR_ERR(pcie->pextpcfg); + pcie->pextpcfg = NULL; + return ret; + } + } + return 0; } @@ -1047,6 +1085,12 @@ static void mtk_pcie_power_down(struct mtk_gen3_pcie *pcie) phy_power_off(pcie->phy); phy_exit(pcie->phy); reset_control_bulk_assert(pcie->soc->phy_resets.num_resets, pcie->phy_resets); + + if (pcie->soc && pcie->soc->cleanup) + pcie->soc->cleanup(pcie); + + if (pcie->pextpcfg) + iounmap(pcie->pextpcfg); } static int mtk_pcie_get_controller_max_link_speed(struct mtk_gen3_pcie *pcie) @@ -1277,6 +1321,49 @@ static const struct mtk_gen3_pcie_pdata mtk_pcie_soc_mt8192 = { }, }; +static int mtk_pcie_mt8196_pre_init(struct mtk_gen3_pcie *pcie) +{ + u32 val; + + /* Adjust SYS_CLK_RDY_TIME ot 10us to avoid glitch */ + val = readl_relaxed(pcie->base + PCIE_RESOURCE_CTRL_REG); + val &= ~PCIE_SYS_CLK_RDY_TIME_MASK; + val |= PCIE_SYS_CLK_RDY_TIME_TO_10US; + writel_relaxed(val, pcie->base + PCIE_RESOURCE_CTRL_REG); + + /* Switch to normal clock */ + val = readl_relaxed(pcie->pextpcfg + PEXTP_CLOCK_CON_REG); + val &= ~PEXTP_P0P1_LOWPOWER_CK_SEL; + writel_relaxed(val, pcie->pextpcfg + PEXTP_CLOCK_CON_REG); + + /* Force pcie_26m_req and bypass pcie_26m_ack signal */ + val = readl_relaxed(pcie->pextpcfg + PEXTP_REQ_CTRL_0_REG); + val |= (PEXTP_26M_REQ_FORCE_ON | PEXTP_PCIE26M_BYPASS); + writel_relaxed(val, pcie->pextpcfg + PEXTP_REQ_CTRL_0_REG); + + return 0; +} + +static void mtk_pcie_mt8196_cleanup(struct mtk_gen3_pcie *pcie) +{ + u32 val; + + /* Release pcie_26m_req and pcie_26m_ack signal */ + val = readl_relaxed(pcie->pextpcfg + PEXTP_REQ_CTRL_0_REG); + val &= ~(PEXTP_26M_REQ_FORCE_ON | PEXTP_PCIE26M_BYPASS); + writel_relaxed(val, pcie->pextpcfg + PEXTP_REQ_CTRL_0_REG); +} + +static const struct mtk_gen3_pcie_pdata mtk_pcie_soc_mt8196 = { + .power_up = mtk_pcie_power_up, + .pre_init = mtk_pcie_mt8196_pre_init, + .cleanup = mtk_pcie_mt8196_cleanup, + .phy_resets = { + .id[0] = "phy", + .num_resets = 1, + }, +}; + static const struct mtk_gen3_pcie_pdata mtk_pcie_soc_en7581 = { .power_up = mtk_pcie_en7581_power_up, .phy_resets = { @@ -1290,6 +1377,7 @@ static const struct mtk_gen3_pcie_pdata mtk_pcie_soc_en7581 = { static const struct of_device_id mtk_pcie_of_match[] = { { .compatible = "airoha,en7581-pcie", .data = &mtk_pcie_soc_en7581 }, { .compatible = "mediatek,mt8192-pcie", .data = &mtk_pcie_soc_mt8192 }, + { .compatible = "mediatek,mt8196-pcie", .data = &mtk_pcie_soc_mt8196 }, {}, }; MODULE_DEVICE_TABLE(of, mtk_pcie_of_match); From patchwork Fri Jan 3 06:00:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Smlhbmp1biBXYW5nICjnjovlu7rlhpsp?= X-Patchwork-Id: 13925178 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 64953E77188 for ; Fri, 3 Jan 2025 06:08:22 +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-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=8aGyyE4ZNasZE1YSK6osQK3Ake9zKnUpC4PIOmTm/Ls=; b=1w+fU7NSdECIHEegnuyH9MOGo7 qWaWDNEA+kW3IeZdMX9hYbrNrWNpSIHjlIib/12dM4w71x0poHAMgIde4hLo5L3+5WhzyoCcB8yfp sGlR+mjXG/vyZKsdF+ubv9sVucc+ITIhxYKooQN8HXR+FFGepV2fm6KJLTEhfUNYTny1hCARGhdf0 vhUfYA4eVfjSHA/Ows7KmJVKBJslbaB5Oc/zIn1v16hXheElIwRnkwzkNxWRHwCpsQ6lwvFnugN9I Tq5bxu7yirKBN7b+mWz3bB+DhlRlXI7QFPizbAS8CBrCKJy40XnuKvfbzsWn3FS6U6dt1b0oLRBEx Im3hP+eg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tTar7-0000000CBM3-2Cbf; Fri, 03 Jan 2025 06:08:21 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tTajw-0000000CA0b-096d; Fri, 03 Jan 2025 06:00:57 +0000 X-UUID: 15300b7ac99811ef82ff63e91e7eb18c-20250102 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=8aGyyE4ZNasZE1YSK6osQK3Ake9zKnUpC4PIOmTm/Ls=; b=hn8B+zkRIrdZoXeDwk94xnM08wf7g+Ys0Gcxn15nTdmCQBZqOSuGJltDOQwyIGYp6cnSbA5ihCTWRHkeFDHwwfVAaJy58vjPAUIMuh05UlDsT287J1/KNkQDdmfyFNu9p4DHdTc359X2mUqPOWt2/5bPaQLsQMeeXlEd34jXdaU=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.46,REQID:4ae86738-13f7-4687-8f6a-00cda4d75fed,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:60aa074,CLOUDID:ae3a9825-8650-4337-bf57-045b64170f0c,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:nil,Content:0|50,EDM:-3 ,IP:nil,URL:11|1,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0 ,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULN X-UUID: 15300b7ac99811ef82ff63e91e7eb18c-20250102 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1341089430; Thu, 02 Jan 2025 23:00:49 -0700 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 3 Jan 2025 14:00:47 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 3 Jan 2025 14:00:46 +0800 From: Jianjun Wang To: Bjorn Helgaas , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Manivannan Sadhasivam , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno CC: Ryder Lee , Jianjun Wang , , , , , , Xavier Chang Subject: [PATCH 3/5] PCI: mediatek-gen3: Disable ASPM L0s Date: Fri, 3 Jan 2025 14:00:13 +0800 Message-ID: <20250103060035.30688-4-jianjun.wang@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20250103060035.30688-1-jianjun.wang@mediatek.com> References: <20250103060035.30688-1-jianjun.wang@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250102_220056_093047_36F6514E X-CRM114-Status: GOOD ( 10.62 ) 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 Disable ASPM L0s support because it does not significantly save power but impacts performance. Signed-off-by: Jianjun Wang --- drivers/pci/controller/pcie-mediatek-gen3.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c index ed3c0614486c..4bd3b39eebe2 100644 --- a/drivers/pci/controller/pcie-mediatek-gen3.c +++ b/drivers/pci/controller/pcie-mediatek-gen3.c @@ -84,6 +84,9 @@ #define PCIE_MSI_SET_ENABLE_REG 0x190 #define PCIE_MSI_SET_ENABLE GENMASK(PCIE_MSI_SET_NUM - 1, 0) +#define PCIE_LOW_POWER_CTRL_REG 0x194 +#define PCIE_FORCE_DIS_L0S BIT(8) + #define PCIE_PIPE4_PIE8_REG 0x338 #define PCIE_K_FINETUNE_MAX GENMASK(5, 0) #define PCIE_K_FINETUNE_ERR GENMASK(7, 6) @@ -458,6 +461,14 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie) val &= ~PCIE_INTX_ENABLE; writel_relaxed(val, pcie->base + PCIE_INT_ENABLE_REG); + /* + * Disable L0s support because it does not significantly save power + * but impacts performance. + */ + val = readl_relaxed(pcie->base + PCIE_LOW_POWER_CTRL_REG); + val |= PCIE_FORCE_DIS_L0S; + writel_relaxed(val, pcie->base + PCIE_LOW_POWER_CTRL_REG); + /* Disable DVFSRC voltage request */ val = readl_relaxed(pcie->base + PCIE_MISC_CTRL_REG); val |= PCIE_DISABLE_DVFSRC_VLT_REQ; From patchwork Fri Jan 3 06:00:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Smlhbmp1biBXYW5nICjnjovlu7rlhpsp?= X-Patchwork-Id: 13925176 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 285A0E77188 for ; Fri, 3 Jan 2025 06:05:54 +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-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=7pw2Eg2CoZnwYLB8feuiTpkmmwpupbCUbpnCYeC/dUI=; b=XcqtrNpyBqCrqDTEPBpwIXW7JI lpHLf92Brs8N2YUk8BTdwr4iwkda8dlZKS4XSniVptvPBxotdp66fm+Qlwst4nbc5viVib0/L8Sra 9Gz85uvpgN/lnzd7ySEObqPH29FhAuLycEqBHsmcYv/Fn2lzEt0NFUFhE3TVGPVc+1J5gzTw51eTj lpw01bQ2LtQlBZ1jjDXkBJS5slLnsVKLn8uazGn75ZX2AoZTwRcJ7uCHgRN6rnPj0bGtl+DsKw5nJ wxOCXhfafGXeCUSITBZZpZqpzwX6UmmwYNqQJdAD50qLZRpkllHw7F99bevb2rP6F5Dk+HjOFUSCN UErQfFzg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tTaoj-0000000CAxy-12A0; Fri, 03 Jan 2025 06:05:53 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tTajv-0000000CA0c-2YeD; Fri, 03 Jan 2025 06:00:57 +0000 X-UUID: 15cdc9dcc99811ef9048ed6ed365623b-20250102 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=7pw2Eg2CoZnwYLB8feuiTpkmmwpupbCUbpnCYeC/dUI=; b=qOIEPzQoODDc5mvJv1HcdOvn7lv93s/30iIyQ2Hl7BD0oJg4iOpSQeZp8hZmsWA+dbh6L6yJ65h2zBvjltfqaoYRq6ziaKP4kXJaifE2KH8qh6ufnDMtcLWL2rgNoLjN1YYQwpMt343Wx9Yu/alEQUa/psdftw+37uaC6/y2m3Q=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.46,REQID:80db15d9-f434-41d8-bd03-56a1c6fa5766,IP:0,U RL:0,TC:0,Content:-5,EDM:25,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:20 X-CID-META: VersionHash:60aa074,CLOUDID:58c34419-ec44-4348-86ee-ebcff634972b,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:nil,Content:0|50,EDM:5, IP:nil,URL:11|1,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0, AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0 X-CID-BAS: 0,_,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULN X-UUID: 15cdc9dcc99811ef9048ed6ed365623b-20250102 Received: from mtkmbs09n1.mediatek.inc [(172.21.101.35)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 236518474; Thu, 02 Jan 2025 23:00:50 -0700 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by MTKMBS14N1.mediatek.inc (172.21.101.75) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 3 Jan 2025 14:00:48 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 3 Jan 2025 14:00:47 +0800 From: Jianjun Wang To: Bjorn Helgaas , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Manivannan Sadhasivam , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno CC: Ryder Lee , Jianjun Wang , , , , , , Xavier Chang Subject: [PATCH 4/5] PCI: mediatek-gen3: Don't reply AXI slave error Date: Fri, 3 Jan 2025 14:00:14 +0800 Message-ID: <20250103060035.30688-5-jianjun.wang@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20250103060035.30688-1-jianjun.wang@mediatek.com> References: <20250103060035.30688-1-jianjun.wang@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250102_220055_658564_63AB0F8D X-CRM114-Status: GOOD ( 14.61 ) 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 There are some circumstances where the EP device will not respond to non-posted access from the root port (e.g., MMIO read). In such cases, the root port will reply with an AXI slave error, which will be treated as a System Error (SError), causing a kernel panic and preventing us from obtaining any useful information for further debugging. We have added a new bit in the PCIE_AXI_IF_CTRL_REG register to prevent PCIe AXI0 from replying with a slave error. Setting this bit on an older platform that does not support this feature will have no effect. By preventing AXI0 from replying with a slave error, we can keep the kernel alive and debug using the information from AER. Signed-off-by: Jianjun Wang --- drivers/pci/controller/pcie-mediatek-gen3.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c index 4bd3b39eebe2..48f83c2d91f7 100644 --- a/drivers/pci/controller/pcie-mediatek-gen3.c +++ b/drivers/pci/controller/pcie-mediatek-gen3.c @@ -87,6 +87,9 @@ #define PCIE_LOW_POWER_CTRL_REG 0x194 #define PCIE_FORCE_DIS_L0S BIT(8) +#define PCIE_AXI_IF_CTRL_REG 0x1a8 +#define PCIE_AXI0_SLV_RESP_MASK BIT(12) + #define PCIE_PIPE4_PIE8_REG 0x338 #define PCIE_K_FINETUNE_MAX GENMASK(5, 0) #define PCIE_K_FINETUNE_ERR GENMASK(7, 6) @@ -469,6 +472,15 @@ static int mtk_pcie_startup_port(struct mtk_gen3_pcie *pcie) val |= PCIE_FORCE_DIS_L0S; writel_relaxed(val, pcie->base + PCIE_LOW_POWER_CTRL_REG); + /* + * Prevent PCIe AXI0 from replying a slave error, as it will cause kernel panic + * and prevent us from getting useful information. + * Keep the kernel alive and debug using the information from AER. + */ + val = readl_relaxed(pcie->base + PCIE_AXI_IF_CTRL_REG); + val |= PCIE_AXI0_SLV_RESP_MASK; + writel_relaxed(val, pcie->base + PCIE_AXI_IF_CTRL_REG); + /* Disable DVFSRC voltage request */ val = readl_relaxed(pcie->base + PCIE_MISC_CTRL_REG); val |= PCIE_DISABLE_DVFSRC_VLT_REQ; From patchwork Fri Jan 3 06:00:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Smlhbmp1biBXYW5nICjnjovlu7rlhpsp?= X-Patchwork-Id: 13925179 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 9E1F2E7718F for ; Fri, 3 Jan 2025 06:08:22 +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-Type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:CC:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=5fd/q59gvByZH+NptJiVBXQPQ56n4yqQJajHMESFfjw=; b=WuY0vtumEH40bWg9HYduP11Cdq YrU6b7bTe0fl5pw9eVRKPro4p3OPtZaUc+i0Co+JnkVIHQ58Ef2wizRWnvo4dcX3bm1JOYo9nrzcx 0iPMKVVRhePJTGPOKwU2XTaC4CwcEdtv7cpSU9MFG6uVLL/UTy447udYeL+DamnVtrKsTklg8PoBh gJKxa3FMhwDxW1upJYVsfNmUwdjaGOpl8XA0OqTida/+8q+p7yCUbKmn8w8t8hEXYJuAg5zOC06Vc 2vg3GCOf5fXwpouUI8iuRtu56nnuNHOQVA6KmrqMmjpCZkgZWjE928AH0nOI5if4+mces14W7vfnh 1rktflYw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tTar7-0000000CBML-3ZAI; Fri, 03 Jan 2025 06:08:21 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tTajw-0000000CA1x-1ahA; Fri, 03 Jan 2025 06:00:57 +0000 X-UUID: 15b2669cc99811ef82ff63e91e7eb18c-20250102 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=5fd/q59gvByZH+NptJiVBXQPQ56n4yqQJajHMESFfjw=; b=V7g8Q3CznUgwxThh1EL3yMgF3UjCr0UUsKLHLoQ/0uhJPBG+lMUdfS+IHWPiyZmVzIy0j1yEg+PPkcM84+n3iYUkGy5K5igomns9dWaJbj0TF/A+2HhY/Xc1HegdApnU9IReoo+UnWwRzNEd/mH7fOAUVKxPapbW4NLXLH6zIRI=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.46,REQID:9fc907d8-3102-40eb-9963-c6ef77e317b3,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:60aa074,CLOUDID:6ec34419-ec44-4348-86ee-ebcff634972b,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:81|82|102,TC:nil,Content:0|50,EDM:-3 ,IP:nil,URL:11|1,File:nil,RT:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0 ,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 0,NGT X-CID-BAS: 0,NGT,0,_ X-CID-FACTOR: TF_CID_SPAM_SNR,TF_CID_SPAM_ULN X-UUID: 15b2669cc99811ef82ff63e91e7eb18c-20250102 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 6181237; Thu, 02 Jan 2025 23:00:50 -0700 Received: from mtkmbs11n1.mediatek.inc (172.21.101.185) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Fri, 3 Jan 2025 14:00:49 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Fri, 3 Jan 2025 14:00:48 +0800 From: Jianjun Wang To: Bjorn Helgaas , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy=C5=84?= =?utf-8?q?ski?= , Manivannan Sadhasivam , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Matthias Brugger , AngeloGioacchino Del Regno CC: Ryder Lee , Jianjun Wang , , , , , , Xavier Chang Subject: [PATCH 5/5] PCI: mediatek-gen3: Keep PCIe power and clocks if suspend-to-idle Date: Fri, 3 Jan 2025 14:00:15 +0800 Message-ID: <20250103060035.30688-6-jianjun.wang@mediatek.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20250103060035.30688-1-jianjun.wang@mediatek.com> References: <20250103060035.30688-1-jianjun.wang@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250102_220056_442978_6F36BEC8 X-CRM114-Status: GOOD ( 14.54 ) 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 If the target system sleep state is suspend-to-idle, the bridge is supposed to stay in D0, and the framework will not help to restore its configuration space, so keep its power and clocks during suspend. It's recommended to enable L1ss support, so the link can be changed to L1.2 state during suspend. Signed-off-by: Jianjun Wang --- drivers/pci/controller/pcie-mediatek-gen3.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c index 48f83c2d91f7..11da68910502 100644 --- a/drivers/pci/controller/pcie-mediatek-gen3.c +++ b/drivers/pci/controller/pcie-mediatek-gen3.c @@ -1291,6 +1291,19 @@ static int mtk_pcie_suspend_noirq(struct device *dev) int err; u32 val; + /* + * If the target system sleep state is suspend-to-idle, the bridge is supposed to stay in + * D0, and the framework will not help to restore its configuration space, so keep it's + * power and clocks during suspend. + * + * It's recommended to enable L1ss support, so the link can be changed to L1.2 state during + * suspend. + */ + if (pm_suspend_default_s2idle()) { + dev_info(dev, "System enter s2idle state, keep PCIe power and clocks\n"); + return 0; + } + /* Trigger link to L2 state */ err = mtk_pcie_turn_off_link(pcie); if (err) { @@ -1316,6 +1329,11 @@ static int mtk_pcie_resume_noirq(struct device *dev) struct mtk_gen3_pcie *pcie = dev_get_drvdata(dev); int err; + if (pm_suspend_default_s2idle()) { + dev_info(dev, "System enter s2idle state, no need to reinitialization\n"); + return 0; + } + err = pcie->soc->power_up(pcie); if (err) return err;