Skip to contentSkip to conversation

PCI: brcmstb: Add Broadcom Settopbox PCIe support

PATCH Superseded Jim Quinlan 5 participants 22 messages Sep 6, 2018 – Sep 13, 2018

Subsystems (12)
lore
Share & tools
lore

Jim Quinlan

author maintainer
#0 lore raw

v5 cover PCI: brcmstb: Add Broadcom Settopbox PCIe support

This patch series adds support for the Broadcom Settopbox PCIe host controller. It is targeted to Broadcom Settopbox chips running on ARM, ARM64, and MIPS platforms.

V5 Changes:
- V4 had its own DMA ops structure in the PCIe driver which would override/coexist with the default arch DMA ops. This approach was scrapped, and this version instead essentially implements custom definitions of the __phys_to_dma and __dma_to_phys operations for the three target arches: MIPs, ARM64, ARM. This was the course suggested by one of the V4 reviewers (ChristophH).

For MIPs and ARM64, the DMA remapping is easily accomplished by having custom definitions of __phys_to_dma and __dma_to_phys. For MIPs/BMIPs, ARCH_HAS_PHYS_TO_DMA is already selected and the two functions are just modified. For ARM64, this driver selects ARCH_HAS_PHYS_TO_DMA and declares and defines __phys_to_dma() and __dma_to_phys(). For ARM, things were not so simple. The default functions like __arch_pfn_to_dma() had to be overridden by custom ones defined in arch/arm/mach-bcm/include/mach/memory.h. For these functions to be "seen", we had to declare our own brcmstb_defconfig and no longer use multi_v7_defconfig. This is unfortunate.

- Commits have been better organized to first implement the main driver, then add features (MSI, DMA remap infrastructure), and then add the DMA remapping modifications for MIPs, ARM64, and ARM.

V4 Changes:
- Merged all BrcmSTB PCIe controller files into a single file.
- All new files now have the SPDX identifier.
- Removed the list of PCIe controllers.
- Removed "link-up" race.
- Removed probe of msi psuedo-device.
- Multiple comment text changes, as requested.
- "SSC" => "Spread Spectrum Clocking".
- Set 'memc' variable.
- Unnecessary variable initializations removed (eg rc_bar2_size).
- Added comment on "L23" link state.
- Removed use of "__refdata".
- Formatting of structure elements.

V3 Changes:
- Fold pcie-brcmstb-msi.c into pcie-brcmstb.c
- Use PCI_XXX constants for PCIe capability registers
- Removal of any unused constants
- Change s/pci/pcie/ for filenames, comment text
- Config space access now uses 8/16/32 read/writes
- Use proper multi-line comment style
- Use function names, structure that are common in other host drivers
- DT binding 'brcm,ssc' is now 'brcm,enable-ssc'
- Dropped DT binding 'xyz-supply'
- Not setting CRS support as Linux does it if it is advertised.
- Removed code that was considered "debug code".
- Use of_get_pcie_domain_nr()
- Variable 'bridge_setup_done' removed.

V2 Changes:
* Patch brcmstb-add-memory-API:
- fix DT_PROP_DATA_TO_U32 macro.
- dropped one EXPORT_SYMBOL, changed the other to GPL.
* Patch DT-docs-for-Brcmstb-PCIe:
- change 'brcm,gen' prop to standard 'max-link-speed'.
- rewrite bindings commit to omit standard prop defs.
- change props "supplies", "supply-names" to "xyz-supply"
* Patch removed: export-symbol-arch_setup_dma_ops [4/9]
* Patch brcmstb-add-dma-ranges:
- use get_dma_ops(); also use a const dma_map_ops structure.
- rewrite map_sg(), unmap_sg(), other calls like syng_sg_*()
- omit brcm_mapping_error(), but added code in brcm_dma_supported()
- put all of the notifier code in one compilation unit.

Florian Fainelli (1):
soc: bcm: brcmstb: add memory API

Jim Quinlan (11):
dt-bindings: pci: add DT docs for Brcmstb PCIe device
PCI: brcmstb: add Broadcom STB PCIe host controller driver
PCI: brcmstb: add dma-range mapping for inbound traffic
PCI: brcmstb: add MSI capability
MIPS: BMIPS: add dma remap for BrcmSTB PCIe PCI/MSI: enable PCI_MSI_IRQ_DOMAIN support for MIPS
MIPS: BMIPS: add PCI bindings for 7425, 7435
MIPS: BMIPS: enable PCI
ARM64: declare __phys_to_dma on ARCH_HAS_PHYS_TO_DMA
ARM64: add dma remap for BrcmSTB PCIe
ARM: add dma remap for BrcmSTB PCIe

 .../devicetree/bindings/pci/brcmstb-pcie.txt       |   59 +
 arch/arm/Kconfig                                   |   33 +
 arch/arm/configs/brcmstb_defconfig                 |  204 +++
 arch/arm/configs/multi_v7_defconfig                |    3 -
 arch/arm/mach-bcm/Kconfig                          |   21 +-
 arch/arm/mach-bcm/Makefile.boot                    |    0
 arch/arm/mach-bcm/include/mach/irqs.h              |    3 +
 arch/arm/mach-bcm/include/mach/memory.h            |   47 +
 arch/arm/mach-bcm/include/mach/uncompress.h        |    8 +
 arch/arm64/include/asm/dma-direct.h                |   16 +
 arch/mips/Kconfig                                  |    3 +
 arch/mips/bmips/dma.c                              |    9 +
 arch/mips/boot/dts/brcm/bcm7425.dtsi               |   28 +
 arch/mips/boot/dts/brcm/bcm7435.dtsi               |   28 +
 arch/mips/boot/dts/brcm/bcm97425svmb.dts           |    4 +
 arch/mips/boot/dts/brcm/bcm97435svmb.dts           |    4 +
 drivers/pci/Kconfig                                |    2 +-
 drivers/pci/controller/Kconfig                     |   13 +
 drivers/pci/controller/Makefile                    |    1 +
 drivers/pci/controller/pcie-brcmstb.c              | 1554 ++++++++++++++++++++
 drivers/soc/bcm/brcmstb/Makefile                   |    2 +-
 drivers/soc/bcm/brcmstb/memory.c                   |  158 ++
 include/soc/brcmstb/common.h                       |   16 +
 include/soc/brcmstb/memory_api.h                   |   26 +
 24 files changed, 2217 insertions(+), 25 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pci/brcmstb-pcie.txt
 create mode 100644 arch/arm/configs/brcmstb_defconfig
 create mode 100644 arch/arm/mach-bcm/Makefile.boot
 create mode 100644 arch/arm/mach-bcm/include/mach/irqs.h
 create mode 100644 arch/arm/mach-bcm/include/mach/memory.h
 create mode 100644 arch/arm/mach-bcm/include/mach/uncompress.h
 create mode 100644 arch/arm64/include/asm/dma-direct.h
 create mode 100644 drivers/pci/controller/pcie-brcmstb.c
 create mode 100644 drivers/soc/bcm/brcmstb/memory.c
 create mode 100644 include/soc/brcmstb/memory_api.h
Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#1 lore raw

PATCH v5 1/12 soc: bcm: brcmstb: add memory API

From: Florian Fainelli <[email protected]>

This commit adds a memory API suitable for ascertaining the sizes of each of the N memory controllers in a Broadcom STB chip. Its first user will be the Broadcom STB PCIe root complex driver, which needs to know these sizes to properly set up DMA mappings for inbound regions.

We cannot use memblock here or anything like what Linux provides because it collapses adjacent regions within a larger block, and here we actually need per-memory controller addresses and sizes, which is why we resort to manual DT parsing.

---
 drivers/soc/bcm/brcmstb/Makefile |   2 +-
 drivers/soc/bcm/brcmstb/memory.c | 158 +++++++++++++++++++++++++++++++++++++++
 include/soc/brcmstb/memory_api.h |  26 +++++++
 3 files changed, 185 insertions(+), 1 deletion(-)
 create mode 100644 drivers/soc/bcm/brcmstb/memory.c
 create mode 100644 include/soc/brcmstb/memory_api.h
drivers/soc/bcm/brcmstb/Makefile +1 -1
index 01687c2..e4ccd3a 100644
@@ -1,2 +1,2 @@
-obj-y				+= common.o biuctrl.o
+obj-y				+= common.o biuctrl.o memory.o
 obj-$(CONFIG_BRCMSTB_PM)	+= pm/
drivers/soc/bcm/brcmstb/memory.c new file +158 -0

158 lines not on this page · raw message

include/soc/brcmstb/memory_api.h new file +26 -0
new file mode 100644
index 0000000..6546845
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __MEMORY_API_H
+#define __MEMORY_API_H
+
+/*
+ * Bus Interface Unit control register setup, must happen early during boot,
+ * before SMP is brought up, called by machine entry point.
+ */
+void brcmstb_biuctrl_init(void);
+
+#ifdef CONFIG_SOC_BRCMSTB
+int brcmstb_memory_phys_addr_to_memc(phys_addr_t pa);
+u64 brcmstb_memory_memc_size(int memc);
+#else
+static inline int brcmstb_memory_phys_addr_to_memc(phys_addr_t pa)
+{
+	return -EINVAL;
+}
+
+static inline u64 brcmstb_memory_memc_size(int memc)
+{
+	return -1;
+}
+#endif
+
+#endif /* __MEMORY_API_H */
Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#2 lore raw

PATCH v5 2/12 dt-bindings: pci: add DT docs for Brcmstb PCIe device

In reply to Jim Quinlan

The DT bindings description of the Brcmstb PCIe device is described. This node can be used by almost all Broadcom settop box chips, using ARM, ARM64, or MIPS CPU architectures.

---
 .../devicetree/bindings/pci/brcmstb-pcie.txt       | 59 ++++++++++++++++++++++
 1 file changed, 59 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/pci/brcmstb-pcie.txt
