From patchwork Thu Dec 9 21:13:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12695524 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 9D882C433F5 for ; Thu, 9 Dec 2021 21:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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=mW3R0iqWubjPkXpXjV99RH+NCeh+GT+Se9ooFIeUPj0=; b=U3z6gH+Mqfhg3Q piyzh9hCxEzP9zerJu8nDS6hwyCysQLbY2sOeJ5iuCoK1csX1DG97OeGW0YDOkrrPVYwRkY8rCXht /uRM2sPO9WNUyGl0LlmaikR6DYzEbP/PPmIP2XiJfhqlfT+mv27LvAinn2minh+35ePowlFgx2wrZ 6J17PAN/sc+CfUMSdJJEVxV8A4jEuKAwaM0PuAcz6ihVGadO9sfVC7qnvBLAqiY9yeWzE7cI2zPoG 7tRQwZva5omYek2Re0CRTW+e7j9BXQOj2eVamcYD2syBe1blt7fplYdt/N5d7Xoe8glxF8JmQEni3 Q5aSuw5IL/rgtJxmuj8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvQkI-0000qX-4U; Thu, 09 Dec 2021 21:14:30 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvQk5-0000lt-M2; Thu, 09 Dec 2021 21:14:18 +0000 Received: by mail-pl1-x635.google.com with SMTP id u11so4853069plf.3; Thu, 09 Dec 2021 13:14:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+zcuXFbqK8H0xdNFwVNSeclVkixsgVOiV/M+oI0ZGTY=; b=jSJTycM1LHfsqch9Tn+iEzckPdBUoUSwsZSLvvFvx9HL1d+3H2meXR8c2PgUIVDIbm +2sOF0dBLdEyARpv2FiufUTh9W62UGUm1FzD6U+JkKBt7WViSRUz1Q+IdZyl1pUurE4Q uceVQ2eDN/K4tY6dUKa3NL+Ke4WoeRwPmUHDc7dp0SOszJ9kbtl0uoS8tmx9JXHyiUoa PyoeYc2RvC+w4SLaB3JjGkiUb2jV0kFLwElzvvl8RxdaP9JwOw9RufhCQmhmr1105+// IqYatHMACCNAWcYJXkaPbv6lkxYfqlDB8gymqQoM6hBvWaK8KNDd8QmrFGMm8BCuUC8y UIew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+zcuXFbqK8H0xdNFwVNSeclVkixsgVOiV/M+oI0ZGTY=; b=fzXQXZ63cqmA1L+DKaEV3ZlBb05IaYwTJxqGyb8NQCwuaNcjS72TlwBBLg3LQNf6Ub UXXDyJfoCChMN9kyygzyU1wCF+r74JQRfhy76/8urNboqZTmNOYpDa5mafT8R0REUczl 54UsCSCuWaanoQQ+dGjDB45WRc8HflBQFCI7awZ9/MynIuxiRXx6jKkJh/KAOI/3dq/l d1rBvZybzUnDj30CKehfBC32AdxuuSiNCbM1U8SU+aY2SxEGvlWeqzYnBDdy3I2RditX UsB0mKIoBRJ+pLVxjw+bzzI2Esx0poGtyV3jcc4k8R6ycMnttvp0y6PNHNX4x53hOPCW yxkA== X-Gm-Message-State: AOAM530C1l9b57IOAJ1azTlKnjqgrxXdQn0YuJ29p2XP11kHCTcoqK86 OapdWjHIH02twfNwx/a9tfk= X-Google-Smtp-Source: ABdhPJyX/WNjlHXzEOS9kK07DY0dM2ycqsaHaQnGFsuHE4Oc6LPhdzvaWvbMeLDlO1h0yNCKdee+5A== X-Received: by 2002:a17:90a:5d8b:: with SMTP id t11mr18548215pji.8.1639084456602; Thu, 09 Dec 2021 13:14:16 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id y4sm617800pfi.178.2021.12.09.13.14.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 13:14:16 -0800 (PST) From: Jim Quinlan To: linux-pci@vger.kernel.org, Bjorn Helgaas , Nicolas Saenz Julienne , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Philipp Zabel , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v10 1/7] PCI: brcmstb: Fix function return value handling Date: Thu, 9 Dec 2021 16:13:59 -0500 Message-Id: <20211209211407.8102-2-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211209211407.8102-1-jim2101024@gmail.com> References: <20211209211407.8102-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211209_131417_748983_D24EC5C5 X-CRM114-Status: GOOD ( 15.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Do at least a dev_err() on some calls to reset_control_rearm() and brcm_phy_stop(). In some cases it may not make sense to return this error value "above" as doing so will cause more trouble than is warranted. Signed-off-by: Jim Quinlan Acked-by: Florian Fainelli --- drivers/pci/controller/pcie-brcmstb.c | 28 +++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 1fc7bd49a7ad..9ed79ddb6a83 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -1146,11 +1146,23 @@ static int brcm_pcie_suspend(struct device *dev) int ret; brcm_pcie_turn_off(pcie); - ret = brcm_phy_stop(pcie); - reset_control_rearm(pcie->rescal); + /* + * If brcm_phy_stop() returns an error, just dev_err(). If we + * return the error it will cause the suspend to fail and this is a + * forgivable offense that will probably be erased on resume. + */ + if (brcm_phy_stop(pcie)) + dev_err(dev, "Could not stop phy for suspend\n"); + + ret = reset_control_rearm(pcie->rescal); + if (ret) { + dev_err(dev, "Could not rearm rescal reset\n"); + return ret; + } + clk_disable_unprepare(pcie->clk); - return ret; + return 0; } static int brcm_pcie_resume(struct device *dev) @@ -1161,7 +1173,9 @@ static int brcm_pcie_resume(struct device *dev) int ret; base = pcie->base; - clk_prepare_enable(pcie->clk); + ret = clk_prepare_enable(pcie->clk); + if (ret) + return ret; ret = reset_control_reset(pcie->rescal); if (ret) @@ -1202,8 +1216,10 @@ static void __brcm_pcie_remove(struct brcm_pcie *pcie) { brcm_msi_remove(pcie); brcm_pcie_turn_off(pcie); - brcm_phy_stop(pcie); - reset_control_rearm(pcie->rescal); + if (brcm_phy_stop(pcie)) + dev_err(pcie->dev, "Could not stop phy\n"); + if (reset_control_rearm(pcie->rescal)) + dev_err(pcie->dev, "Could not rearm rescal reset\n"); clk_disable_unprepare(pcie->clk); } From patchwork Thu Dec 9 21:14:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12695526 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 703F8C433F5 for ; Thu, 9 Dec 2021 21:16:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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=TXFOVpJ95o3nh1Erb4ojLzD2UzpgfnRbCu92wM47yuo=; b=1DqircAWsVLack 4XvFv5NJcifQ49A7zWbMgijSXq66fa0Br88e4TK8FtLAiESVDOPQ9qDXzHS+8bo8nym1ZChhHOqSm qHz+yj6axeK9ZeiKV63YzMDpLkJP6e+LUBm9HAjxojZe5g+17DgtQH+5Tjxpr6xT+ItMZtlNGowWV xDqL57HvBOFt/pZcmFtK7BFgwIdLQTgRvOpg9xrg2HcwPqV1Lrdj4nMsJw1bNhTHOzgHbS0+/BFPl NDTtkHDL/dliMotPCgrlvGRshJKxdP9iw9GiuIpXOPLDsqpxXL12Wpbe9W40QeU6jY9CWyZZrI/56 MApsvDrdqY3GVNsToysw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvQkT-0000u9-9J; Thu, 09 Dec 2021 21:14:41 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvQk8-0000mp-2v; Thu, 09 Dec 2021 21:14:21 +0000 Received: by mail-pj1-x1035.google.com with SMTP id cq22-20020a17090af99600b001a9550a17a5so7937208pjb.2; Thu, 09 Dec 2021 13:14:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=SdN+YJ62TXrTSxCxmD4U/e88GUhW9Xo7AMa+zjJB9y8=; b=CEZjJ6rON2Dxa3ezTLBnLvMR8JtdoIvoXMd6bldW5WACutcqoiVcGHoSrvrq+9u4h/ 7qmo9g7x2ghdZF2IcsOBZvXjyma44FYIVcdfXR82SeNEXVqaNSzkNBSycZ6RznMZu1XW gJsfvSpJzUsqqY1TiaIAKSnEtpp9lJGY0Tiiz20PMsXtZMMcvVQ6JJ3Uk7GKyGWVINFF ZM9uTpIZFm3izf0KLV7TVfpNc9fNkuCsG+o0SdEa5xqRvtc7NJpdZ3lNSQkJuHhni5yA gNzedWwEu1UkpKi9mWsutT5EcyGEGhQAujI/9dkYlJpPvAw5GulJL5PErUSUgE0walqI 2cwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=SdN+YJ62TXrTSxCxmD4U/e88GUhW9Xo7AMa+zjJB9y8=; b=URckWTxZLib+L3Na2QcGbqWA4LVA8C0TTM28DMtXW+rn/nbmQPBHuNGWmP1y96wlaG bTIYhV8deoo4XuNjX5LAxwo1MoKZSNsGH/Z4GCq4aVAeEDWyHYfY7T45sIXY2zKxhUd/ bqlhnTNi0p6hUqjrxkOtFcYQGYKIDck/XfmnJZ7tFaHQKEMILJ78dS8Bd0lNOfQFb3/4 UcuV6kJXioQV0QaPRMOtjHXv+1srLobbWne82yG6C0cxmy8AGRKw0NVjU+g5tPBMBqJv etCXb5hr5LC3wZyEsm3sa+TpabJdLEAYXo9wlfos16wlN+8p0JhHr/OvArO1Wvsey7tN L4IQ== X-Gm-Message-State: AOAM5316hGjG2SdPNst+/yI37aB0uKMDV+DiRTFt/dssWPF9f6V5hP3p /LmfK5v0wkHGRxCRhs0tB1g= X-Google-Smtp-Source: ABdhPJzqVVumJ3K1t4eLgI7bjrMOMjAALVydzHN2xhAvcY7W0nVSPYKGnq9OxqzOvAQMmVZEUhty7Q== X-Received: by 2002:a17:903:2004:b0:142:6344:2c08 with SMTP id s4-20020a170903200400b0014263442c08mr70192503pla.51.1639084459578; Thu, 09 Dec 2021 13:14:19 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id y4sm617800pfi.178.2021.12.09.13.14.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 13:14:19 -0800 (PST) From: Jim Quinlan To: linux-pci@vger.kernel.org, Bjorn Helgaas , Nicolas Saenz Julienne , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Rob Herring , Saenz Julienne , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v10 2/7] dt-bindings: PCI: Correct brcmstb interrupts, interrupt-map. Date: Thu, 9 Dec 2021 16:14:00 -0500 Message-Id: <20211209211407.8102-3-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211209211407.8102-1-jim2101024@gmail.com> References: <20211209211407.8102-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211209_131420_155147_2B23AE09 X-CRM114-Status: UNSURE ( 9.67 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The "pcie" and "msi" interrupts were given the same interrupt when they are actually different. Interrupt-map only had the INTA entry; the INTB, INTC, and INTD entries are added. Signed-off-by: Jim Quinlan Acked-by: Florian Fainelli Acked-by: Rob Herring --- Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml index 1fe102743f82..22f2ef446f18 100644 --- a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml +++ b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml @@ -143,11 +143,15 @@ examples: #address-cells = <3>; #size-cells = <2>; #interrupt-cells = <1>; - interrupts = , + interrupts = , ; interrupt-names = "pcie", "msi"; interrupt-map-mask = <0x0 0x0 0x0 0x7>; - interrupt-map = <0 0 0 1 &gicv2 GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>; + interrupt-map = <0 0 0 1 &gicv2 GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH + 0 0 0 2 &gicv2 GIC_SPI 144 IRQ_TYPE_LEVEL_HIGH + 0 0 0 3 &gicv2 GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH + 0 0 0 4 &gicv2 GIC_SPI 146 IRQ_TYPE_LEVEL_HIGH>; + msi-parent = <&pcie0>; msi-controller; ranges = <0x02000000 0x0 0xf8000000 0x6 0x00000000 0x0 0x04000000>; From patchwork Thu Dec 9 21:14:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12695527 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 EC3D9C433F5 for ; Thu, 9 Dec 2021 21:16:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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=jKVZWeUZMxnl0YFWK1ESZ1uSg784JTFYIfA2RkfjRgE=; b=gaNrsoON/7Kfl9 d2HvaQaTZSLSnw7YCc7DKPYIpY/htrJ7DdzFnkePb7FwswT2Tr4F75Q0QENh6lG5ZC0A/6kVJYsD5 2KjNeSzKLP7+VljKfOtPur4KPnzYMe/lnnON2jzgiJuH7YKp1O0fS6lW3iIP9/GVzzLSFqCiYrq2n dUID+1JnHZ63QUf98FzE/22Ln4bF71whCv1DjBBzDrmW5aaq1yxYwVf1kmFNyJTr4DU6fQ5sr4o7n +FI4pwsCmUmwtj5IgLcJNzhqJvnzJD0BdOyRmrSfa7ZJEX2D8MkAoiCJkQmU/EIR/QwjcqgfcS93e dgY7ZFd0FXHzw43kbETA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvQke-0000wE-5F; Thu, 09 Dec 2021 21:14:52 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvQkB-0000nq-Jb; Thu, 09 Dec 2021 21:14:25 +0000 Received: by mail-pj1-x102d.google.com with SMTP id n15-20020a17090a160f00b001a75089daa3so7940964pja.1; Thu, 09 Dec 2021 13:14:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=Mlsh7dHVaUbpSBFxq3neiP3SXJ2omeiCvlm9a7TlWWo=; b=o1yRTRvN9rB29RhN8won8BaUYLhbnYpr8VbhAuVi9/95Kwd0RcEP/rhSxaeYmfmhvG 1/Vm+XsKiaV750uwNVCfOmGj+Xvmj9C0Sn2/mcy2QO3pFgobrzAS9e8x8UP1ZID33R2v sIMSWc4I/dy2NjlNzJcJoaRcGvVVwinS4nHgBc2wLd34/5zNV3cfylek+VDgoAW6jall izB+hZbrjq32uKpf/uv1ZP52UE7ViP7CAkOsATvO4F+0Bu2giNjWeczBLKpvB0985pa/ PFVegcYeoLZGOCaBbbocmaY8c6+Bjv4MasdtsxOkT2V+rnv0D6q9HbNqfP2Ig3B3rWQT 4jdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Mlsh7dHVaUbpSBFxq3neiP3SXJ2omeiCvlm9a7TlWWo=; b=JfliSg7moBQVazT7yMR1Q/OkEzxFv1Jn+ktwNns5auaZnrcIprPxyqs2wNomo0OXLD uqh67/Eu/EUNI63rdk32r4kHMgJfp3K1Tanrub4eDWNKjwAKwbWhrvSQqs8iN7j9y9A0 ANERGFFu1+MgNaUIiLMQgg2t+McbA1Y4f7NHlDSLqCemLK83NiciTSPDeMdWbf8BO/zt 6LTP6xBpl84LYsv9vBuk42J0sn8IRaxd7W7MYiRWo78v8e164lR2WOuMADMHbTeo/JRu 4ZNuYxL0YYEt3pq+b2zcEWYE+hG/0aKTYzMMEtmljltlKrK0hVgew3cAJJZCkyYDgVaF 4RZw== X-Gm-Message-State: AOAM531Olc9J6+21LZsjM6xXnB21Vykp6WeKBTA/Ttkeoz7V0YiVgec2 5vW/aOrGdPvtVJuuMVsg0Ro= X-Google-Smtp-Source: ABdhPJypf6f9wIQqndSaToBWmTE6o9AXvHEV34jt2TxjD7g5guqcJrXi806zmz58A40Jd0iXp1yxBw== X-Received: by 2002:a17:90a:4142:: with SMTP id m2mr18927143pjg.80.1639084462546; Thu, 09 Dec 2021 13:14:22 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id y4sm617800pfi.178.2021.12.09.13.14.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 13:14:22 -0800 (PST) From: Jim Quinlan To: linux-pci@vger.kernel.org, Bjorn Helgaas , Nicolas Saenz Julienne , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Rob Herring , Saenz Julienne , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v10 3/7] dt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators Date: Thu, 9 Dec 2021 16:14:01 -0500 Message-Id: <20211209211407.8102-4-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211209211407.8102-1-jim2101024@gmail.com> References: <20211209211407.8102-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211209_131423_675197_CBC65F40 X-CRM114-Status: GOOD ( 10.47 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add bindings for Brcmstb EP voltage regulators. A new mechanism is to be added to the Linux PCI subsystem that will allocate and turn on/off regulators. These are standard regulators -- vpcie12v, vpcie3v3, and vpcie3v3aux -- placed in the DT in the bridge node under the host bridge device. The use of a regulator property in the pcie EP subnode such as "vpcie12v-supply" depends on a pending pullreq to the pci-bus.yaml file at https://github.com/devicetree-org/dt-schema/pull/63 Signed-off-by: Jim Quinlan Reviewed-by: Rob Herring --- .../bindings/pci/brcm,stb-pcie.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml index 22f2ef446f18..3e3c8929c97c 100644 --- a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml +++ b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml @@ -159,5 +159,24 @@ examples: <0x42000000 0x1 0x80000000 0x3 0x00000000 0x0 0x80000000>; brcm,enable-ssc; brcm,scb-sizes = <0x0000000080000000 0x0000000080000000>; + + /* PCIe bridge, Root Port */ + pci@0,0 { + #address-cells = <3>; + #size-cells = <2>; + reg = <0x0 0x0 0x0 0x0 0x0>; + compatible = "pciclass,0604"; + device_type = "pci"; + vpcie3v3-supply = <&vreg7>; + ranges; + + /* PCIe endpoint */ + pci-ep@0,0 { + assigned-addresses = + <0x82010000 0x0 0xf8000000 0x6 0x00000000 0x0 0x2000>; + reg = <0x0 0x0 0x0 0x0 0x0>; + compatible = "pci14e4,1688"; + }; + }; }; }; From patchwork Thu Dec 9 21:14:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12695528 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 ACCCFC433EF for ; Thu, 9 Dec 2021 21:16:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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=nYjmVShYJEfwTSycowTyjNpV9lgIcjK2eTNQhfz2804=; b=OL0NP9Z4HmMLx8 cGXmZ/+lagYZbUKoPQ4rvR23IIdkVNXL8V5VdLAk9bVdqVm9W9G+heKKbqa34tFrP+0QupZbRZlq5 QlzHtZuOnpMGUtN0Pi2qCTR+ec5p9dKOLBbw9s+QGfNbHlJR6Iqk5dsZUq3J0+vgSxSCRLNNima3b Yz0TA45ePDFI4TOELascxIDDwXP7vxiTjiwLq4CyeJdsRhjiwdfORRSzg6jW8ZUp0XH/cWCl6oIPu PbDhZ//VsFaiGfbX2X2vsPVqxqfHBAyD6Bpz/iP6gAEoxIHS6LzPMpS2fLViG+Nqwkq0nGACcfBiA ETogFRzqZ/GAkBwMZWLA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvQkt-00012g-E9; Thu, 09 Dec 2021 21:15:07 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvQkG-0000q5-3q; Thu, 09 Dec 2021 21:14:29 +0000 Received: by mail-pj1-x1035.google.com with SMTP id n15-20020a17090a160f00b001a75089daa3so7941143pja.1; Thu, 09 Dec 2021 13:14:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=+Qzj5uM3WmTTnFaEKj5iKt+4OPXn0Lx6lUn5gyvkQ+E=; b=T7zIYHXGDGLH68yTR9AS+wy5YX4rG81euAcVO+77a6QXucxpOLsryN1xcuLI3aTb7J VRni6YqAAqlt94AIDRc6BrLELzW3yxEC5MqWw+8m86mi4dt70oBkfpuWiYrktw6jrtxD oy5zYUip31rq0vzE/z2zP48wc4SmXc2tjYkZckFEKv3ra/6vz38xIa+xuQzhNc6h/FpV w8f6bwKUsxNZCu394H+EqVZN4n8b0J6AqYvfcEcxv+6+6mW7eHNR95tC3w59HallXnf/ rshjeohThuGuJY7MCO+YzS2+b33IBTuv90tMlr4iz1z5wjoOI/V7LSb30ytSDQYprtiy xJAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=+Qzj5uM3WmTTnFaEKj5iKt+4OPXn0Lx6lUn5gyvkQ+E=; b=kjpB4rqiOkuGaxVdmpqHE3t6vCJeA8eDV/ZmLyiaCc538bWEMGQ6VloaP9ca08Y3Bv mbHkU0n3/hRgdwbcA6dKymGIM36TLeLk5f7JER/+FkVoT3RGHYk3lzlIJNKwCoURpqTf mVSd/SjhGtLR9Fd0d+ic9Hb5DhXI2gXQRXKf1GjpNwObWfoxa5FLeDeQx4j6+QOm1uZt /bFZrYATozwZt2tVsAT5uWcCcZeqrW9TISXKbUzdKjNcuiKa1vqD6p4EYR8TLHuHOXv6 MAHeIkKPBnj6hlzeTe3A05VD5YM+OGLS0MXH8Os+1r9SChtp7BdN47O6qtrqKQHMWAEX 77FQ== X-Gm-Message-State: AOAM530C2R4kk6JYwYDJjT9W0iN0tsQ53U/kr3QqyJfXfq3Il+7jW1t/ 5J4wzCtMSd41DBMYJjydqqG/kmRr6Ns= X-Google-Smtp-Source: ABdhPJxJq3ZihiJupQgXscc7nwgUJE1FJX6qa58J9Fl7YdyGBvG0UmIGNfLmNJOVbp9oG0KDahudVQ== X-Received: by 2002:a17:903:1210:b0:143:a088:7932 with SMTP id l16-20020a170903121000b00143a0887932mr71635830plh.11.1639084467692; Thu, 09 Dec 2021 13:14:27 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id y4sm617800pfi.178.2021.12.09.13.14.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 13:14:27 -0800 (PST) From: Jim Quinlan To: linux-pci@vger.kernel.org, Bjorn Helgaas , Nicolas Saenz Julienne , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v10 5/7] PCI: brcmstb: Split brcm_pcie_setup() into two funcs Date: Thu, 9 Dec 2021 16:14:03 -0500 Message-Id: <20211209211407.8102-6-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211209211407.8102-1-jim2101024@gmail.com> References: <20211209211407.8102-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211209_131428_189283_1E2FBD0B X-CRM114-Status: GOOD ( 20.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We need to take some code in brcm_pcie_setup() and put it in a new function brcm_pcie_linkup(). In future commits the brcm_pcie_linkup() function will be called indirectly by pci_host_probe() as opposed to the host driver invoking it directly. Some code that was executed after the PCIe linkup is now placed so that it executes prior to linkup, since this code has to run prior to the invocation of pci_host_probe(). Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 65 ++++++++++++++++----------- 1 file changed, 39 insertions(+), 26 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 9ed79ddb6a83..5f373227aad6 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -863,16 +863,9 @@ static inline int brcm_pcie_get_rc_bar2_size_and_offset(struct brcm_pcie *pcie, static int brcm_pcie_setup(struct brcm_pcie *pcie) { - struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); u64 rc_bar2_offset, rc_bar2_size; void __iomem *base = pcie->base; - struct device *dev = pcie->dev; - struct resource_entry *entry; - bool ssc_good = false; - struct resource *res; - int num_out_wins = 0; - u16 nlw, cls, lnksta; - int i, ret, memc; + int ret, memc; u32 tmp, burst, aspm_support; /* Reset the bridge */ @@ -957,6 +950,40 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie) if (pcie->gen) brcm_pcie_set_gen(pcie, pcie->gen); + /* Don't advertise L0s capability if 'aspm-no-l0s' */ + aspm_support = PCIE_LINK_STATE_L1; + if (!of_property_read_bool(pcie->np, "aspm-no-l0s")) + aspm_support |= PCIE_LINK_STATE_L0S; + tmp = readl(base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY); + u32p_replace_bits(&tmp, aspm_support, + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK); + writel(tmp, base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY); + + /* + * For config space accesses on the RC, show the right class for + * a PCIe-PCIe bridge (the default setting is to be EP mode). + */ + tmp = readl(base + PCIE_RC_CFG_PRIV1_ID_VAL3); + u32p_replace_bits(&tmp, 0x060400, + PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK); + writel(tmp, base + PCIE_RC_CFG_PRIV1_ID_VAL3); + + return 0; +} + +static int brcm_pcie_linkup(struct brcm_pcie *pcie) +{ + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); + struct device *dev = pcie->dev; + void __iomem *base = pcie->base; + struct resource_entry *entry; + struct resource *res; + int num_out_wins = 0; + u16 nlw, cls, lnksta; + bool ssc_good = false; + u32 tmp; + int ret, i; + /* Unassert the fundamental reset */ pcie->perst_set(pcie, 0); @@ -994,24 +1021,6 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie) num_out_wins++; } - /* Don't advertise L0s capability if 'aspm-no-l0s' */ - aspm_support = PCIE_LINK_STATE_L1; - if (!of_property_read_bool(pcie->np, "aspm-no-l0s")) - aspm_support |= PCIE_LINK_STATE_L0S; - tmp = readl(base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY); - u32p_replace_bits(&tmp, aspm_support, - PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK); - writel(tmp, base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY); - - /* - * For config space accesses on the RC, show the right class for - * a PCIe-PCIe bridge (the default setting is to be EP mode). - */ - tmp = readl(base + PCIE_RC_CFG_PRIV1_ID_VAL3); - u32p_replace_bits(&tmp, 0x060400, - PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK); - writel(tmp, base + PCIE_RC_CFG_PRIV1_ID_VAL3); - if (pcie->ssc) { ret = brcm_pcie_set_ssc(pcie); if (ret == 0) @@ -1200,6 +1209,10 @@ static int brcm_pcie_resume(struct device *dev) if (ret) goto err_reset; + ret = brcm_pcie_linkup(pcie); + if (ret) + goto err_reset; + if (pcie->msi) brcm_msi_set_regs(pcie->msi); From patchwork Thu Dec 9 21:14:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12695529 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 C3215C433EF for ; Thu, 9 Dec 2021 21:16:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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=O5FuPBLwtHtJFi2vvo/aW5ySDvwdvA9YTySLnOO8zXI=; b=XvZFnkkpeiK9NZ k30M538MBYzFV6nD7eImvP0l5fQT9FcdUTI4QhWPmZd1ZzlH/brMu+uX5bqKQ19dN6NI5JOEnvVDg EOry2kSFmECm2asqTvJaWddthYQyQHGGS+NiGuTfnzXPQnPmnt8lzM7Vmg6ibll0QQEV7Gz5TCWJp xlXjeLbV2JXqjfo+9ZDBcvdNBLh+tl9o+osMu92EngbAcRuovFvFEHigSptGovnAC3ajbU6lgxiTF YvgIyNTpIHtOvfwVUc2hVOtY6aCF5WmkAvDIvLadqrUy21gPb/2bILE4bKw/9aN7HoVMXhINbqGfU CWP0AriCOa5J5iu+Yeug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvQlA-0001BU-0a; Thu, 09 Dec 2021 21:15:24 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvQkJ-0000rL-3i; Thu, 09 Dec 2021 21:14:32 +0000 Received: by mail-pf1-x435.google.com with SMTP id i12so6563200pfd.6; Thu, 09 Dec 2021 13:14:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=dZMcHb3UiJ34ZchDQTmKgC2WeBRqnz1j82a2xIWNX7w=; b=lqGiEDu0rd3SGWitzAV7M5LlgIsh4Iro4EedGhj6mWVuOyODsFkxmc7bYwssiLDJXm XLBYQeedc7rcejAVsSvzU8yMAS3wwqheWxSCM+X67xWxV6bRNHT7a9fWYOJqfq5n4YA1 LonbvZV4PJMXcDbV2G6eacIrO6DTULqyFBMmoC+jxJm6MdRQt3jtvfyziIh8o99LQs92 NFRMEG8J/4pcSlErkvVU+I5b3KxoBkaMqRHijbGyN0YmqLC4ncAmiO6/HrNel0XEXyFX GgE/SmiHF2QvAT4RKfL7DJYFEjw0u5tSeXMMIMkXDbvCOZMtBYpOFJkDd15FWjXjF6C/ pK7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=dZMcHb3UiJ34ZchDQTmKgC2WeBRqnz1j82a2xIWNX7w=; b=kw+Vku4W0vsvJEtf9ovk03D1mr+jiANgh8cACD0nPj1y4Ydt5U4tElzQc9kyZNDM/L hpRgrxvZ+bEM8c/zdv1xgm/I0iB43Jq/hF+S/e0TETBYSNiTfHmlTo6Nfa2lkCCxb7s2 ECQ0yrFMeYe8/VrcBZIpOT+Zed+ViVPwi8wjOxXt3GX/WKPhj4ftxJyWfIjWkdgVK6Sr TSXyrdsZD+sVc9SkOtSxSZ/jGY2zHqeg8NpUT8eWubT9Q1f44su8j7k+O6T++5LcL2Yb IciFMx3LU1rU89g5fCF9GHfrXYNbsD2tfmCVX9wo52E51JjVZOb+RSe1eF1B5TLrj0JM CSDA== X-Gm-Message-State: AOAM533GVDdXX8ryJ3NsgUIqvgokVS1/shj5GSM+VIs8mUrS5CpwY2Lf aP7ooJ+/4P7UTgG/GrEjyZY= X-Google-Smtp-Source: ABdhPJzK49wvtB15D40vynDAko/WEB/IXGw5aiV4OaJ70GaDdaA7ZD5HgL7CDUPzO2q3QElPtBkCrA== X-Received: by 2002:a62:33c6:0:b0:4a0:3a81:3489 with SMTP id z189-20020a6233c6000000b004a03a813489mr13984302pfz.59.1639084470512; Thu, 09 Dec 2021 13:14:30 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id y4sm617800pfi.178.2021.12.09.13.14.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 13:14:30 -0800 (PST) From: Jim Quinlan To: linux-pci@vger.kernel.org, Bjorn Helgaas , Nicolas Saenz Julienne , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Philipp Zabel , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v10 6/7] PCI: brcmstb: Add control of subdevice voltage regulators Date: Thu, 9 Dec 2021 16:14:04 -0500 Message-Id: <20211209211407.8102-7-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211209211407.8102-1-jim2101024@gmail.com> References: <20211209211407.8102-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211209_131431_193475_C6D9D644 X-CRM114-Status: GOOD ( 27.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This Broadcom STB PCIe RC driver has one port and connects directly to one device, be it a switch or an endpoint. We want to be able to leverage the recently added mechansim that allocates and turns on/off subdevice regulators. All that needs to be done is to put the regulator DT nodes in the bridge below host and to set the pci_ops methods add_bus and remove_bus. Note that the pci_subdev_regulators_add_bus() method is wrapped for two reasons: 1. To acheive linkup after the voltage regulators are turned on. 2. If, in the case of an unsuccessful linkup, to redirect any PCIe accesses to subdevices, e.g. the scan for DEV/ID. This redirection is needed because the Broadcom PCIe HW wil issue a CPU abort if such an access is made when there is no linkup. Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 81 +++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 5f373227aad6..9b4df253e79a 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -191,6 +191,7 @@ static inline void brcm_pcie_bridge_sw_init_set_generic(struct brcm_pcie *pcie, static inline void brcm_pcie_perst_set_4908(struct brcm_pcie *pcie, u32 val); static inline void brcm_pcie_perst_set_7278(struct brcm_pcie *pcie, u32 val); static inline void brcm_pcie_perst_set_generic(struct brcm_pcie *pcie, u32 val); +static int brcm_pcie_add_bus(struct pci_bus *bus); enum { RGR1_SW_INIT_1, @@ -295,6 +296,8 @@ struct brcm_pcie { u32 hw_rev; void (*perst_set)(struct brcm_pcie *pcie, u32 val); void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val); + bool refusal_mode; + struct subdev_regulators *sr; }; /* @@ -711,6 +714,18 @@ static void __iomem *brcm_pcie_map_conf(struct pci_bus *bus, unsigned int devfn, /* Accesses to the RC go right to the RC registers if slot==0 */ if (pci_is_root_bus(bus)) return PCI_SLOT(devfn) ? NULL : base + where; + if (pcie->refusal_mode) { + /* + * At this point we do not have link. There will be a CPU + * abort -- a quirk with this controller --if Linux tries + * to read any config-space registers besides those + * targeting the host bridge. To prevent this we hijack + * the address to point to a safe access that will return + * 0xffffffff. + */ + writel(0xffffffff, base + PCIE_MISC_RC_BAR2_CONFIG_HI); + return base + PCIE_MISC_RC_BAR2_CONFIG_HI + (where & 0x3); + } /* For devices, write to the config space index register */ idx = PCIE_ECAM_OFFSET(bus->number, devfn, 0); @@ -722,6 +737,8 @@ static struct pci_ops brcm_pcie_ops = { .map_bus = brcm_pcie_map_conf, .read = pci_generic_config_read, .write = pci_generic_config_write, + .add_bus = brcm_pcie_add_bus, + .remove_bus = pci_subdev_regulators_remove_bus, }; static inline void brcm_pcie_bridge_sw_init_set_generic(struct brcm_pcie *pcie, u32 val) @@ -1169,6 +1186,14 @@ static int brcm_pcie_suspend(struct device *dev) return ret; } + if (pcie->sr) { + ret = regulator_bulk_disable(pcie->sr->num_supplies, pcie->sr->supplies); + if (ret) { + dev_err(dev, "Could not turn off regulators\n"); + reset_control_reset(pcie->rescal); + return ret; + } + } clk_disable_unprepare(pcie->clk); return 0; @@ -1186,9 +1211,17 @@ static int brcm_pcie_resume(struct device *dev) if (ret) return ret; + if (pcie->sr) { + ret = regulator_bulk_enable(pcie->sr->num_supplies, pcie->sr->supplies); + if (ret) { + dev_err(dev, "Could not turn on regulators\n"); + goto err_disable_clk; + } + } + ret = reset_control_reset(pcie->rescal); if (ret) - goto err_disable_clk; + goto err_regulator; ret = brcm_phy_start(pcie); if (ret) @@ -1220,6 +1253,8 @@ static int brcm_pcie_resume(struct device *dev) err_reset: reset_control_rearm(pcie->rescal); +err_regulator: + regulator_bulk_disable(pcie->sr->num_supplies, pcie->sr->supplies); err_disable_clk: clk_disable_unprepare(pcie->clk); return ret; @@ -1258,6 +1293,34 @@ static const struct of_device_id brcm_pcie_match[] = { {}, }; +static int brcm_pcie_add_bus(struct pci_bus *bus) +{ + struct device *dev = &bus->dev; + struct brcm_pcie *pcie = (struct brcm_pcie *) bus->sysdata; + int ret; + + if (!dev->of_node || !bus->parent || !pci_is_root_bus(bus->parent)) + return 0; + + ret = pci_subdev_regulators_add_bus(bus); + if (ret) + return ret; + + /* Grab the regulators for suspend/resume */ + pcie->sr = bus->dev.driver_data; + + /* + * If we have failed linkup there is no point to return an error as + * currently it will cause a WARNING() from pci_alloc_child_bus(). + * We return 0 and turn on the "refusal_mode" so that any further + * accesses to the pci_dev just get 0xffffffff + */ + if (brcm_pcie_linkup(pcie) != 0) + pcie->refusal_mode = true; + + return 0; +} + static int brcm_pcie_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node, *msi_np; @@ -1349,7 +1412,17 @@ static int brcm_pcie_probe(struct platform_device *pdev) platform_set_drvdata(pdev, pcie); - return pci_host_probe(bridge); + ret = pci_host_probe(bridge); + if (!ret && !brcm_pcie_link_up(pcie)) + ret = -ENODEV; + + if (ret) { + brcm_pcie_remove(pdev); + return ret; + } + + return 0; + fail: __brcm_pcie_remove(pcie); return ret; @@ -1358,8 +1431,8 @@ static int brcm_pcie_probe(struct platform_device *pdev) MODULE_DEVICE_TABLE(of, brcm_pcie_match); static const struct dev_pm_ops brcm_pcie_pm_ops = { - .suspend = brcm_pcie_suspend, - .resume = brcm_pcie_resume, + .suspend_noirq = brcm_pcie_suspend, + .resume_noirq = brcm_pcie_resume, }; static struct platform_driver brcm_pcie_driver = { From patchwork Thu Dec 9 21:14:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12695530 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 6597CC433F5 for ; Thu, 9 Dec 2021 21:17:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id: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=pltub6LTkZRc6CSTGQbkFjiS3ggLUAVwQG0uXM3eiPQ=; b=c5LYrOnnfkddjR c48vCOPZlHe4daBSmpFXdZQtjCx1uNgMkLD6EoBIwws81Nrkq/dHvDXwPkO4OOCRpNAEdnfupnuRu gbpsDFZaD3vz1kUyfUpLaWuhuq+L6COs+mU+GgWHbXI2/t79sQkSgKqgBywfMOI1hi9yRjSIe4BJI ixfLC8JuBvg32Cwu+0zLCqyUK5tiXeF9ucl6VdRRMgAb99dZJ8UXF1w8D4BXnQbRxanfL6LGcrMSL /Usv34t99e0qAMRD3WRrgVZkYGJRFG8dfjx+YbxEgbIxZTvzYcO8efUmMXtSOGBqG81mQfTM7FttI FvHDQzNM6mHwijKk+Zsw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvQlS-0001LI-VT; Thu, 09 Dec 2021 21:15:43 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mvQkM-0000sS-Ob; Thu, 09 Dec 2021 21:14:36 +0000 Received: by mail-pf1-x432.google.com with SMTP id k26so6544456pfp.10; Thu, 09 Dec 2021 13:14:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1ejdtBcGu/O1Cxw2YS57FB14hxKmb2vB0wySR/Hf7zE=; b=P+EaI414dlrKAt2SUJZUawDH5u9Hkall7tbv2f8N1argny6SjHkSNzI5i3O20hxLPw 7vbSf9pIQxNiHm+ecRl1DIH5aWTMOBsg2NTzk+wu4M3M3stfw0p46uX2TS9ZdvP55JGU eaWrj4a4LjdqNQoFgx1JxCYpSzE4CcAtZwKS3T9NMrZkBgvsuzW0npOmunQuOhihBd+S iAJ+rq5D60kg8F8DqUBnaI4GjvhpwOPB3jxaMLLXPO0Z8XIPi0R33v7/bJGNTqA4T42G jGqp1NaoD7LLePmrRchsCmM6yACSj9Zc1tYX8cMoNauLXNIlmiDj/sDT6JOkSwNzcufL KssA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1ejdtBcGu/O1Cxw2YS57FB14hxKmb2vB0wySR/Hf7zE=; b=Sq2cN31p1oixr1cFHi2jBVdiXz72PYmtj9ZhStCOMB2imODXBBs0tjR0gSMJOcL8Uv dw8LErqOfwOJi7/Uvcdbkdbel+bh51lyv2zD6WN8/t7gDn96yaqg7RjypkUsIY9WKVHm ceQS039UqgW0T1/ZKp5n62trK350UvVxbYotM+6XaFqVnICI7AG9dKq9AAa7Q9pU6TcK pcmZXwQc/KnUoA7Nl43uM+Zn0CuG3b7krCihOrUkYxY+jRzEya1E4Bmp0uNDSV6GVzlZ o6RYDjo65x2pcgPCLTtOgGqpArHBNL1/luxOWu4cbvN0nH37eXFD9XqssVUB54g262BQ w9VA== X-Gm-Message-State: AOAM530omR6BDMieKhY/4dDC8qfigrxFtuIH/7buJs+V1CtPwzOeTkxX BRekArRvkA3AI2kgLGrmBr0= X-Google-Smtp-Source: ABdhPJwyhlwJggiRgi7BqXbJk7CM8QL1w7vHCs91o46x2lSJhd/S8prWb7v2FHaHQ4pEeoXNclYBiw== X-Received: by 2002:a05:6a00:244b:b0:4ad:5852:f41d with SMTP id d11-20020a056a00244b00b004ad5852f41dmr14392033pfj.29.1639084473656; Thu, 09 Dec 2021 13:14:33 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id y4sm617800pfi.178.2021.12.09.13.14.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Dec 2021 13:14:32 -0800 (PST) From: Jim Quinlan To: linux-pci@vger.kernel.org, Bjorn Helgaas , Nicolas Saenz Julienne , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Philipp Zabel , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v10 7/7] PCI: brcmstb: Do not turn off WOL regulators on suspend Date: Thu, 9 Dec 2021 16:14:05 -0500 Message-Id: <20211209211407.8102-8-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211209211407.8102-1-jim2101024@gmail.com> References: <20211209211407.8102-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211209_131434_837945_75522880 X-CRM114-Status: GOOD ( 17.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If any downstream device can be awoken do not turn off the regulators as the device will need them on. Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 53 ++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 9 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 9b4df253e79a..8e5cbf6850cd 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -298,6 +298,7 @@ struct brcm_pcie { void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val); bool refusal_mode; struct subdev_regulators *sr; + bool ep_wakeup_capable; }; /* @@ -1166,9 +1167,21 @@ static void brcm_pcie_turn_off(struct brcm_pcie *pcie) pcie->bridge_sw_init_set(pcie, 1); } +static int pci_dev_may_wakeup(struct pci_dev *dev, void *data) +{ + bool *ret = data; + + if (device_may_wakeup(&dev->dev)) { + *ret = true; + dev_info(&dev->dev, "disable cancelled for wake-up device\n"); + } + return (int) *ret; +} + static int brcm_pcie_suspend(struct device *dev) { struct brcm_pcie *pcie = dev_get_drvdata(dev); + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); int ret; brcm_pcie_turn_off(pcie); @@ -1187,11 +1200,22 @@ static int brcm_pcie_suspend(struct device *dev) } if (pcie->sr) { - ret = regulator_bulk_disable(pcie->sr->num_supplies, pcie->sr->supplies); - if (ret) { - dev_err(dev, "Could not turn off regulators\n"); - reset_control_reset(pcie->rescal); - return ret; + /* + * Now turn off the regulators, but if at least one + * downstream device is enabled as a wake-up source, do not + * turn off regulators. + */ + pcie->ep_wakeup_capable = false; + pci_walk_bus(bridge->bus, pci_dev_may_wakeup, + &pcie->ep_wakeup_capable); + if (!pcie->ep_wakeup_capable) { + ret = regulator_bulk_disable(pcie->sr->num_supplies, + pcie->sr->supplies); + if (ret) { + dev_err(dev, "Could not turn off regulators\n"); + reset_control_reset(pcie->rescal); + return ret; + } } } clk_disable_unprepare(pcie->clk); @@ -1212,10 +1236,21 @@ static int brcm_pcie_resume(struct device *dev) return ret; if (pcie->sr) { - ret = regulator_bulk_enable(pcie->sr->num_supplies, pcie->sr->supplies); - if (ret) { - dev_err(dev, "Could not turn on regulators\n"); - goto err_disable_clk; + if (pcie->ep_wakeup_capable) { + /* + * We are resuming from a suspend. In the suspend we + * did not disable the power supplies, so there is + * no need to enable them (and falsely increase their + * usage count). + */ + pcie->ep_wakeup_capable = false; + } else { + ret = regulator_bulk_enable(pcie->sr->num_supplies, + pcie->sr->supplies); + if (ret) { + dev_err(dev, "Could not turn on regulators\n"); + goto err_disable_clk; + } } }