<p>Philipp Hug has uploaded this change for <strong>review</strong>.</p><p><a href="https://review.coreboot.org/27434">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">uart/sifive: provide a monotonic timer using CLINT timer register<br><br>Makes it possible to use the generic udelay.<br><br>Change-Id: I5139601226e6f89da69e302a10f2fb56b4b24f38<br>Signed-off-by: Philipp Hug <philipp@hug.cx><br>---<br>M src/arch/riscv/misc.c<br>M src/soc/sifive/fu540/Kconfig<br>M src/soc/sifive/fu540/Makefile.inc<br>A src/soc/sifive/fu540/timer.c<br>4 files changed, 29 insertions(+), 4 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://review.coreboot.org:29418/coreboot refs/changes/34/27434/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/src/arch/riscv/misc.c b/src/arch/riscv/misc.c</span><br><span>index 65b8ecf..1909dbc 100644</span><br><span>--- a/src/arch/riscv/misc.c</span><br><span>+++ b/src/arch/riscv/misc.c</span><br><span>@@ -16,7 +16,3 @@</span><br><span> void init_timer(void)</span><br><span> {</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">-</span><br><span style="color: hsl(0, 100%, 40%);">-void udelay(unsigned int n)</span><br><span style="color: hsl(0, 100%, 40%);">-{</span><br><span style="color: hsl(0, 100%, 40%);">-}</span><br><span>diff --git a/src/soc/sifive/fu540/Kconfig b/src/soc/sifive/fu540/Kconfig</span><br><span>index d247c28..4db34f7 100644</span><br><span>--- a/src/soc/sifive/fu540/Kconfig</span><br><span>+++ b/src/soc/sifive/fu540/Kconfig</span><br><span>@@ -20,6 +20,8 @@</span><br><span>         select ARCH_RAMSTAGE_RISCV</span><br><span>   select BOOTBLOCK_CONSOLE</span><br><span>     select DRIVERS_UART_SIFIVE</span><br><span style="color: hsl(120, 100%, 40%);">+    select HAVE_MONOTONIC_TIMER</span><br><span style="color: hsl(120, 100%, 40%);">+   select GENERIC_UDELAY</span><br><span> </span><br><span> if SOC_SIFIVE_FU540</span><br><span> </span><br><span>diff --git a/src/soc/sifive/fu540/Makefile.inc b/src/soc/sifive/fu540/Makefile.inc</span><br><span>index 8a2f3a6..4ac080b 100644</span><br><span>--- a/src/soc/sifive/fu540/Makefile.inc</span><br><span>+++ b/src/soc/sifive/fu540/Makefile.inc</span><br><span>@@ -19,10 +19,12 @@</span><br><span> </span><br><span> romstage-y += uart.c</span><br><span> romstage-y += media.c</span><br><span style="color: hsl(120, 100%, 40%);">+romstage-y += timer.c</span><br><span> </span><br><span> ramstage-y += uart.c</span><br><span> ramstage-y += media.c</span><br><span> ramstage-y += cbmem.c</span><br><span style="color: hsl(120, 100%, 40%);">+ramstage-y += timer.c</span><br><span> </span><br><span> CPPFLAGS_common += -Isrc/soc/sifive/fu540/include</span><br><span> </span><br><span>diff --git a/src/soc/sifive/fu540/timer.c b/src/soc/sifive/fu540/timer.c</span><br><span>new file mode 100644</span><br><span>index 0000000..57afc88</span><br><span>--- /dev/null</span><br><span>+++ b/src/soc/sifive/fu540/timer.c</span><br><span>@@ -0,0 +1,25 @@</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 2018 Philipp Hug <philipp@hug.cx></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 <arch/io.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <arch/encoding.h></span><br><span style="color: hsl(120, 100%, 40%);">+#include <timer.h></span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+#define CLINT_MTIME CLINT_BASE + 0xbff8</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+void timer_monotonic_get(struct mono_time *mt)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+      mono_time_set_usecs(mt, read32((void *)(CLINT_MTIME)));</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/27434">change 27434</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/27434"/><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: I5139601226e6f89da69e302a10f2fb56b4b24f38 </div>
<div style="display:none"> Gerrit-Change-Number: 27434 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Philipp Hug <philipp@hug.cx> </div>