From patchwork Thu Jan 6 16:03:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12705519 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 2AAC8C433F5 for ; Thu, 6 Jan 2022 16:05:24 +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=/jcKETsCZf9mllWZX+tctA+aage2GXKt6zJo21GyFdE=; b=2C1Hy4nKTTQ9ln EjTbHJTR00X2aAtlAET3+qYQxfFx5je0D2qPVKsLmJ+733aEnzZgAxhe+/8/wuupWT3rEFzd6yCy3 ysKnLOq7eSNJw2DtlCWXxzZ+fS3i1dECUMdgwD93ClGwgLc3mUlf4WvsTUsfi+puYwxouR7a04DeJ VXy1jChkvVCd+c+WBIU/cIZW+Zg3yj914Yyd4YuosyOCxiGVjG+6ncmPoPKdzT+tZQ8B++c7w5O4d F4F3dM631nTb5p0CkkoGTfdgc1eJSymSYGwX5JiTuXUkLOKa2tg1NwsNgwxDihRnLFS3TkxDF3AyT iRL+ITz1uFqLFcn/wk/w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5VF3-000X71-PT; Thu, 06 Jan 2022 16:03:53 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5VEs-000X2B-Tz; Thu, 06 Jan 2022 16:03:44 +0000 Received: by mail-pj1-x1030.google.com with SMTP id l16-20020a17090a409000b001b2e9628c9cso3644125pjg.4; Thu, 06 Jan 2022 08:03:42 -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=ny451XICFZwmv/3fN6tVd1MtvFhizeu82dbPq5GZyWM=; b=B/bJAL+9WSowS7PoK06mmDrVzgt02eyDNMsOWEOFLOz29VKdblVemN9wxL2Ccjd95k EAIK7FXwe8LOSzGZwiPhVH+P4sFunR8RsBApeS62FyHromHaN5VBGkMdkGuks/1RbBWB md2Z0Q/otAyw2fW31yMaY4NE5wkXrgPE7cLxV9PmbhumzUzbhz5sOlJKIz3G+93dr0g7 1xWVLRyy8kCXpTCrueZEUpklpuzpEIjVXARZ5rUNbhT14JVnann1dvfVOcNqyFHI8FpP uFFfRSgE89MaJ018xedf63DocBR1C+/enZpDOa09Y5jKPChPe/wzRkUeinHhUGYZuRCq d/5w== 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=ny451XICFZwmv/3fN6tVd1MtvFhizeu82dbPq5GZyWM=; b=stxzCU9IeKdzr1NPcaRcYnguXWYnS2xvomLIUfl87brolxO473xTMPaNXjXsK4gpZz HVSoAmdHUt1xGTbpvtUuqoFZh6rJzF5eoaH8VR34wVMOEGzTXFoH+aQD5T+3B6DPFK9f R2Y1U7kcydmzKP45031JpOAEHT+GcMi55Q//4c2raWeXwCCcEPdQeOeISkANeFH9GoYM p9vPX4OKVVOiBA2qHnxk6WZRMmN/TSY9Eeb8YxljhLWyZb0ARmpIYbnqSWeBqBT4fhwB +rHJVTXIDxsTXZbZ4Q1yCqyEmd4eOQ7mMR0AoUWuNme6SEdG5NFJPx7PopkpgAaLM5pk ahng== X-Gm-Message-State: AOAM532EoYZuwd71jwefleQN8AoKDHKDmdDlLsJqlxh1AOJGbpHumciP AcuFDkx0uoo4pkOw0SvpH8w= X-Google-Smtp-Source: ABdhPJwVNSM8XJAXkqDKNJQgq2zUYGKTki3fMD3qLUZ5nTowM5+y0ryglm3I1q3luY/LPCHnXG++bg== X-Received: by 2002:a17:903:244f:b0:149:873:e17c with SMTP id l15-20020a170903244f00b001490873e17cmr58362526pls.133.1641485021987; Thu, 06 Jan 2022 08:03:41 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id q19sm2376316pgb.77.2022.01.06.08.03.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 08:03:40 -0800 (PST) From: Jim Quinlan To: linux-pci@vger.kernel.org, Bjorn Helgaas , Nicolas Saenz Julienne , Lorenzo Pieralisi , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , =?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 v11 1/7] PCI: brcmstb: Fix function return value handling Date: Thu, 6 Jan 2022 11:03:24 -0500 Message-Id: <20220106160332.2143-2-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220106160332.2143-1-jim2101024@gmail.com> References: <20220106160332.2143-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_080343_007245_A803AFC9 X-CRM114-Status: GOOD ( 15.24 ) 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 Jan 6 16:03:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12705520 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 AD68CC433F5 for ; Thu, 6 Jan 2022 16:05: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=xvAyUXtrwxZsv6 1GfTrIXyqgv74GkqJD+CKvxsWa25bzzPGbn9sKZgHGRSvIXaI1wc/yznLZjRIxV8KQxPw0L+oESzR u4lbaoQ8oyOEHXz4bs1S2pJHqZMWEmlG5sQb5+/51DOyYNFiFFG3Gr9b27U3lp9j9XHt+/xOifW9e e+wADrpglcywzESsc7/te6ED/qTFqWqzOZsyq/GRkP51HrLeIaWMDdEFAtFES5EAldnd6v1L6jAgz PnLk0urbKR/BSBTvQtCMVrh2v4KulUMcxr04FE0Zsu4WZ4IVE41HrHJM4RMzWQvlrBjRO2YcJfj8u U503cnaOQvYXufFh7uIg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5VFE-000XCQ-IY; Thu, 06 Jan 2022 16:04:04 +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 1n5VEv-000X35-NH; Thu, 06 Jan 2022 16:03:47 +0000 Received: by mail-pf1-x432.google.com with SMTP id p37so2908571pfh.4; Thu, 06 Jan 2022 08:03:45 -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=pZSDNXVBUjpW4Vz+1npVATF5jK5aLGSV9iNcNWEoaO2Vpseob1m0TSu0aY4lU65zQd TWg2RMqFpeeIZ+YanrmFW/7Pc0N5uKfPWp7CNOfvXRIHnaijGuxUY5uE2LGJpeLqdllj zg1URwv+fmxcMuimypwigGNGBYI+bxVr58RJYs2BKW66X6KsrQn7jr2ikFTwDWFHq5wP lJY9e03IE0F1YhrJJ1C6MMRvuvpwNn5i8WYFASOCwZO4cBk0edJ4bCIE8AqzrJptMkpR qQyNrMmEgUPwlsGAxsNdiUeLLaI6DsLcvOmCWEnuLbqmAf9YAGx2U+p7fnu1yQMKRU3C ieiQ== 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=n+M34q/56tmBjBQMD5KS8U2IvIjaDFu+GvLI4vaGu7NVxpyuGKB7MB/3jt+9Ah4TVK au0FDX6Ldaw8GUz6uPvFm+/pa0kBKpdBN2WISbQe9HAvnFq5is02W80Zgjag7RVU3Ynu kTfhulwO6tG7odYYva9lT2ECqfqJawAdjRILTHt+nBeDVPgEP1A2bQGaMTQX2oAAlq3p Uk34ciPZ/lRgHnz3Kjat+PkPxbESaUuAqoNgfhN50dtP9iydvVkmjgoV3RKFpJnW5usj ezlcvaGqSDjsdCmNOIHV90gW0L3qgedEuxGx+cjDYx6S1FiZVaaq0kZ/661jOA0MvD+q xcoQ== X-Gm-Message-State: AOAM530TuplHtU4QAlzpZRvdnx8hdvxu1YsMTSgJ/gEnQr8tGPJEzot6 MRIaKEi62NVCXGJoFb2Onqc= X-Google-Smtp-Source: ABdhPJxMMul3ldncZfyDJ69TT+quVA6wkcOPZWP4sRDEUwiRE92/drHcvZyHGvZQuGQV+BIUK0wOVg== X-Received: by 2002:a63:7408:: with SMTP id p8mr48886911pgc.73.1641485025029; Thu, 06 Jan 2022 08:03:45 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id q19sm2376316pgb.77.2022.01.06.08.03.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 08:03:44 -0800 (PST) From: Jim Quinlan To: linux-pci@vger.kernel.org, Bjorn Helgaas , Nicolas Saenz Julienne , Lorenzo Pieralisi , 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 v11 2/7] dt-bindings: PCI: Correct brcmstb interrupts, interrupt-map. Date: Thu, 6 Jan 2022 11:03:25 -0500 Message-Id: <20220106160332.2143-3-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220106160332.2143-1-jim2101024@gmail.com> References: <20220106160332.2143-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_080345_789699_F8D84A29 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 Jan 6 16:03:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12705521 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 AE01BC433EF for ; Thu, 6 Jan 2022 16:05:39 +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=g88uugqh8zdJ252lfXvkmrbI7AocoI6hAulitSabzaU=; b=gcTE+IA1HXbm9T Azugb9CGxbJcHp55hCrM99XQO+PzY1Wd35GP6IgXiWJs59sr0e6aNxPNN1ryD/qypmM0cIZkh5B3H ruaXwkJRnhmDjQB1D1KNp1/DjQ8ZTHRk/UfO8KR+ABuBSlQy8OAe/TNNlhr0QERXU5NwRXErZ5R5a OG13+wgiU7YoKCjVRoGQdLSehRDE7UjSk1y+8VJ+aAsyRzVZGdhEFI9TOz2geI6KH33aSXq7RlxTz ZpyFJAFn6YVC9QhdrrPGaLSBkvrAMvmOvuLbJalxseLNpGgRGMCkRFwFr4J4v5aT0Few+6q0CH9o1 pUNEGeoTiAC6XXHipD7Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5VFO-000XFD-KO; Thu, 06 Jan 2022 16:04:14 +0000 Received: from mail-pg1-x52c.google.com ([2607:f8b0:4864:20::52c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5VEy-000X4i-Nw; Thu, 06 Jan 2022 16:03:50 +0000 Received: by mail-pg1-x52c.google.com with SMTP id s1so2953598pga.5; Thu, 06 Jan 2022 08:03:48 -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=5dT86tBwDZRV1+HRjJU72lkLB4v9H+Y+3vey7BiyYNs=; b=B+2zGrku2UL9VY7W1qquw6ncR2iOIot+MYbsfHolNha1kVqUqYAPqhEEpjPk5DwZBn 8tlwoLz62gx+FUSa70lES5zuysTF0m9eSxIlni/uZT3cjsV0I2AO9p2nuJrii0r1hMJQ Tb2nrvXp+Di5HGF+xZ8RdJddUChNTM9JwZh6xVL+ZBmILt6KpIQZb+2El3WVAkIkIybZ 0W/AKeDq3qJpEYA+Ost5t+ktA+e9bMYd/cVtwP20jYALP9Un1bVIpE5o+yRZGxBaUb3H uo+/TOQsUsOkXtWMi33RNPsrJvutGNs25L0OgmrPNzp9322KRheF8N7Ct83siFvZ4Uof D97g== 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=5dT86tBwDZRV1+HRjJU72lkLB4v9H+Y+3vey7BiyYNs=; b=t/On5nPOHumgVD75rpCM5QmiVEKS/wAyvGeT+0Dp2omL72J9n/Gj9p/ui6L+C/A7qk sTubRW64T2pMDqGyn0WejUcg+mR33BNkzDgGnGe0bsXjtBW31SUevvNdWlI/c6YGJkKT j19JPrCp955tVHTGUKSpSRaQ0zoNJoI9QmxN9ouEuM7rCs4Ppqq9FU1myxXXoSgGmt6c c+KYLBsOsgBqjGg4qPKaO5IqoSM04hSN2PgdvX5M+P23h4T9MNNLsSMBpQEurl4axJZp nNRqbLzwEjq3zZtnc3tgwhE/8OpzxFDjuaPkMxoj5vwi7Mn2TPVc+emq62k6ATL49DEA EHmg== X-Gm-Message-State: AOAM533mmG1JJcmVWiA5mHcUXC0UfQUbhDtVBuSQhco0fdiY6DecqHZP kwKpw0Wc7pp6gBHoNe0eFC0= X-Google-Smtp-Source: ABdhPJwkGG8nmAsmSlVxaYf4GZ7GnRNaoH6USwzTvf3wkGhONj9co+WIgJ8Uwa3ot4UKiNlylFhVAw== X-Received: by 2002:a63:1ca:: with SMTP id 193mr18612679pgb.497.1641485028037; Thu, 06 Jan 2022 08:03:48 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id q19sm2376316pgb.77.2022.01.06.08.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 08:03:47 -0800 (PST) From: Jim Quinlan To: linux-pci@vger.kernel.org, Bjorn Helgaas , Nicolas Saenz Julienne , Lorenzo Pieralisi , 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 v11 3/7] dt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators Date: Thu, 6 Jan 2022 11:03:26 -0500 Message-Id: <20220106160332.2143-4-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220106160332.2143-1-jim2101024@gmail.com> References: <20220106160332.2143-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_080348_805357_BF8CA532 X-CRM114-Status: GOOD ( 10.57 ) 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 Reviewed-by: Rob Herring Signed-off-by: Jim Quinlan Acked-by: Florian Fainelli --- .../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 Jan 6 16:03:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12705522 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 0BAF9C433EF for ; Thu, 6 Jan 2022 16:05:46 +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=Yuory5JmbIojkU EZSPhu2Mh/PRbhl2JVamN5yme4wwMOWViMDCXKzDIwpKPIYjYj4NyEipudTQQI/VctGHMaxTKgoI4 /tX3uM2oL5SJ8avmf2y0jEbtaXk8gSEGmKe+SReBgFkWTvozoWl+3NL6GmaQvRd9YFgimqoZAOfCh RsOjCQaRKfSS1JMDEel9FePdFbA9v7FZKHvAAsGrVIjWL8nRDzMNYoHUZ6ZYeWY4eL/JJ3726MC3Q lSy1W4M1NkiIZpslizcUTnBhH1o0Xw+iObUfhe25+jotXcAp0fFcL/VELPfEf+FyMIIOAbCypbsB0 Ghow2UjX8A/jvnuStgog==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5VFb-000XJB-9D; Thu, 06 Jan 2022 16:04:27 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5VF1-000X5h-9W; Thu, 06 Jan 2022 16:03:52 +0000 Received: by mail-pj1-x1030.google.com with SMTP id r14-20020a17090b050e00b001b3548a4250so729393pjz.2; Thu, 06 Jan 2022 08:03:51 -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=N8wK/hRD1u3eb7TVeN1Csp7IwhqFqj1t094kbL8ce5G6wEGT0Z1UIU9MmlAXUeAWSr EJVePebjd59M1AuR5yDw0qiN7/1ulwW0x8ZVAQ+Eqg/ZEXuQ4H0y1IOrpB8UrkczOeLB whhNeCgXVZFQAj+NTCBLp+pr1RWF4KAEYWvbFUYR5uhp6+WdCKqrHScBr6ckxwZFUJKj lrEGsOP/wRJtiuEfCgPfbv+eEB3MubeNYGLOVt3OqXWG/j3bS6A2OdtNvj2YbgDGTujX Gi2Hjy8BU7z7tV/nqNNrQ4VaSxYxRMfVF1GbpIrYCoNKanjWb4mfkv928NoA9Ud/7i5r Q9Zw== 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=U2bwWkaAEdpC5/J9Pg4rxfc1SHONRyBfyW4GkHP+WzZu+C/78wzFB5HNZsUJ3jl5XZ 4KMuv8YZluKlvhM4arazDEBRTIsV5yExBTq3XiLTXd6Amv68RaZ5J7QOgsd4jTSNp8Kv tUFGsimPMdQYG8P/zMeSDC2KBUT1Uh6BE56qqV33Gvg8tOt/xfkTTbhJArAVAOnkJ8Bi vdg4Xjjrzd8Yg+Y+2mX1O37xR/KM18d9T5RhCnuK2KpaO/8NzzzXz3yEhUn9KuDAIv7R RR9XPDB8KssEXVNvbQPGboCvWeQyiXYG7c8F9T2wsk+GXL3CAHaglTz0OSDOn48knx/E Y8gQ== X-Gm-Message-State: AOAM530Y4F5fZwnrIhsqg2/AXRaMhuA6iUmoh2pIBmtMTT0/cygfxlg8 wvCj3MsJHs6ctrVJjN/rl7w= X-Google-Smtp-Source: ABdhPJynVfa2BqUF7oYxZ+qXdflkl/Xq5ZuShssXE3LWpM9zD23C7Y01xPxtPsdcem3u6V/yU6XTLg== X-Received: by 2002:a17:902:7009:b0:149:e7b4:ba32 with SMTP id y9-20020a170902700900b00149e7b4ba32mr5514766plk.151.1641485030857; Thu, 06 Jan 2022 08:03:50 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id q19sm2376316pgb.77.2022.01.06.08.03.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 08:03:50 -0800 (PST) From: Jim Quinlan To: linux-pci@vger.kernel.org, Bjorn Helgaas , Nicolas Saenz Julienne , Lorenzo Pieralisi , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , =?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 v11 4/7] PCI: brcmstb: Split brcm_pcie_setup() into two funcs Date: Thu, 6 Jan 2022 11:03:27 -0500 Message-Id: <20220106160332.2143-5-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220106160332.2143-1-jim2101024@gmail.com> References: <20220106160332.2143-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_080351_367167_127AD6A5 X-CRM114-Status: GOOD ( 20.33 ) 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 Jan 6 16:03:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12705523 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 9A38BC433F5 for ; Thu, 6 Jan 2022 16:06:11 +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=9vntcFuEc2eJLQpJkoJARqpQxxAxXck+zerTVvaVlZI=; b=1eN97mF2wEUmCC Z9eZYB86z71LXd1s38Soa/5VTFnfDOECsFhxelDQ4T6gl58clsPg2klgFsNHZUgXhBCIJS4f0YIcV PpF17GO2nPf+m/9iIaDlGmTN89bEKTwgtEuxsl++YTRPPFPIr5jKC+GLjUO36yI1BBwk8jmefM0ck vIG3NBZ+1gXNEFoEaFaxLbO7GDW0zmQLjBS7O36UUELij3AxC5nYWouCnkfrxVBpQet2Ib5oV8KF9 gnaUh2QDrHUElsMBOkPtC3vogp46c4uUmbOM4yl7n8HVGrxPEYBRijRGHbc3DZiuFY2g4grUVoLxh anwgU/fSaLyTNBemOG5g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5VFr-000XR0-4k; Thu, 06 Jan 2022 16:04:43 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5VF4-000X7L-EH; Thu, 06 Jan 2022 16:03:56 +0000 Received: by mail-pj1-x1031.google.com with SMTP id c14-20020a17090a674e00b001b31e16749cso7597102pjm.4; Thu, 06 Jan 2022 08:03:54 -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=1Pufw6nuD1iiGPOOR6CrXzd6obJQKvUivxb5DzcAVo8=; b=WJkCr0NI+weYPB03yxMI8QdWRUE5FQ4an4olw9yYV01JF11DaiV+EP4Hs9Lpk7HJwV UTPTlRGiepdGbXWEc7P6T8nzuN+tkdvcf3WCxmwfhOQ2J8wXaYa/Ejnn4mcMs92cb5Da 61YgUfXdUakdwO3gpsncQ+OFHXdFD2TdclZn3MM6i0HoEYptRuqxdqCy0bkUF/OPc1Yz yDRqGuMeM9OxNAet/KG1SJt0YJeHH70YZgbeh1CY5bK8kHfmTkD/lvvmzA24lVcpKIKA iYPLLfV17hk4pYjmdK69Bi4/sk8P/gG1Y8OvpFRuHzzTgaDH6ydrkX4Th3Q17MYj3Xzy 9U5A== 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=1Pufw6nuD1iiGPOOR6CrXzd6obJQKvUivxb5DzcAVo8=; b=YcfBvQgj8Luop0r12CnbVmT95Rvnqik8vneXuAGkFL61kDGCM9fFVIVU4vD38rSu7p rWofbJEBxQV6WePvjBizLa3vNO6QZucEAOH2xLip3DHKoYP23DQV3nAxpti5rD2U+851 mX2itzN5Zo8EcSUW+vDhpKKoBkItcg5UMP2j8cooMsSWZ8p/zl0x8ZpYDUBNk6T44mrL 4BQ2cULA4ZeFWG4bhYLtdLOwStWK+6M7cJDkE90EAi6lO4VAcCUKb12P/NE3U+fFilN4 rZY66R4ML2LYNsJY8kxNtsmiue2fUvF9Srv9EZ9klfzan2Aa4eWYNC+1pn4GqhRObqA8 ZE+w== X-Gm-Message-State: AOAM531P2Uonhgdi/kPpAuiw6FQNKXGLlZaBI/ofS+f3ZR9GLUGlI/AX WrNm1VbWku+5fzV3p1qICk0= X-Google-Smtp-Source: ABdhPJxItDbWZOLh45lBkX134F/h811hcKjhUGFwo7SSgb97M6YZESoQt9a3SsklrwbR0V4dxJtw6g== X-Received: by 2002:a17:90a:1919:: with SMTP id 25mr10847464pjg.181.1641485033651; Thu, 06 Jan 2022 08:03:53 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id q19sm2376316pgb.77.2022.01.06.08.03.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 08:03:53 -0800 (PST) From: Jim Quinlan To: linux-pci@vger.kernel.org, Bjorn Helgaas , Nicolas Saenz Julienne , Lorenzo Pieralisi , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , =?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 v11 5/7] PCI: brcmstb: Add mechanism to turn on subdev regulators Date: Thu, 6 Jan 2022 11:03:28 -0500 Message-Id: <20220106160332.2143-6-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220106160332.2143-1-jim2101024@gmail.com> References: <20220106160332.2143-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_080354_514990_2B3217C7 X-CRM114-Status: GOOD ( 29.24 ) 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 a mechanism to identify standard PCIe regulators in the DT, allocate them, and turn them on before the rest of the bus is scanned during pci_host_probe(). The allocated structure that contains the regulators is stored in the port driver dev.driver_data field. Here is a point-by-point of how and when this mechanism is activated: If: -- PCIe RC driver sets pci_ops {add,remove)_bus to pci_subdev_regulators_{add,remove}_bus during its probe. -- There is a DT node "RB" under the host bridge DT node. -- During the RC driver's pci_host_probe() the add_bus callback is invoked where (bus->parent && pci_is_root_bus(bus->parent) is true Then: -- A struct subdev_regulators structure will be allocated and assigned to bus->dev.driver_data. -- regulator_bulk_{get,enable} will be invoked on &bus->dev and the former will search for and process any vpcie{12v,3v3,3v3aux}-supply properties that reside in node "RB". -- The regulators will be turned off/on for any unbind/bind operations. -- The regulators will be turned off/on for any suspend/resumes, but only if the RC driver handles this on its own. This will appear in a later commit for the pcie-brcmstb.c driver. The unabridged reason for doing this is as follows. We would like the Broadcom STB PCIe root complex driver (and others) to be able to turn off/on regulators[1] that provide power to endpoint[2] devices. Typically, the drivers of these endpoint devices are stock Linux drivers that are not aware that these regulator(s) exist and must be turned on for the driver to be probed. The simple solution of course is to turn these regulators on at boot and keep them on. However, this solution does not satisfy at least three of our usage modes: 1. For example, one customer uses multiple PCIe controllers, but wants the ability to, by script invoking and unbind, turn any or all of them by and their subdevices off to save power, e.g. when in battery mode. 2. Another example is when a watchdog script discovers that an endpoint device is in an unresponsive state and would like to unbind, power toggle, and re-bind just the PCIe endpoint and controller. 3. Of course we also want power turned off during suspend mode. However, some endpoint devices may be able to "wake" during suspend and we need to recognise this case and veto the nominal act of turning off its regulator. Such is the case with Wake-on-LAN and Wake-on-WLAN support where PCIe end-point device needs to be kept powered on in order to receive network packets and wake-up the system. In all of these cases it is advantageous for the PCIe controller to govern the turning off/on the regulators needed by the endpoint device. The first two cases can be done by simply unbinding and binding the PCIe controller, if the controller has control of these regulators. [1] These regulators typically govern the actual power supply to the endpoint chip. Sometimes they may be the official PCIe socket power -- such as 3.3v or aux-3.3v. Sometimes they are truly the regulator(s) that supply power to the EP chip. [2] The 99% configuration of our boards is a single endpoint device attached to the PCIe controller. I use the term endpoint but it could possibly mean a switch as well. Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 76 +++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 5f373227aad6..7d46eccf17ff 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -257,6 +258,14 @@ static const struct pcie_cfg_data bcm2711_cfg = { .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, }; +struct subdev_regulators { + unsigned int num_supplies; + struct regulator_bulk_data supplies[]; +}; + +static int pci_subdev_regulators_add_bus(struct pci_bus *bus); +static void pci_subdev_regulators_remove_bus(struct pci_bus *bus); + struct brcm_msi { struct device *dev; void __iomem *base; @@ -406,6 +415,71 @@ static int brcm_pcie_set_ssc(struct brcm_pcie *pcie) return ssc && pll ? 0 : -EIO; } +static void *alloc_subdev_regulators(struct device *dev) +{ + static const char * const supplies[] = { + "vpcie3v3", + "vpcie3v3aux", + "vpcie12v", + }; + const size_t size = sizeof(struct subdev_regulators) + + sizeof(struct regulator_bulk_data) * ARRAY_SIZE(supplies); + struct subdev_regulators *sr; + int i; + + sr = devm_kzalloc(dev, size, GFP_KERNEL); + if (sr) { + sr->num_supplies = ARRAY_SIZE(supplies); + for (i = 0; i < ARRAY_SIZE(supplies); i++) + sr->supplies[i].supply = supplies[i]; + } + + return sr; +} + +static int pci_subdev_regulators_add_bus(struct pci_bus *bus) +{ + struct device *dev = &bus->dev; + struct subdev_regulators *sr; + int ret; + + if (!dev->of_node || !bus->parent || !pci_is_root_bus(bus->parent)) + return 0; + + if (dev->driver_data) + dev_err(dev, "dev.driver_data unexpectedly non-NULL\n"); + + sr = alloc_subdev_regulators(dev); + if (!sr) + return -ENOMEM; + + dev->driver_data = sr; + ret = regulator_bulk_get(dev, sr->num_supplies, sr->supplies); + if (ret) + return ret; + + ret = regulator_bulk_enable(sr->num_supplies, sr->supplies); + if (ret) { + dev_err(dev, "failed to enable regulators for downstream device\n"); + return ret; + } + + return 0; +} + +static void pci_subdev_regulators_remove_bus(struct pci_bus *bus) +{ + struct device *dev = &bus->dev; + struct subdev_regulators *sr = dev->driver_data; + + if (!sr || !bus->parent || !pci_is_root_bus(bus->parent)) + return; + + if (regulator_bulk_disable(sr->num_supplies, sr->supplies)) + dev_err(dev, "failed to disable regulators for downstream device\n"); + dev->driver_data = NULL; +} + /* Limits operation to a specific generation (1, 2, or 3) */ static void brcm_pcie_set_gen(struct brcm_pcie *pcie, int gen) { @@ -722,6 +796,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 = pci_subdev_regulators_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) From patchwork Thu Jan 6 16:03:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12705524 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 10EF9C433EF for ; Thu, 6 Jan 2022 16:06:28 +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=ofNMwWGty+5C7cgOY9JUfoIxv83dsCo15Ihxh3p1ylk=; b=MZSUBYrRXMgMUY hTJmqg0DyFvfanvFaSZyd6ZENP7dUU5fjO+NFVVN3v4P69oo4/QhFEu/2AEgHllQ4Z0f2L/g/OR8M 8HRr1IVmEmuvQl0ZSLMWEUHV5DBidFQP20/eRUgjv5JnikIUzgnPyp574id7VdnzVpSO59YSkXkL3 FrI732bvM5vTx+4XT60ZiEXuxOWRGedIVGTJ7aRmS40QeYBjlG5bLW/bGgnnlfPe6NEqgiPjrpy8J WGi3yKxZJqFV7awHEp5Izz1e02yrlEGzbz+VIbNInWM3KGew4unhmdxeRjzsY2goAQ7X091IYEtOM 2+JxG8WLjyN1P9UD9vmw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5VG5-000XYm-Vf; Thu, 06 Jan 2022 16:04:58 +0000 Received: from mail-pj1-x1034.google.com ([2607:f8b0:4864:20::1034]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5VF8-000X8m-4R; Thu, 06 Jan 2022 16:03:59 +0000 Received: by mail-pj1-x1034.google.com with SMTP id d10-20020a17090a498a00b001b33bc40d01so1377628pjh.1; Thu, 06 Jan 2022 08:03:57 -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=DuPkQ5sJoarT7nOT3y0NDaQHC98tJ10BZ2FpiUiaoT0=; b=hs141GemNiIYC645rkaWmPGU/cIQynFBAT58jQnntoZID+1wXx4MlJaujLCkEeQCJi olJAdRjvFs0alvLaVcE8FWSglnEZa+lokGG11DJw+6nE4eqwCdZYW+JUqwCAmBajNIZw Rr9CW/O0Uq/BGOYL1ZFwksXuELwLC5vEpMoPn1GaRQkXcspZQsjrnlVxx+XeFYZzeNdk Fbqv6wisS4wK91X8l5XK+zi4Uk99GghGOQ6bB5lD2Tprs9THST8d0c9iZV7LawUrBTP2 yBVuZHzCWex38lqu7k2OrsvGQ0WNusP6ynl/kDA3blT9xCDlYn4kxZ2/WrFV3O3nNc/I kEIw== 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=DuPkQ5sJoarT7nOT3y0NDaQHC98tJ10BZ2FpiUiaoT0=; b=cJN+CfxRZdu0Zgji25wW4g9BROyAT+V2R420SB8SVXEB7eKzuj9IKDqk6IW66exFkR 04udoh03l3ZT+w5NU26XamXBTq47uHwbmfVUGMslTfIcg+2Gc4ECKJj1h9KpseXRbpTC JoD0LGHRLhYAA0IQ/ru2RNsOf8dQweAfa2aseGbFErLvTeW/u0R+RaFjjjGy58rkm3Ib uiVuMHCv2Ef1EfXgikqLOq9C+k764boqirYEJsX9lYuQLGs3+E/oZPKwHCvTNSVYJfNl Nk0W1rapNnLqmKDTYS+XWPuE82XxbPCjF5MhMYeFRLX4d/pa8siTehVuzvJa+wQFq/5w OKuQ== X-Gm-Message-State: AOAM531xhqW97J+dwPmYft35E/QVw0YIPnFNzCktpbjdGZBXSh4XSu+2 5tLK3AhU8COFKeBZpAFTkRk= X-Google-Smtp-Source: ABdhPJzMZupo5IIDS7Tqb1VjLSsvQrC6oumwLxgThY354rxsvCxWbaP9fCl5UoJUIS+WoVqw/nCaGA== X-Received: by 2002:a17:902:b184:b0:149:be5f:c6f3 with SMTP id s4-20020a170902b18400b00149be5fc6f3mr17597855plr.174.1641485036618; Thu, 06 Jan 2022 08:03:56 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id q19sm2376316pgb.77.2022.01.06.08.03.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 08:03:56 -0800 (PST) From: Jim Quinlan To: linux-pci@vger.kernel.org, Bjorn Helgaas , Nicolas Saenz Julienne , Lorenzo Pieralisi , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , =?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 v11 6/7] PCI: brcmstb: Add control of subdevice voltage regulators Date: Thu, 6 Jan 2022 11:03:29 -0500 Message-Id: <20220106160332.2143-7-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220106160332.2143-1-jim2101024@gmail.com> References: <20220106160332.2143-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_080358_213771_EC45836C X-CRM114-Status: GOOD ( 27.86 ) 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 | 82 +++++++++++++++++++++++++-- 1 file changed, 77 insertions(+), 5 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 7d46eccf17ff..3c1b2fefe7e1 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -192,6 +192,8 @@ 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_linkup(struct brcm_pcie *pcie); +static int brcm_pcie_add_bus(struct pci_bus *bus); enum { RGR1_SW_INIT_1, @@ -304,6 +306,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; }; /* @@ -467,6 +471,34 @@ static int pci_subdev_regulators_add_bus(struct pci_bus *bus) return 0; } +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 void pci_subdev_regulators_remove_bus(struct pci_bus *bus) { struct device *dev = &bus->dev; @@ -785,6 +817,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); @@ -796,7 +840,7 @@ 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 = pci_subdev_regulators_add_bus, + .add_bus = brcm_pcie_add_bus, .remove_bus = pci_subdev_regulators_remove_bus, }; @@ -1245,6 +1289,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; @@ -1262,9 +1314,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) @@ -1296,6 +1356,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; @@ -1425,7 +1487,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; @@ -1434,8 +1506,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 Jan 6 16:03:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12705525 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 21B1EC433EF for ; Thu, 6 Jan 2022 16:07:02 +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=nnrh4OVBiAnfNP/D+ywQs75c2PYsX+3rCuLvKYg6He8=; b=Km/uRjicMdEOP7 YiDtA4dUXSNj3Is8+ubrTXpXxVP/v988zs44gW5mc0XcApHZz5ltbbQYvJbEVqXd/SKPjSZcJ5unM hphCSY6MNt7c97Gl04hFBD8WrRcI5Ir1NvyFnQwA3gQo4mVh8rNj6TneoG/ecT089tL1r4IASzNiz ROYr4Q7VVmRaTKXMz2ayK9kpaAV6CyyKjyv/3fLuC8MxP4ROM6VtzGXQUitP0/q0V9HajeL5+8f8t NA0ausvu3lQDDAmUmlwSPbZWlW6Dl/KAdPj24SihgwXK6yKPpA17Ij/NHpdmJhqWv3kOf0rwVR2j6 XYuE3jFUMbQPyuR0WFCw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5VGe-000Xrv-PP; Thu, 06 Jan 2022 16:05:34 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n5VFA-000XA1-8l; Thu, 06 Jan 2022 16:04:01 +0000 Received: by mail-pj1-x102c.google.com with SMTP id 59-20020a17090a09c100b001b34a13745eso1762011pjo.5; Thu, 06 Jan 2022 08:03:59 -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=UHomRXytyYgyL9vtpaE63/zjvL/tbxiA4ouQRYYuZNM=; b=c5EaoEwe0k4Y+kQIV5nbnpVpnij3u8gmP/HYggIXoYlNSEvMPLnJC2YgPb+PeLhYoT 8UadcBboJznJOT1R9M3EfhTqcV6yUGz5bFxz5+EDQOknZ+UdlZCzqnb3rFnotQuUDUAk CBU8emUqfl/XtO5E3i5RMpAaaaKOFS9xMYCsDjzf/Q29aWqp09nbgZXGxoQmGsh8Yh1B pto/5wpZLodO0Ia4hUclXeiSILBIAaUAMUZPet147zwswHA3gAMCGnx5pdIBQ8eqj5Dn P05OgdMsdVUT1C+iseGBwrBYLgP5aNnFgtN7ia+2+bK10VwGX5bhMhT2wxQ1VIeoV2da iLlw== 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=UHomRXytyYgyL9vtpaE63/zjvL/tbxiA4ouQRYYuZNM=; b=3pCcVXGeU4vkYgPhddZzYnuYoqDaAVVaERci5FOh5Xw2+SdzK10f/2uqsFbS+j0UdU ovbK8wClKJrqfwUYzFZFEK+0y/hMFvIGijRkJwRgoCgUB06t2E71w7wgaLH+NnTHEuyq x4nhPhcp8jmuhESqZfM79zzc4+mjzmSkeRPuv+GbOJHa70PZV18J8+tgSeH7cO8KCZKu fHRkJogbF+a7iEBhlTMWo3EW3qoM36vaQtTCCkl1BCE/iqSVCmsOFAai0+v2VhvA6avM lbNdEB8WfL/zAll+ZhmpYO9X1oBRJeXzD9d8WpEg1Oi7OLwzBKFxyfXAdeUyd1kl+pyX +tLQ== X-Gm-Message-State: AOAM530JYdt/peVYvuX0e/SU/IqPUYj/C/9gVGpzGyHl4ESSe66DNbNr UYZdNChcWgcp0/VtcPVEFYhFacYfYbw= X-Google-Smtp-Source: ABdhPJx6++vXFv73cMhMbu7dLZ1FYH3JW6xuu7wKmHwNUI65WS5IwVZh0B82ylv7LxL5ZzRpeFIaHA== X-Received: by 2002:a17:902:c401:b0:149:7451:2200 with SMTP id k1-20020a170902c40100b0014974512200mr51383018plk.14.1641485039575; Thu, 06 Jan 2022 08:03:59 -0800 (PST) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id q19sm2376316pgb.77.2022.01.06.08.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jan 2022 08:03:59 -0800 (PST) From: Jim Quinlan To: linux-pci@vger.kernel.org, Bjorn Helgaas , Nicolas Saenz Julienne , Lorenzo Pieralisi , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , =?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 v11 7/7] PCI: brcmstb: Do not turn off WOL regulators on suspend Date: Thu, 6 Jan 2022 11:03:30 -0500 Message-Id: <20220106160332.2143-8-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220106160332.2143-1-jim2101024@gmail.com> References: <20220106160332.2143-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220106_080400_333842_E6B8D596 X-CRM114-Status: GOOD ( 18.08 ) 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 3c1b2fefe7e1..8a3321314b74 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -308,6 +308,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; }; /* @@ -1269,9 +1270,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); @@ -1290,11 +1303,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); @@ -1315,10 +1339,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; + } } }