aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/netlogic/xlp/nlm_hal.c
diff options
context:
space:
mode:
authorJayachandran C <jchandra@broadcom.com>2013-08-21 10:01:29 -0400
committerRalf Baechle <ralf@linux-mips.org>2013-09-03 17:22:18 -0400
commita2ba6cd6e65bf96059632ed2fe48a7a0f5aea472 (patch)
treee6a04a3eed22d430ebcb84b6f0d68164211b8bab /arch/mips/netlogic/xlp/nlm_hal.c
parent2c4f1ac5623750e715ae2a5fc7e0569999b9bfc5 (diff)
MIPS: Netlogic: Read memory from DRAM BARs
Read the memory from the Bridge DRAM BARs, if it is not passed in from the device tree. This will allow us to remove memory configuration from built in device trees. Signed-off-by: Jayachandran C <jchandra@broadcom.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/5743/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/netlogic/xlp/nlm_hal.c')
-rw-r--r--arch/mips/netlogic/xlp/nlm_hal.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/arch/mips/netlogic/xlp/nlm_hal.c b/arch/mips/netlogic/xlp/nlm_hal.c
index 87560e4db35f..6f2c21008ddb 100644
--- a/arch/mips/netlogic/xlp/nlm_hal.c
+++ b/arch/mips/netlogic/xlp/nlm_hal.c
@@ -44,6 +44,7 @@
44#include <asm/netlogic/haldefs.h> 44#include <asm/netlogic/haldefs.h>
45#include <asm/netlogic/xlp-hal/iomap.h> 45#include <asm/netlogic/xlp-hal/iomap.h>
46#include <asm/netlogic/xlp-hal/xlp.h> 46#include <asm/netlogic/xlp-hal/xlp.h>
47#include <asm/netlogic/xlp-hal/bridge.h>
47#include <asm/netlogic/xlp-hal/pic.h> 48#include <asm/netlogic/xlp-hal/pic.h>
48#include <asm/netlogic/xlp-hal/sys.h> 49#include <asm/netlogic/xlp-hal/sys.h>
49 50
@@ -142,3 +143,37 @@ unsigned int nlm_get_cpu_frequency(void)
142{ 143{
143 return nlm_get_core_frequency(0, 0); 144 return nlm_get_core_frequency(0, 0);
144} 145}
146
147/*
148 * Fills upto 8 pairs of entries containing the DRAM map of a node
149 * if n < 0, get dram map for all nodes
150 */
151int xlp_get_dram_map(int n, uint64_t *dram_map)
152{
153 uint64_t bridgebase, base, lim;
154 uint32_t val;
155 int i, node, rv;
156
157 /* Look only at mapping on Node 0, we don't handle crazy configs */
158 bridgebase = nlm_get_bridge_regbase(0);
159 rv = 0;
160 for (i = 0; i < 8; i++) {
161 val = nlm_read_bridge_reg(bridgebase,
162 BRIDGE_DRAM_NODE_TRANSLN(i));
163 node = (val >> 1) & 0x3;
164 if (n >= 0 && n != node)
165 continue;
166 val = nlm_read_bridge_reg(bridgebase, BRIDGE_DRAM_BAR(i));
167 val = (val >> 12) & 0xfffff;
168 base = (uint64_t) val << 20;
169 val = nlm_read_bridge_reg(bridgebase, BRIDGE_DRAM_LIMIT(i));
170 val = (val >> 12) & 0xfffff;
171 if (val == 0) /* BAR not used */
172 continue;
173 lim = ((uint64_t)val + 1) << 20;
174 dram_map[rv] = base;
175 dram_map[rv + 1] = lim;
176 rv += 2;
177 }
178 return rv;
179}