Received: by 2002:ac0:cd04:0:0:0:0:0 with SMTP id w4csp75304imn; Fri, 1 Jul 2022 10:13:08 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tvRT0TkfGS5FTijakc/bBinNJt4nJqo3Om2QXNkBp21MD298ClWEVCd1a8esAsiK5d1RNc X-Received: by 2002:a17:906:1001:b0:715:8356:d4da with SMTP id 1-20020a170906100100b007158356d4damr16048280ejm.10.1656695588693; Fri, 01 Jul 2022 10:13:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656695588; cv=none; d=google.com; s=arc-20160816; b=u3flkGHcVHW5ZM6kZqAh/zsKkByXThDPht6+qqzpJEBL18qrhQDlRstrzW4Nv/JNIh 70RiKoq097+PLSuJ7OOJbBGLsW9YqHTeWCTsmizoqCllD427ELyr9tTjnIabmphpAYyI WCWHutdZBZ8jxFc58bc+0JKUU9CWP8FAMTqkaYCm7bBKOz1+/VlL+DdAb2LjaXRhP/18 3r+yJ1My4rGwdPQLYMnQnvyrj1ylTEweUxOdRJn86pv0nKpZ84I7A6gRrQEFfTUaPEbh uWJlCdPOMii3H4cyddIGvjijlNt90HaWHXmBKm6UrFygF5DZIKVnGWAmXOfkt0PxJG5Z JDHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=GvJg8bmxsvlHCDYxnCVH4CTrk9c3cNS1BabGXZKXbv4=; b=C5JS7icUjZ9kpQDPVPi9BTCsb8t5DhMQDVflBirntKZ4fGp0+bK0NJMKvlvE5VULic hr4XdEsRXdiuQ0bQivWL2InV6W/w6rKlCbhXwoiHRfFnhyWoCGTyaqKqMpJaM9VckbI6 +5SxniSoG8Swz8gzHRsTpSdZsvmhvihWnTD8K0O3boo9L1sOoK0tin5KRb6gbqzOq632 h/Srlx18lyMaXk6mDLwuomVjlnKmwaFelUsmpqbnGrxtj5O9CW8kAGu3OE4E10jSkwf1 r71Pwhx8EULHPi53oFjYXXne3WGtMTYCa8/1Vmdy84i5aXHmC9kj9GI/QRsvOBrMaSxk bLxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mPcXNgjF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t2-20020a170906a10200b00722f48fa046si25722675ejy.202.2022.07.01.10.12.43; Fri, 01 Jul 2022 10:13:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mPcXNgjF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232355AbiGAQ1e (ORCPT + 99 others); Fri, 1 Jul 2022 12:27:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232329AbiGAQ1c (ORCPT ); Fri, 1 Jul 2022 12:27:32 -0400 Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BD7841980; Fri, 1 Jul 2022 09:27:31 -0700 (PDT) Received: by mail-qk1-x72c.google.com with SMTP id b24so2198741qkn.4; Fri, 01 Jul 2022 09:27: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=GvJg8bmxsvlHCDYxnCVH4CTrk9c3cNS1BabGXZKXbv4=; b=mPcXNgjFmh89J+gcPGS/jr/8KlgV8vh5eVwlyTT14hWY/J9dtOU7QMK6zswrQ2NR8x BG36Yy9myT7jIzCT2V1e7fcc28ZMb6CNOtKQFRicYuDB+5RD2Z9yjBBGjiLVc/OrbUkF eWB2bBnx70EkBgO7m3aq1zfllsilSSkmDMEGx3B4HLZfqaTn1P90eupBYkNSbkwveJO0 q7EmmUBJnRxxVqM+83sG9rFtSUYtxVBlZQ4hUtLCCr5C0UtYf0R1DD/kcaod0fWv1Ush 34d4wnqRyuxPE2rBwUT7K0vWBgS/i7kfAhDKBPS/V7OBkQ551/3u69sMYzktEq4qQyfn Vb6g== 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=GvJg8bmxsvlHCDYxnCVH4CTrk9c3cNS1BabGXZKXbv4=; b=r6gSrDwbXiVt185NxKxXMjLkW//Ey2z8I1iBUkTZcEflJMSiunPA3Oc4yKG21a9K8I yKL956EPidrBZY6v+9B8dMK7gBZqFeSMMACpm321O+7RyjXVAL2fE9pvso2Tk5ACvrxi jx4FsjBS/8JDSJn/IDCuD7lZBn9JZcUw08hNw2Ul7EvJ+EdZTAecElSH8wbH0NBUzWSr Yb6XzhYqY9Uag7zPkJDrZxpiFkUKXc3Py9V5U5rahDHmp3MQXlU7Oj+v5MvkJsLwehB9 JM2SrVKR/Sbzwk+5FxjQju6SoAMmtrqaabrNKYpvFSevatiMfzuLPfmuk77h3AxctlKd oHCg== X-Gm-Message-State: AJIora8+pVKjrEFP1UxKvgMnIdinIzqd6Pn+w7918DANCaSGLzIelVf7 3KBlZ9sho6rx4+wVefrfbHg/B8TlLoI= X-Received: by 2002:a05:620a:4706:b0:6af:3d73:6018 with SMTP id bs6-20020a05620a470600b006af3d736018mr11181944qkb.357.1656692849929; Fri, 01 Jul 2022 09:27:29 -0700 (PDT) Received: from stbsrv-and-01.and.broadcom.net ([192.19.144.250]) by smtp.gmail.com with ESMTPSA id w4-20020a05620a424400b006af08c26774sm17316175qko.47.2022.07.01.09.27.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jul 2022 09:27:29 -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=20Wilczy=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 v1 1/4] PCI: brcmstb: Split brcm_pcie_setup() into two funcs Date: Fri, 1 Jul 2022 12:27:22 -0400 Message-Id: <20220701162726.31346-2-jim2101024@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220701162726.31346-1-jim2101024@gmail.com> References: <20220701162726.31346-1-jim2101024@gmail.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We need to take some code in brcm_pcie_setup() and put it in a new function brcm_pcie_linkup(). In future commits the brcm_pcie_linkup() function will be called indirectly by pci_host_probe() as opposed to the host driver invoking it directly. Some code that was executed after the PCIe linkup is now placed so that it executes prior to linkup, since this code has to run prior to the invocation of pci_host_probe(). Link: https://lore.kernel.org/r/20220106160332.2143-5-jim2101024@gmail.com Signed-off-by: Jim Quinlan --- drivers/pci/controller/pcie-brcmstb.c | 69 +++++++++++++++++---------- 1 file changed, 43 insertions(+), 26 deletions(-) diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index e61058e13818..2bf5cc399fd0 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -926,16 +926,9 @@ static inline int brcm_pcie_get_rc_bar2_size_and_offset(struct brcm_pcie *pcie, static int brcm_pcie_setup(struct brcm_pcie *pcie) { - struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); u64 rc_bar2_offset, rc_bar2_size; void __iomem *base = pcie->base; - struct device *dev = pcie->dev; - struct resource_entry *entry; - bool ssc_good = false; - struct resource *res; - int num_out_wins = 0; - u16 nlw, cls, lnksta; - int i, ret, memc; + int ret, memc; u32 tmp, burst, aspm_support; /* Reset the bridge */ @@ -1025,6 +1018,40 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie) if (pcie->gen) brcm_pcie_set_gen(pcie, pcie->gen); + /* Don't advertise L0s capability if 'aspm-no-l0s' */ + aspm_support = PCIE_LINK_STATE_L1; + if (!of_property_read_bool(pcie->np, "aspm-no-l0s")) + aspm_support |= PCIE_LINK_STATE_L0S; + tmp = readl(base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY); + u32p_replace_bits(&tmp, aspm_support, + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK); + writel(tmp, base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY); + + /* + * For config space accesses on the RC, show the right class for + * a PCIe-PCIe bridge (the default setting is to be EP mode). + */ + tmp = readl(base + PCIE_RC_CFG_PRIV1_ID_VAL3); + u32p_replace_bits(&tmp, 0x060400, + PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK); + writel(tmp, base + PCIE_RC_CFG_PRIV1_ID_VAL3); + + return 0; +} + +static int brcm_pcie_linkup(struct brcm_pcie *pcie) +{ + struct pci_host_bridge *bridge = pci_host_bridge_from_priv(pcie); + struct device *dev = pcie->dev; + void __iomem *base = pcie->base; + struct resource_entry *entry; + struct resource *res; + int num_out_wins = 0; + u16 nlw, cls, lnksta; + bool ssc_good = false; + u32 tmp; + int ret, i; + /* Unassert the fundamental reset */ pcie->perst_set(pcie, 0); @@ -1075,24 +1102,6 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie) num_out_wins++; } - /* Don't advertise L0s capability if 'aspm-no-l0s' */ - aspm_support = PCIE_LINK_STATE_L1; - if (!of_property_read_bool(pcie->np, "aspm-no-l0s")) - aspm_support |= PCIE_LINK_STATE_L0S; - tmp = readl(base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY); - u32p_replace_bits(&tmp, aspm_support, - PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK); - writel(tmp, base + PCIE_RC_CFG_PRIV1_LINK_CAPABILITY); - - /* - * For config space accesses on the RC, show the right class for - * a PCIe-PCIe bridge (the default setting is to be EP mode). - */ - tmp = readl(base + PCIE_RC_CFG_PRIV1_ID_VAL3); - u32p_replace_bits(&tmp, 0x060400, - PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK); - writel(tmp, base + PCIE_RC_CFG_PRIV1_ID_VAL3); - if (pcie->ssc) { ret = brcm_pcie_set_ssc(pcie); if (ret == 0) @@ -1281,6 +1290,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); @@ -1398,6 +1411,10 @@ static int brcm_pcie_probe(struct platform_device *pdev) if (ret) goto fail; + ret = brcm_pcie_linkup(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"); -- 2.17.1