From patchwork Mon Jul 25 15:12:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12928249 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BF830C43334 for ; Mon, 25 Jul 2022 15:44:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=AZL2390ORnRzhfWKZSmGIm8Wpv1HFMs4zCDkJEeZGuQ=; b=oTo8rCZHg1g7Om OwheRmlUt3U3NW8TV7gqvakvU3RyF9uVBraNRw+yygtd7ZxXdLDgR1XbktsuXmjWbrB/jDiAGX1z4 kMmRRiaGZblPjme9Kt937aRTOzJ2kfVgzyZqH2+G1jrTp1cqfPZgWJzSm/TQ8oIfPYI931s6wC2q5 Qu1h1zTzFO6xQUL2ZZiIYORsRsWA9zgA5BM/DNx15fiJgGMquviyxMMp5MIVTcJ8dw8JYDcHV3QXA VWEVnvnLGHQi2YUV/KR4UUqAwy12kYogSNfax2S1NFf1P5uvM3BgQU4xtUwqtRR/NT5ybWIo0pmzV bSBvXdkP0CFwN3/Ui7qg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oG0FE-00FRD2-Ba; Mon, 25 Jul 2022 15:43:45 +0000 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oFzm4-00FH0F-Pm; Mon, 25 Jul 2022 15:13:38 +0000 Received: by mail-pg1-x531.google.com with SMTP id 12so10409014pga.1; Mon, 25 Jul 2022 08:13:34 -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=2t980Sr9Ua/t6NokOYt+cxt415QzejuNvLB89UJ9Rvo=; b=LFZ/s5HrtNGmw5hwkrLpfaC/dPfWZLUZjBAOiqFovZXKstFpV5dPgTResg2x0L9Nmw Y/FusNB7i4AY2rm3fgv6cKpgB+k1V/kj2G/uTASgyesGFKMbP1evibXRfmSLHe7TI4T/ iO/Tv4SCHthYZxJPdQVaq4QsPOfeJdvWDc022vRo+aKCOQmlCMABMcZrDl8VDHaAVmds IW2nzxDL8yb4hEkvmClggbKseAZ6m7tgT8PCQkSUqUnIJiNVjP1AFrklhFjbNsFc/naH UUBiHADaJ6dbBGP9PY0BtzKG+waRgE93t7y+R0/HuJvQnnsdwCkqT2IYJW47dgc16xeM /1/w== 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=2t980Sr9Ua/t6NokOYt+cxt415QzejuNvLB89UJ9Rvo=; b=KgW4QjyUJad+Cet8oX3VN1Rfe5KFUnCM7VsZRO3r/DV13EcJk1ZghgFDAjadVLJD+4 jQDMAtZs8cgSD1nVbf3hzmiaUIFBwgKc5En4Gf5PCtiGbD8/3Rfd0RNxb2jAqQZSF3XZ LCT5iloaESH5mzsbZtv2Y1X7DejbT+Wt3wvSxW1N6SHf0rqqw0PfVmfhzpYhaB7XU81e qAbtdf/Ece7HFHxHrULKVY5xak2gD5W9qbxnof2ctfHJsLLzveLq8BQOxtmk/G7DZRkk AVZoofSdRpDMiVu30r248B9fcLr+br6aUEI+/t5Z3qPiDVnIqIpBZmKOwWzarD8JrbjN yROg== X-Gm-Message-State: AJIora+vQzlCKKPfhpx8vPlfvz/hv2ewBcFnvolTBdVajdXkXu7tV1L6 Ea14SZuMJ+tQKNptZy6EnZ8= X-Google-Smtp-Source: AGRyM1vBMjzcaPknwMkhetj0IuXkME38zOiwmYRnY7TDo+E1HRoMdNkswHOyoRS0JWccp6y0YoAyEQ== X-Received: by 2002:aa7:9583:0:b0:52a:f076:5043 with SMTP id z3-20020aa79583000000b0052af0765043mr13423527pfj.9.1658762003654; Mon, 25 Jul 2022 08:13:23 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id a9-20020a170902ecc900b001641b2d61d4sm6649667plh.30.2022.07.25.08.13.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 08:13:23 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 1/7] PCI: brcmstb: Remove unnecessary forward declarations Date: Mon, 25 Jul 2022 11:12:50 -0400 Message-Id: <20220725151258.42574-2-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725151258.42574-1-jim2101024@gmail.com> References: <20220725151258.42574-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220725_081336_888307_965EA71E X-CRM114-Status: GOOD ( 14.42 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The forward function declarations in this driver are removed. Besides that, some constant structure definitions are moved towards a lower position in the file. There are no changes to the code that has been moved. Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 149 +++++++++++++------------- 1 file changed, 72 insertions(+), 77 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index e61058e13818..bd88a0a46c63 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -190,11 +190,6 @@ /* Forward declarations */ struct brcm_pcie; -static inline void brcm_pcie_bridge_sw_init_set_7278(struct brcm_pcie *pcie, u32 val); -static inline void brcm_pcie_bridge_sw_init_set_generic(struct brcm_pcie *pcie, u32 val); -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); enum { RGR1_SW_INIT_1, @@ -223,66 +218,6 @@ struct pcie_cfg_data { void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val); }; -static const int pcie_offsets[] = { - [RGR1_SW_INIT_1] = 0x9210, - [EXT_CFG_INDEX] = 0x9000, - [EXT_CFG_DATA] = 0x9004, -}; - -static const int pcie_offsets_bmips_7425[] = { - [RGR1_SW_INIT_1] = 0x8010, - [EXT_CFG_INDEX] = 0x8300, - [EXT_CFG_DATA] = 0x8304, -}; - -static const struct pcie_cfg_data generic_cfg = { - .offsets = pcie_offsets, - .type = GENERIC, - .perst_set = brcm_pcie_perst_set_generic, - .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, -}; - -static const struct pcie_cfg_data bcm7425_cfg = { - .offsets = pcie_offsets_bmips_7425, - .type = BCM7425, - .perst_set = brcm_pcie_perst_set_generic, - .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, -}; - -static const struct pcie_cfg_data bcm7435_cfg = { - .offsets = pcie_offsets, - .type = BCM7435, - .perst_set = brcm_pcie_perst_set_generic, - .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, -}; - -static const struct pcie_cfg_data bcm4908_cfg = { - .offsets = pcie_offsets, - .type = BCM4908, - .perst_set = brcm_pcie_perst_set_4908, - .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, -}; - -static const int pcie_offset_bcm7278[] = { - [RGR1_SW_INIT_1] = 0xc010, - [EXT_CFG_INDEX] = 0x9000, - [EXT_CFG_DATA] = 0x9004, -}; - -static const struct pcie_cfg_data bcm7278_cfg = { - .offsets = pcie_offset_bcm7278, - .type = BCM7278, - .perst_set = brcm_pcie_perst_set_7278, - .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_7278, -}; - -static const struct pcie_cfg_data bcm2711_cfg = { - .offsets = pcie_offsets, - .type = BCM2711, - .perst_set = brcm_pcie_perst_set_generic, - .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, -}; - struct brcm_msi { struct device *dev; void __iomem *base; @@ -775,18 +710,6 @@ static void __iomem *brcm_pcie_map_conf32(struct pci_bus *bus, unsigned int devf return base + DATA_ADDR(pcie); } -static struct pci_ops brcm_pcie_ops = { - .map_bus = brcm_pcie_map_conf, - .read = pci_generic_config_read, - .write = pci_generic_config_write, -}; - -static struct pci_ops brcm_pcie_ops32 = { - .map_bus = brcm_pcie_map_conf32, - .read = pci_generic_config_read32, - .write = pci_generic_config_write32, -}; - static inline void brcm_pcie_bridge_sw_init_set_generic(struct brcm_pcie *pcie, u32 val) { u32 tmp, mask = RGR1_SW_INIT_1_INIT_GENERIC_MASK; @@ -1316,6 +1239,66 @@ static int brcm_pcie_remove(struct platform_device *pdev) return 0; } +static const int pcie_offsets[] = { + [RGR1_SW_INIT_1] = 0x9210, + [EXT_CFG_INDEX] = 0x9000, + [EXT_CFG_DATA] = 0x9004, +}; + +static const int pcie_offsets_bmips_7425[] = { + [RGR1_SW_INIT_1] = 0x8010, + [EXT_CFG_INDEX] = 0x8300, + [EXT_CFG_DATA] = 0x8304, +}; + +static const struct pcie_cfg_data generic_cfg = { + .offsets = pcie_offsets, + .type = GENERIC, + .perst_set = brcm_pcie_perst_set_generic, + .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, +}; + +static const struct pcie_cfg_data bcm7425_cfg = { + .offsets = pcie_offsets_bmips_7425, + .type = BCM7425, + .perst_set = brcm_pcie_perst_set_generic, + .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, +}; + +static const struct pcie_cfg_data bcm7435_cfg = { + .offsets = pcie_offsets, + .type = BCM7435, + .perst_set = brcm_pcie_perst_set_generic, + .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, +}; + +static const struct pcie_cfg_data bcm4908_cfg = { + .offsets = pcie_offsets, + .type = BCM4908, + .perst_set = brcm_pcie_perst_set_4908, + .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, +}; + +static const int pcie_offset_bcm7278[] = { + [RGR1_SW_INIT_1] = 0xc010, + [EXT_CFG_INDEX] = 0x9000, + [EXT_CFG_DATA] = 0x9004, +}; + +static const struct pcie_cfg_data bcm7278_cfg = { + .offsets = pcie_offset_bcm7278, + .type = BCM7278, + .perst_set = brcm_pcie_perst_set_7278, + .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_7278, +}; + +static const struct pcie_cfg_data bcm2711_cfg = { + .offsets = pcie_offsets, + .type = BCM2711, + .perst_set = brcm_pcie_perst_set_generic, + .bridge_sw_init_set = brcm_pcie_bridge_sw_init_set_generic, +}; + static const struct of_device_id brcm_pcie_match[] = { { .compatible = "brcm,bcm2711-pcie", .data = &bcm2711_cfg }, { .compatible = "brcm,bcm4908-pcie", .data = &bcm4908_cfg }, @@ -1328,6 +1311,18 @@ static const struct of_device_id brcm_pcie_match[] = { {}, }; +static struct pci_ops brcm_pcie_ops = { + .map_bus = brcm_pcie_map_conf, + .read = pci_generic_config_read, + .write = pci_generic_config_write, +}; + +static struct pci_ops brcm_pcie_ops32 = { + .map_bus = brcm_pcie_map_conf32, + .read = pci_generic_config_read32, + .write = pci_generic_config_write32, +}; + static int brcm_pcie_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node, *msi_np; From patchwork Mon Jul 25 15:12:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12928246 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 997D7C43334 for ; Mon, 25 Jul 2022 15:41:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=lBd8VxAgtB3FbAtwxVVBhWYE25VFA8shZzsjztc5bjs=; b=CFNjAHrAtNtvy0 wswbSb303fE96p/TatmBvMQYiPRUpjfuYHKLvoA5GOd3ltzl7Sjm4/mGz0VoKsP3ysksybq+lU3IE 2W9Eh35A6gwemhCnulabD65WnufpS27zXeZDorXV1WX/XKgrwvYlOj7c0LMz3b5MNlFzmo8hs7Gv3 jhl4SEujh4E4/vU02pKLfkLBiKhy993lP+svzotW+MfPWM43+2w7MhHVNDJwd6NH3xnoM+WU2B+dg pPC4LIbIt2qn1QfrG1dGi010fznnXmomjHMB+KDo+ZO3MXO6cXaATfyAKGuiD9o45McpYVENl/LmZ 9tEt0W5NO1QFrzH2F1BA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oG0Bg-00FQ87-8i; Mon, 25 Jul 2022 15:40:05 +0000 Received: from mail-pg1-x533.google.com ([2607:f8b0:4864:20::533]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oFzm0-00FGyl-Ku; Mon, 25 Jul 2022 15:13:35 +0000 Received: by mail-pg1-x533.google.com with SMTP id q22so5477466pgt.9; Mon, 25 Jul 2022 08:13: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=nqXI0OBX6+3fPD9GB7eqkTNdkkNXz3BLLurSoXm4HMY=; b=hGZdKFYkmF90c02xvsh4TfWmzhRk35TqVrz2UXPDss5oWXIh5efjAMVqxnh9vYxcz3 xHhmwQJ1+gSPCXSYD/cbL4I/xAAzGjWwfkARCxHkJaOLsZHHrWQeAzNrIaSd88BlEiYP F7DmwbirPybTHYyzpO01qUxDP320aL/O8Javs2gKC8zTVzBvdlqhd1UlWgD5+Z6ZnVd8 maB0slKaLaxtaGkpxUMukcslUPUvr9lwXtxDiQXjsusIBe3T6oN6ciDhipuXmDBLH8A+ 2spdzBp/CJ53fuMR9bg4i1fjbOelqVWT33eCPUudAPyar81AhQW4u4KARfQvv+gO2ioA P0UQ== 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=nqXI0OBX6+3fPD9GB7eqkTNdkkNXz3BLLurSoXm4HMY=; b=Kbe5uWOsuDxBJnHpZ48fBF864NCZWryJfyPmsBso+qP/lVYj8gfdpR8tOVLB917GxM d13pUPvHkWqKL3VjBaZpKtyCP62ArWDw0C82clxi325adfN20i+wWDHRHfv1fUezmDdg Svy5nVOvokrYcp+IGYij+7f+EPqTyE55tBj039OnUTF5m6pu4VG1mg2ksEvHVnzFYY+y dC16RthykE4PCIz/KUlgEcPMB+SKFoCbtkqbXYGKpGYaR1XePEqTSuqzXJPAFMixl9UF PUp3ZZ3qEqLWaogrXg9yaZekdrC4IfTfZ4fb1tGd6UF4zIeXLGitj7Rl5mLf0M3aBE17 fO+g== X-Gm-Message-State: AJIora/CxOqzK2RqJLpTDoGXb0ni1g8Zomoz3R5+tKjjL6+yg7LdgjTN xr/HSCNqE9V4PCI5z1uNNC8= X-Google-Smtp-Source: AGRyM1tDMzwhzglh6zmMH0dTfmoPWhxUORzvFrGe51sd2pdmdOipPi6xw1FyIB9+SCslffXPs69U5w== X-Received: by 2002:a05:6a00:796:b0:52c:2d1:3ae0 with SMTP id g22-20020a056a00079600b0052c02d13ae0mr1888610pfu.52.1658762008159; Mon, 25 Jul 2022 08:13:28 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id a9-20020a170902ecc900b001641b2d61d4sm6649667plh.30.2022.07.25.08.13.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 08:13:27 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 2/7] PCI: brcmstb: Split brcm_pcie_setup() into two funcs Date: Mon, 25 Jul 2022 11:12:51 -0400 Message-Id: <20220725151258.42574-3-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725151258.42574-1-jim2101024@gmail.com> References: <20220725151258.42574-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220725_081332_762973_806EE7EF X-CRM114-Status: GOOD ( 26.08 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Currently, the function does the setup for establishing PCIe link-up with the downstream device, and it does the actual link-up as well. The calling sequence is (roughly) the following in the probe: -> brcm_pcie_probe() -> brcm_pcie_setup(); /* Set-up and link-up */ -> pci_host_probe(bridge); This commit splits the setup function in two: brcm_pcie_setup(), which only does the set-up, and brcm_pcie_start_link(), which only does the link-up. The reason why we are doing this is to lay a foundation for subsequent commits so that we can turn on any power regulators, as described in the root port's DT node, prior to doing link-up. We do this by defining an add_bus() callback which is invoked during enumeration. At the end of this patchset the probe function trace will look something like this: -> brcm_pcie_probe() -> brcm_pcie_setup(); /* Set-up only */ -> pci_host_probe(bridge); -> [enumeration] -> pci_alloc_child_bus() -> bus->ops->add_bus(bus); /* We've set this op */ -> brcm_pcie_add_bus() /* Our callback */ -> [turn on regulators] /* Main objective! */ -> brcm_pcie_start_link() /* Link-up */ One final note: some code that was executed after the PCIe linkup is now placed so that it executes prior to linkup, since this code has to run prior to the invocation of pci_host_probe(). Link: https://lore.kernel.org/r/20220106160332.2143-5-jim2101024@gmail.com Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 111 +++++++++++++++----------- 1 file changed, 64 insertions(+), 47 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index bd88a0a46c63..15e47e8c94eb 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -849,17 +849,13 @@ 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 pci_host_bridge *bridge; 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 num_out_wins = 0; + int ret, memc; /* Reset the bridge */ pcie->bridge_sw_init_set(pcie, 1); @@ -935,6 +931,11 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie) else pcie->msi_target_addr = BRCM_MSI_TARGET_ADDR_GT_4GB; + if (!brcm_pcie_rc_mode(pcie)) { + dev_err(pcie->dev, "PCIe RC controller misconfigured as Endpoint\n"); + return -EINVAL; + } + /* disable the PCIe->GISB memory window (RC_BAR1) */ tmp = readl(base + PCIE_MISC_RC_BAR1_CONFIG_LO); tmp &= ~PCIE_MISC_RC_BAR1_CONFIG_LO_SIZE_MASK; @@ -945,31 +946,27 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie) tmp &= ~PCIE_MISC_RC_BAR3_CONFIG_LO_SIZE_MASK; writel(tmp, base + PCIE_MISC_RC_BAR3_CONFIG_LO); - if (pcie->gen) - brcm_pcie_set_gen(pcie, pcie->gen); - - /* Unassert the fundamental reset */ - pcie->perst_set(pcie, 0); + /* Don't advertise L0s capability if 'aspm-no-l0s' */ + aspm_support = PCIE_LINK_STATE_L1; + if (!of_property_read_bool(pcie->np, "aspm-no-l0s")) + aspm_support |= PCIE_LINK_STATE_L0S; + tmp = readl(base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY); + u32p_replace_bits(&tmp, aspm_support, + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK); + writel(tmp, base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY); /* - * Give the RC/EP time to wake up, before trying to configure RC. - * Intermittently check status for link-up, up to a total of 100ms. + * For config space accesses on the RC, show the right class for + * a PCIe-PCIe bridge (the default setting is to be EP mode). */ - for (i = 0; i < 100 && !brcm_pcie_link_up(pcie); i += 5) - msleep(5); - - if (!brcm_pcie_link_up(pcie)) { - dev_err(dev, "link down\n"); - return -ENODEV; - } - - if (!brcm_pcie_rc_mode(pcie)) { - dev_err(dev, "PCIe misconfigured; is in EP mode\n"); - return -EINVAL; - } + tmp = readl(base + PCIE_RC_CFG_PRIV1_ID_VAL3); + u32p_replace_bits(&tmp, 0x060400, + PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK); + writel(tmp, base + PCIE_RC_CFG_PRIV1_ID_VAL3); + bridge = pci_host_bridge_from_priv(pcie); resource_list_for_each_entry(entry, &bridge->windows) { - res = entry->res; + struct resource *res = entry->res; if (resource_type(res) != IORESOURCE_MEM) continue; @@ -998,23 +995,41 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie) num_out_wins++; } - /* Don't advertise L0s capability if 'aspm-no-l0s' */ - aspm_support = PCIE_LINK_STATE_L1; - if (!of_property_read_bool(pcie->np, "aspm-no-l0s")) - aspm_support |= PCIE_LINK_STATE_L0S; - tmp = readl(base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY); - u32p_replace_bits(&tmp, aspm_support, - PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK); - writel(tmp, base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY); + /* PCIe->SCB endian mode for BAR */ + tmp = readl(base + PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1); + u32p_replace_bits(&tmp, PCIE_RC_CFG_VENDOR_SPCIFIC_REG1_LITTLE_ENDIAN, + PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1_ENDIAN_MODE_BAR2_MASK); + writel(tmp, base + PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1); + + return 0; +} + +static int brcm_pcie_start_link(struct brcm_pcie *pcie) +{ + struct device *dev = pcie->dev; + void __iomem *base = pcie->base; + u16 nlw, cls, lnksta; + bool ssc_good = false; + u32 tmp; + int ret, i; + + /* Unassert the fundamental reset */ + pcie->perst_set(pcie, 0); /* - * For config space accesses on the RC, show the right class for - * a PCIe-PCIe bridge (the default setting is to be EP mode). + * Give the RC/EP time to wake up, before trying to configure RC. + * Intermittently check status for link-up, up to a total of 100ms. */ - tmp = readl(base + PCIE_RC_CFG_PRIV1_ID_VAL3); - u32p_replace_bits(&tmp, 0x060400, - PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK); - writel(tmp, base + PCIE_RC_CFG_PRIV1_ID_VAL3); + for (i = 0; i < 100 && !brcm_pcie_link_up(pcie); i += 5) + msleep(5); + + if (!brcm_pcie_link_up(pcie)) { + dev_err(dev, "link down\n"); + return -ENODEV; + } + + if (pcie->gen) + brcm_pcie_set_gen(pcie, pcie->gen); if (pcie->ssc) { ret = brcm_pcie_set_ssc(pcie); @@ -1031,12 +1046,6 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie) pci_speed_string(pcie_link_speed[cls]), nlw, ssc_good ? "(SSC)" : "(!SSC)"); - /* PCIe->SCB endian mode for BAR */ - tmp = readl(base + PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1); - u32p_replace_bits(&tmp, PCIE_RC_CFG_VENDOR_SPCIFIC_REG1_LITTLE_ENDIAN, - PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1_ENDIAN_MODE_BAR2_MASK); - writel(tmp, base + PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1); - /* * Refclk from RC should be gated with CLKREQ# input when ASPM L0s,L1 * is enabled => setting the CLKREQ_DEBUG_ENABLE field to 1. @@ -1204,6 +1213,10 @@ static int brcm_pcie_resume(struct device *dev) if (ret) goto err_reset; + ret = brcm_pcie_start_link(pcie); + if (ret) + goto err_reset; + if (pcie->msi) brcm_msi_set_regs(pcie->msi); @@ -1393,6 +1406,10 @@ static int brcm_pcie_probe(struct platform_device *pdev) if (ret) goto fail; + ret = brcm_pcie_start_link(pcie); + if (ret) + goto fail; + pcie->hw_rev = readl(pcie->base + PCIE_MISC_REVISION); if (pcie->type == BCM4908 && pcie->hw_rev >= BRCM_PCIE_HW_REV_3_20) { dev_err(pcie->dev, "hardware revision with unsupported PERST# setup\n"); From patchwork Mon Jul 25 15:12:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12928247 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 731C1C433EF for ; Mon, 25 Jul 2022 15:42:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=xRK8tXG1YEO8WLA7yJl+P5xuuurHdKlc092y2/yaDmk=; b=lnGZtjmzkq/eLU ahVKeOJNdRKje4b1nS7HrJa3Q/E9x3vP9mcEGASQC9PNepiE96UiWUTB3pY2IDSaHeX+9mOP2ekEj Pjbnc/nQCYARCaGcaFzzX4/oNK5zUzQnsqs3RHakiisNQ88Y40SNvRKhN8o1btloBqlWLAyM/e0I/ OVinPeV59sS3RTwly5U7rWbeF+pm8Wj8Mf3uoxPu/aQixIYWcG98Ue+cQhXzW24+agS+/7MA9RKAj rOR7Iusjo5QilozL0J8Hh+6bVq1cZJKnQExWiJktigcMNZH1SiQpsGhIsRRyz+jAxvbaJNYx7DWoC G0/Km3s1BZPK/c4ILJkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oG0Cy-00FQVO-9u; Mon, 25 Jul 2022 15:41:25 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oFzm2-00FGyq-Hu; Mon, 25 Jul 2022 15:13:36 +0000 Received: by mail-pf1-x434.google.com with SMTP id o12so10690124pfp.5; Mon, 25 Jul 2022 08:13: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=xI+CaZm7AHUscnYqQYFqdG4FTtSq1DoKhCMhOBlS3fE=; b=OnY0rVF2m4WIM7h85TZx9pPO4Ehy+e7cElKMLbhxoh4Zh+DI9SuU0o4MYVdIyG4pZA RhzWlN3yZVHjFgM+aV1Y2PbYEqlyRrlP1QXUbzGV5ZrrFibslr6UxAameeDC+DdZm1A1 KPhHw2JNlf2UwhjE6CsMI0NgdFbsJGxWJpkGo/qVJMRqw0vuqBWNlesw7T4ZqdTl5VH4 akvrzqLP6ZiY3wCVP5IKao6HfOJ8cJipDWTkOSams7ApAFBPjrMjPZ/HJBWQW2QXjs7C SWPwWT/vHciN6c/qVrYUZuana8iJltVeCPgkn3FaUGlOJiboBq3Ryk/faQhgu2PN9XMb 9VJQ== 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=xI+CaZm7AHUscnYqQYFqdG4FTtSq1DoKhCMhOBlS3fE=; b=aUgoX2uHONn4a9h7Y/Y15C5gGxNPKkTWxNFGoVLUXtIhqku/qcsC0nDNQeFXmIMrl7 4H36HQt6iMX+Wy3cNg/EbizFZDOvr/b1IMHOPGEHxkd5G3NrJuOyjQnHrip21g84LDZg om5XUZQz6uBC+DfxAlWoJACMyqUjERNTOLmkXaXTbZm6vS1GQR8cEQmFrKC3NTaJiqe4 sTDJq7RAbtPWAKbQMIHgwxFnjhW3TxOeCnesBSgoFhhcUXRFlQoSjckFOxQbHfme2sRS itVnWAscWC5kwfz7wq3xt9ugsx+MW1qRuo6vio/tWGX8YDGnokVp0JaWLNkrqD/PIema +g7g== X-Gm-Message-State: AJIora+izShs2Y6EnJloMsk3LdnthGRm03rbKyYK6WShjHg6oklM7BbR JshOT0jfPo7Fa81iHUEhuvU= X-Google-Smtp-Source: AGRyM1vsa4Y8EuFQldpA75OhwPbn8kQCUj/eHUetPEinSfboGW+WPPmgHmfunyGl0wLyXyWb2gr+bg== X-Received: by 2002:aa7:888a:0:b0:52b:17e8:fd1 with SMTP id z10-20020aa7888a000000b0052b17e80fd1mr13249304pfe.46.1658762011028; Mon, 25 Jul 2022 08:13:31 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id a9-20020a170902ecc900b001641b2d61d4sm6649667plh.30.2022.07.25.08.13.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 08:13:30 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 3/7] PCI: brcmstb: Gate config space access on link status Date: Mon, 25 Jul 2022 11:12:52 -0400 Message-Id: <20220725151258.42574-4-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725151258.42574-1-jim2101024@gmail.com> References: <20220725151258.42574-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220725_081334_652267_599C50C4 X-CRM114-Status: GOOD ( 14.18 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Our PCIe RC HW has an atypical behavior: if it does not have PCIe link established between itself and downstream, any subsequent config space access for a downstream device causes a CPU abort. This commit allows a config space access for dowwnstream devices only if the PCIe link is up. Note that config space accesses to the root port are diverted to the RC registers and are honored regardless of link status. Some other minor changes are also made: (1) limit the "where" offset to 4K and (2) reject RC accesses if devfn != 0. Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 15e47e8c94eb..3443206d2a95 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -683,14 +683,18 @@ static void __iomem *brcm_pcie_map_conf(struct pci_bus *bus, unsigned int devfn, void __iomem *base = pcie->base; int idx; - /* Accesses to the RC go right to the RC registers if slot==0 */ + /* Accesses to the RC go right to the RC registers if !devfn */ if (pci_is_root_bus(bus)) - return PCI_SLOT(devfn) ? NULL : base + where; + return devfn ? NULL : base + (where & 0xfff); + + /* An access to our HW w/o link-up will cause a CPU Abort */ + if (!brcm_pcie_link_up(pcie)) + return NULL; /* For devices, write to the config space index register */ idx = PCIE_ECAM_OFFSET(bus->number, devfn, 0); writel(idx, pcie->base + PCIE_EXT_CFG_INDEX); - return base + PCIE_EXT_CFG_DATA + where; + return base + PCIE_EXT_CFG_DATA + (where & 0xfff); } static void __iomem *brcm_pcie_map_conf32(struct pci_bus *bus, unsigned int devfn, @@ -700,12 +704,16 @@ static void __iomem *brcm_pcie_map_conf32(struct pci_bus *bus, unsigned int devf void __iomem *base = pcie->base; int idx; - /* Accesses to the RC go right to the RC registers if slot==0 */ + /* Accesses to the RC go right to the RC registers if !devfn */ if (pci_is_root_bus(bus)) - return PCI_SLOT(devfn) ? NULL : base + (where & ~0x3); + return devfn ? NULL : base + (where & 0xffc); + + /* An access to our HW w/o link-up will cause a CPU Abort */ + if (!brcm_pcie_link_up(pcie)) + return NULL; /* For devices, write to the config space index register */ - idx = PCIE_ECAM_OFFSET(bus->number, devfn, (where & ~3)); + idx = PCIE_ECAM_OFFSET(bus->number, devfn, (where & 0xffc)); writel(idx, base + IDX_ADDR(pcie)); return base + DATA_ADDR(pcie); } From patchwork Mon Jul 25 15:12:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12928248 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 541AAC433EF for ; Mon, 25 Jul 2022 15:43:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=frXAFz61ZZjlRl2YsFMXTSM8d0h3/xm8nUkQrcFAdbQ=; b=ExV7rtXEU9Dy2k RrTdeztL6PVaVQP3hSlQYJotUnUjH6oKHsh06CXjWqKKYI7+GTzbDcAyf5E1qKlzJtyw/WvWIjgSh 6FluQM3Vr0R3D5eGr4nE8cYKWfNu22zahBDzTKaGzeUq1tIjpShRAq3OjVi2f92t+SWXRhr8J92sI KCHDldhiA8vUk7J/1dto3QO9s7926kjzEw8GSDAZs/CqNfgRoryDHydAXflaWEN55oRsJaGgqCdLO 4EOrBr3oKjWP9Db+lpsl1392JeO1o0/frubdXj+HjRq34NqfznJKcF5YwuNy2Jiuar4qt8Og+y25n km/llMXTDoJRKayXPKzw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oG0E5-00FQq1-IS; Mon, 25 Jul 2022 15:42:34 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oFzm3-00FH0B-Qe; Mon, 25 Jul 2022 15:13:38 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d7so10659398plr.9; Mon, 25 Jul 2022 08:13:34 -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=edERAY+W+H8xhkt0YCtw/+TrmSGvoLSrgsbiPZWxo1M=; b=UDP6QyDPlufFmbTy8VQCrHP42wyCskSWjF2zPuud5pMczdl6GbM6D8bN89NWSZ4hQQ tF/pJakz0tYHrYxexzU1aNRfQ9TLRFKRLCglMYcW77K2Ydx1qN76V3huI1jU7X6KdqRr OLPib1LuuE6so0BUWiDxC+aL6Sm7aITXo0OH8zzr+CiFaOWuIBi8pg/J1QiHSHD7yWUj bgEohqYHOk0z7Znhfd1hO0uO91Ul9KvTsgqw8UdP7W0AxXhTdtxotsgObo/uwtXPUqT+ FRc7Teddza1fGCnJSsGHp+uArSwJoaPMHrt5EKmlBPV4aI2rObaSZkJhC+QABPcB3JSQ 4+eg== 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=edERAY+W+H8xhkt0YCtw/+TrmSGvoLSrgsbiPZWxo1M=; b=cg8SimlFB/TY78WxAoZ7CMqPcptlYUwiHdKgAZknv0SplmwAImDVYMT2JEYWRzcIdE ND33ieIMHyg9KP1at0eFpFRs6aB0A3LNPzCDBTRf/yA3bUeGDcoArSzCO3PNLbWzTRG4 O/20HeCUYAgbXS2AUIM1HYC38IRFDGSYHH8ulNkQVl46h4Aob9XCPMds79sw/nmD9ncq OAT2B6VaAItCSXDt2fFwDoqq9rN2dSRJUuNuotsN/wfpk4PvZpbiFUUGWtS6U8QG7PbA NIqoKwkNMm4rPZpoIok+8LDBNypzRH3d8sZSeA8pRftRuslxIgKm31rIbcRmLkspHLM0 rukQ== X-Gm-Message-State: AJIora/I+8JpJ/+gyM5wfyxxgiBWXyKAayd000NzLWay5FfsOU1DnFrI b4pvQ9Fvd73Fo8HWGI8dSyw= X-Google-Smtp-Source: AGRyM1sSUDuX+xnwkkAVMFJXj5KVqkNcQeCnhtjYu7jL33O/Td6gUjb2DbJFnpP9PujuFAk2qrMr7Q== X-Received: by 2002:a17:90a:9b03:b0:1f1:85b2:c52b with SMTP id f3-20020a17090a9b0300b001f185b2c52bmr33387441pjp.159.1658762013809; Mon, 25 Jul 2022 08:13:33 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id a9-20020a170902ecc900b001641b2d61d4sm6649667plh.30.2022.07.25.08.13.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 08:13:33 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 4/7] PCI: brcmstb: Add mechanism to turn on subdev regulators Date: Mon, 25 Jul 2022 11:12:53 -0400 Message-Id: <20220725151258.42574-5-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725151258.42574-1-jim2101024@gmail.com> References: <20220725151258.42574-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220725_081335_912997_D4C72C4E X-CRM114-Status: GOOD ( 33.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Add a mechanism to identify standard PCIe regulators in the DT, allocate them, and turn them on before the rest of the bus is scanned during pci_host_probe(). The allocated structure that contains the regulators is stored in the port driver dev.driver_data field. Here is a point-by-point of how and when this mechanism is activated: If: -- PCIe RC driver sets pci_ops {add,remove)_bus to pci_subdev_regulators_{add,remove}_bus during its probe. -- There is a root port DT node under the host bridge DT node. -- During the RC driver's pci_host_probe() the add_bus callback is invoked where (bus->parent && pci_is_root_bus(bus->parent) is true Then: -- A struct subdev_regulators structure will be allocated and assigned to bus->dev.driver_data. -- regulator_bulk_{get,enable} will be invoked on &bus->dev and the former will search for and process any vpcie{12v,3v3,3v3aux}-supply properties that reside in the root port DT node. -- The regulators will be turned off/on for any unbind/bind operations. -- The regulators will be turned off/on for any suspend/resumes, but only if the RC driver handles this on its own. This will appear in a later commit for the pcie-brcmstb.c driver. The unabridged reason for doing this is as follows. We would like the Broadcom STB PCIe root complex driver (and others) to be able to turn off/on standard PCIe regulators. Typically, the drivers of endpoint devices are stock Linux drivers that are not aware that these regulator(s) exist and must be turned on for the driver to be probed. The simple solution of course is to turn these regulators on at boot and keep them on. However, this solution does not satisfy at least three of our usage modes: 1. For example, one customer uses multiple PCIe controllers, but wants the ability to, by script invoking and unbind, turn any or all of them 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 the PCIe endpoint device needs to be kept powered on in order to receive network packets and wake the system. In all of these cases it is advantageous for the PCIe controller to govern the turning off/on the regulators needed by the endpoint device. The first two cases can be done by simply unbinding and binding the PCIe controller, if the controller has control of these regulators. [1] The 99% configuration of our boards is a single endpoint device attached to the PCIe controller. I use the term endpoint but it could possibly mean a switch as well. Link: https://lore.kernel.org/r/20220106160332.2143-6-jim2101024@gmail.com Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 96 +++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 3443206d2a95..1be6e71142d8 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 @@ -218,6 +219,11 @@ struct pcie_cfg_data { void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val); }; +struct subdev_regulators { + unsigned int num_supplies; + struct regulator_bulk_data supplies[]; +}; + struct brcm_msi { struct device *dev; void __iomem *base; @@ -1065,6 +1071,92 @@ static int brcm_pcie_start_link(struct brcm_pcie *pcie) return 0; } +static const char * const supplies[] = { + "vpcie3v3", + "vpcie3v3aux", + "vpcie12v", +}; + +static void *alloc_subdev_regulators(struct device *dev) +{ + const size_t size = sizeof(struct subdev_regulators) + + sizeof(struct regulator_bulk_data) * ARRAY_SIZE(supplies); + struct subdev_regulators *sr; + int i; + + sr = devm_kzalloc(dev, size, GFP_KERNEL); + if (sr) { + sr->num_supplies = ARRAY_SIZE(supplies); + for (i = 0; i < ARRAY_SIZE(supplies); i++) + sr->supplies[i].supply = supplies[i]; + } + + return sr; +} + +static int pci_subdev_regulators_add_bus(struct pci_bus *bus) +{ + struct device *dev = &bus->dev; + struct subdev_regulators *sr; + int ret; + + if (!dev->of_node || !bus->parent || !pci_is_root_bus(bus->parent)) + return 0; + + if (dev->driver_data) { + /* + * Oops, this is unfortunate. We are using the port + * driver's driver_data field to store our regulator info + * and it appears that another driver started using it as + * well. If so, be a team player do not overwrite it. We + * may still be okay if there are no regulators. + */ + dev_err(dev, "root port dev.driver_data non-NULL; something wrong\n"); + return 0; + } + + sr = alloc_subdev_regulators(dev); + if (!sr) + return -ENOMEM; + + /* + * There is not much of a point to return an error as currently it + * will cause a WARNING() from pci_alloc_child_bus(). So only + * return the error if it is -ENOMEM. Note that we are always + * doing a dev_err() for other erros. + */ + ret = regulator_bulk_get(dev, sr->num_supplies, sr->supplies); + if (ret) { + dev_err(dev, "failed to get regulators for downstream device\n"); + return 0; + } + + ret = regulator_bulk_enable(sr->num_supplies, sr->supplies); + if (ret) { + dev_err(dev, "failed to enable regulators for downstream device\n"); + regulator_bulk_free(sr->num_supplies, sr->supplies); + return 0; + } + + dev->driver_data = sr; + + return 0; +} + +static void pci_subdev_regulators_remove_bus(struct pci_bus *bus) +{ + struct device *dev = &bus->dev; + struct subdev_regulators *sr = dev->driver_data; + + if (!dev->of_node || !sr || !bus->parent || !pci_is_root_bus(bus->parent)) + return; + + if (regulator_bulk_disable(sr->num_supplies, sr->supplies)) + dev_err(dev, "failed to disable regulators for downstream device\n"); + regulator_bulk_free(sr->num_supplies, sr->supplies); + dev->driver_data = NULL; +} + /* L23 is a low-power PCIe link state */ static void brcm_pcie_enter_l23(struct brcm_pcie *pcie) { @@ -1336,12 +1428,16 @@ static struct pci_ops brcm_pcie_ops = { .map_bus = brcm_pcie_map_conf, .read = pci_generic_config_read, .write = pci_generic_config_write, + .add_bus = pci_subdev_regulators_add_bus, + .remove_bus = pci_subdev_regulators_remove_bus, }; static struct pci_ops brcm_pcie_ops32 = { .map_bus = brcm_pcie_map_conf32, .read = pci_generic_config_read32, .write = pci_generic_config_write32, + .add_bus = pci_subdev_regulators_add_bus, + .remove_bus = pci_subdev_regulators_remove_bus, }; static int brcm_pcie_probe(struct platform_device *pdev) From patchwork Mon Jul 25 15:12:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12928250 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5BEE5C43334 for ; Mon, 25 Jul 2022 15:46:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ir51RGQIcxTMmbZnvTa2sgLFA2w5UhDfaeBdDOi67KY=; b=t16/CT7n1ybo3y QLDdNyPyVcEDHaLmSsCWXBSkAuOTYeM6x7Xzp5jydNKXy/8eKmU1OudSVoBffpLFTlv4/0NfEbWoh PY2HAK7zrr99kuMx5Dj+acYlKOELkMHp7iqrZ7XPQZ6c3Gtot+JTLcgmtbULyPFWL00PaPHfUMmNd AtQ+jWB5XgbUx8YGn+LAizgV2mxxkvrt96fdzF+Lfn3+030i8kkbGpBwvW8WT8ipgaBPgza/1vhMv AFNJBKi+db6u980QkXZZ1n53dKVJPA0P8n/09zEzKedL4TORyt08O7Qibx19Nb49wTlRuZOQriZMW gmc8MTCuvBo+Z7f3AonA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oG0GI-00FRZX-Tu; Mon, 25 Jul 2022 15:44:51 +0000 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oFzm7-00FH1i-O7; Mon, 25 Jul 2022 15:13:41 +0000 Received: by mail-pj1-x1032.google.com with SMTP id e1so173717pjl.1; Mon, 25 Jul 2022 08:13: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=JE8bRC6uYHCtiV8R8EE5D5GYSiT8jkroOdZWcPrNIso=; b=dJPeHC17hBf5NkCv/C83Oow9fLbq2L9cbdIVaIvvEUSgLtdOZ2BsIevw0UK4GWIdpT UdPxLsui6l4A1Hrz/VlNNftUqOgSuWGcg3ajaQgRTYke+lNBhKmYiKpCGf/YLmQeCvH3 LJ1wgktinCSwxPVXHPgUqatA+WoI+fLLeOd0hsckOveIb8WY3Z3LFyhDJBH1qkkMEKwr ELaljoH1+paxcH1QdDkCEjeEAagMI7/FIRXrcHP4MK2KgIZJj52wgq6JdMrMMnZX1jqx t1dA6gykJBj+Q1EcrdHxdkySKvWF6pdAD7y2wxNPBc+Ph/fXbPkNXrywVf6rkBVrBVxa qdEg== 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=JE8bRC6uYHCtiV8R8EE5D5GYSiT8jkroOdZWcPrNIso=; b=uFs5AJoUPwWSAygcolre+JAFlZJOkerDJcX1cjxCp3x3Tv38uzlLKO2UM1AE5+TSet D4sxElAgKB68ECaKWrggOVH/F/X0IeBncG35+F4HfU4UHZyPfUrG7fofUePdAzwBODEk kHYON/ZIHSivJYcKayu/OmR4rRHTSaSQMaTZI+3kqzb+Hezjsi7N0obG0rciQDIzAozp F6EQYAHsBYWlX7lw+BzcbYSpDgFV5xf+tE0IsIlxyjMbWeS8xI2lJR6KoKnJcy6yGci0 9gxn7El0PJN47vaBjMetDyTx0IZaNeKcZgmEAf6dGNUV/O67Egg6j8lLrqapAg8CPRd9 MEgA== X-Gm-Message-State: AJIora+ZcHm2ZnrH1AmhHokRM/6gOxfUCuSQ/oI6vsjgN+Q94RH7xNq/ +i/Vxc75kE3/mv3+3kDgIVs= X-Google-Smtp-Source: AGRyM1vE7L8X4jFX0/CbMVa/j1CVPqAjkMZJ1o95jHXF818zgQj4imyni/y+UHauWYM0NPcWXTXuLA== X-Received: by 2002:a17:90a:880a:b0:1ef:76fb:d8b6 with SMTP id s10-20020a17090a880a00b001ef76fbd8b6mr15047682pjn.69.1658762016747; Mon, 25 Jul 2022 08:13:36 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id a9-20020a170902ecc900b001641b2d61d4sm6649667plh.30.2022.07.25.08.13.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 08:13:36 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Philipp Zabel , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 5/7] PCI: brcmstb: Add control of subdevice voltage regulators Date: Mon, 25 Jul 2022 11:12:54 -0400 Message-Id: <20220725151258.42574-6-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725151258.42574-1-jim2101024@gmail.com> References: <20220725151258.42574-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220725_081339_841655_1BBC5AFE X-CRM114-Status: GOOD ( 29.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org This Broadcom STB PCIe RC driver has one port and connects directly to one device, be it a switch or an endpoint. We want to be able to leverage the recently added mechanism that allocates and turns on/off subdevice regulators. All that needs to be done is to put the regulator DT nodes in the bridge below host and to set the pci_ops methods add_bus and remove_bus. Note that the pci_subdev_regulators_add_bus() method is wrapped for two reasons: 1. To achieve link up after the voltage regulators are turned on. 2. If, in the case of an unsuccessful link up, to redirect any PCIe accesses to subdevices, e.g. the scan for DEV/ID. This redirection is needed because the Broadcom PCIe HW will issue a CPU abort if such an access is made when the link is down. The pci_subdev_regulators_remove_bus() is wrapped as well as we must avoid invoking it if we see that there is a collision in the use of dev->driver_data. [bhelgaas: fold in https://lore.kernel.org/r/20220112013100.48029-1-jim2101024@gmail.com] Link: https://lore.kernel.org/r/20220106160332.2143-7-jim2101024@gmail.com Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 134 ++++++++++++++++++-------- 1 file changed, 95 insertions(+), 39 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 1be6e71142d8..aa199b0a39e2 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -261,6 +261,8 @@ struct brcm_pcie { u32 hw_rev; void (*perst_set)(struct brcm_pcie *pcie, u32 val); void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val); + bool regulator_oops; + struct subdev_regulators *sr; }; static inline bool is_bmips(const struct brcm_pcie *pcie) @@ -1100,10 +1102,37 @@ static int pci_subdev_regulators_add_bus(struct pci_bus *bus) struct subdev_regulators *sr; int ret; - if (!dev->of_node || !bus->parent || !pci_is_root_bus(bus->parent)) + sr = alloc_subdev_regulators(dev); + if (!sr) + return -ENOMEM; + + ret = regulator_bulk_get(dev, sr->num_supplies, sr->supplies); + if (ret) { + dev_err(dev, "failed to get regulators for downstream device\n"); + return ret; + } + + ret = regulator_bulk_enable(sr->num_supplies, sr->supplies); + if (ret) { + dev_err(dev, "failed to enable regulators for downstream device\n"); + regulator_bulk_free(sr->num_supplies, sr->supplies); + return ret; + } + dev->driver_data = sr; + + return 0; +} + +static int brcm_pcie_add_bus(struct pci_bus *bus) +{ + struct brcm_pcie *pcie = (struct brcm_pcie *) bus->sysdata; + struct device *dev = &bus->dev; + int ret; + + if (!bus->parent || !pci_is_root_bus(bus->parent) || !pcie) return 0; - if (dev->driver_data) { + if (dev->of_node && dev->driver_data) { /* * Oops, this is unfortunate. We are using the port * driver's driver_data field to store our regulator info @@ -1112,12 +1141,15 @@ static int pci_subdev_regulators_add_bus(struct pci_bus *bus) * may still be okay if there are no regulators. */ dev_err(dev, "root port dev.driver_data non-NULL; something wrong\n"); - return 0; + + } else if (dev->of_node) { + ret = pci_subdev_regulators_add_bus(bus); + /* Grab the regulators for suspend/resume */ + pcie->sr = bus->dev.driver_data; } - sr = alloc_subdev_regulators(dev); - if (!sr) - return -ENOMEM; + /* Try to start the link. */ + brcm_pcie_start_link(pcie); /* * There is not much of a point to return an error as currently it @@ -1125,22 +1157,7 @@ static int pci_subdev_regulators_add_bus(struct pci_bus *bus) * return the error if it is -ENOMEM. Note that we are always * doing a dev_err() for other erros. */ - ret = regulator_bulk_get(dev, sr->num_supplies, sr->supplies); - if (ret) { - dev_err(dev, "failed to get regulators for downstream device\n"); - return 0; - } - - ret = regulator_bulk_enable(sr->num_supplies, sr->supplies); - if (ret) { - dev_err(dev, "failed to enable regulators for downstream device\n"); - regulator_bulk_free(sr->num_supplies, sr->supplies); - return 0; - } - - dev->driver_data = sr; - - return 0; + return ret == -ENOMEM ? ret : 0; } static void pci_subdev_regulators_remove_bus(struct pci_bus *bus) @@ -1148,15 +1165,28 @@ static void pci_subdev_regulators_remove_bus(struct pci_bus *bus) struct device *dev = &bus->dev; struct subdev_regulators *sr = dev->driver_data; - if (!dev->of_node || !sr || !bus->parent || !pci_is_root_bus(bus->parent)) - return; - if (regulator_bulk_disable(sr->num_supplies, sr->supplies)) dev_err(dev, "failed to disable regulators for downstream device\n"); regulator_bulk_free(sr->num_supplies, sr->supplies); dev->driver_data = NULL; } +static void brcm_pcie_remove_bus(struct pci_bus *bus) +{ + struct device *dev = &bus->dev; + struct brcm_pcie *pcie; + + if (!dev->of_node || !dev->driver_data || !bus->parent || + !pci_is_root_bus(bus->parent)) + return; + + pcie = (struct brcm_pcie *) bus->sysdata; + if (pcie && pcie->sr) { + pci_subdev_regulators_remove_bus(bus); + pcie->sr = NULL; + } +} + /* L23 is a low-power PCIe link state */ static void brcm_pcie_enter_l23(struct brcm_pcie *pcie) { @@ -1253,7 +1283,7 @@ static void brcm_pcie_turn_off(struct brcm_pcie *pcie) pcie->bridge_sw_init_set(pcie, 1); } -static int brcm_pcie_suspend(struct device *dev) +static int brcm_pcie_suspend_noirq(struct device *dev) { struct brcm_pcie *pcie = dev_get_drvdata(dev); int ret; @@ -1273,12 +1303,20 @@ static int brcm_pcie_suspend(struct device *dev) return ret; } + if (pcie->sr) { + ret = regulator_bulk_disable(pcie->sr->num_supplies, pcie->sr->supplies); + if (ret) { + dev_err(dev, "Could not turn off regulators\n"); + reset_control_reset(pcie->rescal); + return ret; + } + } clk_disable_unprepare(pcie->clk); return 0; } -static int brcm_pcie_resume(struct device *dev) +static int brcm_pcie_resume_noirq(struct device *dev) { struct brcm_pcie *pcie = dev_get_drvdata(dev); void __iomem *base; @@ -1313,15 +1351,27 @@ static int brcm_pcie_resume(struct device *dev) if (ret) goto err_reset; + if (pcie->sr) { + ret = regulator_bulk_enable(pcie->sr->num_supplies, + pcie->sr->supplies); + if (ret) { + dev_err(dev, "Could not turn on regulators\n"); + goto err_reset; + } + } + ret = brcm_pcie_start_link(pcie); if (ret) - goto err_reset; + goto err_regulator; if (pcie->msi) brcm_msi_set_regs(pcie->msi); return 0; +err_regulator: + if (pcie->sr) + regulator_bulk_disable(pcie->sr->num_supplies, pcie->sr->supplies); err_reset: reset_control_rearm(pcie->rescal); err_disable_clk: @@ -1428,16 +1478,16 @@ static struct pci_ops brcm_pcie_ops = { .map_bus = brcm_pcie_map_conf, .read = pci_generic_config_read, .write = pci_generic_config_write, - .add_bus = pci_subdev_regulators_add_bus, - .remove_bus = pci_subdev_regulators_remove_bus, + .add_bus = brcm_pcie_add_bus, + .remove_bus = brcm_pcie_remove_bus }; static struct pci_ops brcm_pcie_ops32 = { .map_bus = brcm_pcie_map_conf32, .read = pci_generic_config_read32, .write = pci_generic_config_write32, - .add_bus = pci_subdev_regulators_add_bus, - .remove_bus = pci_subdev_regulators_remove_bus, + .add_bus = brcm_pcie_add_bus, + .remove_bus = brcm_pcie_remove_bus }; static int brcm_pcie_probe(struct platform_device *pdev) @@ -1510,10 +1560,6 @@ static int brcm_pcie_probe(struct platform_device *pdev) if (ret) goto fail; - ret = brcm_pcie_start_link(pcie); - if (ret) - goto fail; - pcie->hw_rev = readl(pcie->base + PCIE_MISC_REVISION); if (pcie->type == BCM4908 && pcie->hw_rev >= BRCM_PCIE_HW_REV_3_20) { dev_err(pcie->dev, "hardware revision with unsupported PERST# setup\n"); @@ -1535,7 +1581,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; @@ -1544,8 +1600,8 @@ static int brcm_pcie_probe(struct platform_device *pdev) MODULE_DEVICE_TABLE(of, brcm_pcie_match); static const struct dev_pm_ops brcm_pcie_pm_ops = { - .suspend = brcm_pcie_suspend, - .resume = brcm_pcie_resume, + .suspend_noirq = brcm_pcie_suspend_noirq, + .resume_noirq = brcm_pcie_resume_noirq, }; static struct platform_driver brcm_pcie_driver = { From patchwork Mon Jul 25 15:12:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12928251 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 61573C433EF for ; Mon, 25 Jul 2022 15:47:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Cd72D6HFSJSKSn5EONRY+1v5AgIYKqq03dAPDC7koPI=; b=E4wm8yWzaDNPUe Iem4NyYATW3/Ae3uKtmmdAJO2ZY50Hzic3WuNE6Osd356VCa4BO9BidcY9s0wnWuT04BxGeLuT57v 3Oh7HeAjCheO+JBuAl4kK3djqcvo+sqEOXliNZ8qjYM+4wSVYTY4U+OWYWXo8I2bqIqV7UO3uEFE4 KRNTdOhxmxOw+PN0eLNN0hb+43aBvFiMI8AIAy/gehkt4iiSCFgvIdzKNCjHUHJcwZPcUD/+koLXe kmdHhAHT8IKMhXu5NFi/kmieSgZ54WCr3ki5OVol14b9fzAxjyWsRRcUpJCrV/ZgWSMVhgmdlIEyw h1ITTJdlzJzLJb7J7j8A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oG0HO-00FRti-GK; Mon, 25 Jul 2022 15:45:58 +0000 Received: from mail-pg1-x52e.google.com ([2607:f8b0:4864:20::52e]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oFzm9-00FH2s-CN; Mon, 25 Jul 2022 15:13:43 +0000 Received: by mail-pg1-x52e.google.com with SMTP id f65so10614453pgc.12; Mon, 25 Jul 2022 08:13:40 -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=cWqt3A+kTTr3GuQ/QKtvOTNiaH7+FtME/Jys/x5W9Qg=; b=RnHVXJ7QzoxC/Sb4hfqcVvvu5DQpUvhCBmwM3ZfgRwfuFoTwxujBXVmTDApsn5EFw9 JL9cAxz6gNHdtxWfy195R63xeEHToGNb3wCwYSSuCipWefhsDN54obbf36XGugonATR6 pkZSuaMmGyX6bXjcdWRhFVkvvc9CHgeafUcE+ow2bRHr3Cg8vTLwUGP/wAg3j69csvj1 /iOtfyxFG3WltjRMO0gdDJj4RvkUxx1bIlhaCQirgSYjvl7eFKG3wztVR5EVt8Cpxh37 P7zJWc6cYo64Vr5zPZ1sejbk3ohHiGia6ceCSqh7QQslmVn/dhdfx+ydUN8i4WjPnehU l+dw== 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=cWqt3A+kTTr3GuQ/QKtvOTNiaH7+FtME/Jys/x5W9Qg=; b=ZigPj3rUMOGYwY8jH71tED740/UgBbhGQWOde+il7nu475T6gbG2BKNvi6BOyt0bWW FN4wY0wCrhSa166BZFcqxXI/bXl61obnDT5fUC3ThJvryTVX2rw01VCkVtYjuQLu9clv Q1D0kSIT8PnplVL0nJthnsuBabqEVyK3sIjvBTp0hln1CeUdfbEBFTen+SlZf7f5fIKI mB5TKEGIT1FcRaUtlsorszB0FUSwWyEhfb7KJ+pqGgCEyCoLRAZ3IGGfduVH/zem++Rs GrDXBSw7o1y7/lONtL8d3M9b6DmIuI4X8G6QN7J++Uhyd5R5koREBdQ8iYCcXV+rrywP Ka9A== X-Gm-Message-State: AJIora+QccjRpkbR7svqV/517ZNvGLO/UpQ3w0XyjdccMKdfMgoNBC2L JP2c3xXjUNbZ12RYd3d1SUA= X-Google-Smtp-Source: AGRyM1uRxc0dreTIHkxKj089Ou1wxbKhCJI9jsthW/cnZ/UAr2TLk2D+Hk9H+Qdjneaasbc5pXkq3A== X-Received: by 2002:a63:fb01:0:b0:419:699f:a0bb with SMTP id o1-20020a63fb01000000b00419699fa0bbmr11334115pgh.4.1658762019875; Mon, 25 Jul 2022 08:13:39 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id a9-20020a170902ecc900b001641b2d61d4sm6649667plh.30.2022.07.25.08.13.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 08:13:39 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Philipp Zabel , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 6/7] PCI: brcmstb: Do not turn off WOL regulators on suspend Date: Mon, 25 Jul 2022 11:12:55 -0400 Message-Id: <20220725151258.42574-7-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725151258.42574-1-jim2101024@gmail.com> References: <20220725151258.42574-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220725_081341_461171_031997B3 X-CRM114-Status: GOOD ( 17.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org If any downstream device can be a wakeup device, do not turn off the regulators as the device will need them on. Link: https://lore.kernel.org/r/20220106160332.2143-8-jim2101024@gmail.com Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 54 ++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index aa199b0a39e2..fc1d36f6094e 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -263,6 +263,7 @@ struct brcm_pcie { void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val); bool regulator_oops; struct subdev_regulators *sr; + bool ep_wakeup_capable; }; static inline bool is_bmips(const struct brcm_pcie *pcie) @@ -1283,9 +1284,21 @@ static void brcm_pcie_turn_off(struct brcm_pcie *pcie) pcie->bridge_sw_init_set(pcie, 1); } +static int pci_dev_may_wakeup(struct pci_dev *dev, void *data) +{ + bool *ret = data; + + if (device_may_wakeup(&dev->dev)) { + *ret = true; + dev_info(&dev->dev, "disable cancelled for wake-up device\n"); + } + return (int) *ret; +} + static int brcm_pcie_suspend_noirq(struct device *dev) { struct brcm_pcie *pcie = dev_get_drvdata(dev); + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); int ret; brcm_pcie_turn_off(pcie); @@ -1304,11 +1317,22 @@ static int brcm_pcie_suspend_noirq(struct device *dev) } if (pcie->sr) { - ret = regulator_bulk_disable(pcie->sr->num_supplies, pcie->sr->supplies); - if (ret) { - dev_err(dev, "Could not turn off regulators\n"); - reset_control_reset(pcie->rescal); - return ret; + /* + * Now turn off the regulators, but if at least one + * downstream device is enabled as a wake-up source, do not + * turn off regulators. + */ + pcie->ep_wakeup_capable = false; + pci_walk_bus(bridge->bus, pci_dev_may_wakeup, + &pcie->ep_wakeup_capable); + if (!pcie->ep_wakeup_capable) { + ret = regulator_bulk_disable(pcie->sr->num_supplies, + pcie->sr->supplies); + if (ret) { + dev_err(dev, "Could not turn off regulators\n"); + reset_control_reset(pcie->rescal); + return ret; + } } } clk_disable_unprepare(pcie->clk); @@ -1352,11 +1376,21 @@ static int brcm_pcie_resume_noirq(struct device *dev) goto err_reset; if (pcie->sr) { - ret = regulator_bulk_enable(pcie->sr->num_supplies, - pcie->sr->supplies); - if (ret) { - dev_err(dev, "Could not turn on regulators\n"); - goto err_reset; + if (pcie->ep_wakeup_capable) { + /* + * We are resuming from a suspend. In the suspend we + * did not disable the power supplies, so there is + * no need to enable them (and falsely increase their + * usage count). + */ + pcie->ep_wakeup_capable = false; + } else { + ret = regulator_bulk_enable(pcie->sr->num_supplies, + pcie->sr->supplies); + if (ret) { + dev_err(dev, "Could not turn on regulators\n"); + goto err_reset; + } } } From patchwork Mon Jul 25 15:12:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Quinlan X-Patchwork-Id: 12928252 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4DF35C43334 for ; Mon, 25 Jul 2022 15:48:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=BbJMmUwtIaaXtquASwroRiR8XCuelgH3mX4zMiAbEyY=; b=Oe+dyv1DQ7AQ5M u1k+/7YoQR63X7gMzXo78A204ZVnAb5ALxR/EPl2oHRq/jrOBcO1sO2rQimYi8HouGIoDYZVOzZKN HML5AJCB2fIBjOZG6WuJ75m3Uwbmi/Za117XRIMmP145Ug+9JA7qpgeRbyPKTmM6YbzmFLzf3v+ia gAFcalRmqt9Fsy/OjEEOcxmydpjl1SbHRwilSsT0CFwj4oqhH5MldpqbMQTqcBgFkNKa+soc6uczX q/iBe3Kyzg8rkBOz6GzkJ3CRZZFtx56Qpin0wcwuBIcDZrJIsJF5NrLfZEPsYzakowMJJXtI1pZFQ UBW34lb38bpD9RfFg1ng==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oG0Ib-00FSKj-T2; Mon, 25 Jul 2022 15:47:16 +0000 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oFzmC-00FH4i-IQ; Mon, 25 Jul 2022 15:13:45 +0000 Received: by mail-pj1-x102c.google.com with SMTP id b7-20020a17090a12c700b001f20eb82a08so14650508pjg.3; Mon, 25 Jul 2022 08:13:43 -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=XRISqH0YEt9x37mOvZB1aRfZZEl6+ks0JDgNi4Ug7Zk=; b=o5neeh4ryOoBCB8aglOKL52nvvcBgFyio+39f1GPtB2O/slaQJdSCAr4qATZhCQmF7 1zjFyzWkusGEbaJI6oYjegXXuPo5ICsGd2dXIQ3WCRyjOMFl1YGlKEM/kFKKyzPx72An 8bKV15YiEXk1Ungcvs+IogfaUTguat61aZa9aDVmg4Q/qvSsp4AhG19nCC+xfY3ti/Fx geXalA7hGJGtLujyQ4lCHfgFo1jn7cZ3B0VK+qwRSVNqXAysraPUQa2by2+4YDAEhftO xpAiofVS6Qh3GnK8oRRIe2TiGXoHU+WOyIcastiLhcc/h49+tTNlSpugOwWQo1fONNrV N0Bw== 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=XRISqH0YEt9x37mOvZB1aRfZZEl6+ks0JDgNi4Ug7Zk=; b=5DJ0wEKrX5HrwwRDTCG+dsdIkdUX7SMEopDyyCIyRZ3BtxuBkRVCAGQzla076OO8iU //FpHDiS5hOsBUModuPPxGUH3QDGHRj2hjss0PToUU/+OKHXQxLlBybDfXct7U8fFmRf z5Sgme62fGByy06b+KOEJuXgzgQjVdqRGatOsMak96HPgNzLNSLsqel/T2jepE3vuHQL 03zksmE7tZdlkKz2DLf9TxwpcsK1suxJDV6wr/i3TeRb+9HFqqRD6+tB5hB9uYHsWTr+ EgEX0s2sthdGBTp+H4Ac5xCmWEQPXadAtZBQ+CBtj+dWB+b/JrJ8hyNq8kPESTTiTd1G H8MQ== X-Gm-Message-State: AJIora+UIX6S3swR6c8diDtDTCSYqB0GkCPXgycrQnoIXUQFYKknTRdb IlrjmHHdAhZi9nBW/VVLfKXf/vkTuJE= X-Google-Smtp-Source: AGRyM1uCEX3dmY0dBa+CpILOTqJu48Q9xyKEqm4oI4EyeWgqGjO1n1uVJmCPP5x3Ng2Y3fble129qw== X-Received: by 2002:a17:902:c40a:b0:16d:2dbd:35cd with SMTP id k10-20020a170902c40a00b0016d2dbd35cdmr12397728plk.65.1658762022801; Mon, 25 Jul 2022 08:13:42 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id a9-20020a170902ecc900b001641b2d61d4sm6649667plh.30.2022.07.25.08.13.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Jul 2022 08:13:42 -0700 (PDT) From: Jim Quinlan To: linux-pci@vger.kernel.org, Nicolas Saenz Julienne , Bjorn Helgaas , Lorenzo Pieralisi , Cyril Brulebois , bcm-kernel-feedback-list@broadcom.com, jim2101024@gmail.com, james.quinlan@broadcom.com Cc: Florian Fainelli , Lorenzo Pieralisi , Rob Herring , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , linux-rpi-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-arm-kernel@lists.infradead.org (moderated list:BROADCOM BCM2711/BCM2835 ARM ARCHITECTURE), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v3 7/7] PCI: brcmstb: Have .map_bus function names end with 'map_bus' Date: Mon, 25 Jul 2022 11:12:56 -0400 Message-Id: <20220725151258.42574-8-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220725151258.42574-1-jim2101024@gmail.com> References: <20220725151258.42574-1-jim2101024@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220725_081344_636753_062EF6FF X-CRM114-Status: GOOD ( 11.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Conform with other drivers' map_bus functions. 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 fc1d36f6094e..b40733dd253c 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -685,7 +685,7 @@ static bool brcm_pcie_link_up(struct brcm_pcie *pcie) return dla && plu; } -static void __iomem *brcm_pcie_map_conf(struct pci_bus *bus, unsigned int devfn, +static void __iomem *brcm_pcie_map_bus(struct pci_bus *bus, unsigned int devfn, int where) { struct brcm_pcie *pcie = bus->sysdata; @@ -706,7 +706,7 @@ static void __iomem *brcm_pcie_map_conf(struct pci_bus *bus, unsigned int devfn, return base + PCIE_EXT_CFG_DATA + (where & 0xfff); } -static void __iomem *brcm_pcie_map_conf32(struct pci_bus *bus, unsigned int devfn, +static void __iomem *brcm_pcie_map_bus32(struct pci_bus *bus, unsigned int devfn, int where) { struct brcm_pcie *pcie = bus->sysdata; @@ -1509,7 +1509,7 @@ static const struct of_device_id brcm_pcie_match[] = { }; static struct pci_ops brcm_pcie_ops = { - .map_bus = brcm_pcie_map_conf, + .map_bus = brcm_pcie_map_bus, .read = pci_generic_config_read, .write = pci_generic_config_write, .add_bus = brcm_pcie_add_bus, @@ -1517,7 +1517,7 @@ static struct pci_ops brcm_pcie_ops = { }; static struct pci_ops brcm_pcie_ops32 = { - .map_bus = brcm_pcie_map_conf32, + .map_bus = brcm_pcie_map_bus32, .read = pci_generic_config_read32, .write = pci_generic_config_write32, .add_bus = brcm_pcie_add_bus,