Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp263459pxj; Fri, 14 May 2021 02:53:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyYqwirYQv9hGmStnnByoNir0RUNhRXyh3WiOSzQHo7chkhwZdAFZDman0svC40iYFBSyjC X-Received: by 2002:a5d:8481:: with SMTP id t1mr35148963iom.39.1620985994749; Fri, 14 May 2021 02:53:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620985994; cv=none; d=google.com; s=arc-20160816; b=YqPEsCifWB6asunSmibkrieelFMBGmpu2/q2dru0kAV7LNWb+hlj0U2w2wu11OJW3z vM9QKdnUkUMah/BqMqPWvhsNefKZmAIhH7U4X1fIcZXOUe5Re0JaoRdSMY779zJEoTC3 cTdojlnkp7OQR2o0s3FWqbmZONYa6LESQauC7SOXXVolS2brBbj+Ux8xtxdEs3OyGBGQ unQPpFTIRdzAYRtm2xBYO+XzReymuyoM22WuKfxGgK+sJZBC+ekcPvclgHXmDI5jI8dH WuLScRVV6YjvDzGNmHgLIoU/5I3AwgNeGJru11sdWq3uWnWpI5zbuwQBMyC5rRNzSHcM 8Wdg== 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=MX37rqStEbJKWe4umrJbrGz5DL6Uuj9GBtHzBnI+zi0=; b=CEovBYCXJOw438pFD9wps4QkKGCvdCeeaz9XUks0ODpK3R5t7Hpn6KO3r1QZRgjUKD +OpCVJcmslgpGE9T46FyzNEAJUldDeJMcyxjGLxXrU3FFyuxOPi6z3xLca0SwsXAMFly a4sQq5Iz5Wfms5YFJX+r5+s5f5JUoYo56Khgxgqerl+/KLt40Cpp1mzSxxNU2s2QaEbf dHEhD4Ko1dnSnP5k3QN7dXpIoKz6ghxlMyjyGeAp1af6chyRlpYNx5wLTNMUGYualh3o I/0KvVEypVJo/NkgvJJEn2WHRHs5BKmGFouCeqvXSBdNEBfoTedp+Hu0qDi27C4N7xi3 ocbg== 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 q13si7498009ilg.125.2021.05.14.02.53.01; Fri, 14 May 2021 02:53:14 -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 S231956AbhENHBg (ORCPT + 99 others); Fri, 14 May 2021 03:01:36 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:43365 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S230212AbhENHBd (ORCPT ); Fri, 14 May 2021 03:01:33 -0400 X-UUID: cf9f7cfec056423eb19f1ea647d1f587-20210514 X-UUID: cf9f7cfec056423eb19f1ea647d1f587-20210514 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 941507898; Fri, 14 May 2021 14:59:54 +0800 Received: from mtkcas10.mediatek.inc (172.21.101.39) by mtkmbs05n1.mediatek.inc (172.21.101.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 14 May 2021 14:59:53 +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; Fri, 14 May 2021 14:59:51 +0800 From: Jianjun Wang To: Bjorn Helgaas , Rob Herring , Lorenzo Pieralisi , Ryder Lee CC: Matthias Brugger , , , , , , Jianjun Wang , , , , , , , Krzysztof Wilczyski , Subject: [PATCH 2/2] PCI: mediatek-gen3: Add support for disable dvfsrc voltage request Date: Fri, 14 May 2021 14:59:27 +0800 Message-ID: <20210514065927.20774-3-jianjun.wang@mediatek.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20210514065927.20774-1-jianjun.wang@mediatek.com> References: <20210514065927.20774-1-jianjun.wang@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 PCIe Gen3 PHY layer cannot work properly when the requested voltage is lower than a specific level(e.g. 0.55V, it's depends on the chip manufacturing process). When the dvfsrc feature is implemented, the requested voltage may be reduced to a lower level in suspend mode, hence that the MAC layer will assert a HW signal to request the dvfsrc to raise voltage to normal mode, and it will wait the voltage ready signal which is derived from dvfsrc to determine whether the LTSSM can start normally. When the dvfsrc feature is not implemented, the MAC layer still assert the voltage request to dvfsrc when exit suspend mode, but will not receive the voltage ready signal, in this case, the LTSSM cannot start normally, and the PCIe link will be failed. Add support for disable dvfsrc voltage request. If the property of "disable-dvfsrc-vlt-req" is presented in device node, we assume that the requested voltage is always higher enough to keep the PCIe Gen3 PHY active, and the voltage request to dvfsrc should be disabled. Signed-off-by: Jianjun Wang --- drivers/pci/controller/pcie-mediatek-gen3.c | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/drivers/pci/controller/pcie-mediatek-gen3.c b/drivers/pci/controller/pcie-mediatek-gen3.c index 20165e4a75b2..d1864303217e 100644 --- a/drivers/pci/controller/pcie-mediatek-gen3.c +++ b/drivers/pci/controller/pcie-mediatek-gen3.c @@ -68,6 +68,9 @@ #define PCIE_MSI_SET_ENABLE_REG 0x190 #define PCIE_MSI_SET_ENABLE GENMASK(PCIE_MSI_SET_NUM - 1, 0) +#define PCIE_MISC_CTRL_REG 0x348 +#define PCIE_DISABLE_DVFSRC_VLT_REQ BIT(1) + #define PCIE_MSI_SET_BASE_REG 0xc00 #define PCIE_MSI_SET_OFFSET 0x10 #define PCIE_MSI_SET_STATUS_OFFSET 0x04 @@ -297,6 +300,35 @@ static int mtk_pcie_startup_port(struct mtk_pcie_port *port) val &= ~PCIE_INTX_ENABLE; writel_relaxed(val, port->base + PCIE_INT_ENABLE_REG); + /* + * PCIe Gen3 PHY layer can not work properly when the requested voltage + * is lower than a specific level(e.g. 0.55V, it's depends on + * the chip manufacturing process). + * + * When the dvfsrc feature is implemented, the requested voltage + * may be reduced to a lower level in suspend mode, hence that + * the MAC layer will assert a HW signal to request the dvfsrc + * to raise voltage to normal mode, and it will wait the voltage + * ready signal which is derived from dvfsrc to determine whether + * the LTSSM can start normally. + * + * When the dvfsrc feature is not implemented, the MAC layer still + * assert the voltage request to dvfsrc when exit suspend mode, + * but will not receive the voltage ready signal, in this case, + * the LTSSM cannot start normally, and the PCIe link will be failed. + * + * If the property of "disable-dvfsrc-vlt-req" is presented + * in device node, we assume that the requested voltage is always + * higher enough to keep the PCIe Gen3 PHY active, and the voltage + * request to dvfsrc should be disabled. + */ + val = readl_relaxed(port->base + PCIE_MISC_CTRL_REG); + val &= ~PCIE_DISABLE_DVFSRC_VLT_REQ; + if (of_property_read_bool(port->dev->of_node, "disable-dvfsrc-vlt-req")) + val |= PCIE_DISABLE_DVFSRC_VLT_REQ; + + writel(val, port->base + PCIE_MISC_CTRL_REG); + /* Assert all reset signals */ val = readl_relaxed(port->base + PCIE_RST_CTRL_REG); val |= PCIE_MAC_RSTB | PCIE_PHY_RSTB | PCIE_BRG_RSTB | PCIE_PE_RSTB; -- 2.25.1