Documentation/devicetree/bindings/pci/brcmstb-pcie.txt new file +59 -0
new file mode 100644
index 0000000..a1a9ad5
@@ -0,0 +1,59 @@
+Brcmstb PCIe Host Controller Device Tree Bindings
+
+Required Properties:
+- compatible
+  "brcm,bcm7425-pcie" -- for 7425 family MIPS-based SOCs.
+  "brcm,bcm7435-pcie" -- for 7435 family MIPS-based SOCs.
+  "brcm,bcm7445-pcie" -- for 7445 and later ARM based SOCs (not including
+      the 7278).
+  "brcm,bcm7278-pcie"  -- for 7278 family ARM-based SOCs.
+
+- reg -- the register start address and length for the PCIe reg block.
+- interrupts -- two interrupts are specified; the first interrupt is for
+     the PCI host controller and the second is for MSI if the built-in
+     MSI controller is to be used.
+- interrupt-names -- names of the interrupts (above): "pcie" and "msi".
+- #address-cells -- set to <3>.
+- #size-cells -- set to <2>.
+- #interrupt-cells: set to <1>.
+- interrupt-map-mask and interrupt-map, standard PCI properties to define the
+     mapping of the PCIe interface to interrupt numbers.
+- ranges: ranges for the PCI memory and I/O regions.
+- linux,pci-domain -- should be unique per host controller.
+
+Optional Properties:
+- clocks -- phandle of pcie clock.
+- clock-names -- set to "sw_pcie" if clocks is used.
+- dma-ranges -- Specifies the inbound memory mapping regions when
+     an "identity map" is not possible.
+- msi-controller -- this property is typically specified to have the
+     PCIe controller use its internal MSI controller.
+- msi-parent -- set to use an external MSI interrupt controller.
+- brcm,enable-ssc -- (boolean) indicates usage of spread-spectrum clocking.
+- max-link-speed --  (integer) indicates desired generation of link:
+     1 => 2.5 Gbps (gen1), 2 => 5.0 Gbps (gen2), 3 => 8.0 Gbps (gen3).
+
+Example Node:
+
+pcie0: pcie@f0460000 {
+		reg = <0x0 0xf0460000 0x0 0x9310>;
+		interrupts = <0x0 0x0 0x4>;
+		compatible = "brcm,bcm7445-pcie";
+		#address-cells = <3>;
+		#size-cells = <2>;
+		ranges = <0x02000000 0x00000000 0x00000000 0x00000000 0xc0000000 0x00000000 0x08000000
+			  0x02000000 0x00000000 0x08000000 0x00000000 0xc8000000 0x00000000 0x08000000>;
+		#interrupt-cells = <1>;
+		interrupt-map-mask = <0 0 0 7>;
+		interrupt-map = <0 0 0 1 &intc 0 47 3
+				 0 0 0 2 &intc 0 48 3
+				 0 0 0 3 &intc 0 49 3
+				 0 0 0 4 &intc 0 50 3>;
+		clocks = <&sw_pcie0>;
+		clock-names = "sw_pcie";
+		msi-parent = <&pcie0>;  /* use PCIe's internal MSI controller */
+		msi-controller;         /* use PCIe's internal MSI controller */
+		brcm,ssc;
+		max-link-speed = <1>;
+		linux,pci-domain = <0>;
+	};
Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#3 lore raw

PATCH v5 3/12 PCI: brcmstb: add Broadcom STB PCIe host controller driver

In reply to Jim Quinlan

This commit adds the basic Broadcom STB PCIe controller. Missing is the ability to process MSI and also handle dma-ranges for inbound memory accesses. These two functionalities are added in subsequent commits.

The PCIe block contains an MDIO interface. This is a local interface only accessible by the PCIe controller. It cannot be used or shared by any other HW. As such, the small amount of code for this controller is included in this driver as there is little upside to put it elsewhere.

---
 drivers/pci/controller/Kconfig        |   12 +
 drivers/pci/controller/Makefile       |    1 +
 drivers/pci/controller/pcie-brcmstb.c | 1099 +++++++++++++++++++++++++++++++++
 3 files changed, 1112 insertions(+)
 create mode 100644 drivers/pci/controller/pcie-brcmstb.c
drivers/pci/controller/Kconfig +12 -0
index 028b287..c863c67 100644
@@ -278,5 +278,17 @@ config VMD
 	  To compile this driver as a module, choose M here: the
 	  module will be called vmd.
 
+config PCIE_BRCMSTB
+	bool "Broadcom Brcmstb PCIe host controller"
+	depends on ARCH_BRCMSTB || BMIPS_GENERIC
+	depends on OF
+	depends on SOC_BRCMSTB
+	default ARCH_BRCMSTB || BMIPS_GENERIC
+	help
+	  Say Y here to enable PCIe host controller support for
+	  Broadcom Settop Box SOCs.  A Broadcom SOC will may have
+	  multiple host controllers as opposed to a single host
+	  controller with multiple ports.
+
 source "drivers/pci/controller/dwc/Kconfig"
 endmenu
drivers/pci/controller/Makefile +1 -0
index d56a507..e76bfb2 100644
@@ -29,6 +29,7 @@ obj-$(CONFIG_PCIE_MEDIATEK) += pcie-mediatek.o
 obj-$(CONFIG_PCIE_MOBIVEIL) += pcie-mobiveil.o
 obj-$(CONFIG_PCIE_TANGO_SMP8759) += pcie-tango.o
 obj-$(CONFIG_VMD) += vmd.o
+obj-$(CONFIG_PCIE_BRCMSTB) += pcie-brcmstb.o
 # pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW
 obj-y				+= dwc/
 
drivers/pci/controller/pcie-brcmstb.c new file +1099 -0

1,099 lines not on this page · raw message

Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#4 lore raw

PATCH v5 4/12 PCI: brcmstb: add dma-range mapping for inbound traffic

In reply to Jim Quinlan

The Broadcom STB PCIe host controller is intimately related to the memory subsystem. This close relationship adds complexity to how cpu system memory is mapped to PCIe memory. Ideally, this mapping is an identity mapping, or an identity mapping off by a constant. Not so in this case.

Consider the Broadcom reference board BCM97445LCC_4X8 which has 6 GB of system memory. Here is how the PCIe controller maps the system memory to PCIe memory:

memc0-a@[ 0....3fffffff] <=> pci@[ 0....3fffffff]
memc0-b@[100000000...13fffffff] <=> pci@[ 40000000....7fffffff] memc1-a@[ 40000000....7fffffff] <=> pci@[ 80000000....bfffffff] memc1-b@[300000000...33fffffff] <=> pci@[ c0000000....ffffffff] memc2-a@[ 80000000....bfffffff] <=> pci@[100000000...13fffffff] memc2-b@[c00000000...c3fffffff] <=> pci@[140000000...17fffffff]

Although there are some "gaps" that can be added between the individual mappings by software, the permutation of memory regions for the most part is fixed by HW. The solution of having something close to an identity mapping is not possible.

The idea behind this HW design is that the same PCIe module can act as an RC or EP, and if it acts as an EP it concatenates all of system memory into a BAR so anything can be accessed. Unfortunately, when the PCIe block is in the role of an RC it also presents this "BAR" to downstream PCIe devices, rather than offering an identity map between its system memory and PCIe space.

Suppose that an endpoint driver allocs some DMA memory. Suppose this memory is located at 0x6000_0000, which is in the middle of memc1-a. The driver wants a dma_addr_t value that it can pass on to the EP to use. Without doing any custom mapping, the EP will use this value for
DMA: the driver will get a dma_addr_t equal to 0x6000_0000. But this won't work; the device needs a dma_addr_t that reflects the PCIe space address, namely 0xa000_0000.

So, essentially the solution to this problem must modify the dma_addr_t returned by the DMA routines routines. The method to do this is to redefine the __dma_to_phys() and __phys_to_dma() functions of the ARM, ARM64, and MIPS architectures. This commit sets up the infrastructure in the Brcm PCIe controller to prepare for this, while there is three other subsequent commits to implement/redefine these two functions for the three target architectures.

---
 drivers/pci/controller/pcie-brcmstb.c | 130 ++++++++++++++++++++++++++++++----
 include/soc/brcmstb/common.h          |  16 +++++
 2 files changed, 133 insertions(+), 13 deletions(-)
drivers/pci/controller/pcie-brcmstb.c +117 -13
index 9c87d10..abfa429 100644
@@ -21,6 +21,7 @@
 #include <linux/printk.h>
 #include <linux/sizes.h>
 #include <linux/slab.h>
+#include <soc/brcmstb/common.h>
 #include <soc/brcmstb/memory_api.h>
 #include <linux/string.h>
 #include <linux/types.h>
