summaryrefslogtreecommitdiff
path: root/arch/arc
diff options
context:
space:
mode:
authorAlexey Brodkin <abrodkin@synopsys.com>2017-06-26 08:46:47 (GMT)
committerAlexey Brodkin <abrodkin@synopsys.com>2017-06-29 16:34:10 (GMT)
commit97a63144a906827ad7e3c4ef18d641c2765b1ebc (patch)
tree7dc31ffb5054b7dd728bdcf656909928d291d8b4 /arch/arc
parentef41e9d33e1ba524ef4bb0919959e2db92a2547c (diff)
downloadu-boot-fsl-qoriq-97a63144a906827ad7e3c4ef18d641c2765b1ebc.tar.xz
arcv2: Set IOC aperture so it covers available DDR
We used to use the same memory layout and size for a couple of boards and thus we just hardcoding IOC aperture start and size. Now when we're getting more boards with more memory on board we need to have an ability to set IOC so it matches real DDR layout and size. Even though it is not really a must but for simplicity we assume IOC covers all the DDR we have, that gives us a chance to not bother where DMA buffers are allocated - any part of DDR is OK. Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Diffstat (limited to 'arch/arc')
-rw-r--r--arch/arc/lib/cache.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/arch/arc/lib/cache.c b/arch/arc/lib/cache.c
index f1436bf..cbae27e 100644
--- a/arch/arc/lib/cache.c
+++ b/arch/arc/lib/cache.c
@@ -8,6 +8,7 @@
#include <common.h>
#include <linux/compiler.h>
#include <linux/kernel.h>
+#include <linux/log2.h>
#include <asm/arcregs.h>
#include <asm/cache.h>
@@ -215,17 +216,33 @@ void cache_init(void)
read_decode_cache_bcr_arcv2();
if (ioc_exists) {
+ /* IOC Aperture start is equal to DDR start */
+ unsigned int ap_base = CONFIG_SYS_SDRAM_BASE;
+ /* IOC Aperture size is equal to DDR size */
+ long ap_size = CONFIG_SYS_SDRAM_SIZE;
+
flush_dcache_all();
invalidate_dcache_all();
- /* IO coherency base - 0x8z */
- write_aux_reg(ARC_AUX_IO_COH_AP0_BASE, 0x80000);
- /* IO coherency aperture size - 512Mb: 0x8z-0xAz */
- write_aux_reg(ARC_AUX_IO_COH_AP0_SIZE, 0x11);
- /* Enable partial writes */
+ if (!is_power_of_2(ap_size) || ap_size < 4096)
+ panic("IOC Aperture size must be power of 2 and bigger 4Kib");
+
+ /*
+ * IOC Aperture size decoded as 2 ^ (SIZE + 2) KB,
+ * so setting 0x11 implies 512M, 0x12 implies 1G...
+ */
+ write_aux_reg(ARC_AUX_IO_COH_AP0_SIZE,
+ order_base_2(ap_size/1024) - 2);
+
+
+ /* IOC Aperture start must be aligned to the size of the aperture */
+ if (ap_base % ap_size != 0)
+ panic("IOC Aperture start must be aligned to the size of the aperture");
+
+ write_aux_reg(ARC_AUX_IO_COH_AP0_BASE, ap_base >> 12);
write_aux_reg(ARC_AUX_IO_COH_PARTIAL, 1);
- /* Enable IO coherency */
write_aux_reg(ARC_AUX_IO_COH_ENABLE, 1);
+
}
#endif
}