From patchwork Fri Oct 29 20:03:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12593639 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 B7440C433F5 for ; Fri, 29 Oct 2021 20:03:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 92C996101E for ; Fri, 29 Oct 2021 20:03:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230506AbhJ2UGA (ORCPT ); Fri, 29 Oct 2021 16:06:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230287AbhJ2UF4 (ORCPT ); Fri, 29 Oct 2021 16:05:56 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42002C061570; Fri, 29 Oct 2021 13:03:27 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id x1-20020a17090a530100b001a1efa4ebe6so7948161pjh.0; Fri, 29 Oct 2021 13:03:27 -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=bTzdKFlLFxjEYXsTCiwTs/u3WhqgR0accwfx+BQVxCI=; b=WXLrJc4CiRZzhTY/aUKgXzjL/YRIDCpia8+QRg5wgkZ+erdxhdGaP+zvm/9sIIZCAq WJbfnkFPMqvqYNWJe+RvA6SR1CvAWIsgYt1/0zIppVDUqIRfXfcpL5LRQzyWX3eEwIqT 3jVjGidOjJ3cg8vLd2OZwvg8Dy2vZ2zTiDLcQsQ68yikhhp3zU2ZGxEkAYYesyXloqBH CqooGtajNNxvdN+4urd9szc0hKrSQDOiExMtVc2as9pAaFKmh4OHsxwM5PsxZLxJLcrj +3/WP/G4xvESLKeyx4e7o50gJVB1LvbSTLW9kxfA/kL9JEIVUd97M0Hh1+tA3VAGBrVh xO4g== 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=bTzdKFlLFxjEYXsTCiwTs/u3WhqgR0accwfx+BQVxCI=; b=lHjIxh6+ZH25MV2DBkaU+x97vAgA/8Iyx1NAvnLL2HALmLIUSxsDdbeUQLAQX4xVnf c31Deev5Z9yn0ryEzYoRnyUf8KOsrBIdpHOTnZxOpX8jHoGTsC2II/yFD4646KypnCtM rILEs+M93209x4i7Z5wHYG9hWMYJQFFkvA11tGmPDteBxQiaEki6hntc1Q8IVzPbP+sm 7bFrlU84gPFdavg15TCPnusXb1iINV+U9IOYIoYneqlaYdA9GIFXs4qkFVTJ9gpIHwcd YIAGKRX3HjDbQMfH9WBpp8ZrV2LcPcmtaOHq+Z5cdP9ul4G9crhdMAFlDCX4Z/8mzZor dX3w== X-Gm-Message-State: AOAM533k/dIlHB0jwtRX1TbYQ/xyiM6XRI9EmeQg9QtJvJ1PuQnHnnjD MQTtqSTwjEjCoNw+vgDTIIGJ61a2RQ1uJw== X-Google-Smtp-Source: ABdhPJxwNDSSmjNeJqV62003+UnO4NwEwDL1ymH1lO6taFm2VcGBtdhV0XI4gNiUZKyjtwz7IDhV0g== X-Received: by 2002:a17:902:6b83:b0:141:6368:3562 with SMTP id p3-20020a1709026b8300b0014163683562mr11401897plk.42.1635537806508; Fri, 29 Oct 2021 13:03:26 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id j16sm8775041pfj.16.2021.10.29.13.03.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 13:03:26 -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 v6 1/9] dt-bindings: PCI: correct brcmstb interrupts, interrupt-map. Date: Fri, 29 Oct 2021 16:03:09 -0400 Message-Id: <20211029200319.23475-2-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211029200319.23475-1-jim2101024@gmail.com> References: <20211029200319.23475-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 Fri Oct 29 20:03:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12593641 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 09DAEC433FE for ; Fri, 29 Oct 2021 20:03:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E13F96101E for ; Fri, 29 Oct 2021 20:03:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231144AbhJ2UGB (ORCPT ); Fri, 29 Oct 2021 16:06:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37132 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230397AbhJ2UF7 (ORCPT ); Fri, 29 Oct 2021 16:05:59 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3EB6C061714; Fri, 29 Oct 2021 13:03:29 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id x7so5190782pfh.7; Fri, 29 Oct 2021 13:03:29 -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=i/xlFeFGzhcgynIWoi7Dy7maGf++a2Lj0CJo9lD52eo=; b=GepHwVrZxe/sGAtgAU8y/aOWlfk5bidJZKMNnGKBvVhd1O0yS5ZYRsSnZs5PEupDOD XFh/8vpZICKn/+OD5sx6PcsEwM5EtZMdAmFgLVXQIfIIIhLe2ht3JKiXYzTcXov15tDs 04O+okmaQnyLH8PY/fX8La0HKBwZD62f2HF+uCsCUifL3BNyYDPOqsojH1eJB3xniGA7 SYpp7Jr/sq+NP1YoXCG7I+/fSy0jhpbjYOALDDOqlzO8TPFTOojDFoiI00a6WzyWLDyT YKa6eyT6ypCyuDBG7ZzQ9JBZhs07SOMpMrw4L/XiweSpu1zZeSMCUsD98qsUZFPe/UiT qZzg== 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=i/xlFeFGzhcgynIWoi7Dy7maGf++a2Lj0CJo9lD52eo=; b=PCv1EU+dyYkzfsRrM3DMLUPbBAzhRI994X46OcPzWlqEb23rhwaHZvp3KbdgO/t/GW qkT23tAvv6Lf0abYAb/uSUxrM8QhafAMmR4I4RCJC4wITIlit0IxQDeJz2XELlIgIBtL wgeqhxMBBgILOxyAIxrReoEJY+0CrgMon4KDmwapaVfL6gvBLSdMKlpn2ssm3YoOumFB /aO9UTpRs+M7arx8Y9nGsYZEQX2JamL1T8Fn8YkJ96yknngEALeFL8/fDNq6SxXCOkMr ogVG1SNGw23P7ubuCj4cfuxLA/4TxPFnZSUUYylDuS4L0ONJ0DKrc7f6FCx9VIrfft/F ao+Q== X-Gm-Message-State: AOAM532ODlkt7lOn3WiEmwEhi7Y1rFQTgaZzbegmxH8GLb9KXJmCrm+V coBnu/3vs1vN1OAtT5i5GWCIOsrnSrSPlw== X-Google-Smtp-Source: ABdhPJwvZSqQE/QbehqXCsHdQjyZTJdGYntsE57MxjyPpWUTC+sJLUK5O246dAdal1NwP+lGT+k1Hw== X-Received: by 2002:a62:754a:0:b0:47c:36b0:652 with SMTP id q71-20020a62754a000000b0047c36b00652mr12805931pfc.1.1635537809046; Fri, 29 Oct 2021 13:03:29 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id j16sm8775041pfj.16.2021.10.29.13.03.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 13:03:28 -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 v6 2/9] dt-bindings: PCI: Add bindings for Brcmstb EP voltage regulators Date: Fri, 29 Oct 2021 16:03:10 -0400 Message-Id: <20211029200319.23475-3-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211029200319.23475-1-jim2101024@gmail.com> References: <20211029200319.23475-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 | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml index 508e5dce1282..d90d867deb5c 100644 --- a/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml +++ b/Documentation/devicetree/bindings/pci/brcm,stb-pcie.yaml @@ -62,6 +62,10 @@ properties: aspm-no-l0s: true + vpcie12v-supply: true + vpcie3v3-supply: true + vpcie3v3aux-supply: true + brcm,scb-sizes: description: u64 giving the 64bit PCIe memory viewport size of a memory controller. There may be up to @@ -158,5 +162,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"; + 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"; + vpcie3v3-supply = <&vreg7>; + #address-cells = <3>; + #size-cells = <2>; + + ranges; + }; + }; }; }; From patchwork Fri Oct 29 20:03:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12593643 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 BF2DEC433EF for ; Fri, 29 Oct 2021 20:03:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A579960FED for ; Fri, 29 Oct 2021 20:03:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231245AbhJ2UGD (ORCPT ); Fri, 29 Oct 2021 16:06:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230504AbhJ2UGA (ORCPT ); Fri, 29 Oct 2021 16:06:00 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A309C061570; Fri, 29 Oct 2021 13:03:31 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id r28so10933062pga.0; Fri, 29 Oct 2021 13:03:31 -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=GIjfy/tGNtent3A9GnfPiCrIze+injINArkbcqn2zVE=; b=p+oAlOuiUVwiubxNDXtb5Ls8Dz9z5SXr5I3LZ0YJHmrSlX48A0HxNxBvlGEE8wAI3Y X8FJ1uRcQUhwBDqord3ZjwqnuHclhvoxY3jodljBl3RliRFfz/dx9cPcfAUIqd9Xth8K 2IuDrxzx+LdsTVm6t/UxMozCExb/+dK5nypbOpmiFkT4Ve65enJZF5b4lej6hP8dCvVd ZdgReamjmkybX8X4Corsg4kw42BRiS7/GXkcm6+PieHDkoFo8VjdzEsmu/uwjyQigJPG jPK6mqDCxnd2UaUz+XfcOWB19PMdYL+eek1NfIo577KdxJBlCGJEYFJL1uMGmjEU7T3f +8bw== 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=GIjfy/tGNtent3A9GnfPiCrIze+injINArkbcqn2zVE=; b=vf5Q8Yb9zuk05EIfRHmV2WjDyF5vbbqPXl79p4SSZmx90WIUkCZ6NQHQrfKZn3gv4z zNuPHdming7RZmZXOCW3SmiIbj9ba0eMjY+rxFxuqkiHKPpI17ieDFK5aGVC4uPOL2oq BmRJQraFX4X4KUeFViEqbJQgyxk/gX2IEe46PErGwIHesVQLtOPoen6vF2reSkPiWZvN 7Fl13hay1pq4/LvhU1wZiL1JIH4tjz0yil0YS48sxsue0Jye4MCEW8IaS5tfRovZblG2 nfKsvtYE8Zx6ntSzOPN/h4E7Ej2uQhomYLorX5+mb0zc6/TDZOvvoERilB6jZJ//8XLa 9kbQ== X-Gm-Message-State: AOAM531aeO4dDHURp+2KH6UR+gZ4oonSwvqOZkWbQ9YRu2FMYdIAONze 8QYoaUFjOXrT+13UhhipMRgfyfEUxlRqGg== X-Google-Smtp-Source: ABdhPJzxj7D8qpXxRVKpPoqOezXeQnpGkTqP0uawpq/cR8dn5DTZHWuwbA8spZhKN+VcNvbp0+yUsA== X-Received: by 2002:aa7:8b49:0:b0:44d:65a9:fb9d with SMTP id i9-20020aa78b49000000b0044d65a9fb9dmr12897641pfd.24.1635537810877; Fri, 29 Oct 2021 13:03:30 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id j16sm8775041pfj.16.2021.10.29.13.03.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 13:03:30 -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 v6 3/9] PCI: move pci_device_add() call Date: Fri, 29 Oct 2021 16:03:11 -0400 Message-Id: <20211029200319.23475-4-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211029200319.23475-1-jim2101024@gmail.com> References: <20211029200319.23475-1-jim2101024@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Move call to pci_device_add() from pci_scan_single_device() to pci_scan_device(). No other functions call pci_scan_device() so this should be harmless. Signed-off-by: Jim Quinlan --- drivers/pci/probe.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index d9fc02a71baa..f3fc807b4fe8 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2391,6 +2391,7 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) kfree(dev); return NULL; } + pci_device_add(dev, bus); return dev; } @@ -2540,13 +2541,7 @@ struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn) return dev; } - dev = pci_scan_device(bus, devfn); - if (!dev) - return NULL; - - pci_device_add(dev, bus); - - return dev; + return pci_scan_device(bus, devfn); } EXPORT_SYMBOL(pci_scan_single_device); From patchwork Fri Oct 29 20:03:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12593645 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 B24AEC4332F for ; Fri, 29 Oct 2021 20:03:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9931E60FED for ; Fri, 29 Oct 2021 20:03:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231129AbhJ2UGG (ORCPT ); Fri, 29 Oct 2021 16:06:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37152 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231169AbhJ2UGC (ORCPT ); Fri, 29 Oct 2021 16:06:02 -0400 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 69B59C061570; Fri, 29 Oct 2021 13:03:33 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id oa4so7921825pjb.2; Fri, 29 Oct 2021 13:03:33 -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=mqyNSe6MvQjNqCrZ6ODvlguuYfZXiuPpJnBJ1oYm5bA=; b=Dp8dJxNRzneNfNmUHTWUJrxMcMm6CKcXzdXAxbtTFl0JQmX63q4zhcM8NGb6RmWf6t bS2uoaagIgU0oKwHTBNA/5cVxcS/gwX9zt5OrdOCfYCTHnkDF/pRf5cNIqanNkEpQuU6 5gbzSYIQmFwyjdqwCOO4YTOAlFU6ZSYK6WM7xVSL3/Z17vjHJtEaQXPqXDzhWCRrq5gh e0UOlYX4/qsOlXoXfxdWAy6od1/RHinAcjYTSQSSMqqESbLxlrCv+JgPPXOQVmzbSzJt bVg3fiUlqffuX5+qGPLkOBEp946sRtketmjGw2gwlJwNBepQDTEM5P3Yl9ReueNd6A71 JGOA== 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=mqyNSe6MvQjNqCrZ6ODvlguuYfZXiuPpJnBJ1oYm5bA=; b=H2ShPWhcJc+50BT38OqVuY+D/8qYofKsy07x9YyceZs8nk3G4iK2lHbgjLmEu1a04r Clxbtwh/m4KdU8ZRvohwj28bQdZtlqj5B/HUMmXQx0UMnRg4+Oz0qBA1IRjg5+FETBde HlrPInfFixkHzHJoJdF75GcHAGLgJiYGDYetOjJJw9bCh+vWprtY9AJr6GKLee/MRbXN UW/vPzxUCIp153eUWkh9ZhH50v4b4QTw2FDtqnZTdEwCWrTDqbyC3OiwXjBERRK9Clin 1Kjdpzot4HX2G9D7qrcl0A3YFcX1CVC1EldjhfZP3R6LPgoHqOvFerHEdjA8GNCnjfZZ PqZA== X-Gm-Message-State: AOAM532uTj6ySUWVOJ7cgt+AR76WbFjofjtZmV/r8GEsmump8kiuEFwZ 1ttp0nww7f2naotkPKfr7gH682KLQR4D9A== X-Google-Smtp-Source: ABdhPJyu17y3WiVBqzNdl0nuYLkATpneyKPOgCs5w0Krbsr1qhfPFig0+ICxqfvknpxdHO07gb/ycg== X-Received: by 2002:a17:90b:224e:: with SMTP id hk14mr13837771pjb.224.1635537812766; Fri, 29 Oct 2021 13:03:32 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id j16sm8775041pfj.16.2021.10.29.13.03.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 13:03:32 -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 v6 4/9] PCI: separate device_initialize() from pci_device_add() Date: Fri, 29 Oct 2021 16:03:12 -0400 Message-Id: <20211029200319.23475-5-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211029200319.23475-1-jim2101024@gmail.com> References: <20211029200319.23475-1-jim2101024@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org Do this so that device_initialize() may be called separately (to prepare for an imminent commit). This change does reverse the invocation of these calls: pci_configure_device(dev); device_initialize(&dev->dev) to device_initialize(&dev->dev) pci_configure_device(dev); I reviewed this and didn't see any issue but it deserves mentioning. Signed-off-by: Jim Quinlan --- drivers/pci/iov.c | 1 + drivers/pci/probe.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/pci/iov.c b/drivers/pci/iov.c index dafdc652fcd0..baf5c1af47de 100644 --- a/drivers/pci/iov.c +++ b/drivers/pci/iov.c @@ -292,6 +292,7 @@ int pci_iov_add_virtfn(struct pci_dev *dev, int id) BUG_ON(rc); } + device_initialize(&virtfn->dev); pci_device_add(virtfn, virtfn->bus); rc = pci_iov_sysfs_link(dev, virtfn, id); if (rc) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index f3fc807b4fe8..0f092882b33f 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2391,6 +2391,7 @@ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) kfree(dev); return NULL; } + device_initialize(&dev->dev); pci_device_add(dev, bus); return dev; @@ -2491,7 +2492,6 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) pci_configure_device(dev); - device_initialize(&dev->dev); dev->dev.release = pci_release_dev; set_dev_node(&dev->dev, pcibus_to_node(bus)); From patchwork Fri Oct 29 20:03:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12593647 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 606CEC433EF for ; Fri, 29 Oct 2021 20:03:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 48B606101E for ; Fri, 29 Oct 2021 20:03:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231305AbhJ2UGH (ORCPT ); Fri, 29 Oct 2021 16:06:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231252AbhJ2UGE (ORCPT ); Fri, 29 Oct 2021 16:06:04 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64DB0C061714; Fri, 29 Oct 2021 13:03:35 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id v193so10186395pfc.4; Fri, 29 Oct 2021 13:03:35 -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=/xsefYqdfGM3gwTzp77+CzGEQFr/OK+AwnRYV+MylP4=; b=i0hWrQt4+laf0kcnMMYOv5YQ8hXTLb7pCnihggTiTil+fi/zsZ8JgL/rhL/w5ysYhb JceYMx8kbnySVv7amLjMbHI5byLOSptkC0zxDeFSGBiXYsW1nECeaTXY80ugXvyHIuZk Uq7Dr6NH9fgsZW589AThogunzmrsJMx9PCEnjYHgHRqZkqi6Y/Du+w1lmOKSzmEGE/tq QC8Cu6iEnxj71MAIZopzo/6zUIdlr8P5wgZItfZ6OJ4LaAxdhZZd+MyN3W7BrTHnj80d UjxIc/BoIln8U78CNGJnUstDVzzxzRGQNrL0jxJlSsja22aZPBAW9JrInCAltB5B+Wvk D6dQ== 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=/xsefYqdfGM3gwTzp77+CzGEQFr/OK+AwnRYV+MylP4=; b=S1gK77T3cL9/TgPvYEYeVko/xwqlgag+JyEXmDBo1Ix9usZZTyIEaeGEdrGsaBWEK+ 5jlf4lp1zZVnUXtKqR86V66JmmfOePoMCSaRMSg0iY2y2/stzTQx9Mm3oY35XnK/Jfq4 de/v/mUAjQhVrdJQgFWO1g46VCBQitl0w4nH8jV7vgpBlqWz2lvOomxusPyud7fleLVC ep3SeLGCqIU8xJkclAft4WmKDl2y+iisP83Wyht++0erpHFAf15TtD4J4BGvaYKVtYAY FZpl2UIf5QoX0IZxPFBH6KLff1KsenAPBDTYfzLsHQJ/Sp9kmHCG5Jx+cD9g/md2mS4a 1PEw== X-Gm-Message-State: AOAM530lgUgAYaH/xXgHACwR9TPkZKtGwURf76HsRvY/oxGtb6ICsMpS WwI9RXFO3ogRdNEi4M2sXSl+efoZv0wtHw== X-Google-Smtp-Source: ABdhPJxrDHmn9JZ3WxPtmokBaTHvh3WyD7lqBFP1ofhcVzk1p2e94AiCbFGCt2CUPnHz2RyaZ8ImTQ== X-Received: by 2002:a63:9348:: with SMTP id w8mr9876745pgm.325.1635537814688; Fri, 29 Oct 2021 13:03:34 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id j16sm8775041pfj.16.2021.10.29.13.03.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 13:03:34 -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 v6 5/9] PCI: allow for callback to prepare nascent subdev Date: Fri, 29 Oct 2021 16:03:13 -0400 Message-Id: <20211029200319.23475-6-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211029200319.23475-1-jim2101024@gmail.com> References: <20211029200319.23475-1-jim2101024@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org We would like the Broadcom STB PCIe root complex driver 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, 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. This commit solves the "chicken-and-egg" problem by providing a callback to the RC driver when a downstream device is "discovered" by inspecting its DT, and allowing said driver to allocate the device object prematurely in order to get the regulator(s) and turn them on before the device's ID is read. [1] These regulators typically govern the actual power supply to the endpoint chip. Sometimes they may be a 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 possible mean a switch as well. Signed-off-by: Jim Quinlan --- drivers/pci/probe.c | 52 ++++++++++++++++++++++++++++++++++----------- include/linux/pci.h | 4 ++++ 2 files changed, 44 insertions(+), 12 deletions(-) diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 0f092882b33f..8a58a9975ff6 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2372,29 +2372,57 @@ EXPORT_SYMBOL(pci_bus_read_dev_vendor_id); */ static struct pci_dev *pci_scan_device(struct pci_bus *bus, int devfn) { - struct pci_dev *dev; + struct pci_host_bridge *hb = pci_find_host_bridge(bus); + struct pci_dev *dev = NULL; + bool device_initialize_called = false; u32 l; - if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000)) - return NULL; + /* + * If the host bridge has a pci_subdev_can_prepare() function, call + * it to see if it "cares" about this device. If it does, + * partially allocate some of the device and call + * pci_subdev_prepare(). This tells it to allow the host bridge + * driver to pre-allocate some resources such as voltage + * regulators so that the pcie linkup can be established. + */ + if (hb->pci_subdev_can_prepare + && hb->pci_subdev_can_prepare(bus, devfn)) { + dev = pci_alloc_dev(bus); + if (!dev) + return NULL; - dev = pci_alloc_dev(bus); - if (!dev) - return NULL; + dev->devfn = devfn; + device_initialize(&dev->dev); + device_initialize_called = true; + if (hb->pci_subdev_prepare(bus, devfn, hb, dev) + || !pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000)) + goto err_out; + } else { + if (!pci_bus_read_dev_vendor_id(bus, devfn, &l, 60*1000)) + return NULL; + dev = pci_alloc_dev(bus); + if (!dev) + return NULL; + } dev->devfn = devfn; dev->vendor = l & 0xffff; dev->device = (l >> 16) & 0xffff; - if (pci_setup_device(dev)) { - pci_bus_put(dev->bus); - kfree(dev); - return NULL; - } - device_initialize(&dev->dev); + if (pci_setup_device(dev)) + goto err_out; + + if (!device_initialize_called) + device_initialize(&dev->dev); + pci_device_add(dev, bus); return dev; + +err_out: + pci_bus_put(dev->bus); + kfree(dev); + return NULL; } void pcie_report_downtraining(struct pci_dev *dev) diff --git a/include/linux/pci.h b/include/linux/pci.h index cd8aa6fce204..45ba24537ef2 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -552,6 +552,10 @@ struct pci_host_bridge { u8 (*swizzle_irq)(struct pci_dev *, u8 *); /* Platform IRQ swizzler */ int (*map_irq)(const struct pci_dev *, u8, u8); void (*release_fn)(struct pci_host_bridge *); + bool (*pci_subdev_can_prepare)(struct pci_bus *bus, int devfn); + int (*pci_subdev_prepare)(struct pci_bus *bus, int devfn, + struct pci_host_bridge *hb, + struct pci_dev *pdev); void *release_data; unsigned int ignore_reset_delay:1; /* For entire hierarchy */ unsigned int no_ext_tags:1; /* No Extended Tags */ From patchwork Fri Oct 29 20:03:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12593649 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 2ECF8C433FE for ; Fri, 29 Oct 2021 20:03:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 17B1B61038 for ; Fri, 29 Oct 2021 20:03:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231285AbhJ2UGI (ORCPT ); Fri, 29 Oct 2021 16:06:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231269AbhJ2UGG (ORCPT ); Fri, 29 Oct 2021 16:06:06 -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 A6C2BC061570; Fri, 29 Oct 2021 13:03:37 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id o6-20020a17090a0a0600b001a64b9a11aeso818962pjo.3; Fri, 29 Oct 2021 13:03:37 -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=qjSLHUXCDQWygnVlyrtmeX80jN8aeq1XvoNqVZbcgz3pWBNXh2WUTbMxhMcqf6Dy6L Y4b+BpSNhZm3TwUwIyJpnh7f9gY/5lESKlhSZmdENaKYakRR4wWQ2GAh40GPdp7Z5csi S55V7NyXufyKihgew1e11sQGlAkkspyYiGOvhjDaiPCWkge568MSaSuoJFqrHiZF6flb D6lAmbmbfPM4jB1keRmDH6qOEwYbUo49nk5ujBzeKcAqYt1VML7em0zYZYwk1uravbYj f7fabu+/GOWr9aP30GdqxwFQHniV9QABhzWk5Jx24yBOhjV1dHSpHt3duL95ucNnVCX2 rM9w== 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=B4KqN5zql6A73JQrBuSjZCucG2rjPRwFUCcx3hhUZi2qOLw5RVaoDoo8250pgHNv6d j6FtJcF0ax2m/pxpnem5VMx8+gNWfaf+WuxvhZ5HHXVWPYbgq6xBonj55z7CiKkLm0mF PLOYJbJOinSPufpsfQ7E8SH7gZKMM7qBznH0ugU3EFHKqBfODTTLOH4QFsbFL3pwp406 YheZAjwjnihS1UGuK/NVcfnVA7Tu2VfKuRFQtuz4q9n876rKYBvSFniJZVYKsDnWSbKV YnzDGjo+g5mhq5G/6shCuXNgwnWoo/Bdeh/35K4aUsUHRFipZB1X/mKKPWKN/1eA67ic adOg== X-Gm-Message-State: AOAM533tJMIldxrh2KWYiljBCcujqSs7KVq+E9lAgLalRwUZ63rKYmOE pHdRDk/KCffhv1+tiWGmQ5/39AS2sCMCPA== X-Google-Smtp-Source: ABdhPJz8kWh0F8QgJktCkgyP+kh03917s5z8vxLV8DEMrXsbHm9kC89imHO+DLcCD6SsMQdbqPK9cQ== X-Received: by 2002:a17:902:64c2:b0:141:c171:b99b with SMTP id y2-20020a17090264c200b00141c171b99bmr351680pli.55.1635537816878; Fri, 29 Oct 2021 13:03:36 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id j16sm8775041pfj.16.2021.10.29.13.03.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 13:03:36 -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 v6 6/9] PCI: brcmstb: split brcm_pcie_setup() into two funcs Date: Fri, 29 Oct 2021 16:03:14 -0400 Message-Id: <20211029200319.23475-7-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211029200319.23475-1-jim2101024@gmail.com> References: <20211029200319.23475-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 Fri Oct 29 20:03:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12593651 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 B801CC433F5 for ; Fri, 29 Oct 2021 20:03:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 996BD61039 for ; Fri, 29 Oct 2021 20:03:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230126AbhJ2UGK (ORCPT ); Fri, 29 Oct 2021 16:06:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231400AbhJ2UGJ (ORCPT ); Fri, 29 Oct 2021 16:06:09 -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 E5CA3C061714; Fri, 29 Oct 2021 13:03:39 -0700 (PDT) Received: by mail-pl1-x62b.google.com with SMTP id n18so7533496plc.2; Fri, 29 Oct 2021 13:03:39 -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=fs1h0oEJpXq+0v9+ITH8gAhhMpG3tKFNm2Sg0Y1iFCA=; b=AdSBhCOASd+zHNLdwvAGJ7h02CtSExXSpYpNdBAd9rvXWezBLKLb7ggDC7PUvR9NlE V34k00QzPQEAJhWOHF+JlGE5Oj36XP6JzwAdRYM8oRGMkXv/khoeVe6Zzz+pDQyzMvQR UgCJGH9nJ5/A90Kr0XRSargmAxXCb4U3RV2GIkE37RM7RQI9RjAsFnhheLF+qbsDbHEn FMMgu87v8vQkZD1esC1hDURGJE7sTMBzNICSXb0yHWuq4Se6DG6caQhu+lYWUNG7c8XG dX4mMz8/houceeN576nKHo2lBQJZ0aJ+l8Aye24Sv6+B41xI6+lZ1qKanQZNVP/eXvDE ENhw== 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=fs1h0oEJpXq+0v9+ITH8gAhhMpG3tKFNm2Sg0Y1iFCA=; b=x1Lvg63UVUGDDbZy/wByS5TYcoiKeGKUmw+4pHHQIk2fs3jZoCqf+Uu9wmh9ZP9TB1 +GvPLYbGGxnX5Yaz2PJzBBJ0/DSW+0ebvVVdBQYk/LaiGhteMqB/Avd2Jq3T/u3EnwEf /GPdPMEaCaa+ax5BGmNtywQ5VV24Fv19ud3xFbXHaGfQCTsfbrVOXcpdZNjauTKDgaiu 8W+eThfy6KrRYIFVgVCDcYzYHKELzPIlS6RxW7Cas7mPsIy2djh8n/17OA5pMTfMtoDa 4pJkkwK1XSt73Ogjj9P0uuUGB1UWLbqCLsazAd28dwltkut2/EjiZ9prtpvFmuzl+fyJ V8IQ== X-Gm-Message-State: AOAM530jH1zoTQTrBSaOJb+L5fik6/lMDF6lR2EB6Jvho7OoCa3rM+sZ xSs5oNXTqGwwOwZQ2nD63UumOvenfnhuyQ== X-Google-Smtp-Source: ABdhPJzUJR0JVVGnwuS2gERt1y/KK+57eHJfq2QYnEfBbNOGUl7HS2gfq8Em/+N7DoKVduEC6dWO8w== X-Received: by 2002:a17:902:bcc4:b0:141:bfc4:ada with SMTP id o4-20020a170902bcc400b00141bfc40adamr1112784pls.20.1635537819137; Fri, 29 Oct 2021 13:03:39 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id j16sm8775041pfj.16.2021.10.29.13.03.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 13:03:38 -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 v6 7/9] PCI: brcmstb: Add control of subdevice voltage regulators Date: Fri, 29 Oct 2021 16:03:15 -0400 Message-Id: <20211029200319.23475-8-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211029200319.23475-1-jim2101024@gmail.com> References: <20211029200319.23475-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 Reported-by: kernel test robot --- drivers/pci/controller/pcie-brcmstb.c | 164 +++++++++++++++++++++++++- 1 file changed, 162 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index ba4d6daf312c..6635e143cfcb 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 @@ -192,6 +193,12 @@ 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 const char * const supplies[] = { + "vpcie3v3", + "vpcie3v3aux", + "vpcie12v", +}; + enum { RGR1_SW_INIT_1, EXT_CFG_INDEX, @@ -295,8 +302,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 @@ -1148,6 +1185,59 @@ 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 pci_dev *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; + + pci_set_of_node(dev); + dn = dev->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; + + /* + * We set the name ahead of time as the regulator core expects + * it to exist when regulator_bulk_get() is called. + */ + dev_set_name(&dev->dev, "%04x:%02x:%02x.%d", + pci_domain_nr(dev->bus), + dev->bus->number, PCI_SLOT(dev->devfn), + PCI_FUNC(dev->devfn)); + /* + * We cannot use devm_regulator_bulk_get() because the + * downstream device may be removed w/o the regulator + * first being disabled by the host bridge. + */ + ret = regulator_bulk_get(&dev->dev, pcie->num_supplies, + pcie->supplies); + + return ret; +} + static int brcm_pcie_suspend(struct device *dev) { struct brcm_pcie *pcie = dev_get_drvdata(dev); @@ -1158,7 +1248,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 +1264,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) @@ -1217,6 +1310,10 @@ static void __brcm_pcie_remove(struct brcm_pcie *pcie) brcm_phy_stop(pcie); reset_control_rearm(pcie->rescal); clk_disable_unprepare(pcie->clk); + if (pcie->num_supplies) { + brcm_regulators_off(pcie); + regulator_bulk_free(pcie->num_supplies, pcie->supplies); + } } static int brcm_pcie_remove(struct platform_device *pdev) @@ -1241,6 +1338,57 @@ static const struct of_device_id brcm_pcie_match[] = { {}, }; +static bool brcm_pcie_pci_subdev_can_prepare(struct pci_bus *bus, int devfn) +{ + /* + * We only care about a device that is directly connected + * to the root complex, ie bus == 1 and slot == 0. + */ + return (bus->number == 1 && PCI_SLOT(devfn) == 0); +} + +static int brcm_pcie_pci_subdev_prepare(struct pci_bus *bus, int devfn, + struct pci_host_bridge *bridge, + struct pci_dev *pdev) +{ + struct brcm_pcie *pcie; + int ret = 0; + + pcie = (struct brcm_pcie *) bridge->sysdata; + ret = brcm_pcie_get_regulators(pcie, pdev); + if (ret) { + pcie->num_supplies = 0; + if (ret != -EPROBE_DEFER) + dev_err(pcie->dev, "failed to get regulators (err=%d)\n", ret); + return ret; + } + + ret = brcm_regulators_on(pcie); + if (ret) + goto err_out0; + + ret = brcm_pcie_linkup(pcie); + if (ret) + goto err_out1; + + /* + * dev_set_name() was called in brcm_get_regulators(). Free the + * string it allocated as it will be called again when + * pci_setup_device() is invoked. + */ + kfree_const(pdev->dev.kobj.name); + pdev->dev.kobj.name = NULL; + + return 0; + +err_out1: + brcm_regulators_off(pcie); +err_out0: + regulator_bulk_free(pcie->num_supplies, pcie->supplies); + pcie->num_supplies = 0; + return ret; +} + static int brcm_pcie_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node, *msi_np; @@ -1327,12 +1475,24 @@ static int brcm_pcie_probe(struct platform_device *pdev) } } + bridge->pci_subdev_can_prepare = brcm_pcie_pci_subdev_can_prepare; + bridge->pci_subdev_prepare = brcm_pcie_pci_subdev_prepare; bridge->ops = &brcm_pcie_ops; bridge->sysdata = pcie; 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 Fri Oct 29 20:03:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12593653 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 E5172C433F5 for ; Fri, 29 Oct 2021 20:03:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D430F6101E for ; Fri, 29 Oct 2021 20:03:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231403AbhJ2UGU (ORCPT ); Fri, 29 Oct 2021 16:06:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231271AbhJ2UGL (ORCPT ); Fri, 29 Oct 2021 16:06:11 -0400 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 1994AC061766; Fri, 29 Oct 2021 13:03:42 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id nn3-20020a17090b38c300b001a03bb6c4ebso8101908pjb.1; Fri, 29 Oct 2021 13:03:42 -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=xm4SxmqwuOzBa/eZu2FFd0i6Z3G+Vk7bausmQ5xw+Wk=; b=Ukpz40DOhJCbTS0qUysan/cT59elQe3QGvN3TqPOJ9ouYTGiABkDBzs0G1TJ2/++sy NZa+I1/MJ02SV0AyDQg+x4sIvcSelYgVP/IWVgX6WB69sY6bz1VDX2HELr47w3nzxFC6 jypWTJ9BUYStdK+qnKNDygx3BqwIE7Lw0XuWitHusQxOCE6QoqDMppBhQAIo18gc0g4q TgjhJNCa8R7+IDZFWfAWl73IkeIjGkoMHW/EMkWO+YjHKQaPerU35AftWjCs/dkofE9q eNh9WdNCqh0u15YoGMH2smxpI5r33H62uC0qGr8YeJxoxEJXuZQ04jJtcVIyMOzgMsnk EIvA== 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=xm4SxmqwuOzBa/eZu2FFd0i6Z3G+Vk7bausmQ5xw+Wk=; b=UF8hGdH3lT0zDggwQx3VJqw5N03/yskFYunNNipz0BlTSwBh2YxkhIjtLBvjSp36WM XI17P9xzQlbLYhN/od/GwkV69VHYfTEWIYMCQ2XKuQix3JCUP+jzs4yISZDYxo3ih1Pg yold68XFNm8a/od5yroBUoHGsvgjjVTJIbvT1nLMKxNRSiMI2vSFMuZTWo3IoG/iOkKr NHNcVWHgfAHKNRVIu+wiOeFeGQAxMwQ8kYh6m17dNIut3ib5RsFjSM/2p5BlcwCeeCxx pPaOiddcAztpvNgECyPds+bzm2gRgTa903En3dOShgPXk3dTP/zvtIPnJ4MLn5nkE134 fmcw== X-Gm-Message-State: AOAM532TuYgIvTeTotS3fwy/+uVdnPjjGyPmRtIaVUUefP9E6qaGyxKY VP3UWtYwO5lxq16U5HD5YzZBlqmRt3aYlg== X-Google-Smtp-Source: ABdhPJyBfG5E+MF9U5ej9v+kNG6zjDbhbmOpAJsBRFAGkk7Xi3emFFxmGH3ASKOyUClSZjy3uUvTeQ== X-Received: by 2002:a17:90b:33c7:: with SMTP id lk7mr13790866pjb.172.1635537821370; Fri, 29 Oct 2021 13:03:41 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id j16sm8775041pfj.16.2021.10.29.13.03.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 13:03:41 -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 v6 8/9] PCI: brcmstb: Do not turn off regulators if EP can wake up Date: Fri, 29 Oct 2021 16:03:16 -0400 Message-Id: <20211029200319.23475-9-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211029200319.23475-1-jim2101024@gmail.com> References: <20211029200319.23475-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 --- drivers/pci/controller/pcie-brcmstb.c | 49 ++++++++++++++++++++++++--- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 6635e143cfcb..18b9f7c97864 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -192,6 +192,7 @@ static inline void brcm_pcie_bridge_sw_init_set_generic(struct brcm_pcie *pcie, static inline void brcm_pcie_perst_set_4908(struct brcm_pcie *pcie, u32 val); static inline void brcm_pcie_perst_set_7278(struct brcm_pcie *pcie, u32 val); static inline void brcm_pcie_perst_set_generic(struct brcm_pcie *pcie, u32 val); +static bool brcm_pcie_link_up(struct brcm_pcie *pcie); static const char * const supplies[] = { "vpcie3v3", @@ -304,8 +305,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; @@ -313,6 +326,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"); @@ -320,13 +345,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"); @@ -1248,7 +1288,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) @@ -1264,6 +1304,7 @@ 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; @@ -1311,7 +1352,7 @@ static void __brcm_pcie_remove(struct brcm_pcie *pcie) reset_control_rearm(pcie->rescal); clk_disable_unprepare(pcie->clk); if (pcie->num_supplies) { - brcm_regulators_off(pcie); + brcm_regulators_off(pcie, true); regulator_bulk_free(pcie->num_supplies, pcie->supplies); } } @@ -1382,7 +1423,7 @@ static int brcm_pcie_pci_subdev_prepare(struct pci_bus *bus, int devfn, return 0; err_out1: - brcm_regulators_off(pcie); + brcm_regulators_off(pcie, true); err_out0: regulator_bulk_free(pcie->num_supplies, pcie->supplies); pcie->num_supplies = 0; From patchwork Fri Oct 29 20:03:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12593655 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 B736CC433F5 for ; Fri, 29 Oct 2021 20:04:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9DE686101E for ; Fri, 29 Oct 2021 20:04:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231269AbhJ2UG3 (ORCPT ); Fri, 29 Oct 2021 16:06:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231561AbhJ2UGS (ORCPT ); Fri, 29 Oct 2021 16:06:18 -0400 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 B3C6FC0613B9; Fri, 29 Oct 2021 13:03:47 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id v1-20020a17090a088100b001a21156830bso11427540pjc.1; Fri, 29 Oct 2021 13:03:47 -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=dR5goGjRH+faRSi6+pkacTGlwe5Jw734C5Ek8o+kxiM=; b=EO5UYp4d9BPAHCW1iVC6CevixytvZOW1wSqpJwVRSt21Xo3bykzvIiwMLlmnORyFEB 3iE6CBm7HdlZmceoiKQ6PhLdfV8n99raNFrZuvhpnlMlHbngfcHHPTqjcvVKjqdXnkr0 hOSSMjttoN0fULRdSKM3wC54QGW0x16arz1I12bIZnFIYrtOPfl11dD3MKPj5u1k3Qs7 yiaElWlN2u85si9nIDIl7MMdE1bpI8A/RlT7kAkK2qS/RYAAy2dO8y8rhB+Q53kDwQ2J mDbml3aLhSdbF2/NIusE9vsh7pKje8XDQEZDXsmOBdj0S2dX397i8F2XtSLkg/+HNAgd jN3g== 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=dR5goGjRH+faRSi6+pkacTGlwe5Jw734C5Ek8o+kxiM=; b=bQk6hWsr6ZaueCQ+9ofrYrO5cRd86CX2CSV6UaDSlgBe6HCKVMFWX2IdV/gYriCtQY tep2EV0tgD2CvefltnuNE0B6GPUIR6zmaQi/EO9pvSvRigYCWa0AzsDHtGi4N2VHIAlY GhvXCDLsq8pCeQZYwFt9PQumYfNaVPe5WIxH1jiMCjCuQQGGQLs9PQPuS3U/w/EXsFxO zcZpInnKipftEcNY+Mw/mHQsuxY2vWYZWx2Wz9czpzvHzkH9A7xHcznB0UbEiTezMb8N YsRBLdLCMUaiZe1M44AQo5jJHa+lx1gwyt1Wj/5rJjWy61Q0vpQ/+mIvEB+5itl46OUf WaEg== X-Gm-Message-State: AOAM532wH8vtSz2ab3wIbnGat3RIhZuI0zwx+O+SQStG6kOhCpxTSQnA KofGMPfSlc2xlA9M03ZKn6Rd8NdGyvsdIw== X-Google-Smtp-Source: ABdhPJxfHPZGaIHFIxsk4OqGM5oJw5NQuLdc00Tn5tag40VnL4M5tQXeStlEaSC90MV8JJb1Te1gcA== X-Received: by 2002:a17:90a:4e42:: with SMTP id t2mr13798887pjl.108.1635537823599; Fri, 29 Oct 2021 13:03:43 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.11.250]) by smtp.gmail.com with ESMTPSA id j16sm8775041pfj.16.2021.10.29.13.03.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Oct 2021 13:03:43 -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 v6 9/9] PCI: brcmstb: change brcm_phy_stop() to return void Date: Fri, 29 Oct 2021 16:03:17 -0400 Message-Id: <20211029200319.23475-10-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211029200319.23475-1-jim2101024@gmail.com> References: <20211029200319.23475-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 18b9f7c97864..c1f8fdb89cec 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -1196,9 +1196,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) @@ -1281,10 +1282,9 @@ static int brcm_pcie_get_regulators(struct brcm_pcie *pcie, struct pci_dev *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);