@@ -321,6 +322,7 @@ static void __iomem *brcm_pcie_map_conf(struct pci_bus *bus, unsigned int devfn,
 	(((val) & ~reg##_##field##_MASK) | \
 	 (reg##_##field##_MASK & (field_val << reg##_##field##_SHIFT)))
 
+static struct of_pci_range *brcm_dma_ranges;
 static phys_addr_t scb_size[BRCM_MAX_SCB];
 static int num_memc;
 static int num_pcie;
@@ -599,6 +601,79 @@ static inline void brcm_pcie_perst_set(struct brcm_pcie *pcie,
 		WR_FLD_RB(pcie->base, PCIE_MISC_PCIE_CTRL, PCIE_PERSTB, !val);
 }
 
+static int brcm_pcie_parse_map_dma_ranges(struct brcm_pcie *pcie)
+{
+	int i;
+	struct of_pci_range_parser parser;
+	struct device_node *dn = pcie->dn;
+
+	/*
+	 * Parse dma-ranges property if present.  If there are multiple
+	 * PCIe controllers, we only have to parse from one of them since
+	 * the others will have an identical mapping.
+	 */
+	if (!of_pci_dma_range_parser_init(&parser, dn)) {
+		struct of_pci_range *p;
+		unsigned int max_ranges = (parser.end - parser.range)
+			/ parser.np;
+
+		/* Add a null entry to indicate the end of the array */
+		brcm_dma_ranges = kcalloc(max_ranges + 1,
+					  sizeof(struct of_pci_range),
+					  GFP_KERNEL);
+		if (!brcm_dma_ranges)
+			return -ENOMEM;
+
+		p = brcm_dma_ranges;
+		while (of_pci_range_parser_one(&parser, p))
+			p++;
+	}
+
+	for (i = 0, num_memc = 0; i < BRCM_MAX_SCB; i++) {
+		u64 size = brcmstb_memory_memc_size(i);
+
+		if (size == (u64)-1) {
+			dev_err(pcie->dev, "cannot get memc%d size", i);
+			return -EINVAL;
+		} else if (size) {
+			scb_size[i] = roundup_pow_of_two_64(size);
+			num_memc++;
+		} else {
+			break;
+		}
+	}
+
+	return 0;
+}
+
+dma_addr_t brcm_phys_to_dma(struct device *dev, phys_addr_t paddr)
+{
+	struct of_pci_range *p;
+
+	if (!dev || !dev_is_pci(dev))
+		return (dma_addr_t)paddr;
+	for (p = brcm_dma_ranges; p && p->size; p++)
+		if (paddr >= p->cpu_addr && paddr < (p->cpu_addr + p->size))
+			return (dma_addr_t)(paddr - p->cpu_addr + p->pci_addr);
+
+	return (dma_addr_t)paddr;
+}
+
+phys_addr_t brcm_dma_to_phys(struct device *dev, dma_addr_t dev_addr)
+{
+	struct of_pci_range *p;
+
+	if (!dev || !dev_is_pci(dev))
+		return (phys_addr_t)dev_addr;
+	for (p = brcm_dma_ranges; p && p->size; p++)
+		if (dev_addr >= p->pci_addr
+		    && dev_addr < (p->pci_addr + p->size))
+			return (phys_addr_t)
+				(dev_addr - p->pci_addr + p->cpu_addr);
+
+	return (phys_addr_t)dev_addr;
+}
+
 static int brcm_pcie_add_controller(struct brcm_pcie *pcie)
 {
 	int i, ret = 0;
@@ -610,6 +685,10 @@ static int brcm_pcie_add_controller(struct brcm_pcie *pcie)
 		goto done;
 	}
 
+	ret = brcm_pcie_parse_map_dma_ranges(pcie);
+	if (ret)
+		goto done;
+
 	/* Determine num_memc and their sizes */
 	for (i = 0, num_memc = 0; i < BRCM_MAX_SCB; i++) {
 		u64 size = brcmstb_memory_memc_size(i);
@@ -639,8 +718,13 @@ static int brcm_pcie_add_controller(struct brcm_pcie *pcie)
 static void brcm_pcie_remove_controller(struct brcm_pcie *pcie)
 {
 	mutex_lock(&brcm_pcie_lock);
-	if (--num_pcie == 0)
-		num_memc = 0;
+	if (--num_pcie > 0)
+		goto out;
+
+	kfree(brcm_dma_ranges);
+	brcm_dma_ranges = NULL;
+	num_memc = 0;
+out:
 	mutex_unlock(&brcm_pcie_lock);
 }
 
@@ -747,11 +831,37 @@ static int brcm_pcie_setup(struct brcm_pcie *pcie)
 	 */
 	rc_bar2_size = roundup_pow_of_two_64(total_mem_size);
 
-	/*
-	 * Set simple configuration based on memory sizes
-	 * only.  We always start the viewport at address 0.
-	 */
-	rc_bar2_offset = 0;
+	if (brcm_dma_ranges) {
+		/*
+		 * The best-case scenario is to place the inbound
+		 * region in the first 4GB of pcie-space, as some
+		 * legacy devices can only address 32bits.
+		 * We would also like to put the MSI under 4GB
+		 * as well, since some devices require a 32bit
+		 * MSI target address.
+		 */
+		if (total_mem_size <= 0xc0000000ULL &&
+		    rc_bar2_size <= 0x100000000ULL) {
+			rc_bar2_offset = 0;
+		} else {
+			/*
+			 * The system memory is 4GB or larger so we
+			 * cannot start the inbound region at location
+			 * 0 (since we have to allow some space for
+			 * outbound memory @ 3GB).  So instead we
+			 * start it at the 1x multiple of its size
+			 */
+			rc_bar2_offset = rc_bar2_size;
+		}
+
+	} else {
+		/*
+		 * Set simple configuration based on memory sizes
+		 * only.  We always start the viewport at address 0,
+		 * and set the MSI target address accordingly.
+		 */
+		rc_bar2_offset = 0;
+	}
 
 	tmp = lower_32_bits(rc_bar2_offset);
 	tmp = INSERT_FIELD(tmp, PCIE_MISC_RC_BAR2_CONFIG_LO, SIZE,
@@ -969,7 +1079,6 @@ static int brcm_pcie_probe(struct platform_device *pdev)
 	struct brcm_pcie *pcie;
 	struct resource *res;
 	void __iomem *base;
-	u32 tmp;
 	struct pci_host_bridge *bridge;
 	struct pci_bus *child;
 
@@ -986,11 +1095,6 @@ static int brcm_pcie_probe(struct platform_device *pdev)
 		return -EINVAL;
 	}
 
-	if (of_property_read_u32(dn, "dma-ranges", &tmp) == 0) {
-		dev_err(&pdev->dev, "cannot yet handle dma-ranges\n");
-		return -EINVAL;
-	}
-
 	data = of_id->data;
 	pcie->reg_offsets = data->offsets;
 	pcie->reg_field_info = data->reg_field_info;
include/soc/brcmstb/common.h +16 -0
index cfb5335..a7f19e0 100644
@@ -12,4 +12,20 @@
 
 bool soc_is_brcmstb(void);
 
+#if defined(CONFIG_PCIE_BRCMSTB)
+dma_addr_t brcm_phys_to_dma(struct device *dev, phys_addr_t paddr);
+phys_addr_t brcm_dma_to_phys(struct device *dev, dma_addr_t dev_addr);
+#else
+static inline dma_addr_t brcm_phys_to_dma(struct device *dev, phys_addr_t paddr)
+{
+	return (dma_addr_t)paddr;
+}
+
+static inline phys_addr_t brcm_dma_to_phys(struct device *dev,
+					   dma_addr_t dev_addr)
+{
+	return (phys_addr_t)dev_addr;
+}
+#endif
+
 #endif /* __SOC_BRCMSTB_COMMON_H__ */
Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#5 lore raw

PATCH v5 5/12 PCI: brcmstb: add MSI capability

In reply to Jim Quinlan

This commit adds MSI to the Broadcom STB PCIe host controller. It does not add MSIX since that functionality is not in the HW. The MSI controller is physically located within the PCIe block, however, there is no reason why the MSI controller could not be moved elsewhere in the future.

Since the internal Brcmstb MSI controller is intertwined with the PCIe controller, it is not its own platform device but rather part of the PCIe platform device.

---
 drivers/pci/controller/Kconfig        |   2 +-
 drivers/pci/controller/pcie-brcmstb.c | 361 ++++++++++++++++++++++++++++++++--
 2 files changed, 351 insertions(+), 12 deletions(-)
drivers/pci/controller/Kconfig +1 -1
index c863c67..8daa621 100644
@@ -281,7 +281,7 @@ config VMD
 config PCIE_BRCMSTB
 	bool "Broadcom Brcmstb PCIe host controller"
 	depends on ARCH_BRCMSTB || BMIPS_GENERIC
-	depends on OF
+	depends on OF && PCI_MSI
 	depends on SOC_BRCMSTB
 	default ARCH_BRCMSTB || BMIPS_GENERIC
 	help
drivers/pci/controller/pcie-brcmstb.c +350 -11

477 lines not on this page · raw message

Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#6 lore raw

PATCH v5 6/12 MIPS: BMIPS: add dma remap for BrcmSTB PCIe

In reply to Jim Quinlan

The design of the Broadcom PCIe RC controller requires us to remap its DMA addresses for inbound traffic. We do this by modifying the definitions of __phys_to_dma() and __dma_to_phys().

In arch/mips/bmips/dma.c, these functions are already in use to remap DMA addresses for the 338x SOC chips. We leave this code alone -- and give its mapping priority -- but if it is not in use, the PCIe DMA mapping is in effect.

One might think that the two DMA remapping systems of dma.c could be combined, but they cannot: one governs only DMA addresses for the PCIe controller of BrcmSTB ARM/ARM64/MIPs chips, while the other governs the PCIe controller *and* other peripherals for only MIPs 338x chips.

---
 arch/mips/bmips/dma.c | 9 +++++++++
 1 file changed, 9 insertions(+)
arch/mips/bmips/dma.c +9 -0
index 3d13c77..292994f 100644
@@ -18,6 +18,7 @@
 #include <linux/slab.h>
 #include <linux/types.h>
 #include <asm/bmips.h>
+#include <soc/brcmstb/common.h>
 
 /*
  * BCM338x has configurable address translation windows which allow the
@@ -44,6 +45,10 @@ dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t pa)
 {
 	struct bmips_dma_range *r;
 
+#ifdef CONFIG_PCIE_BRCMSTB
+	if (!bmips_dma_ranges)
+		return brcm_phys_to_dma(dev, pa);
+#endif
 	for (r = bmips_dma_ranges; r && r->size; r++) {
 		if (pa >= r->child_addr &&
 		    pa < (r->child_addr + r->size))
@@ -56,6 +61,10 @@ phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dma_addr)
 {
 	struct bmips_dma_range *r;
 
+#ifdef CONFIG_PCIE_BRCMSTB
+	if (!bmips_dma_ranges)
+		return (unsigned long)brcm_dma_to_phys(dev, dma_addr);
+#endif
 	for (r = bmips_dma_ranges; r && r->size; r++) {
 		if (dma_addr >= r->parent_addr &&
 		    dma_addr < (r->parent_addr + r->size))
Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#7 lore raw

PATCH v5 7/12 PCI/MSI: enable PCI_MSI_IRQ_DOMAIN support for MIPS

In reply to Jim Quinlan

Add MIPS as an arch that supports PCI_MSI_IRQ_DOMAIN and add generation of msi.h in the MIPS arch.

---
 drivers/pci/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/Kconfig +1 -1
index 56ff8f6..61a9539 100644
@@ -22,7 +22,7 @@ config PCI_MSI
 	   If you don't know what to do here, say Y.
 
 config PCI_MSI_IRQ_DOMAIN
-	def_bool ARC || ARM || ARM64 || X86
+	def_bool ARC || ARM || ARM64 || MIPS || X86
 	depends on PCI_MSI
 	select GENERIC_MSI_IRQ_DOMAIN
 
Signature · 1 line
1.9.0.138.g2de3478
Acked-by on v5 7/12
#8 lore raw

Re: [PATCH v5 07/12] PCI/MSI: enable PCI_MSI_IRQ_DOMAIN support for MIPS

Hi Jim,

Quoted 2 lines · Jim Quinlan

Add MIPS as an arch that supports PCI_MSI_IRQ_DOMAIN and add generation of msi.h in the MIPS arch.

I guess the second part of this probably became untrue after rebasing atop something including commit 34a4399f196c ("mips: use asm-generic version of msi.h"), and ought to be removed.

Quoted 4 lines
---
 drivers/pci/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Otherwise this looks fine:

Thanks,
Paul

author maintainer
#9 lore raw

Re: [PATCH v5 07/12] PCI/MSI: enable PCI_MSI_IRQ_DOMAIN support for MIPS

Quoted 10 lines · Paul Burton

Hi Jim,

Quoted 2 lines · Jim Quinlan

Add MIPS as an arch that supports PCI_MSI_IRQ_DOMAIN and add generation of msi.h in the MIPS arch.

I guess the second part of this probably became untrue after rebasing atop something including commit 34a4399f196c ("mips: use asm-generic version of msi.h"), and ought to be removed.

Hi Paul,

Yes, the second clause of this commit message will be removed.

Thanks,
Jim

Quoted 12 lines
Quoted 5 lines
---
 drivers/pci/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Otherwise this looks fine:

Thanks,
Paul

author maintainer
#10 lore raw

PATCH v5 8/12 MIPS: BMIPS: add PCI bindings for 7425, 7435

In reply to Jim Quinlan

Adds the PCIe nodes for the Broadcom STB PCIe root complex.

---
 arch/mips/boot/dts/brcm/bcm7425.dtsi     | 28 ++++++++++++++++++++++++++++
 arch/mips/boot/dts/brcm/bcm7435.dtsi     | 28 ++++++++++++++++++++++++++++
 arch/mips/boot/dts/brcm/bcm97425svmb.dts |  4 ++++
 arch/mips/boot/dts/brcm/bcm97435svmb.dts |  4 ++++
 4 files changed, 64 insertions(+)
arch/mips/boot/dts/brcm/bcm7425.dtsi +28 -0
index 410e61e..0edcbe4 100644
@@ -584,4 +584,32 @@
 			};
 		};
 	};
+
+	pcie: pcie@10410000 {
+		reg = <0x10410000 0x830c>;
+		compatible = "brcm,bcm7425-pcie";
+		interrupts = <37>, <37>;
+		interrupt-names = "pcie", "msi";
+		interrupt-parent = <&periph_intc>;
+		#address-cells = <3>;
+		#size-cells = <2>;
+		linux,pci-domain = <0>;
+		brcm,enable-ssc;
+		bus-range = <0x00 0xff>;
+		msi-controller;
+		#interrupt-cells = <1>;
+		/* 4x128mb windows */
+		ranges = <0x2000000 0x0 0xd0000000 0xd0000000 0x0 0x20000000>;
+		/* 768M or 1GB memc0, 0-1GB memc1 */
+		dma-ranges =
+			<0x02000000 0x0 0x00000000 0x00000000 0x0 0x10000000>,
+			<0x02000000 0x0 0x10000000 0x20000000 0x0 0x30000000>,
+			<0x02000000 0x0 0x40000000 0x90000000 0x0 0x40000000>;
+		interrupt-map-mask = <0 0 0 7>;
+		interrupt-map = <0 0 0 1 &periph_intc 33
+				 0 0 0 2 &periph_intc 34
+				 0 0 0 3 &periph_intc 35
+				 0 0 0 4 &periph_intc 36>;
+	};
+
 };
arch/mips/boot/dts/brcm/bcm7435.dtsi +28 -0
index 8398b7f..50bc7a0 100644
@@ -599,4 +599,32 @@
 			};
 		};
 	};
