<p>Patrick Rudolph has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/25371">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">soc/cavium: Enable MMU<br><br>* Configure and enable MMU.<br>* Use secure mem attribute as firmware is running in ARM TZ region.<br>* Increase TTB size to fit all page tables<br><br>Tested on Cavium SoC.<br><br>Change-Id: I969446da62b4cc7adf9393fab69ff84ebf49220d<br>Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com><br>---<br>M src/mainboard/cavium/cn8100_sff_evb/romstage.c<br>M src/soc/cavium/cn81xx/Makefile.inc<br>M src/soc/cavium/cn81xx/include/soc/memlayout.ld<br>A src/soc/cavium/cn81xx/include/soc/mmu.h<br>A src/soc/cavium/cn81xx/mmu.c<br>5 files changed, 70 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/71/25371/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/mainboard/cavium/cn8100_sff_evb/romstage.c b/src/mainboard/cavium/cn8100_sff_evb/romstage.c</span><br><span>index b466abb..4cf8f09 100644</span><br><span>--- a/src/mainboard/cavium/cn8100_sff_evb/romstage.c</span><br><span>+++ b/src/mainboard/cavium/cn8100_sff_evb/romstage.c</span><br><span>@@ -20,6 +20,7 @@</span><br><span> #include <romstage_handoff.h></span><br><span> #include <soc/sdram.h></span><br><span> #include <soc/timer.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <soc/mmu.h></span><br><span> #include <stdlib.h></span><br><span> #include <console/console.h></span><br><span> #include <program_loading.h></span><br><span>@@ -32,6 +33,7 @@</span><br><span>   exception_init();</span><br><span> </span><br><span>        sdram_init();</span><br><span style="color: hsl(120, 100%, 40%);">+ soc_mmu_init();</span><br><span> </span><br><span>  watchdog_poke(0);</span><br><span> </span><br><span>diff --git a/src/soc/cavium/cn81xx/Makefile.inc b/src/soc/cavium/cn81xx/Makefile.inc</span><br><span>index d4fc57d..aac09a0 100644</span><br><span>--- a/src/soc/cavium/cn81xx/Makefile.inc</span><br><span>+++ b/src/soc/cavium/cn81xx/Makefile.inc</span><br><span>@@ -40,6 +40,8 @@</span><br><span> romstage-$(CONFIG_DRIVERS_UART) += uart.c</span><br><span> romstage-y += l2c.c</span><br><span> romstage-y += sdram.c</span><br><span style="color: hsl(120, 100%, 40%);">+romstage-y += mmu.c</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> romstage-y += ../common/cbmem.c</span><br><span> romstage-y += ../common/lame_string.c</span><br><span> romstage-y += ../common/bdk/libbdk-arch/bdk-csr.c</span><br><span>diff --git a/src/soc/cavium/cn81xx/include/soc/memlayout.ld b/src/soc/cavium/cn81xx/include/soc/memlayout.ld</span><br><span>index cf43c51..fbbe665 100644</span><br><span>--- a/src/soc/cavium/cn81xx/include/soc/memlayout.ld</span><br><span>+++ b/src/soc/cavium/cn81xx/include/soc/memlayout.ld</span><br><span>@@ -40,8 +40,9 @@</span><br><span> #if ENV_RAMSTAGE</span><br><span>     STACK(0x2000000, 16K)</span><br><span>        TIMESTAMP(0x2004000, 4K)</span><br><span style="color: hsl(0, 100%, 40%);">-        TTB(0x2005000, 44K)</span><br><span style="color: hsl(0, 100%, 40%);">-     RAMSTAGE(0x2010000, 512K)</span><br><span> #endif</span><br><span style="color: hsl(120, 100%, 40%);">+   TTB(0x2005000, 108K)</span><br><span style="color: hsl(120, 100%, 40%);">+  RAMSTAGE(0x2020000, 512K)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span>  POSTRAM_CBFS_CACHE(0x3000000, 16M)</span><br><span> }</span><br><span>diff --git a/src/soc/cavium/cn81xx/include/soc/mmu.h b/src/soc/cavium/cn81xx/include/soc/mmu.h</span><br><span>new file mode 100644</span><br><span>index 0000000..9b811c3</span><br><span>--- /dev/null</span><br><span>+++ b/src/soc/cavium/cn81xx/include/soc/mmu.h</span><br><span>@@ -0,0 +1,21 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * This file is part of the coreboot project.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright 2017-present Facebook, Inc.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; version 2 of the License.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#ifndef __SOC_CAVIUM_CN81XX_INCLUDE_SOC_MMU_H</span><br><span style="color: hsl(120, 100%, 40%);">+#define __SOC_CAVIUM_CN81XX_INCLUDE_SOC_MMU_H</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void soc_mmu_init(void);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#endif  /* ! __SOC_CAVIUM_CN81XX_INCLUDE_SOC_MMU_H */</span><br><span>diff --git a/src/soc/cavium/cn81xx/mmu.c b/src/soc/cavium/cn81xx/mmu.c</span><br><span>new file mode 100644</span><br><span>index 0000000..7a77329</span><br><span>--- /dev/null</span><br><span>+++ b/src/soc/cavium/cn81xx/mmu.c</span><br><span>@@ -0,0 +1,42 @@</span><br><span style="color: hsl(120, 100%, 40%);">+/*</span><br><span style="color: hsl(120, 100%, 40%);">+ * This file is part of the coreboot project.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright 2015 MediaTek Inc.</span><br><span style="color: hsl(120, 100%, 40%);">+ * Copyright 2018-present Facebook, Inc.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is free software; you can redistribute it and/or modify</span><br><span style="color: hsl(120, 100%, 40%);">+ * it under the terms of the GNU General Public License as published by</span><br><span style="color: hsl(120, 100%, 40%);">+ * the Free Software Foundation; version 2 of the License.</span><br><span style="color: hsl(120, 100%, 40%);">+ *</span><br><span style="color: hsl(120, 100%, 40%);">+ * This program is distributed in the hope that it will be useful,</span><br><span style="color: hsl(120, 100%, 40%);">+ * but WITHOUT ANY WARRANTY; without even the implied warranty of</span><br><span style="color: hsl(120, 100%, 40%);">+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span><br><span style="color: hsl(120, 100%, 40%);">+ * GNU General Public License for more details.</span><br><span style="color: hsl(120, 100%, 40%);">+ */</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#include <symbols.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <soc/addressmap.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <soc/mmu.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <soc/sdram.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <arch/mmu.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void soc_mmu_init(void)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+   const unsigned long devmem = MA_DEV | MA_S | MA_RW;</span><br><span style="color: hsl(120, 100%, 40%);">+   const unsigned long secure_mem = MA_MEM | MA_S | MA_RW;</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+     mmu_init();</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+ /*</span><br><span style="color: hsl(120, 100%, 40%);">+     * Need to use secure mem attribute, as firmware is running in ARM TZ</span><br><span style="color: hsl(120, 100%, 40%);">+  * region.</span><br><span style="color: hsl(120, 100%, 40%);">+     */</span><br><span style="color: hsl(120, 100%, 40%);">+   mmu_config_range((void *)_ttb, _ttb_size, secure_mem);</span><br><span style="color: hsl(120, 100%, 40%);">+        mmu_config_range((void *)_dram,</span><br><span style="color: hsl(120, 100%, 40%);">+                        ((uintptr_t)_dram + sdram_size_mb() * MiB),</span><br><span style="color: hsl(120, 100%, 40%);">+                   secure_mem);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+       mmu_config_range((void *)0x800000000000ULL, 0x80000000000ULL, devmem);</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+      mmu_enable();</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span></span><br></pre><p>To view, visit <a href="https://review.coreboot.org/25371">change 25371</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://review.coreboot.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://review.coreboot.org/25371"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: coreboot </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: I969446da62b4cc7adf9393fab69ff84ebf49220d </div>
<div style="display:none"> Gerrit-Change-Number: 25371 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Patrick Rudolph <patrick.rudolph@9elements.com> </div>