From patchwork Fri Nov 19 22:07:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12693154 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 C45BEC433F5 for ; Fri, 19 Nov 2021 22:09:55 +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=Tcc0tXdqap5n36 rQbecRwnyFhX+iW4cXnEYOYBB6iB5qlCAnECq7Qt6yBSpEsRChAjTzhWAFGX9z/Z876xMkEANygjZ IAgzNpcCnYvUzcoCa4oP3SqMo5WpUgiOpYd1wPOyvP055HptvDfqxqAqf/x22U6NQg/wFCBxLx0pv /B1xL3kMrgN54Jk/bHoil6qHh7ve1jQCPrOWIsbw1URQM/9cWC4kQYS1EPO2LUmmADkj930IXAiJp 4s9X1zk4pCv+65IGdjuPaU+19c9fM+hig55XfA1NFlNGq7nPDonWvxvIps0RwQ1fKiczD66mCK/c2 mLof7gd4ZsE4XEs53GJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1moC3U-00Bdyt-Gs; Fri, 19 Nov 2021 22:08:24 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1moC3G-00Bdsb-7X; Fri, 19 Nov 2021 22:08:11 +0000 Received: by mail-pj1-x1033.google.com with SMTP id np3so8894550pjb.4; Fri, 19 Nov 2021 14:08:03 -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=mdTN4XDtNAPQv/72+dhoCFCoxzdfJEdUOuV2E6IjFSHGq7ARXOXM+gVCLtD878WAuV 8eZDGyOkFVOSVG7IYqhgBthLvaYyx4aSunqvokXa4wkp2D3+GlqpQbFbg6x0n+PEiDMK c8xwjWMlUDSQQhbtB76wwk/nEQWLomvM5ckraA06dkwlqDXtkx28Z1YK8hh+IH9EMUao 3zoLQja652aZw8RwZh3EWaA/X3ld6CnyLl6xEGslq3PxWWPVtJrP9KmnwQ4b4/+J6ufo erpvIXtkld22/LCru4axk98shP1D0qxNpTqq+eiFjF55UJ9VmfeTEB8RikE8a/cUWEGI ltdQ== 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=YOuZKKaIfs57jISPZPZw9FbvxkiYdWeeTXvuF8CSSZZANRUST+DgTaWu1wWqNfqfnW 9B6m8JK23K1fcRUhCkgm5Mf3NqTjfa9ZEQ+1pNnJUVfPZruT47LEm6MpkzTc2ZwasB6L MCY6++9bWZCyMW9S8C1xy6SeC915yc8tCPZc/pj0xTRFly0DGmS7gRXbHA34lGQe5vQ6 7tu6w5T8pnaRrdaOAcw3zR1M4k1JwG4VzAnHWCbQvTRO5SfSJTUregMOUulF4Bye8Q0C 0Up7irJOvs0/trp6wjH0jLlNsLwVriw0xcEGpaeaxgtmR2VxrwYt7gqnYctPhtscILfN /FAg== X-Gm-Message-State: AOAM530g0OCqPsCO3zOr+HFJ588qtyALxhYLy/SEOCj/kr+LZI1WfALF 0fGzoBua5Lpkxy4xAJbzsGkFBDKDrBkf/g== X-Google-Smtp-Source: ABdhPJzyF20Xa2xvnCY+FSmR4kmroEp3K2+l/gI1fE9Qa5W3WAlNK5vIJABvOyqRzIDhyXuv1sQvog== X-Received: by 2002:a17:902:7fc5:b0:143:6d84:88eb with SMTP id t5-20020a1709027fc500b001436d8488ebmr81623886plb.61.1637359683454; Fri, 19 Nov 2021 14:08:03 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id t2sm612940pfd.36.2021.11.19.14.08.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 14:08:03 -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 v9 1/7] PCI: brcmstb: Fix function return value handling Date: Fri, 19 Nov 2021 17:07:48 -0500 Message-Id: <20211119220756.18628-2-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211119220756.18628-1-jim2101024@gmail.com> References: <20211119220756.18628-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211119_140810_294381_91371351 X-CRM114-Status: GOOD ( 15.48 ) 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 --- 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 Fri Nov 19 22:07:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12693158 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 D9BF0C433F5 for ; Fri, 19 Nov 2021 22:10:29 +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=OyJ30kEhfzT38H DlxoSfyqgMe7GzXHB5IfSDhsr8k25z7YpGRuiZHpim4ayP8hc3BFO9eNBj7ddNIr4PFyqh08yWTWO TA7YEaiztH1X9eZCClJiDLieRJhHfT/P7gpkVnFWSZ9PxSPINjXgBUjpZFYlbmpLcQYNCggxKXnQB lLnoTNcAB4scqYyjGyTx4280QIKNMxQGZaCzq4OQoHmz7NMWChtwfchUz2aoaO87pfY9uhH+LhSf3 nvyAS3TYDWLGBW2l7agMKB1111tBdJWiACRJZXz4JwnD5lgqFx6v8tmNRen2/QAPUMN/SmRfIdOaU 8KTczNVb0ZZ0xdDAgqHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1moC3r-00Be3l-Fm; Fri, 19 Nov 2021 22:08:47 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1moC3H-00Bdsf-Mo; Fri, 19 Nov 2021 22:08:13 +0000 Received: by mail-pf1-x42f.google.com with SMTP id x5so10525837pfr.0; Fri, 19 Nov 2021 14:08:06 -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=OXp8MSbilwTmttnGLC/21f13Z6KyQ05Rx6hfbNx0hQlrVzvHAr7HYuQM6ERfKt2RlY uO6Qnd1JoKkEpq8OslqJONPW3DNXSM1Jhzp5CgGNEFlwZMCTWCf7FzqSamXk4sIe5Wll FuwAip0wibmXE2EleQyzDusP9eHVwzadCE6bm9LhQs82QkMWyS2NZ9b/ByvjZju8jlzW xwJCb7Dv9hlasCsLYQCUPmW8YiUogs/GWtQ5//F9o/3suayeJsRmJGAro9h+XwV4aePl PfGrtYBjSOaq6h3bDgn4J1HfYJmq6wZBiedugGK++gEOK0siS2e9DBfbE04Kt7SAIzRM wi5w== 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=D3g6au3VboIOahEHeboKbQkrVuGRMv8X0RBx51jUtC3D8F5JEtw1waozeOanyhHF5o zGkQ7mVjgpFJsrp/yYs8uSCL0y0uKciT7FQTSTrz57zUnaP7oJ5Z3K8NyiC+rJ5omxq1 LZUpHIj5ENKFKqUtVzi1eaQykgS0pkmpfSjAz/+k/2JhNwLzZtl3Iz3HcQt9JvMsy5W6 HerGZGC/cfGtj6ddgjD+nmwSOpBKLiAc4CWTYucibaD7TENOA4e/sURBOs7wk+xLPU4N 0GGyOZxCVhEj+pDrGFNPxjogJkCszBVQSQRFbba86s7CYMNrFQwRLCpwuYqttHzRNHUo iQWw== X-Gm-Message-State: AOAM531ygInw9M3fDnK6FGd7E+o+mWC4A0ghtqgwCkUVUY4N1BqGSgZs OahLBrpm0FV+E57FK4AJYP4= X-Google-Smtp-Source: ABdhPJzH681ogPXuizx1FhR1dB0O3FWsPhf1C1SLgnj8C4S4k5xTzla+QD2tHL+WWWqgejCeApdhHg== X-Received: by 2002:a05:6a00:10d1:b0:47b:aa9b:1e7a with SMTP id d17-20020a056a0010d100b0047baa9b1e7amr26141445pfu.57.1637359685874; Fri, 19 Nov 2021 14:08:05 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id t2sm612940pfd.36.2021.11.19.14.08.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 14:08:05 -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-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE), linux-rpi-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 v9 2/7] dt-bindings: PCI: Correct brcmstb interrupts, interrupt-map. Date: Fri, 19 Nov 2021 17:07:49 -0500 Message-Id: <20211119220756.18628-3-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211119220756.18628-1-jim2101024@gmail.com> References: <20211119220756.18628-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211119_140811_910746_FC5413D1 X-CRM114-Status: GOOD ( 10.09 ) 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 Fri Nov 19 22:07:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12693156 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 51684C433F5 for ; Fri, 19 Nov 2021 22:09:59 +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=Jr8AXEJrP8G4r7rB2oL545VF4yVoSwICWdZZwe2jmDA=; b=3BphPXJ2xoWMxr XxfoG3WBofpeLyT8N4Eq1lpVIlvKY2cjo+iQcIMI0eJA57gcdwN1Dun42ppVXaDdyKK/VUJJKzQQ9 yb2hEEgxgHLubiX47nNuxehyMDuf3I0fie+FZJ+281AaKYQEwEhP7xTawoBFHOPPW44a5GHkBWfTB n1/ndZRWz91I0oK06Ac19d6aRLBSPvly95GP9WnUfJNtnpk1cj58Zy2q0APwRktTiVlnp+RnlmJbx oHlOxoU0U0jJCKcSuXV0ByMWA8ncDz5GUzQ94M2Kl5epdpOAlj1g+cPTppGzr7TVSF40GQFMymKIx RD56+e536bxP3jGrrTow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1moC3g-00Be1b-G8; Fri, 19 Nov 2021 22:08:36 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1moC3H-00Bdt7-Id; Fri, 19 Nov 2021 22:08:13 +0000 Received: by mail-pl1-x633.google.com with SMTP id k4so9135502plx.8; Fri, 19 Nov 2021 14:08:09 -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=7FMM33BgaDXx9wEJ77VEFyRdRiWrhK4qqNx3A3Rw4xQ=; b=qouy1VCikNtWXl5c1BkmoZhh8O9nxnXAYAo5ln/jrgF60O/mra9X8rvx2tUVctEWmv PZOounY6UlD3r5oI8cj1Vx0Y3DH/vsiWGQMqAqj6Vntbw8XMoz6O8yZuTuSw7+4NrdCJ K7IiCD1GW1LdhwUKLBLubhhHkYWGiKaXCUWV2H+qoZN3KeLs+4l/9BCsLL4ivzkrTJYb FTeyPzAkBIjj7lJBMfbDUVXM3t4k1vVt2AJpLvG/LuIizF3Rxr7rPr2MUEUQATscAy96 WQ1SysjIFPoGuXf3Z01VNdAzb5Mxw2ckdh4aol+nnlqf99QB3klXw7HPgl3OIKRKyaeJ CaYg== 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=7FMM33BgaDXx9wEJ77VEFyRdRiWrhK4qqNx3A3Rw4xQ=; b=Wf1RsaEPbK2ZtH06prr4KQAUk3xmPcymr46ksFfZpoIpOagZ1BHgCIh7tLqrPKrlR5 jSKM+CTDmZ4E6TI4ravdJRwdjcuKHP0IR7F/Xw9P8/nc8oU8vUTpLXKTsQFumcNbtlmY 5j3D9sIreeJnSBkffR35d1tAGlmB/6jIXyfsQ5rRtIFdfm//pQ+zR9tAnAk1s4FTElCM eASwuMUzvBVFOt/RgSOrQQ8IF/244CJb9doDh4dCX0cH2w+n6Q+lX+9HSm0gqVJ2ENwC kkQfVV4LOEFxg40uHfcetl3uI2r1OLbXf+9KgjORpwQBpF69Lu0DhZZTuBQDVPqJuclX tUSQ== X-Gm-Message-State: AOAM532JwbAr3UPAxpOyOlVllEyFvnFlX6xY/dEs3DcKo47K+6JpPH9N 1ue3UfyIsgq54s0eO6bXq9k= X-Google-Smtp-Source: ABdhPJxFy5pQVWOP/nGjpyJRTiOKzysS5T0HPsFOfuCrJFDcryBFXtNi/7ENHQg15+kOFjv5rHYWtQ== X-Received: by 2002:a17:902:b20a:b0:143:7add:5ab7 with SMTP id t10-20020a170902b20a00b001437add5ab7mr79967248plr.71.1637359688852; Fri, 19 Nov 2021 14:08:08 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id t2sm612940pfd.36.2021.11.19.14.08.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 14:08:07 -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-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM7XXX ARM ARCHITECTURE), linux-rpi-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 v9 3/7] dt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators Date: Fri, 19 Nov 2021 17:07:50 -0500 Message-Id: <20211119220756.18628-4-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211119220756.18628-1-jim2101024@gmail.com> References: <20211119220756.18628-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211119_140811_641617_305F74B0 X-CRM114-Status: GOOD ( 11.27 ) 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 --- .../bindings/pci/brcm,stb-pcie.yaml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml index 22f2ef446f18..7113a7f726e7 100644 --- a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml +++ b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml @@ -159,5 +159,28 @@ examples: <0x42000000 0x1 0x80000000 0x3 0x00000000 0x0 0x80000000>; brcm,enable-ssc; brcm,scb-sizes = <0x0000000080000000 0x0000000080000000>; + + /* PCIe bridge */ + 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"; + #address-cells = <3>; + #size-cells = <2>; + + ranges; + }; + }; }; }; From patchwork Fri Nov 19 22:07:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12693157 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 7D4BEC433EF for ; Fri, 19 Nov 2021 22:10:27 +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=UqklurBIEAQxXk xR3Qz5hAVR6+YUdo5QflJhkEF5s4FsxiMvnDXF/akxHF1Gplg2zhfMxtB06DJnIfj1VEmk6MVKWUt /AEkAMQhENVNZrcTb6T8aTwIh5gVCd6PtKQgmo2LPx+ufPGu9uAwlI4xIC4EdYLKaBfJ6TiYbdfg2 GOsfaNr7Q4ePvQ8+/aUuzmpcxPp1mz4DXfOpSSv6aVxj7bXskldHTMyAPdqG2O0TUvmWkvWFsmFq8 OUP9b0mZThbXqXfeqaOk/uYdZc+Z8qx2yAtExjMBY2q6OcPKkyMfUgrNJ6F/+SpRi1AHO+msj0fQ9 6tzPCgA7npQEf07NFj+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1moC44-00Be7Z-Nl; Fri, 19 Nov 2021 22:09:00 +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 1moC3K-00BdvV-9a; Fri, 19 Nov 2021 22:08:15 +0000 Received: by mail-pl1-x635.google.com with SMTP id o14so9161336plg.5; Fri, 19 Nov 2021 14:08:13 -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=GDBt8g5Niq+zlRLNMjg3+WqhC86C2L43ATn6svv85dl6zQ56CsdkZMY3QzF8+H2qd9 gzdYAA4cvCRwImuoXceQ8k5VAeSwmxJq6eGi3A1a5VHCyxqi5Pn0+8mb2fdBEUjZdkjI TcOOyJgdkW+3y0M5aQeRpp7R2X7ELgxGQw1oUg4zH3ZGPIe6Fvwq7cY2SZyrpLrbIvKv orQyHhL9dGhY0JTDRH5ykJyaNhWwvbOv/LKkyLz+/BqFsMgQfSPUBCiiwl06xa8l+Lo/ 6E7XKDSjqGR1VfMKYRfBbYJH/awezZz7En/AxBRDOFmyvamtmMNuJ7ssCOUgvoiRg/j7 n8lA== 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=HYu+WN26mNzotma7tT6dIDwyYb+M6gCtfEX742og8CDMT807Za1Wm0FuMPZc8Y3WTA waR7JW1oJgkORsWW9gHwUItN6eJwNFJ1xq36YwQfMlLICrPLDqEyR1eDZDbneOMnzbxg YBmklv1Fw0Z0BDVKo9yiyEclwE1LKcEycrvn6fu1vJEAdLvMpuKfX2/I2yI7PK40qOzb 3N3M/xpG79+YZRR6KWX4Yey7rqE3Ifr9ndK8wHbLqbqsuRixcBiixd5u7Vyk+XKX4WmG 8YsQjLRTiEsP4c62C65EGAuEqgyRgwmIw+zOz0Gd0d1uM/j7f1rioZcI2z+9YeCiw8p4 jThQ== X-Gm-Message-State: AOAM53325QE3ZF2EhoL7mrw/n1cym9CRoO269VeGemFcI89jnrOKce6v rOwjhQhCSQA5jII/P8bkbSU= X-Google-Smtp-Source: ABdhPJxn0P0q6CY+GSX7H1+0FReMXcgaPqgEf8Ede+HaJV7J5IkSZmvYUO6EXrjDi+IyreLfEUSDOg== X-Received: by 2002:a17:90b:4a05:: with SMTP id kk5mr3796903pjb.142.1637359693167; Fri, 19 Nov 2021 14:08:13 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id t2sm612940pfd.36.2021.11.19.14.08.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 14:08:12 -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 v9 5/7] PCI: brcmstb: Split brcm_pcie_setup() into two funcs Date: Fri, 19 Nov 2021 17:07:52 -0500 Message-Id: <20211119220756.18628-6-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211119220756.18628-1-jim2101024@gmail.com> References: <20211119220756.18628-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211119_140814_371339_4E700DEF X-CRM114-Status: GOOD ( 20.42 ) 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 Fri Nov 19 22:07:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12693159 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 97CF3C433F5 for ; Fri, 19 Nov 2021 22:10: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: 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=FD6oe3aiIV42nG ePuep/BM59FsBVqjfHb7TRQUdtxoovuqh7OarsQToexkguGwKuBi66YtCAEwbjwZcJ7PrcnqAKlRN KtNVmhMDhieiEKg4MjlF4ppMdX2sIg8Jw4XQ4v6VqmOyPMm1q6MVASuAUShTsPKa9/gCWesYYoLzj Nn+bqvdVJp44NluWUZ9DF6nwd8cpTNltVvFo3y4BwuI71+r30AbNVBrUfozw0WYjGZkJi9mKDzgg3 HoDjUoY4zJGgZJ1ibLa6cLqusBr+t4kOHOEg+JCeuSPhdvfYET/EYtLwI59278Xbr0mssL5eWVnVi lK2fEIr+0L3FWR5TbLFA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1moC4K-00BeE6-6K; Fri, 19 Nov 2021 22:09:16 +0000 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1moC3M-00BdwC-Rn; Fri, 19 Nov 2021 22:08:18 +0000 Received: by mail-pf1-x42a.google.com with SMTP id x131so10450306pfc.12; Fri, 19 Nov 2021 14:08:16 -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=lu51B37sYJkJFff+4OCkUTLnA/V4MDjFmyQPR4U9Pln9/Y3p+vQ2aUKyEYLW8FSDOn 1+bKjMzPzfkb7vguoUrNQE3P/M19UcFi56ZBahJtXHXjw13M07zBwTrv6CuEjsEDj4Gh jqhcEyZm3eCxI1ozZDJgy0My2x/yb51EdzYGGuXxJrKZht4K73UPAyh/7R6Gsh/pwvOD Yo9dBIMF++AVYeY0n2C8szI5VZUehmKThdi1jOyJKqj1iy+VllTBP/+YO+z8fPH0hjb8 U9H7HgAn070B2jiTL2dZF6Sqs9/eUlQPEbFt0tHErfhA71jokMJqU5Dpp+jXa0N/1BAm NxFg== 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=ke+Vo7m/56MYW6pM5vQhKy1dz8GZiAGBfoP6vujs9RbmDiom0OMVxN9506q2t1Tk6e GgbyD10L3dQw5Eahyv1LzFvtj0sn3B7vTNuiZ7x0Ilv56H/AEsGe9Z9BkN504v7vu/uu xAUsFLg7DGoUGL2+mHz4eXEqJX8Nd7sn0nTSbjc4JnAWKeszCI/1i0kuB6jBD4Qzb3CG ritRutfaF1Qz31+PL6kqZAixe9W6oatQ92dFZlppAY3CmYGdVAz6dQuwEDnkeVFOl08t sL5KiXazpjVcsq8W6BPgq+lbjaiT4zylwZeEnxPtSoYCdmZRvFjxpShsnUyocBKn+evs oC7A== X-Gm-Message-State: AOAM531ZgQpOPNBaivOsGHGPmIU9VgzmsnyZGeYkWIAIU/Ta+11hW0Dx wGdhrZ01aECtAiWEwWOllLg= X-Google-Smtp-Source: ABdhPJw6rrHXY3KSG+uA7dNZp1Vf6OmAYrr7871M3nftoCAxz8veEZvShrJI+j5PYP+AEEtWnO2CFA== X-Received: by 2002:a05:6a00:1399:b0:49f:ae7d:cda6 with SMTP id t25-20020a056a00139900b0049fae7dcda6mr25962290pfg.10.1637359695710; Fri, 19 Nov 2021 14:08:15 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id t2sm612940pfd.36.2021.11.19.14.08.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 14:08:15 -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 v9 6/7] PCI: brcmstb: Add control of subdevice voltage regulators Date: Fri, 19 Nov 2021 17:07:53 -0500 Message-Id: <20211119220756.18628-7-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211119220756.18628-1-jim2101024@gmail.com> References: <20211119220756.18628-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211119_140816_938358_853C286A X-CRM114-Status: GOOD ( 27.84 ) 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 Fri Nov 19 22:07:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12693160 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 3D842C433F5 for ; Fri, 19 Nov 2021 22:11: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: 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=AHdYyv2BaueyTu N8A7gIKEDUV/1EXTJiO8mGEf9Ia9aI9rPgKe0pX7yX/QmWcdk19u7h5lBLydjBqGD7N26YltUi39Z 45W6HPpmD9T+bQbafwP02ooxAFbcMNMcbRs+U8gZO1d2ruFOLoITVlQz4v0pxqOKXBl1YxgfhN8YL qzu6JRivJZGZeheusZm6Y77RhLMpjGj0qh6JbXCXLFEJ1Q+lubwjmPyQSduy7VtveZKQz0oVw0rrV QVf2xu9yQJ5xiCsprIRETpJvn72NYFnB+yPD5ugsuSYJyl/OhiRHj/eV+lEp/tj4d3lhdEiJPF7B3 4clZ80d1PKq+aIf/w5KA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1moC4g-00BeOH-H3; Fri, 19 Nov 2021 22:09:38 +0000 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1moC3P-00Bdxp-2U; Fri, 19 Nov 2021 22:08:20 +0000 Received: by mail-pg1-x52d.google.com with SMTP id p17so9766156pgj.2; Fri, 19 Nov 2021 14:08:18 -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=jdKk9h0KGCz7rzKg7MWOpNLiwNJ+xR77xNz2Lxp2dg9w7GUe0LJGBzukoh9vYX6vZX 1D2J6dPOj7CrAIBuw5Iwep3uFzwg8/YkZgqNoW5OOL19QSCkrmdf3qpHqurRgL9OTAe7 xgGk5YkPXlhjKZ83iVhlC37YjNkit/aIb2fCMRvx6cmTHZD8Qi2IRh05HRGQzgWKtuf6 4VG75KaQ4B9pPt71kJsmMqWMeyaPEEg0eqjLIXc6+JQUHFoQF/LR+qEAKWwv0wsml8L/ KMO6G4As02e//7bphr0MS5/ZRo+KJ+IGtSG7RNOJ+1fc8hXDauiIBgRICwZcLWmtPkYU Nsag== 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=7Pb66MQ4fVK6ilfkkEu+BtfEJSuJrrSGww41sltwcdpNeZ8iX3+H4iNkXmHZnN1hOo GNe0AsIU1VfGyIvh09zH+MoU+l4CGE+ZgjEh+Jp71QYBR9wq/BMWZmQAastbPuqTE6Jm jdL0yGW2xw5PVWRa85wgUbCCKwv2Zw65eu1hFwCQooU+0wSn0nFbTqi65IQ68lIdOFaO TjB3fZ5HL+WZcdJiISC9bkA+3CfkBHfFR7wSOnruTaR/cLbGvTCbXnuutSKeshd2mGCS rNi3hqeXU3PfWHTNXr8IsKVn2n3R3LV6vnLHyvMAsvkNRc6boQWLxGUZTFxS9BZNJIOW 7qVQ== X-Gm-Message-State: AOAM530m4Ylu4f/Z/MIqjAYZA8MoVkEHsPlaNd5tW0P9fn3Y7mfWn0Sd oeFSmN12gQ3HWu1YRmCqNtc= X-Google-Smtp-Source: ABdhPJxfHsOlCGlDapHzJKdRp+W1ALfXhzzHf0u5YLalK3nbMWxxpORK+mLoBIIEPwEk6dmSgOWegA== X-Received: by 2002:a63:454:: with SMTP id 81mr19078349pge.24.1637359698006; Fri, 19 Nov 2021 14:08:18 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id t2sm612940pfd.36.2021.11.19.14.08.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Nov 2021 14:08:17 -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 v9 7/7] PCI: brcmstb: Do not turn off WOL regulators on suspend Date: Fri, 19 Nov 2021 17:07:54 -0500 Message-Id: <20211119220756.18628-8-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211119220756.18628-1-jim2101024@gmail.com> References: <20211119220756.18628-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211119_140819_151364_1060A89E X-CRM114-Status: GOOD ( 18.13 ) 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; + } } }