+
+	pcie: pcie@10410000 {
+		reg = <0x10410000 0x930c>;
+		interrupts = <0x27>, <0x27>;
+		interrupt-names = "pcie", "msi";
+		interrupt-parent = <&periph_intc>;
+		compatible = "brcm,bcm7435-pcie";
+		#address-cells = <3>;
+		#size-cells = <2>;
+		linux,pci-domain = <0>;
+		brcm,enable-ssc;
+		bus-range = <0x00 0xff>;
+		msi-controller;
+		#interrupt-cells = <1>;
+		ranges = <0x2000000 0x0 0xd0000000 0xd0000000 0x0 0x20000000>;
+		/* 768M or 1GB memc0, 0-1GB memc1 */
+		dma-ranges =
+			<0x02000000 0x0 0x00000000 0x00000000 0x0 0x10000000>,
+			<0x02000000 0x0 0x10000000 0x20000000 0x0 0x30000000>,
+			<0x02000000 0x0 0x40000000 0x90000000 0x0 0x40000000>;
+		interrupt-map-mask = <0 0 0 7>;
+		interrupt-map = <0 0 0 1 &periph_intc 35
+				 0 0 0 2 &periph_intc 36
+				 0 0 0 3 &periph_intc 37
+				 0 0 0 4 &periph_intc 38>;
+		status = "disabled";
+	};
+
 };
arch/mips/boot/dts/brcm/bcm97425svmb.dts +4 -0
index 0ed2221..22270a9 100644
@@ -152,3 +152,7 @@
 &waketimer {
 	status = "okay";
 };
+
+&pcie {
+	status = "okay";
+};
arch/mips/boot/dts/brcm/bcm97435svmb.dts +4 -0
index 2c145a8..91bc1ec 100644
@@ -128,3 +128,7 @@
 &waketimer {
 	status = "okay";
 };
+
+&pcie {
+	status = "okay";
+};
Signature · 1 line
1.9.0.138.g2de3478
Acked-by on v5 8/12
#11 lore raw

Re: [PATCH v5 08/12] MIPS: BMIPS: add PCI bindings for 7425, 7435

Hi Jim,

Quoted 9 lines · Jim Quinlan

Adds the PCIe nodes for the Broadcom STB PCIe root complex.

---
 arch/mips/boot/dts/brcm/bcm7425.dtsi     | 28 ++++++++++++++++++++++++++++
 arch/mips/boot/dts/brcm/bcm7435.dtsi     | 28 ++++++++++++++++++++++++++++
 arch/mips/boot/dts/brcm/bcm97425svmb.dts |  4 ++++
 arch/mips/boot/dts/brcm/bcm97435svmb.dts |  4 ++++
 4 files changed, 64 insertions(+)

Do you have a preference for how this gets merged? If it goes via the PCI tree then for patches 8 & 9:

Still looking at patch 6.

Thanks,
Paul

author maintainer
#12 lore raw

Re: [PATCH v5 08/12] MIPS: BMIPS: add PCI bindings for 7425, 7435

Quoted 14 lines · Paul Burton

Hi Jim,

Quoted 9 lines · Jim Quinlan

Adds the PCIe nodes for the Broadcom STB PCIe root complex.

---
 arch/mips/boot/dts/brcm/bcm7425.dtsi     | 28 ++++++++++++++++++++++++++++
 arch/mips/boot/dts/brcm/bcm7435.dtsi     | 28 ++++++++++++++++++++++++++++
 arch/mips/boot/dts/brcm/bcm97425svmb.dts |  4 ++++
 arch/mips/boot/dts/brcm/bcm97435svmb.dts |  4 ++++
 4 files changed, 64 insertions(+)
Quoted 5 lines

Do you have a preference for how this gets merged? If it goes via the PCI tree then for patches 8 & 9:

Hi Paul,

I hope that the 12 commits go together and will go through the PCI tree. I'm inclined to think I will have to do a V6, and in the cover leter I will mention this request.

Thanks!
Jim

Quoted 4 lines

Still looking at patch 6.

Thanks,
Paul

#13 lore raw

Re: [PATCH v5 08/12] MIPS: BMIPS: add PCI bindings for 7425, 7435

Quoted 18 lines · Jim Quinlan
Quoted 17 lines · Paul Burton

Hi Jim,

Quoted 9 lines · Jim Quinlan

Adds the PCIe nodes for the Broadcom STB PCIe root complex.

---
 arch/mips/boot/dts/brcm/bcm7425.dtsi     | 28 ++++++++++++++++++++++++++++
 arch/mips/boot/dts/brcm/bcm7435.dtsi     | 28 ++++++++++++++++++++++++++++
 arch/mips/boot/dts/brcm/bcm97425svmb.dts |  4 ++++
 arch/mips/boot/dts/brcm/bcm97435svmb.dts |  4 ++++
 4 files changed, 64 insertions(+)

Do you have a preference for how this gets merged? If it goes via the PCI tree then for patches 8 & 9:

Quoted 7 lines
Quoted 2 lines

Hi Paul,

I hope that the 12 commits go together and will go through the PCI tree. I'm inclined to think I will have to do a V6, and in the cover leter I will mention this request.

Somehow nothing of the v5 patch series seem to have made it to any mailing lists, at least I can't find them in my inbox (or spam) in any of the mailing lists, nor through the public archives of e.g. LKML. Patchwork (ozlabs and kernel) doesn't know of them either.

Regards
Jonas

#14 lore raw

Re: [PATCH v5 08/12] MIPS: BMIPS: add PCI bindings for 7425, 7435

Quoted 23 lines · Jonas Gorski
Quoted 22 lines · Jim Quinlan
Quoted 14 lines · Paul Burton

Hi Jim,

Quoted 9 lines · Jim Quinlan

Adds the PCIe nodes for the Broadcom STB PCIe root complex.

---
  arch/mips/boot/dts/brcm/bcm7425.dtsi     | 28 ++++++++++++++++++++++++++++
  arch/mips/boot/dts/brcm/bcm7435.dtsi     | 28 ++++++++++++++++++++++++++++
  arch/mips/boot/dts/brcm/bcm97425svmb.dts |  4 ++++
  arch/mips/boot/dts/brcm/bcm97435svmb.dts |  4 ++++
  4 files changed, 64 insertions(+)
Quoted 5 lines

Do you have a preference for how this gets merged? If it goes via the PCI tree then for patches 8 & 9:

Hi Paul,

Quoted 8 lines
Quoted 3 lines

I hope that the 12 commits go together and will go through the PCI tree. I'm inclined to think I will have to do a V6, and in the cover leter I will mention this request.

Somehow nothing of the v5 patch series seem to have made it to any mailing lists, at least I can't find them in my inbox (or spam) in any of the mailing lists, nor through the public archives of e.g. LKML. Patchwork (ozlabs and kernel) doesn't know of them either.

Indeed, that would explain why there has been little discussion on this....

Signature · 1 line
Florian
author maintainer
#15 lore raw

PATCH v5 9/12 MIPS: BMIPS: enable PCI

In reply to Jim Quinlan

Adds the Kconfig hooks to enable the Broadcom STB PCIe root complex driver for Broadcom MIPS systems.

---
 arch/mips/Kconfig | 3 +++
 1 file changed, 3 insertions(+)
arch/mips/Kconfig +3 -0
index 3551199..a15c0da 100644
@@ -220,6 +220,9 @@ config BMIPS_GENERIC
 	select BOOT_RAW
 	select NO_EXCEPT_FILL
 	select USE_OF
+	select HW_HAS_PCI
+	select PCI_DRIVERS_GENERIC
+	select PCI
 	select CEVT_R4K
 	select CSRC_R4K
 	select SYNC_R4K
Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#16 lore raw

PATCH v5 10/12 ARM64: declare __phys_to_dma on ARCH_HAS_PHYS_TO_DMA

In reply to Jim Quinlan

This change allows one to define custom routines for __phys_to_dma() and __dma_to_phys() for the ARM64 architecture by selecting ARCH_HAS_PHYS_TO_DMA. This is done for similar reasons that caused arch/x86/include/asm/dma-direct.h to exist (see CONFIG_STA2X11).

---
 arch/arm64/include/asm/dma-direct.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 arch/arm64/include/asm/dma-direct.h
arch/arm64/include/asm/dma-direct.h new file +16 -0
new file mode 100644
index 0000000..d87da92
@@ -0,0 +1,16 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _ARM64_DMA_DIRECT_H
+#define _ARM64_DMA_DIRECT_H 1
+
+static inline bool dma_capable(struct device *dev, dma_addr_t addr, size_t size)
+{
+	if (!dev->dma_mask)
+		return false;
+
+	return addr + size - 1 <= *dev->dma_mask;
+}
+
+dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr);
+phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t daddr);
+
+#endif /* _ARM64_DMA_DIRECT_H */
Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#17 lore raw

PATCH v5 11/12 ARM64: add dma remap for BrcmSTB PCIe

In reply to Jim Quinlan

The BrcmSTB PCIe controller needs to remap DMA accesses to it because of the requirements of its interface with the SOC memory controllers.

---
 drivers/pci/controller/Kconfig        |  1 +
 drivers/pci/controller/pcie-brcmstb.c | 12 ++++++++++++
 2 files changed, 13 insertions(+)
drivers/pci/controller/Kconfig +1 -0
index 8daa621..4394430 100644
@@ -284,6 +284,7 @@ config PCIE_BRCMSTB
 	depends on OF && PCI_MSI
 	depends on SOC_BRCMSTB
 	default ARCH_BRCMSTB || BMIPS_GENERIC
+	select ARCH_HAS_PHYS_TO_DMA if ARM64
 	help
 	  Say Y here to enable PCIe host controller support for
 	  Broadcom Settop Box SOCs.  A Broadcom SOC will may have
drivers/pci/controller/pcie-brcmstb.c +12 -0
index a805d87..ae9df8e 100644
@@ -974,6 +974,18 @@ phys_addr_t brcm_dma_to_phys(struct device *dev, dma_addr_t dev_addr)
 	return (phys_addr_t)dev_addr;
 }
 
