ARCv2: IOC: Use actual memory size to setup aperture size
authorVineet Gupta <vgupta@synopsys.com>
Wed, 18 Jan 2017 20:59:21 +0000 (12:59 -0800)
committerVineet Gupta <vgupta@synopsys.com>
Wed, 18 Jan 2017 22:52:43 +0000 (14:52 -0800)
vs. fixed 512M before.

But this still assumes that all of memory is under IOC which may not be
true for the SoC. Improve that later when this becomes a real issue, by
specifying this from DT.

Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
arch/arc/include/asm/setup.h
arch/arc/mm/cache.c
arch/arc/mm/init.c

index cb954cdab07087bc6b49e72c8d117c77b905595c..c568a9df82b1a397d73d3fa3c0c523804a2856f2 100644 (file)
@@ -31,6 +31,7 @@ extern int root_mountflags, end_mem;
 
 void setup_processor(void);
 void __init setup_arch_memory(void);
+long __init arc_get_mem_sz(void);
 
 /* Helpers used in arc_*_mumbojumbo routines */
 #define IS_AVAIL1(v, s)                ((v) ? s : "")
index 1b4cda10844a1df7ff9f0c41c8b1ab4abfe7aade..3c275a81528c77ebaedd3b8900cc336f1892c4ed 100644 (file)
@@ -995,6 +995,8 @@ SYSCALL_DEFINE3(cacheflush, uint32_t, start, uint32_t, sz, uint32_t, flags)
  */
 noinline void arc_ioc_setup(void)
 {
+       unsigned int ap_sz;
+
        /* Flush + invalidate + disable L1 dcache */
        __dc_disable();
 
@@ -1005,8 +1007,14 @@ noinline void arc_ioc_setup(void)
        /* IOC Aperture start: TDB: handle non default CONFIG_LINUX_LINK_BASE */
        write_aux_reg(ARC_REG_IO_COH_AP0_BASE, 0x80000);
 
-       /* IOC Aperture size: TBD: handle different mem sizes, PAE... */
-       write_aux_reg(ARC_REG_IO_COH_AP0_SIZE, 0x11);
+       /*
+        * IOC Aperture size:
+        *   decoded as 2 ^ (SIZE + 2) KB: so setting 0x11 implies 512M
+        * TBD: fix for PGU + 1GB of low mem
+        * TBD: fix for PAE
+        */
+       ap_sz = order_base_2(arc_get_mem_sz()/1024) - 2;
+       write_aux_reg(ARC_REG_IO_COH_AP0_SIZE, ap_sz);
 
        write_aux_reg(ARC_REG_IO_COH_PARTIAL, 1);
        write_aux_reg(ARC_REG_IO_COH_ENABLE, 1);
index 399e2f223d25303f1294c35b52862e584fbcb1eb..8c9415ed62804d0a8b4a35df176f1b43e6c1be44 100644 (file)
@@ -40,6 +40,11 @@ struct pglist_data node_data[MAX_NUMNODES] __read_mostly;
 EXPORT_SYMBOL(node_data);
 #endif
 
+long __init arc_get_mem_sz(void)
+{
+       return low_mem_sz;
+}
+
 /* User can over-ride above with "mem=nnn[KkMm]" in cmdline */
 static int __init setup_mem_sz(char *str)
 {