Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Jan 2016 13:53:33 +0000 (UTC)
From:      Zbigniew Bodek <zbb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r294425 - in head/sys/arm/mv: . armada38x
Message-ID:  <201601201353.u0KDrX4C068312@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: zbb
Date: Wed Jan 20 13:53:33 2016
New Revision: 294425
URL: https://svnweb.freebsd.org/changeset/base/294425

Log:
  Set IO Sync Barrier flags for all Mbus devices on Armada38x
  
  IO Sync Barrier setting is required for I/O coherency.
  
  Reviewed by:   andrew, ian, imp
  Obtained from: Semihalf
  Sponsored by:  Stormshield
  Submitted by:  Michal Stanek <mst@semihalf.com>
  Differential revision:  https://reviews.freebsd.org/D4219

Modified:
  head/sys/arm/mv/armada38x/armada38x.c
  head/sys/arm/mv/mv_machdep.c
  head/sys/arm/mv/mvwin.h

Modified: head/sys/arm/mv/armada38x/armada38x.c
==============================================================================
--- head/sys/arm/mv/armada38x/armada38x.c	Wed Jan 20 13:51:14 2016	(r294424)
+++ head/sys/arm/mv/armada38x/armada38x.c	Wed Jan 20 13:53:33 2016	(r294425)
@@ -32,10 +32,14 @@ __FBSDID("$FreeBSD$");
 #include <sys/systm.h>
 #include <sys/bus.h>
 
+#include <machine/fdt.h>
+
 #include <arm/mv/mvwin.h>
 #include <arm/mv/mvreg.h>
 #include <arm/mv/mvvar.h>
 
+int armada38x_win_set_iosync_barrier(void);
+
 uint32_t
 get_tclk(void)
 {
@@ -52,3 +56,25 @@ get_tclk(void)
 	else
 		return (TCLK_200MHZ);
 }
+
+int
+armada38x_win_set_iosync_barrier(void)
+{
+	bus_space_handle_t vaddr_iowind;
+	int rv;
+
+	rv = bus_space_map(fdtbus_bs_tag, (bus_addr_t)MV_MBUS_BRIDGE_BASE,
+	    MV_CPU_SUBSYS_REGS_LEN, 0, &vaddr_iowind);
+	if (rv != 0)
+		return (rv);
+
+	/* Set Sync Barrier flags for all Mbus internal units */
+	bus_space_write_4(fdtbus_bs_tag, vaddr_iowind, MV_SYNC_BARRIER_CTRL,
+	    MV_SYNC_BARRIER_CTRL_ALL);
+
+	bus_space_barrier(fdtbus_bs_tag, vaddr_iowind, 0,
+	    MV_CPU_SUBSYS_REGS_LEN, BUS_SPACE_BARRIER_WRITE);
+	bus_space_unmap(fdtbus_bs_tag, vaddr_iowind, MV_CPU_SUBSYS_REGS_LEN);
+
+	return (rv);
+}

Modified: head/sys/arm/mv/mv_machdep.c
==============================================================================
--- head/sys/arm/mv/mv_machdep.c	Wed Jan 20 13:51:14 2016	(r294424)
+++ head/sys/arm/mv/mv_machdep.c	Wed Jan 20 13:53:33 2016	(r294425)
@@ -66,6 +66,9 @@ static int platform_mpp_init(void);
 void armadaxp_init_coher_fabric(void);
 void armadaxp_l2_init(void);
 #endif
+#if defined(SOC_MV_ARMADA38X)
+int armada38x_win_set_iosync_barrier(void);
+#endif
 
 #define MPP_PIN_MAX		68
 #define MPP_PIN_CELLS		2
@@ -249,6 +252,12 @@ platform_late_init(void)
 #endif
 	armadaxp_l2_init();
 #endif
+
+#if defined(SOC_MV_ARMADA38X)
+	/* Set IO Sync Barrier bit for all Mbus devices */
+	if (armada38x_win_set_iosync_barrier() != 0)
+		printf("WARNING: could not map CPU Subsystem registers\n");
+#endif
 }
 
 #define FDT_DEVMAP_MAX	(MV_WIN_CPU_MAX + 2)

Modified: head/sys/arm/mv/mvwin.h
==============================================================================
--- head/sys/arm/mv/mvwin.h	Wed Jan 20 13:51:14 2016	(r294424)
+++ head/sys/arm/mv/mvwin.h	Wed Jan 20 13:53:33 2016	(r294425)
@@ -305,6 +305,16 @@
 #define	MV_WIN_SATA_BASE(n)		(0x10 * (n) + 0x34)
 #define	MV_WIN_SATA_MAX			4
 
+#if defined(SOC_MV_ARMADA38X)
+#define	MV_BOOTROM_MEM_ADDR	0xFFF00000
+#define	MV_BOOTROM_WIN_SIZE	0xF
+#define	MV_CPU_SUBSYS_REGS_LEN	0x100
+
+/* Internal Units Sync Barrier Control Register */
+#define	MV_SYNC_BARRIER_CTRL		0x84
+#define	MV_SYNC_BARRIER_CTRL_ALL	0xFFFF
+#endif
+
 #define WIN_REG_IDX_RD(pre,reg,off,base)					\
 	static __inline uint32_t						\
 	pre ## _ ## reg ## _read(int i)						\



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601201353.u0KDrX4C068312>