summaryrefslogtreecommitdiffstats
path: root/sys/arm
diff options
context:
space:
mode:
authorzbb <zbb@FreeBSD.org>2017-06-21 18:27:05 +0000
committerLuiz Souza <luiz@netgate.com>2017-09-06 11:56:44 -0500
commit611ac2d6672db236d44248dd06e1ccb80dfa8462 (patch)
tree40a35e394f2dee022450c7c6577e662859be742c /sys/arm
parent0772c4ad56d8693e76d49aab7ddf457dbb80113d (diff)
downloadFreeBSD-src-611ac2d6672db236d44248dd06e1ccb80dfa8462.zip
FreeBSD-src-611ac2d6672db236d44248dd06e1ccb80dfa8462.tar.gz
Create root DMA tag and fix MBUS windows on DMA coherent platforms
Armada 38x SoCs, in order to work properly in IO-coherent mode, requires an update of the MBUS windows attributesd. This patch also configures nexus coherent dma tag, because all busses and children devices have to inherit this setting in runtime. The latter has to be executed as a sysinit (SI_SUB_DRIVERS type), so that bus_dma_tag_create() can be executed properly. Submitted by: Michal Mazur <mkm@semihalf.com> Marcin Wojtas <mw@semihalf.com> Obtained from: Semihalf Sponsored by: Stormshield Reviewed by: ian Differential revision: https://reviews.freebsd.org/D11203 (cherry picked from commit 713a0a26db4493f96a2ce3200ce8429564246208)
Diffstat (limited to 'sys/arm')
-rw-r--r--sys/arm/mv/mv_common.c13
-rw-r--r--sys/arm/mv/mv_machdep.c36
2 files changed, 47 insertions, 2 deletions
diff --git a/sys/arm/mv/mv_common.c b/sys/arm/mv/mv_common.c
index d94ea37..21ca881 100644
--- a/sys/arm/mv/mv_common.c
+++ b/sys/arm/mv/mv_common.c
@@ -128,6 +128,7 @@ static uint32_t dev_mask = 0;
static int cpu_wins_no = 0;
static int eth_port = 0;
static int usb_port = 0;
+static boolean_t platform_io_coherent = false;
static struct decode_win cpu_win_tbl[MAX_CPU_WIN];
@@ -1078,7 +1079,7 @@ ddr_size(int i)
uint32_t
ddr_attr(int i)
{
- uint32_t dev, rev;
+ uint32_t dev, rev, attr;
soc_id(&dev, &rev);
if (dev == MV_DEV_88RC8180)
@@ -1086,10 +1087,14 @@ ddr_attr(int i)
if (dev == MV_DEV_88F6781)
return (0);
- return (i == 0 ? 0xe :
+ attr = (i == 0 ? 0xe :
(i == 1 ? 0xd :
(i == 2 ? 0xb :
(i == 3 ? 0x7 : 0xff))));
+ if (platform_io_coherent)
+ attr |= 0x10;
+
+ return (attr);
}
uint32_t
@@ -2493,6 +2498,10 @@ fdt_win_setup(void)
if (node == -1)
panic("fdt_win_setup: no root node");
+ /* Allow for coherent transactions on the A38x MBUS */
+ if (ofw_bus_node_is_compatible(node, "marvell,armada380"))
+ platform_io_coherent = true;
+
/*
* Traverse through all children of root and simple-bus nodes.
* For each found device retrieve decode windows data (if applicable).
diff --git a/sys/arm/mv/mv_machdep.c b/sys/arm/mv/mv_machdep.c
index d5315b2..e161d91 100644
--- a/sys/arm/mv/mv_machdep.c
+++ b/sys/arm/mv/mv_machdep.c
@@ -46,10 +46,13 @@ __FBSDID("$FreeBSD$");
#include <sys/systm.h>
#include <sys/bus.h>
#include <sys/devmap.h>
+#include <sys/kernel.h>
#include <vm/vm.h>
#include <vm/pmap.h>
+#include <arm/arm/nexusvar.h>
+
#include <machine/bus.h>
#include <machine/fdt.h>
#include <machine/machdep.h>
@@ -87,6 +90,39 @@ int armada38x_mbus_optimization(void);
#define MPP_SEL(pin,func) (((func) & 0xf) << \
(((pin) % MPP_PINS_PER_REG) * 4))
+static void
+mv_busdma_tag_init(void *arg __unused)
+{
+ phandle_t node;
+ bus_dma_tag_t dmat;
+
+ /*
+ * If this platform has coherent DMA, create the parent DMA tag to pass
+ * down the coherent flag to all busses and devices on the platform,
+ * otherwise return without doing anything. By default create tag
+ * for all A38x-based platforms only.
+ */
+ if ((node = OF_finddevice("/")) == -1)
+ return;
+ if (ofw_bus_node_is_compatible(node, "marvell,armada380") == 0)
+ return;
+
+ bus_dma_tag_create(NULL, /* No parent tag */
+ 1, 0, /* alignment, bounds */
+ BUS_SPACE_MAXADDR, /* lowaddr */
+ BUS_SPACE_MAXADDR, /* highaddr */
+ NULL, NULL, /* filter, filterarg */
+ BUS_SPACE_MAXSIZE, /* maxsize */
+ BUS_SPACE_UNRESTRICTED, /* nsegments */
+ BUS_SPACE_MAXSIZE, /* maxsegsize */
+ BUS_DMA_COHERENT, /* flags */
+ NULL, NULL, /* lockfunc, lockarg */
+ &dmat);
+
+ nexus_set_dma_tag(dmat);
+}
+SYSINIT(mv_busdma_tag, SI_SUB_DRIVERS, SI_ORDER_ANY, mv_busdma_tag_init, NULL);
+
static int
platform_mpp_init(void)
{
OpenPOWER on IntegriCloud