From patchwork Thu Aug 5 21:11:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 492274 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp664612jap; Thu, 5 Aug 2021 14:12:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvul/0vb09AjRQRiVjMq4dm7n85K2NhorzZc/WIYp65zquDvraBbkOSKMH4CSXEzQQi9bB X-Received: by 2002:a05:6402:408:: with SMTP id q8mr9038634edv.13.1628197934157; Thu, 05 Aug 2021 14:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628197934; cv=none; d=google.com; s=arc-20160816; b=x1NHwmK8CLDx0yAltFNJ2tdmYnh93gfhHim9hqrFrxrxqKDcdEYIasi6GNCB5BC5k0 QvRLYNA28Ds/8g+P4GpgVc9eSKgxCkijVHyDYeSLxCsVqM+93nxm94T8cHfI+Nk7q3K1 dfIbx2eGdkJGWkxIO89ZivSmLiyj+kzZhU7XbtX0H+CAMBoFOYB61PDwBO/ED5IMrXNw sUqSwSlYSyXIkZwF3Gga2jPpiwyJCeuZDmu2lmjJROuow0gkXK9hqUEpBROWBUxv4CaR Q6OZPAGcb+9/CaCjT8rEFrs4Va08w6Wa1Hhg8enWln2X7Uwp0CbL6e2ciRM6BRtmFbVu 6GGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=PSEYP+OCndgor8TZbgitSgXT07nMMjltDY8EdBWBsoE=; b=FtF/wdjwhceKqxB08MgYNoE6dFqm5QrU3NipEXX+FK/PrWCNslSru13MxlzmHsRa98 KOihNMqPfwP4Uh3zJvm113+vqegq8PQHWUo+LaehAmiA5OGbGhKRpzOZRM+muIyipwsy lLvcyb3lu6/ULHvu68j9KTtPr0cLK7boZkZ6awqzR3S4hhFucQw+Ko2OVVmgPESFamlm it0XxrQTVhUgPhAtdUrlBchvSSRnjWBheXxRPL62MgqeMR/vbqai4XZAoeGiLpVsRXpV p0tuHgR4s2IrvgPdBbo/BhacUx8z+wDjtQGvf6PJLIgIn5xbzFt06GV7qp+PVHa1uTxG LizA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ee27si7087336edb.168.2021.08.05.14.12.13; Thu, 05 Aug 2021 14:12:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241859AbhHEVMX (ORCPT + 4 others); Thu, 5 Aug 2021 17:12:23 -0400 Received: from foss.arm.com ([217.140.110.172]:52392 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241806AbhHEVMW (ORCPT ); Thu, 5 Aug 2021 17:12:22 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 169D711FB; Thu, 5 Aug 2021 14:12:07 -0700 (PDT) Received: from u200856.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7B78C3F719; Thu, 5 Aug 2021 14:12:06 -0700 (PDT) From: Jeremy Linton To: linux-pci@vger.kernel.org Cc: lorenzo.pieralisi@arm.com, nsaenz@kernel.org, bhelgaas@google.com, rjw@rjwysocki.net, lenb@kernel.org, robh@kernel.org, kw@linux.com, f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rpi-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jeremy Linton Subject: [PATCH 1/3] PCI: brcmstb: Break register definitions into separate header Date: Thu, 5 Aug 2021 16:11:58 -0500 Message-Id: <20210805211200.491275-2-jeremy.linton@arm.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210805211200.491275-1-jeremy.linton@arm.com> References: <20210805211200.491275-1-jeremy.linton@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org We are about to create a standalone ACPI quirk module for the bcmstb controller. Lets move the register definitions into a separate file so they can be shared between the APCI quirk and the normal host bridge driver. Signed-off-by: Jeremy Linton --- drivers/pci/controller/pcie-brcmstb.c | 179 +------------------------ drivers/pci/controller/pcie-brcmstb.h | 182 ++++++++++++++++++++++++++ 2 files changed, 183 insertions(+), 178 deletions(-) create mode 100644 drivers/pci/controller/pcie-brcmstb.h -- 2.31.1 diff --git a/drivers/pci/controller/pcie-brcmstb.c b/drivers/pci/controller/pcie-brcmstb.c index 08bc788d9422..916de435ced9 100644 --- a/drivers/pci/controller/pcie-brcmstb.c +++ b/drivers/pci/controller/pcie-brcmstb.c @@ -31,192 +31,15 @@ #include #include "../pci.h" - -/* BRCM_PCIE_CAP_REGS - Offset for the mandatory capability config regs */ -#define BRCM_PCIE_CAP_REGS 0x00ac - -/* Broadcom STB PCIe Register Offsets */ -#define PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1 0x0188 -#define PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1_ENDIAN_MODE_BAR2_MASK 0xc -#define PCIE_RC_CFG_VENDOR_SPCIFIC_REG1_LITTLE_ENDIAN 0x0 - -#define PCIE_RC_CFG_PRIV1_ID_VAL3 0x043c -#define PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK 0xffffff - -#define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY 0x04dc -#define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK 0xc00 - -#define PCIE_RC_DL_MDIO_ADDR 0x1100 -#define PCIE_RC_DL_MDIO_WR_DATA 0x1104 -#define PCIE_RC_DL_MDIO_RD_DATA 0x1108 - -#define PCIE_MISC_MISC_CTRL 0x4008 -#define PCIE_MISC_MISC_CTRL_SCB_ACCESS_EN_MASK 0x1000 -#define PCIE_MISC_MISC_CTRL_CFG_READ_UR_MODE_MASK 0x2000 -#define PCIE_MISC_MISC_CTRL_MAX_BURST_SIZE_MASK 0x300000 - -#define PCIE_MISC_MISC_CTRL_SCB0_SIZE_MASK 0xf8000000 -#define PCIE_MISC_MISC_CTRL_SCB1_SIZE_MASK 0x07c00000 -#define PCIE_MISC_MISC_CTRL_SCB2_SIZE_MASK 0x0000001f -#define SCB_SIZE_MASK(x) PCIE_MISC_MISC_CTRL_SCB ## x ## _SIZE_MASK - -#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LO 0x400c -#define PCIE_MEM_WIN0_LO(win) \ - PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LO + ((win) * 8) - -#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_HI 0x4010 -#define PCIE_MEM_WIN0_HI(win) \ - PCIE_MISC_CPU_2_PCIE_MEM_WIN0_HI + ((win) * 8) - -#define PCIE_MISC_RC_BAR1_CONFIG_LO 0x402c -#define PCIE_MISC_RC_BAR1_CONFIG_LO_SIZE_MASK 0x1f - -#define PCIE_MISC_RC_BAR2_CONFIG_LO 0x4034 -#define PCIE_MISC_RC_BAR2_CONFIG_LO_SIZE_MASK 0x1f -#define PCIE_MISC_RC_BAR2_CONFIG_HI 0x4038 - -#define PCIE_MISC_RC_BAR3_CONFIG_LO 0x403c -#define PCIE_MISC_RC_BAR3_CONFIG_LO_SIZE_MASK 0x1f - -#define PCIE_MISC_MSI_BAR_CONFIG_LO 0x4044 -#define PCIE_MISC_MSI_BAR_CONFIG_HI 0x4048 - -#define PCIE_MISC_MSI_DATA_CONFIG 0x404c -#define PCIE_MISC_MSI_DATA_CONFIG_VAL_32 0xffe06540 -#define PCIE_MISC_MSI_DATA_CONFIG_VAL_8 0xfff86540 - -#define PCIE_MISC_PCIE_CTRL 0x4064 -#define PCIE_MISC_PCIE_CTRL_PCIE_L23_REQUEST_MASK 0x1 -#define PCIE_MISC_PCIE_CTRL_PCIE_PERSTB_MASK 0x4 - -#define PCIE_MISC_PCIE_STATUS 0x4068 -#define PCIE_MISC_PCIE_STATUS_PCIE_PORT_MASK 0x80 -#define PCIE_MISC_PCIE_STATUS_PCIE_DL_ACTIVE_MASK 0x20 -#define PCIE_MISC_PCIE_STATUS_PCIE_PHYLINKUP_MASK 0x10 -#define PCIE_MISC_PCIE_STATUS_PCIE_LINK_IN_L23_MASK 0x40 - -#define PCIE_MISC_REVISION 0x406c -#define BRCM_PCIE_HW_REV_33 0x0303 -#define BRCM_PCIE_HW_REV_3_20 0x0320 - -#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT 0x4070 -#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT_LIMIT_MASK 0xfff00000 -#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT_BASE_MASK 0xfff0 -#define PCIE_MEM_WIN0_BASE_LIMIT(win) \ - PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT + ((win) * 4) - -#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI 0x4080 -#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI_BASE_MASK 0xff -#define PCIE_MEM_WIN0_BASE_HI(win) \ - PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI + ((win) * 8) - -#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI 0x4084 -#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI_LIMIT_MASK 0xff -#define PCIE_MEM_WIN0_LIMIT_HI(win) \ - PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI + ((win) * 8) - -#define PCIE_MISC_HARD_PCIE_HARD_DEBUG 0x4204 -#define PCIE_MISC_HARD_PCIE_HARD_DEBUG_CLKREQ_DEBUG_ENABLE_MASK 0x2 -#define PCIE_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK 0x08000000 - - -#define PCIE_INTR2_CPU_BASE 0x4300 -#define PCIE_MSI_INTR2_BASE 0x4500 -/* Offsets from PCIE_INTR2_CPU_BASE and PCIE_MSI_INTR2_BASE */ -#define MSI_INT_STATUS 0x0 -#define MSI_INT_CLR 0x8 -#define MSI_INT_MASK_SET 0x10 -#define MSI_INT_MASK_CLR 0x14 - -#define PCIE_EXT_CFG_DATA 0x8000 -#define PCIE_EXT_CFG_INDEX 0x9000 - -#define PCIE_RGR1_SW_INIT_1_PERST_MASK 0x1 -#define PCIE_RGR1_SW_INIT_1_PERST_SHIFT 0x0 - -#define RGR1_SW_INIT_1_INIT_GENERIC_MASK 0x2 -#define RGR1_SW_INIT_1_INIT_GENERIC_SHIFT 0x1 -#define RGR1_SW_INIT_1_INIT_7278_MASK 0x1 -#define RGR1_SW_INIT_1_INIT_7278_SHIFT 0x0 - -/* PCIe parameters */ -#define BRCM_NUM_PCIE_OUT_WINS 0x4 -#define BRCM_INT_PCI_MSI_NR 32 -#define BRCM_INT_PCI_MSI_LEGACY_NR 8 -#define BRCM_INT_PCI_MSI_SHIFT 0 - -/* MSI target adresses */ -#define BRCM_MSI_TARGET_ADDR_LT_4GB 0x0fffffffcULL -#define BRCM_MSI_TARGET_ADDR_GT_4GB 0xffffffffcULL - -/* MDIO registers */ -#define MDIO_PORT0 0x0 -#define MDIO_DATA_MASK 0x7fffffff -#define MDIO_PORT_MASK 0xf0000 -#define MDIO_REGAD_MASK 0xffff -#define MDIO_CMD_MASK 0xfff00000 -#define MDIO_CMD_READ 0x1 -#define MDIO_CMD_WRITE 0x0 -#define MDIO_DATA_DONE_MASK 0x80000000 -#define MDIO_RD_DONE(x) (((x) & MDIO_DATA_DONE_MASK) ? 1 : 0) -#define MDIO_WT_DONE(x) (((x) & MDIO_DATA_DONE_MASK) ? 0 : 1) -#define SSC_REGS_ADDR 0x1100 -#define SET_ADDR_OFFSET 0x1f -#define SSC_CNTL_OFFSET 0x2 -#define SSC_CNTL_OVRD_EN_MASK 0x8000 -#define SSC_CNTL_OVRD_VAL_MASK 0x4000 -#define SSC_STATUS_OFFSET 0x1 -#define SSC_STATUS_SSC_MASK 0x400 -#define SSC_STATUS_PLL_LOCK_MASK 0x800 -#define PCIE_BRCM_MAX_MEMC 3 - -#define IDX_ADDR(pcie) (pcie->reg_offsets[EXT_CFG_INDEX]) -#define DATA_ADDR(pcie) (pcie->reg_offsets[EXT_CFG_DATA]) -#define PCIE_RGR1_SW_INIT_1(pcie) (pcie->reg_offsets[RGR1_SW_INIT_1]) - -/* Rescal registers */ -#define PCIE_DVT_PMU_PCIE_PHY_CTRL 0xc700 -#define PCIE_DVT_PMU_PCIE_PHY_CTRL_DAST_NFLDS 0x3 -#define PCIE_DVT_PMU_PCIE_PHY_CTRL_DAST_DIG_RESET_MASK 0x4 -#define PCIE_DVT_PMU_PCIE_PHY_CTRL_DAST_DIG_RESET_SHIFT 0x2 -#define PCIE_DVT_PMU_PCIE_PHY_CTRL_DAST_RESET_MASK 0x2 -#define PCIE_DVT_PMU_PCIE_PHY_CTRL_DAST_RESET_SHIFT 0x1 -#define PCIE_DVT_PMU_PCIE_PHY_CTRL_DAST_PWRDN_MASK 0x1 -#define PCIE_DVT_PMU_PCIE_PHY_CTRL_DAST_PWRDN_SHIFT 0x0 +#include "pcie-brcmstb.h" /* 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, - EXT_CFG_INDEX, - EXT_CFG_DATA, -}; - -enum { - RGR1_SW_INIT_1_INIT_MASK, - RGR1_SW_INIT_1_INIT_SHIFT, -}; - -enum pcie_type { - GENERIC, - BCM4908, - BCM7278, - BCM2711, -}; - -struct pcie_cfg_data { - const int *offsets; - const enum pcie_type type; - void (*perst_set)(struct brcm_pcie *pcie, u32 val); - 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, diff --git a/drivers/pci/controller/pcie-brcmstb.h b/drivers/pci/controller/pcie-brcmstb.h new file mode 100644 index 000000000000..b732a0ec56a0 --- /dev/null +++ b/drivers/pci/controller/pcie-brcmstb.h @@ -0,0 +1,182 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* Copyright (C) 2009 - 2021 Broadcom */ + +/* BRCM_PCIE_CAP_REGS - Offset for the mandatory capability config regs */ +#define BRCM_PCIE_CAP_REGS 0x00ac + +/* Broadcom STB PCIe Register Offsets */ +#define PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1 0x0188 +#define PCIE_RC_CFG_VENDOR_VENDOR_SPECIFIC_REG1_ENDIAN_MODE_BAR2_MASK 0xc +#define PCIE_RC_CFG_VENDOR_SPCIFIC_REG1_LITTLE_ENDIAN 0x0 + +#define PCIE_RC_CFG_PRIV1_ID_VAL3 0x043c +#define PCIE_RC_CFG_PRIV1_ID_VAL3_CLASS_CODE_MASK 0xffffff + +#define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY 0x04dc +#define PCIE_RC_CFG_PRIV1_LINK_CAPABILITY_ASPM_SUPPORT_MASK 0xc00 + +#define PCIE_RC_DL_MDIO_ADDR 0x1100 +#define PCIE_RC_DL_MDIO_WR_DATA 0x1104 +#define PCIE_RC_DL_MDIO_RD_DATA 0x1108 + +#define PCIE_MISC_MISC_CTRL 0x4008 +#define PCIE_MISC_MISC_CTRL_SCB_ACCESS_EN_MASK 0x1000 +#define PCIE_MISC_MISC_CTRL_CFG_READ_UR_MODE_MASK 0x2000 +#define PCIE_MISC_MISC_CTRL_MAX_BURST_SIZE_MASK 0x300000 + +#define PCIE_MISC_MISC_CTRL_SCB0_SIZE_MASK 0xf8000000 +#define PCIE_MISC_MISC_CTRL_SCB1_SIZE_MASK 0x07c00000 +#define PCIE_MISC_MISC_CTRL_SCB2_SIZE_MASK 0x0000001f +#define SCB_SIZE_MASK(x) PCIE_MISC_MISC_CTRL_SCB ## x ## _SIZE_MASK + +#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LO 0x400c +#define PCIE_MEM_WIN0_LO(win) \ + PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LO + ((win) * 8) + +#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_HI 0x4010 +#define PCIE_MEM_WIN0_HI(win) \ + PCIE_MISC_CPU_2_PCIE_MEM_WIN0_HI + ((win) * 8) + +#define PCIE_MISC_RC_BAR1_CONFIG_LO 0x402c +#define PCIE_MISC_RC_BAR1_CONFIG_LO_SIZE_MASK 0x1f + +#define PCIE_MISC_RC_BAR2_CONFIG_LO 0x4034 +#define PCIE_MISC_RC_BAR2_CONFIG_LO_SIZE_MASK 0x1f +#define PCIE_MISC_RC_BAR2_CONFIG_HI 0x4038 + +#define PCIE_MISC_RC_BAR3_CONFIG_LO 0x403c +#define PCIE_MISC_RC_BAR3_CONFIG_LO_SIZE_MASK 0x1f + +#define PCIE_MISC_MSI_BAR_CONFIG_LO 0x4044 +#define PCIE_MISC_MSI_BAR_CONFIG_HI 0x4048 + +#define PCIE_MISC_MSI_DATA_CONFIG 0x404c +#define PCIE_MISC_MSI_DATA_CONFIG_VAL_32 0xffe06540 +#define PCIE_MISC_MSI_DATA_CONFIG_VAL_8 0xfff86540 + +#define PCIE_MISC_PCIE_CTRL 0x4064 +#define PCIE_MISC_PCIE_CTRL_PCIE_L23_REQUEST_MASK 0x1 +#define PCIE_MISC_PCIE_CTRL_PCIE_PERSTB_MASK 0x4 + +#define PCIE_MISC_PCIE_STATUS 0x4068 +#define PCIE_MISC_PCIE_STATUS_PCIE_PORT_MASK 0x80 +#define PCIE_MISC_PCIE_STATUS_PCIE_DL_ACTIVE_MASK 0x20 +#define PCIE_MISC_PCIE_STATUS_PCIE_PHYLINKUP_MASK 0x10 +#define PCIE_MISC_PCIE_STATUS_PCIE_LINK_IN_L23_MASK 0x40 + +#define PCIE_MISC_REVISION 0x406c +#define BRCM_PCIE_HW_REV_33 0x0303 +#define BRCM_PCIE_HW_REV_3_20 0x0320 + +#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT 0x4070 +#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT_LIMIT_MASK 0xfff00000 +#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT_BASE_MASK 0xfff0 +#define PCIE_MEM_WIN0_BASE_LIMIT(win) \ + PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_LIMIT + ((win) * 4) + +#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI 0x4080 +#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI_BASE_MASK 0xff +#define PCIE_MEM_WIN0_BASE_HI(win) \ + PCIE_MISC_CPU_2_PCIE_MEM_WIN0_BASE_HI + ((win) * 8) + +#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI 0x4084 +#define PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI_LIMIT_MASK 0xff +#define PCIE_MEM_WIN0_LIMIT_HI(win) \ + PCIE_MISC_CPU_2_PCIE_MEM_WIN0_LIMIT_HI + ((win) * 8) + +#define PCIE_MISC_HARD_PCIE_HARD_DEBUG 0x4204 +#define PCIE_MISC_HARD_PCIE_HARD_DEBUG_CLKREQ_DEBUG_ENABLE_MASK 0x2 +#define PCIE_MISC_HARD_PCIE_HARD_DEBUG_SERDES_IDDQ_MASK 0x08000000 + + +#define PCIE_INTR2_CPU_BASE 0x4300 +#define PCIE_MSI_INTR2_BASE 0x4500 +/* Offsets from PCIE_INTR2_CPU_BASE and PCIE_MSI_INTR2_BASE */ +#define MSI_INT_STATUS 0x0 +#define MSI_INT_CLR 0x8 +#define MSI_INT_MASK_SET 0x10 +#define MSI_INT_MASK_CLR 0x14 + +#define PCIE_EXT_CFG_DATA 0x8000 +#define PCIE_EXT_CFG_INDEX 0x9000 + +#define PCIE_RGR1_SW_INIT_1_PERST_MASK 0x1 +#define PCIE_RGR1_SW_INIT_1_PERST_SHIFT 0x0 + +#define RGR1_SW_INIT_1_INIT_GENERIC_MASK 0x2 +#define RGR1_SW_INIT_1_INIT_GENERIC_SHIFT 0x1 +#define RGR1_SW_INIT_1_INIT_7278_MASK 0x1 +#define RGR1_SW_INIT_1_INIT_7278_SHIFT 0x0 + +/* PCIe parameters */ +#define BRCM_NUM_PCIE_OUT_WINS 0x4 +#define BRCM_INT_PCI_MSI_NR 32 +#define BRCM_INT_PCI_MSI_LEGACY_NR 8 +#define BRCM_INT_PCI_MSI_SHIFT 0 + +/* MSI target addresses */ +#define BRCM_MSI_TARGET_ADDR_LT_4GB 0x0fffffffcULL +#define BRCM_MSI_TARGET_ADDR_GT_4GB 0xffffffffcULL + +/* MDIO registers */ +#define MDIO_PORT0 0x0 +#define MDIO_DATA_MASK 0x7fffffff +#define MDIO_PORT_MASK 0xf0000 +#define MDIO_REGAD_MASK 0xffff +#define MDIO_CMD_MASK 0xfff00000 +#define MDIO_CMD_READ 0x1 +#define MDIO_CMD_WRITE 0x0 +#define MDIO_DATA_DONE_MASK 0x80000000 +#define MDIO_RD_DONE(x) (((x) & MDIO_DATA_DONE_MASK) ? 1 : 0) +#define MDIO_WT_DONE(x) (((x) & MDIO_DATA_DONE_MASK) ? 0 : 1) +#define SSC_REGS_ADDR 0x1100 +#define SET_ADDR_OFFSET 0x1f +#define SSC_CNTL_OFFSET 0x2 +#define SSC_CNTL_OVRD_EN_MASK 0x8000 +#define SSC_CNTL_OVRD_VAL_MASK 0x4000 +#define SSC_STATUS_OFFSET 0x1 +#define SSC_STATUS_SSC_MASK 0x400 +#define SSC_STATUS_PLL_LOCK_MASK 0x800 +#define PCIE_BRCM_MAX_MEMC 3 + +#define IDX_ADDR(pcie) (pcie->reg_offsets[EXT_CFG_INDEX]) +#define DATA_ADDR(pcie) (pcie->reg_offsets[EXT_CFG_DATA]) +#define PCIE_RGR1_SW_INIT_1(pcie) (pcie->reg_offsets[RGR1_SW_INIT_1]) + +/* Rescal registers */ +#define PCIE_DVT_PMU_PCIE_PHY_CTRL 0xc700 +#define PCIE_DVT_PMU_PCIE_PHY_CTRL_DAST_NFLDS 0x3 +#define PCIE_DVT_PMU_PCIE_PHY_CTRL_DAST_DIG_RESET_MASK 0x4 +#define PCIE_DVT_PMU_PCIE_PHY_CTRL_DAST_DIG_RESET_SHIFT 0x2 +#define PCIE_DVT_PMU_PCIE_PHY_CTRL_DAST_RESET_MASK 0x2 +#define PCIE_DVT_PMU_PCIE_PHY_CTRL_DAST_RESET_SHIFT 0x1 +#define PCIE_DVT_PMU_PCIE_PHY_CTRL_DAST_PWRDN_MASK 0x1 +#define PCIE_DVT_PMU_PCIE_PHY_CTRL_DAST_PWRDN_SHIFT 0x0 + +/* Forward declarations */ +struct brcm_pcie; + +enum { + RGR1_SW_INIT_1, + EXT_CFG_INDEX, + EXT_CFG_DATA, +}; + +enum { + RGR1_SW_INIT_1_INIT_MASK, + RGR1_SW_INIT_1_INIT_SHIFT, +}; + +enum pcie_type { + GENERIC, + BCM4908, + BCM7278, + BCM2711, +}; + +struct pcie_cfg_data { + const int *offsets; + const enum pcie_type type; + void (*perst_set)(struct brcm_pcie *pcie, u32 val); + void (*bridge_sw_init_set)(struct brcm_pcie *pcie, u32 val); +}; From patchwork Thu Aug 5 21:11:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 492275 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp664636jap; Thu, 5 Aug 2021 14:12:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZMl+XK5tvjffmmiJyDycOo6o5KNy3ur3FEfiSqkB9C4Jaru4/z1jafI74XW8cVCmXlLhR X-Received: by 2002:a50:cdcb:: with SMTP id h11mr9167111edj.366.1628197935605; Thu, 05 Aug 2021 14:12:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628197935; cv=none; d=google.com; s=arc-20160816; b=CbrNP1adYhkO80KxidjaSY4Dsv8S1PpNJv+QWnmbIDRX5JKCekcaMIFg75ir6pLPll X5fOK4NJ/2RrsgdaWNeD+mirK8iRFjqmMue6EE+cRyWb9s+Ssv7ew1KcSbNZKPnJsyim bKjuDOTutZWMW22z3IRwh2uEMIgpMThsZfmaHkxF+jXV6ApWRD3LSyjGpANkD9Vdzkub 7npjSRQxSJAJhlNSJ+153V5yFdInyB1+g1zUmao55U0qCdXAKwoD34Njrz3qxW462mS4 kE9aBWsbY3TsatsP+1qrf3tbNl/DuSSSHoQmQMJY/PKnsPI3wtnTdFh1CLmNEM9v+ATq x0pA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=/q8kx/DN8N9GocOhfKRU5+lTG9OgaItTwPBwFTpbttU=; b=BogEL8IUuaWTq4bUgo9/BB2w/JaRf9xPF/b6ErQ4AK24u5KTe08QJ9LFIHer4rJL4t NQT96yWz7sVMJfSs78V5RY+zRjzAV9M/v+VFlxpRSVethbUeQZhm2xIfPobBeUvWJz4E tN1Iy9INrLCI15XXHSOcmTE7BTkZs3a2eizquSNEbrpUlfHH7k8tXJu5pt+BQ1Jkeffx +X/K4jWBFw9sRfOqjRwl65elCK4MCrMbrJVL09atgL8N9QF9LSzS4NjrDw6KQcD5uhGO yqLOhcnqJrJ8gt+tnYNmpC2bjNG7BpLOd00wUzKeoep9Uy9vIFnDmPvyCVeQMcmDpQK3 jNeQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ee27si7087336edb.168.2021.08.05.14.12.15; Thu, 05 Aug 2021 14:12:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241870AbhHEVMX (ORCPT + 4 others); Thu, 5 Aug 2021 17:12:23 -0400 Received: from foss.arm.com ([217.140.110.172]:52408 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241842AbhHEVMX (ORCPT ); Thu, 5 Aug 2021 17:12:23 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 70D3112FC; Thu, 5 Aug 2021 14:12:08 -0700 (PDT) Received: from u200856.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C821E3F719; Thu, 5 Aug 2021 14:12:07 -0700 (PDT) From: Jeremy Linton To: linux-pci@vger.kernel.org Cc: lorenzo.pieralisi@arm.com, nsaenz@kernel.org, bhelgaas@google.com, rjw@rjwysocki.net, lenb@kernel.org, robh@kernel.org, kw@linux.com, f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rpi-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jeremy Linton Subject: [PATCH 2/3] PCI: brcmstb: Add ACPI config space quirk Date: Thu, 5 Aug 2021 16:11:59 -0500 Message-Id: <20210805211200.491275-3-jeremy.linton@arm.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210805211200.491275-1-jeremy.linton@arm.com> References: <20210805211200.491275-1-jeremy.linton@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org The PFTF CM4 is an ACPI platform that is following the PCIe SMCCC standard because its PCIe config space isn't ECAM compliant and is split into two parts. One part for the root port registers and a moveable window which points at a given device's 4K config space. Thus it doesn't have a MCFG (and really any MCFG provided would be nonsense anyway). As Linux doesn't support the PCIe SMCCC standard we key off a Linux specific host bridge _DSD to add custom ECAM ops and cfgres. The cfg op selects between those two regions, as well as disallowing problematic accesses, particularly if the link is down because there isn't an attached device. Signed-off-by: Jeremy Linton --- drivers/pci/controller/Makefile | 1 + drivers/pci/controller/pcie-brcmstb-acpi.c | 77 ++++++++++++++++++++++ include/linux/pci-ecam.h | 1 + 3 files changed, 79 insertions(+) create mode 100644 drivers/pci/controller/pcie-brcmstb-acpi.c -- 2.31.1 diff --git a/drivers/pci/controller/Makefile b/drivers/pci/controller/Makefile index aaf30b3dcc14..65aa6fd3ed89 100644 --- a/drivers/pci/controller/Makefile +++ b/drivers/pci/controller/Makefile @@ -57,5 +57,6 @@ ifdef CONFIG_PCI_QUIRKS obj-$(CONFIG_ARM64) += pci-thunder-ecam.o obj-$(CONFIG_ARM64) += pci-thunder-pem.o obj-$(CONFIG_ARM64) += pci-xgene.o +obj-$(CONFIG_ARM64) += pcie-brcmstb-acpi.o endif endif diff --git a/drivers/pci/controller/pcie-brcmstb-acpi.c b/drivers/pci/controller/pcie-brcmstb-acpi.c new file mode 100644 index 000000000000..76944876155f --- /dev/null +++ b/drivers/pci/controller/pcie-brcmstb-acpi.c @@ -0,0 +1,77 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * ACPI quirks for Brcm2711 PCIe host controller + * As used on the Raspberry Pi Compute Module 4 + * + * Copyright (C) 2021 Arm Ltd. + */ + +#include +#include +#include +#include +#include "../pci.h" +#include "pcie-brcmstb.h" + +static int brcm_acpi_init(struct pci_config_window *cfg) +{ + /* + * This platform doesn't technically have anything that could be called + * ECAM. Its config region has root port specific registers between + * standard PCIe defined config registers. Thus the region setup by the + * generic ECAM code needs to be adjusted. The HW can access bus 0-ff + * but the footprint isn't a nice power of 2 (40k). For purposes of + * mapping the config region we are just going to squash the standard + * and nonstandard registers together rather than mapping them + * separately. This code simply honors the quirk provided base+size + * instead. + */ + iounmap(cfg->win); + cfg->win = pci_remap_cfgspace(cfg->res.start, resource_size(&cfg->res)); + if (!cfg->win) + goto err_exit; + + /* MSI is nonstandard as well */ + pci_no_msi(); + + return 0; +err_exit: + dev_err(cfg->parent, "PCI: Failed to remap config\n"); + return -ENOMEM; +} + +static void __iomem *brcm_pcie_map_conf2(struct pci_bus *bus, unsigned int devfn, + int where) +{ + struct pci_config_window *cfg = bus->sysdata; + void __iomem *base = cfg->win; + int idx; + u32 up; + + /* Accesses to the RC go right to the RC registers if slot==0 */ + if (pci_is_root_bus(bus)) + return PCI_SLOT(devfn) ? NULL : base + where; + + /* Assure link up before sending request */ + up = readl(base + PCIE_MISC_PCIE_STATUS); + if (!(up & PCIE_MISC_PCIE_STATUS_PCIE_DL_ACTIVE_MASK)) + return NULL; + + if (!(up & PCIE_MISC_PCIE_STATUS_PCIE_PHYLINKUP_MASK)) + return NULL; + + /* For devices, write to the config space index register */ + idx = PCIE_ECAM_OFFSET(bus->number, devfn, 0); + writel(idx, base + PCIE_EXT_CFG_INDEX); + return base + PCIE_EXT_CFG_DATA + where; +} + +const struct pci_ecam_ops bcm2711_pcie_ops = { + .init = brcm_acpi_init, + .bus_shift = 1, + .pci_ops = { + .map_bus = brcm_pcie_map_conf2, + .read = pci_generic_config_read, + .write = pci_generic_config_write, + } +}; diff --git a/include/linux/pci-ecam.h b/include/linux/pci-ecam.h index adea5a4771cf..a5de0285bb7f 100644 --- a/include/linux/pci-ecam.h +++ b/include/linux/pci-ecam.h @@ -87,6 +87,7 @@ extern const struct pci_ecam_ops xgene_v1_pcie_ecam_ops; /* APM X-Gene PCIe v1 * extern const struct pci_ecam_ops xgene_v2_pcie_ecam_ops; /* APM X-Gene PCIe v2.x */ extern const struct pci_ecam_ops al_pcie_ops; /* Amazon Annapurna Labs PCIe */ extern const struct pci_ecam_ops tegra194_pcie_ops; /* Tegra194 PCIe */ +extern const struct pci_ecam_ops bcm2711_pcie_ops; /* Bcm2711 PCIe */ #endif #if IS_ENABLED(CONFIG_PCI_HOST_COMMON) From patchwork Thu Aug 5 21:12:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeremy Linton X-Patchwork-Id: 492276 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:396:0:0:0:0 with SMTP id y22csp664654jap; Thu, 5 Aug 2021 14:12:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDWwFeNH+O7vtFR9cUU9WOr9IHPTsAddlMJTzqsWyzXmVJmeVwPpB42Zs8xEulrSGIGo3P X-Received: by 2002:a17:906:4b56:: with SMTP id j22mr6839069ejv.551.1628197937104; Thu, 05 Aug 2021 14:12:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628197937; cv=none; d=google.com; s=arc-20160816; b=tTG0/pjbEmUvnXP1qPAPmvUJ9j912/doQ5TqspJ7+KdALGG16vlB+5zRBLSF2HZ0un VkXu5SxYj+GULNgQZFZkPKiZ9fgC2iOc6N3QogtVmdbvuY8ynpWvmrsz3OkL93TTELvg RKQXyzvAgwhwJTZjLZMhnCtxZOQuwhBGuwsBoHOP8htvHNd190S1CtEFd6ywif/fEzM7 1Y8/aYj7/auSWowkXriXFPF3OdvHu5eAHHK52lSg7thQHbwWVpXWs9/TBZbcURU64TOH AQ7I9oUJDZ8bVn8mtgOaxsulzhEk6Vn82uDg76xZbNtfgGFjvhVR5sGLShFj0Ve56TbJ 0/vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=vMTOoIh2k2fVmO6WSVZSdmmQDn9aY5x3TMn3rOnsNMc=; b=MoU63hyaUhsIYjOWAUGAYP7NabZugT30uYP1iZ4VObH0Hhd4GvwbYlSaP2Q66k9GMA DWwFsDHUocPL+ewLg+f8ulYESYPWMQQdpTtpKXdKfdYFjghP8mdqtI3d8NuvazH36Du/ YOmUn8TPDhiSmMWBOOz2nz0o5UOVloqvrj+iQdJRf4Ki60Sk9icUuGfYTUMj0P97q0uX b1Bby60+PGMTUp+hQvnyCJkRig4NGwHq7YYDl1ZUu4ugDjMU1AgDM2KnO09HK3Qg+1mb iqdIFBrkKjt2knSrObybG15Wog2/Bw7BHYIGtHvJBivEXfEF8A2f0XOnvyd3YMKcgoqV IsEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ee27si7087336edb.168.2021.08.05.14.12.16; Thu, 05 Aug 2021 14:12:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-acpi-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241942AbhHEVM1 (ORCPT + 4 others); Thu, 5 Aug 2021 17:12:27 -0400 Received: from foss.arm.com ([217.140.110.172]:52430 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241884AbhHEVMY (ORCPT ); Thu, 5 Aug 2021 17:12:24 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C262813D5; Thu, 5 Aug 2021 14:12:09 -0700 (PDT) Received: from u200856.usa.arm.com (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 225F83F719; Thu, 5 Aug 2021 14:12:09 -0700 (PDT) From: Jeremy Linton To: linux-pci@vger.kernel.org Cc: lorenzo.pieralisi@arm.com, nsaenz@kernel.org, bhelgaas@google.com, rjw@rjwysocki.net, lenb@kernel.org, robh@kernel.org, kw@linux.com, f.fainelli@gmail.com, bcm-kernel-feedback-list@broadcom.com, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-rpi-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Jeremy Linton Subject: [PATCH 3/3] PCI/ACPI: Add new quirk detection, enable bcm2711 Date: Thu, 5 Aug 2021 16:12:00 -0500 Message-Id: <20210805211200.491275-4-jeremy.linton@arm.com> X-Mailer: git-send-email 2.26.3 In-Reply-To: <20210805211200.491275-1-jeremy.linton@arm.com> References: <20210805211200.491275-1-jeremy.linton@arm.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org Now that we have a bcm2711 quirk, we need to be able to detect it when the MCFG is missing. Use a namespace property as an alternative to the MCFG OEM. Signed-off-by: Jeremy Linton --- drivers/acpi/pci_mcfg.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.31.1 diff --git a/drivers/acpi/pci_mcfg.c b/drivers/acpi/pci_mcfg.c index 53cab975f612..7d77fc72c2a4 100644 --- a/drivers/acpi/pci_mcfg.c +++ b/drivers/acpi/pci_mcfg.c @@ -169,6 +169,9 @@ static struct mcfg_fixup mcfg_quirks[] = { ALTRA_ECAM_QUIRK(1, 13), ALTRA_ECAM_QUIRK(1, 14), ALTRA_ECAM_QUIRK(1, 15), + + { "bcm2711", "", 0, 0, MCFG_BUS_ANY, &bcm2711_pcie_ops, + DEFINE_RES_MEM(0xFD500000, 0xA000) }, }; static char mcfg_oem_id[ACPI_OEM_ID_SIZE]; @@ -198,8 +201,19 @@ static void pci_mcfg_apply_quirks(struct acpi_pci_root *root, u16 segment = root->segment; struct resource *bus_range = &root->secondary; struct mcfg_fixup *f; + const char *soc; int i; + /* + * This could be a machine with a PCI/SMC conduit, + * which means it doens't have MCFG. Get the machineid from + * the namespace definition instead. + */ + if (!fwnode_property_read_string(acpi_fwnode_handle(root->device), + "linux,pcie-quirk", &soc)) { + memcpy(mcfg_oem_id, soc, ACPI_OEM_ID_SIZE); + } + for (i = 0, f = mcfg_quirks; i < ARRAY_SIZE(mcfg_quirks); i++, f++) { if (pci_mcfg_quirk_matches(f, segment, bus_range)) { if (f->cfgres.start)