+#if defined(CONFIG_ARM64)
+dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr)
+{
+	return brcm_phys_to_dma(dev, paddr);
+}
+
+phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t dev_addr)
+{
+	return brcm_dma_to_phys(dev, dev_addr);
+}
+#endif
+
 static int brcm_pcie_add_controller(struct brcm_pcie *pcie)
 {
 	int i, ret = 0;
Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#18 lore raw

PATCH v5 12/12 ARM: add dma remap for BrcmSTB PCIe

In reply to Jim Quinlan

The BrcmSTB PCIe controller needs to remap DMA accesses to it because of the requirements of its interface with the SOC memory controllers. In the ARM64 and MIPs architectures, this is accomplished by CONFIG_ARCH_HAS_PHYS_TO_DMA=y and then defining the functions __dma_to_phys() and __phys_to_dma() accordingly.

Doing so for the ARM architecture is not as easy as ARM64 and MIPS; the two functions are already defined as static inline functions. Howevery, the behavior of these functions may be changed by redefining the sub-functions that these two functions invoke.

Specifically, this commit defines

	__arch_pfn_to_dma()
	__arch_dma_to_pfn()
	__arch_dma_to_virt()
	__arch_virt_to_dma()

as these are the functions invoked by __dma_to_phys() and __phys_to_dma(). Unfortunately, the only apparent approach to do this is to declare and define the four sub-functions in arch/arm/mach-bcm/include/mach/memory.h, and in doing so we must move out of ARCH_MULTIPLATFORM and create brcmstb_defconfig, as we were previously using multi_v7_defconfig.

---
 arch/arm/Kconfig                            |  33 +++++
 arch/arm/configs/brcmstb_defconfig          | 204 ++++++++++++++++++++++++++++
 arch/arm/configs/multi_v7_defconfig         |   3 -
 arch/arm/mach-bcm/Kconfig                   |  21 +--
 arch/arm/mach-bcm/Makefile.boot             |   0
 arch/arm/mach-bcm/include/mach/irqs.h       |   3 +
 arch/arm/mach-bcm/include/mach/memory.h     |  47 +++++++
 arch/arm/mach-bcm/include/mach/uncompress.h |   8 ++
 8 files changed, 296 insertions(+), 23 deletions(-)
 create mode 100644 arch/arm/configs/brcmstb_defconfig
 create mode 100644 arch/arm/mach-bcm/Makefile.boot
 create mode 100644 arch/arm/mach-bcm/include/mach/irqs.h
 create mode 100644 arch/arm/mach-bcm/include/mach/memory.h
 create mode 100644 arch/arm/mach-bcm/include/mach/uncompress.h
arch/arm/Kconfig +33 -0
index e8cd55a..913765b 100644
@@ -637,6 +637,39 @@ config ARCH_OMAP1
 	help
 	  Support for older TI OMAP1 (omap7xx, omap15xx or omap16xx)
 
+config ARCH_BRCMSTB
+	bool "Broadcom BCM7XXX based boards"
+	select ARM_HAS_SG_CHAIN
+	select ARM_PATCH_PHYS_VIRT
+	select TIMER_OF
+	select COMMON_CLK
+	select GENERIC_CLOCKEVENTS
+	select MULTI_IRQ_HANDLER
+	select MIGHT_HAVE_PCI
+	select PCI_DOMAINS if PCI
+	select USE_OF
+
+	select CPU_V7
+	select ARCH_BCM
+	select HAVE_SMP
+	select AUTO_ZRELADDR
+	select ARM_GIC
+	select ARM_GIC_V3
+	select HAVE_ARM_ARCH_TIMER
+	select SPARSE_IRQ
+	select BRCMSTB_L2_IRQ
+	select BCM7120_L2_IRQ
+	select ARCH_HAS_HOLES_MEMORYMODEL
+	select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE
+	select ZONE_DMA if ARM_LPAE
+	select NEED_MACH_MEMORY_H
+	help
+	  Say Y if you intend to run the kernel on a Broadcom ARM-based STB
+	  chipset.
+
+	  This enables support for Broadcom ARM-based set-top box chipsets,
+	  including the 7445 family of chips.
+
 endchoice
 
 menu "Multiple platform selection"
arch/arm/configs/brcmstb_defconfig new file +204 -0

204 lines not on this page · raw message

arch/arm/configs/multi_v7_defconfig +0 -3
index fc33444..33c91f8 100644
@@ -17,7 +17,6 @@ CONFIG_ARCH_AT91=y
 CONFIG_SOC_SAMA5D2=y
 CONFIG_SOC_SAMA5D3=y
 CONFIG_SOC_SAMA5D4=y
-CONFIG_ARCH_BCM=y
 CONFIG_ARCH_BCM_CYGNUS=y
 CONFIG_ARCH_BCM_HR2=y
 CONFIG_ARCH_BCM_NSP=y
@@ -26,7 +25,6 @@ CONFIG_ARCH_BCM_281XX=y
 CONFIG_ARCH_BCM_21664=y
 CONFIG_ARCH_BCM2835=y
 CONFIG_ARCH_BCM_63XX=y
-CONFIG_ARCH_BRCMSTB=y
 CONFIG_ARCH_BERLIN=y
 CONFIG_MACH_BERLIN_BG2=y
 CONFIG_MACH_BERLIN_BG2CD=y
@@ -229,7 +227,6 @@ CONFIG_B53_MMAP_DRIVER=m
 CONFIG_B53_SRAB_DRIVER=m
 CONFIG_NET_DSA_BCM_SF2=m
 CONFIG_SUN4I_EMAC=y
-CONFIG_BCMGENET=m
 CONFIG_BGMAC_BCMA=y
 CONFIG_SYSTEMPORT=m
 CONFIG_MACB=y
arch/arm/mach-bcm/Kconfig +1 -20
index 25aac6e..2c3ad42 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 menuconfig ARCH_BCM
 	bool "Broadcom SoC Support"
-	depends on ARCH_MULTI_V6_V7
+	depends on ARCH_BRCMSTB
 	help
 	  This enables support for Broadcom ARM based SoC chips
 
@@ -203,23 +203,4 @@ config ARCH_BCM_63XX
 	  It currently supports the 'BCM63XX' ARM-based family, which includes
 	  the BCM63138 variant.
 
-config ARCH_BRCMSTB
-	bool "Broadcom BCM7XXX based boards"
-	depends on ARCH_MULTI_V7
-	select ARM_GIC
-	select ARM_ERRATA_798181 if SMP
-	select HAVE_ARM_ARCH_TIMER
-	select BRCMSTB_L2_IRQ
-	select BCM7120_L2_IRQ
-	select ARCH_HAS_HOLES_MEMORYMODEL
-	select ZONE_DMA if ARM_LPAE
-	select SOC_BRCMSTB
-	select SOC_BUS
-	help
-	  Say Y if you intend to run the kernel on a Broadcom ARM-based STB
-	  chipset.
-
-	  This enables support for Broadcom ARM-based set-top box chipsets,
-	  including the 7445 family of chips.
-
 endif
arch/arm/mach-bcm/Makefile.boot new file +0 -0
new file mode 100644
index 0000000..e69de29
arch/arm/mach-bcm/include/mach/irqs.h new file +3 -0
new file mode 100644
index 0000000..f1f3f22
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#define NR_IRQS NR_IRQS_LEGACY
arch/arm/mach-bcm/include/mach/memory.h new file +47 -0

47 lines not on this page · raw message

arch/arm/mach-bcm/include/mach/uncompress.h new file +8 -0
new file mode 100644
index 0000000..b297333
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifdef CONFIG_DEBUG_UNCOMPRESS
+void putc(int c);
+#else
+static inline void putc(int c) {}
+#endif
+static inline void flush(void) {}
+static inline void arch_decomp_setup(void) {}
Signature · 1 line
1.9.0.138.g2de3478
#19 lore raw

Re: [PATCH v5 12/12] ARM: add dma remap for BrcmSTB PCIe

Quoted 10 lines · Jim Quinlan

The BrcmSTB PCIe controller needs to remap DMA accesses to it because of the requirements of its interface with the SOC memory controllers. In the ARM64 and MIPs architectures, this is accomplished by CONFIG_ARCH_HAS_PHYS_TO_DMA=y and then defining the functions __dma_to_phys() and __phys_to_dma() accordingly.

Doing so for the ARM architecture is not as easy as ARM64 and MIPS; the two functions are already defined as static inline functions. Howevery, the behavior of these functions may be changed by redefining the sub-functions that these two functions invoke.

So we talked extensively about this before privately but I think we need to have a better way rather than depart from MULTI_V7 because that will really prevent us from getting any build coverage if anything, and, there could conceptually be another ARMv7 platform that has the same requirements.

Your prior submissions were calling set_dma_ops() for the children devices created by the PCIe root complex driver during enumeration which had the nice advantage of scaling well across platforms, also came with no cost to the other devices (e.g: non-PCIe), and was a nice "subscriber/provider" model in that, if, and only if you had a PCIe root complex, would you be overriding a given device's dma_ops. AFAIR Christoph did not like that, so here we are now.

So maybe a solution somewhere in between is to allow the ARM machine to provide custom pfn_to_dma(), dma_to_pfn() and whatnot, and those, can potentially be resolved via the PCIe root complex driver through explicit call? I am thinking about something like this, not that I think this is any better than overriding a given devices' dma_ops, but maybe that will fly...:

(quoted diff) +0 -0

b/arch/arm/include/asm/dma-mapping.h
index 8436f6ade57d..507d3060c899 100644

arch/arm/include/asm/dma-mapping.h +0 -0
@@ -31,8 +31,15 @@ static inline const struct dma_map_ops

*get_arch_dma_ops(struct bus_type *bus)
* addresses. They must not be used by drivers.
*/
#ifndef __arch_pfn_to_dma
+dma_addr_t (*mach_pfn_to_dma)(struct device *dev, unsigned long pfn); +unsigned long (*mach_dma_to_pfn)(struct device *dev, dma_addr_t addr); +void *(*mach_dma_to_virt)(struct device *dev, dma_addr_t addr); +dma_addr_t *(*mach_virt_to_dma)(struct device *dev, void *addr); +
static inline dma_addr_t pfn_to_dma(struct device *dev, unsigned long pfn) {
+ if (mach_pfn_to_dma)

+               return (dma_addr_t)mach_pfn_to_dma(dev, pfn);
        if (dev)
                pfn -= dev->dma_pfn_offset;
        return (dma_addr_t)__pfn_to_bus(pfn);
@@ -42,6 +49,8 @@ static inline unsigned long dma_to_pfn(struct device
*dev, dma_addr_t addr)
 {
        unsigned long pfn = __bus_to_pfn(addr);

+ if (mach_dma_to_pfn)

+               return mach_dma_to_pfn(dev, addr);
        if (dev)
                pfn += dev->dma_pfn_offset;

@@ -50,6 +59,9 @@ static inline unsigned long dma_to_pfn(struct device *dev, dma_addr_t addr)

static inline void *dma_to_virt(struct device *dev, dma_addr_t addr) {
+ if (mach_dma_to_virt)
+ return mach_dma_to_virt(dev, addr);
+

        if (dev) {
                unsigned long pfn = dma_to_pfn(dev, addr);

@@ -61,6 +73,8 @@ static inline void *dma_to_virt(struct device *dev, dma_addr_t addr)

static inline dma_addr_t virt_to_dma(struct device *dev, void *addr) {
+ if (mach_virt_to_dma)

+               mach_virt_to_dma(dev, addr);
        if (dev)
                return pfn_to_dma(dev, virt_to_pfn(addr));
arch/arm/mach-bcm/brcmstb.c +12 -0
index 5f127d5f1045..d78a892604c0 100644
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/irqchip.h>
 #include <linux/of_platform.h>
+#include <linux/dma-mapping.h>
 
 #include <asm/mach-types.h>
 #include <asm/mach/arch.h>
@@ -39,6 +40,16 @@ static void __init brcmstb_init_irq(void)
        irqchip_init();
 }
 
+static void __init brcmstb_init_late(void)
+{
+#if IS_ENABLED(CONFIG_PCIE_BRCMSTB)
+       mach_pfn_to_dma = brcm_phys_to_dma;
+       mach_dma_to_pfn = brcm_dma_to_phys;
+       mach_dma_to_virt = brcm_dma_to_virt;
+       mach_virt_to_dma = brcm_virt_to_dma;
+#endif
+}
+
 static const char *const brcmstb_match[] __initconst = {
        "brcm,bcm7445",
        "brcm,brcmstb",
@@ -48,4 +59,5 @@ static const char *const brcmstb_match[] __initconst = {
 DT_MACHINE_START(BRCMSTB, "Broadcom STB (Flattened Device Tree)")
        .dt_compat      = brcmstb_match,
        .init_irq       = brcmstb_init_irq,
+       .init_late      = brcmstb_init_late,
 MACHINE_END
Quoted 428 lines
	__arch_pfn_to_dma()
	__arch_dma_to_pfn()
	__arch_dma_to_virt()
	__arch_virt_to_dma()

as these are the functions invoked by __dma_to_phys() and __phys_to_dma(). Unfortunately, the only apparent approach to do this is to declare and define the four sub-functions in arch/arm/mach-bcm/include/mach/memory.h, and in doing so we must move out of ARCH_MULTIPLATFORM and create brcmstb_defconfig, as we were previously using multi_v7_defconfig.

---
 arch/arm/Kconfig                            |  33 +++++
 arch/arm/configs/brcmstb_defconfig          | 204 ++++++++++++++++++++++++++++
 arch/arm/configs/multi_v7_defconfig         |   3 -
 arch/arm/mach-bcm/Kconfig                   |  21 +--
 arch/arm/mach-bcm/Makefile.boot             |   0
 arch/arm/mach-bcm/include/mach/irqs.h       |   3 +
 arch/arm/mach-bcm/include/mach/memory.h     |  47 +++++++
 arch/arm/mach-bcm/include/mach/uncompress.h |   8 ++
 8 files changed, 296 insertions(+), 23 deletions(-)
 create mode 100644 arch/arm/configs/brcmstb_defconfig
 create mode 100644 arch/arm/mach-bcm/Makefile.boot
 create mode 100644 arch/arm/mach-bcm/include/mach/irqs.h
 create mode 100644 arch/arm/mach-bcm/include/mach/memory.h
 create mode 100644 arch/arm/mach-bcm/include/mach/uncompress.h
arch/arm/Kconfig +33 -0
index e8cd55a..913765b 100644
@@ -637,6 +637,39 @@ config ARCH_OMAP1
 	help
 	  Support for older TI OMAP1 (omap7xx, omap15xx or omap16xx)
 
+config ARCH_BRCMSTB
+	bool "Broadcom BCM7XXX based boards"
+	select ARM_HAS_SG_CHAIN
+	select ARM_PATCH_PHYS_VIRT
+	select TIMER_OF
+	select COMMON_CLK
+	select GENERIC_CLOCKEVENTS
+	select MULTI_IRQ_HANDLER
+	select MIGHT_HAVE_PCI
+	select PCI_DOMAINS if PCI
+	select USE_OF
+
+	select CPU_V7
+	select ARCH_BCM
+	select HAVE_SMP
+	select AUTO_ZRELADDR
+	select ARM_GIC
+	select ARM_GIC_V3
+	select HAVE_ARM_ARCH_TIMER
+	select SPARSE_IRQ
+	select BRCMSTB_L2_IRQ
+	select BCM7120_L2_IRQ
+	select ARCH_HAS_HOLES_MEMORYMODEL
+	select ARCH_DMA_ADDR_T_64BIT if ARM_LPAE
+	select ZONE_DMA if ARM_LPAE
+	select NEED_MACH_MEMORY_H
+	help
+	  Say Y if you intend to run the kernel on a Broadcom ARM-based STB
+	  chipset.
+
+	  This enables support for Broadcom ARM-based set-top box chipsets,
+	  including the 7445 family of chips.
+
 endchoice
 
 menu "Multiple platform selection"
arch/arm/configs/brcmstb_defconfig new file +204 -0
new file mode 100644
index 0000000..572fcf32
@@ -0,0 +1,204 @@
+CONFIG_POSIX_MQUEUE=y
+CONFIG_NO_HZ=y
+CONFIG_HIGH_RES_TIMERS=y
+CONFIG_IRQ_TIME_ACCOUNTING=y
+CONFIG_LOG_BUF_SHIFT=16
+CONFIG_CGROUPS=y
+CONFIG_RELAY=y
+CONFIG_BLK_DEV_INITRD=y
+CONFIG_INITRAMFS_SOURCE="romfs"
+CONFIG_EMBEDDED=y
+CONFIG_PERF_EVENTS=y
+CONFIG_MODULES=y
+CONFIG_MODULE_FORCE_LOAD=y
+CONFIG_MODULE_UNLOAD=y
+CONFIG_MODVERSIONS=y
+CONFIG_PARTITION_ADVANCED=y
+CONFIG_ARCH_BRCMSTB=y
+CONFIG_ARM_LPAE=y
+CONFIG_ARM_THUMBEE=y
+CONFIG_ARM_ERRATA_430973=y
+CONFIG_ARM_ERRATA_720789=y
+CONFIG_ARM_ERRATA_754322=y
+CONFIG_ARM_ERRATA_754327=y
+CONFIG_ARM_ERRATA_764369=y
+CONFIG_ARM_ERRATA_775420=y
+CONFIG_ARM_ERRATA_798181=y
+CONFIG_PCI=y
+CONFIG_PCIEPORTBUS=y
+CONFIG_PCI_MSI=y
+CONFIG_SMP=y
+CONFIG_MCPM=y
+CONFIG_NR_CPUS=16
+CONFIG_ARM_PSCI=y
+CONFIG_HZ_1000=y
+CONFIG_HIGHMEM=y
+CONFIG_CMA=y
+CONFIG_ARM_APPENDED_DTB=y
+CONFIG_ARM_ATAG_DTB_COMPAT=y
+CONFIG_EFI=y
+CONFIG_CPU_FREQ=y
+CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND=y
+CONFIG_CPU_FREQ_GOV_POWERSAVE=y
+CONFIG_CPU_FREQ_GOV_USERSPACE=y
+CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
+CONFIG_CPU_FREQ_GOV_SCHEDUTIL=y
+CONFIG_CPU_IDLE=y
+CONFIG_VFP=y
+CONFIG_PM_DEBUG=y
+CONFIG_NET=y
+CONFIG_PACKET=y
+CONFIG_UNIX=y
+CONFIG_INET=y
+CONFIG_IP_MULTICAST=y
+CONFIG_IP_PNP=y
+CONFIG_IP_PNP_DHCP=y
+CONFIG_IP_PNP_BOOTP=y
+CONFIG_IP_PNP_RARP=y
+CONFIG_IP_MROUTE=y
+CONFIG_IP_PIMSM_V1=y
+CONFIG_IP_PIMSM_V2=y
+# CONFIG_INET_XFRM_MODE_TRANSPORT is not set
+# CONFIG_INET_XFRM_MODE_TUNNEL is not set
+# CONFIG_INET_XFRM_MODE_BEET is not set
+CONFIG_INET_UDP_DIAG=y
+CONFIG_TCP_CONG_ADVANCED=y
+CONFIG_TCP_CONG_BIC=y
+# CONFIG_TCP_CONG_WESTWOOD is not set
+# CONFIG_TCP_CONG_HTCP is not set
+# CONFIG_IPV6 is not set
+CONFIG_BRIDGE=y
+CONFIG_NET_DSA=y
+CONFIG_CFG80211=y
+CONFIG_UEVENT_HELPER_PATH="/sbin/hotplug"
+CONFIG_DEVTMPFS=y
+CONFIG_DEVTMPFS_MOUNT=y
+CONFIG_DMA_CMA=y
+CONFIG_CMA_ALIGNMENT=9
+CONFIG_MTD=y
+CONFIG_MTD_CMDLINE_PARTS=y
+CONFIG_MTD_BLOCK=y
+CONFIG_MTD_CFI=y
+CONFIG_MTD_JEDECPROBE=y
+CONFIG_MTD_CFI_INTELEXT=y
+CONFIG_MTD_CFI_AMDSTD=y
+CONFIG_MTD_CFI_STAA=y
+CONFIG_MTD_ROM=y
+CONFIG_MTD_ABSENT=y
+CONFIG_MTD_PHYSMAP_OF=y
+CONFIG_MTD_M25P80=y
+CONFIG_MTD_NAND=y
+CONFIG_MTD_NAND_BRCMNAND=y
+CONFIG_MTD_SPI_NOR=y
+# CONFIG_MTD_SPI_NOR_USE_4K_SECTORS is not set
+CONFIG_MTD_UBI=y
+CONFIG_MTD_UBI_GLUEBI=y
+CONFIG_BLK_DEV_LOOP=y
+CONFIG_BLK_DEV_RAM=y
+CONFIG_BLK_DEV_RAM_SIZE=8192
+CONFIG_EEPROM_93CX6=y
+CONFIG_BLK_DEV_SD=y
+CONFIG_BLK_DEV_SR=y
+CONFIG_CHR_DEV_SG=y
+CONFIG_ATA=y
+CONFIG_SATA_AHCI_PLATFORM=y
+CONFIG_AHCI_BRCM=y
+CONFIG_NETDEVICES=y
+CONFIG_NET_DSA_BCM_SF2=y
+# CONFIG_NET_VENDOR_ARC is not set
+# CONFIG_NET_CADENCE is not set
+CONFIG_BCMGENET=y
+CONFIG_SYSTEMPORT=y
+# CONFIG_NET_VENDOR_MARVELL is not set
+# CONFIG_NET_VENDOR_MELLANOX is not set
+# CONFIG_NET_VENDOR_MICREL is not set
+# CONFIG_NET_VENDOR_MICROCHIP is not set
+# CONFIG_NET_VENDOR_NATSEMI is not set
+# CONFIG_NET_VENDOR_SEEQ is not set
+# CONFIG_NET_VENDOR_SMSC is not set
+# CONFIG_NET_VENDOR_STMICRO is not set
+# CONFIG_NET_VENDOR_VIA is not set
+# CONFIG_NET_VENDOR_WIZNET is not set
+CONFIG_USB_PEGASUS=y
+CONFIG_USB_USBNET=y
+# CONFIG_USB_NET_NET1080 is not set
+# CONFIG_USB_NET_CDC_SUBSET is not set
+# CONFIG_USB_NET_ZAURUS is not set
+CONFIG_INPUT_EVDEV=y
+CONFIG_MOUSE_PS2_ELANTECH=y
+CONFIG_INPUT_MISC=y
+CONFIG_INPUT_UINPUT=y
+# CONFIG_SERIO_SERPORT is not set
+CONFIG_VT_HW_CONSOLE_BINDING=y
+CONFIG_SERIAL_8250=y
+CONFIG_SERIAL_8250_CONSOLE=y
+CONFIG_SERIAL_8250_DW=y
+CONFIG_SERIAL_OF_PLATFORM=y
+CONFIG_HW_RANDOM=y
+CONFIG_I2C_CHARDEV=y
+CONFIG_SPI=y
+CONFIG_SPI_BITBANG=y
+CONFIG_GPIOLIB=y
+CONFIG_GPIO_SYSFS=y
+CONFIG_POWER_RESET=y
+# CONFIG_HWMON is not set
+CONFIG_MFD_SYSCON=y
+CONFIG_REGULATOR=y
+CONFIG_REGULATOR_FIXED_VOLTAGE=y
+CONFIG_MEDIA_SUPPORT=y
+CONFIG_MEDIA_CAMERA_SUPPORT=y
+CONFIG_MEDIA_USB_SUPPORT=y
+CONFIG_USB_GSPCA=y
+CONFIG_DRM=y
+CONFIG_SOUND=m
+CONFIG_SND=m
+CONFIG_SND_SOC=m
+CONFIG_USB=y
+CONFIG_USB_MON=y
+CONFIG_USB_XHCI_HCD=y
+CONFIG_USB_EHCI_HCD=y
+CONFIG_USB_OHCI_HCD=y
+CONFIG_USB_STORAGE=y
+CONFIG_USB_GADGET=y
+CONFIG_USB_MASS_STORAGE=y
+CONFIG_MMC=y
+CONFIG_MMC_BLOCK_MINORS=16
+CONFIG_MMC_SDHCI=y
+CONFIG_MMC_SDHCI_PLTFM=y
+CONFIG_RTC_CLASS=y
+# CONFIG_IOMMU_SUPPORT is not set
+CONFIG_IIO=y
+CONFIG_INA2XX_ADC=y
+CONFIG_RESET_CONTROLLER=y
+CONFIG_PHY_BRCM_SATA=y
+CONFIG_EXT4_FS=y
+CONFIG_JBD2_DEBUG=y
+CONFIG_FUSE_FS=y
+CONFIG_CUSE=y
+CONFIG_ISO9660_FS=y
+CONFIG_JOLIET=y
+CONFIG_ZISOFS=y
+CONFIG_UDF_FS=y
+CONFIG_MSDOS_FS=y
+CONFIG_VFAT_FS=y
+CONFIG_TMPFS=y
+CONFIG_JFFS2_FS=y
+CONFIG_UBIFS_FS=y
+CONFIG_CRAMFS=y
+CONFIG_SQUASHFS=y
+CONFIG_SQUASHFS_LZO=y
+CONFIG_SQUASHFS_XZ=y
+CONFIG_NFS_FS=y
+CONFIG_NFS_V3_ACL=y
+CONFIG_NFS_V4=y
+CONFIG_NFS_V4_1=y
+CONFIG_NFS_V4_2=y
+CONFIG_ROOT_NFS=y
+CONFIG_NLS_CODEPAGE_437=y
+CONFIG_NLS_ISO8859_1=y
+CONFIG_PRINTK_TIME=y
+CONFIG_DEBUG_INFO=y
+CONFIG_DEBUG_INFO_REDUCED=y
+CONFIG_MAGIC_SYSRQ=y
+# CONFIG_CRYPTO_HW is not set
+CONFIG_CRC_CCITT=y
arch/arm/configs/multi_v7_defconfig +0 -3
index fc33444..33c91f8 100644
@@ -17,7 +17,6 @@ CONFIG_ARCH_AT91=y
 CONFIG_SOC_SAMA5D2=y
 CONFIG_SOC_SAMA5D3=y
 CONFIG_SOC_SAMA5D4=y
-CONFIG_ARCH_BCM=y
 CONFIG_ARCH_BCM_CYGNUS=y
 CONFIG_ARCH_BCM_HR2=y
 CONFIG_ARCH_BCM_NSP=y
@@ -26,7 +25,6 @@ CONFIG_ARCH_BCM_281XX=y
 CONFIG_ARCH_BCM_21664=y
 CONFIG_ARCH_BCM2835=y
 CONFIG_ARCH_BCM_63XX=y
-CONFIG_ARCH_BRCMSTB=y
 CONFIG_ARCH_BERLIN=y
 CONFIG_MACH_BERLIN_BG2=y
 CONFIG_MACH_BERLIN_BG2CD=y
@@ -229,7 +227,6 @@ CONFIG_B53_MMAP_DRIVER=m
 CONFIG_B53_SRAB_DRIVER=m
 CONFIG_NET_DSA_BCM_SF2=m
 CONFIG_SUN4I_EMAC=y
-CONFIG_BCMGENET=m
 CONFIG_BGMAC_BCMA=y
 CONFIG_SYSTEMPORT=m
 CONFIG_MACB=y
arch/arm/mach-bcm/Kconfig +1 -20
index 25aac6e..2c3ad42 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 menuconfig ARCH_BCM
 	bool "Broadcom SoC Support"
-	depends on ARCH_MULTI_V6_V7
+	depends on ARCH_BRCMSTB
 	help
 	  This enables support for Broadcom ARM based SoC chips
 
@@ -203,23 +203,4 @@ config ARCH_BCM_63XX
 	  It currently supports the 'BCM63XX' ARM-based family, which includes
 	  the BCM63138 variant.
 
-config ARCH_BRCMSTB
-	bool "Broadcom BCM7XXX based boards"
-	depends on ARCH_MULTI_V7
-	select ARM_GIC
-	select ARM_ERRATA_798181 if SMP
-	select HAVE_ARM_ARCH_TIMER
-	select BRCMSTB_L2_IRQ
-	select BCM7120_L2_IRQ
-	select ARCH_HAS_HOLES_MEMORYMODEL
-	select ZONE_DMA if ARM_LPAE
-	select SOC_BRCMSTB
-	select SOC_BUS
-	help
-	  Say Y if you intend to run the kernel on a Broadcom ARM-based STB
-	  chipset.
-
-	  This enables support for Broadcom ARM-based set-top box chipsets,
-	  including the 7445 family of chips.
-
 endif
arch/arm/mach-bcm/Makefile.boot new file +0 -0
new file mode 100644
index 0000000..e69de29
arch/arm/mach-bcm/include/mach/irqs.h new file +3 -0
new file mode 100644
index 0000000..f1f3f22
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#define NR_IRQS NR_IRQS_LEGACY
arch/arm/mach-bcm/include/mach/memory.h new file +47 -0
new file mode 100644
index 0000000..a90a216
@@ -0,0 +1,47 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __ASM_ARCH_MEMORY_H__
+#define __ASM_ARCH_MEMORY_H__
+#ifndef __ASSEMBLY__
+
+struct device;
+
+#include <soc/brcmstb/common.h>
+
+#ifdef CONFIG_PCIE_BRCMSTB
+#define __arch_pfn_to_dma(dev, pfn)					\
+	({								\
+		if (dev)						\
+			pfn -= dev->dma_pfn_offset;			\
+		(dma_addr_t)brcm_phys_to_dma(dev, __pfn_to_phys(pfn));	\
+	})
+
+#define  __arch_dma_to_pfn(dev, addr)					\
+	({								\
+		unsigned long pfn = __phys_to_pfn(brcm_dma_to_phys(dev, addr));\
+		if (dev)						\
+			pfn += dev->dma_pfn_offset;			\
+		pfn;							\
+	})
+
+#define __arch_dma_to_virt(dev, addr)					\
+	({								\
+		void *v;						\
+		if (dev) {						\
+			unsigned long pfn = dma_to_pfn(dev, addr);	\
+			v = phys_to_virt(__pfn_to_phys(pfn));		\
+		} else {						\
+			v = (void *)__bus_to_virt((unsigned long)addr);	\
+		}							\
+		v;							\
+	})
+
+#define __arch_virt_to_dma(dev, addr)					\
+	({								\
+		(dev) ? pfn_to_dma(dev, virt_to_pfn(addr))		\
+		      : (dma_addr_t)__virt_to_bus((unsigned long)(addr));\
+	})
+
+#endif /* CONFIG_PCIE_BRCMSTB */
+#endif /* __ASSEMBLY__ */
+#endif /* __ASM_ARCH_MEMORY_H__ */
arch/arm/mach-bcm/include/mach/uncompress.h new file +8 -0
new file mode 100644
index 0000000..b297333
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifdef CONFIG_DEBUG_UNCOMPRESS
+void putc(int c);
+#else
+static inline void putc(int c) {}
+#endif
+static inline void flush(void) {}
+static inline void arch_decomp_setup(void) {}
Signature · 1 line
Florian
#20 lore raw
In reply to Jim Quinlan

FYI,

AFAICS this thread did not make it to any vger list you addressed, I can't apply/review patches that do not appear on [email protected] at least so we need to figure out what went wrong.

I would consider trimming the CC list to start with, which is huge.

Lorenzo

Quoted 128 lines · Jim Quinlan

This patch series adds support for the Broadcom Settopbox PCIe host controller. It is targeted to Broadcom Settopbox chips running on ARM, ARM64, and MIPS platforms.

V5 Changes:
- V4 had its own DMA ops structure in the PCIe driver which would override/coexist with the default arch DMA ops. This approach was scrapped, and this version instead essentially implements custom definitions of the __phys_to_dma and __dma_to_phys operations for the three target arches: MIPs, ARM64, ARM. This was the course suggested by one of the V4 reviewers (ChristophH).

For MIPs and ARM64, the DMA remapping is easily accomplished by having custom definitions of __phys_to_dma and __dma_to_phys. For MIPs/BMIPs, ARCH_HAS_PHYS_TO_DMA is already selected and the two functions are just modified. For ARM64, this driver selects ARCH_HAS_PHYS_TO_DMA and declares and defines __phys_to_dma() and __dma_to_phys(). For ARM, things were not so simple. The default functions like __arch_pfn_to_dma() had to be overridden by custom ones defined in arch/arm/mach-bcm/include/mach/memory.h. For these functions to be "seen", we had to declare our own brcmstb_defconfig and no longer use multi_v7_defconfig. This is unfortunate.

- Commits have been better organized to first implement the main driver, then add features (MSI, DMA remap infrastructure), and then add the DMA remapping modifications for MIPs, ARM64, and ARM.

V4 Changes:
- Merged all BrcmSTB PCIe controller files into a single file.
- All new files now have the SPDX identifier.
- Removed the list of PCIe controllers.
- Removed "link-up" race.
- Removed probe of msi psuedo-device.
- Multiple comment text changes, as requested.
- "SSC" => "Spread Spectrum Clocking".
- Set 'memc' variable.
- Unnecessary variable initializations removed (eg rc_bar2_size).
- Added comment on "L23" link state.
- Removed use of "__refdata".
- Formatting of structure elements.

V3 Changes:
- Fold pcie-brcmstb-msi.c into pcie-brcmstb.c
- Use PCI_XXX constants for PCIe capability registers
- Removal of any unused constants
- Change s/pci/pcie/ for filenames, comment text
- Config space access now uses 8/16/32 read/writes
- Use proper multi-line comment style
- Use function names, structure that are common in other host drivers
- DT binding 'brcm,ssc' is now 'brcm,enable-ssc'
- Dropped DT binding 'xyz-supply'
- Not setting CRS support as Linux does it if it is advertised.
- Removed code that was considered "debug code".
- Use of_get_pcie_domain_nr()
- Variable 'bridge_setup_done' removed.

V2 Changes:
* Patch brcmstb-add-memory-API:
- fix DT_PROP_DATA_TO_U32 macro.
- dropped one EXPORT_SYMBOL, changed the other to GPL.
* Patch DT-docs-for-Brcmstb-PCIe:
- change 'brcm,gen' prop to standard 'max-link-speed'.
- rewrite bindings commit to omit standard prop defs.
- change props "supplies", "supply-names" to "xyz-supply"
* Patch removed: export-symbol-arch_setup_dma_ops [4/9]
* Patch brcmstb-add-dma-ranges:
- use get_dma_ops(); also use a const dma_map_ops structure.
- rewrite map_sg(), unmap_sg(), other calls like syng_sg_*()
- omit brcm_mapping_error(), but added code in brcm_dma_supported()
- put all of the notifier code in one compilation unit.

Florian Fainelli (1):
soc: bcm: brcmstb: add memory API

Jim Quinlan (11):
dt-bindings: pci: add DT docs for Brcmstb PCIe device
PCI: brcmstb: add Broadcom STB PCIe host controller driver
PCI: brcmstb: add dma-range mapping for inbound traffic
PCI: brcmstb: add MSI capability
MIPS: BMIPS: add dma remap for BrcmSTB PCIe PCI/MSI: enable PCI_MSI_IRQ_DOMAIN support for MIPS
MIPS: BMIPS: add PCI bindings for 7425, 7435
MIPS: BMIPS: enable PCI
ARM64: declare __phys_to_dma on ARCH_HAS_PHYS_TO_DMA
ARM64: add dma remap for BrcmSTB PCIe
ARM: add dma remap for BrcmSTB PCIe

 .../devicetree/bindings/pci/brcmstb-pcie.txt       |   59 +
 arch/arm/Kconfig                                   |   33 +
 arch/arm/configs/brcmstb_defconfig                 |  204 +++
 arch/arm/configs/multi_v7_defconfig                |    3 -
 arch/arm/mach-bcm/Kconfig                          |   21 +-
 arch/arm/mach-bcm/Makefile.boot                    |    0
 arch/arm/mach-bcm/include/mach/irqs.h              |    3 +
 arch/arm/mach-bcm/include/mach/memory.h            |   47 +
 arch/arm/mach-bcm/include/mach/uncompress.h        |    8 +
 arch/arm64/include/asm/dma-direct.h                |   16 +
 arch/mips/Kconfig                                  |    3 +
 arch/mips/bmips/dma.c                              |    9 +
 arch/mips/boot/dts/brcm/bcm7425.dtsi               |   28 +
 arch/mips/boot/dts/brcm/bcm7435.dtsi               |   28 +
 arch/mips/boot/dts/brcm/bcm97425svmb.dts           |    4 +
 arch/mips/boot/dts/brcm/bcm97435svmb.dts           |    4 +
 drivers/pci/Kconfig                                |    2 +-
 drivers/pci/controller/Kconfig                     |   13 +
 drivers/pci/controller/Makefile                    |    1 +
 drivers/pci/controller/pcie-brcmstb.c              | 1554 ++++++++++++++++++++
 drivers/soc/bcm/brcmstb/Makefile                   |    2 +-
 drivers/soc/bcm/brcmstb/memory.c                   |  158 ++
 include/soc/brcmstb/common.h                       |   16 +
 include/soc/brcmstb/memory_api.h                   |   26 +
 24 files changed, 2217 insertions(+), 25 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pci/brcmstb-pcie.txt
 create mode 100644 arch/arm/configs/brcmstb_defconfig
 create mode 100644 arch/arm/mach-bcm/Makefile.boot
 create mode 100644 arch/arm/mach-bcm/include/mach/irqs.h
 create mode 100644 arch/arm/mach-bcm/include/mach/memory.h
 create mode 100644 arch/arm/mach-bcm/include/mach/uncompress.h
 create mode 100644 arch/arm64/include/asm/dma-direct.h
 create mode 100644 drivers/pci/controller/pcie-brcmstb.c
 create mode 100644 drivers/soc/bcm/brcmstb/memory.c
 create mode 100644 include/soc/brcmstb/memory_api.h
Signature · 1 line
1.9.0.138.g2de3478
author maintainer
#21 lore raw
Quoted 11 lines · Lorenzo Pieralisi

FYI,

AFAICS this thread did not make it to any vger list you addressed, I can't apply/review patches that do not appear on [email protected] at least so we need to figure out what went wrong.

I would consider trimming the CC list to start with, which is huge.

Lorenzo

Hi Lorenzo, this may have had something to do with an email issue on my end. I will resend again soon.
Thanks, Jim

Quoted 130 lines · Jim Quinlan
Quoted 128 lines

This patch series adds support for the Broadcom Settopbox PCIe host controller. It is targeted to Broadcom Settopbox chips running on ARM, ARM64, and MIPS platforms.

V5 Changes:
- V4 had its own DMA ops structure in the PCIe driver which would override/coexist with the default arch DMA ops. This approach was scrapped, and this version instead essentially implements custom definitions of the __phys_to_dma and __dma_to_phys operations for the three target arches: MIPs, ARM64, ARM. This was the course suggested by one of the V4 reviewers (ChristophH).

For MIPs and ARM64, the DMA remapping is easily accomplished by having custom definitions of __phys_to_dma and __dma_to_phys. For MIPs/BMIPs, ARCH_HAS_PHYS_TO_DMA is already selected and the two functions are just modified. For ARM64, this driver selects ARCH_HAS_PHYS_TO_DMA and declares and defines __phys_to_dma() and __dma_to_phys(). For ARM, things were not so simple. The default functions like __arch_pfn_to_dma() had to be overridden by custom ones defined in arch/arm/mach-bcm/include/mach/memory.h. For these functions to be "seen", we had to declare our own brcmstb_defconfig and no longer use multi_v7_defconfig. This is unfortunate.

- Commits have been better organized to first implement the main driver, then add features (MSI, DMA remap infrastructure), and then add the DMA remapping modifications for MIPs, ARM64, and ARM.

V4 Changes:
- Merged all BrcmSTB PCIe controller files into a single file.
- All new files now have the SPDX identifier.
- Removed the list of PCIe controllers.
- Removed "link-up" race.
- Removed probe of msi psuedo-device.
- Multiple comment text changes, as requested.
- "SSC" => "Spread Spectrum Clocking".
- Set 'memc' variable.
- Unnecessary variable initializations removed (eg rc_bar2_size).
- Added comment on "L23" link state.
- Removed use of "__refdata".
- Formatting of structure elements.

V3 Changes:
- Fold pcie-brcmstb-msi.c into pcie-brcmstb.c
- Use PCI_XXX constants for PCIe capability registers
- Removal of any unused constants
- Change s/pci/pcie/ for filenames, comment text
- Config space access now uses 8/16/32 read/writes
- Use proper multi-line comment style
- Use function names, structure that are common in other host drivers
- DT binding 'brcm,ssc' is now 'brcm,enable-ssc'
- Dropped DT binding 'xyz-supply'
- Not setting CRS support as Linux does it if it is advertised.
- Removed code that was considered "debug code".
- Use of_get_pcie_domain_nr()
- Variable 'bridge_setup_done' removed.

V2 Changes:
* Patch brcmstb-add-memory-API:
- fix DT_PROP_DATA_TO_U32 macro.
- dropped one EXPORT_SYMBOL, changed the other to GPL.
* Patch DT-docs-for-Brcmstb-PCIe:
- change 'brcm,gen' prop to standard 'max-link-speed'.
- rewrite bindings commit to omit standard prop defs.
- change props "supplies", "supply-names" to "xyz-supply"
* Patch removed: export-symbol-arch_setup_dma_ops [4/9]
* Patch brcmstb-add-dma-ranges:
- use get_dma_ops(); also use a const dma_map_ops structure.
- rewrite map_sg(), unmap_sg(), other calls like syng_sg_*()
- omit brcm_mapping_error(), but added code in brcm_dma_supported()
- put all of the notifier code in one compilation unit.

Florian Fainelli (1):
soc: bcm: brcmstb: add memory API

Jim Quinlan (11):
dt-bindings: pci: add DT docs for Brcmstb PCIe device
PCI: brcmstb: add Broadcom STB PCIe host controller driver
PCI: brcmstb: add dma-range mapping for inbound traffic
PCI: brcmstb: add MSI capability
MIPS: BMIPS: add dma remap for BrcmSTB PCIe PCI/MSI: enable PCI_MSI_IRQ_DOMAIN support for MIPS
MIPS: BMIPS: add PCI bindings for 7425, 7435
MIPS: BMIPS: enable PCI
ARM64: declare __phys_to_dma on ARCH_HAS_PHYS_TO_DMA
ARM64: add dma remap for BrcmSTB PCIe
ARM: add dma remap for BrcmSTB PCIe

 .../devicetree/bindings/pci/brcmstb-pcie.txt       |   59 +
 arch/arm/Kconfig                                   |   33 +
 arch/arm/configs/brcmstb_defconfig                 |  204 +++
 arch/arm/configs/multi_v7_defconfig                |    3 -
 arch/arm/mach-bcm/Kconfig                          |   21 +-
 arch/arm/mach-bcm/Makefile.boot                    |    0
 arch/arm/mach-bcm/include/mach/irqs.h              |    3 +
 arch/arm/mach-bcm/include/mach/memory.h            |   47 +
 arch/arm/mach-bcm/include/mach/uncompress.h        |    8 +
 arch/arm64/include/asm/dma-direct.h                |   16 +
 arch/mips/Kconfig                                  |    3 +
 arch/mips/bmips/dma.c                              |    9 +
 arch/mips/boot/dts/brcm/bcm7425.dtsi               |   28 +
 arch/mips/boot/dts/brcm/bcm7435.dtsi               |   28 +
 arch/mips/boot/dts/brcm/bcm97425svmb.dts           |    4 +
 arch/mips/boot/dts/brcm/bcm97435svmb.dts           |    4 +
 drivers/pci/Kconfig                                |    2 +-
 drivers/pci/controller/Kconfig                     |   13 +
 drivers/pci/controller/Makefile                    |    1 +
 drivers/pci/controller/pcie-brcmstb.c              | 1554 ++++++++++++++++++++
 drivers/soc/bcm/brcmstb/Makefile                   |    2 +-
 drivers/soc/bcm/brcmstb/memory.c                   |  158 ++
 include/soc/brcmstb/common.h                       |   16 +
 include/soc/brcmstb/memory_api.h                   |   26 +
 24 files changed, 2217 insertions(+), 25 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/pci/brcmstb-pcie.txt
 create mode 100644 arch/arm/configs/brcmstb_defconfig
 create mode 100644 arch/arm/mach-bcm/Makefile.boot
 create mode 100644 arch/arm/mach-bcm/include/mach/irqs.h
 create mode 100644 arch/arm/mach-bcm/include/mach/memory.h
 create mode 100644 arch/arm/mach-bcm/include/mach/uncompress.h
 create mode 100644 arch/arm64/include/asm/dma-direct.h
 create mode 100644 drivers/pci/controller/pcie-brcmstb.c
 create mode 100644 drivers/soc/bcm/brcmstb/memory.c
 create mode 100644 include/soc/brcmstb/memory_api.h

--
1.9.0.138.g2de3478