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: 12705527 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50430C433F5 for ; Thu, 6 Jan 2022 16:03:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233888AbiAFQDo (ORCPT ); Thu, 6 Jan 2022 11:03:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240848AbiAFQDn (ORCPT ); Thu, 6 Jan 2022 11:03:43 -0500 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1324C061245; Thu, 6 Jan 2022 08:03:42 -0800 (PST) Received: by mail-pj1-x1034.google.com with SMTP id lr15-20020a17090b4b8f00b001b19671cbebso3667195pjb.1; 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=To9LjY+wPga3p6egTkT36mhBhQVu1YkIudGsZBcS9lESgH07LavIV67LfYF/wBrpD+ /BAEzjJ/4LkqqAsAixax8Z4in6sRRKTaJYgH8thNyCrexp4fAx0ZpiTMOkduWjzJ3v/j 1J7b+GOA350dd42k8ZQXF0cekgLnEkacWDK0QB3hUGjSjvJy5FRppZJ+j7WmoVFWA1Pu LXAIfLK45MNMX8vn0smWBQRBDGymVEz/KTKxJwVKDH0ilWyPwcDvcrNnesnOaK40ys+i zX0GHsxm4dznFxBDhqv7suFDU6x7F+FXp529d/ZbtDLu2wtCmvP8atvhXpZ37YIn3MwM AvNg== X-Gm-Message-State: AOAM532Is5PPr7yRdvcZO2+dm3ibZl8RAqg7SwfNoTDH8c6INu3SOHU2 jjrrsMbcLa66lDPUv8KzruRdD9djCYo= 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> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.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: 12705528 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 16F8AC4332F for ; Thu, 6 Jan 2022 16:03:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240848AbiAFQDq (ORCPT ); Thu, 6 Jan 2022 11:03:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240865AbiAFQDq (ORCPT ); Thu, 6 Jan 2022 11:03:46 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B754CC061201; Thu, 6 Jan 2022 08:03:45 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id s1so2953463pga.5; 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=UP18EoBTBZJWENgAFxhmnE4N59gYeHmUkFW0R815XZ2tgBsfY4KlIjqeYsJCI3uXpE Tgdg3+1YpFMvAadJrgtK3M+Hh4rvUhj+DcKV/NHarg5oqD3fevamwltxTRNmiRduSOKY S7dTTeYeWgC8Yyrxsysh2pQhfvTwDcPmLT7LcSG18g9DNuhGCOatBO+JBSeBI4Bbk2mH v6oBm4dYkJaB3zqhJmYoEFnKW4MECemzTeG3zHjQuoNTe6Z6v6261RVkdEPq3azm3ApU 7FUeIpZMCfOZMdT/IXqPz0bN+PI6+imzMD02F6DtB5zOi4LXGEjKSjtzbRHxIAwLZnbL 7WNQ== X-Gm-Message-State: AOAM530Tx8HZXDYd/Tnz9ngatwDT0necPVzVXfExBT+STBM55N8rajtx 1aK92zB/jVRFKj0KA8r1JdvMbHD1yqA= 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> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.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: 12705529 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 67C8AC433F5 for ; Thu, 6 Jan 2022 16:03:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240844AbiAFQDu (ORCPT ); Thu, 6 Jan 2022 11:03:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49928 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240884AbiAFQDs (ORCPT ); Thu, 6 Jan 2022 11:03:48 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A797CC061212; Thu, 6 Jan 2022 08:03:48 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id v25so2958747pge.2; 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=EyLTr+kb2TPedCSZgf0p+97LBcixEQv0agZ1jlnMBYHekMkSZ5qzOedgpMd+B1LN2u GVyQm/JcQiL0HCWyH/ms0k/2QBPuIKlCObVZcvF5YZTJ7QgTSoEkELzsW+TqEOJwbWZa 72FNRBvn5GJdiVT4mK+QDVDHIKPf/fWV/7DMccoK/VikN7iecZa1fKfzZYD5MuPeTKNF glgwLNYmX6d8yI3UFY1B0jVWdM5jy/6iQl7fZxtIMZkKfyPlKw4o9e6v9GhrXhJJNYqG tFL9Bx495q5Xt1lneaWU2kcAnPJ2No2WNR6eN1mDtWLVtYTdJrjoXUs0Q+gmfr8JXd1n y5gA== X-Gm-Message-State: AOAM530aYUyCGxLSALpeu1atm8IeOsTbCZbGWwx30l3BjYMIkV5k8TKy AzDZDUmPXWLFzF3+R0hEgAS57pgIIUw= 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> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.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: 12705530 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 63CE4C433F5 for ; Thu, 6 Jan 2022 16:03:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240903AbiAFQDx (ORCPT ); Thu, 6 Jan 2022 11:03:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240904AbiAFQDv (ORCPT ); Thu, 6 Jan 2022 11:03:51 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 927B9C061245; Thu, 6 Jan 2022 08:03:51 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id q14so2789588plx.4; 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=FHqN5+vzDgN5Fu8S2D9gcdRaStbMm7WgYo/ZgyG6wF5qixNiCooWh9/lzNSg9OxgZH c/GAXurien2GhhriFo/0va5/3tsu3R4XNdgaWtpptWxdEHeYTMbk3xUrvAoG6cKG4zX1 /NzZTdNc/fEyWuiEpGtHm4t3hj6jndMZtStuf/cCMpdOF7aZEHu3Y7rboVVGc6O0Ykwz ByypKEc+ouOpJmLP832P2th5UYDSS5oZwzEFTeEBGpi36ZDtdRLFY0lbSxBIo8NVQuSe gy7/lxYgRpqaXmCK5PLoL19G6pFqbl3F2MJ5ocQK7s8QJs7LxGupt2uz8m09ty9a7re8 FvzQ== X-Gm-Message-State: AOAM532zqDIfoh5DS39e++kD5VRCsz2L9RDaSW613sAf3usVDbYKPl3/ gkS6u4lEVc7bW4+xk/MZL7l0hdHxrrQ= 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> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.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: 12705531 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5C442C433EF for ; Thu, 6 Jan 2022 16:03:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240890AbiAFQD4 (ORCPT ); Thu, 6 Jan 2022 11:03:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240910AbiAFQDz (ORCPT ); Thu, 6 Jan 2022 11:03:55 -0500 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5F20DC0611FF; Thu, 6 Jan 2022 08:03:54 -0800 (PST) Received: by mail-pj1-x1036.google.com with SMTP id ie13so2836541pjb.1; 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=0YfP9mLiud9ItKXH1cRWpx+IPXDVeurUDIPaMGjfl7qcccZ49YlFXWmb9VXAWealIy t1lN6pWVrzkjzAFZac0quMvnbDcVfydqrDNBmZGD1OYYeEByBSeWwytr5Iku1RYObOc8 SDuLm5yN1bTZAj37U4FJ0K26qk5bWFvTEXJliFlIlpXWrI11QAtf3OXxNWdV27NQHpIr ZKp7XHgxXuKtvGrT9PZOwb/thiVz1V8yCiehxb5rhJ3kcZXZL09V9HBGDTRJwUznpaUV rg6shdEAAaosY83afwlD54T80mMJxgNJuFPFvkzBvAMRzcbELbXUDV3E5QVA3Yb6i0ui gUIQ== X-Gm-Message-State: AOAM532BOVzGzW/tT1TdEXSY1W1fce3T5BoVOo6esbl0jRKUEwxllRim L60Bk6fVr7KM1zQs4YBNOyPu9y0zyfk= 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> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.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: 12705532 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 006B0C433EF for ; Thu, 6 Jan 2022 16:04:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240891AbiAFQEA (ORCPT ); Thu, 6 Jan 2022 11:04:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49990 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240916AbiAFQD5 (ORCPT ); Thu, 6 Jan 2022 11:03:57 -0500 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5767EC0611FD; Thu, 6 Jan 2022 08:03:57 -0800 (PST) Received: by mail-pj1-x1030.google.com with SMTP id g11-20020a17090a7d0b00b001b2c12c7273so5055798pjl.0; 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=yc5y1iXHiZMrSDSuHgaC06J3/zXgfmq1LIQfPYQ1MH3hEnwg2SJfVAdU7i7Md4Joo+ qZMryhfShzlKDY+NgYI/16YCA35SJ3nE5t5LcAcN7ZgCzvNVfMTcavISAAG7mP6SNwpI +KJVm55ikewi1NL3+XvV7kx2LMBgZB3fx7DnM3A/DWv2Qgel5U39LA4bkQItuSr9Dt6a NBU8ruzH1tKXsfgG/u+Rx+/0rx2SolwjCZSYpHeir66qL6fqvOW54N9nOsSfF65iQwit XLMTfu2wQYambPoJCD85++EQzsx6Kx4tSehXwKsOQS6BCJPiqaMoBBkydll+4Nb4JMI4 uW/A== X-Gm-Message-State: AOAM531OejDDFOlJyNWXop6iCJ6/mHd0xHuJfYJse+kJ+CcYBWZ1ZQzI i1ykCCzjjERthVvcp+vzxDpj0dlkbRE= 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> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.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: 12705533 X-Patchwork-Delegate: lorenzo.pieralisi@arm.com 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE7AEC433FE for ; Thu, 6 Jan 2022 16:04:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240910AbiAFQEB (ORCPT ); Thu, 6 Jan 2022 11:04:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240889AbiAFQEA (ORCPT ); Thu, 6 Jan 2022 11:04:00 -0500 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C34AC061201; Thu, 6 Jan 2022 08:04:00 -0800 (PST) Received: by mail-pj1-x102d.google.com with SMTP id iy13so2814378pjb.5; Thu, 06 Jan 2022 08:04:00 -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=OLTF1fK1+Dpv3dEvpfrY+JTDOWmMO1YsJ9DFD/oGN3eOUrHX0bp30GoK0vegO+QCpf QXAq2qQ31bjEC8v2ZyDbKHFJUBmgVGOZtYhr0jpJpxKfaP3qBnZZY7mDE8PTT5RrPiTV Dfk5M/WUACoo4B/5IlFKl8YMgJvjaT1BU+tszHRUzJVkBEdgtGeoiAakRCMJvC4OWrDs IwIpjXYr+LcGCzcxPz3a6TlTwNsaZGC7Oa9am/9BtG/2h+Wztp3PlhEqchIrp/oHXC2E UQyiwS1XPusuUPAHomSdvCBMwKFcAkK0XwwxAsOsikUOLMO71T7MwHGjxDUFxx+sym3r BbLw== X-Gm-Message-State: AOAM532FxO6k4/5NlHFx5l/68HgXS6YPkaza+D95GA3LzxBrpBBOfXRt Q2K97Muug/TgmSp2GR3Jme0Zh9MSrA0= 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> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.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; + } } }