From patchwork Wed Nov 3 18:49:31 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12601487 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 226B6C43217 for ; Wed, 3 Nov 2021 18:49:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E39761108 for ; Wed, 3 Nov 2021 18:49:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230218AbhKCSw0 (ORCPT ); Wed, 3 Nov 2021 14:52:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbhKCSwZ (ORCPT ); Wed, 3 Nov 2021 14:52:25 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 39C82C061205; Wed, 3 Nov 2021 11:49:49 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id p18so3050487plf.13; Wed, 03 Nov 2021 11:49:49 -0700 (PDT) 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=fkZ8oSbM149H4kVEdywu4YO/VDBT9raRSHF6PBOWSzY=; b=QPcXBNaGfBEelci/AS0Wcr0RcxzQXFao6D7dU4xdP8ITMYC6PES+VET4jqDflNtCYB hCKgbQnPc0929uMMXzwdO2+7lJV1Kq9bp0kjmQDNxhQ+0BYsEPjdEydMRAivLO5BD+Ag DlraZc6+N664tQKk502lx/7cNWjrhz75imYhNdgtDwr2nFlGxdflXUtOedOaUsczWGoq vKdR5HP0Ho6N2OZy1sIHBRwvyma9apE+u1D6H2r1Wj2mTDY4lvFh+RitaXqZZ8Q8lKXN 4ZMp7q0u7tI7CfD1U0bS8OkwlR9aSyeGxXBfjszTUNxaWyAwiK4eQp4lI1XvdxV5UZbd p3yw== 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=fkZ8oSbM149H4kVEdywu4YO/VDBT9raRSHF6PBOWSzY=; b=dkO5q6d/7NjWB46a+iW+lHqnqlhoPmRIYM9OhU/xM2Rn3LyoSvvyN0K1+r9bN0n4Vn MENUzthHRfM31s1SK64WZHmWLkZ8r4g3E+RDPJriXh3dyj2VUi/In3mnflKP5YsUzaz4 1LcQ4QbpUlnYn1hbWUkKoMVR7RBZUcA3WJE0mk3PN/IyLLShbEzHciEiQnZQN6GHLSZM AajAk2jlmGrPDXr3Rd4CksQNPEWb5BwCEmiPlPs/3NNSRMshRax+yAhz9fUpI6hLdS6S MGKM4hn7n2w0l9hH267aGGmINrPXuHEcaaBQQPWf2i5pCPnhSp9FhfzwcnpoY8r1aL4f 4pmw== X-Gm-Message-State: AOAM533hVkP6QZjabsbzVcs3m26Dzbc/+tijzlD9BLH2v3o5FUKz9+Og PEV7DuANisrowFH6kQcnNnvVNLcbZB/0Zg== X-Google-Smtp-Source: ABdhPJxcijKpuPZtOgucEvRV6NRFccIYE07lEYWuGVuVxbWcFnVaelAhB7GpMip/bz0eb+SsA1xcXw== X-Received: by 2002:a17:902:e849:b0:142:c85:4d3d with SMTP id t9-20020a170902e84900b001420c854d3dmr11979537plg.75.1635965388447; Wed, 03 Nov 2021 11:49:48 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id j6sm2379065pgq.0.2021.11.03.11.49.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Nov 2021 11:49:47 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Bjorn Helgaas , 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 v7 1/7] dt-bindings: PCI: Correct brcmstb interrupts, interrupt-map. Date: Wed, 3 Nov 2021 14:49:31 -0400 Message-Id: <20211103184939.45263-2-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211103184939.45263-1-jim2101024@gmail.com> References: <20211103184939.45263-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 b9589a0daa5c..508e5dce1282 100644 --- a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml +++ b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml @@ -142,11 +142,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 Wed Nov 3 18:49:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12601489 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B64AAC433EF for ; Wed, 3 Nov 2021 18:49:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A5F36112E for ; Wed, 3 Nov 2021 18:49:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231380AbhKCSwc (ORCPT ); Wed, 3 Nov 2021 14:52:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbhKCSw2 (ORCPT ); Wed, 3 Nov 2021 14:52:28 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A5ACC061203; Wed, 3 Nov 2021 11:49:51 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id t21so3116697plr.6; Wed, 03 Nov 2021 11:49:51 -0700 (PDT) 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=XxDFU6zngH2MiSJPUrDOxFHmK942PXrD/2AGczC8Ul8=; b=pZG5T96zGfFKOpbOk4/fe7AakdF5UfixT2t71nwLmhH5Mx0X+IqI0nA1ljOfxTfLuH BplUo3adJ8WAG5PaZT5lVlKfHBk0oQzabZ/g4SUiOYrQPEN7Yo+c1jKM4MamKeiww10n DdHaN09TRhET2EMztgaY6Pc8BfS7jpN8wh8MZ7WckLx0UMiW4oSogYTIhpCvJTVR10GZ O5OPrMn8nbqKa8rQLbYP1PY+tlfSA4n1Y1ZplmD1zzEtQ1qvgVFHOQF0FOQe9KgyloG6 HKyl4g8GpreFi6bV8OGgBJbm8QLWoseN5CqHiAlRIuj7VE1tNcjciO2MJrP1cwxz7CxX 5SVw== 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=XxDFU6zngH2MiSJPUrDOxFHmK942PXrD/2AGczC8Ul8=; b=31Tva6kz14KjKbVqxhjQPohEiUph6TMyksfK6poXcNCuLGX6Ad1D0AdTHI/6katVKX /XxtDyJUDeXrDFCgIpmwtnT0GB8s6v9LzKfWLWtpFcI522R9phoCMHg5ixa6Hj1BmWiK 7c7kl7SxVgBdLj1ss384jgcgdgxtzg6zEsASthkNlkjdCBxKBN/TH5n1V8GCCPvSqIMn Q1iqntzKkTTVmuUziYtVWu11QHQt47sDywwBZ5wxxTZ8kcP7SDPqztvMUu9EBIhHPbuS z0AJ+88SzbmHJkRz1sE2dUe9FW5+7PNPgJ5CvL+LEvrST/qWRZG3crRfARD14L5n5xw4 2Kkw== X-Gm-Message-State: AOAM531tzNPgRPV6D4u5kygeTfmPEMUjM48VME0lXY6/2phoDlU8jK6v /cG7R4X0habqEcpp82T9p6i84NxXIln/gw== X-Google-Smtp-Source: ABdhPJwATqSP80m9Am/wm/Wa6I9Nc5RO2ocnh2+BqVcYLRdPASPmpaMTg8hrU7YBav6nVeR3Ynw2qg== X-Received: by 2002:a17:90b:3802:: with SMTP id mq2mr16547475pjb.213.1635965390969; Wed, 03 Nov 2021 11:49:50 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id j6sm2379065pgq.0.2021.11.03.11.49.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Nov 2021 11:49:50 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Bjorn Helgaas , 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 v7 2/7] dt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators Date: Wed, 3 Nov 2021 14:49:32 -0400 Message-Id: <20211103184939.45263-3-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211103184939.45263-1-jim2101024@gmail.com> References: <20211103184939.45263-1-jim2101024@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Similar to the regulator bindings found in "rockchip-pcie-host.txt", this allows optional regulators to be attached and controlled by the PCIe RC driver. That being said, this driver searches in the DT subnode (the EP node, eg pci-ep@0,0) for the regulator property. The use of a regulator property in the pcie EP subnode such as "vpcie12v-supply" depends on a pending pullreq to the pci-bus.yaml file at https://github.com/devicetree-org/dt-schema/pull/63 Signed-off-by: Jim Quinlan --- .../bindings/pci/brcm,stb-pcie.yaml | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml index 508e5dce1282..ef2427320b7d 100644 --- a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml +++ b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml @@ -158,5 +158,28 @@ examples: <0x42000000 0x1 0x80000000 0x3 0x00000000 0x0 0x80000000>; brcm,enable-ssc; brcm,scb-sizes = <0x0000000080000000 0x0000000080000000>; + + /* PCIe bridge */ + pci@0,0 { + #address-cells = <3>; + #size-cells = <2>; + reg = <0x0 0x0 0x0 0x0 0x0>; + compatible = "pciclass,0604"; + device_type = "pci"; + vpcie3v3-supply = <&vreg7>; + ranges; + + /* PCIe endpoint */ + pci-ep@0,0 { + assigned-addresses = + <0x82010000 0x0 0xf8000000 0x6 0x00000000 0x0 0x2000>; + reg = <0x0 0x0 0x0 0x0 0x0>; + compatible = "pci14e4,1688"; + #address-cells = <3>; + #size-cells = <2>; + + ranges; + }; + }; }; }; From patchwork Wed Nov 3 18:49:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12601491 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EF51C433EF for ; Wed, 3 Nov 2021 18:49:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 82DF261108 for ; Wed, 3 Nov 2021 18:49:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231314AbhKCSwe (ORCPT ); Wed, 3 Nov 2021 14:52:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231305AbhKCSwa (ORCPT ); Wed, 3 Nov 2021 14:52:30 -0400 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 17FF5C06120B; Wed, 3 Nov 2021 11:49:54 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id nh10-20020a17090b364a00b001a69adad5ebso2120127pjb.2; Wed, 03 Nov 2021 11:49:54 -0700 (PDT) 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=+KIUczUS/ZsYc2yKqmHED/7x17icKPInYDTolIdaty0=; b=VRwLrL82bnQDTaHfLIz36gShEC2CRz5Ssow3SBz2QkVVpRIUdqnJPNY9dr635rzky5 EI9H0iZ4vQpItvYSglTFAXJdafJdyAxGP8lMnqzwtgF8XF2lEWXA0unrjHV1BxF7Lokj zSn55qlG7xzZarOzCzpIPEGnb0Uffg/uH7Txm/909GRFSsj2fhjlTHkh/uY4YMufGM0y TdR1YwNjvGZmqne1FnPNOub3PPpZpaLcYqBgouh2g7U5eseNiK5HheQWMxuvDbulc+t7 6XIQyOQsgQRDNsTQvnOSwy85BcWiL0Gjtb3zB65Zzhf2kROaQ8Z/XprheMBHaPp1Ib7S vlcA== 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=+KIUczUS/ZsYc2yKqmHED/7x17icKPInYDTolIdaty0=; b=rQGrnBDgyHLipFgbehzFtv/a4sMEeMbqKkk4VR2E77MBbMJZAp69DIkuylx3rHTd1I hj+OYXrqZnDh32WA6vx0B0HM2LHtYDELuKEeDgOhBBdTVsYI2Ky6qHvKqjsF9PVOE/Vi BYK5onWd31E+3A3R99qo8/15Z+0cjh+lbbWbcgpthbnrx0VZQS6h1h66xqsYWat5Hrg9 ZFNa01nRvV2wzL2rtZPJFc6vzItuoEDW6wMxmYlOvFs0oRQcXbPrvm/V3KCGbtEXrXUY rEKt0plBeaETu9ym+Vz37Xm/IaijIR/CFs4bcYlaBwWMuU4PUoHnC4D1Lri7/cGYe0Lt 6D5g== X-Gm-Message-State: AOAM533Z6+8t1CEvWy4OA4Yty9J0fXqvdmzYXlIsKzImlQ8zZsSxaZfo 7lR/Mei1WzTuwvxB1Zge2b5kc0Fz6RP21A== X-Google-Smtp-Source: ABdhPJz7p4koVRRiR5HdILl24gGZV0hYsk1W8hGHmXKRWDnY3dPh8DQfSUExvFTUANzPFJ75UZXuzQ== X-Received: by 2002:a17:902:bc8a:b0:141:eb43:81a1 with SMTP id bb10-20020a170902bc8a00b00141eb4381a1mr20280237plb.52.1635965393405; Wed, 03 Nov 2021 11:49:53 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id j6sm2379065pgq.0.2021.11.03.11.49.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Nov 2021 11:49:52 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Bjorn Helgaas , 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 v7 3/7] PCI: brcmstb: Split brcm_pcie_setup() into two funcs Date: Wed, 3 Nov 2021 14:49:33 -0400 Message-Id: <20211103184939.45263-4-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211103184939.45263-1-jim2101024@gmail.com> References: <20211103184939.45263-1-jim2101024@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org We need to split a function in two so that the driver can take advantage of the recently added function pci_subdev_prepare() which is a member of struct pci_host_bridge. Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 30 +++++++++++++++++++-------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index cc30215f5a43..ba4d6daf312c 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -863,17 +863,10 @@ 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; - u32 tmp, burst, aspm_support; + int ret, memc; + u32 tmp, burst; /* Reset the bridge */ pcie->bridge_sw_init_set(pcie, 1); @@ -956,6 +949,21 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie) if (pcie->gen) brcm_pcie_set_gen(pcie, pcie->gen); + 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 aspm_support, tmp; + int ret, i; /* Unassert the fundamental reset */ pcie->perst_set(pcie, 0); @@ -1186,6 +1194,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 Wed Nov 3 18:49:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12601493 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC244C433F5 for ; Wed, 3 Nov 2021 18:49:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C0EDB6113E for ; Wed, 3 Nov 2021 18:49:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231311AbhKCSwf (ORCPT ); Wed, 3 Nov 2021 14:52:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231381AbhKCSwc (ORCPT ); Wed, 3 Nov 2021 14:52:32 -0400 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [IPv6:2607:f8b0:4864:20::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E7DEAC061714; Wed, 3 Nov 2021 11:49:55 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id t11so3064503plq.11; Wed, 03 Nov 2021 11:49:55 -0700 (PDT) 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=kVoHPfQnodZ3/LWe6f7ZKVgKp7X363UiJlEFSvrGKys=; b=gCEi8Sy5N/Mk9eVvupjNy+ymn4U1vqg+Aj7EWLvoP69wUHBSwDzLRbIUC8MZTYi2st BU1+tpQHQU7vgWAcz6drBp/rD4mUTdLB+qWWi8IOdBGzytGmEbvRxONyR4E36OeJ9Cpm +CXAjCvpfRuirwkSTB42gvUCrEwCSdYloBce5squFWnQ0pxapJ8obllZ5ZfGdt+KmyxC Cu0P5h2iMi1ho5elmlrxk/HD/DJZl95hyOcnG8LypJ9pi7LNQ4NxNSCIJTQktFlYp2DT jtWEaB4kD3oQUCu0XKJ7o5doa+QGDMgpPz1V7FBPeAFTOxRBzhZWRLgYA8wXpLZsdmTS 5ZQA== 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=kVoHPfQnodZ3/LWe6f7ZKVgKp7X363UiJlEFSvrGKys=; b=OGykd+kAcxkkmFQqehOwKrnwxNeBauJOVVUkoETjakeVYekaz8a+9MD5Xu7gx7c+/m CF38IVpJ0DlUBpK7n6+3ZuPCPN89O32ZVbkW91ThovCL2vZtjcfONzweXYNZf5gQMN/k 5LI9/+K9lTSfH3m85AafIq0h9vwbHtlkStRrh3UDow/b4P4Bi5ynMnY4cXrX0Sb0azpJ U70sTe2nZSlvrqhG0VZiZbBbuMjswu8V+JMzQixG55zpTNcQ/OeWPa2/gQ3EM1gYyrEj QnFAE69n42hTNLeUkVIgpkQgzIF4P6SxQjuAw1Tj5EPnu7OoDAjO2MpwduR6Ekq4Hx/x yKYg== X-Gm-Message-State: AOAM532mI0MTOHRgcwyZxBqHSpR3XilhJ2GdbgE/vtQoFse0yc4K9auu EaItFXkoGuTq+R7qnxe/zhusMnefkqwuUA== X-Google-Smtp-Source: ABdhPJzshArmo/48IhJdPKAnbwwXSdLIecSzkTpe89usHqdHIxb4sn9w2GLV2y0gtzbssrMCx68EwA== X-Received: by 2002:a17:903:18d:b0:142:8ab:d11f with SMTP id z13-20020a170903018d00b0014208abd11fmr12951026plg.47.1635965395238; Wed, 03 Nov 2021 11:49:55 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id j6sm2379065pgq.0.2021.11.03.11.49.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Nov 2021 11:49:54 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Bjorn Helgaas , linux-kernel@vger.kernel.org (open list) Subject: [PATCH v7 4/7] PCI: pci_alloc_child_bus() return NULL if ->add_bus() returns -ENOLINK Date: Wed, 3 Nov 2021 14:49:34 -0400 Message-Id: <20211103184939.45263-5-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211103184939.45263-1-jim2101024@gmail.com> References: <20211103184939.45263-1-jim2101024@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Currently, if the call to the pci_ops add_bus() method returns an error, a WARNING and dev_err() occurs. We keep this behavior for all errors except -ENOLINK; for -ENOLINK we want to skip the WARNING and immediately return NULL. The argument for this case is that one does not want to continue enumerating if pcie-link has not been established. The real reason is that without doing this the pcie-brcmstb.c driver panics when the dev/id is read, as this controller panics on such accesses rather than returning 0xffffffff. It appears that there are only a few uses of the pci_ops add_bus() method in the kernel and none of them currently return -ENOLINK so it should be safe to do this. Signed-off-by: Jim Quinlan --- drivers/pci/probe.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index d9fc02a71baa..fdc3f42634b7 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -1122,6 +1122,9 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent, if (child->ops->add_bus) { ret = child->ops->add_bus(child); + /* Don't return the child if w/o pcie link-up */ + if (ret == -ENOLINK) + return NULL; if (WARN_ON(ret < 0)) dev_err(&child->dev, "failed to add bus: %d\n", ret); } From patchwork Wed Nov 3 18:49:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12601495 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 85023C433F5 for ; Wed, 3 Nov 2021 18:50:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 658BC610EA for ; Wed, 3 Nov 2021 18:50:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231496AbhKCSwi (ORCPT ); Wed, 3 Nov 2021 14:52:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33890 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229772AbhKCSwe (ORCPT ); Wed, 3 Nov 2021 14:52:34 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F85DC061714; Wed, 3 Nov 2021 11:49:58 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id y1so3075637plk.10; Wed, 03 Nov 2021 11:49:58 -0700 (PDT) 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=3TSaUqFQ373KOcylCPvljRjsapR+eghqQwHcyVQXkYo=; b=ii33XPCm/NMGn3E3iCWe0wqAG/0f51JRs3YinU1BbTAxc5X5UCysala684ozI+XDXY R8mHIIv0bAlKXtBzSPCYPwj7im93EdPmt3jMRhgXv//BEYIq7B4R75JzFMhRkZ7cc3gG R7loLkP1C4vtm+tn1npDzmmwKPi0m19pa+7TceIlZ5Yhg8VKCF4jSzQg7OWT3jF0c5Fk DzIk7rad4VYcYqIMZ8c0KFrhJbcjvX17SsJTyabbXEo2nEq/ea6xpNWHZUfKkEEEuVaU G0ND+zB/0WDRNDQ69+BjZTaL4/TuhaGxuzWCrmQXtNHAvg5cwUwuSB+c/RUWRmZ1D+ye VNFQ== 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=3TSaUqFQ373KOcylCPvljRjsapR+eghqQwHcyVQXkYo=; b=0bAoCIkPWFQi5lcM5v0kN1UrldJHsyjVTYvw7iHWusbl0CAEKJkyW3U7LULsXm1TTW PAG7M2MuOics0emiPozvMODYl80VtY2hwddufVUJAY0vTEUefubF/MJh0QYr0qXOKXc7 HakpeOyjGH1dnUheAC/6OnFFsYWs/GvB8lu9OOs0twQ3bGUQBbN9jXRE54u6CqvZ4kgX 69rfww/go/UwySQ+Ges9P5tz4peDddrXFm2U84Y8wrWJRxYUwBsTbj6kJq3s0qFX/txq KMZVLQOazGToJYd1NcS/mz3tFiUraZv+IOlm9+UcVKKj9XAewSvdgb/TwT7sUbWIX+vR ynOw== X-Gm-Message-State: AOAM531+FYkcrEDrfm8vNM2+XdP+ONGGtA4kPGMTYiSmbavx1IlooEaj IF8nXEpHWAUTIde5yQZijYFyNUItGa9ohA== X-Google-Smtp-Source: ABdhPJzgbs8kLCJfJbnoJW1JqqKe9OKcGb5xUw327c8eClhY/MH+OcN0k+BFgN6+Je4t0EdmWDx9aA== X-Received: by 2002:a17:903:1207:b0:138:e2f9:6c98 with SMTP id l7-20020a170903120700b00138e2f96c98mr41428638plh.11.1635965397471; Wed, 03 Nov 2021 11:49:57 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id j6sm2379065pgq.0.2021.11.03.11.49.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Nov 2021 11:49:57 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Bjorn Helgaas , 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 v7 5/7] PCI: brcmstb: Add control of subdevice voltage regulators Date: Wed, 3 Nov 2021 14:49:35 -0400 Message-Id: <20211103184939.45263-6-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211103184939.45263-1-jim2101024@gmail.com> References: <20211103184939.45263-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 turn on/off any regulators for that device. Control of regulators is needed because of the chicken-and-egg situation: although the regulator is "owned" by the device and would be best handled by its driver, the device cannot be discovered and probed unless its regulator is already turned on. Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 156 +++++++++++++++++++++++++- 1 file changed, 154 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index ba4d6daf312c..aaf6a4cbeb78 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 @@ -191,6 +192,15 @@ static inline void brcm_pcie_bridge_sw_init_set_generic(struct brcm_pcie *pcie, static inline void brcm_pcie_perst_set_4908(struct brcm_pcie *pcie, u32 val); static inline void brcm_pcie_perst_set_7278(struct brcm_pcie *pcie, u32 val); static inline void brcm_pcie_perst_set_generic(struct brcm_pcie *pcie, u32 val); +static int brcm_pcie_add_bus(struct pci_bus *bus); +static void brcm_pcie_remove_bus(struct pci_bus *bus); +static bool brcm_pcie_link_up(struct brcm_pcie *pcie); + +static const char * const supplies[] = { + "vpcie3v3", + "vpcie3v3aux", + "vpcie12v", +}; enum { RGR1_SW_INIT_1, @@ -295,8 +305,38 @@ 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); + struct regulator_bulk_data supplies[ARRAY_SIZE(supplies)]; + unsigned int num_supplies; }; +static int brcm_regulators_on(struct brcm_pcie *pcie) +{ + struct device *dev = pcie->dev; + int ret; + + if (!pcie->num_supplies) + return 0; + ret = regulator_bulk_enable(pcie->num_supplies, pcie->supplies); + if (ret) + dev_err(dev, "failed to enable EP regulators\n"); + + return ret; +} + +static int brcm_regulators_off(struct brcm_pcie *pcie) +{ + struct device *dev = pcie->dev; + int ret; + + if (!pcie->num_supplies) + return 0; + ret = regulator_bulk_disable(pcie->num_supplies, pcie->supplies); + if (ret) + dev_err(dev, "failed to disable EP regulators\n"); + + return ret; +} + /* * This is to convert the size of the inbound "BAR" region to the * non-linear values of PCIE_X_MISC_RC_BAR[123]_CONFIG_LO.SIZE @@ -722,6 +762,8 @@ static struct pci_ops brcm_pcie_ops = { .map_bus = brcm_pcie_map_conf, .read = pci_generic_config_read, .write = pci_generic_config_write, + .add_bus = brcm_pcie_add_bus, + .remove_bus = brcm_pcie_remove_bus, }; static inline void brcm_pcie_bridge_sw_init_set_generic(struct brcm_pcie *pcie, u32 val) @@ -1148,6 +1190,47 @@ static void brcm_pcie_turn_off(struct brcm_pcie *pcie) pcie->bridge_sw_init_set(pcie, 1); } +static int brcm_pcie_get_regulators(struct brcm_pcie *pcie, struct device *dev) +{ + const unsigned int ns = ARRAY_SIZE(supplies); + struct device_node *dn; + struct property *pp; + unsigned int i; + int ret; + + /* This is for Broadcom STB/CM chips only */ + if (pcie->type == BCM2711) + return 0; + + dn = dev->of_node; + if (!dn) + return 0; + + for_each_property_of_node(dn, pp) { + for (i = 0; i < ns; i++) { + char prop_name[64]; /* 64 is max size of property name */ + + snprintf(prop_name, 64, "%s-supply", supplies[i]); + if (strcmp(prop_name, pp->name) == 0) + break; + } + if (i >= ns || pcie->num_supplies >= ARRAY_SIZE(supplies)) + continue; + + pcie->supplies[pcie->num_supplies++].supply = supplies[i]; + } + + if (pcie->num_supplies == 0) + return 0; + + ret = devm_regulator_bulk_get(dev, pcie->num_supplies, + pcie->supplies); + if (ret) + dev_err(dev, "failed to get EP regulators\n"); + + return ret; +} + static int brcm_pcie_suspend(struct device *dev) { struct brcm_pcie *pcie = dev_get_drvdata(dev); @@ -1158,7 +1241,7 @@ static int brcm_pcie_suspend(struct device *dev) reset_control_rearm(pcie->rescal); clk_disable_unprepare(pcie->clk); - return ret; + return brcm_regulators_off(pcie); } static int brcm_pcie_resume(struct device *dev) @@ -1174,6 +1257,9 @@ static int brcm_pcie_resume(struct device *dev) ret = reset_control_reset(pcie->rescal); if (ret) goto err_disable_clk; + ret = brcm_regulators_on(pcie); + if (ret) + goto err_reset; ret = brcm_phy_start(pcie); if (ret) @@ -1241,6 +1327,62 @@ static const struct of_device_id brcm_pcie_match[] = { {}, }; +static int brcm_pcie_add_bus(struct pci_bus *bus) +{ + struct pci_host_bridge *hb = pci_find_host_bridge(bus); + struct brcm_pcie *pcie = (struct brcm_pcie *) hb->sysdata; + struct device *dev = &bus->dev; + int ret; + + /* + * We only care about a device that is directly connected + * to the root complex, ie bus == 1 and slot == 0. + */ + if (bus->number != 1) + return 0; + + ret = brcm_pcie_get_regulators(pcie, dev); + if (ret) + goto err_out; + + ret = brcm_regulators_on(pcie); + if (ret) + goto err_out; + + ret = brcm_pcie_linkup(pcie); + if (ret) + goto err_out; + + return 0; + +err_out: + /* + * If we have failed there is no point to return the exact reason, + * as currently it will cause a WARNING() from + * pci_alloc_child_bus(). We return -ENOLINK to the caller, which + * unlike any other errors, will stop the PCIe tree exploration. + */ + return -ENOLINK; +} + +static void brcm_pcie_remove_bus(struct pci_bus *bus) +{ + struct pci_host_bridge *hb = pci_find_host_bridge(bus); + struct brcm_pcie *pcie = (struct brcm_pcie *) hb->sysdata; + struct device *dev = &bus->dev; + int ret; + + if (bus->number != 1) + return; + + if (pcie->num_supplies > 0) { + ret = brcm_regulators_off(pcie, true); + if (ret) + dev_err(dev, "Could not turn of regulators\n"); + pcie->num_supplies = 0; + } +} + static int brcm_pcie_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node, *msi_np; @@ -1332,7 +1474,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; From patchwork Wed Nov 3 18:49:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12601497 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BB04C433F5 for ; Wed, 3 Nov 2021 18:50:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 21982610EA for ; Wed, 3 Nov 2021 18:50:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231266AbhKCSwm (ORCPT ); Wed, 3 Nov 2021 14:52:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231482AbhKCSwh (ORCPT ); Wed, 3 Nov 2021 14:52:37 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EB82C06120B; Wed, 3 Nov 2021 11:50:00 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id n36-20020a17090a5aa700b0019fa884ab85so2066402pji.5; Wed, 03 Nov 2021 11:50:00 -0700 (PDT) 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=wB1XTHRrUvGXuzH1iZwj1J6GyNltpPCGAayAWSa5LmQ=; b=Jj8wZVtWZX2avHtT6K3bSj2bMG40lbof6al+upIjE7v3prKL0Gs3UxNJozzt8u1SVn qiB3GwgJpsqaYVkk7UAyEGZ5cTHZQwl1Pa2eeY8LKW3uMnVIduLtjV9BsxcaC2Y5xA+N ohXJ0QybXPPWQg4ct6FDvRGTAqwl90ycMiPDNEUqZ4x5zo96VNRGlAVMnpkrdbHLHVmS PrtQiTySChOB2IYY9Eq/7sKmUm9+7mEmLtXjgFHbh4oorXVkDtTnp855HOh3rbg0TMsC OHaVuERpAmLFCLVliDJjGCkRQMM5ZJEWKmTUH9rYGdmuAOVbcSl9q8CPLiJEohehV8/K IPLw== 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=wB1XTHRrUvGXuzH1iZwj1J6GyNltpPCGAayAWSa5LmQ=; b=Vv1v3og+oLXa/F+Ad7vSVA2Di/xlovd7AUMaWDNywp/W5+qA8PqR9KQjV8KIx6gyA4 9HbA1J7WleU4TPzobB8lFyz+dxSpvTY900rN3FFLdPtRHXSZ67ED4tQHh4wUhK2haSyF GcKTpkJAzPfgfoqQ96WF+9BOezkWOlOMrK0fGPbsAs5Io5DQfHzn1ZCOYe6+XYUV+ZOn xkNKtzno+BdZFzmD1mU0KkbUBEt9RUrB1ZZp6xDcKDeWX+6c7T/vXVP9i9W5YSyAHvxC /bVh5lVwvd4FU+6vXKBLa/OErnc5r3oI37gayANJPnutibYBEUfAgc1GIeOuWWB22Gw1 jfcw== X-Gm-Message-State: AOAM531McXqOzSuGooUbxyR6vCpxrXEzh7P3y5m315bHC4T6Ey0tW/Fm 3on+dL7Zr0rZV41usJLdNVSQbK11b+npmA== X-Google-Smtp-Source: ABdhPJxysJWpo64eRsY6+bwdO1TrGhnH5TPuJXNlA8jir9+FpIYzLpJNg28HsV1AQ62Z5m6fK2zglA== X-Received: by 2002:a17:902:778a:b0:13f:672c:103a with SMTP id o10-20020a170902778a00b0013f672c103amr40891628pll.55.1635965399774; Wed, 03 Nov 2021 11:49:59 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id j6sm2379065pgq.0.2021.11.03.11.49.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Nov 2021 11:49:59 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Bjorn Helgaas , 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 v7 6/7] PCI: brcmstb: Do not turn off regulators if EP can wake up Date: Wed, 3 Nov 2021 14:49:36 -0400 Message-Id: <20211103184939.45263-7-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211103184939.45263-1-jim2101024@gmail.com> References: <20211103184939.45263-1-jim2101024@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org If any downstream device may wake up during S2/S3 suspend, we do not want to turn off its power when suspending. Signed-off-by: Jim Quinlan Reviewed-by: Mark Brown --- drivers/pci/controller/pcie-brcmstb.c | 43 +++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index aaf6a4cbeb78..9aadb0eccfff 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -307,8 +307,20 @@ struct brcm_pcie { void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val); struct regulator_bulk_data supplies[ARRAY_SIZE(supplies)]; unsigned int num_supplies; + bool ep_wakeup_capable; }; +static int pci_dev_may_wakeup(struct pci_dev *dev, void *data) +{ + bool *ret = data; + + if (device_may_wakeup(&dev->dev)) { + *ret = true; + dev_dbg(&dev->dev, "disable cancelled for wake-up device\n"); + } + return (int) *ret; +} + static int brcm_regulators_on(struct brcm_pcie *pcie) { struct device *dev = pcie->dev; @@ -316,6 +328,18 @@ static int brcm_regulators_on(struct brcm_pcie *pcie) if (!pcie->num_supplies) return 0; + + if (pcie->ep_wakeup_capable) { + /* + * We are resuming from a suspend. In the previous 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; + return 0; + } + ret = regulator_bulk_enable(pcie->num_supplies, pcie->supplies); if (ret) dev_err(dev, "failed to enable EP regulators\n"); @@ -323,13 +347,28 @@ static int brcm_regulators_on(struct brcm_pcie *pcie) return ret; } -static int brcm_regulators_off(struct brcm_pcie *pcie) +static int brcm_regulators_off(struct brcm_pcie *pcie, bool force) { + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); struct device *dev = pcie->dev; int ret; if (!pcie->num_supplies) return 0; + + pcie->ep_wakeup_capable = false; + + if (!force && bridge->bus && brcm_pcie_link_up(pcie)) { + /* + * If at least one device on this bus is enabled as a + * wake-up source, do not turn off regulators. + */ + pci_walk_bus(bridge->bus, pci_dev_may_wakeup, + &pcie->ep_wakeup_capable); + if (pcie->ep_wakeup_capable) + return 0; + } + ret = regulator_bulk_disable(pcie->num_supplies, pcie->supplies); if (ret) dev_err(dev, "failed to disable EP regulators\n"); @@ -1241,7 +1280,7 @@ static int brcm_pcie_suspend(struct device *dev) reset_control_rearm(pcie->rescal); clk_disable_unprepare(pcie->clk); - return brcm_regulators_off(pcie); + return brcm_regulators_off(pcie, false); } static int brcm_pcie_resume(struct device *dev) From patchwork Wed Nov 3 18:49:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12601499 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66808C433F5 for ; Wed, 3 Nov 2021 18:50:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E42E6112E for ; Wed, 3 Nov 2021 18:50:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231538AbhKCSwp (ORCPT ); Wed, 3 Nov 2021 14:52:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231555AbhKCSwj (ORCPT ); Wed, 3 Nov 2021 14:52:39 -0400 Received: from mail-pg1-x52c.google.com (mail-pg1-x52c.google.com [IPv6:2607:f8b0:4864:20::52c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B0EC6C061208; Wed, 3 Nov 2021 11:50:02 -0700 (PDT) Received: by mail-pg1-x52c.google.com with SMTP id g184so3156891pgc.6; Wed, 03 Nov 2021 11:50:02 -0700 (PDT) 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=qT6D8z9EWM5nbqoODMsf6pYhfTqAM6D4oAkvj8nPzI4=; b=kT4+I28b80Hx+pwNuGDFDshF/1eR9612Hjb09D99u7P60J+2XEhPtO0SwamVqVk8qy mAiTjhfhFBsH2uf7SaucFkvYpHbA+Z3bMa51gajLIy7b27EZIU8av3Ymya58ye9Zfxg4 jSl2eACif4DN1bi/QVqpIGb3IbxRJ8cclPEk67g3RcpLHW0LOsjJyrfuCZUOvi9gRYAj lPcijjwKa/fl2PbmCJ7kdzOIAwouBXNVt6H7C6TgKD56oeXIpUrfsrzfpdcBCbOOZHz3 GnnFxfNEIr+BsIL6moW7Q0YKDAG2wjhdDknObRBgjnG//MTG9TKG4xRkxGq3gnSAi3vT Kmuw== 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=qT6D8z9EWM5nbqoODMsf6pYhfTqAM6D4oAkvj8nPzI4=; b=SEfFaE44fxtaZrpExKDyZQc3vVoJYkc95b5dzyudHBzGbF7KfT0P/seOxcZWquewNk CqUhFpLMmfPCDIb41P4EbmUsmwxnG5SNbtfR6f1Vq0h5wrThGiSy1IrNUTE5fT+dBy0M KVRc8lGDMttfAfxozfX700htTgwzgEMxxmNars5uiZ8qs+fGSRvcsBhNXhAUpb1gvdJw c4nqBqI/N1GaqfWvrbMNkPXm2tQ7i5R51gWsyoLKf7Auv8AsMQToOsMi9ugYvfGztvNF uJrsMTscON0NGeAYae7LtnjRI0XB4lVMHroRJH/1x9uKkl2I7yiiYqkvzzc6k/QLU4hr bXNw== X-Gm-Message-State: AOAM531fD+WtWbjQgjTtxXi119Fw0FcH35YEAuCXU/XJc2lMd/wdKlrI 1IHEx9QVpyUj7SJ00Sw4/4S+os3M2I+kYg== X-Google-Smtp-Source: ABdhPJy+7EOGlv8SCRA+dshz00FJ/GQ3infaDey2A4rnwN3sb7znxUN4xm8S3OhuxlKNlU27ryNIew== X-Received: by 2002:a05:6a00:21c2:b0:44c:fa0b:f72 with SMTP id t2-20020a056a0021c200b0044cfa0b0f72mr46346157pfj.13.1635965402040; Wed, 03 Nov 2021 11:50:02 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id j6sm2379065pgq.0.2021.11.03.11.50.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Nov 2021 11:50:01 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Rob Herring , Mark Brown , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Bjorn Helgaas , 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 v7 7/7] PCI: brcmstb: Change brcm_phy_stop() to return void Date: Wed, 3 Nov 2021 14:49:37 -0400 Message-Id: <20211103184939.45263-8-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211103184939.45263-1-jim2101024@gmail.com> References: <20211103184939.45263-1-jim2101024@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org We do not use the result of this function so make it void. Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 9aadb0eccfff..5eabbd72e5b8 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -1200,9 +1200,10 @@ static inline int brcm_phy_start(struct brcm_pcie *pcie) return pcie->rescal ? brcm_phy_cntl(pcie, 1) : 0; } -static inline int brcm_phy_stop(struct brcm_pcie *pcie) +static inline void brcm_phy_stop(struct brcm_pcie *pcie) { - return pcie->rescal ? brcm_phy_cntl(pcie, 0) : 0; + if (pcie->rescal) + brcm_phy_cntl(pcie, 0); } static void brcm_pcie_turn_off(struct brcm_pcie *pcie) @@ -1273,10 +1274,9 @@ static int brcm_pcie_get_regulators(struct brcm_pcie *pcie, struct device *dev) static int brcm_pcie_suspend(struct device *dev) { struct brcm_pcie *pcie = dev_get_drvdata(dev); - int ret; brcm_pcie_turn_off(pcie); - ret = brcm_phy_stop(pcie); + brcm_phy_stop(pcie); reset_control_rearm(pcie->rescal); clk_disable_unprepare(pcie->clk);