Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d666cd02 authored by Kevin Cernekee's avatar Kevin Cernekee Committed by Ralf Baechle
Browse files

MIPS: bcm3384: Initial commit of bcm3384 platform support

This supports SMP Linux running on the BCM3384 Zephyr (BMIPS5000)
application processor, with fully functional UART and USB 1.1/2.0.
Device Tree is used to configure the following items:

 - All peripherals
 - Early console base address
 - SMP or UP mode
 - MIPS counter frequency
 - Memory size / regions
 - DMA offset
 - Kernel command line

The DT-enabled bootloader and build instructions are posted at
https://github.com/Broadcom/aeolus



Signed-off-by: default avatarKevin Cernekee <cernekee@gmail.com>
Cc: f.fainelli@gmail.com
Cc: mbizon@freebox.fr
Cc: jogo@openwrt.org
Cc: jfraser@broadcom.com
Cc: linux-mips@linux-mips.org
Cc: devicetree@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/8170/


Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent ab81ce62
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -3,6 +3,7 @@
platforms += alchemy
platforms += ar7
platforms += ath79
platforms += bcm3384
platforms += bcm47xx
platforms += bcm63xx
platforms += cavium-octeon
+26 −0
Original line number Diff line number Diff line
@@ -116,6 +116,32 @@ config ATH79
	help
	  Support for the Atheros AR71XX/AR724X/AR913X SoCs.

config BCM3384
	bool "Broadcom BCM3384 based boards"
	select BOOT_RAW
	select NO_EXCEPT_FILL
	select USE_OF
	select CEVT_R4K
	select CSRC_R4K
	select SYNC_R4K
	select COMMON_CLK
	select DMA_NONCOHERENT
	select IRQ_CPU
	select SYS_SUPPORTS_32BIT_KERNEL
	select SYS_SUPPORTS_BIG_ENDIAN
	select SYS_SUPPORTS_HIGHMEM
	select SYS_HAS_CPU_BMIPS5000
	select SWAP_IO_SPACE
	select USB_EHCI_BIG_ENDIAN_DESC
	select USB_EHCI_BIG_ENDIAN_MMIO
	select USB_OHCI_BIG_ENDIAN_DESC
	select USB_OHCI_BIG_ENDIAN_MMIO
	help
	  Support for BCM3384 based boards.  BCM3384/BCM33843 is a cable modem
	  chipset with a Linux application processor that is often used to
	  provide Samba services, a CUPS print server, and/or advanced routing
	  features.

config BCM47XX
	bool "Broadcom BCM47XX based boards"
	select ARCH_WANT_OPTIONAL_GPIOLIB
+1 −0
Original line number Diff line number Diff line
obj-y		+= setup.o irq.o dma.o
+7 −0
Original line number Diff line number Diff line
#
# Broadcom BCM3384 boards
#
platform-$(CONFIG_BCM3384)	+= bcm3384/
cflags-$(CONFIG_BCM3384)	+=					\
		-I$(srctree)/arch/mips/include/asm/mach-bcm3384/
load-$(CONFIG_BCM3384)		:= 0xffffffff80010000
+81 −0
Original line number Diff line number Diff line
/*
 * This file is subject to the terms and conditions of the GNU General Public
 * License.  See the file "COPYING" in the main directory of this archive
 * for more details.
 *
 * Copyright (C) 2014 Kevin Cernekee <cernekee@gmail.com>
 */

#include <linux/device.h>
#include <linux/dma-direction.h>
#include <linux/dma-mapping.h>
#include <linux/init.h>
#include <linux/mm.h>
#include <linux/of.h>
#include <linux/pci.h>
#include <linux/types.h>
#include <dma-coherence.h>

/*
 * BCM3384 has configurable address translation windows which allow the
 * peripherals' DMA addresses to be different from the Zephyr-visible
 * physical addresses.  e.g. usb_dma_addr = zephyr_pa ^ 0x08000000
 *
 * If our DT "memory" node has a "dma-xor-mask" property we will enable this
 * translation using the provided offset.
 */
static u32 bcm3384_dma_xor_mask;
static u32 bcm3384_dma_xor_limit = 0xffffffff;

/*
 * PCI collapses the memory hole at 0x10000000 - 0x1fffffff.
 * On systems with a dma-xor-mask, this range is guaranteed to live above
 * the dma-xor-limit.
 */
#define BCM3384_MEM_HOLE_PA	0x10000000
#define BCM3384_MEM_HOLE_SIZE	0x10000000

static dma_addr_t bcm3384_phys_to_dma(struct device *dev, phys_addr_t pa)
{
	if (dev && dev_is_pci(dev) &&
	    pa >= (BCM3384_MEM_HOLE_PA + BCM3384_MEM_HOLE_SIZE))
		return pa - BCM3384_MEM_HOLE_SIZE;
	if (pa <= bcm3384_dma_xor_limit)
		return pa ^ bcm3384_dma_xor_mask;
	return pa;
}

dma_addr_t plat_map_dma_mem(struct device *dev, void *addr, size_t size)
{
	return bcm3384_phys_to_dma(dev, virt_to_phys(addr));
}

dma_addr_t plat_map_dma_mem_page(struct device *dev, struct page *page)
{
	return bcm3384_phys_to_dma(dev, page_to_phys(page));
}

unsigned long plat_dma_addr_to_phys(struct device *dev, dma_addr_t dma_addr)
{
	if (dev && dev_is_pci(dev) &&
	    dma_addr >= BCM3384_MEM_HOLE_PA)
		return dma_addr + BCM3384_MEM_HOLE_SIZE;
	if ((dma_addr ^ bcm3384_dma_xor_mask) <= bcm3384_dma_xor_limit)
		return dma_addr ^ bcm3384_dma_xor_mask;
	return dma_addr;
}

static int __init bcm3384_init_dma_xor(void)
{
	struct device_node *np = of_find_node_by_type(NULL, "memory");

	if (!np)
		return 0;

	of_property_read_u32(np, "dma-xor-mask", &bcm3384_dma_xor_mask);
	of_property_read_u32(np, "dma-xor-limit", &bcm3384_dma_xor_limit);

	of_node_put(np);
	return 0;
}
arch_initcall(bcm3384_init_dma_xor);
Loading