aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/embedded6xx
diff options
context:
space:
mode:
authorAlbert Herranz <albert_herranz@yahoo.es>2009-12-12 01:31:53 -0500
committerGrant Likely <grant.likely@secretlab.ca>2009-12-13 00:24:31 -0500
commitde32400dd26e743c5d500aa42d8d6818b79edb73 (patch)
tree5fee868e4fac044dca4fb3a18532b67b62c90c96 /arch/powerpc/platforms/embedded6xx
parent02d748a9ee56735641bade9b734dc2fa9be4df4c (diff)
wii: use both mem1 and mem2 as ram
The Nintendo Wii video game console has two discontiguous RAM regions: - MEM1: 24MB @ 0x00000000 - MEM2: 64MB @ 0x10000000 Unfortunately, the kernel currently does not support discontiguous RAM memory regions on 32-bit PowerPC platforms. This patch adds a series of workarounds to allow the use of the second memory region (MEM2) as RAM by the kernel. Basically, a single range of memory from the beginning of MEM1 to the end of MEM2 is reported to the kernel, and a memory reservation is created for the hole between MEM1 and MEM2. With this patch the system is able to use all the available RAM and not just ~27% of it. This will no longer be needed when proper discontig memory support for 32-bit PowerPC is added to the kernel. Signed-off-by: Albert Herranz <albert_herranz@yahoo.es> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'arch/powerpc/platforms/embedded6xx')
-rw-r--r--arch/powerpc/platforms/embedded6xx/wii.c63
1 files changed, 63 insertions, 0 deletions
diff --git a/arch/powerpc/platforms/embedded6xx/wii.c b/arch/powerpc/platforms/embedded6xx/wii.c
index 1bd41cc8039d..de0c1e397c99 100644
--- a/arch/powerpc/platforms/embedded6xx/wii.c
+++ b/arch/powerpc/platforms/embedded6xx/wii.c
@@ -20,6 +20,8 @@
20#include <linux/seq_file.h> 20#include <linux/seq_file.h>
21#include <linux/kexec.h> 21#include <linux/kexec.h>
22#include <linux/of_platform.h> 22#include <linux/of_platform.h>
23#include <linux/lmb.h>
24#include <mm/mmu_decl.h>
23 25
24#include <asm/io.h> 26#include <asm/io.h>
25#include <asm/machdep.h> 27#include <asm/machdep.h>
@@ -52,6 +54,67 @@
52static void __iomem *hw_ctrl; 54static void __iomem *hw_ctrl;
53static void __iomem *hw_gpio; 55static void __iomem *hw_gpio;
54 56
57unsigned long wii_hole_start;
58unsigned long wii_hole_size;
59
60
61static int __init page_aligned(unsigned long x)
62{
63 return !(x & (PAGE_SIZE-1));
64}
65
66void __init wii_memory_fixups(void)
67{
68 struct lmb_property *p = lmb.memory.region;
69
70 /*
71 * This is part of a workaround to allow the use of two
72 * discontiguous RAM ranges on the Wii, even if this is
73 * currently unsupported on 32-bit PowerPC Linux.
74 *
75 * We coealesce the two memory ranges of the Wii into a
76 * single range, then create a reservation for the "hole"
77 * between both ranges.
78 */
79
80 BUG_ON(lmb.memory.cnt != 2);
81 BUG_ON(!page_aligned(p[0].base) || !page_aligned(p[1].base));
82
83 p[0].size = _ALIGN_DOWN(p[0].size, PAGE_SIZE);
84 p[1].size = _ALIGN_DOWN(p[1].size, PAGE_SIZE);
85
86 wii_hole_start = p[0].base + p[0].size;
87 wii_hole_size = p[1].base - wii_hole_start;
88
89 pr_info("MEM1: <%08llx %08llx>\n", p[0].base, p[0].size);
90 pr_info("HOLE: <%08lx %08lx>\n", wii_hole_start, wii_hole_size);
91 pr_info("MEM2: <%08llx %08llx>\n", p[1].base, p[1].size);
92
93 p[0].size += wii_hole_size + p[1].size;
94
95 lmb.memory.cnt = 1;
96 lmb_analyze();
97
98 /* reserve the hole */
99 lmb_reserve(wii_hole_start, wii_hole_size);
100}
101
102unsigned long __init wii_mmu_mapin_mem2(unsigned long top)
103{
104 unsigned long delta, size, bl;
105 unsigned long max_size = (256<<20);
106
107 /* MEM2 64MB@0x10000000 */
108 delta = wii_hole_start + wii_hole_size;
109 size = top - delta;
110 for (bl = 128<<10; bl < max_size; bl <<= 1) {
111 if (bl * 2 > size)
112 break;
113 }
114 setbat(4, PAGE_OFFSET+delta, delta, bl, PAGE_KERNEL_X);
115 return delta + bl;
116}
117
55static void wii_spin(void) 118static void wii_spin(void)
56{ 119{
57 local_irq_disable(); 120 local_irq_disable();